• 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: Wrapping C functions in Objective C proxy objects: naming convention?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrapping C functions in Objective C proxy objects: naming convention?


  • Subject: Re: Wrapping C functions in Objective C proxy objects: naming convention?
  • From: "Austin Ziegler" <email@hidden>
  • Date: Thu, 20 Nov 2008 07:58:44 -0500

On Thu, Nov 20, 2008 at 4:54 AM, Alexander Spohr <email@hidden> wrote:
> I'd go for #1.
> If you have an error in status, throw an exception.
>
> What is the reason to put those functions in a class anyway if you just
> mimic the c-function? Are you adding anything?

Yes, I am. The C function definition that I showed was actually just a
SOAP service definition. What my proxy object will be calling are
about three or four different C functions to make the SOAP call,
hiding that complexity from the programmer. (I could just use C++ and
have this code generated for me automatically, but this is also an
intellectual challenge to generate these Objective C wrappers that
mimic what the C++ code does.)

-austin

> Am 20.11.2008 um 06:27 schrieb Austin Ziegler:
>> For a project that I'm working on, I have a need to write a code
>> generator that will wrap certain kinds of C functions as Objective C
>> messages on an Objective C proxy. Because I don't ultimately control
>> the input, the parameters on the C functions may be poorly named. I'm
>> looking for advice on how one might make useful object message names
>> from C functions.
>>
>> The format of the functions in question is essentially like this[1]:
>>
>>  int ns__add(double a, double b, double *result);
>>  int ns__sub(double a, double b, double *result);
>>  int ns__mul(double a, double b, double *result);
>>  int ns__div(double a, double b, double *result);
>>  int ns__pow(double a, double b, double *result);
>>
>> The int return is a status code; the result of the operation is in
>> double* result. If there's an error in the operation. (The status code
>> may be ignorable, in which case part of my following question is
>> answered; I'm still researching this part. I suspect that it is best
>> not ignored.)
>>
>> Anyway, the problem is how I should convert this function with poorly
>> named parameters into a proxy object and messages?
>>
>> The options that I've come up with (expressed in terms of use) follow.
>> They're all expressed in terms of an object ns__CalcProxy:
>>
>>  ns__CalcProxy calc = [[ns__CalcProxy alloc] init];
>>  double a, b, result;
>>  int status;
>>
>>  result = [calc addDoubleA:a withDoubleB:b]; // #1
>>  result = [calc addDoubleA:a withDoubleB:b status:&status]; // #2
>>  status = [calc addDoubleA:a withDoubleB:b returning:&result]; // #3
>>
>> The examples given here are simple; the items being returned may in
>> fact be pretty complex (and I'm planning on making it so that
>> structured parameters and return values may be passed in Objective C
>> proxies themselves).
>>
>> I really don't like the "addDoubleA:withDoubleB:" name, to be honest,
>> but what am I supposed to do with:
>>
>>  struct ns1__ludcmpResponse {matrix *a; ivector *i; xsd__double d;};
>>  int ns1__ludcmp(matrix *a, struct ns1__ludcmpResponse** result);
>>
>> Like I said; I don't really have any control over the names of the
>> parameters, more's the pity.
>>
>> -austin
>> [1] Actually, they're more like this:
>>  int soap_call_ns__add(struct soap *soap, const char *soap_endpoint,
>>       const char *soap_action, double a, double b, double *result);
>> But there's enough information in there for me to extract the former
>> to use as a proxy function.
>> --
>> Austin Ziegler * email@hidden * http://www.halostatue.ca/
>>              * email@hidden * http://www.halostatue.ca/feed/
>>              * email@hidden
>> _______________________________________________
>>
>> 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
>
> ---
> Alexander Spohr
> Freeport & Soliversum
>
> Fax: +49 40 303 757 99
> Web: http://www.freeport.de/
> Box: http://dropbox.letsfile.com/02145299-4347-4671-aab9-1d3004eac51d
> ---
>
>
>
>



--
Austin Ziegler * email@hidden * http://www.halostatue.ca/
               * email@hidden * http://www.halostatue.ca/feed/
               * email@hidden
_______________________________________________

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

  • Follow-Ups:
    • Re: Wrapping C functions in Objective C proxy objects: naming convention?
      • From: Ken Thomases <email@hidden>
References: 
 >Wrapping C functions in Objective C proxy objects: naming convention? (From: "Austin Ziegler" <email@hidden>)
 >Re: Wrapping C functions in Objective C proxy objects: naming convention? (From: Alexander Spohr <email@hidden>)

  • Prev by Date: Project handling multiple developers
  • Next by Date: [OT] Re: Project handling multiple developers
  • Previous by thread: Re: Wrapping C functions in Objective C proxy objects: naming convention?
  • Next by thread: Re: Wrapping C functions in Objective C proxy objects: naming convention?
  • Index(es):
    • Date
    • Thread