Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 5a3d998cc00060c67a9a8d7f23c2d34c > files > 75

gauche-0.8.14-3.fc11.x86_64.rpm

;;;
;;; mqueue_lib.stub
;;;

"
#include \"mqueue_glue.h\"
"

;; Let the stub generator know about <mqueue> type.
;; The arguments of define-type are:
;;
;; (define-type 
;;    scheme-name    ;; Scheme class name
;;    c-type         ;; C type name when unboxed
;;    description    ;; used in error message 
;;    c-predicate    ;; bool c-predicate(ScmObj obj) - check whether
;;                   ;;   obj is the type.
;;    c-unbox        ;; c-type c-unbox(ScmObj obj) - unbox obj.
;;                   ;;   You can assume obj is of the type.
;;    c-box          ;; ScmObj c-box(c-type x) - box obj.
;;    )
;;
;; Note: when you use a foreign pointer class, care should be taken
;; if you want to save the unboxed value somewhere; since the ScmObj
;; that points to the unboxed value may be unreferenced after subr
;; call, you should be responsible to make sure the unboxed pointer
;; is visible from GC.
(define-type <mqueue> "MQueue*" "mqueue"
  "MQUEUE_P" "MQUEUE_UNBOX" "MQUEUE_BOX")

(define-cproc make-mqueue (name::<const-cstring>)
  (expr <mqueue> "new MQueue(name)"))

(define-cproc mqueue-find (name::<const-cstring>)
  (call <mqueue> "MQueue::findByName"))

(define-cproc mqueue-name (mq::<mqueue>)
  (expr <const-cstring> "mq->getName().c_str()"))

(define-cproc mqueue-empty? (mq::<mqueue>)
  (expr <boolean> "mq->empty()"))

(define-cproc mqueue-push! (mq::<mqueue> message::<const-cstring>
                                         &optional (urgency::<int> 0))
  (expr <int> "mq->pushMessage(message, urgency)"))

(define-cproc mqueue-pop! (mq::<mqueue>)
  (expr <const-cstring> "mq->popMessage().c_str()")
  (catch ("MQueueException& e"
          "Scm_Error(\"mqueue-pop!: %s\", e.reason.c_str());")))

;; Local variables:
;; mode: scheme
;; end: