On 1 May 2011, at 12:19, Mathieu Suen wrote: > Hi All, > > In my objective-c-smallltalk bridge now I need to setup a value of an > instance variable. > On osx I used the function object_setIvar, but in gnustep there is no such > method. > > undefined symbol: object_setIvar
This function does exist in trunk, just not in the latest stable releases. > How do I set a value of an instance variable with the runtime? Using this function is almost certainly wrong anyway, for two reasons: 1) It only works correctly with objects - if you try to set a char instance variable with it, for example, you will corrupt your object. 2) With a non-fragile ABI, ivars can be declared in class extensions, so an object may have two ivars with the same name, coming from different classes. This function does not allow you to disambiguate them. The correct way of doing it is to use class_getInstanceVariable(), then ivar_getTypeEncoding() and ivar_getOffset(). Use the result from the first call to box / unbox the value correctly for the corresponding Objective-C type. Then add the value returned by the second to the address of the object to find the correct memory location. David -- Sent from my Apple II _______________________________________________ Etoile-discuss mailing list [email protected] https://mail.gna.org/listinfo/etoile-discuss
