Keith L. Downing | 20 Apr 22:56

Making C arrays in OpenMCL

As part of my graphics conversion from MCL to OpenMCL (which is actually going quite well), I'm trying touse a variety of line types: solid, dash, dash-dot, etc. I declare each type as a CL global variable, whichthen points to an object that houses, among other things, a pointer to a small C array that codes thespecification for the line type (as described in the "COCOA Drawing Guide" (pg. 75)). It's the pointer tothis array that then gets passed to Objective C for drawing the line (as part of a Bezier curve).
However, I'm having trouble creating these arrays in Objective C via the foreign-function interface. My impressionis that make-heap-ivector will do this for me, and it does seem to work when the element-type argumentis '(unsigned-byte 64), for example. But it doesn't seem to work when I use '(double-float 64). And itappears that the Obj-C drawing routines need a float array for the line-type specification.
Does anyone know if make-heap-ivector really works for all element types, or if there's a different list offoreign type keywords than those listed in the OpenMCL online documentation? Or maybe there's just a better way tocreate C arrays in OpenMCL? make-heap-ivector makes it LOOK so easy, but maybe it's not very general? So far, Ican't get it to work with any of the float types (single-float or double-float).
(defun make-heap-ivector (element-count element-type) (let* ((subtag (ccl::element-type-subtype element-type))) (unless (= (logand subtag target::fulltagmask) target::fulltag-immheader) (error "~s is not an ivector subtype." element-type)) (let* ((size-in-bytes (ccl::subtag-bytes subtag element-count))) (ccl::%make-heap-ivector subtag size-in-bytes element-count)))) MAKE-HEAP-IVECTOR
Cheers...
Keith Downing (who hopes to quietly recede into the shadows of this mailing list once this graphics conversion is complete) Trondheim, Norway
_______________________________________________
info-mcl mailing list
info-mcl@...
http://clozure.com/mailman/listinfo/info-mcl
Andrew Shalit | 21 Apr 17:49

Fwd: [info-mcl] Making C arrays in OpenMCL

Keith -- I'm glad to hear that your port is going well.  I'm taking the liberty of forwarding your message to the OpenMCL-Devel e-mail list, where it has more of a chance of being answered.

Andrew

Begin forwarded message:

From: "Keith L. Downing" <Keith.Downing <at> idi.ntnu.no>
Date: April 20, 2008 4:58:21 PM EDT
To: Discussion list for MCL users <info-mcl <at> clozure.com>
Subject: [info-mcl] Making C arrays in OpenMCL
Reply-To: Discussion list for MCL users <info-mcl <at> clozure.com>

As part of my graphics conversion from MCL to OpenMCL (which is actually going quite well), I'm trying touse a variety of line types: solid, dash, dash-dot, etc. I declare each type as a CL global variable, whichthen points to an object that houses, among other things, a pointer to a small C array that codes thespecification for the line type (as described in the "COCOA Drawing Guide" (pg. 75)). It's the pointer tothis array that then gets passed to Objective C for drawing the line (as part of a Bezier curve).
However, I'm having trouble creating these arrays in Objective C via the foreign-function interface. My impressionis that make-heap-ivector will do this for me, and it does seem to work when the element-type argumentis '(unsigned-byte 64), for example. But it doesn't seem to work when I use '(double-float 64). And itappears that the Obj-C drawing routines need a float array for the line-type specification.
Does anyone know if make-heap-ivector really works for all element types, or if there's a different list offoreign type keywords than those listed in the OpenMCL online documentation? Or maybe there's just a better way tocreate C arrays in OpenMCL? make-heap-ivector makes it LOOK so easy, but maybe it's not very general? So far, Ican't get it to work with any of the float types (single-float or double-float).
(defun make-heap-ivector (element-count element-type) (let* ((subtag (ccl::element-type-subtype element-type))) (unless (= (logand subtag target::fulltagmask) target::fulltag-immheader) (error "~s is not an ivector subtype." element-type)) (let* ((size-in-bytes (ccl::subtag-bytes subtag element-count))) (ccl::%make-heap-ivector subtag size-in-bytes element-count)))) MAKE-HEAP-IVECTOR
Cheers...
Keith Downing (who hopes to quietly recede into the shadows of this mailing list once this graphics conversion is complete) Trondheim, Norway
_______________________________________________
info-mcl mailing list
info-mcl <at> clozure.com
http://clozure.com/mailman/listinfo/info-mcl

_______________________________________________
Openmcl-devel mailing list
Openmcl-devel <at> clozure.com
http://clozure.com/mailman/listinfo/openmcl-devel
Ron Garret | 23 Apr 19:55

Re: Fwd: [info-mcl] Making C arrays in OpenMCL


On Apr 21, 2008, at 8:49 AM, Andrew Shalit wrote:

Keith -- I'm glad to hear that your port is going well.  I'm taking the liberty of forwarding your message to the OpenMCL-Devel e-mail list, where it has more of a chance of being answered.

Andrew

Begin forwarded message:

From: "Keith L. Downing" <Keith.Downing <at> idi.ntnu.no>
Date: April 20, 2008 4:58:21 PM EDT
To: Discussion list for MCL users <info-mcl <at> clozure.com>
Subject: [info-mcl] Making C arrays in OpenMCL
Reply-To: Discussion list for MCL users <info-mcl <at> clozure.com>

As part of my graphics conversion from MCL to OpenMCL (which is actually going quite well), I'm trying touse a variety of line types: solid, dash, dash-dot, etc. I declare each type as a CL global variable, whichthen points to an object that houses, among other things, a pointer to a small C array that codes thespecification for the line type (as described in the "COCOA Drawing Guide" (pg. 75)). It's the pointer tothis array that then gets passed to Objective C for drawing the line (as part of a Bezier curve).
However, I'm having trouble creating these arrays in Objective C via the foreign-function interface. My impressionis that make-heap-ivector will do this for me, and it does seem to work when the element-type argumentis '(unsigned-byte 64), for example. But it doesn't seem to work when I use '(double-float 64).

That's because there's no such type as (double-float 64).  Try this:

Welcome to Clozure Common Lisp Version 1.2-r9233M-RC1  (DarwinX8664)!
? (make-heap-ivector 10 'single-float)
#(0.0 3.2539062 0.0 3.2773437 1.835429E+29 4.5916347E-41 1.8354169E+29 4.5916347E-41 1.8230012E+29 4.5916347E-41)
#<A Foreign Pointer #xB90DF58>
40
? (make-heap-ivector 10 'double-float)
#(1.0D-323 2.964394D-318 6.953251193885D-310 0.0D0 0.0D0 0.0D0 0.0D0 0.0D0 0.0D0 -2.0000000000000013D0)
#<A Foreign Pointer #xB9267A8>
80

rg

_______________________________________________
Openmcl-devel mailing list
Openmcl-devel <at> clozure.com
http://clozure.com/mailman/listinfo/openmcl-devel

Gmane