Commits

Moritz Heidkamp committed 3561e4c

Remove zmq-prefix and more comprehensive errors

  • Participants
  • Parent commits dfaa954
  • Branches 3.2

Comments (0)

Files changed (2)

-(load-relative "../zmq.so")
-(load-relative "../zmq.import.so")
-(import zmq)
-(use test srfi-18 srfi-4)
+(use zmq test srfi-18 srfi-4)
 
 (test-group "contexts"
   (test-assert (context? (make-context 1)))
 (test-group "sockets"
 
   (test-group "default-context"
-    (test-assert (not (zmq-default-context)))
+    (test-assert (not (default-context)))
     (make-socket 'rep)
-    (test-assert (context? (zmq-default-context))))
+    (test-assert (context? (default-context))))
 
   (test-group "options"
     (let ((s (make-socket 'pull)))
 (module zmq 
 
-(zmq-io-threads
- zmq-default-context
- zmq-version
+(io-threads
+ default-context
+ version
  make-context
  terminate-context
  context?
 
 (define (zmq-error location)
   (let ((errno (foreign-value errno int)))
-    (error location 
-           ((foreign-lambda c-string zmq_strerror int) errno)
-           errno)))
+    (abort
+     (make-composite-condition
+      (make-property-condition 'exn
+                               'location location
+                               'message ((foreign-lambda c-string zmq_strerror int) errno))
+      (make-property-condition 'zmq
+                               'errno errno)))))
 
 (define (errno)
   (foreign-value errno errno))
 (define (type-error value expected-type)
   (error (format "expected ~A, got" value) expected-type))
 
-(define (zmq-version)
+(define (version)
   (let-location ((major int) (minor int) (patch int))
     ((foreign-lambda void zmq_version (c-pointer int) (c-pointer int) (c-pointer int))
      (location major) (location minor) (location patch))
 
 ;; contexts
 
-(define zmq-io-threads (make-parameter 1))
+(define io-threads (make-parameter 1))
 
-(define zmq-default-context (make-parameter #f))
+(define default-context (make-parameter #f))
 
-(define (zmq-default-context/initialize)
-  (or (zmq-default-context) 
-      (begin (zmq-default-context (make-context (zmq-io-threads)))
-             (zmq-default-context))))
+(define (default-context/initialize)
+  (or (default-context)
+      (begin (default-context (make-context (io-threads)))
+             (default-context))))
 
 (define %make-context make-context)
 
 
 (define %make-socket make-socket)
 
-(define (make-socket type #!optional (context (zmq-default-context/initialize)))
+(define (make-socket type #!optional (context (default-context/initialize)))
   (let ((sp ((foreign-lambda socket zmq_socket context socket-type)
              (context-pointer context) type)))
     (if (not sp)