[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Is there another way to return data from a C functio
From: |
Kon Lovett |
Subject: |
Re: [Chicken-users] Is there another way to return data from a C function? |
Date: |
Sun, 17 Jun 2007 18:52:20 -0700 |
On Jun 17, 2007, at 2:30 PM, Eduardo Cavazos wrote:
<snip>
Something else I had in mind was to make "foreign boxes":
(define (make-ulong-box)
(let-location ((val unsigned-long))
(lambda (op)
(case op
((get)
val)
((set)
(lambda (new-val)
(set! val new-val)))
((box)
(location val))))))
I made those for uinteger and integer as well, and compiled them
as "foreign-boxes.so".
Then I was able to use xquerypointer from csi as follows:
;; make the boxes
(define root (make-ulong-box))
(define child (make-ulong-box))
(define root-x (make-integer-box))
(define root-y (make-integer-box))
(define win-x (make-integer-box))
(define win-y (make-integer-box))
(define mask (make-uinteger-box))
;; call xquerypointer
(xquerypointer (dpy 'ptr)
((dpy 'default-root) 'id)
(root 'box)
(child 'box)
(root-x 'box)
(root-y 'box)
(win-x 'box)
(win-y 'box)
(mask 'box))
;; look at some box values
(list (win-x 'get)
(win-y 'get))
Ed
Thank you for the idea. I added something similar to the box egg:
(define root (make-box-location unsigned-long))
(box-ref root)
(box-set! root 0)
(box-location root)
Best Wishes,
Kon
_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users