diff options
Diffstat (limited to 'Examples/lua')
30 files changed, 138 insertions, 123 deletions
diff --git a/Examples/lua/arrays/Makefile b/Examples/lua/arrays/Makefile index d398dffea..4191f7ec3 100644 --- a/Examples/lua/arrays/Makefile +++ b/Examples/lua/arrays/Makefile @@ -5,15 +5,15 @@ TARGET = example INTERFACE = example.i check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/arrays/example.c b/Examples/lua/arrays/example.c index ed23738c8..da1bd755a 100644 --- a/Examples/lua/arrays/example.c +++ b/Examples/lua/arrays/example.c @@ -13,7 +13,7 @@ void sort_int(int* arr, int len) qsort(arr, len, sizeof(int), compare_int); } -// ditto doubles +/* ditto doubles */ int compare_double(const void * a, const void * b) { return (int)( *(double*)a - *(double*)b ); diff --git a/Examples/lua/class/Makefile b/Examples/lua/class/Makefile index c39e8acdf..96308f0df 100644 --- a/Examples/lua/class/Makefile +++ b/Examples/lua/class/Makefile @@ -6,15 +6,15 @@ INTERFACE = example.i LIBS = -lm check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/class/example.cxx b/Examples/lua/class/example.cxx index 1e8e203dd..046304519 100644 --- a/Examples/lua/class/example.cxx +++ b/Examples/lua/class/example.cxx @@ -1,4 +1,4 @@ -/* File : example.c */ +/* File : example.cxx */ #include "example.h" #define M_PI 3.14159265358979323846 @@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) { int Shape::nshapes = 0; -double Circle::area(void) { +double Circle::area() { return M_PI*radius*radius; } -double Circle::perimeter(void) { +double Circle::perimeter() { return 2*M_PI*radius; } -double Square::area(void) { +double Square::area() { return width*width; } -double Square::perimeter(void) { +double Square::perimeter() { return 4*width; } diff --git a/Examples/lua/class/runme.lua b/Examples/lua/class/runme.lua index 2c3ad8ced..5d140defe 100644 --- a/Examples/lua/class/runme.lua +++ b/Examples/lua/class/runme.lua @@ -53,7 +53,6 @@ print("\nGuess I'll clean up now") -- Note: this invokes the virtual destructor c=nil s=nil -s = 3 -- call gc to make sure they are collected collectgarbage() diff --git a/Examples/lua/constants/Makefile b/Examples/lua/constants/Makefile index 7e36e15a1..ae33cb182 100644 --- a/Examples/lua/constants/Makefile +++ b/Examples/lua/constants/Makefile @@ -6,15 +6,15 @@ INTERFACE = example.i LIBS = check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/dual/Makefile b/Examples/lua/dual/Makefile index 12ee00a68..c86152a97 100644 --- a/Examples/lua/dual/Makefile +++ b/Examples/lua/dual/Makefile @@ -1,21 +1,21 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = dual -CXXSRCS = example2_wrap.cxx +GENCXXSRCS = example2_wrap.cxx INTERFACE = dual.i LUA_INTERP = dual.cpp # This is a little different to normal as we need to static link two modules and a custom interpreter # We need the external runtime, then swig examples2, and build the module as normal check: build - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: $(SWIG) -lua -external-runtime - $(SWIG) -c++ -lua $(SWIGOPT) example2.i - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(SWIG) -c++ -lua $(SWIGOPT) -o $(GENCXXSRCS) $(SRCDIR)example2.i + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) GENCXXSRCS='$(GENCXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean rm -f swigluarun.h $(TARGET) diff --git a/Examples/lua/dual/dual.cpp b/Examples/lua/dual/dual.cpp index b54e44de1..2108a7275 100644 --- a/Examples/lua/dual/dual.cpp +++ b/Examples/lua/dual/dual.cpp @@ -45,14 +45,14 @@ void testModule(lua_State *L) swig_type_info *pTypeInfo=0,*pTypeInfo2=0; swig_module_info *pModule=0; pModule=SWIG_GetModule(L); - DEBUG2(" SWIG_GetModule() returns %p\n",pModule) + DEBUG2(" SWIG_GetModule() returns %p\n", (void *)pModule) if(pModule==0) return; pTypeInfo = SWIG_TypeQuery(L,"Foo *"); DEBUG2(" Type (Foo*) is %s\n",pTypeInfo==0?"unknown":"known"); - DEBUG3(" Module %p typeinfo(Foo*) %p\n",pModule,pTypeInfo); + DEBUG3(" Module %p typeinfo(Foo*) %p\n", (void *)pModule, (void *)pTypeInfo); pTypeInfo2 = SWIG_TypeQuery(L,"Bar *"); DEBUG2(" Type (Bar*) is %s\n",pTypeInfo2==0?"unknown":"known"); - DEBUG3(" Module %p typeinfo(Bar*) %p\n",pModule,pTypeInfo2); + DEBUG3(" Module %p typeinfo(Bar*) %p\n", (void *)pModule, (void *)pTypeInfo2); } int main(int argc,char* argv[]) diff --git a/Examples/lua/embed/Makefile b/Examples/lua/embed/Makefile index 57979c061..5e3a91893 100644 --- a/Examples/lua/embed/Makefile +++ b/Examples/lua/embed/Makefile @@ -9,12 +9,12 @@ LIBS = -lm # this is a little different to normal as we have our own special interpreter # which we want to static link check: build - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' LIBS='$(LIBS)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean rm -f $(TARGET) diff --git a/Examples/lua/embed/embed.c b/Examples/lua/embed/embed.c index 507567489..1f10cc8e8 100644 --- a/Examples/lua/embed/embed.c +++ b/Examples/lua/embed/embed.c @@ -13,6 +13,7 @@ We will be using the luaL_dostring()/lua_dostring() function to call into lua #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <lua.h> #include <lauxlib.h> @@ -62,9 +63,13 @@ int main(int argc,char* argv[]) { luaopen_example(L); printf("[C] all looks ok\n"); printf("\n"); - printf("[C] let's load the file 'runme.lua'\n"); + if (argc != 2 || argv[1] == NULL || strlen(argv[1]) == 0) { + printf("[C] ERROR: no lua file given on command line\n"); + exit(3); + } + printf("[C] let's load the file '%s'\n", argv[1]); 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, argv[1]) || lua_pcall(L, 0, 0, 0)) { printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1)); exit(3); } diff --git a/Examples/lua/embed2/Makefile b/Examples/lua/embed2/Makefile index ec22bdcae..d30ba0942 100644 --- a/Examples/lua/embed2/Makefile +++ b/Examples/lua/embed2/Makefile @@ -9,12 +9,12 @@ LIBS = -lm # this is a little different to normal as we have our own special interpreter # which we want to static link check: build - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' LIBS='$(LIBS)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean rm -f $(TARGET) diff --git a/Examples/lua/embed2/embed2.c b/Examples/lua/embed2/embed2.c index 100a1fb33..0ce9f8f7f 100644 --- a/Examples/lua/embed2/embed2.c +++ b/Examples/lua/embed2/embed2.c @@ -24,6 +24,7 @@ We will be using the luaL_dostring()/lua_dostring() function to call into lua #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <lua.h> #include <lauxlib.h> @@ -52,7 +53,7 @@ int call_add(lua_State *L,int a,int b,int* res) { lua_getglobal(L, "add"); /* function to be called */ if (!lua_isfunction(L,-1)) { printf("[C] error: cannot find function 'add'\n"); - lua_settop(L,top); // reset + lua_settop(L,top); return 0; } lua_pushnumber(L,a); @@ -60,18 +61,18 @@ int call_add(lua_State *L,int a,int b,int* res) { if (lua_pcall(L, 2, 1, 0) != 0) /* call function with 2 arguments and 1 result */ { printf("[C] error running function `add': %s\n",lua_tostring(L, -1)); - lua_settop(L,top); // reset + lua_settop(L,top); return 0; } - // check results + /* check results */ if (!lua_isnumber(L,-1)) { printf("[C] error: returned value is not a number\n"); - lua_settop(L,top); // reset + lua_settop(L,top); return 0; } *res=(int)lua_tonumber(L,-1); lua_settop(L,top); /* reset stack */ - return 1; // ok + return 1; } /* This is a variargs call function for calling from C into Lua. @@ -189,9 +190,13 @@ int main(int argc,char* argv[]) { luaopen_example(L); printf("[C] all looks ok\n"); printf("\n"); - printf("[C] let's load the file 'runme.lua'\n"); + if (argc != 2 || argv[1] == NULL || strlen(argv[1]) == 0) { + printf("[C] ERROR: no lua file given on command line\n"); + exit(3); + } + printf("[C] let's load the file '%s'\n", argv[1]); 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, argv[1]) || lua_pcall(L, 0, 0, 0)) { printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1)); exit(3); } diff --git a/Examples/lua/embed2/runme.lua b/Examples/lua/embed2/runme.lua index 9e7ab616c..6e93164c0 100644 --- a/Examples/lua/embed2/runme.lua +++ b/Examples/lua/embed2/runme.lua @@ -3,25 +3,25 @@ print "[lua] This is runme.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
--- this will help us later
-for k,v in pairs(example) do _G[k]=v end
--- our add function
+-- note: we will copy the functions from example table into global +-- this will help us later +for k,v in pairs(example) do _G[k]=v end + +-- our add function -- we will be calling this from C -function add(a,b)
- print("[lua] this is function add(",a,b,")")
- c=a+b
- print("[lua] returning",c)
- return c
+function add(a,b) + print("[lua] this is function add(",a,b,")") + c=a+b + print("[lua] returning",c) + return c end -function append(a,b)
- print("[lua] this is function append(",a,b,")")
- c=a..b
- print("[lua] returning",c)
- return c
+function append(a,b) + print("[lua] this is function append(",a,b,")") + c=a..b + print("[lua] returning",c) + return c end diff --git a/Examples/lua/embed3/Makefile b/Examples/lua/embed3/Makefile index 8cfa97454..fc0026122 100644 --- a/Examples/lua/embed3/Makefile +++ b/Examples/lua/embed3/Makefile @@ -9,13 +9,13 @@ LUA_INTERP = embed3.cpp # which we want to static link # we also need the external runtime, so we can get access to certain internals of SWIG check: build - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: $(SWIG) -c++ -lua $(SWIGOPT) -external-runtime swigluarun.h - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean rm -f swigluarun.h $(TARGET) diff --git a/Examples/lua/embed3/embed3.cpp b/Examples/lua/embed3/embed3.cpp index d559167d1..9be49add3 100644 --- a/Examples/lua/embed3/embed3.cpp +++ b/Examples/lua/embed3/embed3.cpp @@ -113,10 +113,14 @@ int main(int argc, char* argv[]) { push_pointer(L,&engine,"Engine *",0); lua_setglobal(L, "pEngine"); // set as global variable - printf("[C++] now let's load the file 'runme.lua'\n"); + if (argc != 2 || argv[1] == NULL || strlen(argv[1]) == 0) { + printf("[C++] ERROR: no lua file given on command line\n"); + exit(3); + } + printf("[C++] now let's load the file '%s'\n", argv[1]); 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)); + if (luaL_loadfile(L, argv[1]) || lua_pcall(L, 0, 0, 0)) { + printf("[C++] ERROR: cannot run lua file: %s",lua_tostring(L, -1)); exit(3); } printf("[C++] We are now back in C++, all looks ok\n"); diff --git a/Examples/lua/exception/Makefile b/Examples/lua/exception/Makefile index 3dbebb4e5..ac9c28b69 100644 --- a/Examples/lua/exception/Makefile +++ b/Examples/lua/exception/Makefile @@ -6,15 +6,15 @@ INTERFACE = example.i LIBS = -lm check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/funcptr3/Makefile b/Examples/lua/funcptr3/Makefile index 8b51e73e8..aeeaad469 100644 --- a/Examples/lua/funcptr3/Makefile +++ b/Examples/lua/funcptr3/Makefile @@ -6,15 +6,15 @@ INTERFACE = example.i LIBS = check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/functest/Makefile b/Examples/lua/functest/Makefile index 8b51e73e8..aeeaad469 100644 --- a/Examples/lua/functest/Makefile +++ b/Examples/lua/functest/Makefile @@ -6,15 +6,15 @@ INTERFACE = example.i LIBS = check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/functest/example.i b/Examples/lua/functest/example.i index 631e0602d..9bb64cbf5 100644 --- a/Examples/lua/functest/example.i +++ b/Examples/lua/functest/example.i @@ -1,13 +1,12 @@ /* File : example.i */ %module example -%include "typemaps.i" // you must have this for the typemaps for ptrs -// basic function testing -// +%include "typemaps.i" + %inline %{ -extern int add1(int x, int y); // return x+y -- basic function test -extern void add2(int x, int *INPUT, int *OUTPUT); // *z = x+*y -- argin and argout test -extern int add3(int x, int y, int *OUTPUT); // return x+y, *z=x-y -- returning 2 values -extern void add4(int x, int *INOUT); // *y += x -- INOUT dual purpose variable +extern int add1(int x, int y); /* return x+y -- basic function test */ +extern void add2(int x, int *INPUT, int *OUTPUT); /* *z = x+*y -- argin and argout test */ +extern int add3(int x, int y, int *OUTPUT); /* return x+y, *z=x-y -- returning 2 values */ +extern void add4(int x, int *INOUT); /* *y += x -- INOUT dual purpose variable */ %} diff --git a/Examples/lua/functor/Makefile b/Examples/lua/functor/Makefile index 4e4edbfa5..e647fb2a8 100644 --- a/Examples/lua/functor/Makefile +++ b/Examples/lua/functor/Makefile @@ -7,15 +7,15 @@ LIBS = -lm SWIGOPT = check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/import/Makefile b/Examples/lua/import/Makefile index 0a9aebd57..8d64a21c6 100644 --- a/Examples/lua/import/Makefile +++ b/Examples/lua/import/Makefile @@ -4,17 +4,17 @@ SWIGOPT = LIBS = check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' lua_cpp - $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' lua_cpp - $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' lua_cpp - $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' lua_cpp clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/import/base.h b/Examples/lua/import/base.h index fec0f329c..ff6fecdd3 100644 --- a/Examples/lua/import/base.h +++ b/Examples/lua/import/base.h @@ -1,7 +1,7 @@ class Base { public: - Base() { }; - virtual ~Base() { }; + Base() { } + virtual ~Base() { } virtual const char * A() const { return "Base::A"; } diff --git a/Examples/lua/nspace/Makefile b/Examples/lua/nspace/Makefile index 57875ec49..17757c2ec 100644 --- a/Examples/lua/nspace/Makefile +++ b/Examples/lua/nspace/Makefile @@ -5,15 +5,15 @@ TARGET = example INTERFACE = example.i check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/owner/Makefile b/Examples/lua/owner/Makefile index c39e8acdf..96308f0df 100644 --- a/Examples/lua/owner/Makefile +++ b/Examples/lua/owner/Makefile @@ -6,15 +6,15 @@ INTERFACE = example.i LIBS = -lm check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/owner/example.cxx b/Examples/lua/owner/example.cxx index bce484aea..c2c073d79 100644 --- a/Examples/lua/owner/example.cxx +++ b/Examples/lua/owner/example.cxx @@ -39,12 +39,15 @@ Square* createSquare(double w) return new Square(w); } -ShapeOwner::ShapeOwner() {printf(" ShapeOwner(%p)\n",this);} +ShapeOwner::ShapeOwner() { + printf(" ShapeOwner(%p)\n", (void *)this); +} + ShapeOwner::~ShapeOwner() { - printf(" ~ShapeOwner(%p)\n",this); - for(unsigned i=0;i<shapes.size();i++) - delete shapes[i]; + printf(" ~ShapeOwner(%p)\n", (void *)this); + for(unsigned i=0;i<shapes.size();i++) + delete shapes[i]; } void ShapeOwner::add(Shape* ptr) // this method takes ownership of the object diff --git a/Examples/lua/owner/example.h b/Examples/lua/owner/example.h index 320bb2569..9101c6330 100644 --- a/Examples/lua/owner/example.h +++ b/Examples/lua/owner/example.h @@ -8,7 +8,7 @@ public: } virtual ~Shape() { nshapes--; - }; + } double x, y; void move(double dx, double dy); virtual double area(void) = 0; @@ -20,7 +20,7 @@ class Circle : public Shape { private: double radius; public: - Circle(double r) : radius(r) { }; + Circle(double r) : radius(r) { } virtual double area(void); virtual double perimeter(void); }; @@ -29,7 +29,7 @@ class Square : public Shape { private: double width; public: - Square(double w) : width(w) { }; + Square(double w) : width(w) { } virtual double area(void); virtual double perimeter(void); }; diff --git a/Examples/lua/pointer/Makefile b/Examples/lua/pointer/Makefile index 8b51e73e8..aeeaad469 100644 --- a/Examples/lua/pointer/Makefile +++ b/Examples/lua/pointer/Makefile @@ -6,15 +6,15 @@ INTERFACE = example.i LIBS = check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/simple/Makefile b/Examples/lua/simple/Makefile index d398dffea..4191f7ec3 100644 --- a/Examples/lua/simple/Makefile +++ b/Examples/lua/simple/Makefile @@ -5,15 +5,15 @@ TARGET = example INTERFACE = example.i check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/variables/Makefile b/Examples/lua/variables/Makefile index d398dffea..4191f7ec3 100644 --- a/Examples/lua/variables/Makefile +++ b/Examples/lua/variables/Makefile @@ -5,15 +5,15 @@ TARGET = example INTERFACE = example.i check: build - $(MAKE) -f $(TOP)/Makefile lua_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: - $(MAKE) -f $(TOP)/Makefile lua_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/variables/example.c b/Examples/lua/variables/example.c index 05e17c8c5..85685fe72 100644 --- a/Examples/lua/variables/example.c +++ b/Examples/lua/variables/example.c @@ -52,9 +52,9 @@ void print_vars() { printf("cvar = %c\n", cvar); printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("cstrvar = %s\n", cstrvar); - printf("iptrvar = %p\n", iptrvar); + printf("iptrvar = %p\n", (void *)iptrvar); printf("name = %s\n", name); - printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); + printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); printf("pt = (%d, %d)\n", pt.x, pt.y); printf("status = %d\n", status); } |