123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- #include "objc-private.h"
- #include "objc-load.h"
- #if !__OBJC2__ && !TARGET_OS_WIN32
- extern void (*callbackFunction)( Class, Category );
- int objc_loadModule(char *moduleName, void (*class_callback) (Class, Category), int *errorCode)
- {
- int successFlag = 1;
- int locErrorCode;
- NSObjectFileImage objectFileImage;
- NSObjectFileImageReturnCode code;
-
- if (errorCode == NULL)
- errorCode = &locErrorCode;
- if (moduleName == NULL)
- {
- *errorCode = NSObjectFileImageInappropriateFile;
- return 0;
- }
- if (_dyld_present () == 0)
- {
- *errorCode = NSObjectFileImageFailure;
- return 0;
- }
- callbackFunction = class_callback;
- code = NSCreateObjectFileImageFromFile (moduleName, &objectFileImage);
- if (code != NSObjectFileImageSuccess)
- {
- *errorCode = code;
- return 0;
- }
- if (NSLinkModule(objectFileImage, moduleName, NSLINKMODULE_OPTION_RETURN_ON_ERROR) == NULL) {
- NSLinkEditErrors error;
- int errorNum;
- const char *fileName, *errorString;
- NSLinkEditError(&error, &errorNum, &fileName, &errorString);
-
- *errorCode = error;
- return 0;
- }
- callbackFunction = NULL;
- return successFlag;
- }
- long objc_loadModules (char * modlist[],
- void * errStream,
- void (*class_callback) (Class, Category),
- headerType ** hdr_addr,
- char * debug_file)
- {
- char ** modules;
- int code;
- int itWorked;
- if (modlist == 0)
- return 0;
- for (modules = &modlist[0]; *modules != 0; modules++)
- {
- itWorked = objc_loadModule (*modules, class_callback, &code);
- if (itWorked == 0)
- {
-
-
- return 1;
- }
- if (hdr_addr)
- *(hdr_addr++) = 0;
- }
- return 0;
- }
- long objc_unloadModules (void * errStream,
- void (*unload_callback) (Class, Category))
- {
- headerType * header_addr = 0;
- int errflag = 0;
-
- if (header_addr)
- {
- ;
- }
- else
- {
- errflag = 1;
- }
- return errflag;
- }
- #endif
|