• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Public API method naming for NSString * / const char * parameters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Public API method naming for NSString * / const char * parameters


  • Subject: Re: Public API method naming for NSString * / const char * parameters
  • From: "email@hidden" <email@hidden>
  • Date: Mon, 03 Mar 2014 19:35:03 +0000

On 3 Mar 2014, at 19:23, Kyle Sluder <email@hidden> wrote:

> But Jonathan, why are you even exposing raw C pointer access to the
> identifiers in the first place? Why wouldn't you convert them to
> NSStrings and only expose them to Objective-C code that way?
>
Jens sort of nailed it.
The underlying Mono API is C.

So every call to a managed method looks something like:
onoObject *monoObject = [self invokeMonoMethod:"SumAndSwitch(double*,double*)" withNumArgs:2, p1, p2];

The code generator wraps it up like so:

- (float)sumAndSwitch_withFloatPtrX:(float*)p1 floatPtrY:(float*)p2
{
    MonoObject *monoObject = [self invokeMonoMethod:"SumAndSwitch(single*,single*)" withNumArgs:2, p1, p2];
    return DB_UNBOX_FLOAT(monoObject);
}

So only the direct access Cocoa methods have to futz with char *.

There would be an obvious overhead unboxing every NSString instance.
Plus I would have to refactor the entire legacy API.

I don’t really like all the char * pointers but given the context of the API it’s probably for the best.

Jonathan


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >Public API method naming for NSString * / const char * parameters (From: "email@hidden" <email@hidden>)
 >Re: Public API method naming for NSString * / const char * parameters (From: Daniel DeCovnick <email@hidden>)
 >Re: Public API method naming for NSString * / const char * parameters (From: "email@hidden" <email@hidden>)
 >Re: Public API method naming for NSString * / const char * parameters (From: Daniel DeCovnick <email@hidden>)
 >Re: Public API method naming for NSString * / const char * parameters (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Public API method naming for NSString * / const char * parameters
  • Next by Date: Re: notification when device change in /dev
  • Previous by thread: Re: Public API method naming for NSString * / const char * parameters
  • Next by thread: Re: Public API method naming for NSString * / const char * parameters
  • Index(es):
    • Date
    • Thread