Re: Public API method naming for NSString * / const char * parameters
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