Merge branch 'stricter-examples-compilation'

* stricter-examples-compilation:
  Travis testing - examples use stricter CFLAGS and CXXFLAGS
  Warning fixes in test-suite
  Refactor Lua class base search to make ISO c/c++ compliant
  Javascript warnings for c++98 - remove vla
  Fix compiler warnings in generated code when using -std=c++98 -std=gnu89 -pedantic -Wreturn-type
  Fix compiler warnings in examples when using -std=c++98 -std=gnu89 -pedantic -Wreturn-type
  Correct CFLAGS CXXFLAGS for Javascript and guile examples
This commit is contained in:
William S Fulton 2014-05-24 14:14:48 +01:00
commit 8350288a6b
58 changed files with 245 additions and 193 deletions

View file

@ -67,6 +67,35 @@ before_install:
- if test "$SWIGLANG" = "python" -a "$PY3" -a -z "$VER"; then sudo apt-get install -qq python3-dev; fi - if test "$SWIGLANG" = "python" -a "$PY3" -a -z "$VER"; then sudo apt-get install -qq python3-dev; fi
- if test "$SWIGLANG" = "python" -a "$VER"; then sudo add-apt-repository -y ppa:fkrull/deadsnakes && sudo apt-get -qq update && sudo apt-get -qq install python${VER}-dev && export CONFIGOPTS="--with-python${PY3}=python${VER}"; fi - if test "$SWIGLANG" = "python" -a "$VER"; then sudo add-apt-repository -y ppa:fkrull/deadsnakes && sudo apt-get -qq update && sudo apt-get -qq install python${VER}-dev && export CONFIGOPTS="--with-python${PY3}=python${VER}"; fi
- if test "$SWIGLANG" = "tcl"; then sudo apt-get -qq install tcl8.4-dev; fi - if test "$SWIGLANG" = "tcl"; then sudo apt-get -qq install tcl8.4-dev; fi
# Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic.
- declare -A CFLAGS_EXAMPLES && CFLAGS_EXAMPLES=(
["csharp"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
["go"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
["guile"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
["java"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
["javascript"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
["lua"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
["octave"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
["perl5"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
["php"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
["python"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
["ruby"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
["tcl"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
)
- declare -A CXXFLAGS_EXAMPLES && CXXFLAGS_EXAMPLES=(
["csharp"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
["go"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
["guile"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
["java"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
["javascript"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
["lua"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
["octave"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
["perl5"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
["php"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
["python"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
["ruby"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
["tcl"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
)
- $CC --version - $CC --version
- $CXX --version - $CXX --version
script: script:
@ -81,7 +110,7 @@ script:
- if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi - if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi
- echo -en 'travis_fold:end:script.2\\r' - echo -en 'travis_fold:end:script.2\\r'
- if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi - if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi
- if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-examples; fi - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-examples CFLAGS="${CFLAGS_EXAMPLES[$SWIGLANG]}" CXXFLAGS="${CXXFLAGS_EXAMPLES[$SWIGLANG]}"; fi
- if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-test-suite; fi - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-test-suite; fi
- echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r' - echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r'
- make maintainer-clean && ../../configure $CONFIGOPTS - make maintainer-clean && ../../configure $CONFIGOPTS

View file

@ -498,7 +498,7 @@ guile_externalhdr:
guile_augmented: $(SRCDIR_SRCS) guile_augmented: $(SRCDIR_SRCS)
$(SWIG) -guile $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(SWIG) -guile $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
$(CC) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) -o $(TARGET) $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) -o $(TARGET)
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# Build statically linked Guile interpreter # Build statically linked Guile interpreter
@ -656,8 +656,8 @@ ifeq (node,$(JSENGINE))
sed -e 's|$$srcdir|./$(SRCDIR)|g' $(SRCDIR)binding.gyp.in > binding.gyp sed -e 's|$$srcdir|./$(SRCDIR)|g' $(SRCDIR)binding.gyp.in > binding.gyp
$(NODEGYP) --loglevel=silent configure build 1>>/dev/null $(NODEGYP) --loglevel=silent configure build 1>>/dev/null
else else
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES)
$(CXXSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
endif endif
@ -669,14 +669,14 @@ ifeq (jsc, $(ENGINE))
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(JSINCLUDES) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(JSINCLUDES)
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
else # (v8 | node) # v8 and node must be compiled as c++ else # (v8 | node) # v8 and node must be compiled as c++
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES)
$(CXXSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
endif endif
javascript_cpp: $(SRCDIR_SRCS) javascript_custom_interpreter javascript_cpp: $(SRCDIR_SRCS) javascript_custom_interpreter
$(SWIG) -javascript -c++ $(SWIGOPT) $(INTERFACEPATH) $(SWIG) -javascript -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES)
$(CXXSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# Running a Javascript example # Running a Javascript example

View file

@ -14,7 +14,7 @@ public:
virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getTitle() { return getPosition() + " " + getName(); }
virtual std::string getName() { return name; } virtual std::string getName() { return name; }
virtual std::string getPosition() const { return "Employee"; } virtual std::string getPosition() const { return "Employee"; }
virtual ~Employee() { printf("~Employee() @ %p\n", this); } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
}; };

View file

@ -19,7 +19,7 @@ Vector operator+(const Vector &a, const Vector &b) {
char *Vector::print() { char *Vector::print() {
static char temp[512]; static char temp[512];
sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp; return temp;
} }

View file

@ -52,9 +52,9 @@ void print_vars() {
printf("cvar = %c\n", cvar); printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar); printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", iptrvar); printf("iptrvar = %p\n", (void *)iptrvar);
printf("name = %s\n", name); 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("pt = (%d, %d)\n", pt.x, pt.y);
printf("status = %d\n", status); printf("status = %d\n", status);
} }

View file

@ -14,7 +14,7 @@ public:
virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getTitle() { return getPosition() + " " + getName(); }
virtual std::string getName() { return name; } virtual std::string getName() { return name; }
virtual std::string getPosition() const { return "Employee"; } virtual std::string getPosition() const { return "Employee"; }
virtual ~Employee() { printf("~Employee() @ %p\n", this); } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
}; };

View file

@ -52,9 +52,9 @@ void print_vars() {
printf("cvar = %c\n", cvar); printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar); printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", iptrvar); printf("iptrvar = %p\n", (void *)iptrvar);
printf("name = %s\n", name); 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("pt = (%d, %d)\n", pt.x, pt.y);
printf("status = %d\n", status); printf("status = %d\n", status);
} }

View file

@ -14,7 +14,7 @@ public:
virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getTitle() { return getPosition() + " " + getName(); }
virtual std::string getName() { return name; } virtual std::string getName() { return name; }
virtual std::string getPosition() const { return "Employee"; } virtual std::string getPosition() const { return "Employee"; }
virtual ~Employee() { printf("~Employee() @ %p\n", this); } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
}; };

View file

@ -19,7 +19,7 @@ Vector operator+(const Vector &a, const Vector &b) {
char *Vector::print() { char *Vector::print() {
static char temp[512]; static char temp[512];
sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp; return temp;
} }

View file

@ -14,7 +14,7 @@ public:
virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getTitle() { return getPosition() + " " + getName(); }
virtual std::string getName() { return name; } virtual std::string getName() { return name; }
virtual std::string getPosition() const { return "Employee"; } virtual std::string getPosition() const { return "Employee"; }
virtual ~Employee() { printf("~Employee() @ %p\n", this); } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
}; };

View file

@ -19,7 +19,7 @@ Vector operator+(const Vector &a, const Vector &b) {
char *Vector::print() { char *Vector::print() {
static char temp[512]; static char temp[512];
sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp; return temp;
} }

View file

@ -52,9 +52,9 @@ void print_vars() {
printf("cvar = %c\n", cvar); printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar); printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", iptrvar); printf("iptrvar = %p\n", (void *)iptrvar);
printf("name = %s\n", name); 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("pt = (%d, %d)\n", pt.x, pt.y);
printf("status = %d\n", status); printf("status = %d\n", status);
} }

View file

@ -19,7 +19,7 @@ Vector operator+(const Vector &a, const Vector &b) {
char *Vector::print() { char *Vector::print() {
static char temp[512]; static char temp[512];
sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp; return temp;
} }

View file

@ -57,9 +57,9 @@ void print_vars() {
printf("cvar = %c\n", cvar); printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar); printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", iptrvar); printf("iptrvar = %p\n", (void *)iptrvar);
printf("name = %s\n", name); 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("pt = (%d, %d)\n", pt.x, pt.y);
printf("status = %d\n", status); printf("status = %d\n", status);
} }

View file

@ -13,7 +13,7 @@ void sort_int(int* arr, int len)
qsort(arr, len, sizeof(int), compare_int); qsort(arr, len, sizeof(int), compare_int);
} }
// ditto doubles /* ditto doubles */
int compare_double(const void * a, const void * b) int compare_double(const void * a, const void * b)
{ {
return (int)( *(double*)a - *(double*)b ); return (int)( *(double*)a - *(double*)b );

View file

@ -45,14 +45,14 @@ void testModule(lua_State *L)
swig_type_info *pTypeInfo=0,*pTypeInfo2=0; swig_type_info *pTypeInfo=0,*pTypeInfo2=0;
swig_module_info *pModule=0; swig_module_info *pModule=0;
pModule=SWIG_GetModule(L); pModule=SWIG_GetModule(L);
DEBUG2(" SWIG_GetModule() returns %p\n",pModule) DEBUG2(" SWIG_GetModule() returns %p\n", (void *)pModule)
if(pModule==0) return; if(pModule==0) return;
pTypeInfo = SWIG_TypeQuery(L,"Foo *"); pTypeInfo = SWIG_TypeQuery(L,"Foo *");
DEBUG2(" Type (Foo*) is %s\n",pTypeInfo==0?"unknown":"known"); 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 *"); pTypeInfo2 = SWIG_TypeQuery(L,"Bar *");
DEBUG2(" Type (Bar*) is %s\n",pTypeInfo2==0?"unknown":"known"); 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[]) int main(int argc,char* argv[])

View file

@ -53,7 +53,7 @@ int call_add(lua_State *L,int a,int b,int* res) {
lua_getglobal(L, "add"); /* function to be called */ lua_getglobal(L, "add"); /* function to be called */
if (!lua_isfunction(L,-1)) { if (!lua_isfunction(L,-1)) {
printf("[C] error: cannot find function 'add'\n"); printf("[C] error: cannot find function 'add'\n");
lua_settop(L,top); // reset lua_settop(L,top);
return 0; return 0;
} }
lua_pushnumber(L,a); lua_pushnumber(L,a);
@ -61,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 */ 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)); printf("[C] error running function `add': %s\n",lua_tostring(L, -1));
lua_settop(L,top); // reset lua_settop(L,top);
return 0; return 0;
} }
// check results /* check results */
if (!lua_isnumber(L,-1)) { if (!lua_isnumber(L,-1)) {
printf("[C] error: returned value is not a number\n"); printf("[C] error: returned value is not a number\n");
lua_settop(L,top); // reset lua_settop(L,top);
return 0; return 0;
} }
*res=(int)lua_tonumber(L,-1); *res=(int)lua_tonumber(L,-1);
lua_settop(L,top); /* reset stack */ lua_settop(L,top); /* reset stack */
return 1; // ok return 1;
} }
/* This is a variargs call function for calling from C into Lua. /* This is a variargs call function for calling from C into Lua.

View file

@ -1,13 +1,12 @@
/* File : example.i */ /* File : example.i */
%module example %module example
%include "typemaps.i" // you must have this for the typemaps for ptrs %include "typemaps.i"
// basic function testing
//
%inline %{ %inline %{
extern int add1(int x, int y); // return x+y -- basic function test 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 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 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 void add4(int x, int *INOUT); /* *y += x -- INOUT dual purpose variable */
%} %}

View file

@ -39,12 +39,15 @@ Square* createSquare(double w)
return new Square(w); return new Square(w);
} }
ShapeOwner::ShapeOwner() {printf(" ShapeOwner(%p)\n",this);} ShapeOwner::ShapeOwner() {
printf(" ShapeOwner(%p)\n", (void *)this);
}
ShapeOwner::~ShapeOwner() ShapeOwner::~ShapeOwner()
{ {
printf(" ~ShapeOwner(%p)\n",this); printf(" ~ShapeOwner(%p)\n", (void *)this);
for(unsigned i=0;i<shapes.size();i++) for(unsigned i=0;i<shapes.size();i++)
delete shapes[i]; delete shapes[i];
} }
void ShapeOwner::add(Shape* ptr) // this method takes ownership of the object void ShapeOwner::add(Shape* ptr) // this method takes ownership of the object

View file

@ -52,9 +52,9 @@ void print_vars() {
printf("cvar = %c\n", cvar); printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar); printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", iptrvar); printf("iptrvar = %p\n", (void *)iptrvar);
printf("name = %s\n", name); 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("pt = (%d, %d)\n", pt.x, pt.y);
printf("status = %d\n", status); printf("status = %d\n", status);
} }

