[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[DotGNU]progress on x11-winforms on os x
From: |
Ian Fung |
Subject: |
[DotGNU]progress on x11-winforms on os x |
Date: |
Sun, 15 Jun 2003 00:19:33 -0400 |
rhysw,
we should think about using dlcompat instead of calling all the NS*
functions ourselves, for example, this is the dlopen() function in
dlcompat. but right now let's just try to get something to show up on
os x first.
void *dlopen(const char *path, int mode)
{
void *module = 0;
NSObjectFileImage ofi = 0;
NSObjectFileImageReturnCode ofirc;
static int (*make_private_module_public) (NSModule module) = 0;
unsigned int flags = NSLINKMODULE_OPTION_RETURN_ON_ERROR |
NSLINKMODULE_OPTION_PRIVATE;
/* If we got no path, the app wants the global namespace, use -1 as
the marker
in this case */
if (!path)
return (void *)-1;
/* Create the object file image, works for things linked with the
-bundle arg to ld */
ofirc = NSCreateObjectFileImageFromFile(path, &ofi);
switch (ofirc)
{
case NSObjectFileImageSuccess:
/* It was okay, so use NSLinkModule to link in the
image */
if (!(mode & RTLD_LAZY)) flags +=
NSLINKMODULE_OPTION_BINDNOW;
module = NSLinkModule(ofi, path,flags);
/* Don't forget to destroy the object file image,
unless you like
leaks */
NSDestroyObjectFileImage(ofi);
/* If the mode was global, then change the module, this
avoids
multiply defined symbol errors to first load private
then make
global. Silly, isn't it. */
if ((mode & RTLD_GLOBAL))
{
if (!make_private_module_public)
{
_dyld_func_lookup("__dyld_NSMakePrivateModulePublic",
(unsigned long *)&make_private_module_public);
}
make_private_module_public(module);
}
break;
case NSObjectFileImageInappropriateFile:
/* It may have been a dynamic library rather than a
bundle, try to
load it */
module = (void *)NSAddImage(path,
NSADDIMAGE_OPTION_RETURN_ON_ERROR);
break;
case NSObjectFileImageFailure:
error(0,"Object file setup failure : \"%s\"", path);
return 0;
case NSObjectFileImageArch: