mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
more changes for new runtime
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29828 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
cb757f4794
commit
102df587f7
4 changed files with 37 additions and 86 deletions
|
@ -1,3 +1,10 @@
|
|||
2010-03-03 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/ObjectiveC2/runtime.c: Fix class data copying functions to
|
||||
match OSX.
|
||||
* Source/Additions/GSObjCRuntime.m: Implement adding classes using
|
||||
new runtime functions.
|
||||
|
||||
2010-03-03 Doug Simons <dpsimons@testplant.com>
|
||||
|
||||
* Source/NSDate.m: Fix natural language date parsing to handle AM/PM.
|
||||
|
|
|
@ -552,7 +552,7 @@ GS_EXPORT int GSObjCVersion(Class cls);
|
|||
#endif
|
||||
|
||||
/**
|
||||
* Return the zone in which an object belongs, without using the zone method
|
||||
* GSObjCZone() is deprecated ... use -zone
|
||||
*/
|
||||
GS_EXPORT NSZone *
|
||||
GSObjCZone(NSObject *obj);
|
||||
|
|
|
@ -523,66 +523,18 @@ GSObjCMakeClass(NSString *name, NSString *superName, NSDictionary *iVars)
|
|||
* The classes argument is an array of NSValue objects containing pointers
|
||||
* to classes previously created by the GSObjCMakeClass() function.
|
||||
*/
|
||||
#ifdef NeXT_RUNTIME
|
||||
void
|
||||
GSObjCAddClasses(NSArray *classes)
|
||||
{
|
||||
unsigned int numClasses = [classes count];
|
||||
unsigned int i;
|
||||
for (i = 0; i < numClasses; i++)
|
||||
{
|
||||
objc_addClass((Class)[[classes objectAtIndex: i] pointerValue]);
|
||||
}
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* NOTE - OBJC_VERSION needs to be defined to be the version of the
|
||||
* Objective-C runtime you are using. You can find this in the file
|
||||
* 'init.c' in the GNU objective-C runtime source.
|
||||
*/
|
||||
#define OBJC_VERSION 8
|
||||
|
||||
void
|
||||
GSObjCAddClasses(NSArray *classes)
|
||||
{
|
||||
void __objc_exec_class (void* module);
|
||||
void __objc_resolve_class_links ();
|
||||
Module_t module;
|
||||
Symtab_t symtab;
|
||||
unsigned int numClasses = [classes count];
|
||||
unsigned int i;
|
||||
Class c;
|
||||
|
||||
NSCAssert(numClasses > 0, @"No classes (array is NULL)");
|
||||
|
||||
c = (Class)[[classes objectAtIndex: 0] pointerValue];
|
||||
|
||||
// Prepare a fake module containing only the new classes
|
||||
module = objc_calloc (1, sizeof (Module));
|
||||
module->version = OBJC_VERSION;
|
||||
module->size = sizeof (Module);
|
||||
module->name = malloc (strlen(c->name) + 15);
|
||||
strcpy ((char*)module->name, "GNUstep-Proxy-");
|
||||
strcat ((char*)module->name, c->name);
|
||||
module->symtab = malloc(sizeof(Symtab) + numClasses * sizeof(void *));
|
||||
|
||||
symtab = module->symtab;
|
||||
symtab->sel_ref_cnt = 0;
|
||||
symtab->refs = 0;
|
||||
symtab->cls_def_cnt = numClasses; // We are defining numClasses classes.
|
||||
symtab->cat_def_cnt = 0; // But no categories
|
||||
NSUInteger numClasses = [classes count];
|
||||
NSUInteger i;
|
||||
|
||||
for (i = 0; i < numClasses; i++)
|
||||
{
|
||||
symtab->defs[i] = (Class)[[classes objectAtIndex: i] pointerValue];
|
||||
objc_registerClassPair((Class)[[classes objectAtIndex: i] pointerValue]);
|
||||
}
|
||||
symtab->defs[numClasses] = NULL; //null terminated list
|
||||
|
||||
// Insert our new class into the runtime.
|
||||
__objc_exec_class (module);
|
||||
__objc_resolve_class_links();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static int behavior_debug = 0;
|
||||
|
|
|
@ -117,7 +117,7 @@ static void
|
|||
objc_updateDtableForClassContainingMethod(Method m)
|
||||
{
|
||||
Class nextClass = Nil;
|
||||
void *state;
|
||||
void *state = NULL;
|
||||
SEL sel = method_getName(m);
|
||||
|
||||
while (Nil != (nextClass = objc_next_class(&state)))
|
||||
|
@ -268,7 +268,6 @@ class_copyIvarList(Class cls, unsigned int *outCount)
|
|||
{
|
||||
struct objc_ivar_list *ivarlist = cls->ivars;
|
||||
unsigned int count = 0;
|
||||
unsigned int i;
|
||||
Ivar *list;
|
||||
|
||||
if (ivarlist != NULL)
|
||||
|
@ -284,11 +283,10 @@ class_copyIvarList(Class cls, unsigned int *outCount)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
list = malloc(count * sizeof(struct objc_ivar *));
|
||||
for (i = 0; i < ivarlist->ivar_count; i++)
|
||||
{
|
||||
list[i] = &(ivarlist->ivar_list[i]);
|
||||
}
|
||||
list = malloc((count + 1) * sizeof(struct objc_ivar *));
|
||||
list[count] = NULL;
|
||||
memcpy(list, ivarlist->ivar_list,
|
||||
ivarlist->ivar_count * sizeof(struct objc_ivar *));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -297,11 +295,9 @@ class_copyMethodList(Class cls, unsigned int *outCount)
|
|||
{
|
||||
unsigned int count = 0;
|
||||
Method *list;
|
||||
Method *copyDest;
|
||||
struct objc_method_list *methods;
|
||||
|
||||
for (methods = cls->methods; methods != NULL;
|
||||
methods = methods->method_next)
|
||||
for (methods = cls->methods; methods != NULL; methods = methods->method_next)
|
||||
{
|
||||
count += methods->method_count;
|
||||
}
|
||||
|
@ -314,19 +310,14 @@ class_copyMethodList(Class cls, unsigned int *outCount)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
list = malloc(count * sizeof(struct objc_method *));
|
||||
copyDest = list;
|
||||
|
||||
for (methods = cls->methods; methods != NULL;
|
||||
methods = methods->method_next)
|
||||
list = malloc((count + 1) * sizeof(struct objc_method *));
|
||||
list[count] = NULL;
|
||||
count = 0;
|
||||
for (methods = cls->methods; methods != NULL; methods = methods->method_next)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < methods->method_count; i++)
|
||||
{
|
||||
copyDest[i] = &(methods->method_list[i]);
|
||||
}
|
||||
copyDest += methods->method_count;
|
||||
memcpy(&list[count], methods->method_list,
|
||||
methods->method_count * sizeof(struct objc_method *));
|
||||
count += methods->method_count;
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -337,29 +328,30 @@ class_copyProtocolList(Class cls, unsigned int *outCount)
|
|||
{
|
||||
struct objc_protocol_list *protocolList = cls->protocols;
|
||||
struct objc_protocol_list *list;
|
||||
int listSize = 0;
|
||||
unsigned int count = 0;
|
||||
Protocol **protocols;
|
||||
int index;
|
||||
|
||||
for (list = protocolList; list != NULL; list = list->next)
|
||||
{
|
||||
listSize += list->count;
|
||||
count += list->count;
|
||||
}
|
||||
if (listSize == 0)
|
||||
if (outCount != NULL)
|
||||
{
|
||||
*outCount = count;
|
||||
}
|
||||
if (count == 0)
|
||||
{
|
||||
*outCount = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
protocols = calloc(listSize, sizeof(Protocol *) + 1);
|
||||
index = 0;
|
||||
protocols = malloc((count + 1) * sizeof(Protocol *));
|
||||
protocols[count] = NULL;
|
||||
count = 0;
|
||||
for (list = protocolList; list != NULL; list = list->next)
|
||||
{
|
||||
memcpy(&protocols[index], list->list, list->count * sizeof(Protocol *));
|
||||
index += list->count;
|
||||
memcpy(&protocols[count], list->list, list->count * sizeof(Protocol *));
|
||||
count += list->count;
|
||||
}
|
||||
protocols[listSize] = NULL;
|
||||
*outCount = listSize + 1;
|
||||
return protocols;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue