[Mono-osx] MonoMac parser.cs

Duane Wandless duane at wandless.net
Tue Apr 20 09:31:11 EDT 2010

Miguel - this is fantastic btw!

I have taken parser.cs and extended it to handle categories.  To start I
tested parsing NSArray.h.  This produced NSArray.cs and NSMutableArray.cs.
I have "full" bindings for these obj-c classes.

NSMutableArray:  http://monobin.com/__m335d328c
NSArray:  http://monobin.com/__m36c66b6e

However not all the bindings generated are valid.  For example I do not know
how to generate a binding for this selector (note I do not use this
selector, just an example):
- (void)sortUsingFunction:(NSInteger (*)(id, id, void *))compare
context:(void *)context;

Then comes the question of constructors.  Take these two (the 2nd is not
really a constructor I know) from NSMutableArray for example:
+ (id)arrayWithCapacity:(NSUInteger)numItems;
- (id)initWithCapacity:(NSUInteger)numItems;

My parser exposes these as:

        [Export ("arrayWithCapacity:")]
        IntPtr ArrayWithCapacity (uint numItems);

        [Export ("initWithCapacity:")]
        IntPtr InitWithCapacity (uint numItems);

First I do not think returning an IntPtr is correct.  It should return
NSMutableArray.  But IntPtr follows what was started with MT.  Returning an
IntPtr will require calling GetNSObject which seems cumbersome.  Unless I'm
missing something.

Ideally we would not have to hand write too many methods or constructors.

What is the recommended binding for these?  Note see my email about MonoMac
naming conventions.  Ideally ArrayWithCapacity would still be exposed.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20100420/3669330a/attachment-0001.html 

More information about the Mono-osx mailing list