Re: C functions

2013-10-19 Thread Uli Kusterer
On 18 Oct 2013, at 20:38, Kyle Sluder k...@ksluder.com wrote: CFBundleGetFunctionPointerForName just calls dlsym. Sure. NSLog also eventually calls syslog. I still wouldn’t drop down to syslog for most Cocoa logging needs. CFBundleGetFunctionPointerForName takes a CFStringRef and if you’re

Re: C functions

2013-10-19 Thread Uli Kusterer
On 19 Oct 2013, at 01:17, Shane Stanley sstan...@myriad-com.com.au wrote: On 19 Oct 2013, at 3:15 AM, Uli Kusterer witness.of.teacht...@gmx.net wrote: this is what you'd do if you wanted to make e.g. CoreFoundation APIs accessible to a scripting language That's along the lines of what I

Re: C functions

2013-10-19 Thread Jean-Daniel Dupas
Le 19 oct. 2013 à 15:01, Uli Kusterer witness.of.teacht...@gmx.net a écrit : On 19 Oct 2013, at 01:17, Shane Stanley sstan...@myriad-com.com.au wrote: On 19 Oct 2013, at 3:15 AM, Uli Kusterer witness.of.teacht...@gmx.net wrote: this is what you'd do if you wanted to make e.g.

Re: C functions

2013-10-19 Thread Maxthon Chan
libclang is more than that. Xcode code highlighting and code indexing is based on lib clang, as well as delta compilation. (and I have a remote plan of cloning Xcode for GNUstep) Also, there was a friend of mine that created a translator that converts code from a new language to C, and I

Re: C functions

2013-10-18 Thread Jens Alfke
On Oct 17, 2013, at 8:49 PM, Charles Srstka cocoa...@charlessoft.com wrote: You shouldn't rely on dlsym() working in production code. If the binary is stripped (as it is by default for release builds, I believe), it won't work. You could work around that by exporting the symbol, e.g. by

Re: C functions

2013-10-18 Thread Uli Kusterer
On Oct 18, 2013, at 4:48 AM, Shane Stanley sstan...@myriad-com.com.au wrote: is there any way to build a call to a C function on the fly? I mean something like pass a string to a method, and have it call the function of that name? Short: No. Long: Maybe. 1) You can put a function in a

Re: C functions

2013-10-18 Thread Jeffrey Oleander
On 2013 Oct 18,, at 04:48, Shane Stanley sstan...@myriad-com.com.au wrote: is there any way to build a call to a C function on the fly? I mean something like pass a string to a method, and have it call the function of that name? This at least used to be shown in the Objective-C 2.0 Runtime

Re: C functions

2013-10-18 Thread Charles Srstka
On Oct 18, 2013, at 6:15 AM, Dmitry Markman dmark...@me.com wrote: I don't thinks strip remove info used by dynamic linker Thus dlsym should work As long as symbol is external (not with hidden visibility) dlsym is able to find the symbol (stripped or not) Not in my testing: #import

Re: C functions

2013-10-18 Thread Charles Srstka
On Oct 18, 2013, at 6:15 AM, Dmitry Markman dmark...@me.com wrote: I don't thinks strip remove info used by dynamic linker Thus dlsym should work As long as symbol is external (not with hidden visibility) dlsym is able to find the symbol (stripped or not) Trying to set the symbol to

Re: C functions

2013-10-18 Thread Uli Kusterer
On Oct 18, 2013, at 6:15 PM, Uli Kusterer witness.of.teacht...@gmx.net wrote: On Oct 18, 2013, at 4:48 AM, Shane Stanley sstan...@myriad-com.com.au wrote: is there any way to build a call to a C function on the fly? I mean something like pass a string to a method, and have it call the function

Re: C functions

2013-10-18 Thread Kyle Sluder
On Fri, Oct 18, 2013, at 10:39 AM, Uli Kusterer wrote: Oh, one more thing: Instead of dlsym(), you can also use CFBundleGetFunctionPointerForName() and its cohorts might also be useful for this if you want to go a bit more high-level. But even then, it needs to be an exported symbol in a

Re: C functions

2013-10-18 Thread Shane Stanley
On 19 Oct 2013, at 3:15 AM, Uli Kusterer witness.of.teacht...@gmx.net wrote: this is what you'd do if you wanted to make e.g. CoreFoundation APIs accessible to a scripting language That's along the lines of what I had in mind, although in this case for basic things like the trig functions in

Re: C functions

