[cells-devel] Problem with defmd and dependency ...
Hi Kenny (and all on the list): I have a simple defmd: (defmd gnc-point () (x (c-in 0)) (y (c-in 0)) (z (c-in 0)) (foreign-ptr (c_? (let ((ptr (or (^foreign-ptr) (fgn-alloc 'glInt 3 :gnc-point)))) (when ptr (setf (eltgli ptr 0) (^x)) (setf (eltgli ptr 1) (^y)) (setf (eltgli ptr 2) (^z))) ptr)))) This is a model for a point ( x | y | z ) and a foreign object pointer. The pointer shall be set to a an FFI memory pointer (via CFFI) when the instance is created. Also, the elements of the memory array (which is 3 glInt, this being three OpenGL Integers) shall be updated when any of the coordinates x y z is changed... I get x, y, and z updated but the foreign-ptr remains NIL ... What am I doing wrong ??? Thx! Frank
Correct problem case: I defined the foreign-ptr cell as lazy (as :until-asked) for a reason ... -> 0> 7612 calculating cell ~a appears in call stack: ~a dirty=0/ foreign-ptr/gnc-point0] dirty=0/foreign-ptr/gnc-point0] (dirty=0/foreign-ptr/gnc-point0]) ... landing in a (break) ... Ok. So I am basically looking for an idiom on how to avoid the circularity. I sense there is a simple solution but ... Oh my. It's been a long day ;-) Frank Am 29.08.2007 um 21:35 schrieb Frank Goenninger:
* PGP Signed: 08/29/07 at 21:35:14
Hi Kenny (and all on the list):
I have a simple defmd:
(defmd gnc-point () (x (c-in 0)) (y (c-in 0)) (z (c-in 0)) (foreign-ptr (c_? (let ((ptr (or (^foreign-ptr) (fgn-alloc 'glInt 3 :gnc-point)))) (when ptr (setf (eltgli ptr 0) (^x)) (setf (eltgli ptr 1) (^y)) (setf (eltgli ptr 2) (^z))) ptr))))
This is a model for a point ( x | y | z ) and a foreign object pointer. The pointer shall be set to a an FFI memory pointer (via CFFI) when the instance is created. Also, the elements of the memory array (which is 3 glInt, this being three OpenGL Integers) shall be updated when any of the coordinates x y z is changed...
I get x, y, and z updated but the foreign-ptr remains NIL ... What am I doing wrong ???
Thx!
Frank
* Frank Goenninger<frgo@mac.com> * 0xED320F02:0x05AE0907 _______________________________________________ cells-devel site list cells-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cells-devel
* PGP Signed: 08/29/07 at 21:35:14 * text/plain body * Frank Goenninger<frgo@mac.com> * 0xED320F02:0x05AE0907
Solved: (defmd gnc-point () (x (c-in 0)) (y (c-in 0)) (z (c-in 0)) (foreign-ptr (c-in (fgn-alloc 'glInt 3 :gnc-point)))) (defobserver x ((self gnc-point)) (with-integrity (:change self) (let ((ptr (^foreign-ptr))) (if ptr (setf (eltgli ptr 0) (^x)) (error "OBSERVER X OF ~S: FOREIGN-PTR is NIL (Foreign memory not available)" self))))) (defobserver y ((self gnc-point)) (with-integrity (:change self) (let ((ptr (^foreign-ptr))) (if ptr (setf (eltgli ptr 1) (^y)) (error "OBSERVER Y OF ~S: FOREIGN-PTR is NIL (Foreign memory not available)" self))))) (defobserver z ((self gnc-point)) (with-integrity (:change self) (let ((ptr (^foreign-ptr))) (if ptr (setf (eltgli ptr 2) (^z)) (error "OBSERVER Z OF ~S: FOREIGN-PTR is NIL (Foreign memory not available)" self))))) ... A bit more complex but works ;-) Frank Am 29.08.2007 um 21:50 schrieb Frank Goenninger: > * PGP Signed: 08/29/07 at 21:50:08 > > Correct problem case: > > I defined the foreign-ptr cell as lazy (as :until-asked) for a > reason ... -> > > 0> 7612 calculating cell ~a appears in call stack: ~a dirty=0/ > foreign-ptr/gnc-point0] dirty=0/foreign-ptr/gnc-point0] > (dirty=0/foreign-ptr/gnc-point0]) > > ... landing in a (break) ... > > Ok. So I am basically looking for an idiom on how to avoid the > circularity. I sense there is a simple solution but ... > > Oh my. It's been a long day ;-) > > Frank > > > Am 29.08.2007 um 21:35 schrieb Frank Goenninger: > >> > Old Signed: 08/29/07 at 21:35:14 >> >> Hi Kenny (and all on the list): >> >> I have a simple defmd: >> >> (defmd gnc-point () >> (x (c-in 0)) >> (y (c-in 0)) >> (z (c-in 0)) >> (foreign-ptr (c_? (let ((ptr (or (^foreign-ptr) (fgn-alloc 'glInt >> 3 :gnc-point)))) >> (when ptr >> (setf (eltgli ptr 0) (^x)) >> (setf (eltgli ptr 1) (^y)) >> (setf (eltgli ptr 2) (^z))) >> ptr)))) >> >> >> This is a model for a point ( x | y | z ) and a foreign object >> pointer. The pointer shall be set to a an FFI memory pointer (via >> CFFI) when the instance is created. Also, the elements of the >> memory array (which is 3 glInt, this being three OpenGL Integers) >> shall be updated when any of the coordinates x y z is changed... >> >> I get x, y, and z updated but the foreign-ptr remains NIL ... >> What am I doing wrong ??? >> >> Thx! >> >> Frank >> >> >> * Frank Goenninger<frgo@mac.com> >> * 0xED320F02:0x05AE0907 >> _______________________________________________ >> cells-devel site list >> cells-devel@common-lisp.net >> http://common-lisp.net/mailman/listinfo/cells-devel >> >> >> > Old Signed: 08/29/07 at 21:35:14 >> * text/plain body >> * Frank Goenninger<frgo@mac.com> >> * 0xED320F02:0x05AE0907 > > > * Frank Goenninger<frgo@mac.com> > * 0xED320F02:0x05AE0907 > _______________________________________________ > cells-devel site list > cells-devel@common-lisp.net > http://common-lisp.net/mailman/listinfo/cells-devel > > > * PGP Signed: 08/29/07 at 21:50:08 > * text/plain body > * Frank Goenninger<frgo@mac.com> > * 0xED320F02:0x05AE0907
Frank Goenninger wrote:
Correct problem case:
I defined the foreign-ptr cell as lazy (as :until-asked) for a reason ... ->
Lazy is one good step if you have confidence a slot will not get read (asked) until its dependencies will be in place.
0> 7612 calculating cell ~a appears in call stack: ~a dirty=0/ foreign-ptr/gnc-point0] dirty=0/foreign-ptr/gnc-point0] (dirty=0/foreign-ptr/gnc-point0])
... landing in a (break) ...
Ok. So I am basically looking for an idiom on how to avoid the circularity. I sense there is a simple solution
.cache or .cache., I forget. :) kt
Frank Goenninger wrote:
Hi Kenny (and all on the list):
I have a simple defmd:
(defmd gnc-point () (x (c-in 0)) (y (c-in 0)) (z (c-in 0)) (foreign-ptr (c_? (let ((ptr (or (^foreign-ptr) (fgn-alloc 'glInt 3 :gnc-point)))) (when ptr (setf (eltgli ptr 0) (^x)) (setf (eltgli ptr 1) (^y)) (setf (eltgli ptr 2) (^z))) ptr))))
This is a model for a point ( x | y | z ) and a foreign object pointer. The pointer shall be set to a an FFI memory pointer (via CFFI) when the instance is created. Also, the elements of the memory array (which is 3 glInt, this being three OpenGL Integers) shall be updated when any of the coordinates x y z is changed...
I get x, y, and z updated but the foreign-ptr remains NIL ... What am I doing wrong ???
Sorry, I was out for the day at the US Open Tennis tournament. I am just going to throw notes over the wall cuz no time to dig... Cells debugging issue: pretty sure you can turn on some global such as *c-debug* to have been warned earlier about referencing the cell in its own rule. I might even have made it a parameter to cells-reset. To do what you are trying to do, use (I think) the .cache symbol-macro (or is it .cache.?): (or .cache. (let ((ptr <allocate>)) (assert (and (^x)(^y)(^z))) (setf eo x e1 y e2 z))) Something like that. hth, kt
participants (2)
-
Frank Goenninger
-
Ken Tilton