View file

@ -19,7 +19,7 @@ Vector operator+(const Vector &a, const Vector &b) {
char *Vector::print() { char *Vector::print() {
static char temp[512]; static char temp[512];
sprintf(temp,"Vector %x (%g,%g,%g)", (int)this, x,y,z); sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp; return temp;
} }

View file

@ -14,7 +14,7 @@ public:
virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getTitle() { return getPosition() + " " + getName(); }
virtual std::string getName() { return name; } virtual std::string getName() { return name; }
virtual std::string getPosition() const { return "Employee"; } virtual std::string getPosition() const { return "Employee"; }
virtual ~Employee() { printf("~Employee() @ %p\n", this); } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
}; };

View file

@ -19,7 +19,7 @@ Vector operator+(const Vector &a, const Vector &b) {
char *Vector::print() { char *Vector::print() {
static char temp[512]; static char temp[512];
sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp; return temp;
} }

View file

@ -52,9 +52,9 @@ void print_vars() {
printf("cvar = %c\n", cvar); printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar); printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", iptrvar); printf("iptrvar = %p\n", (void *)iptrvar);
printf("name = %s\n", name); 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("pt = (%d, %d)\n", pt.x, pt.y);
printf("status = %d\n", status); printf("status = %d\n", status);
} }

View file

@ -14,7 +14,7 @@ public:
virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getTitle() { return getPosition() + " " + getName(); }
virtual std::string getName() { return name; } virtual std::string getName() { return name; }
virtual std::string getPosition() const { return "Employee"; } virtual std::string getPosition() const { return "Employee"; }
virtual ~Employee() { printf("~Employee() @ %p\n", this); } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
}; };

View file

@ -19,7 +19,7 @@ Vector operator+(const Vector &a, const Vector &b) {
char *Vector::print() { char *Vector::print() {
static char temp[512]; static char temp[512];
sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp; return temp;
} }

View file

@ -26,7 +26,7 @@ Vector *new_Vector(double x, double y, double z) {
} }
void vector_print(Vector *v) { void vector_print(Vector *v) {
printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z); printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z);
} }
%} %}

View file

@ -52,9 +52,9 @@ void print_vars() {
printf("cvar = %c\n", cvar); printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar); printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", iptrvar); printf("iptrvar = %p\n", (void *)iptrvar);
printf("name = %s\n", name); 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("pt = (%d, %d)\n", pt.x, pt.y);
printf("status = %d\n", status); printf("status = %d\n", status);
} }

View file

@ -14,7 +14,7 @@ public:
virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getTitle() { return getPosition() + " " + getName(); }
virtual std::string getName() { return name; } virtual std::string getName() { return name; }
virtual std::string getPosition() const { return "Employee"; } virtual std::string getPosition() const { return "Employee"; }
virtual ~Employee() { printf("~Employee() @ %p\n", this); } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
}; };

View file

@ -19,23 +19,23 @@ Vector operator+(const Vector &a, const Vector &b) {
char *Vector::as_string() { char *Vector::as_string() {
static char temp[512]; static char temp[512];
sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp; return temp;
} }
VectorArray::VectorArray(int size) { VectorArray::VectorArray(int size) {
items = new Vector[size]; items = new Vector[size];
maxsize = size; maxsize = size;
printf("VectorArray new: self=%p\n",this); printf("VectorArray new: self=%p\n", (void *)this);
} }
VectorArray::~VectorArray() { VectorArray::~VectorArray() {
printf("VectorArray delete: self=%p\n",this); printf("VectorArray delete: self=%p\n", (void *)this);
delete [] items; delete [] items;
} }
Vector &VectorArray::operator[](int index) { Vector &VectorArray::operator[](int index) {
printf("VectorArray: read[%d] self=%p\n",index,this); printf("VectorArray: read[%d] self=%p\n", index, (void *)this);
if ((index < 0) || (index >= maxsize)) { if ((index < 0) || (index >= maxsize)) {
printf("Panic! Array index out of bounds.\n"); printf("Panic! Array index out of bounds.\n");
exit(1); exit(1);
@ -44,6 +44,6 @@ Vector &VectorArray::operator[](int index) {
} }
int VectorArray::size() { int VectorArray::size() {
printf("VectorArray: size %d self=%p\n",maxsize,this); printf("VectorArray: size %d self=%p\n", maxsize, (void *)this);
return maxsize; return maxsize;
} }

View file

@ -37,7 +37,7 @@ public:
/* This wrapper provides an alternative to the [] operator */ /* This wrapper provides an alternative to the [] operator */
%extend { %extend {
Vector &get(int index) { Vector &get(int index) {
printf("VectorArray extended get: %p %d\n",$self,index); printf("VectorArray extended get: %p %d\n", (void *)$self, index);
return (*$self)[index]; return (*$self)[index];
} }
void set(int index, Vector &a) { void set(int index, Vector &a) {

View file

@ -10,4 +10,4 @@ void Sync::printer(void) {
printf("The value of global x is %d\n", x); printf("The value of global x is %d\n", x);
printf("The value of class s is %s\n", s); printf("The value of class s is %s\n", s);
printf("The value of class x is %d\n", x); printf("The value of class x is %d\n", x);
}; }

View file

@ -11,7 +11,7 @@
%inline %{ %inline %{
void vector_print(Vector *v) { void vector_print(Vector *v) {
printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z); printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z);
} }
%} %}

View file

@ -52,9 +52,9 @@ void print_vars() {
printf("cvar = %c\n", cvar); printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar); printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", iptrvar); printf("iptrvar = %p\n", (void *)iptrvar);
printf("name = %c%c%c%c%c\n", name[0],name[1],name[2],name[3],name[4]); printf("name = %c%c%c%c%c\n", name[0],name[1],name[2],name[3],name[4]);
printf("ptptr = %p %s\n", ptptr, Point_print( ptptr ) ); printf("ptptr = %p %s\n", (void *)ptptr, Point_print( ptptr ) );
printf("pt = (%d, %d)\n", pt.x, pt.y); printf("pt = (%d, %d)\n", pt.x, pt.y);
printf("status = %d\n", status); printf("status = %d\n", status);
} }

View file

@ -14,7 +14,7 @@ public:
virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getTitle() { return getPosition() + " " + getName(); }
virtual std::string getName() { return name; } virtual std::string getName() { return name; }
virtual std::string getPosition() const { return "Employee"; } virtual std::string getPosition() const { return "Employee"; }
virtual ~Employee() { printf("~Employee() @ %p\n", this); } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
}; };

View file

@ -19,7 +19,7 @@ Vector operator+(const Vector &a, const Vector &b) {
char *Vector::print() { char *Vector::print() {
static char temp[512]; static char temp[512];
sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp; return temp;
} }

View file

@ -9,7 +9,7 @@ Manager* convert_to_Manager(PyObject *py_obj)
{ {
Manager* c_ptr; Manager* c_ptr;
swig_type_info *ty = SWIG_TypeQuery("Manager *"); swig_type_info *ty = SWIG_TypeQuery("Manager *");
printf("manager ty %p \n", ty); printf("manager ty %p \n", (void *)ty);
if (SWIG_ConvertPtr(py_obj, (void **) &c_ptr, ty, 0) == -1) { if (SWIG_ConvertPtr(py_obj, (void **) &c_ptr, ty, 0) == -1) {
c_ptr = 0; c_ptr = 0;
} else { } else {

View file

@ -14,7 +14,7 @@ public:
virtual std::string getTitle() { return getPosition() + " " + getName(); } virtual std::string getTitle() { return getPosition() + " " + getName(); }
virtual std::string getName() { return name; } virtual std::string getName() { return name; }
virtual std::string getPosition() const { return "Employee"; } virtual std::string getPosition() const { return "Employee"; }
virtual ~Employee() { printf("~Employee() @ %p\n", this); } virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
}; };

View file

@ -52,9 +52,9 @@ void print_vars() {
printf("cvar = %c\n", cvar); printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar); printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", iptrvar); printf("iptrvar = %p\n", (void *)iptrvar);
printf("name = %s\n", name); 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("pt = (%d, %d)\n", pt.x, pt.y);
printf("status = %d\n", status); printf("status = %d\n", status);
} }

View file

@ -19,7 +19,7 @@ Vector operator+(const Vector &a, const Vector &b) {
char *Vector::print() { char *Vector::print() {
static char temp[512]; static char temp[512];
sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp; return temp;
} }

View file

@ -26,7 +26,7 @@ Vector *new_Vector(double x, double y, double z) {
} }
void vector_print(Vector *v) { void vector_print(Vector *v) {
printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z); printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z);
} }
%} %}

