Hi Nicolas, Thanks. I guess I just kinda wanted to create a Neko library with minimal Neko bytecode files. I guess other than this, there is little reason for having all the object types in the C code itself.
I'll have a rethink. Regards, Lee -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nicolas Cannasse Sent: 10 July 2006 19:23 To: Neko intermediate language mailing list Subject: Re: [Neko] Objects in the cffi > 2. Is there a simple way through the Neko api to tag this object for > quick type comparison in the same way that abstract pointers can > be checked? I'll answer (2) and this should answer (1) as well. There is no "simple way" to tag an object. You need to store the abstract value in one of its fields. Then when you get a "method" call, you need to do the following : value o = val_this(); value abs; val_check(o,object); abs = val_field(o,val_id("__abstract")); val_check_kind(abs,my_kind); ... So basically you're doing here in your C code what usually the OO wrapper is doing in Neko (like the haXe class wrapper for example), but with a little overhead when calling "val_this" and "val_field" from C compared to doing that in Neko. The most big problem is that you're breaking language intercompatibility. Neko is meant to be used with different languages, with sometimes no OO support (like NekoML for instance). Also, to do it properly, you would have to do the following : - store all methods in the object prototype (or you'll have one copy of the method table per instance which takes more memory) - access the strings with __s which is a haXe convention and not a Neko one. I would recommand that you stick to the classic Neko way of doing things. It's a bit verbose but has beegin working pretty well up to now. In the end, you give the end-user the choice of rewrapping your functions the way he need/want, and eventually make major changes in the API without changing a single line of your C library. Nicolas -- Neko : One VM to run them all (http://nekovm.org) -- Neko : One VM to run them all (http://nekovm.org)
