Skip to content

Commit

Permalink
don't define global symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
mbalmer committed Feb 14, 2016
1 parent 4942bc6 commit beda6aa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion constants.c
Expand Up @@ -12,7 +12,7 @@
* * Neither the name of Micro Systems Marc Balmer nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand Down
42 changes: 20 additions & 22 deletions luamotif.c
Expand Up @@ -423,6 +423,9 @@ lm_getArgs(lua_State *L, int start, Arg **args)
case LUA_TNIL:
break;
case LUA_TBOOLEAN:
XtSetArg((*args)[narg], (String)arg, (XtArgVal)
(int)lua_toboolean(L, n));
narg++;
break;
case LUA_TTABLE:
break;
Expand Down Expand Up @@ -939,16 +942,16 @@ lm_set_info(lua_State *L) {
lua_pushliteral(L, "Motif binding for Lua");
lua_settable(L, -3);
lua_pushliteral(L, "_VERSION");
lua_pushliteral(L, "Motif 1.1.5");
lua_pushliteral(L, "Motif 1.2.0");
lua_settable(L, -3);
}

static void
register_global(lua_State *L, struct luaL_Reg *reg)
lm_register(lua_State *L, struct luaL_Reg *reg)
{
while (reg->name != NULL) {
lua_pushcfunction(L, reg->func);
lua_setglobal(L, reg->name);
lua_setfield(L, -2, reg->name);
reg++;
}
}
Expand Down Expand Up @@ -1043,10 +1046,6 @@ lm_newindex(lua_State *L)
free(args[n].name);
}
}
#if 0
else
printf("newindex on non-widget\n");
#endif
return 0;
}

Expand Down Expand Up @@ -1324,6 +1323,13 @@ luaopen_motif(lua_State *L)
int n;

struct luaL_Reg luamotif[] = {
{ "AddInput", lm_AddInput },
{ "Realize", lm_Realize },
{ "Unrealize", lm_Unrealize },
{ "Initialize", lm_Initialize },
{ "RemoveInput", lm_RemoveInput },
{ "RemoveTimeOut", lm_RemoveTimeOut },
{ "SetLanguageProc", lm_XtSetLanguageProc },
{ NULL, NULL }
};
struct luaL_Reg luaapp[] = {
Expand All @@ -1333,6 +1339,9 @@ luaopen_motif(lua_State *L)
{ "CreateInformationDialog", lm_CreateInformationDialog },
{ "CreateFileSelectionDialog", lm_CreateFileSelectionDialog },
{ "CreateFormDialog", lm_CreateFormDialog },
{ "FileSelectionBoxGetChild", lm_XmFileSelectionBoxGetChild },
{ "FileSelectionDoSearch", lm_XmFileSelectionDoSearch },
{ "MessageBoxGetChild", lm_XmMessageBoxGetChild },

/* Managing, Xt */
{ "SetSensitive", lm_SetSensitive },
Expand Down Expand Up @@ -1368,16 +1377,6 @@ luaopen_motif(lua_State *L)
{ "SetSelection", lm_SetSelection },
{ NULL, NULL }
};
struct luaL_Reg luaXt[] = {
{ "AddInput", lm_AddInput },
{ "Realize", lm_Realize },
{ "Unrealize", lm_Unrealize },
{ "Initialize", lm_Initialize },
{ "RemoveInput", lm_RemoveInput },
{ "RemoveTimeOut", lm_RemoveTimeOut },
{ "SetLanguageProc", lm_XtSetLanguageProc },
{ NULL, NULL }
};
struct luaL_Reg luaXtApp[] = {
{ "AddInput", lm_AddInput },
{ "AddTimeOut", lm_AddTimeOut },
Expand All @@ -1392,17 +1391,16 @@ luaopen_motif(lua_State *L)
luaL_register(L, "motif", luamotif);
#endif
lm_set_info(L);
register_global(L, luaXt);
register_global(L, lm_widgetConstructors);
register_global(L, lm_gadgetConstructors);
lm_register(L, lm_widgetConstructors);
lm_register(L, lm_gadgetConstructors);

for (n = 0; n < num_motif_strings(); n++) {
lua_pushstring(L, motif_strings[n].value);
lua_setglobal(L, motif_strings[n].name);
lua_setfield(L, -2, motif_strings[n].name);
};
for (n = 0; n < num_motif_ints(); n++) {
lua_pushinteger(L, motif_ints[n].value);
lua_setglobal(L, motif_ints[n].name);
lua_setfield(L, -2, motif_ints[n].name);
};

/* The Widget metatable */
Expand Down

0 comments on commit beda6aa

Please sign in to comment.