Re: Calling an object from a C function

2008-08-20 Thread Antonio Nunes
On 20 Aug 2008, at 01:06, Charlie Dickman wrote: Now, how do I define things like 'self' and 'super' to a C program? Put like this the question doesn't make sense. But maybe this is useful: If you have a C function that _conceptually_ is part of an object and that needs to access 'self'

Re: Calling an object from a C function

2008-08-20 Thread Ken Thomases
On Aug 20, 2008, at 4:21 AM, Antonio Nunes wrote: I don't know how this would scale to 'super'. I don't think you can pass in a pointer to super, as that is not how the mechanism works. While self is a variable name super is a flag to the compiler telling it where to begin searching for

Re: Calling an object from a C function

2008-08-20 Thread Antonio Nunes
On 20 Aug 2008, at 11:16, Ken Thomases wrote: Well, you can try to achieve this result with the Objective-C runtime. The better approach would be to have the C function be a very simple wrapper around an Objective-C method (as you illustrated) and then have that method invoke 'super' if

Calling an object from a C function

2008-08-19 Thread Gilbert Mackall
I have a C function from which I would like to call a method. I can't find any documents the cover how to do this. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact

Re: Calling an object from a C function

2008-08-19 Thread Kenny Leung
Hi Gilbert. You just have to make sure that your C function is in a .m file (not a .c file) and have the proper header included. Then you just call the method. -Kenny On Aug 19, 2008, at 2:53 PM, Gilbert Mackall wrote: I have a C function from which I would like to call a method. I

Re: Calling an object from a C function

2008-08-19 Thread David Duncan
On Aug 19, 2008, at 2:53 PM, Gilbert Mackall wrote: I have a C function from which I would like to call a method. I can't find any documents the cover how to do this. You call it just like you call any other method. Your C function will need to be compiled with the Obj-C compiler however.

Re: Calling an object from a C function

2008-08-19 Thread Charlie Dickman
What is the syntax? For example, how do I invoke the method - (int) myMethod: (int) int; In object myObject from within a C (not Objective C) function and make use of the result? In Objective C I would invoke [myObject myMethod: myInt]; Even better, how do I invoke - (myObject) myMethod:

Re: Calling an object from a C function

2008-08-19 Thread David Duncan
On Aug 19, 2008, at 4:28 PM, Charlie Dickman wrote: from within a C (not Objective C) function and make use of the result? In Objective C I would invoke [myObject myMethod: myInt]; You invoke it exactly the same way. There is no difference. But you need to compile as Obj-C. int foo(id

Re: Calling an object from a C function

2008-08-19 Thread Kenny Leung
Example: void cFunction(MyObject *myObject) { int myInt; int result; myInt = initializeMyInt(); result = [myObject myMethod:myInt]; printf(result:%i, result); } On Aug 19, 2008, at 4:28 PM, Charlie Dickman wrote: What is the syntax? For example, how do I invoke the method

Re: Calling an object from a C function

2008-08-19 Thread Kiel Gillard
Hi Charlie, The format is like any normal C function. int MyStaticCFunction(int someArg) { //invoke myMethod and return the int the myMethod returns return [objcObject myMethod:someArg]; } You wrote: What is the syntax? For example, how do I invoke the method - (int) myMethod: (int)

Re: Calling an object from a C function

2008-08-19 Thread Charlie Dickman
Thanks to all who responded. I must have had a mental block against this. Now, how do I define things like 'self' and 'super' to a C program? On Aug 19, 2008, at 7:38 PM, David Duncan wrote: On Aug 19, 2008, at 4:28 PM, Charlie Dickman wrote: from within a C (not Objective C) function and

Re: Calling an object from a C function

2008-08-19 Thread Charles Steinman
--- On Tue, 8/19/08, Charlie Dickman [EMAIL PROTECTED] wrote: Now, how do I define things like 'self' and 'super' to a C program? You mean outside of an object? You don't. What would it even mean? There's no concept of selfness in a function. If you want there to be a self, you should create

Re: Calling an object from a C function

2008-08-19 Thread mm w
hi charlie give your code or something clearer what are you trying to do? a C object runtime? or a wrapper obj-c to C? (kidding) maybe you could have the right answers, when I read you, my feelings is that you don't go in the right direction On Tue, Aug 19, 2008 at 5:06 PM, Charlie Dickman