View file

@ -52,9 +52,9 @@ void print_vars() {
printf("cvar = %c\n", cvar); printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar); printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", iptrvar); printf("iptrvar = %p\n", (void *)iptrvar);
printf("name = %s\n", name); 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("pt = (%d, %d)\n", pt.x, pt.y);
printf("status = %d\n", status); printf("status = %d\n", status);
} }

View file

@ -19,7 +19,7 @@ Vector operator+(const Vector &a, const Vector &b) {
char *Vector::print() { char *Vector::print() {
static char temp[512]; static char temp[512];
sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp; return temp;
} }

View file

@ -26,7 +26,7 @@ Vector *new_Vector(double x, double y, double z) {
} }
void vector_print(Vector *v) { void vector_print(Vector *v) {
printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z); printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z);
} }
%} %}

View file

@ -52,9 +52,9 @@ void print_vars() {
printf("cvar = %c\n", cvar); printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)"); printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar); printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", iptrvar); printf("iptrvar = %p\n", (void *)iptrvar);
printf("name = %s\n", name); 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("pt = (%d, %d)\n", pt.x, pt.y);
printf("status = %d\n", status); printf("status = %d\n", status);
} }

View file

@ -45,7 +45,7 @@ public:
%template(QueryInterfaceObjct) Objct::QueryInterface<Objct>; %template(QueryInterfaceObjct) Objct::QueryInterface<Objct>;
#endif #endif
}; // namespace } // namespace
%} %}

View file

@ -3,7 +3,7 @@
%inline %{ %inline %{
// Named types /* Named types */
struct StructA { struct StructA {
int x; int x;
} instanceA1; } instanceA1;

View file

@ -43,8 +43,8 @@ $1 = 0;
/* Correct typemap for $symname: $type */ /* Correct typemap for $symname: $type */
} }
%inline %{ %inline %{
void func1a(myarray x) {}; void func1a(myarray x) {}
void func1b(volatile myarray x) {}; void func1b(volatile myarray x) {}
%} %}
CLEAR_SWIGTYPE_TYPEMAPS; CLEAR_SWIGTYPE_TYPEMAPS;
@ -57,9 +57,9 @@ $1 = 0;
/* Correct typemap for $symname: $type */ /* Correct typemap for $symname: $type */
} }
%inline %{ %inline %{
void func2a(const myarray x) {}; void func2a(const myarray x) {}
void func2b(const myconstarray x) {}; void func2b(const myconstarray x) {}
void func2c(const volatile myconstarray x) {}; void func2c(const volatile myconstarray x) {}
%} %}
CLEAR_SWIGTYPE_TYPEMAPS; CLEAR_SWIGTYPE_TYPEMAPS;
@ -72,7 +72,7 @@ $1 = 0;
/* Correct typemap for $symname: $type */ /* Correct typemap for $symname: $type */
} }
%inline %{ %inline %{
void func3a(const mycrazyarray x, const mycrazyarray y[7]) {}; void func3a(const mycrazyarray x, const mycrazyarray y[7]) {}
%} %}
CLEAR_SWIGTYPE_TYPEMAPS; CLEAR_SWIGTYPE_TYPEMAPS;
@ -81,5 +81,5 @@ $1 = 0;
/* Correct typemap for $symname: $type */ /* Correct typemap for $symname: $type */
} }
%inline %{ %inline %{
void func4a(mycrazyfunc *const x, const mycrazyfuncptr y) {}; void func4a(mycrazyfunc *const x, const mycrazyfuncptr y) {}
%} %}

View file

@ -27,8 +27,7 @@ scm_module_variable (SCM module, SCM sym)
#endif #endif
#if SCM_MAJOR_VERSION >= 2 #if SCM_MAJOR_VERSION >= 2
// scm_c_define_gsubr takes a different parameter type /* scm_c_define_gsubr takes a different parameter type depending on the guile version */
// depending on the guile version
typedef scm_t_subr swig_guile_proc; typedef scm_t_subr swig_guile_proc;
#else #else

View file

