Fix typos
This commit is contained in:
parent
4c86f17bcb
commit
618868ce3d
17 changed files with 65 additions and 65 deletions
6
CHANGES
6
CHANGES
|
|
@ -9970,7 +9970,7 @@ Version 1.3.23 (November 11, 2004)
|
||||||
- Remove the ability to share type information by using c linking.
|
- Remove the ability to share type information by using c linking.
|
||||||
All type sharing happens through a global variable in the target language.
|
All type sharing happens through a global variable in the target language.
|
||||||
+ Remove SWIG_NOIMPORT, SWIG_RUNTIME, and related defines.
|
+ Remove SWIG_NOIMPORT, SWIG_RUNTIME, and related defines.
|
||||||
+ Depreciate -runtime, -noruntime command line options
|
+ Deprecate -runtime, -noruntime command line options
|
||||||
+ Update test-suite common.mk to correctly build multicpptest
|
+ Update test-suite common.mk to correctly build multicpptest
|
||||||
+ Remove reference to precommon.swg
|
+ Remove reference to precommon.swg
|
||||||
+ Update the guile_gh interface to share data by a global var instead
|
+ Update the guile_gh interface to share data by a global var instead
|
||||||
|
|
@ -21212,9 +21212,9 @@ Version 1.3 Alpha 1 (February 11, 2000)
|
||||||
*** POTENTIAL INCOMPATIBILITY ***
|
*** POTENTIAL INCOMPATIBILITY ***
|
||||||
|
|
||||||
1/30/00 : loic
|
1/30/00 : loic
|
||||||
Conditionaly compile experimental code with --enable-experiment
|
Conditionally compile experimental code with --enable-experiment
|
||||||
configure flag.
|
configure flag.
|
||||||
Fix .cvsignore to ignore configrue & yacc generated files
|
Fix .cvsignore to ignore configure & yacc generated files
|
||||||
|
|
||||||
1/28/00 : loic
|
1/28/00 : loic
|
||||||
Apply automake everywhere
|
Apply automake everywhere
|
||||||
|
|
|
||||||
|
|
@ -1056,7 +1056,7 @@ operators and pseudo-operators):</p>
|
||||||
<li><tt>__len__</tt>
|
<li><tt>__len__</tt>
|
||||||
<li><tt>__getitem__</tt>
|
<li><tt>__getitem__</tt>
|
||||||
<li><tt>__setitem__</tt>
|
<li><tt>__setitem__</tt>
|
||||||
<li><tt>__tostring</tt> used internaly by Lua for tostring() function. __str__ is mapped to this function
|
<li><tt>__tostring</tt> used internally by Lua for tostring() function. __str__ is mapped to this function
|
||||||
</ul>
|
</ul>
|
||||||
<p>No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. <tt>__tostring</tt> is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG</p>
|
<p>No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. <tt>__tostring</tt> is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG</p>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
|
|
@ -4690,7 +4690,7 @@ public:
|
||||||
C++ constructor, thus creating a new <tt>foo</tt> object.
|
C++ constructor, thus creating a new <tt>foo</tt> object.
|
||||||
By default, SWIG will assign the new Ruby object a "free" function.
|
By default, SWIG will assign the new Ruby object a "free" function.
|
||||||
When the Ruby object is garbage collected, the "free" function will be
|
When the Ruby object is garbage collected, the "free" function will be
|
||||||
called. It in turn will call <tt>Foo's</tt> destructor.</p>
|
called. It in turn will call <tt>Foo</tt>'s destructor.</p>
|
||||||
|
|
||||||
<p>Next, consider this code: </p>
|
<p>Next, consider this code: </p>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ math.randomseed(0) -- init random
|
||||||
|
|
||||||
|
|
||||||
--[[ version 1: passing a C array to the code
|
--[[ 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]]
|
this requires a C array, so is the hardest to use]]
|
||||||
ARRAY_SIZE=10
|
ARRAY_SIZE=10
|
||||||
arr=example.new_int(ARRAY_SIZE)
|
arr=example.new_int(ARRAY_SIZE)
|
||||||
|
|
|
||||||
|
|
@ -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:
|
What is happening is as follows:
|
||||||
example.i declares a type Foo
|
example.i declares a type Foo
|
||||||
|
|
@ -28,7 +28,7 @@ both Foo and Bar.
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.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_example(lua_State*L);
|
||||||
extern "C" int luaopen_example2(lua_State*L);
|
extern "C" int luaopen_example2(lua_State*L);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
The idea is that we wrapper a few simple function (example.c)
|
||||||
and write our own app to call it.
|
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
|
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.
|
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
|
/* a really simple way of calling lua from C
|
||||||
just give it a lua state & a string to execute
|
just give it a lua state & a string to execute
|
||||||
Unfortunately lua keeps changing its API's.
|
Unfortunately lua keeps changing its API's.
|
||||||
In lua 5.0.X its lua_dostring()
|
In lua 5.0.X it's lua_dostring()
|
||||||
In lua 5.1.X its luaL_dostring()
|
In lua 5.1.X it's luaL_dostring()
|
||||||
so we have a few extra compiles
|
so we have a few extra compiles
|
||||||
*/
|
*/
|
||||||
int dostring(lua_State *L, char* str) {
|
int dostring(lua_State *L, char* str) {
|
||||||
|
|
@ -58,11 +58,11 @@ int main(int argc,char* argv[]) {
|
||||||
luaopen_base(L);
|
luaopen_base(L);
|
||||||
luaopen_string(L);
|
luaopen_string(L);
|
||||||
luaopen_math(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);
|
luaopen_example(L);
|
||||||
printf("[C] all looks ok\n");
|
printf("[C] all looks ok\n");
|
||||||
printf("\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");
|
printf("[C] any lua code in this file will be executed\n");
|
||||||
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
||||||
printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
|
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("[C] We are now back in C, all looks ok\n");
|
||||||
printf("\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()");
|
ok=dostring(L,"do_tests()");
|
||||||
printf("[C] We are back in C, the dostring() function returned %d\n",ok);
|
printf("[C] We are back in C, the dostring() function returned %d\n",ok);
|
||||||
printf("\n");
|
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()");
|
ok=dostring(L,"no_such_function()");
|
||||||
printf("[C] We are back in C, the dostring() function returned %d\n",ok);
|
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("[C] it should also have returned 1 and printed an error message\n");
|
||||||
printf("\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()");
|
ok=dostring(L,"call_greeting()");
|
||||||
printf("[C] This was C=>Lua=>C (getting a bit complex)\n");
|
printf("[C] This was C=>Lua=>C (getting a bit complex)\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
print "[lua] This is runme.lua"
|
print "[lua] This is runme.lua"
|
||||||
-- test program for embeded lua
|
-- test program for embedded lua
|
||||||
-- we do not need to load the library, as it was already in the intrepreter
|
-- we do not need to load the library, as it was already in the interpreter
|
||||||
-- but lets check anyway
|
-- but let's check anyway
|
||||||
assert(type(example)=='table',"Don't appear to have loaded the example module")
|
assert(type(example)=='table',"Don't appear to have loaded the example module")
|
||||||
|
|
||||||
-- a test function to run the tests
|
-- a test function to run the tests
|
||||||
|
|
|
||||||
|
|
@ -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.
|
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
|
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
|
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.
|
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
|
#define lua_open luaL_newstate
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* the SWIG wrappered library */
|
/* the SWIG wrapped library */
|
||||||
extern int luaopen_example(lua_State*L);
|
extern int luaopen_example(lua_State*L);
|
||||||
|
|
||||||
/* This is an example of how to call the Lua function
|
/* This is an example of how to call the Lua function
|
||||||
int add(int,int)
|
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)
|
(look below for a better idea)
|
||||||
*/
|
*/
|
||||||
int call_add(lua_State *L,int a,int b,int* res) {
|
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
|
Original Code from Programming in Lua (PIL) by Roberto Ierusalimschy
|
||||||
ISBN 85-903798-1-7
|
ISBN 85-903798-1-7
|
||||||
http://www.lua.org/pil/25.3.html
|
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.
|
But it gives the idea of how to make it work.
|
||||||
*/
|
*/
|
||||||
int call_va (lua_State *L,const char *func, const char *sig, ...) {
|
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);
|
luaopen_example(L);
|
||||||
printf("[C] all looks ok\n");
|
printf("[C] all looks ok\n");
|
||||||
printf("\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");
|
printf("[C] any lua code in this file will be executed\n");
|
||||||
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
||||||
printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
|
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("[C] We are now back in C, all looks ok\n");
|
||||||
printf("\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");
|
printf("[C] using the C function 'call_add'\n");
|
||||||
ok=call_add(L,1,1,&res);
|
ok=call_add(L,1,1,&res);
|
||||||
printf("[C] the function returned %d with value %d\n",ok,res);
|
printf("[C] the function returned %d with value %d\n",ok,res);
|
||||||
printf("\n");
|
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");
|
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);
|
ok=call_va(L,"add","ii>i",1,1,&res);
|
||||||
printf("[C] the function returned %d with value %d\n",ok,res);
|
printf("[C] the function returned %d with value %d\n",ok,res);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
print "[lua] This is runme.lua"
|
print "[lua] This is runme.lua"
|
||||||
-- test program for embeded lua
|
-- test program for embedded lua
|
||||||
-- we do not need to load the library, as it was already in the intrepreter
|
-- we do not need to load the library, as it was already in the interpreter
|
||||||
-- but lets check anyway
|
-- but let's check anyway
|
||||||
assert(type(example)=='table',"Don't appear to have loaded the example module")
|
assert(type(example)=='table',"Don't appear to have loaded the example module")
|
||||||
|
|
||||||
-- note: we will copy the functions from example table into global
|
-- note: we will copy the functions from example table into global
|
||||||
|
|
|
||||||
|
|
@ -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
|
This will register a C++ class with Lua, and then call a Lua function
|
||||||
passing C++ objects to this function.
|
passing C++ objects to this function.
|
||||||
|
|
@ -33,12 +33,12 @@ extern "C" {
|
||||||
|
|
||||||
/* The SWIG external runtime is generated by using.
|
/* The SWIG external runtime is generated by using.
|
||||||
swig -lua -externalruntime swigluarun.h
|
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()
|
SWIG_TypeQuery() SWIG_NewPointerObj()
|
||||||
*/
|
*/
|
||||||
#include "swigluarun.h" // the SWIG external runtime
|
#include "swigluarun.h" // the SWIG external runtime
|
||||||
|
|
||||||
/* the SWIG wrappered library */
|
/* the SWIG wrapped library */
|
||||||
extern "C" int luaopen_example(lua_State*L);
|
extern "C" int luaopen_example(lua_State*L);
|
||||||
|
|
||||||
// the code itself
|
// the code itself
|
||||||
|
|
@ -100,10 +100,10 @@ int main(int argc, char* argv[]) {
|
||||||
luaopen_example(L);
|
luaopen_example(L);
|
||||||
printf("[C++] all looks ok\n");
|
printf("[C++] all looks ok\n");
|
||||||
printf("\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;
|
Engine engine;
|
||||||
/* this code will pass a pointer into lua, but C++ still owns the object
|
/* 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
|
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
|
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
|
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);
|
push_pointer(L,&engine,"Engine *",0);
|
||||||
lua_setglobal(L, "pEngine"); // set as global variable
|
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");
|
printf("[C++] any lua code in this file will be executed\n");
|
||||||
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
||||||
printf("[C++] ERROR: cannot run lua file: %s", lua_tostring(L, -1));
|
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("[C++] We are now back in C++, all looks ok\n");
|
||||||
printf("\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++] We will give it different events, as we wish\n");
|
||||||
printf("[C++] Starting with STARTUP\n");
|
printf("[C++] Starting with STARTUP\n");
|
||||||
Event ev;
|
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.
|
to do this.
|
||||||
*/
|
*/
|
||||||
class Event
|
class Event
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
print "[lua] This is runme.lua"
|
print "[lua] This is runme.lua"
|
||||||
-- test program for embeded lua
|
-- test program for embedded lua
|
||||||
-- we do not need to load the library, as it was already in the intrepreter
|
-- we do not need to load the library, as it was already in the interpreter
|
||||||
-- but lets check anyway
|
-- 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")
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
-- the embed program expects a function void onEvent(Event)
|
-- the embedded program expects a function void onEvent(Event)
|
||||||
-- this is it
|
-- this is it
|
||||||
|
|
||||||
function onEvent(e)
|
function onEvent(e)
|
||||||
print("[Lua] onEvent with event",e.mType)
|
print("[Lua] onEvent with event",e.mType)
|
||||||
-- lets do something with the Engine
|
-- let's do something with the Engine
|
||||||
-- nothing clever, but ...
|
-- nothing clever, but ...
|
||||||
if e.mType==example.Event_STARTUP then
|
if e.mType==example.Event_STARTUP then
|
||||||
pEngine:start()
|
pEngine:start()
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ function b()
|
||||||
t:message()
|
t:message()
|
||||||
end
|
end
|
||||||
print [[
|
print [[
|
||||||
Now lets call function a()
|
Now let's call function a()
|
||||||
which calls b()
|
which calls b()
|
||||||
which calls into C++
|
which calls into C++
|
||||||
which will throw an exception!]]
|
which will throw an exception!]]
|
||||||
|
|
@ -80,7 +80,7 @@ if ok then
|
||||||
else
|
else
|
||||||
print(" call failed with error:",res)
|
print(" call failed with error:",res)
|
||||||
end
|
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)
|
ok,res=xpcall(a,debug.traceback)
|
||||||
if ok then
|
if ok then
|
||||||
print " that worked! Funny"
|
print " that worked! Funny"
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,15 @@ else
|
||||||
require('example')
|
require('example')
|
||||||
end
|
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("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)
|
a=example.Square(10)
|
||||||
b=example.Circle(1)
|
b=example.Circle(1)
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 2)")
|
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)
|
c=example.createCircle(5)
|
||||||
d=example.createSquare(3)
|
d=example.createSquare(3)
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 4)")
|
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()
|
collectgarbage()
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 4)")
|
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
|
a,b,c,d=nil,nil,nil,nil
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
|
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"
|
print "The ShapeOwner now owns the shapes, but Lua still has pointers to them"
|
||||||
o=example.ShapeOwner()
|
o=example.ShapeOwner()
|
||||||
a=example.Square(10)
|
a=example.Square(10)
|
||||||
|
|
@ -41,7 +41,7 @@ o:add(b)
|
||||||
o:add(example.createSquare(5))
|
o:add(example.createSquare(5))
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 3)")
|
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"
|
print "they should be, as the ShapeOwner owns them"
|
||||||
a,b=nil,nil
|
a,b=nil,nil
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
|
|
@ -101,4 +101,4 @@ print "done"
|
||||||
o,sh=nil,nil
|
o,sh=nil,nil
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
|
print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
|
||||||
print "thats all folks!"
|
print "that's all folks!"
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ void main() {
|
||||||
assert(-a == a);
|
assert(-a == a);
|
||||||
assert(-b == new Op(-5));
|
assert(-b == new Op(-5));
|
||||||
|
|
||||||
// Unfortunaly, there is no way to override conversion to boolean for
|
// Unfortunately, there is no way to override conversion to boolean for
|
||||||
// classes in D, opCast!("bool") is only used for structs.
|
// classes in D, opCast!("bool") is only used for structs.
|
||||||
|
|
||||||
// test []
|
// test []
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
This is called to initalise the system & read any command line args
|
This is called to initialise the system & read any command line args
|
||||||
most of this is boilerplate code, except the command line args
|
most of this is boilerplate code, except the command line args
|
||||||
which depends upon what args your code supports
|
which depends upon what args your code supports
|
||||||
NEW LANGUAGE NOTE:END *********************************************** */
|
NEW LANGUAGE NOTE:END *********************************************** */
|
||||||
|
|
@ -380,7 +380,7 @@ public:
|
||||||
Dump(f_header, f_begin);
|
Dump(f_header, f_begin);
|
||||||
Dump(f_wrappers, f_begin);
|
Dump(f_wrappers, f_begin);
|
||||||
Dump(f_initbeforefunc, f_begin);
|
Dump(f_initbeforefunc, f_begin);
|
||||||
/* for the Lua code it needs to be properly excaped to be added into the C/C++ code */
|
/* for the Lua code it needs to be properly escaped to be added into the C/C++ code */
|
||||||
escapeCode(s_luacode);
|
escapeCode(s_luacode);
|
||||||
Printf(f_begin, "const char* SWIG_LUACODE=\n \"%s\";\n\n", s_luacode);
|
Printf(f_begin, "const char* SWIG_LUACODE=\n \"%s\";\n\n", s_luacode);
|
||||||
Wrapper_pretty_print(f_init, f_begin);
|
Wrapper_pretty_print(f_init, f_begin);
|
||||||
|
|
@ -436,9 +436,9 @@ public:
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
This is it!
|
This is it!
|
||||||
you get this one right, and most of your work is done
|
you get this one right, and most of your work is done
|
||||||
but its going to take soem file to get it working right
|
but its going to take some file to get it working right
|
||||||
quite a bit of this is generally boilerplate code
|
quite a bit of this is generally boilerplate code
|
||||||
(or stuff I dont understand)
|
(or stuff I don't understand)
|
||||||
that which matters will have extra added comments
|
that which matters will have extra added comments
|
||||||
NEW LANGUAGE NOTE:END *********************************************** */
|
NEW LANGUAGE NOTE:END *********************************************** */
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
|
|
@ -534,7 +534,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
the wrapper object holds all the wrappering code
|
the wrapper object holds all the wrapper code
|
||||||
we need to add a couple of local variables
|
we need to add a couple of local variables
|
||||||
NEW LANGUAGE NOTE:END *********************************************** */
|
NEW LANGUAGE NOTE:END *********************************************** */
|
||||||
Wrapper *f = NewWrapper();
|
Wrapper *f = NewWrapper();
|
||||||
|
|
@ -554,7 +554,7 @@ public:
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
the format of a lua fn is:
|
the format of a lua fn is:
|
||||||
static int wrap_XXX(lua_State* L){...}
|
static int wrap_XXX(lua_State* L){...}
|
||||||
this line adds this into the wrappering code
|
this line adds this into the wrapper code
|
||||||
NEW LANGUAGE NOTE:END *********************************************** */
|
NEW LANGUAGE NOTE:END *********************************************** */
|
||||||
Printv(f->def, "static int ", wname, "(lua_State* L) {", NIL);
|
Printv(f->def, "static int ", wname, "(lua_State* L) {", NIL);
|
||||||
|
|
||||||
|
|
@ -657,7 +657,7 @@ public:
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
// why is this code not called when I dont have a typemap?
|
// why is this code not called when I don't have a typemap?
|
||||||
// instead of giving a warning, no code is generated
|
// instead of giving a warning, no code is generated
|
||||||
NEW LANGUAGE NOTE:END *********************************************** */
|
NEW LANGUAGE NOTE:END *********************************************** */
|
||||||
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
|
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
|
||||||
|
|
@ -792,7 +792,7 @@ public:
|
||||||
Replaceall(f->code, "$result", Swig_cresult_name());
|
Replaceall(f->code, "$result", Swig_cresult_name());
|
||||||
|
|
||||||
/* Dump the function out */
|
/* Dump the function out */
|
||||||
/* in Lua we will not emit the destructor as a wrappered function,
|
/* in Lua we will not emit the destructor as a wrapper function,
|
||||||
Lua will automatically call the destructor when the object is free'd
|
Lua will automatically call the destructor when the object is free'd
|
||||||
However: you cannot just skip this function as it will not emit
|
However: you cannot just skip this function as it will not emit
|
||||||
any custom destructor (using %extend), as you need to call emit_action()
|
any custom destructor (using %extend), as you need to call emit_action()
|
||||||
|
|
@ -835,7 +835,7 @@ public:
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
This is an extra function used for overloading of functions
|
This is an extra function used for overloading of functions
|
||||||
it checks the args & then calls the relevant fn
|
it checks the args & then calls the relevant fn
|
||||||
nost of the real work in again typemaps:
|
most of the real work in again typemaps:
|
||||||
look for %typecheck(SWIG_TYPECHECK_*) in the .swg file
|
look for %typecheck(SWIG_TYPECHECK_*) in the .swg file
|
||||||
NEW LANGUAGE NOTE:END *********************************************** */
|
NEW LANGUAGE NOTE:END *********************************************** */
|
||||||
int dispatchFunction(Node *n) {
|
int dispatchFunction(Node *n) {
|
||||||
|
|
|
||||||
|
|
@ -2160,7 +2160,7 @@ int R::functionWrapper(Node *n) {
|
||||||
/* If we are dealing with a method in an C++ class, then
|
/* If we are dealing with a method in an C++ class, then
|
||||||
add the name of the R function and its definition.
|
add the name of the R function and its definition.
|
||||||
XXX need to figure out how to store the Wrapper if possible in the hash/list.
|
XXX need to figure out how to store the Wrapper if possible in the hash/list.
|
||||||
Would like to be able to do this so that we can potentialy insert
|
Would like to be able to do this so that we can potentially insert
|
||||||
*/
|
*/
|
||||||
if(processing_member_access_function || processing_class_member_function) {
|
if(processing_member_access_function || processing_class_member_function) {
|
||||||
addAccessor(member_name, sfun, iname);
|
addAccessor(member_name, sfun, iname);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue