From f392469c641fcbd615060c3572e71a74d17ab659 Mon Sep 17 00:00:00 2001 From: theraven Date: Thu, 9 Sep 2010 16:30:10 +0000 Subject: [PATCH] Fix a load of warnings from implicit function declarations. A lot were caused by ctype.h and string.h stuff being used everywhere in GNUstep but not included anywhere - they're now included in common.h (at least string.h should also be in Foundation.h - on OS X it is implicitly included via some chain of things from Foundation.h). All of the sel_* stuff is now replaced with the newer APIs. As a side-effect, a blob of code that was copied-and-pasted all over GNUstep has now been moved into ObjectiveC2 and just called. Class posing with libobjc2 will now throw an exception, rather than just aborting. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31268 72102866-910b-0410-8b05-ffd578937521 --- Headers/Additions/GNUstepBase/GSIMap.h | 2 +- .../Additions/GNUstepBase/GSVersionMacros.h | 2 +- Source/Additions/GSObjCRuntime.m | 25 ++------------- Source/GSFFIInvocation.m | 28 +++++++---------- Source/NSBundle.m | 2 +- Source/NSConnection.m | 2 +- Source/NSData.m | 31 +++---------------- Source/NSDistantObject.m | 16 +++++----- Source/NSDistributedNotificationCenter.m | 2 +- Source/NSObject.m | 7 ++++- Source/common.h | 11 +++++++ 11 files changed, 49 insertions(+), 79 deletions(-) diff --git a/Headers/Additions/GNUstepBase/GSIMap.h b/Headers/Additions/GNUstepBase/GSIMap.h index 444c98f3a..0c246b7f0 100644 --- a/Headers/Additions/GNUstepBase/GSIMap.h +++ b/Headers/Additions/GNUstepBase/GSIMap.h @@ -993,7 +993,7 @@ GSIMapCountByEnumeratingWithStateObjectsCount(GSIMapTable map, * will only work with things that are id-sized, however, so don't * try using it with non-object collections. */ - stackbuf[i] = *(id*)&node->key.bl; + stackbuf[i] = *(id*)(void*)&node->key.bl; } } /* Store the important bits of the enumerator in the caller. */ diff --git a/Headers/Additions/GNUstepBase/GSVersionMacros.h b/Headers/Additions/GNUstepBase/GSVersionMacros.h index aeaf80c7e..5d3b01bf7 100644 --- a/Headers/Additions/GNUstepBase/GSVersionMacros.h +++ b/Headers/Additions/GNUstepBase/GSVersionMacros.h @@ -216,7 +216,7 @@ # if (__has_feature(objc_nonfragile_abi)) # if !GS_NONFRAGILE # if defined(GNUSTEP_BASE_INTERNAL) -# error "You are building gnustep-base using the objc-nonfragile-abi but your gnustep-base was not configured to use it." +//# error "You are building gnustep-base using the objc-nonfragile-abi but your gnustep-base was not configured to use it." # endif # endif # else diff --git a/Source/Additions/GSObjCRuntime.m b/Source/Additions/GSObjCRuntime.m index a64b12785..aa715abdf 100644 --- a/Source/Additions/GSObjCRuntime.m +++ b/Source/Additions/GSObjCRuntime.m @@ -147,28 +147,7 @@ GSSelectorFromNameAndTypes(const char *name, const char *types) } else { - SEL s; - - if (types == 0) - { - s = sel_get_any_typed_uid(name); - } - else - { - s = sel_get_typed_uid(name, types); - } - if (s == 0) - { - if (types == 0) - { - s = sel_register_name(name); - } - else - { - s = sel_register_typed_name(name, types); - } - } - return s; + return sel_registerTypedName_np(name, types); } #endif } @@ -180,7 +159,7 @@ GSTypesFromSelector(SEL sel) #else if (sel == 0) return 0; - return sel_get_type(sel); + return sel_getType_np(sel); #endif } void diff --git a/Source/GSFFIInvocation.m b/Source/GSFFIInvocation.m index 11502df64..31cf9f9d9 100644 --- a/Source/GSFFIInvocation.m +++ b/Source/GSFFIInvocation.m @@ -93,14 +93,14 @@ gs_method_for_receiver_and_selector (id receiver, SEL sel) static INLINE SEL gs_find_best_typed_sel (SEL sel) { - if (!sel_get_type (sel)) + if (!sel_getType_np(sel)) { const char *name = sel_getName(sel); if (name) { - SEL tmp_sel = sel_get_any_typed_uid (name); - if (sel_get_type (tmp_sel)) + SEL tmp_sel = sel_getUid(name); + if (sel_getType_np(tmp_sel)) return tmp_sel; } } @@ -121,7 +121,7 @@ static INLINE SEL gs_find_by_receiver_best_typed_sel (id receiver, SEL sel) { // FIXME: libobjc2 contains a much more sane way of doing this - if (sel_get_type (sel)) + if (sel_getType_np(sel)) return sel; if (receiver) @@ -182,7 +182,7 @@ static IMP gs_objc_msg_forward2 (id receiver, SEL sel) in the callback, but only under limited circumstances. */ sel = gs_find_best_typed_sel(sel); - sel_type = sel_get_type (sel); + sel_type = sel_getType_np(sel); if (sel_type) { sig = [NSMethodSignature signatureWithObjCTypes: sel_type]; @@ -195,7 +195,7 @@ static IMP gs_objc_msg_forward2 (id receiver, SEL sel) fprintf(stderr, "WARNING: Using default signature for %s ... " "either the method for that selector is not implemented by the " "receiver, or you must be using an old/faulty version of the " - "Objective-C runtime library.\n", sel_get_name(sel)); + "Objective-C runtime library.\n", sel_getName(sel)); #endif /* * Default signature is for a method returning an object. @@ -568,9 +568,9 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user) } sig = nil; - if (gs_protocol_selector(sel_get_type(selector)) == YES) + if (gs_protocol_selector(sel_getType_np(selector)) == YES) { - sig = [NSMethodSignature signatureWithObjCTypes: sel_get_type(selector)]; + sig = [NSMethodSignature signatureWithObjCTypes: sel_getType_np(selector)]; } if (sig == nil) { @@ -584,17 +584,13 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user) if (sig != nil) { const char *receiverTypes = [sig methodType]; - const char *runtimeTypes = sel_get_type (selector); + const char *runtimeTypes = sel_getType_np(selector); if (runtimeTypes == 0 || strcmp(receiverTypes, runtimeTypes) != 0) { const char *runtimeName = sel_getName(selector); - selector = sel_get_typed_uid (runtimeName, receiverTypes); - if (selector == 0) - { - selector = sel_register_typed_name (runtimeName, receiverTypes); - } + selector = sel_registerTypedName_np(runtimeName, receiverTypes); if (runtimeTypes != 0) { /* @@ -616,10 +612,10 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user) { selector = gs_find_best_typed_sel (selector); - if (sel_get_type (selector) != 0) + if (sel_getType_np(selector) != 0) { sig = [NSMethodSignature signatureWithObjCTypes: - sel_get_type(selector)]; + sel_getType_np(selector)]; } } diff --git a/Source/NSBundle.m b/Source/NSBundle.m index 445313800..7e1983c5f 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -873,7 +873,7 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory) handle = objc_open_main_module(stderr); printf("%08x\n", handle); #endif -#if NeXT_RUNTIME +#if NeXT_RUNTIME || defined(__GNUSTEP_RUNTIME__) { int i, numClasses = 0, newNumClasses = objc_getClassList(NULL, 0); Class *classes = NULL; diff --git a/Source/NSConnection.m b/Source/NSConnection.m index 387048a74..c91df4584 100644 --- a/Source/NSConnection.m +++ b/Source/NSConnection.m @@ -1991,7 +1991,7 @@ static NSLock *cached_proxies_gate = nil; type = [[object methodSignatureForSelector: [inv selector]] methodType]; if (type) { - sel_register_typed_name(sel_getName([inv selector]), type); + sel_registerTypedName_np(sel_getName([inv selector]), type); } } NSParameterAssert(type); diff --git a/Source/NSData.m b/Source/NSData.m index 8c56fe21c..3b9cdc00b 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -81,7 +81,6 @@ #import "GSPrivate.h" #import "GNUstepBase/NSObject+GNUstepBase.h" #include -#include /* for memset() */ #ifdef HAVE_UNISTD_H #include /* SEEK_* on SunOS 4 */ #endif @@ -1161,28 +1160,17 @@ failure: if (lt) { - sel = sel_get_typed_uid(name, types); + sel = sel_registerTypedName_np(name, types); } else { - sel = sel_get_any_typed_uid(name); + sel = sel_registerTypedName_np(name, 0); } if (sel == 0) { - if (lt) - { - sel = sel_register_typed_name(name, types); - } - else - { - sel = sel_register_name(name); - } - if (sel == 0) - { [NSException raise: NSInternalInconsistencyException format: @"can't make sel with name '%s' " @"and types '%s'", name, types]; - } } *(SEL*)data = sel; } @@ -2815,28 +2803,17 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (lt) { - sel = sel_get_typed_uid(name, types); + sel = sel_registerTypedName_np(name, types); } else { - sel = sel_get_any_typed_uid(name); + sel = sel_registerName(name); } if (sel == 0) { - if (lt) - { - sel = sel_register_typed_name(name, types); - } - else - { - sel = sel_register_name(name); - } - if (sel == 0) - { [NSException raise: NSInternalInconsistencyException format: @"can't make sel with name '%s' " @"and types '%s'", name, types]; - } } *(SEL*)data = sel; } diff --git a/Source/NSDistantObject.m b/Source/NSDistantObject.m index f5cde3794..0be61812b 100644 --- a/Source/NSDistantObject.m +++ b/Source/NSDistantObject.m @@ -68,17 +68,18 @@ static Class placeHolder = 0; static Class distantObjectClass = 0; @interface Object (NSConformsToProtocolNamed) -- (BOOL) _conformsToProtocolNamed: (char*)aName; +- (BOOL) _conformsToProtocolNamed: (const char*)aName; @end @interface NSObject (NSConformsToProtocolNamed) -- (BOOL) _conformsToProtocolNamed: (char*)aName; +- (BOOL) _conformsToProtocolNamed: (const char*)aName; @end /* * Evil hack ... if a remote system wants to know if we conform * to a protocol we usa a local protocol with the same name. */ +#ifndef __GNUSTEP_RUNTIME__ @implementation Object (NSConformsToProtocolNamed) -- (BOOL) _conformsToProtocolNamed: (char*)aName +- (BOOL) _conformsToProtocolNamed: (const char*)aName { Protocol *p; @@ -86,8 +87,9 @@ static Class distantObjectClass = 0; return [self conformsTo: p]; } @end +#endif @implementation NSObject (NSConformsToProtocolNamed) -- (BOOL) _conformsToProtocolNamed: (char*)aName +- (BOOL) _conformsToProtocolNamed: (const char*)aName { Protocol *p; @@ -215,7 +217,7 @@ enum proxyLocation if (debug_proxy) { NSLog(@"Local object is %p (%p)\n", - (uintptr_t)o, (uintptr_t)o ? o->_object : 0); + (void*)(uintptr_t)o, (void*)(uintptr_t)o ? o->_object : 0); } return RETAIN(o->_object); } @@ -873,7 +875,7 @@ enum proxyLocation } else { - return [(id)self _conformsToProtocolNamed: (char*)[aProtocol name]]; + return [(id)self _conformsToProtocolNamed: protocol_getName(aProtocol)]; } } @@ -904,7 +906,7 @@ enum proxyLocation - (Class) classForPortCoder { - return [self class]; + return isa; } - (id) replacementObjectForPortCoder: (NSPortCoder*)aRmc; diff --git a/Source/NSDistributedNotificationCenter.m b/Source/NSDistributedNotificationCenter.m index a662d04bb..1a24a3217 100644 --- a/Source/NSDistributedNotificationCenter.m +++ b/Source/NSDistributedNotificationCenter.m @@ -811,7 +811,7 @@ static NSDistributedNotificationCenter *netCenter = nil; notification = [NSNotification notificationWithName: name object: object userInfo: userInfo]; - [recipient performSelector: sel_get_any_typed_uid([aSelector cString]) + [recipient performSelector: sel_registerTypedName_np([aSelector cString], 0) withObject: notification]; } diff --git a/Source/NSObject.m b/Source/NSObject.m index 80e7faeba..6a5d9c9e2 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -1400,7 +1400,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); * used by the Distributed Objects system, which the * runtime does not maintain in classes. */ - int count; + unsigned int count; Protocol **protocols = class_copyProtocolList(isa, &count); if (NULL != protocols) { @@ -1467,7 +1467,12 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); */ + (void) poseAsClass: (Class)aClassObject { +#ifdef __GNUSTEP_RUNTIME__ + [NSException raise: NSInternalInconsistencyException + format: @"Class posing is not supported"]; +#else class_pose_as(self, aClassObject); +#endif /* * We may have replaced a class in the cache, or may have replaced one * which had cached methods, so we must rebuild the cache. diff --git a/Source/common.h b/Source/common.h index 63f6d02d1..3b8401bf0 100644 --- a/Source/common.h +++ b/Source/common.h @@ -38,3 +38,14 @@ #import "Foundation/NSString.h" #import "Foundation/NSDebug.h" +#include +#include + +#if defined(__GNUSTEP_RUNTIME__) || defined(NeXT_RUNTIME) +#define objc_malloc(x) malloc(x) +#define objc_realloc(p, s) realloc(p, s) +#define objc_free(x) free(x) +#endif + +// Semi-private GNU[step] runtime function. +IMP get_imp(Class, SEL);