mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Added missing ivar access functions.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32939 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ff0b5abd62
commit
a95b18e430
1 changed files with 31 additions and 0 deletions
|
@ -436,6 +436,37 @@ class_getInstanceVariable(Class cls, const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void object_setIvar(id object, Ivar ivar, id value)
|
||||
{
|
||||
char *addr = (char*)&object;
|
||||
addr += ivar_getOffset(ivar);
|
||||
*(id*)addr = value;
|
||||
}
|
||||
|
||||
Ivar object_setInstanceVariable(id obj, const char *name, void *value)
|
||||
{
|
||||
Ivar ivar = class_getInstanceVariable(object_getClass(obj), name);
|
||||
object_setIvar(obj, ivar, value);
|
||||
return ivar;
|
||||
}
|
||||
|
||||
id object_getIvar(id object, Ivar ivar)
|
||||
{
|
||||
return *(id*)(((char*)&object) + ivar_getOffset(ivar));
|
||||
}
|
||||
|
||||
Ivar object_getInstanceVariable(id obj, const char *name, void **outValue)
|
||||
{
|
||||
Ivar ivar = class_getInstanceVariable(object_getClass(obj), name);
|
||||
if (NULL != outValue)
|
||||
{
|
||||
*outValue = object_getIvar(obj, ivar);
|
||||
}
|
||||
return ivar;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// The format of the char* is undocumented. This function is only ever used in
|
||||
// conjunction with class_setIvarLayout().
|
||||
const char *
|
||||
|
|
Loading…
Reference in a new issue