2013-10-18 Thread ChanMaxthon
Try add this line: extern void foo(void); Sent from my iPhone On 2013年10月19日, at 1:21, Charles Srstka cocoa...@charlessoft.com wrote: On Oct 18, 2013, at 6:15 AM, Dmitry Markman dmark...@me.com wrote: I don't thinks strip remove info used by dynamic linker Thus dlsym should work As

Re: C functions

2013-10-18 Thread Charles Srstka
On Oct 18, 2013, at 6:42 PM, ChanMaxthon xcvi...@me.com wrote: Try add this line: extern void foo(void); Already did; it doesn't work. See my follow-up post. Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post

Re: C functions

2013-10-18 Thread ChanMaxthon
I think I know why it did not work: strip command can remove debug symbols, or unused functions as well. Sent from my iPhone On 2013年10月19日, at 7:53, Charles Srstka cocoa...@charlessoft.com wrote: On Oct 18, 2013, at 6:42 PM, ChanMaxthon xcvi...@me.com wrote: Try add this line: extern

Re: C functions

2013-10-18 Thread Charles Srstka
On Oct 18, 2013, at 7:30 PM, ChanMaxthon xcvi...@me.com wrote: I think I know why it did not work: strip command can remove debug symbols, or unused functions as well. Yep. Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do

C functions

2013-10-17 Thread Shane Stanley
is there any way to build a call to a C function on the fly? I mean something like pass a string to a method, and have it call the function of that name? -- Shane Stanley sstan...@myriad-com.com.au 'AppleScriptObjC Explored' www.macosxautomation.com/applescript/apps/

Re: C functions

2013-10-17 Thread Charles Srstka
On Oct 17, 2013, at 9:48 PM, Shane Stanley sstan...@myriad-com.com.au wrote: is there any way to build a call to a C function on the fly? I mean something like pass a string to a method, and have it call the function of that name? No. That's an Objective-C feature that's not present in

Re: C functions

