[Mono-osx] MonoMac [Target]

Duane Wandless duane at wandless.net
Sun Apr 25 23:54:21 EDT 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20100426/e5c3ae0f/attachment.html 


More information about the Mono-osx mailing list