and here is the fileout i have promised ;)

On Mon, Nov 26, 2012 at 9:32 PM, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
Hi Igor,

While I'm waiting impatiently for the new NB version I played around some more and I have noted some ideas:

First thing is related to structures and callbacks... what if I want to have a callback as a member of a structure?
It seems to me that the way to go is to declare a MyCallback class and then use it in the structure, which is fair enough.�
But what if I have a function that initializes this structure with a user provided callback? Then the structure is not printed correctly.�
It seems that #coerceReturnValue: is not implemented in the NBCallbackType...�
While this is not a big issue it made me think that I was doing something wrong... Maybe in this case we can instantiate MyCallback class and put the fct pointer in in trunk ivar.

Secondly, related to structs again... It seems that we can define structures like:
struct {
� void *a[2];�
}
only by transforming them to
struct {
void *a1;
void *a2;
}
Am I wrong... if not maybe we can extend a little bit the syntax for defining structs to accept the first form... which will be far easier to write if we have large index values like void *x[20]...
What do you think?

Lastly, seeing that we are starting to have support for most of c-like declarations, i am not really satified with the way the enums should be handled... Maybe we can reify them as some kind of external object so that we can say something like:
enum {
AAA = 1,
BBB = 2,
};
MyEnum AAA (to get the item AAA of the enum)
MyEnum BBB value = 2�
and behind the enumeration is defined as a Dictionary of item->value mappings.�
Attached to this mail you will find a fileout of such an approach...
I agree that maybe this is not the most optimized way of dealing with enums, however I like this approach because it is uniform (with structs, external objects, external addresses, callbacks, etc).
Moreover if a beginner wants to hack his way into NB FFI I think it is easier to cope with an enum object than with SharedPools defined in classes, and imported.

Cheers,
PS: I can't way to get my hand on the new version...

--
Dr. Ciprian TEODOROV
Ing
nieur�D�veloppement�CAO

t�l : 06 08 54 73 48

mail :�ciprian.teodorov@gmail.com
www.teodorov.ro




--
Dr. Ciprian TEODOROV
Ing
nieur�D�veloppement�CAO

t�l : 06 08 54 73 48

mail :�ciprian.teodorov@gmail.com
www.teodorov.ro