Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 010670e365eac4bfdf0087ea1c497c2e > files > 80

gauche-0.9.3.2-1.fc15.i686.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>) ::<mqueue>
  (expr "new MQueue(name)"))

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

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

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

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

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

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