summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-08-24 14:15:44 (GMT)
committerGuido van Rossum <guido@python.org>1998-08-24 14:15:44 (GMT)
commitab076fdb6fa93542b3209d75002ce7e573758536 (patch)
tree1a0b10fbb551a5c4d139d35e03e333b780484b0b /Python
parent747e1cade657e1e15c0f51d898de901da723e6a2 (diff)
downloadcpython-ab076fdb6fa93542b3209d75002ce7e573758536.zip
cpython-ab076fdb6fa93542b3209d75002ce7e573758536.tar.gz
cpython-ab076fdb6fa93542b3209d75002ce7e573758536.tar.bz2
Ted Horst writes in psa-members@python.org:
This is a patch that Bill Bummgarner did for 1.4 that hasn't made its way into the distribution yet. This is important if you want to use the ObjC module.
Diffstat (limited to 'Python')
-rw-r--r--Python/importdl.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/Python/importdl.c b/Python/importdl.c
index 2947d15..ef015ad 100644
--- a/Python/importdl.c
+++ b/Python/importdl.c
@@ -120,6 +120,18 @@ typedef FARPROC dl_funcptr;
#ifdef NeXT
#define DYNAMIC_LINK
#define USE_RLD
+/* Define this to 1 if you want be able to load ObjC modules as well:
+ it switches between two different way of loading modules on the NeXT,
+ one that directly interfaces with the dynamic loader (rld_load(), which
+ does not correctly load ObjC object files), and another that uses the
+ ObjC runtime (objc_loadModules()) to do the job.
+ You'll have to add ``-ObjC'' to the compiler flags if you set this to 1.
+*/
+#define HANDLE_OBJC_MODULES 1
+#if HANDLE_OBJC_MODULES
+#include <objc/Object.h>
+#include <objc/objc-load.h>
+#endif
#define SHORT_EXT ".so"
#define LONG_EXT "module.so"
#endif
@@ -584,9 +596,38 @@ _PyImport_LoadDynamicModule(name, pathname, fp)
errorStream = NXOpenMemory(NULL, 0, NX_WRITEONLY);
filenames[0] = pathname;
filenames[1] = NULL;
+
+#if HANDLE_OBJC_MODULES
+
+/* The following very bogus line of code ensures that
+ objc_msgSend, etc are linked into the binary. Without
+ it, dynamic loading of a module that includes objective-c
+ method calls will fail with "undefined symbol _objc_msgSend()".
+ This remains true even in the presence of the -ObjC flag
+ to the compiler
+*/
+
+ [Object name];
+
+/* objc_loadModules() dynamically loads the object files
+ indicated by the paths in filenames. If there are any
+ errors generated during loading -- typically due to the
+ inability to find particular symbols -- an error message
+ will be written to errorStream.
+ It returns 0 if the module is successfully loaded, 1
+ otherwise.
+*/
+
+ ret = !objc_loadModules(filenames, errorStream,
+ NULL, &new_header, NULL);
+
+#else /* !HANDLE_OBJC_MODULES */
+
ret = rld_load(errorStream, &new_header,
filenames, NULL);
+#endif /* HANDLE_OBJC_MODULES */
+
/* extract the error messages for the exception */
if(!ret) {
char *streamBuf;