• 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: Ken Tozier <email@hidden>
  • Date: Thu, 20 Nov 2008 18:09:42 -0500

Just out of curiosity, why do you need to send such common math operations to a soap request? Wouldn't it be easier to do simple stuff like calculations in your Soap class and only make requests for the unique services the endpoint provides?


On Nov 20, 2008, at 12:27 AM, Austin Ziegler wrote:

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

_______________________________________________

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: "Austin Ziegler" <email@hidden>
References: 
 >Wrapping C functions in Objective C proxy objects: naming convention? (From: "Austin Ziegler" <email@hidden>)

  • Prev by Date: Re: propblems w/ outline view delegate and notifications
  • Next by Date: GC and print operations cause objects not to finalize?
  • 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