[Openmcl-devel] Casting a FFI pointer
gb at clozure.com
Thu Aug 14 17:13:31 EDT 2003
On Thu, 14 Aug 2003, Kevin Rosenberg wrote:
> Today, I added a new macro named WITH-CAST-POINTER to UFFI based on
> Edi Weitz's patch. It allows the efficient one time type casting a
> pointer. Edi uses this to read an foreign object and write the
> contents as either a stream of characters or byte-sized numbers. I'd
> like to support this macro in OpenMCL.
> What's the best way to add support of this for OpenMCL?
IIRC, in CMUCL/SBCL an "ALIEN" is a little structure-like object that
describes a foreign object; it contains fields which describe the foreign
type of that object and, at least where pointers are involved, a "System
Area Pointer" (SAP) to the real underlying foreign object. (A SAP in
CMUCL/SBCL is almost exactly the same thing as a MACPTR in OpenMCL.)
>In SBCL, this macro looks like:
> (defmacro with-cast-pointer ((binding-name pointer type) &body body)
> `(let ((,binding-name
> (sb-alien:cast ,pointer
> (* ,(convert-from-uffi-type (eval type) :type)))))
> , at body))
Without discussing the merits/demerits of using an ALIEN-like
mechanism to access foreign objects, it doesn't make sense to try to
manipulate ALIEN-like things in implementations that (like OpenMCL)
don't use them.
> Thanks very much!
Openmcl-devel mailing list
Openmcl-devel at clozure.com
More information about the Openmcl-devel