Index: generators/library/GlueGenerator.h ================================================================== --- generators/library/GlueGenerator.h +++ generators/library/GlueGenerator.h @@ -21,12 +21,13 @@ #import "OFXMLElement.h" @interface GlueGenerator: OFObject { OFXMLElement *_library; - OFStream *_outputStream; + OFStream *_header, *_impl; } - (instancetype)initWithLibrary: (OFXMLElement *)library - outputStream: (OFStream *)outputStream; + header: (OFStream *)header + implementation: (OFStream *)implementation; - (void)generate; @end Index: generators/library/GlueGenerator.m ================================================================== --- generators/library/GlueGenerator.m +++ generators/library/GlueGenerator.m @@ -27,11 +27,12 @@ #import "copyright.h" @implementation GlueGenerator - (instancetype)initWithLibrary: (OFXMLElement *)library - outputStream: (OFStream *)outputStream + header: (OFStream *)header + implementation: (OFStream *)impl { self = [super init]; @try { OFXMLAttribute *version; @@ -46,11 +47,12 @@ if (![version.stringValue isEqual: @"1.0"]) @throw [OFUnsupportedVersionException exceptionWithVersion: version.stringValue]; _library = [library retain]; - _outputStream = [outputStream retain]; + _header = [header retain]; + _impl = [impl retain]; } @catch (id e) { [self release]; @throw e; } @@ -58,29 +60,37 @@ } - (void)dealloc { [_library release]; - [_outputStream release]; + [_header release]; + [_impl release]; [super dealloc]; } - (void)generate { - [_outputStream writeString: COPYRIGHT]; - [_outputStream writeString: + [_header writeString: COPYRIGHT]; + [_impl writeString: COPYRIGHT]; + + [_header writeString: + @"/* This file is automatically generated from library.xml */\n" + @"\n"]; + + [_impl writeString: @"/* This file is automatically generated from library.xml */\n" @"\n" @"#include \"config.h\"\n" + @"\n" + @"#import \"amiga-glue.h\"\n" @"\n"]; for (OFXMLElement *include in [_library elementsForName: @"include"]) - [_outputStream writeFormat: @"#import \"%@\"\n", - include.stringValue]; + [_header writeFormat: @"#import \"%@\"\n", include.stringValue]; - [_outputStream writeString: + [_header writeString: @"\n" @"#ifdef OF_AMIGAOS_M68K\n" @"# define PPC_PARAMS(...) (void)\n" @"# define M68K_ARG(type, name, reg)\t\t\\\n" @"\tregister type reg##name __asm__(#reg);\t\\\n" @@ -87,11 +97,12 @@ @"\ttype name = reg##name;\n" @"#else\n" @"# define PPC_PARAMS(...) (__VA_ARGS__)\n" @"# define M68K_ARG(...)\n" @"#endif\n" - @"\n" + @"\n"]; + [_impl writeString: @"#ifdef OF_MORPHOS\n" @"/* All __saveds functions in this file need to use the SysV " @"ABI */\n" @"__asm__ (\n" @" \".section .text\\n\"\n" @@ -113,69 +124,86 @@ size_t argumentIndex; if (returnType == nil) returnType = @"void"; - [_outputStream writeFormat: @"\n" - @"%@ __saveds\n" - @"glue_%@", - returnType, name]; - - if (arguments.count > 0) - [_outputStream writeString: @" PPC_PARAMS("]; - else - [_outputStream writeString: @"(void"]; + [_header writeFormat: + @"extern %@%@glue_%@", + returnType, + (![returnType hasSuffix: @"*"] ? @" " : @""), + name]; + + [_impl writeFormat: @"\n" + @"%@ __saveds\n" + @"glue_%@", + returnType, name]; + + if (arguments.count > 0) { + [_header writeString: @" PPC_PARAMS("]; + [_impl writeString: @" PPC_PARAMS("]; + } else { + [_header writeString: @"(void"]; + [_impl writeString: @"(void"]; + } argumentIndex = 0; for (OFXMLElement *argument in arguments) { OFString *argName = [argument attributeForName: @"name"].stringValue; OFString *argType = [argument attributeForName: @"type"].stringValue; - if (argumentIndex++ > 0) - [_outputStream writeString: @", "]; + if (argumentIndex++ > 0) { + [_header writeString: @", "]; + [_impl writeString: @", "]; + } - [_outputStream writeString: argType]; - if (![argType hasSuffix: @"*"]) - [_outputStream writeString: @" "]; - [_outputStream writeString: argName]; + [_header writeString: argType]; + [_impl writeString: argType]; + if (![argType hasSuffix: @"*"]) { + [_header writeString: @" "]; + [_impl writeString: @" "]; + } + [_header writeString: argName]; + [_impl writeString: argName]; } - [_outputStream writeString: @")\n{\n"]; + [_header writeString: @");\n"]; + + [_impl writeString: @")\n{\n"]; for (OFXMLElement *argument in arguments) { OFString *argName = [argument attributeForName: @"name"].stringValue; OFString *argType = [argument attributeForName: @"type"].stringValue; OFString *m68kReg = [argument attributeForName: @"m68k-reg"].stringValue; - [_outputStream writeFormat: @"\tM68K_ARG(%@, %@, %@)\n", - argType, argName, m68kReg]; + [_impl writeFormat: @"\tM68K_ARG(%@, %@, %@)\n", + argType, argName, m68kReg]; } if (arguments.count > 0) - [_outputStream writeString: @"\n"]; + [_impl writeString: @"\n"]; if (![returnType isEqual: @"void"]) - [_outputStream writeString: @"\treturn "]; + [_impl writeString: @"\treturn "]; else - [_outputStream writeString: @"\t"]; + [_impl writeString: @"\t"]; - [_outputStream writeFormat: @"%@(", name]; + [_impl writeFormat: @"%@(", name]; argumentIndex = 0; for (OFXMLElement *argument in arguments) { OFString *argName = [argument attributeForName: @"name"].stringValue; if (argumentIndex++ > 0) - [_outputStream writeString: @", "]; + [_impl writeString: @", "]; - [_outputStream writeString: argName]; + [_impl writeString: argName]; } - [_outputStream writeString: @");\n}\n"]; + [_impl writeString: @");\n}\n"]; } } @end Index: generators/library/LibraryGenerator.m ================================================================== --- generators/library/LibraryGenerator.m +++ generators/library/LibraryGenerator.m @@ -38,27 +38,32 @@ URLByAppendingPathComponent: @"../../src"]; OFURL *runtimeLibraryURL = [sourcesURL URLByAppendingPathComponent: @"runtime/library.xml"]; OFURL *runtimeLinkLibURL = [sourcesURL URLByAppendingPathComponent: @"runtime/linklib/linklib.m"]; + OFURL *runtimeGlueHeaderURL = [sourcesURL + URLByAppendingPathComponent: @"runtime/amiga-glue.h"]; OFURL *runtimeGlueURL = [sourcesURL URLByAppendingPathComponent: @"runtime/amiga-glue.m"]; OFXMLElement *runtimeLibrary = [OFXMLElement elementWithStream: [OFFile fileWithURL: runtimeLibraryURL mode: @"r"]]; OFFile *runtimeLinkLib = [OFFile fileWithURL: runtimeLinkLibURL mode: @"w"]; + OFFile *runtimeGlueHeader = [OFFile fileWithURL: runtimeGlueHeaderURL + mode: @"w"]; OFFile *runtimeGlue = [OFFile fileWithURL: runtimeGlueURL mode: @"w"]; LinkLibGenerator *runtimeLinkLibGenerator = [[[LinkLibGenerator alloc] initWithLibrary: runtimeLibrary - outputStream: runtimeLinkLib] autorelease]; + implementation: runtimeLinkLib] autorelease]; GlueGenerator *runtimeGlueGenerator = [[[GlueGenerator alloc] initWithLibrary: runtimeLibrary - outputStream: runtimeGlue] autorelease]; + header: runtimeGlueHeader + implementation: runtimeGlue] autorelease]; [runtimeLinkLibGenerator generate]; [runtimeGlueGenerator generate]; [OFApplication terminate]; } @end Index: generators/library/LinkLibGenerator.h ================================================================== --- generators/library/LinkLibGenerator.h +++ generators/library/LinkLibGenerator.h @@ -20,12 +20,12 @@ #import "OFXMLElement.h" @interface LinkLibGenerator: OFObject { OFXMLElement *_library; - OFStream *_outputStream; + OFStream *_impl; } - (instancetype)initWithLibrary: (OFXMLElement *)library - outputStream: (OFStream *)outputStream; + implementation: (OFStream *)impl; - (void)generate; @end Index: generators/library/LinkLibGenerator.m ================================================================== --- generators/library/LinkLibGenerator.m +++ generators/library/LinkLibGenerator.m @@ -27,11 +27,11 @@ #import "copyright.h" @implementation LinkLibGenerator - (instancetype)initWithLibrary: (OFXMLElement *)library - outputStream: (OFStream *)outputStream + implementation: (OFStream *)impl { self = [super init]; @try { OFXMLAttribute *version; @@ -46,11 +46,11 @@ if (![version.stringValue isEqual: @"1.0"]) @throw [OFUnsupportedVersionException exceptionWithVersion: version.stringValue]; _library = [library retain]; - _outputStream = [outputStream retain]; + _impl = [impl retain]; } @catch (id e) { [self release]; @throw e; } @@ -58,11 +58,11 @@ } - (void)dealloc { [_library release]; - [_outputStream release]; + [_impl release]; [super dealloc]; } - (void)generate @@ -69,25 +69,25 @@ { OFString *libBase = [_library attributeForName: @"base"].stringValue; OFArray OF_GENERIC(OFXMLElement *) *functions; size_t funcIndex = 0; - [_outputStream writeString: COPYRIGHT]; - [_outputStream writeString: + [_impl writeString: COPYRIGHT]; + [_impl writeString: @"/* This file is automatically generated from library.xml */\n" @"\n" @"#include \"config.h\"\n" @"\n"]; for (OFXMLElement *include in [_library elementsForName: @"include"]) - [_outputStream writeFormat: @"#import \"%@\"\n", - include.stringValue]; + [_impl writeFormat: @"#import \"%@\"\n", + include.stringValue]; - [_outputStream writeFormat: @"\n" - @"extern struct Library *%@;\n" - @"\n", - libBase]; + [_impl writeFormat: @"\n" + @"extern struct Library *%@;\n" + @"\n", + libBase]; functions = [_library elementsForName: @"function"]; for (OFXMLElement *function in functions) { OFString *name = [function attributeForName: @"name"].stringValue; @@ -98,11 +98,11 @@ size_t argumentIndex; if (returnType == nil) returnType = @"void"; - [_outputStream writeFormat: @"%@\n%@(", returnType, name]; + [_impl writeFormat: @"%@\n%@(", returnType, name]; argumentIndex = 0; for (OFXMLElement *argument in [function elementsForName: @"argument"]) { OFString *argName = @@ -109,122 +109,120 @@ [argument attributeForName: @"name"].stringValue; OFString *argType = [argument attributeForName: @"type"].stringValue; if (argumentIndex++ > 0) - [_outputStream writeString: @", "]; + [_impl writeString: @", "]; - [_outputStream writeString: argType]; + [_impl writeString: argType]; if (![argType hasSuffix: @"*"]) - [_outputStream writeString: @" "]; - [_outputStream writeString: argName]; + [_impl writeString: @" "]; + [_impl writeString: argName]; } - [_outputStream writeFormat: + [_impl writeFormat: @")\n" @"{\n" @"#if defined(OF_AMIGAOS_M68K)\n" @"\tregister struct Library *a6 __asm__(\"a6\") = %@;\n" @"\t(void)a6;\n" @"\t", libBase]; if (![returnType isEqual: @"void"]) - [_outputStream writeString: @"return "]; + [_impl writeString: @"return "]; - [_outputStream writeString: @"(("]; - [_outputStream writeString: returnType]; + [_impl writeString: @"(("]; + [_impl writeString: returnType]; if (![returnType hasSuffix: @"*"]) - [_outputStream writeString: @" "]; - [_outputStream writeString: @"(*)("]; + [_impl writeString: @" "]; + [_impl writeString: @"(*)("]; argumentIndex = 0; for (OFXMLElement *argument in arguments) { OFString *argType = [argument attributeForName: @"type"].stringValue; OFString *m68kReg = [argument attributeForName: @"m68k-reg"].stringValue; if (argumentIndex++ > 0) - [_outputStream writeString: @", "]; + [_impl writeString: @", "]; - [_outputStream writeString: argType]; + [_impl writeString: argType]; if (![argType hasSuffix: @"*"]) - [_outputStream writeString: @" "]; - [_outputStream writeFormat: @"__asm__(\"%@\")", + [_impl writeString: @" "]; + [_impl writeFormat: @"__asm__(\"%@\")", m68kReg]; } - [_outputStream writeFormat: @"))(((uintptr_t)%@) - %zu))(", - libBase, 30 + funcIndex * 6]; + [_impl writeFormat: @"))(((uintptr_t)%@) - %zu))(", + libBase, 30 + funcIndex * 6]; argumentIndex = 0; for (OFXMLElement *argument in [function elementsForName: @"argument"]) { OFString *argName = [argument attributeForName: @"name"].stringValue; if (argumentIndex++ > 0) - [_outputStream writeString: @", "]; - - [_outputStream writeString: argName]; - } - - [_outputStream writeFormat: - @");\n" - @"#elif defined(OF_MORPHOS)\n" - @"\t__asm__ __volatile__ (\n" - @"\t \"mr\t\t%%%%r12, %%0\"\n" - @"\t :: \"r\"(%@) : \"r12\"\n" - @"\t);\n" - @"\n" - @"\t", - libBase, libBase]; + [_impl writeString: @", "]; + + [_impl writeString: argName]; + } + + [_impl writeFormat: @");\n" + @"#elif defined(OF_MORPHOS)\n" + @"\t__asm__ __volatile__ (\n" + @"\t \"mr\t\t%%%%r12, %%0\"\n" + @"\t :: \"r\"(%@) : \"r12\"\n" + @"\t);\n" + @"\n" + @"\t", + libBase, libBase]; if (![returnType isEqual: @"void"]) - [_outputStream writeString: @"return "]; + [_impl writeString: @"return "]; - [_outputStream writeString: @"__extension__ (("]; - [_outputStream writeString: returnType]; + [_impl writeString: @"__extension__ (("]; + [_impl writeString: returnType]; if (![returnType hasSuffix: @"*"]) - [_outputStream writeString: @" "]; - [_outputStream writeString: @"(*)("]; + [_impl writeString: @" "]; + [_impl writeString: @"(*)("]; argumentIndex = 0; for (OFXMLElement *argument in arguments) { OFString *argType = [argument attributeForName: @"type"].stringValue; if (argumentIndex++ > 0) - [_outputStream writeString: @", "]; + [_impl writeString: @", "]; - [_outputStream writeString: argType]; + [_impl writeString: argType]; } - [_outputStream writeFormat: - @"))*(void **)(((uintptr_t)%@) - %zu))(", - libBase, 28 + funcIndex * 6]; + [_impl writeFormat: @"))*(void **)(((uintptr_t)%@) - %zu))(", + libBase, 28 + funcIndex * 6]; argumentIndex = 0; for (OFXMLElement *argument in [function elementsForName: @"argument"]) { OFString *argName = [argument attributeForName: @"name"].stringValue; if (argumentIndex++ > 0) - [_outputStream writeString: @", "]; + [_impl writeString: @", "]; - [_outputStream writeString: argName]; + [_impl writeString: argName]; } - [_outputStream writeString: @");\n" - @"#endif\n"]; + [_impl writeString: @");\n" + @"#endif\n"]; if ([function attributeForName: @"noreturn"] != nil) - [_outputStream writeString: @"\n\tOF_UNREACHABLE\n"]; + [_impl writeString: @"\n\tOF_UNREACHABLE\n"]; - [_outputStream writeString: @"}\n"]; + [_impl writeString: @"}\n"]; if (++funcIndex < functions.count) - [_outputStream writeString: @"\n"]; + [_impl writeString: @"\n"]; } } @end ADDED src/runtime/amiga-glue.h Index: src/runtime/amiga-glue.h ================================================================== --- src/runtime/amiga-glue.h +++ src/runtime/amiga-glue.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, + * 2018, 2019, 2020 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +/* This file is automatically generated from library.xml */ + +#import "ObjFWRT.h" +#import "private.h" + +#ifdef OF_AMIGAOS_M68K +# define PPC_PARAMS(...) (void) +# define M68K_ARG(type, name, reg) \ + register type reg##name __asm__(#reg); \ + type name = reg##name; +#else +# define PPC_PARAMS(...) (__VA_ARGS__) +# define M68K_ARG(...) +#endif + +extern bool glue_objc_init PPC_PARAMS(unsigned int version, struct objc_libc *libc); +extern void glue___objc_exec_class PPC_PARAMS(struct objc_module *_Nonnull module); +extern IMP _Nonnull glue_objc_msg_lookup PPC_PARAMS(id _Nullable object, SEL _Nonnull selector); +extern IMP _Nonnull glue_objc_msg_lookup_stret PPC_PARAMS(id _Nullable object, SEL _Nonnull selector); +extern IMP _Nonnull glue_objc_msg_lookup_super PPC_PARAMS(struct objc_super *_Nonnull super, SEL _Nonnull selector); +extern IMP _Nonnull glue_objc_msg_lookup_super_stret PPC_PARAMS(struct objc_super *_Nonnull super, SEL _Nonnull selector); +extern Class _Nullable glue_objc_lookUpClass PPC_PARAMS(const char *_Nonnull name); +extern Class _Nullable glue_objc_getClass PPC_PARAMS(const char *_Nonnull name); +extern Class _Nonnull glue_objc_getRequiredClass PPC_PARAMS(const char *_Nonnull name); +extern Class _Nullable glue_objc_lookup_class PPC_PARAMS(const char *_Nonnull name); +extern Class _Nonnull glue_objc_get_class PPC_PARAMS(const char *_Nonnull name); +extern void glue_objc_exception_throw PPC_PARAMS(id _Nonnull object); +extern int glue_objc_sync_enter PPC_PARAMS(id _Nullable object); +extern int glue_objc_sync_exit PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_getProperty PPC_PARAMS(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, bool atomic); +extern void glue_objc_setProperty PPC_PARAMS(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, id _Nullable value, bool atomic, signed char copy); +extern void glue_objc_getPropertyStruct PPC_PARAMS(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong); +extern void glue_objc_setPropertyStruct PPC_PARAMS(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong); +extern void glue_objc_enumerationMutation PPC_PARAMS(id _Nonnull object); +extern int glue___gnu_objc_personality PPC_PARAMS(int version, int actions, uint64_t *_Nonnull exClass, void *_Nonnull ex, void *_Nonnull ctx); +extern id _Nullable glue_objc_retain PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_retainBlock PPC_PARAMS(id _Nullable block); +extern id _Nullable glue_objc_retainAutorelease PPC_PARAMS(id _Nullable object); +extern void glue_objc_release PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_autorelease PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_autoreleaseReturnValue PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_retainAutoreleaseReturnValue PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_retainAutoreleasedReturnValue PPC_PARAMS(id _Nullable object); +extern id _Nullable glue_objc_storeStrong PPC_PARAMS(id _Nullable *_Nonnull object, id _Nullable value); +extern id _Nullable glue_objc_storeWeak PPC_PARAMS(id _Nullable *_Nonnull object, id _Nullable value); +extern id _Nullable glue_objc_loadWeakRetained PPC_PARAMS(id _Nullable *_Nonnull object); +extern id _Nullable glue_objc_initWeak PPC_PARAMS(id _Nullable *_Nonnull object, id _Nullable value); +extern void glue_objc_destroyWeak PPC_PARAMS(id _Nullable *_Nonnull object); +extern id _Nullable glue_objc_loadWeak PPC_PARAMS(id _Nullable *_Nonnull object); +extern void glue_objc_copyWeak PPC_PARAMS(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src); +extern void glue_objc_moveWeak PPC_PARAMS(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src); +extern SEL _Nonnull glue_sel_registerName PPC_PARAMS(const char *_Nonnull name); +extern const char *_Nonnull glue_sel_getName PPC_PARAMS(SEL _Nonnull selector); +extern bool glue_sel_isEqual PPC_PARAMS(SEL _Nonnull selector1, SEL _Nonnull selector2); +extern Class _Nonnull glue_objc_allocateClassPair PPC_PARAMS(Class _Nullable superclass, const char *_Nonnull name, size_t extraBytes); +extern void glue_objc_registerClassPair PPC_PARAMS(Class _Nonnull class); +extern unsigned int glue_objc_getClassList PPC_PARAMS(Class _Nonnull *_Nullable buffer, unsigned int count); +extern Class _Nonnull *_Nonnull glue_objc_copyClassList PPC_PARAMS(unsigned int *_Nullable length); +extern bool glue_class_isMetaClass PPC_PARAMS(Class _Nullable class); +extern const char *_Nullable glue_class_getName PPC_PARAMS(Class _Nullable class); +extern Class _Nullable glue_class_getSuperclass PPC_PARAMS(Class _Nullable class); +extern unsigned long glue_class_getInstanceSize PPC_PARAMS(Class _Nullable class); +extern bool glue_class_respondsToSelector PPC_PARAMS(Class _Nullable class, SEL _Nonnull selector); +extern bool glue_class_conformsToProtocol PPC_PARAMS(Class _Nullable class, Protocol *_Nonnull p); +extern IMP _Nullable glue_class_getMethodImplementation PPC_PARAMS(Class _Nullable class, SEL _Nonnull selector); +extern IMP _Nullable glue_class_getMethodImplementation_stret PPC_PARAMS(Class _Nullable class, SEL _Nonnull selector); +extern Method _Nullable glue_class_getInstanceMethod PPC_PARAMS(Class _Nullable class, SEL _Nonnull selector); +extern bool glue_class_addMethod PPC_PARAMS(Class _Nonnull class, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding); +extern IMP _Nullable glue_class_replaceMethod PPC_PARAMS(Class _Nonnull class, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding); +extern Class _Nullable glue_object_getClass PPC_PARAMS(id _Nullable object); +extern Class _Nullable glue_object_setClass PPC_PARAMS(id _Nullable object, Class _Nonnull class); +extern const char *_Nullable glue_object_getClassName PPC_PARAMS(id _Nullable object); +extern const char *_Nonnull glue_protocol_getName PPC_PARAMS(Protocol *_Nonnull protocol); +extern bool glue_protocol_isEqual PPC_PARAMS(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2); +extern bool glue_protocol_conformsToProtocol PPC_PARAMS(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2); +extern _Nullable objc_uncaught_exception_handler_t glue_objc_setUncaughtExceptionHandler PPC_PARAMS(objc_uncaught_exception_handler_t _Nullable handler); +extern void glue_objc_setForwardHandler PPC_PARAMS(IMP _Nullable forward, IMP _Nullable stretForward); +extern void glue_objc_setEnumerationMutationHandler PPC_PARAMS(objc_enumeration_mutation_handler_t _Nullable hadler); +extern id _Nullable glue_objc_constructInstance PPC_PARAMS(Class _Nullable class, void *_Nullable bytes); +extern void glue_objc_exit(void); +extern Ivar _Nullable *_Nullable glue_class_copyIvarList PPC_PARAMS(Class _Nullable class, unsigned int *_Nullable outCount); +extern const char *_Nonnull glue_ivar_getName PPC_PARAMS(Ivar _Nonnull ivar); +extern const char *_Nonnull glue_ivar_getTypeEncoding PPC_PARAMS(Ivar _Nonnull ivar); +extern ptrdiff_t glue_ivar_getOffset PPC_PARAMS(Ivar _Nonnull ivar); +extern Method _Nullable *_Nullable glue_class_copyMethodList PPC_PARAMS(Class _Nullable class, unsigned int *_Nullable outCount); +extern SEL _Nonnull glue_method_getName PPC_PARAMS(Method _Nonnull method); +extern const char *_Nullable glue_method_getTypeEncoding PPC_PARAMS(Method _Nonnull method); +extern objc_property_t _Nullable *_Nullable glue_class_copyPropertyList PPC_PARAMS(Class _Nullable class, unsigned int *_Nullable outCount); +extern const char *_Nonnull glue_property_getName PPC_PARAMS(objc_property_t _Nonnull property); +extern char *_Nullable glue_property_copyAttributeValue PPC_PARAMS(objc_property_t _Nonnull property, const char *_Nonnull name); +extern void *_Nullable glue_objc_destructInstance PPC_PARAMS(id _Nullable object); +extern void *_Null_unspecified glue_objc_autoreleasePoolPush(void); +extern void glue_objc_autoreleasePoolPop PPC_PARAMS(void *_Null_unspecified pool); +extern id _Nullable glue__objc_rootAutorelease PPC_PARAMS(id _Nullable object); +extern struct objc_hashtable *_Nonnull glue_objc_hashtable_new PPC_PARAMS(objc_hashtable_hash_func hash, objc_hashtable_equal_func equal, uint32_t size); +extern void glue_objc_hashtable_set PPC_PARAMS(struct objc_hashtable *_Nonnull table, const void *_Nonnull key, const void *_Nonnull object); +extern void *_Nullable glue_objc_hashtable_get PPC_PARAMS(struct objc_hashtable *_Nonnull table, const void *_Nonnull key); +extern void glue_objc_hashtable_delete PPC_PARAMS(struct objc_hashtable *_Nonnull table, const void *_Nonnull key); +extern void glue_objc_hashtable_free PPC_PARAMS(struct objc_hashtable *_Nonnull table); +extern void glue_objc_setTaggedPointerSecret PPC_PARAMS(uintptr_t secret); +extern int glue_objc_registerTaggedPointerClass PPC_PARAMS(Class _Nonnull class); +extern bool glue_object_isTaggedPointer PPC_PARAMS(id _Nullable object); +extern uintptr_t glue_object_getTaggedPointerValue PPC_PARAMS(id _Nonnull object); +extern id _Nullable glue_objc_createTaggedPointer PPC_PARAMS(int class, uintptr_t value); Index: src/runtime/amiga-glue.m ================================================================== --- src/runtime/amiga-glue.m +++ src/runtime/amiga-glue.m @@ -17,22 +17,11 @@ /* This file is automatically generated from library.xml */ #include "config.h" -#import "ObjFWRT.h" -#import "private.h" - -#ifdef OF_AMIGAOS_M68K -# define PPC_PARAMS(...) (void) -# define M68K_ARG(type, name, reg) \ - register type reg##name __asm__(#reg); \ - type name = reg##name; -#else -# define PPC_PARAMS(...) (__VA_ARGS__) -# define M68K_ARG(...) -#endif +#import "amiga-glue.h" #ifdef OF_MORPHOS /* All __saveds functions in this file need to use the SysV ABI */ __asm__ ( ".section .text\n" Index: src/runtime/amiga-library.m ================================================================== --- src/runtime/amiga-library.m +++ src/runtime/amiga-library.m @@ -17,10 +17,12 @@ #include "config.h" #import "ObjFWRT.h" #import "private.h" + +#import "amiga-glue.h" #include #include #include #include @@ -67,101 +69,10 @@ extern uintptr_t __CTOR_LIST__[]; extern const void *_EH_FRAME_BEGINS__; extern void *_EH_FRAME_OBJECTS__; #endif -extern bool glue_objc_init(void); -extern void glue___objc_exec_class(void); -extern IMP glue_objc_msg_lookup(void); -extern IMP glue_objc_msg_lookup_stret(void); -extern IMP glue_objc_msg_lookup_super(void); -extern IMP glue_objc_msg_lookup_super_stret(void); -extern Class glue_objc_lookUpClass(void); -extern Class glue_objc_getClass(void); -extern Class glue_objc_getRequiredClass(void); -extern Class glue_objc_lookup_class(void); -extern Class glue_objc_get_class(void); -extern void glue_objc_exception_throw(void); -extern int glue_objc_sync_enter(void); -extern int glue_objc_sync_exit(void); -extern id glue_objc_getProperty(void); -extern void glue_objc_setProperty(void); -extern void glue_objc_getPropertyStruct(void); -extern void glue_objc_setPropertyStruct(void); -extern void glue_objc_enumerationMutation(void); -extern int glue___gnu_objc_personality(void); -extern id glue_objc_retain(void); -extern id glue_objc_retainBlock(void); -extern id glue_objc_retainAutorelease(void); -extern void glue_objc_release(void); -extern id glue_objc_autorelease(void); -extern id glue_objc_autoreleaseReturnValue(void); -extern id glue_objc_retainAutoreleaseReturnValue(void); -extern id glue_objc_retainAutoreleasedReturnValue(void); -extern id glue_objc_storeStrong(void); -extern id glue_objc_storeWeak(void); -extern id glue_objc_loadWeakRetained(void); -extern id glue_objc_initWeak(void); -extern void glue_objc_destroyWeak(void); -extern id glue_objc_loadWeak(void); -extern void glue_objc_copyWeak(void); -extern void glue_objc_moveWeak(void); -extern SEL glue_sel_registerName(void); -extern const char *glue_sel_getName(void); -extern bool glue_sel_isEqual(void); -extern Class glue_objc_allocateClassPair(void); -extern void glue_objc_registerClassPair(void); -extern unsigned int glue_objc_getClassList(void); -extern Class *glue_objc_copyClassList(void); -extern bool glue_class_isMetaClass(void); -extern const char *glue_class_getName(void); -extern Class glue_class_getSuperclass(void); -extern unsigned long glue_class_getInstanceSize(void); -extern bool glue_class_respondsToSelector(void); -extern bool glue_class_conformsToProtocol(void); -extern IMP glue_class_getMethodImplementation(void); -extern IMP glue_class_getMethodImplementation_stret(void); -extern Method glue_class_getInstanceMethod(void); -extern bool glue_class_addMethod(void); -extern IMP glue_class_replaceMethod(void); -extern Class glue_object_getClass(void); -extern Class glue_object_setClass(void); -extern const char *glue_object_getClassName(void); -extern const char *glue_protocol_getName(void); -extern bool glue_protocol_isEqual(void); -extern bool glue_protocol_conformsToProtocol(void); -extern objc_uncaught_exception_handler_t - glue_objc_setUncaughtExceptionHandler(void); -extern void glue_objc_setForwardHandler(void); -extern void glue_objc_setEnumerationMutationHandler(void); -extern id glue_objc_constructInstance(void); -extern void glue_objc_exit(void); -extern Ivar *glue_class_copyIvarList(void); -extern const char *glue_ivar_getName(void); -extern const char *glue_ivar_getTypeEncoding(void); -extern ptrdiff_t glue_ivar_getOffset(void); -extern Method *glue_class_copyMethodList(void); -extern SEL glue_method_getName(void); -extern const char *glue_method_getTypeEncoding(void); -extern objc_property_t *glue_class_copyPropertyList(void); -extern const char *glue_property_getName(void); -extern char *glue_property_copyAttributeValue(void); -extern void *glue_objc_destructInstance(void); -extern void *glue_objc_autoreleasePoolPush(void); -extern void glue_objc_autoreleasePoolPop(void); -extern id glue__objc_rootAutorelease(void); -extern struct objc_hashtable *glue_objc_hashtable_new(void); -extern void glue_objc_hashtable_set(void); -extern void *glue_objc_hashtable_get(void); -extern void glue_objc_hashtable_delete(void); -extern void glue_objc_hashtable_free(void); -extern void glue_objc_setTaggedPointerSecret(void); -extern int glue_objc_registerTaggedPointerClass(void); -extern bool glue_object_isTaggedPointer(void); -extern uintptr_t glue_object_getTaggedPointerValue(void); -extern id glue_objc_createTaggedPointer(void); - #ifdef OF_MORPHOS const ULONG __abox__ = 1; #endif struct ExecBase *SysBase; struct objc_libc libc;