diff options
| author | The Lua team <lua@tecgraf.puc-rio.br> | 1993-07-28 10:18:00 -0300 |
|---|---|---|
| committer | The Lua team <lua@tecgraf.puc-rio.br> | 1993-07-28 10:18:00 -0300 |
| commit | cd05d9c5cb69020c069f037ba7f243f705d0a48a (patch) | |
| tree | cb7f08c0684c10970a528984741047fb3babadd3 /lua.c | |
| download | lua-cd05d9c5cb69020c069f037ba7f243f705d0a48a.tar.gz lua-cd05d9c5cb69020c069f037ba7f243f705d0a48a.tar.bz2 lua-cd05d9c5cb69020c069f037ba7f243f705d0a48a.zip | |
oldest known commit
Diffstat (limited to 'lua.c')
| -rw-r--r-- | lua.c | 54 |
1 files changed, 54 insertions, 0 deletions
| @@ -0,0 +1,54 @@ | |||
| 1 | /* | ||
| 2 | ** lua.c | ||
| 3 | ** Linguagem para Usuarios de Aplicacao | ||
| 4 | ** TeCGraf - PUC-Rio | ||
| 5 | ** 28 Apr 93 | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include <stdio.h> | ||
| 9 | |||
| 10 | #include "lua.h" | ||
| 11 | #include "lualib.h" | ||
| 12 | |||
| 13 | |||
| 14 | void test (void) | ||
| 15 | { | ||
| 16 | lua_pushobject(lua_getparam(1)); | ||
| 17 | lua_call ("c", 1); | ||
| 18 | } | ||
| 19 | |||
| 20 | |||
| 21 | static void callfunc (void) | ||
| 22 | { | ||
| 23 | lua_Object obj = lua_getparam (1); | ||
| 24 | if (lua_isstring(obj)) lua_call(lua_getstring(obj),0); | ||
| 25 | } | ||
| 26 | |||
| 27 | static void execstr (void) | ||
| 28 | { | ||
| 29 | lua_Object obj = lua_getparam (1); | ||
| 30 | if (lua_isstring(obj)) lua_dostring(lua_getstring(obj)); | ||
| 31 | } | ||
| 32 | |||
| 33 | void main (int argc, char *argv[]) | ||
| 34 | { | ||
| 35 | int i; | ||
| 36 | if (argc < 2) | ||
| 37 | { | ||
| 38 | puts ("usage: lua filename [functionnames]"); | ||
| 39 | return; | ||
| 40 | } | ||
| 41 | lua_register ("callfunc", callfunc); | ||
| 42 | lua_register ("execstr", execstr); | ||
| 43 | lua_register ("test", test); | ||
| 44 | iolib_open (); | ||
| 45 | strlib_open (); | ||
| 46 | mathlib_open (); | ||
| 47 | lua_dofile (argv[1]); | ||
| 48 | for (i=2; i<argc; i++) | ||
| 49 | { | ||
| 50 | lua_call (argv[i],0); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | |||
