[Mono-osx] MonoMac [Target]

Geoff Norton gnorton at novell.com
Sun Apr 25 23:57:40 EDT 2010


We need new generator support for extension methods to support this properly, however this has a few issues since categories are only applied at link time, so we'd need to ensure that the dependent native library is in the process space before applying the extension methods, or, ensure that we link the requisite library into the proc if the extensions are used.

Something to mull

-g

On 2010-04-25, at 11:54 PM, Duane Wandless wrote:

> I'm experimenting with how to generate various constructs from the header files.  Here is a common pattern:
> 
> Inside AppKit\NSTextAttachment.cs there is this:
> @interface NSMutableAttributedString (NSMutableAttributedStringAttachmentConveniences)
> - (void)updateAttachmentsFromPath:(NSString *)path;
> @end
> 
> Which I tried to bind like this (ignoring making the C# method name better):
>   //- (void)updateAttachmentsFromPath:(NSString *)path;
>   [Export ("updateAttachmentsFromPath:")]
>   void UpdateAttachmentsFromPath ([Target] NSMutableAttributedString  obj, NSString path);
> 
> Which produced this:
> [Export ("updateAttachmentsFromPath:")]
> public virtual void UpdateAttachmentsFromPath (NSMutableAttributedString obj, NSString path)
> {
>    if (obj == null)
>       throw new ArgumentNullException ("obj");
>    if (path == null)
>       throw new ArgumentNullException ("path");
>    if (IsDirectBinding) {
>       MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (obj.Handle, selUpdateAttachmentsFromPath, path.Handle);
>    } else {
>       MonoMac.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr (this.SuperHandle, sel  UpdateAttachmentsFromPath, path.Handle)
> ;
>    }
> }                
> 
> (I do no think the generated code for when IsDirectBinding == false is correct.  But that is a side issue.)
> 
> Is this the correct binding?  I would of course have to call:
> NSTextAttachment textAttachment;
> textAttachment.UpdateAttachmentsFromPath(attributedStringObj, path);
> 
> Or would I rather call:
> attributedStringObj.UpdateAttachmentsFromPath(path);
> 
> In my parser I have the ability of adding this method directly on NSMutableAttributedString, the 2nd example.  Another option would be to create an extension method to NSMutableAttributedString when parsing NSTextAttachment.  Maybe the generator should create:
> 
> public static class NSMutableAttributedStringAttachmentConveniences
> {
>    public static void UpdateAttachmentsFromPath(this NSMutableAttributedString obj, NSString path)
>    { ...
>    }
> }
> 
> So I know how to modify the parser what is the preferred solution?
> 
> Thanks,
> Duane
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20100425/2b62d2c7/attachment.html 


More information about the Mono-osx mailing list