2013-10-17 Thread Maxthon Chan
You actually can, by using dlsym(3) to resolve the symbol, cast it to the appropriate function pointer and call it. For example: int (*myfunc)(int, int) = dlsym(RTLD_DEFAULT, myfunc_name); if (myfunc) printf(“%d”, myfunc(2, 3)); else fprintf(stderr, “error: cannot resolve symbol: %s”,

Re: C functions

2013-10-17 Thread Charles Srstka
On Oct 17, 2013, at 10:40 PM, Maxthon Chan xcvi...@me.com wrote: You actually can, by using dlsym(3) to resolve the symbol, cast it to the appropriate function pointer and call it. For example: int (*myfunc)(int, int) = dlsym(RTLD_DEFAULT, myfunc_name); if (myfunc) printf(“%d”,

Re: C functions

2013-10-17 Thread ChanMaxthon
You can certainly move everything into a library, also you can prevent executables from being stripped in Xcode. Sent from my iPhone On 2013年10月18日, at 11:54, Charles Srstka cocoa...@charlessoft.com wrote: Loadable bundles and libraries don't get stripped. Executables, since they don't

Re: Working with C-functions in separate NSThreads: via Stack or Heap?

2010-11-08 Thread Frederick C. Lee
My original reply was too long for Cocoa Dev; then I lost it. So this is another (small draft)... It appears I'll be working with blocks, keeping the data/functioning local to the stack copying data out to the GUI: typedef sat_t (^MyBlock)(); // C - function: int addFoot(int k) {

Working with C-functions in separate NSThreads: via Stack or Heap?

2010-11-04 Thread Frederick C. Lee
Environment: iOS SDK 4.2+ Xcode 3.2.5 Desired design: 1) Multiple NSThreads (via NSOperation?) running NSObjects in parallel: processing the same C-functions (with different data) in real time till conclusion (or cancelled). 2) These C-functions are located in a common *.c file (or two

Testing C functions using OCUnit

2009-02-15 Thread Martin Redington
In my projects, I tend to define methods which need access to member variables as class methods, and related functions, which do not need direct access to any internal object data, as C functions, like the simple example below. @implementation FunctionTestAppController + (id) sharedController

Re: Testing C functions using OCUnit

2009-02-15 Thread Greg Parker
On Feb 15, 2009, at 10:32 AM, Martin Redington wrote: In my projects, I tend to define methods which need access to member variables as class methods, and related functions, which do not need direct access to any internal object data, as C functions, like the simple example below

Re: Testing C functions using OCUnit

2009-02-15 Thread Martin Redington
variables as class methods, and related functions, which do not need direct access to any internal object data, as C functions, like the simple example below. @implementation FunctionTestAppController + (id) sharedController { return [NSApp delegate]; } - (BOOL) someMethod

Re: Testing C functions using OCUnit

2009-02-15 Thread Timothy Reaves
On Feb 15, 2009, at 1:32 PM, Martin Redington wrote: In my projects, I tend to define methods which need access to member variables as class methods, and related functions, which do not need direct access to any internal object data, as C functions, like the simple example below

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

2008-11-20 Thread Alexander Spohr
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

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

2008-11-20 Thread Austin Ziegler
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

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

2008-11-20 Thread Ken Thomases
On Nov 20, 2008, at 6:58 AM, Austin Ziegler wrote: result = [calc addDoubleA:a withDoubleB:b]; // #1 Why not -addDouble:withDouble: ? That is, why are you promoting the argument names into the method signature? Especially since you're aware that the names are (most often) useless.

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

2008-11-20 Thread Bill Bumgarner
On Nov 20, 2008, at 10:54 AM, Alexander Spohr wrote: I’d go for #1. If you have an error in status, throw an exception. In this case, an exception might actually be OK, given that the library is in isolation. However, it goes against the design patterns of Cocoa and if the code is ever

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

2008-11-20 Thread Michael Ash
On Thu, Nov 20, 2008 at 12:27 AM, Austin Ziegler [EMAIL PROTECTED] 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

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

2008-11-20 Thread Austin Ziegler
On Thu, Nov 20, 2008 at 12:15 PM, Michael Ash [EMAIL PROTECTED] wrote: Please excuse a foolish question, but Why wrap this in Objective-C at all? Looks like the resulting ObjC code is essentially the same, except uglier, slower, and harder to use. Why not just keep the C and use it

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

2008-11-20 Thread Jonathon Kuo
On Nov 19, 2008, at 9:27 PM, 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

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

2008-11-20 Thread Shawn Erickson
On Thu, Nov 20, 2008 at 1:23 PM, Jonathon Kuo [EMAIL PROTECTED] wrote: Just my 2 cents, but it seems an abuse to turn functions into objects. Functions don't retain state; objects do. Objective C very gracefully allows objects to call C functions. If you're doing something like [calc

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

2008-11-20 Thread Ken Tozier
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

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

2008-11-20 Thread Jonathon Kuo
On Nov 20, 2008, at 2:07 PM, Shawn Erickson wrote: On Thu, Nov 20, 2008 at 1:23 PM, Jonathon Kuo [EMAIL PROTECTED] wrote: Just my 2 cents, but it seems an abuse to turn functions into objects. Functions don't retain state; objects do. Objective C very gracefully allows objects to call C

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

2008-11-20 Thread Charles Srstka
. Objective C very gracefully allows objects to call C functions. If you're doing something like [calc addDoubleA:a withDoubleB:b], you've got a function masquerading as an object, which I think misses the entire point of OOP. It is common, if not appropriate, to have utility classes (often ones

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

2008-11-20 Thread Jonathon Kuo
into objects. Functions don't retain state; objects do. Objective C very gracefully allows objects to call C functions. If you're doing something like [calc addDoubleA:a withDoubleB:b], you've got a function masquerading as an object, which I think misses the entire point of OOP. It is common

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

2008-11-20 Thread Charles Srstka
, but it seems an abuse to turn functions into objects. Functions don't retain state; objects do. Objective C very gracefully allows objects to call C functions. If you're doing something like [calc addDoubleA:a withDoubleB:b], you've got a function masquerading as an object, which I think

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

2008-11-20 Thread Jonathon Kuo
, Jonathon Kuo [EMAIL PROTECTED] wrote: Just my 2 cents, but it seems an abuse to turn functions into objects. Functions don't retain state; objects do. Objective C very gracefully allows objects to call C functions. If you're doing something like [calc addDoubleA:a withDoubleB:b], you've got

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

2008-11-20 Thread Austin Ziegler
On Thu, Nov 20, 2008 at 6:09 PM, Ken Tozier [EMAIL PROTECTED] wrote: 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

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

2008-11-19 Thread 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

Re: C functions and instance variables

2008-03-28 Thread Hamish Allan
On Fri, Mar 28, 2008 at 9:14 AM, Trygve Inda [EMAIL PROTECTED] wrote: I have a Cocoa object with .m and .h files and need to include in this a series of about 30 C functions which all all in their own .c file. Is it possible to give functions in the .c file access to the .m files instance