[cffi-devel] Re: translate-type-from-foreign
Sean
rosssd at gmail.com
Fri Apr 13 10:41:21 UTC 2007
On Thu, 2007-04-12 at 17:40 +0100, Luis Oliveira wrote:
> Hmm. I tried to track this alleged removal, unsuccessfully. :-) Are you
> sure you didn't add that code yourself? I can't find this code in
> either 0.9.0 or 0.9.1.
<cough> <cough>, good catch. I swear one day I'll learn not to change
source code residing in asdf-install/site/ .
> In any case, you bring up a good point, which I've mentioned before too:
> <http://article.gmane.org/gmane.lisp.cffi.devel/1033>
>
> Using the cffi-newtypes branch (which I hope to merge soon, since there
> haven't been any complaints, unless James has any objections), you could
> do something like this:
>
> (defcstruct %my-struct ...)
>
> (define-foreign-type my-struct-type ()
> ()
> (:actual-type %my-struct)
> (:simple-parser my-struct))
>
> (defmethod translate-from-foreign (value (type my-struct-type)) ...)
> (defmethod translate-to-foreign (value (type my-struct-type)) ...)
> (defmethod free-translated-object (value (type my-struct-type) param) ...)
>
> Now, perhaps defcstruct could take an option to define a type class thus
> avoiding the need to define a wrapper type. Perhaps something like
> this?
>
> (defcstruct (my-struct :class my-struct-type)
> ...)
>
> Any comments?
Nice, this is exactly the kind of thing that I'm currently looking for.
What does the :simple-parser slot-option do?
I'm just wondering does this provide any value other than the ability to
define translations on c-structs? Not that this is the wrong way to do
it but it does seem like a large amount of work to enable translations.
Just my 2c though.
Cheers,
Sean.
--
...Please don't assume Lisp is only useful for Animation and Graphics,
AI, Bioinformatics, B2B and E-Commerce, Data Mining, EDA/Semiconductor
applications, Expert Systems, Finance, Intelligent Agents, Knowledge
Management, Mechanical CAD, Modeling and Simulation, Natural Language,
Optimization, Research, Risk Analysis, Scheduling, Telecom, and Web
Authoring just because these are the only things they happened to list.
Kent Pitman.
More information about the cffi-devel
mailing list