Fix typos

This commit is contained in:
Olly Betts 2014-04-29 11:24:04 +12:00
commit 618868ce3d
17 changed files with 65 additions and 65 deletions

View file

@ -25,7 +25,7 @@ math.randomseed(0) -- init random
--[[ version 1: passing a C array to the code
lets test call sort_int()
let's test call sort_int()
this requires a C array, so is the hardest to use]]
ARRAY_SIZE=10
arr=example.new_int(ARRAY_SIZE)

View file

@ -1,7 +1,7 @@
/*
dual.cpp a test for multiple modules and multiple intrepreters staticly linked together.
dual.cpp a test for multiple modules and multiple interpreters statically linked together.
Earlier version of lua bindings for SWIG would fail if staticly linked.
Earlier version of lua bindings for SWIG would fail if statically linked.
What is happening is as follows:
example.i declares a type Foo
@ -28,7 +28,7 @@ both Foo and Bar.
#include <stdio.h>
#include <stdlib.h>
// the 2 libraries which are wrappered via SWIG
// the 2 libraries which are wrapped via SWIG
extern "C" int luaopen_example(lua_State*L);
extern "C" int luaopen_example2(lua_State*L);

View file

@ -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");

View file

@ -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")
-- a test function to run the tests

View file

@ -1,9 +1,9 @@
/* embed2.c some more test for an embeded interpreter
/* embed2.c some more tests for an embedded interpreter
This will go a bit further as it will pass values to and from the lua code.
It uses less of the SWIG code, and more of the raw lua API's
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.
@ -35,12 +35,12 @@ We will be using the luaL_dostring()/lua_dostring() function to call into lua
#define lua_open luaL_newstate
#endif
/* the SWIG wrappered library */
/* the SWIG wrapped library */
extern int luaopen_example(lua_State*L);
/* This is an example of how to call the Lua function
int add(int,int)
its very tedious, but gives you an idea of the issues involded.
its very tedious, but gives you an idea of the issues involved.
(look below for a better idea)
*/
int call_add(lua_State *L,int a,int b,int* res) {
@ -78,7 +78,7 @@ int call_add(lua_State *L,int a,int b,int* res) {
Original Code from Programming in Lua (PIL) by Roberto Ierusalimschy
ISBN 85-903798-1-7
http://www.lua.org/pil/25.3.html
This has been modified slightly to make it compile, and its still a bit rough.
This has been modified slightly to make it compile, and it's still a bit rough.
But it gives the idea of how to make it work.
*/
int call_va (lua_State *L,const char *func, const char *sig, ...) {
@ -189,7 +189,7 @@ int main(int argc,char* argv[]) {
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));
@ -197,12 +197,12 @@ 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 'add(1,1)'\n");
printf("[C] let's call the Lua function 'add(1,1)'\n");
printf("[C] using the C function 'call_add'\n");
ok=call_add(L,1,1,&res);
printf("[C] the function returned %d with value %d\n",ok,res);
printf("\n");
printf("[C] lets do this rather easier\n");
printf("[C] let's do this rather easier\n");
printf("[C] we will call the same Lua function using a generic C function 'call_va'\n");
ok=call_va(L,"add","ii>i",1,1,&res);
printf("[C] the function returned %d with value %d\n",ok,res);

View file

@ -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")
-- note: we will copy the functions from example table into global

View file

@ -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;

View file

@ -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

View file

@ -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()

View file

@ -70,7 +70,7 @@ function b()
t:message()
end
print [[
Now lets call function a()
Now let's call function a()
which calls b()
which calls into C++
which will throw an exception!]]
@ -80,7 +80,7 @@ if ok then
else
print(" call failed with error:",res)
end
print "Now lets do the same using xpcall(a,debug.traceback)"
print "Now let's do the same using xpcall(a,debug.traceback)"
ok,res=xpcall(a,debug.traceback)
if ok then
print " that worked! Funny"

View file

@ -9,15 +9,15 @@ else
require('example')
end
print "ok, lets test Lua's ownership of C++ objects"
print "ok, let's test Lua's ownership of C++ objects"
print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
print "\nLets make a couple"
print "\nLet's make a couple"
a=example.Square(10)
b=example.Circle(1)
print("Currently there are",example.Shape_nshapes,"shapes (there should be 2)")
print "\nNote lets use the createX functions"
print "\nNote let's use the createX functions"
c=example.createCircle(5)
d=example.createSquare(3)
print("Currently there are",example.Shape_nshapes,"shapes (there should be 4)")
@ -26,12 +26,12 @@ print "\nWe will run the garbage collector & see if they are till here"
collectgarbage()
print("Currently there are",example.Shape_nshapes,"shapes (there should be 4)")
print "\nLets get rid of them all, collect garbage & see if they are till here"
print "\nLet's get rid of them all, collect garbage & see if they are till here"
a,b,c,d=nil,nil,nil,nil
collectgarbage()
print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
print "\nLets start putting stuff into the ShapeOwner"
print "\nLet's start putting stuff into the ShapeOwner"
print "The ShapeOwner now owns the shapes, but Lua still has pointers to them"
o=example.ShapeOwner()
a=example.Square(10)
@ -41,7 +41,7 @@ o:add(b)
o:add(example.createSquare(5))
print("Currently there are",example.Shape_nshapes,"shapes (there should be 3)")
print "\nWe will nil our references,run the garbage collector & see if they are till here"
print "\nWe will nil our references,run the garbage collector & see if they are still here"
print "they should be, as the ShapeOwner owns them"
a,b=nil,nil
collectgarbage()
@ -101,4 +101,4 @@ print "done"
o,sh=nil,nil
collectgarbage()
print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
print "thats all folks!"
print "that's all folks!"