Fix typos
This commit is contained in:
parent
4c86f17bcb
commit
618868ce3d
17 changed files with 65 additions and 65 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* embed3.cpp A C++ embeded interpreter
|
||||
/* embed3.cpp A C++ embedded interpreter
|
||||
|
||||
This will register a C++ class with Lua, and then call a Lua function
|
||||
passing C++ objects to this function.
|
||||
|
|
@ -33,12 +33,12 @@ extern "C" {
|
|||
|
||||
/* The SWIG external runtime is generated by using.
|
||||
swig -lua -externalruntime swigluarun.h
|
||||
It contains useful function used by SWIG in its wrappering
|
||||
It contains useful function used by SWIG in its wrapper
|
||||
SWIG_TypeQuery() SWIG_NewPointerObj()
|
||||
*/
|
||||
#include "swigluarun.h" // the SWIG external runtime
|
||||
|
||||
/* the SWIG wrappered library */
|
||||
/* the SWIG wrapped library */
|
||||
extern "C" int luaopen_example(lua_State*L);
|
||||
|
||||
// the code itself
|
||||
|
|
@ -100,10 +100,10 @@ int main(int argc, char* argv[]) {
|
|||
luaopen_example(L);
|
||||
printf("[C++] all looks ok\n");
|
||||
printf("\n");
|
||||
printf("[C++] lets create an Engine and pass a pointer to Lua\n");
|
||||
printf("[C++] let's create an Engine and pass a pointer to Lua\n");
|
||||
Engine engine;
|
||||
/* this code will pass a pointer into lua, but C++ still owns the object
|
||||
this is a little tedious, to do, but lets do it
|
||||
this is a little tedious, to do, but let's do it
|
||||
we need to pass the pointer (obviously), the type name
|
||||
and a flag which states if Lua should delete the pointer once its finished with it
|
||||
The type name is a class name string which is registered with SWIG
|
||||
|
|
@ -113,7 +113,7 @@ int main(int argc, char* argv[]) {
|
|||
push_pointer(L,&engine,"Engine *",0);
|
||||
lua_setglobal(L, "pEngine"); // set as global variable
|
||||
|
||||
printf("[C++] now lets load the file 'runme.lua'\n");
|
||||
printf("[C++] now 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));
|
||||
|
|
@ -122,7 +122,7 @@ 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 Lua function onEvent(e)\n");
|
||||
printf("[C++] Let's call the Lua function onEvent(e)\n");
|
||||
printf("[C++] We will give it different events, as we wish\n");
|
||||
printf("[C++] Starting with STARTUP\n");
|
||||
Event ev;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
/* We also want to pass some events to Lua, so lets have a few classes
|
||||
/* We also want to pass some events to Lua, so let's have a few classes
|
||||
to do this.
|
||||
*/
|
||||
class Event
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
print "[lua] This is runme.lua"
|
||||
-- test program for embeded lua
|
||||
-- we do not need to load the library, as it was already in the intrepreter
|
||||
-- but lets check anyway
|
||||
-- test program for embedded lua
|
||||
-- we do not need to load the library, as it was already in the interpreter
|
||||
-- but let's check anyway
|
||||
|
||||
assert(type(example)=='table',"Don't appear to have loaded the example module. Do not run this file directly, run the embed3 executable")
|
||||
|
||||
|
|
@ -13,12 +13,12 @@ else
|
|||
end
|
||||
|
||||
|
||||
-- the embed program expects a function void onEvent(Event)
|
||||
-- the embedded program expects a function void onEvent(Event)
|
||||
-- this is it
|
||||
|
||||
function onEvent(e)
|
||||
print("[Lua] onEvent with event",e.mType)
|
||||
-- lets do something with the Engine
|
||||
-- let's do something with the Engine
|
||||
-- nothing clever, but ...
|
||||
if e.mType==example.Event_STARTUP then
|
||||
pEngine:start()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue