Fix typos
This commit is contained in:
parent
4c86f17bcb
commit
618868ce3d
17 changed files with 65 additions and 65 deletions
|
|
@ -1,9 +1,9 @@
|
|||
/* embed.c a simple test for an embeded interpreter
|
||||
/* embed.c a simple test for an embedded interpreter
|
||||
|
||||
The idea is that we wrapper a few simple function (example.c)
|
||||
and write our own app to call it.
|
||||
|
||||
What it will do is load the wrappered lib, load runme.lua and then call some functions.
|
||||
What it will do is load the wrapped lib, load runme.lua and then call some functions.
|
||||
To make life easier, all the printf's have either [C] or [Lua] at the start
|
||||
so you can see where they are coming from.
|
||||
|
||||
|
|
@ -28,8 +28,8 @@ extern int luaopen_example(lua_State*L);
|
|||
/* a really simple way of calling lua from C
|
||||
just give it a lua state & a string to execute
|
||||
Unfortunately lua keeps changing its API's.
|
||||
In lua 5.0.X its lua_dostring()
|
||||
In lua 5.1.X its luaL_dostring()
|
||||
In lua 5.0.X it's lua_dostring()
|
||||
In lua 5.1.X it's luaL_dostring()
|
||||
so we have a few extra compiles
|
||||
*/
|
||||
int dostring(lua_State *L, char* str) {
|
||||
|
|
@ -58,11 +58,11 @@ int main(int argc,char* argv[]) {
|
|||
luaopen_base(L);
|
||||
luaopen_string(L);
|
||||
luaopen_math(L);
|
||||
printf("[C] now loading the SWIG wrappered library\n");
|
||||
printf("[C] now loading the SWIG wrapped library\n");
|
||||
luaopen_example(L);
|
||||
printf("[C] all looks ok\n");
|
||||
printf("\n");
|
||||
printf("[C] lets load the file 'runme.lua'\n");
|
||||
printf("[C] let's load the file 'runme.lua'\n");
|
||||
printf("[C] any lua code in this file will be executed\n");
|
||||
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
||||
printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
|
||||
|
|
@ -70,16 +70,16 @@ int main(int argc,char* argv[]) {
|
|||
}
|
||||
printf("[C] We are now back in C, all looks ok\n");
|
||||
printf("\n");
|
||||
printf("[C] lets call the function 'do_tests()'\n");
|
||||
printf("[C] let's call the function 'do_tests()'\n");
|
||||
ok=dostring(L,"do_tests()");
|
||||
printf("[C] We are back in C, the dostring() function returned %d\n",ok);
|
||||
printf("\n");
|
||||
printf("[C] Lets call lua again, but create an error\n");
|
||||
printf("[C] Let's call lua again, but create an error\n");
|
||||
ok=dostring(L,"no_such_function()");
|
||||
printf("[C] We are back in C, the dostring() function returned %d\n",ok);
|
||||
printf("[C] it should also have returned 1 and printed an error message\n");
|
||||
printf("\n");
|
||||
printf("[C] Lets call lua again, calling the greeting function\n");
|
||||
printf("[C] Let's call lua again, calling the greeting function\n");
|
||||
ok=dostring(L,"call_greeting()");
|
||||
printf("[C] This was C=>Lua=>C (getting a bit complex)\n");
|
||||
printf("\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue