Merge pull request #109 from alliedmodders/binreloc

Enable binreloc for OS X.
This commit is contained in:
David Anderson 2014-07-24 03:24:52 -07:00
commit 6e48ded1a6
4 changed files with 31 additions and 25 deletions

View File

@ -441,6 +441,7 @@ REGISTER_NATIVES(nativeNatives)
{"GetNativeArray", GetNativeArray}, {"GetNativeArray", GetNativeArray},
{"GetNativeCell", GetNativeCell}, {"GetNativeCell", GetNativeCell},
{"GetNativeCellRef", GetNativeCellRef}, {"GetNativeCellRef", GetNativeCellRef},
{"GetNativeFunction", GetNativeCell},
{"GetNativeString", GetNativeString}, {"GetNativeString", GetNativeString},
{"GetNativeStringLength", GetNativeStringLength}, {"GetNativeStringLength", GetNativeStringLength},
{"FormatNativeString", FormatNativeString}, {"FormatNativeString", FormatNativeString},

View File

@ -428,6 +428,15 @@ native SetNativeString(param, const String:source[], maxlength, bool:utf8=true,
*/ */
native any:GetNativeCell(param); native any:GetNativeCell(param);
/**
* Gets a function pointer from a native parameter.
*
* @param param Parameter number, starting from 1.
* @return Function pointer at the given parameter number.
* @error Invalid parameter number, or calling from a non-native function.
*/
native Function GetNativeFunction(param);
/** /**
* Gets a cell from a native parameter, by reference. * Gets a cell from a native parameter, by reference.
* *

View File

@ -70,7 +70,7 @@ binary.sources += [
'zlib/zutil.c', 'zlib/zutil.c',
'sp_symhash.c' 'sp_symhash.c'
] ]
if builder.target_platform == 'linux': if builder.target_platform != 'windows':
binary.sources.append('binreloc.c') binary.sources.append('binreloc.c')
SM.spcomp = builder.Add(binary) SM.spcomp = builder.Add(binary)

View File

@ -654,7 +654,7 @@ const char *pc_tagname(int tag)
if ((int)(ptr->value & TAGMASK) == (tag & TAGMASK)) if ((int)(ptr->value & TAGMASK) == (tag & TAGMASK))
return ptr->name; return ptr->name;
} }
return "<unknown>"; return "__unknown__";
} }
constvalue *pc_tagptr(const char *name) constvalue *pc_tagptr(const char *name)
@ -1196,9 +1196,6 @@ static void setopt(int argc,char **argv,char *oname,char *ename,char *pname,
#endif #endif
static void setconfig(char *root) static void setconfig(char *root)
{ {
#if defined macintosh
insert_path(":include:");
#else
char path[_MAX_PATH]; char path[_MAX_PATH];
char *ptr,*base; char *ptr,*base;
int len; int len;
@ -1206,7 +1203,7 @@ static void setconfig(char *root)
/* add the default "include" directory */ /* add the default "include" directory */
#if defined __WIN32__ || defined _WIN32 #if defined __WIN32__ || defined _WIN32
GetModuleFileNameA(NULL,path,_MAX_PATH); GetModuleFileNameA(NULL,path,_MAX_PATH);
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ #elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined DARWIN
/* see www.autopackage.org for the BinReloc module */ /* see www.autopackage.org for the BinReloc module */
br_init_lib(NULL); br_init_lib(NULL);
ptr=br_find_exe("spcomp"); ptr=br_find_exe("spcomp");
@ -1215,7 +1212,6 @@ static void setconfig(char *root)
#else #else
if (root!=NULL) if (root!=NULL)
strlcpy(path,root,sizeof path); /* path + filename (hopefully) */ strlcpy(path,root,sizeof path); /* path + filename (hopefully) */
#endif
# if defined __MSDOS__ # if defined __MSDOS__
/* strip the options (appended to the path + filename) */ /* strip the options (appended to the path + filename) */
if ((ptr=strpbrk(path," \t/"))!=NULL) if ((ptr=strpbrk(path," \t/"))!=NULL)
@ -2882,7 +2878,7 @@ static void decl_const(int vclass)
if (expecttoken(tSYMBOL, &tok)) if (expecttoken(tSYMBOL, &tok))
strcpy(constname, tok.str); strcpy(constname, tok.str);
else else
strcpy(constname, "<unknown>"); strcpy(constname, "__unknown__");
symbolline=fline; /* save line where symbol was found */ symbolline=fline; /* save line where symbol was found */
needtoken('='); needtoken('=');
@ -3266,7 +3262,7 @@ static int parse_old_decl(declinfo_t *decl, int flags)
if ((flags & DECLFLAG_MAYBE_FUNCTION) && matchtoken(tOPERATOR)) { if ((flags & DECLFLAG_MAYBE_FUNCTION) && matchtoken(tOPERATOR)) {
decl->opertok = operatorname(decl->name); decl->opertok = operatorname(decl->name);
if (decl->opertok == 0) if (decl->opertok == 0)
strcpy(decl->name, "<unknown>"); strcpy(decl->name, "__unknown__");
} else { } else {
if (!lexpeek(tSYMBOL)) { if (!lexpeek(tSYMBOL)) {
switch (lextok(&tok)) { switch (lextok(&tok)) {
@ -3284,7 +3280,7 @@ static int parse_old_decl(declinfo_t *decl, int flags)
if (expecttoken(tSYMBOL, &tok)) if (expecttoken(tSYMBOL, &tok))
strcpy(decl->name, tok.str); strcpy(decl->name, tok.str);
else else
strcpy(decl->name, "<unknown>"); strcpy(decl->name, "__unknown__");
} }
} }
@ -3322,10 +3318,10 @@ static int parse_new_decl(declinfo_t *decl, const token_t *first, int flags)
if ((flags & DECLFLAG_MAYBE_FUNCTION) && matchtoken(tOPERATOR)) { if ((flags & DECLFLAG_MAYBE_FUNCTION) && matchtoken(tOPERATOR)) {
decl->opertok = operatorname(decl->name); decl->opertok = operatorname(decl->name);
if (decl->opertok == 0) if (decl->opertok == 0)
strcpy(decl->name, "<unknown>"); strcpy(decl->name, "__unknown__");
} else { } else {
if (!expecttoken(tSYMBOL, &tok)) { if (!expecttoken(tSYMBOL, &tok)) {
strcpy(decl->name, "<unknown>"); strcpy(decl->name, "__unknown__");
return FALSE; return FALSE;
} }
strcpy(decl->name, tok.str); strcpy(decl->name, tok.str);
@ -3477,7 +3473,7 @@ static void define_constructor(methodmap_t *map, methodmap_method_t *method)
symbol *sym = findglb(map->name, sGLOBAL); symbol *sym = findglb(map->name, sGLOBAL);
if (sym) { if (sym) {
const char *type = "<unknown>"; const char *type = "__unknown__";
switch (sym->ident) { switch (sym->ident) {
case iVARIABLE: case iVARIABLE:
case iARRAY: case iARRAY:
@ -3783,11 +3779,11 @@ methodmap_method_t *parse_method(methodmap_t *map)
// This stores the name of the method (for destructors, we add a ~). // This stores the name of the method (for destructors, we add a ~).
token_ident_t ident; token_ident_t ident;
strcpy(ident.name, "<unknown>"); strcpy(ident.name, "__unknown__");
// For binding syntax, like X() = Y, this stores the right-hand name. // For binding syntax, like X() = Y, this stores the right-hand name.
token_ident_t bindsource; token_ident_t bindsource;
strcpy(bindsource.name, "<unknown>"); strcpy(bindsource.name, "__unknown__");
typeinfo_t type; typeinfo_t type;
memset(&type, 0, sizeof(type)); memset(&type, 0, sizeof(type));