2
** Support code for Lua bindings.
3
** Written by Waldemar Celes
6
** $Id: tolua.c,v 1.3 1999/07/28 22:21:09 celes Exp $
9
/* This code is free software; you can redistribute it and/or modify it.
10
** The software provided hereunder is on an "as is" basis, and
11
** the author has no obligation to provide maintenance, support, updates,
12
** enhancements, or modifications.
24
static void help (void)
27
"usage: tolua [options] input_file\n"
29
"Command line options are:\n"
30
" -v : print version information.\n"
31
" -o file : set output file; default is stdout.\n"
32
" -H file : create include file.\n"
33
" -n name : set package name; default is input file root name.\n"
35
" -P : parse and print structure information (for debug).\n"
36
" -h : print this message.\n"
37
"Should the input file be omitted, stdin is assumed;\n"
38
"in that case, the package name must be explicitly set.\n\n"
42
static void version (void)
44
fprintf(stderr, "%s (written by W. Celes)\n",TOLUA_VERSION);
47
static void setfield (lua_State* L, int table, char* f, char* v)
51
lua_settable(L,table);
54
static void error (char* o)
56
fprintf(stderr,"tolua: unknown option '%s'\n",o);
61
int main (int argc, char* argv[])
63
lua_State* L = lua_open(0);
67
lua_pushstring(L,TOLUA_VERSION); lua_setglobal(L,"TOLUA_VERSION");
79
lua_setglobal(L,"flags");
81
for (i=1; i<argc; ++i)
87
case 'v': version(); return 0;
88
case 'h': help(); return 0;
89
case 'p': setfield(L,t,"p",""); break;
90
case 'P': setfield(L,t,"P",""); break;
91
case 'o': setfield(L,t,"o",argv[++i]); break;
92
case 'n': setfield(L,t,"n",argv[++i]); break;
93
case 'H': setfield(L,t,"H",argv[++i]); break;
94
default: error(argv[i]); break;
99
setfield(L,t,"f",argv[i]);
108
int tolua_tolualua_open(lua_State* L);
109
tolua_tolualua_open(L);
137
strcpy(path,argv[0]);
138
p = strrchr(path,'/');
139
p = (p==NULL) ? path : p+1;
140
for (i=0; files[i]; ++i)
142
sprintf(p,"%s",files[i]);