@ -53,7 +53,7 @@ SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t siz
} else { } else {
JSStringRef jsstring; JSStringRef jsstring;
if(size < 2) { if(size < 2) {
char c[size+1]; char c[2];
int i; int i;
for(i=0;i<size;++i) { for(i=0;i<size;++i) {
c[i] = carray[i]; c[i] = carray[i];

View file

@ -113,6 +113,6 @@ void SWIGV8_INIT (v8::Handle<v8::Object> exports, v8::Handle<v8::Object> /*modul
} }
#if defined(BUILDING_NODE_EXTENSION) #if defined(BUILDING_NODE_EXTENSION)
NODE_MODULE($jsname, $jsname_initialize); NODE_MODULE($jsname, $jsname_initialize)
#endif #endif
%} %}

View file

@ -103,7 +103,6 @@ void swiglua_ref_clear(SWIGLUA_REF* pref){
} }
void swiglua_ref_set(SWIGLUA_REF* pref,lua_State* L,int idx){ void swiglua_ref_set(SWIGLUA_REF* pref,lua_State* L,int idx){
// swiglua_ref_clear(pref); /* just in case */
pref->L=L; pref->L=L;
lua_pushvalue(L,idx); /* copy obj to top */ lua_pushvalue(L,idx); /* copy obj to top */
pref->ref=luaL_ref(L,LUA_REGISTRYINDEX); /* remove obj from top & put into registry */ pref->ref=luaL_ref(L,LUA_REGISTRYINDEX); /* remove obj from top & put into registry */

View file

@ -630,10 +630,12 @@ SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State *L, swig_lua_namespace *
/* Register all classes in the namespace */ /* Register all classes in the namespace */
SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace *ns) SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace *ns)
{ {
swig_lua_class **classes;
/* There must be a module/namespace table at the top of the stack */ /* There must be a module/namespace table at the top of the stack */
assert(lua_istable(L,-1)); assert(lua_istable(L,-1));
swig_lua_class **classes = ns->ns_classes; classes = ns->ns_classes;
if( classes != 0 ) { if( classes != 0 ) {
while(*classes != 0) { while(*classes != 0) {
@ -650,6 +652,7 @@ SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace
*/ */
SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns, int reg) SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns, int reg)
{ {
swig_lua_namespace **sub_namespace;
/* 1 argument - table on the top of the stack */ /* 1 argument - table on the top of the stack */
const int SWIGUNUSED begin = lua_gettop(L); const int SWIGUNUSED begin = lua_gettop(L);
assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table or parent namespace table */ assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table or parent namespace table */
@ -681,7 +684,7 @@ SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns
/* Register classes */ /* Register classes */
SWIG_Lua_add_namespace_classes(L,ns); SWIG_Lua_add_namespace_classes(L,ns);
swig_lua_namespace **sub_namespace = ns->ns_namespaces; sub_namespace = ns->ns_namespaces;
if( sub_namespace != 0) { if( sub_namespace != 0) {
while(*sub_namespace != 0) { while(*sub_namespace != 0) {
SWIG_Lua_namespace_register(L, *sub_namespace, 1); SWIG_Lua_namespace_register(L, *sub_namespace, 1);
@ -705,46 +708,6 @@ SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns
SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname); SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname);
/* Macros for iteration among class bases */
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
#define SWIG_LUA_INIT_BASE_SEARCH(bases_count)\
(void)swig_type;\
SWIG_Lua_get_table(L,".bases");\
assert(lua_istable(L,-1));\
bases_count = lua_rawlen(L,-1);\
const int bases_table = lua_gettop(L);
#define SWIG_LUA_GET_BASE_METATABLE(i,base_swig_type, valid)\
lua_rawgeti(L,bases_table,i+1);\
base_swig_type = 0;\
if(lua_isnil(L,-1)) {\
valid = 0;\
lua_pop(L,1);\
} else\
valid = 1;
#else /* In elua .bases table doesn't exist. Use table from swig_lua_class */
#define SWIG_LUA_INIT_BASE_SEARCH(bases_count)\
assert(swig_type!=0);\
swig_module_info *module=SWIG_GetModule(L);\
swig_lua_class **bases= ((swig_lua_class*)(swig_type->clientdata))->bases;\
const char **base_names= ((swig_lua_class*)(swig_type->clientdata))->base_names;\
bases_count = 0;\
for(;base_names[bases_count];bases_count++);/* get length of bases */
#define SWIG_LUA_GET_BASE_METATABLE(i,base_swig_type, valid)\
swig_lua_class *base_class = bases[i];\
if(!base_class)\
valid = 0;\
else {\
valid = 1;\
SWIG_Lua_get_class_metatable(L,base_class->fqname);\
base_swig_type = SWIG_TypeQueryModule(module,module,base_names[i]);\
assert(base_swig_type != 0);\
}
#endif
typedef int (*swig_lua_base_iterator_func)(lua_State*,swig_type_info*, int, int *ret); typedef int (*swig_lua_base_iterator_func)(lua_State*,swig_type_info*, int, int *ret);
SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED swig_type, SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED swig_type,
@ -753,22 +716,41 @@ SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED
/* first_arg - position of the object in stack. Everything that is above are arguments /* first_arg - position of the object in stack. Everything that is above are arguments
* and is passed to every evocation of the func */ * and is passed to every evocation of the func */
int last_arg = lua_gettop(L);/* position of last argument */ int last_arg = lua_gettop(L);/* position of last argument */
int original_metatable; int original_metatable = last_arg + 1;
size_t bases_count; size_t bases_count;
int result; int result = SWIG_ERROR;
int bases_table;
(void)swig_type;
lua_getmetatable(L,first_arg); lua_getmetatable(L,first_arg);
original_metatable = last_arg + 1;
SWIG_LUA_INIT_BASE_SEARCH(bases_count); /* initialise base search */
result = SWIG_ERROR; #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
SWIG_Lua_get_table(L,".bases");
assert(lua_istable(L,-1));
bases_count = lua_rawlen(L,-1);
bases_table = lua_gettop(L);
#else
/* In elua .bases table doesn't exist. Use table from swig_lua_class */
(void)bases_table;
assert(swig_type!=0);
swig_module_info *module=SWIG_GetModule(L);
swig_lua_class **bases= ((swig_lua_class*)(swig_type->clientdata))->bases;
const char **base_names= ((swig_lua_class*)(swig_type->clientdata))->base_names;
bases_count = 0;
for(;base_names[bases_count];
bases_count++);/* get length of bases */
#endif
if(ret) if(ret)
*ret = 0; *ret = 0;
if(bases_count>0) if(bases_count>0)
{ {
int to_remove;
size_t i; size_t i;
int j; int j;
int subcall_last_arg;
int subcall_first_arg = lua_gettop(L) + 1;/* Here a copy of first_arg and arguments begin */ int subcall_first_arg = lua_gettop(L) + 1;/* Here a copy of first_arg and arguments begin */
int valid = 1; int valid = 1;
int subcall_last_arg;
swig_type_info *base_swig_type = 0; swig_type_info *base_swig_type = 0;
for(j=first_arg;j<=last_arg;j++) for(j=first_arg;j<=last_arg;j++)
lua_pushvalue(L,j); lua_pushvalue(L,j);
@ -776,7 +758,28 @@ SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED
/* Trick: temporarily replacing original metatable with metatable for base class and call getter */ /* Trick: temporarily replacing original metatable with metatable for base class and call getter */
for(i=0;i<bases_count;i++) { for(i=0;i<bases_count;i++) {
SWIG_LUA_GET_BASE_METATABLE(i,base_swig_type,valid); /* Iteration through class bases */
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
lua_rawgeti(L,bases_table,i+1);
base_swig_type = 0;
if(lua_isnil(L,-1)) {
valid = 0;
lua_pop(L,1);
} else {
valid = 1;
}
#else /* In elua .bases table doesn't exist. Use table from swig_lua_class */
swig_lua_class *base_class = bases[i];
if(!base_class) {
valid = 0;
} else {
valid = 1;
SWIG_Lua_get_class_metatable(L,base_class->fqname);
base_swig_type = SWIG_TypeQueryModule(module,module,base_names[i]);
assert(base_swig_type != 0);
}
#endif
if(!valid) if(!valid)
continue; continue;
assert(lua_isuserdata(L, subcall_first_arg)); assert(lua_isuserdata(L, subcall_first_arg));
@ -792,7 +795,7 @@ SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED
lua_pushvalue(L,original_metatable); lua_pushvalue(L,original_metatable);
lua_setmetatable(L,first_arg); lua_setmetatable(L,first_arg);
/* Clear - remove everything between last_arg and subcall_last_arg including */ /* Clear - remove everything between last_arg and subcall_last_arg including */
const int to_remove = subcall_last_arg - last_arg; to_remove = subcall_last_arg - last_arg;
for(j=0;j<to_remove;j++) for(j=0;j<to_remove;j++)
lua_remove(L,last_arg+1); lua_remove(L,last_arg+1);
} else { } else {
@ -813,6 +816,7 @@ SWIGINTERN int SWIG_Lua_class_do_get(lua_State *L, swig_type_info *type, int SW
(1) userdata (not the meta table) (1) userdata (not the meta table)
(2) string name of the attribute (2) string name of the attribute
*/ */
int bases_search_result;
int substack_start = lua_gettop(L)-2; int substack_start = lua_gettop(L)-2;
assert(first_arg == substack_start+1); assert(first_arg == substack_start+1);
lua_checkstack(L,5); lua_checkstack(L,5);
@ -865,11 +869,8 @@ SWIGINTERN int SWIG_Lua_class_do_get(lua_State *L, swig_type_info *type, int SW
/* Remove the metatable */ /* Remove the metatable */
lua_pop(L,1); lua_pop(L,1);
/* Search in base classes */ /* Search in base classes */
bases_search_result = SWIG_Lua_iterate_bases(L,type,substack_start+1,SWIG_Lua_class_do_get,ret);
{ return bases_search_result; /* sorry not known */
int bases_search_result = SWIG_Lua_iterate_bases(L,type,substack_start+1,SWIG_Lua_class_do_get,ret);
return bases_search_result; /* sorry not known */
}
} }
/* the class.get method, performs the lookup of class attributes /* the class.get method, performs the lookup of class attributes
@ -880,11 +881,14 @@ SWIGINTERN int SWIG_Lua_class_get(lua_State *L)
(1) userdata (not the meta table) (1) userdata (not the meta table)
(2) string name of the attribute (2) string name of the attribute
*/ */
assert(lua_isuserdata(L,1)); int result;
swig_lua_userdata *usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ swig_lua_userdata *usr;
swig_type_info *type = usr->type; swig_type_info *type;
int ret = 0; int ret = 0;
int result = SWIG_Lua_class_do_get(L,type,1,&ret); assert(lua_isuserdata(L,1));
usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */
type = usr->type;
result = SWIG_Lua_class_do_get(L,type,1,&ret);
if(result == SWIG_OK) if(result == SWIG_OK)
return ret; return ret;
@ -902,6 +906,7 @@ SWIGINTERN int SWIG_Lua_class_do_set(lua_State *L, swig_type_info *type, int fi
(3) any for the new value (3) any for the new value
*/ */
int bases_search_result;
int substack_start = lua_gettop(L) - 3; int substack_start = lua_gettop(L) - 3;
lua_checkstack(L,5); lua_checkstack(L,5);
assert(lua_isuserdata(L,substack_start+1)); /* just in case */ assert(lua_isuserdata(L,substack_start+1)); /* just in case */
@ -944,14 +949,12 @@ SWIGINTERN int SWIG_Lua_class_do_set(lua_State *L, swig_type_info *type, int fi
lua_pop(L,1); /* remove value */ lua_pop(L,1); /* remove value */
lua_pop(L,1); /* remove metatable */ lua_pop(L,1); /* remove metatable */
{ /* Search among bases */
/* Search among bases */ bases_search_result = SWIG_Lua_iterate_bases(L,type,first_arg,SWIG_Lua_class_do_set,ret);
int bases_search_result = SWIG_Lua_iterate_bases(L,type,first_arg,SWIG_Lua_class_do_set,ret); if(ret)
if(ret) assert(*ret == 0);
assert(*ret == 0); assert(lua_gettop(L) == substack_start + 3);
assert(lua_gettop(L) == substack_start + 3); return bases_search_result;
return bases_search_result;
}
} }
/* This is the actual method exported to Lua. It calls SWIG_Lua_class_do_set and correctly /* This is the actual method exported to Lua. It calls SWIG_Lua_class_do_set and correctly
@ -964,11 +967,14 @@ SWIGINTERN int SWIG_Lua_class_set(lua_State *L)
(2) string name of the attribute (2) string name of the attribute
(3) any for the new value (3) any for the new value
*/ */
assert(lua_isuserdata(L,1));
swig_lua_userdata *usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */
swig_type_info *type = usr->type;
int ret = 0; int ret = 0;
int result = SWIG_Lua_class_do_set(L,type,1,&ret); int result;
swig_lua_userdata *usr;
swig_type_info *type;
assert(lua_isuserdata(L,1));
usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */
type = usr->type;
result = SWIG_Lua_class_do_set(L,type,1,&ret);
if(result != SWIG_OK) { if(result != SWIG_OK) {
SWIG_Lua_pushferrstring(L,"Assignment not possible. No setter/member with this name. For custom assignments implement __setitem method."); SWIG_Lua_pushferrstring(L,"Assignment not possible. No setter/member with this name. For custom assignments implement __setitem method.");
lua_error(L); lua_error(L);
@ -1004,13 +1010,15 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L)
{ {
/* there should be 1 param passed in /* there should be 1 param passed in
(1) userdata (not the metatable) */ (1) userdata (not the metatable) */
const char *className;
void* userData;
assert(lua_isuserdata(L,1)); /* just in case */ assert(lua_isuserdata(L,1)); /* just in case */
void* userData = lua_touserdata(L,1); /* get the userdata address for later */ userData = lua_touserdata(L,1); /* get the userdata address for later */
lua_getmetatable(L,1); /* get the meta table */ lua_getmetatable(L,1); /* get the meta table */
assert(lua_istable(L,-1)); /* just in case */ assert(lua_istable(L,-1)); /* just in case */
lua_getfield(L, -1, ".type"); lua_getfield(L, -1, ".type");
const char *className = lua_tostring(L, -1); className = lua_tostring(L, -1);
lua_pushfstring(L, "<%s userdata: %p>", className, userData); lua_pushfstring(L, "<%s userdata: %p>", className, userData);
return 1; return 1;
@ -1238,10 +1246,10 @@ SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class
SWIGINTERN void SWIG_Lua_add_class_instance_details(lua_State *L, swig_lua_class *clss) SWIGINTERN void SWIG_Lua_add_class_instance_details(lua_State *L, swig_lua_class *clss)
{ {
int i; int i;
size_t bases_count = 0;
/* Add bases to .bases table */ /* Add bases to .bases table */
SWIG_Lua_get_table(L,".bases"); SWIG_Lua_get_table(L,".bases");
assert(lua_istable(L,-1)); /* just in case */ assert(lua_istable(L,-1)); /* just in case */
size_t bases_count = 0;
for(i=0;clss->bases[i];i++) for(i=0;clss->bases[i];i++)
{ {
SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname); SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
@ -1296,7 +1304,7 @@ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L); /*forward declaration
/* The real function that resolves a metamethod. /* The real function that resolves a metamethod.
* Function searches given class and all it's bases(recursively) for first instance of something that is * Function searches given class and all it's bases(recursively) for first instance of something that is
* not equal to SWIG_Lua_resolve_metatmethod. (Almost always this 'something' is actuall metamethod implementation * not equal to SWIG_Lua_resolve_metatmethod. (Almost always this 'something' is actual metamethod implementation
* and it is a SWIG-generated C function.). It returns value on the top of the L and there is no garbage below the * and it is a SWIG-generated C function.). It returns value on the top of the L and there is no garbage below the
* answer. * answer.
* Returns 1 if found, 0 otherwise. * Returns 1 if found, 0 otherwise.
@ -1310,6 +1318,9 @@ SWIGINTERN int SWIG_Lua_do_resolve_metamethod(lua_State *L, const swig_lua_class
int skip_check) int skip_check)
{ {
/* This function is called recursively */ /* This function is called recursively */
int result = 0;
int i = 0;
if (!skip_check) { if (!skip_check) {
SWIG_Lua_get_class_metatable(L, clss->fqname); SWIG_Lua_get_class_metatable(L, clss->fqname);
lua_pushvalue(L, metamethod_name_idx); lua_pushvalue(L, metamethod_name_idx);
@ -1326,8 +1337,6 @@ SWIGINTERN int SWIG_Lua_do_resolve_metamethod(lua_State *L, const swig_lua_class
} }
/* Forwarding calls to bases */ /* Forwarding calls to bases */
int result = 0;
int i = 0;
for(i=0;clss->bases[i];i++) for(i=0;clss->bases[i];i++)
{ {
result = SWIG_Lua_do_resolve_metamethod(L, clss->bases[i], metamethod_name_idx, 0); result = SWIG_Lua_do_resolve_metamethod(L, clss->bases[i], metamethod_name_idx, 0);
@ -1342,21 +1351,26 @@ SWIGINTERN int SWIG_Lua_do_resolve_metamethod(lua_State *L, const swig_lua_class
* and calls it */ * and calls it */
SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L) SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L)
{ {
int numargs;
int metamethod_name_idx;
const swig_lua_class* clss;
int result;
lua_checkstack(L,5); lua_checkstack(L,5);
const int numargs = lua_gettop(L); /* number of arguments to pass to actuall metamethod */ numargs = lua_gettop(L); /* number of arguments to pass to actual metamethod */
/* Get upvalues from closure */ /* Get upvalues from closure */
lua_pushvalue(L, lua_upvalueindex(1)); /*Get function name*/ lua_pushvalue(L, lua_upvalueindex(1)); /*Get function name*/
const int metamethod_name_idx = lua_gettop(L); metamethod_name_idx = lua_gettop(L);
lua_pushvalue(L, lua_upvalueindex(2)); lua_pushvalue(L, lua_upvalueindex(2));
const swig_lua_class* clss = (const swig_lua_class*)(lua_touserdata(L,-1)); clss = (const swig_lua_class*)(lua_touserdata(L,-1));
lua_pop(L,1); /* remove lightuserdata with clss from stack */ lua_pop(L,1); /* remove lightuserdata with clss from stack */
/* Actuall work */ /* Actual work */
const int result = SWIG_Lua_do_resolve_metamethod(L, clss, metamethod_name_idx, 1); result = SWIG_Lua_do_resolve_metamethod(L, clss, metamethod_name_idx, 1);
if (!result) { if (!result) {
SWIG_Lua_pushferrstring(L,"The metamethod proxy is set, but it failed to find actuall metamethod. Memory corruption is most likely explanation."); SWIG_Lua_pushferrstring(L,"The metamethod proxy is set, but it failed to find actual metamethod. Memory corruption is most likely explanation.");
lua_error(L); lua_error(L);
return 0; return 0;
} }
@ -1374,10 +1388,14 @@ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L)
*/ */
SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class *clss, const int metatable_index) SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class *clss, const int metatable_index)
{ {
int key_index;
int success = 0;
int i = 0;
/* metamethod name - on the top of the stack */ /* metamethod name - on the top of the stack */
assert(lua_isstring(L,-1)); assert(lua_isstring(L,-1));
const int key_index = lua_gettop(L); key_index = lua_gettop(L);
/* Check whether method is already defined in metatable */ /* Check whether method is already defined in metatable */
lua_pushvalue(L,key_index); /* copy of the key */ lua_pushvalue(L,key_index); /* copy of the key */
@ -1389,8 +1407,6 @@ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class *
lua_pop(L,1); lua_pop(L,1);
/* Iterating over immediate bases */ /* Iterating over immediate bases */
int success = 0;
int i = 0;
for(i=0;clss->bases[i];i++) for(i=0;clss->bases[i];i++)
{ {
const swig_lua_class *base = clss->bases[i]; const swig_lua_class *base = clss->bases[i];
@ -1420,11 +1436,15 @@ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class *
SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss) SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss)
{ {
int metatable_index;
int metamethods_info_index;
int tostring_undefined;
SWIG_Lua_get_class_metatable(L, clss->fqname); SWIG_Lua_get_class_metatable(L, clss->fqname);
const int metatable_index = lua_gettop(L); metatable_index = lua_gettop(L);
SWIG_Lua_get_inheritable_metamethods(L); SWIG_Lua_get_inheritable_metamethods(L);
assert(lua_istable(L,-1)); assert(lua_istable(L,-1));
const int metamethods_info_index = lua_gettop(L); metamethods_info_index = lua_gettop(L);
lua_pushnil(L); /* first key */ lua_pushnil(L); /* first key */
while(lua_next(L, metamethods_info_index) != 0 ) { while(lua_next(L, metamethods_info_index) != 0 ) {
/* key at index -2, value at index -1 */ /* key at index -2, value at index -1 */
@ -1442,7 +1462,7 @@ SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class
lua_pushstring(L, "__tostring"); lua_pushstring(L, "__tostring");
lua_pushvalue(L,-1); lua_pushvalue(L,-1);
lua_rawget(L,metatable_index); lua_rawget(L,metatable_index);
const int tostring_undefined = lua_isnil(L,-1); tostring_undefined = lua_isnil(L,-1);
lua_pop(L,1); lua_pop(L,1);
if( tostring_undefined ) { if( tostring_undefined ) {
lua_pushcfunction(L, SWIG_Lua_class_tostring); lua_pushcfunction(L, SWIG_Lua_class_tostring);
@ -1494,6 +1514,7 @@ SWIGINTERN void SWIG_Lua_class_register_static(lua_State *L, swig_lua_class *cls
*/ */
SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *clss) SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *clss)
{ {
int new_metatable_index;
const int SWIGUNUSED begin = lua_gettop(L); const int SWIGUNUSED begin = lua_gettop(L);
int i; int i;
/* if name already there (class is already registered) then do nothing */ /* if name already there (class is already registered) then do nothing */
@ -1520,11 +1541,12 @@ SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *c
* It would get us all special methods: __getitem, __add etc. * It would get us all special methods: __getitem, __add etc.
* This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away * This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away
*/ */
const int new_metatable_index = lua_absindex(L,-1); new_metatable_index = lua_absindex(L,-1);
for(i=0;clss->bases[i];i++) for(i=0;clss->bases[i];i++)
{ {
int base_metatable;
SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname); SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
const int base_metatable = lua_absindex(L,-1); base_metatable = lua_absindex(L,-1);
SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable); SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable);
lua_pop(L,1); lua_pop(L,1);
} }
@ -1573,6 +1595,7 @@ SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *c
SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss) SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss)
{ {
int SWIGUNUSED begin;
assert(lua_istable(L,-1)); /* This is a table (module or namespace) where classes will be added */ assert(lua_istable(L,-1)); /* This is a table (module or namespace) where classes will be added */
SWIG_Lua_class_register_instance(L,clss); SWIG_Lua_class_register_instance(L,clss);
SWIG_Lua_class_register_static(L,clss); SWIG_Lua_class_register_static(L,clss);
@ -1587,7 +1610,7 @@ SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss)
* | ".set" --> .... * | ".set" --> ....
* |=============================== ".instance" * |=============================== ".instance"
*/ */
const int SWIGUNUSED begin = lua_gettop(L); begin = lua_gettop(L);
lua_pushstring(L,clss->cls_static->name); lua_pushstring(L,clss->cls_static->name);
lua_rawget(L,-2); /* get class static table */ lua_rawget(L,-2); /* get class static table */
assert(lua_istable(L,-1)); assert(lua_istable(L,-1));

View file

@ -29,6 +29,7 @@ SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */
{ {
#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */ #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */
int i; int i;
int globalRegister = 0;
/* start with global table */ /* start with global table */
lua_pushglobaltable (L); lua_pushglobaltable (L);
/* SWIG's internal initialisation */ /* SWIG's internal initialisation */
@ -49,7 +50,6 @@ SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */
SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata)); SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata));
} }
} }
int globalRegister = 0;
#ifdef SWIG_LUA_MODULE_GLOBAL #ifdef SWIG_LUA_MODULE_GLOBAL
globalRegister = 1; globalRegister = 1;
#endif #endif

View file

@ -296,7 +296,7 @@ This is one giant macro to define the typemaps & the helpers
for array handling for array handling
*/ */
%define SWIG_TYPEMAP_NUM_ARR(NAME,TYPE) %define SWIG_TYPEMAP_NUM_ARR(NAME,TYPE)
%{SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE);%} %{SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE)%}
// fixed size array's // fixed size array's
%typemap(in) TYPE INPUT[ANY] %typemap(in) TYPE INPUT[ANY]

View file

@ -34,12 +34,12 @@
SWIGTYPE &&, SWIGTYPE &&,
SWIGTYPE [] { SWIGTYPE [] {
zval *z_var; zval *z_var;
zend_constant c;
size_t len = sizeof("$symname") - 1;
MAKE_STD_ZVAL(z_var); MAKE_STD_ZVAL(z_var);
SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0); SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0);
zend_constant c;
c.value = *z_var; c.value = *z_var;
zval_copy_ctor(&c.value); zval_copy_ctor(&c.value);
size_t len = sizeof("$symname") - 1;
c.name = zend_strndup("$symname", len); c.name = zend_strndup("$symname", len);
c.name_len = len+1; c.name_len = len+1;
c.flags = CONST_CS | CONST_PERSISTENT; c.flags = CONST_CS | CONST_PERSISTENT;

View file

@ -92,6 +92,7 @@
%fragment("t_output_helper","header") %{ %fragment("t_output_helper","header") %{
static void static void
t_output_helper(zval **target, zval *o TSRMLS_DC) { t_output_helper(zval **target, zval *o TSRMLS_DC) {
zval *tmp;
if ( (*target)->type == IS_ARRAY ) { if ( (*target)->type == IS_ARRAY ) {
/* it's already an array, just append */ /* it's already an array, just append */
add_next_index_zval( *target, o ); add_next_index_zval( *target, o );
@ -102,7 +103,6 @@ t_output_helper(zval **target, zval *o TSRMLS_DC) {
FREE_ZVAL(o); FREE_ZVAL(o);
return; return;
} }
zval *tmp;
ALLOC_INIT_ZVAL(tmp); ALLOC_INIT_ZVAL(tmp);
*tmp = **target; *tmp = **target;
zval_copy_ctor(tmp); zval_copy_ctor(tmp);

View file

@ -4,7 +4,7 @@
extern "C" { extern "C" {
#endif #endif
// Ruby 1.9 changed the file name of this header /* Ruby 1.9 changed the file name of this header */
#ifdef HAVE_RUBY_IO_H #ifdef HAVE_RUBY_IO_H
#include "ruby/io.h" #include "ruby/io.h"
#else #else