Fixed naming convention issues (internal Swig variables, shadow -> proxy, test.c -> runme.c, etc.), modified Makefiles, bugfixes ("name" -> "sym:name"). Started C test-suite.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10655 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Maciej Drwal 2008-07-09 20:02:20 +00:00
commit a13c5976b5
35 changed files with 925 additions and 639 deletions

View file

@ -1103,10 +1103,12 @@ c: $(SRCS)
$(SWIG) -c $(SWIGOPT) $(INTERFACE) $(SWIG) -c $(SWIGOPT) $(INTERFACE)
$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(CLIBPREFIX)$(TARGET)$(SO) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(CLIBPREFIX)$(TARGET)$(SO)
$(CC) $(MAIN) $(TARGET)_proxy.c -L. -l$(TARGET)
c_cpp: $(SRCS) c_cpp: $(SRCS)
$(SWIG) -c++ -c $(SWIGOPT) $(INTERFACE) $(SWIG) -c++ -c $(SWIGOPT) $(INTERFACE)
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(CLIBPREFIX)$(TARGET)$(SO) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(CLIBPREFIX)$(TARGET)$(SO)
$(CC) $(MAIN) $(TARGET)_proxy.c -L. -l$(TARGET)
c_compile: $(RUNME) $(PROXY)
$(CC) $(RUNME) $(PROXY) -L. -l$(TARGET) -o $(RUNME:.c=)

View file

@ -3,11 +3,17 @@ SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
CXXSRCS = example.cxx CXXSRCS = example.cxx
TARGET = example TARGET = example
INTERFACE = example.i INTERFACE = example.i
MAIN = test.c RUNME = runme.c
PROXY = example_proxy.c
all:: all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c_cpp TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c_cpp
run:
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
TARGET='$(TARGET)' c_compile
env LD_LIBRARY_PATH=. ./runme
clean: clean:
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~ rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~

View file

@ -0,0 +1,36 @@
#include <stdio.h>
#include "example_proxy.h"
int main(int argc, char** argv) {
MyClass* mc = new_MyClass();
A* a = new_A(123), *b = new_A(234), *as[5];
int i, j = 321, *js[5];
double d = 55.0;
for (i = 0; i < 4; ++i) {
as[i] = new_A(20 + i);
js[i] = (int*) malloc(sizeof(int));
*js[i] = 10 + i;
}
as[i] = 0;
js[i] = 0;
MyClass_bar(mc, j, &j, js);
MyClass_foo(mc, a, b, as);
MyClass_foo_1(mc, a, b);
MyClass_foo_1(mc, a, b);
MyClass_foo_2(mc, &j, &d);
MyClass_foo_2(mc, &j, &d);
delete_A(a);
delete_A(b);
delete_MyClass(mc);
for (i = 0; i < 4; ++i)
delete_A(as[i]);
return 0;
}

4
Examples/c/check.list Normal file
View file

@ -0,0 +1,4 @@
# see top-level Makefile.in
class
reference
simple

View file

@ -3,11 +3,17 @@ SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
CXXSRCS = example.cxx CXXSRCS = example.cxx
TARGET = example TARGET = example
INTERFACE = example.i INTERFACE = example.i
MAIN = test.c RUNME = runme.c
PROXY = example_proxy.c
all:: all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c_cpp TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c_cpp
run:
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
TARGET='$(TARGET)' c_compile
env LD_LIBRARY_PATH=. ./runme
clean: clean:
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~ rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~

43
Examples/c/class/runme.c Normal file
View file

@ -0,0 +1,43 @@
#include <stdio.h>
#include "example_proxy.h"
int main(int argc, char **argv) {
printf("Creating some objects:\n");
Circle* c = new_Circle(10);
printf(" Created circle\n");
Square* s = new_Square(10);
printf(" Created square\n");
printf("\nA total of %d shapes were created\n", Shape_nshapes_get());
Circle_x_set(c, 20);
Circle_y_set(c, 30);
Shape* shape = (Shape*) s;
Shape_x_set(shape, -10);
Shape_y_set(shape, 5);
printf("\nHere is their current positions:\n");
printf(" Circle = (%f %f)\n", Circle_x_get(c), Circle_y_get(c));
printf(" Square = (%f %f)\n", Square_x_get(s), Square_y_get(s));
printf("\nHere are some properties of the shapes:\n");
Shape* shapes[] = {(Shape*) c, (Shape*) s};
int i;
for (i = 0; i < 2; i++) {
printf(" %s\n", i ? "Square" : "Circle");
printf(" area = %f\n", Shape_area(shapes[i]));
printf(" perimeter = %f\n", Shape_perimeter(shapes[i]));
}
printf("\nGuess I'll clean up now\n");
delete_Square(s);
delete_Circle(c);
printf("%d shapes remain\n", Shape_nshapes_get());
printf("Goodbye\n");
return 0;
}

View file

@ -3,11 +3,17 @@ SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
CXXSRCS = example.cxx CXXSRCS = example.cxx
TARGET = example TARGET = example
INTERFACE = example.i INTERFACE = example.i
MAIN = test.c RUNME = runme.c
PROXY = example_proxy.c
all:: all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c_cpp TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c_cpp
run:
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
TARGET='$(TARGET)' c_compile
env LD_LIBRARY_PATH=. ./runme
clean: clean:
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~ rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~

View file

@ -0,0 +1,21 @@
#include <stdio.h>
#include "example_proxy.h"
void test(Bar * bar) {
printf("value of x is %d\n", Bar_get(bar));
}
int main(int argc, char** argv) {
Bar* bar = new_Bar();
test(bar);
foo_by_val(bar);
test(bar);
foo_by_ptr(bar);
test(bar);
foo_by_ref(bar);
test(bar);
delete_Bar(bar);
return 0;
}

View file

@ -3,11 +3,17 @@ SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
CXXSRCS = example.cxx CXXSRCS = example.cxx
TARGET = example TARGET = example
INTERFACE = example.i INTERFACE = example.i
MAIN = test.c RUNME = runme.c
PROXY = example_proxy.c
all:: all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c_cpp TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c_cpp
run:
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
TARGET='$(TARGET)' c_compile
env LD_LIBRARY_PATH=. ./runme
clean: clean:
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~ rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~

11
Examples/c/return/runme.c Normal file
View file

@ -0,0 +1,11 @@
#include <stdio.h>
#include "example_proxy.h"
int main(int argc, char** argv) {
Bar b = foo_ret_val();
//Bar * bp = foo_ret_ptr(NULL);
printf("x = %d\n", Bar_get(&b));
return 0;
}

View file

@ -3,11 +3,17 @@ SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
SRCS = example.c SRCS = example.c
TARGET = example TARGET = example
INTERFACE = example.i INTERFACE = example.i
MAIN = test.c RUNME = runme.c
PROXY = example_proxy.c
all:: all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c
run:
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
TARGET='$(TARGET)' c_compile
env LD_LIBRARY_PATH=. ./runme
clean: clean:
rm -f *.o *.so *.out *.a *.exe *.dll *_wrap* *_proxy* *~ rm -f *.o *.so *.out *.a *.exe *.dll *_wrap* *_proxy* *~

15
Examples/c/simple/runme.c Normal file
View file

@ -0,0 +1,15 @@
#include <stdio.h>
#include "example_proxy.h"
int main(int argc, char **argv) {
int a = 35;
int b = 15;
printf("Foo is %f\n", Foo);
printf("Foo by ptr is \%f\n", *Foo_ptr);
printf("my_str is: %s\n", my_str);
printf("GCD(%d, %d)=%d\n", a, b, gcd(a, b));
printf("array_of_strs contains %s and %s\n", get_str(0, 0, 0), get_str(1, 0, 0));
return 0;
}

View file

@ -0,0 +1,62 @@
#######################################################################
# Makefile for C test-suite
#######################################################################
LANGUAGE = c
C = gcc
CXX = g++
SCRIPTSUFFIX = _runme.c
srcdir = @srcdir@
top_srcdir = @top_srcdir@/..
top_builddir = @top_builddir@/..
C_TEST_CASES =
CPP_TEST_CASES = \
c_arguments
include $(srcdir)/../common.mk
# Rules for the different types of tests
%.cpptest:
$(setup)
+(cd $* && $(swig_and_compile_cpp))
$(run_testcase)
%.ctest:
$(setup)
+(cd $* && $(swig_and_compile_c))
$(run_testcase)
%.multicpptest:
$(setup)
+(cd $* && $(swig_and_compile_multi_cpp))
$(run_testcase)
# Makes a directory for the testcase if it does not exist
setup = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
else \
echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
fi; \
if [ ! -d $* ]; then \
mkdir $*; \
fi;
# Compiles C files then runs the testcase. A testcase is only run if
# a file is found which has _runme.c appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then (\
cd $* && $(COMPILETOOL) $(CC) ../$*_runme.c $*_proxy.c -L. -l$* -o $*_runme && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) ./$*_runme;) \
fi;
# Clean: remove testcase directories
%.clean:
@if [ -d $* ]; then \
rm -rf $*; \
fi;
clean:
@rm -f *_wrap.* *_proxy.* *~ *.exe *.dll *.so *.out *runme

View file

@ -0,0 +1,17 @@
#include <stdio.h>
#include "c_arguments/c_arguments_proxy.h"
int main(int argc, char **argv) {
A* a = new_A();
if (A_foo(a, 0) != 1)
fprintf(stderr, "call to A_foo() failed\n");
delete_A(a);
int ***array = (int ***) 0;
foo_1(array);
return 0;
}

View file

@ -0,0 +1,20 @@
%module c_arguments
%inline %{
class A {
public:
A() {}
int foo(int i) {
return i+1;
}
};
void foo(A a, A &ra, A *pa, char c, char *str, char **pstr, char ***ppstri) {
}
void foo_1(int ***a) {
}
%}

View file

@ -6,27 +6,32 @@
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
%insert("runtime") "clabels.swg" %insert("runtime") "clabels.swg"
%insert("shadow_header") "cproxy.swg" %insert("proxy_header") "cproxy.swg"
// typemaps for function parameters // typemaps for function parameters
%typemap(ctype) void, short, int, long, char, float, double "$1_type" %typemap(ctype) void, short, int, long, char, float, double "$1_type"
%typemap(ctype) unsigned short, unsigned int, unsigned long, unsigned char "$1_type"
%typemap(ctype) void*, short*, int*, long*, char*, float*, double* "$1_type" %typemap(ctype) void*, short*, int*, long*, char*, float*, double* "$1_type"
%typemap(ctype) unsigned short*, unsigned int*, unsigned long*, unsigned char* "$1_type"
%typemap(ctype) short&, int&, long&, char&, float&, double& "$1_basetype *" %typemap(ctype) short&, int&, long&, char&, float&, double& "$1_basetype *"
%typemap(ctype) unsigned short&, unsigned int&, unsigned long&, unsigned char& "$1_basetype *"
%typemap(ctype) const short, const int, const long, const char, const float, const double "$1_basetype" %typemap(ctype) const short, const int, const long, const char, const float, const double "$1_basetype"
%typemap(ctype) const unsigned short, const unsigned int, const unsigned long, const unsigned char "$1_basetype"
%typemap(ctype) bool "_Bool" %typemap(ctype) bool "_Bool"
%typemap(ctype) SWIGTYPE "$1_type" %typemap(ctype) SWIGTYPE "$1_type"
%typemap(ctype) SWIGTYPE * "$1_type" %typemap(ctype) SWIGTYPE * "$1_type"
%typemap(ctype) SWIGTYPE & "$1_type" %typemap(ctype) SWIGTYPE & "$1_type"
%typemap(ctype) SWIGTYPE * [ANY] "$1_basetype*" %typemap(ctype) SWIGTYPE * [ANY] "$1_basetype*"
%typemap(ctype) SWIGCLASSTYPE "struct Obj$1_type *" %typemap(ctype) SWIGCLASSTYPE "struct SwigObj$1_type *"
%typemap(ctype) SWIGCLASSTYPE * "struct Obj$1_type" %typemap(ctype) SWIGCLASSTYPE * "struct SwigObj$1_type"
%typemap(ctype) SWIGCLASSTYPE & "struct Obj$*1_ltype *" %typemap(ctype) SWIGCLASSTYPE & "struct SwigObj$*1_ltype *"
%typemap(ctype) SWIGCLASSTYPE * [ANY] "struct Obj$1_basetype*" %typemap(ctype) SWIGCLASSTYPE * [ANY] "struct SwigObj$1_basetype *"
%typemap(in) short, int, long, char, float, double, bool "$1 = ($1_basetype) $input;" %typemap(in) short, int, long, char, float, double, bool "$1 = ($1_basetype) $input;"
%typemap(in) void*, short*, int*, long*, char*, float*, double*, bool* "$1 = ($1_basetype *) $input;" %typemap(in) void*, short*, int*, long*, char*, float*, double*, bool* "$1 = ($1_basetype *) $input;"
%typemap(in) short&, int&, long&, char&, float&, double&, bool& "$1 = ($1_basetype *) $input;" %typemap(in) short&, int&, long&, char&, float&, double&, bool& "$1 = ($1_basetype *) $input;"
%typemap(in) SWIGTYPE "$1 = ($1_type) $input;" %typemap(in) SWIGTYPE "$1 = ($1_type) $input;"
%typemap(in) SWIGTYPE * "$1 = ($1_type) $input;" %typemap(in) SWIGTYPE * "$1 = ($1_type) $input;"
%typemap(in) SWIGTYPE & "$1 = ($1_type) $input;" %typemap(in) SWIGTYPE & "$1 = ($1_type) $input;"
@ -59,8 +64,8 @@
%typemap(couttype) void*, short*, int*, long*, char*, float*, double* "$1_type" %typemap(couttype) void*, short*, int*, long*, char*, float*, double* "$1_type"
%typemap(couttype) const short, const int, const long, const char, const float, const double "$1_basetype" %typemap(couttype) const short, const int, const long, const char, const float, const double "$1_basetype"
%typemap(couttype) bool "_Bool" %typemap(couttype) bool "_Bool"
%typemap(couttype) SWIGTYPE "struct Obj$1_type" %typemap(couttype) SWIGTYPE "struct SwigObj$1_type"
%typemap(couttype) SWIGTYPE * "struct Obj$*1_type *" %typemap(couttype) SWIGTYPE * "struct SwigObj$*1_type *"
%typemap(out) short, int, long, char, float, double, bool "$result = $1;" %typemap(out) short, int, long, char, float, double, bool "$result = $1;"
%typemap(out) void*, short*, int*, long*, char*, float*, double*, bool* "$result = $1;" %typemap(out) void*, short*, int*, long*, char*, float*, double*, bool* "$result = $1;"

View file

@ -57,6 +57,7 @@ skip-clisp = test -n "@SKIP_CLISP@"
skip-cffi = test -n "@SKIP_CFFI@" skip-cffi = test -n "@SKIP_CFFI@"
skip-uffi = test -n "@SKIP_UFFI@" skip-uffi = test -n "@SKIP_UFFI@"
skip-r = test -n "@SKIP_R@" skip-r = test -n "@SKIP_R@"
skip-c = test -n "@SKIP_C@"
# Additional dependencies for some tests # Additional dependencies for some tests
skip-gcj = test -n "@SKIP_GCJ@" skip-gcj = test -n "@SKIP_GCJ@"
@ -91,6 +92,7 @@ check-aliveness:
@$(skip-modula3) || ./$(TARGET) -modula3 -help @$(skip-modula3) || ./$(TARGET) -modula3 -help
@$(skip-lua) || ./$(TARGET) -lua -help @$(skip-lua) || ./$(TARGET) -lua -help
@$(skip-r) || ./$(TARGET) -r -help @$(skip-r) || ./$(TARGET) -r -help
@$(skip-c) || ./$(TARGET) -c -help
# Checks examples for compilation (does not run them) # Checks examples for compilation (does not run them)
check-examples: \ check-examples: \
@ -113,7 +115,8 @@ check-examples: \
check-clisp-examples \ check-clisp-examples \
check-uffi-examples \ check-uffi-examples \
check-cffi-examples \ check-cffi-examples \
check-r-examples check-r-examples \
check-c-examples
tcl_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/tcl/check.list) tcl_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/tcl/check.list)
perl5_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/perl5/check.list) perl5_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/perl5/check.list)
@ -135,6 +138,7 @@ clisp_examples :=
uffi_examples := uffi_examples :=
cffi_examples := cffi_examples :=
r_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/r/check.list) r_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/r/check.list)
c_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/c/check.list)
# all examples # all examples
check-%-examples : check-%-examples :
@ -181,7 +185,8 @@ check-gifplot: \
check-chicken-gifplot \ check-chicken-gifplot \
# check-lua-gifplot \ # check-lua-gifplot \
# check-csharp-gifplot \ # check-csharp-gifplot \
# check-modula3-gifplot # check-modula3-gifplot \
# check-c-gifplot
check-%-gifplot: gifplot-library check-%-gifplot: gifplot-library
@if test -z "$(skip-$*)"; then \ @if test -z "$(skip-$*)"; then \
@ -228,7 +233,8 @@ check-test-suite: \
check-uffi-test-suite \ check-uffi-test-suite \
check-cffi-test-suite \ check-cffi-test-suite \
check-chicken-test-suite \ check-chicken-test-suite \
check-r-test-suite check-r-test-suite \
check-c-test-suite
check-%-test-suite: check-%-test-suite:
@if test -z "$(skip-$*)"; then \ @if test -z "$(skip-$*)"; then \
@ -279,7 +285,8 @@ all-test-suite: \
all-uffi-test-suite \ all-uffi-test-suite \
all-cffi-test-suite \ all-cffi-test-suite \
all-chicken-test-suite \ all-chicken-test-suite \
all-r-test-suite all-r-test-suite \
all-c-test-suite
all-%-test-suite: all-%-test-suite:
@$(MAKE) -k -s check-$*-test-suite ACTION=all @$(MAKE) -k -s check-$*-test-suite ACTION=all
@ -306,7 +313,8 @@ broken-test-suite: \
broken-uffi-test-suite \ broken-uffi-test-suite \
broken-cffi-test-suite \ broken-cffi-test-suite \
broken-chicken-test-suite \ broken-chicken-test-suite \
broken-r-test-suite broken-r-test-suite \
broken-c-test-suite
broken-%-test-suite: broken-%-test-suite:
@$(MAKE) -k -s check-$*-test-suite ACTION=broken @$(MAKE) -k -s check-$*-test-suite ACTION=broken
@ -391,7 +399,8 @@ noskip-test-suite: \
noskip-uffi-test-suite \ noskip-uffi-test-suite \
noskip-cffi-test-suite \ noskip-cffi-test-suite \
noskip-chicken-test-suite \ noskip-chicken-test-suite \
noskip-r-test-suite noskip-r-test-suite \
noskip-c-test-suite
noskip-%-test-suite: noskip-%-test-suite:
dir="Examples/test-suite/$*"; \ dir="Examples/test-suite/$*"; \
@ -440,7 +449,7 @@ install-main:
@$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@ @$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@
lib-languages = gcj typemaps tcl perl5 python guile java mzscheme ruby php4 ocaml octave \ lib-languages = gcj typemaps tcl perl5 python guile java mzscheme ruby php4 ocaml octave \
pike chicken csharp modula3 allegrocl clisp lua cffi uffi r pike chicken csharp modula3 allegrocl clisp lua cffi uffi r c
lib-modules = std lib-modules = std

View file

@ -18,16 +18,16 @@ class C:public Language {
File *f_header; File *f_header;
File *f_wrappers; File *f_wrappers;
File *f_init; File *f_init;
File *f_shadow_c; File *f_proxy_c;
File *f_shadow_h; File *f_proxy_h;
String *f_shadow_code_init; String *f_proxy_code_init;
String *f_shadow_code_body; String *f_proxy_code_body;
String *f_shadow_header; String *f_proxy_header;
String *empty_string; String *empty_string;
bool shadow_flag; bool proxy_flag;
bool runtime_flag; bool runtime_flag;
public: public:
@ -38,7 +38,7 @@ public:
C() : C() :
empty_string(NewString("")), empty_string(NewString("")),
shadow_flag(true), proxy_flag(true),
runtime_flag(true) { runtime_flag(true) {
} }
@ -64,12 +64,15 @@ public:
if (argv[i]) { if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) { if (strcmp(argv[i], "-help") == 0) {
Printf(stdout, "%s\n", usage); Printf(stdout, "%s\n", usage);
} else if ((strcmp(argv[i], "-shadow") == 0) || (strcmp(argv[i], "-proxy") == 0)) { } else if ((strcmp(argv[i], "-proxy") == 0) || (strcmp(argv[i], "-proxy") == 0)) {
shadow_flag = true; proxy_flag = true;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-noproxy") == 0) { } else if (strcmp(argv[i], "-noproxy") == 0) {
shadow_flag = false; proxy_flag = false;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-noruntime") == 0) { } else if (strcmp(argv[i], "-noruntime") == 0) {
runtime_flag = false; runtime_flag = false;
Swig_mark_arg(i);
} }
} }
} }
@ -106,12 +109,12 @@ public:
Printf(f_header, "#include <stdlib.h>\n"); Printf(f_header, "#include <stdlib.h>\n");
Printf(f_header, "#include <string.h>\n"); Printf(f_header, "#include <string.h>\n");
Printf(f_header, "#include <setjmp.h>\n\n"); Printf(f_header, "#include <setjmp.h>\n\n");
Printf(f_header, "static jmp_buf __rt_env;\n"); Printf(f_header, "static jmp_buf Swig_rt_env;\n");
Printf(f_header, "static int __rt_init = 0;\n\n"); Printf(f_header, "static int Swig_rt_init = 0;\n\n");
Printf(f_header, "void __runtime_init() {\n"); Printf(f_header, "void Swig_runtime_init() {\n");
Printf(f_header, " if (!__rt_init) {\n"); Printf(f_header, " if (!Swig_rt_init) {\n");
Printf(f_header, " __rt_init = 1;\n"); Printf(f_header, " Swig_rt_init = 1;\n");
Printf(f_header, " if (setjmp(__rt_env)) {\n"); Printf(f_header, " if (setjmp(Swig_rt_env)) {\n");
Printf(f_header, " fprintf(stderr, \"An error occured. Exitting...\\n\");\n"); Printf(f_header, " fprintf(stderr, \"An error occured. Exitting...\\n\");\n");
Printf(f_header, " exit(1);\n"); Printf(f_header, " exit(1);\n");
Printf(f_header, " }\n"); Printf(f_header, " }\n");
@ -119,32 +122,32 @@ public:
Printf(f_header, "}\n\n"); Printf(f_header, "}\n\n");
} }
// generate shadow files if enabled // generate proxy files if enabled
if (shadow_flag) { if (proxy_flag) {
f_shadow_code_init = NewString(""); f_proxy_code_init = NewString("");
f_shadow_code_body = NewString(""); f_proxy_code_body = NewString("");
f_shadow_header = NewString(""); f_proxy_header = NewString("");
// create shadow files with appropriate name // create proxy files with appropriate name
String *shadow_code_filename = NewStringf("%s%s_proxy.c", SWIG_output_directory(), Char(module)); String *proxy_code_filename = NewStringf("%s%s_proxy.c", SWIG_output_directory(), Char(module));
if ((f_shadow_c = NewFile(shadow_code_filename, "w")) == 0) { if ((f_proxy_c = NewFile(proxy_code_filename, "w")) == 0) {
FileErrorDisplay(shadow_code_filename); FileErrorDisplay(proxy_code_filename);
SWIG_exit(EXIT_FAILURE); SWIG_exit(EXIT_FAILURE);
} }
String *shadow_header_filename = NewStringf("%s%s_proxy.h", SWIG_output_directory(), Char(module)); String *proxy_header_filename = NewStringf("%s%s_proxy.h", SWIG_output_directory(), Char(module));
if ((f_shadow_h = NewFile(shadow_header_filename, "w")) == 0) { if ((f_proxy_h = NewFile(proxy_header_filename, "w")) == 0) {
FileErrorDisplay(shadow_header_filename); FileErrorDisplay(proxy_header_filename);
SWIG_exit(EXIT_FAILURE); SWIG_exit(EXIT_FAILURE);
} }
Swig_register_filebyname("shadow_code_init", f_shadow_code_init); Swig_register_filebyname("proxy_code_init", f_proxy_code_init);
Swig_register_filebyname("shadow_code_body", f_shadow_code_body); Swig_register_filebyname("proxy_code_body", f_proxy_code_body);
Swig_register_filebyname("shadow_header", f_shadow_header); Swig_register_filebyname("proxy_header", f_proxy_header);
Swig_banner(f_shadow_code_init); Swig_banner(f_proxy_code_init);
Swig_banner(f_shadow_header); Swig_banner(f_proxy_header);
Printf(f_shadow_code_init, "#include \"%s\"\n\n", shadow_header_filename); Printf(f_proxy_code_init, "#include \"%s\"\n\n", proxy_header_filename);
} }
Swig_register_filebyname("header", f_header); Swig_register_filebyname("header", f_header);
@ -163,15 +166,15 @@ public:
Printf(f_wrappers, "}\n"); Printf(f_wrappers, "}\n");
Printf(f_wrappers, "#endif\n"); Printf(f_wrappers, "#endif\n");
// finalize generating shadow file // finalize generating proxy file
if (shadow_flag) { if (proxy_flag) {
Printv(f_shadow_c, f_shadow_code_init, "\n", NIL); Printv(f_proxy_c, f_proxy_code_init, "\n", NIL);
Printv(f_shadow_c, f_shadow_code_body, "\n", NIL); Printv(f_proxy_c, f_proxy_code_body, "\n", NIL);
Printv(f_shadow_h, f_shadow_header, "\n", NIL); Printv(f_proxy_h, f_proxy_header, "\n", NIL);
Close(f_shadow_c); Close(f_proxy_c);
Close(f_shadow_h); Close(f_proxy_h);
Delete(f_shadow_code_init); Delete(f_proxy_code_init);
Delete(f_shadow_header); Delete(f_proxy_header);
} }
// write all to the file // write all to the file
@ -198,8 +201,8 @@ public:
String *type_str = SwigType_str(type, 0); String *type_str = SwigType_str(type, 0);
//if (!CPlusPlus) //if (!CPlusPlus)
// Printv(f_wrappers, "SWIGEXPORTC ", type_str, " ", Getattr(n, "name"), ";\n", NIL); // Printv(f_wrappers, "SWIGEXPORTC ", type_str, " ", Getattr(n, "name"), ";\n", NIL);
if (shadow_flag) { if (proxy_flag) {
Printv(f_shadow_header, "SWIGIMPORT ", type_str, " ", Getattr(n, "name"), ";\n", NIL); Printv(f_proxy_header, "SWIGIMPORT ", type_str, " ", Getattr(n, "name"), ";\n", NIL);
} }
return SWIG_OK; return SWIG_OK;
} }
@ -398,7 +401,7 @@ public:
SwigType* type = Getattr(p, "type"); SwigType* type = Getattr(p, "type");
String* lname = Getattr(p, "lname"); String* lname = Getattr(p, "lname");
String* c_parm_type = NewString(""); String* c_parm_type = NewString("");
String* shadow_parm_type = NewString(""); String* proxy_parm_type = NewString("");
String* arg_name = NewString(""); String* arg_name = NewString("");
Printf(arg_name, "c%s", lname); Printf(arg_name, "c%s", lname);
@ -414,20 +417,20 @@ public:
Swig_warning(WARN_C_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s\n", SwigType_str(type, 0)); Swig_warning(WARN_C_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s\n", SwigType_str(type, 0));
} }
// use shadow-type for parameter if supplied // use proxy-type for parameter if supplied
String* stype = Getattr(p, "c:stype"); String* stype = Getattr(p, "c:stype");
if (stype) { if (stype) {
Printv(shadow_parm_type, SwigType_str(stype, 0), NIL); Printv(proxy_parm_type, SwigType_str(stype, 0), NIL);
} }
else { else {
Printv(shadow_parm_type, c_parm_type, NIL); Printv(proxy_parm_type, c_parm_type, NIL);
} }
Replaceall(c_parm_type, "::", "_"); Replaceall(c_parm_type, "::", "_");
Printv(arg_names, gencomma ? ", " : "", Getattr(p, "name"), NIL); Printv(arg_names, gencomma ? ", " : "", Getattr(p, "name"), NIL);
Printv(wrapper->def, gencomma ? ", " : "", c_parm_type, " ", arg_name, NIL); Printv(wrapper->def, gencomma ? ", " : "", c_parm_type, " ", arg_name, NIL);
Printv(proto, gencomma ? ", " : "", shadow_parm_type, " ", Getattr(p, "name"), NIL); Printv(proto, gencomma ? ", " : "", proxy_parm_type, " ", Getattr(p, "name"), NIL);
gencomma = 1; gencomma = 1;
// apply typemaps for input parameter // apply typemaps for input parameter
@ -448,7 +451,7 @@ public:
p = nextSibling(p); p = nextSibling(p);
} }
Delete(arg_name); Delete(arg_name);
Delete(shadow_parm_type); Delete(proxy_parm_type);
Delete(c_parm_type); Delete(c_parm_type);
} }
@ -483,23 +486,23 @@ public:
Append(wrapper->code, "}\n"); Append(wrapper->code, "}\n");
} }
// take care of shadow function // take care of proxy function
if (shadow_flag) { if (proxy_flag) {
// use shadow-type for return type if supplied // use proxy-type for return type if supplied
SwigType* shadow_type = Getattr(n, "c:stype"); SwigType *proxy_type = Getattr(n, "c:stype");
if (shadow_type) { if (proxy_type) {
return_type = SwigType_str(shadow_type, 0); return_type = SwigType_str(proxy_type, 0);
} }
// emit proxy functions prototypes // emit proxy functions prototypes
Printv(f_shadow_code_init, "extern ", return_type, " ", wname, "(", proto, ");\n", NIL); Printv(f_proxy_code_init, "extern ", return_type, " ", wname, "(", proto, ");\n", NIL);
Printv(f_shadow_code_body, return_type, " ", name, "(", proto, ") {\n", NIL); Printv(f_proxy_code_body, return_type, " ", name, "(", proto, ") {\n", NIL);
// call to the wrapper function // call to the wrapper function
Printv(f_shadow_code_body, " return ", wname, "(", arg_names, ");\n}\n", NIL); Printv(f_proxy_code_body, " return ", wname, "(", arg_names, ");\n}\n", NIL);
// add function declaration to the proxy header file // add function declaration to the proxy header file
Printv(f_shadow_header, return_type, " ", name, "(", proto, ");\n"); Printv(f_proxy_header, return_type, " ", name, "(", proto, ");\n");
} }
Wrapper_print(wrapper, f_wrappers); Wrapper_print(wrapper, f_wrappers);
@ -522,13 +525,13 @@ public:
Printf(code, "{\nint i = 0, type_ok = 0;\n"); Printf(code, "{\nint i = 0, type_ok = 0;\n");
Printf(code, "if (arg1 == NULL) {\n"); Printf(code, "if (arg1 == NULL) {\n");
Printv(code, " fprintf(stderr, \"error: NULL object-struct passed to ", funcname, "\\n\");\n"); Printv(code, " fprintf(stderr, \"error: NULL object-struct passed to ", funcname, "\\n\");\n");
Printf(code, " longjmp(__rt_env, 0);\n}\n"); Printf(code, " longjmp(Swig_rt_env, 0);\n}\n");
Printf(code, "while(arg1->typenames[i]) {\n"); Printf(code, "while(arg1->typenames[i]) {\n");
Printv(code, " if (strcmp(arg1->typenames[i++], \"", classname, "\") == 0) {\n", NIL); Printv(code, " if (strcmp(arg1->typenames[i++], \"", classname, "\") == 0) {\n", NIL);
Printf(code, " type_ok = 1;\nbreak;\n}\n}\n"); Printf(code, " type_ok = 1;\nbreak;\n}\n}\n");
Printf(code, "if (!type_ok) {\n"); Printf(code, "if (!type_ok) {\n");
Printv(code, " fprintf(stderr, \"error: object-struct passed to ", funcname, " is not of class ", classname, "\\n\");\n", NIL); Printv(code, " fprintf(stderr, \"error: object-struct passed to ", funcname, " is not of class ", classname, "\\n\");\n", NIL);
Printf(code, " longjmp(__rt_env, 0);\n}\n}\n"); Printf(code, " longjmp(Swig_rt_env, 0);\n}\n}\n");
} }
/* --------------------------------------------------------------------- /* ---------------------------------------------------------------------
@ -549,7 +552,7 @@ public:
} }
/* --------------------------------------------------------------------- /* ---------------------------------------------------------------------
* copy_node() * is_in()
* *
* tests if given name already exists in one of child nodes of n * tests if given name already exists in one of child nodes of n
* --------------------------------------------------------------------- */ * --------------------------------------------------------------------- */
@ -605,18 +608,18 @@ public:
} }
// emit "class"-struct definition // emit "class"-struct definition
Printv(sobj, "struct Obj", name, " {\n void* obj;\n", NIL); Printv(sobj, "struct SwigObj", name, " {\n void* obj;\n", NIL);
if (runtime_flag) if (runtime_flag)
Printf(sobj, " const char* typenames[%d];\n}", Len(baselist) + 2); Printf(sobj, " const char* typenames[%d];\n}", Len(baselist) + 2);
else else
Printf(sobj, "};\n\n"); Printf(sobj, "};\n\n");
Printv(f_header, sobj, ";\n\n", NIL); Printv(f_header, sobj, ";\n\n", NIL);
Printv(f_header, "const char* __typename_", name, " = \"", name, "\";\n\n", NIL); Printv(f_header, "const char* Swig_typename_", name, " = \"", name, "\";\n\n", NIL);
// declare it in the proxy header // declare it in the proxy header
if (shadow_flag) if (proxy_flag)
Printv(f_shadow_header, "typedef ", sobj, " ", name, ";\n\n", NIL); Printv(f_proxy_header, "typedef ", sobj, " ", name, ";\n\n", NIL);
Delete(sobj); Delete(sobj);
Delete(name); Delete(name);
@ -624,19 +627,19 @@ public:
} }
else if (Cmp(Getattr(n, "kind"), "struct") == 0) { else if (Cmp(Getattr(n, "kind"), "struct") == 0) {
// this is C struct, just declare it in proxy // this is C struct, just declare it in proxy
if (shadow_flag) { if (proxy_flag) {
Printv(f_shadow_header, "struct ", name, " {\n", NIL); Printv(f_proxy_header, "struct ", name, " {\n", NIL);
Node* node; Node* node;
for (node = firstChild(n); node; node = nextSibling(node)) { for (node = firstChild(n); node; node = nextSibling(node)) {
String* kind = Getattr(node, "kind"); String* kind = Getattr(node, "kind");
if ((Cmp(kind, "variable") == 0) || (Cmp(kind, "function") == 0)) { if ((Cmp(kind, "variable") == 0) || (Cmp(kind, "function") == 0)) {
String* type = NewString(""); String* type = NewString("");
Printv(type, Getattr(node, "decl"), Getattr(node, "type"), NIL); Printv(type, Getattr(node, "decl"), Getattr(node, "type"), NIL);
Printv(f_shadow_header, " ", SwigType_str(type, 0), " ", Getattr(node, "name"), ";\n", NIL); Printv(f_proxy_header, " ", SwigType_str(type, 0), " ", Getattr(node, "name"), ";\n", NIL);
Delete(type); Delete(type);
} }
} }
Append(f_shadow_header, "};\n\n"); Append(f_proxy_header, "};\n\n");
} }
Delete(sobj); Delete(sobj);
@ -651,7 +654,7 @@ public:
virtual int staticmemberfunctionHandler(Node *n) { virtual int staticmemberfunctionHandler(Node *n) {
String *name = Getattr(n, "name"); String *name = Getattr(n, "name");
String* classname = Getattr(parentNode(n), "name"); String *classname = Getattr(parentNode(n), "sym:name");
String *newclassname = Copy(classname); String *newclassname = Copy(classname);
String *new_name = NewString(""); String *new_name = NewString("");
String *code = NewString(""); String *code = NewString("");
@ -689,7 +692,7 @@ public:
virtual int memberfunctionHandler(Node *n) { virtual int memberfunctionHandler(Node *n) {
String *name = Getattr(n, "name"); String *name = Getattr(n, "name");
String* classname = Getattr(parentNode(n), "name"); String *classname = Getattr(parentNode(n), "sym:name");
String *newclassname = Copy(classname); String *newclassname = Copy(classname);
String *sobj_name = NewString(""); String *sobj_name = NewString("");
String *ctype = NewString(""); String *ctype = NewString("");
@ -702,7 +705,7 @@ public:
Replaceall(newclassname, "::", "_"); Replaceall(newclassname, "::", "_");
// create first argument // create first argument
Printv(sobj_name, "struct Obj", newclassname, NIL); Printv(sobj_name, "struct SwigObj", newclassname, NIL);
ctype = Copy(sobj_name); ctype = Copy(sobj_name);
SwigType_add_pointer(ctype); SwigType_add_pointer(ctype);
Parm *p = NewParm(ctype, "self"); Parm *p = NewParm(ctype, "self");
@ -757,7 +760,7 @@ public:
void wrap_get_variable(Node *n, String *classname, String *newclassname, String *name, String *code) { void wrap_get_variable(Node *n, String *classname, String *newclassname, String *name, String *code) {
// modify method name // modify method name
String *new_name = NewString(""); String *new_name = NewString("");
Printv(new_name, newclassname, "_get_", name, NIL); Printv(new_name, newclassname, "_", Swig_name_get(name), NIL);
Setattr(n, "sym:name", new_name); Setattr(n, "sym:name", new_name);
// generate action code // generate action code
@ -788,7 +791,7 @@ public:
void wrap_set_variable(Node *n, String *classname, String *newclassname, String *name, String *code) { void wrap_set_variable(Node *n, String *classname, String *newclassname, String *name, String *code) {
// modify method name // modify method name
String *new_name = NewString(""); String *new_name = NewString("");
Printv(new_name, newclassname, "_set_", name, NIL); Printv(new_name, newclassname, "_", Swig_name_set(name), NIL);
Setattr(n, "sym:name", new_name); Setattr(n, "sym:name", new_name);
// generate action code // generate action code
@ -803,6 +806,7 @@ public:
} }
Append(action, code); Append(action, code);
Setattr(n, "wrap:action", action); Setattr(n, "wrap:action", action);
Setattr(n, "type", "void");
functionWrapper(n); functionWrapper(n);
@ -818,7 +822,7 @@ public:
virtual int staticmembervariableHandler(Node *n) { virtual int staticmembervariableHandler(Node *n) {
String *name = Getattr(n, "sym:name"); String *name = Getattr(n, "sym:name");
SwigType *type = Copy(Getattr(n, "type")); SwigType *type = Copy(Getattr(n, "type"));
String* classname = Getattr(parentNode(n), "name"); String *classname = Getattr(parentNode(n), "sym:name");
String *newclassname = Copy(classname); String *newclassname = Copy(classname);
String *new_name = NewString(""); String *new_name = NewString("");
String *code = NewString(""); String *code = NewString("");
@ -854,7 +858,7 @@ public:
virtual int membervariableHandler(Node *n) { virtual int membervariableHandler(Node *n) {
String *name = Getattr(n, "sym:name"); String *name = Getattr(n, "sym:name");
SwigType *type = Copy(Getattr(n, "type")); SwigType *type = Copy(Getattr(n, "type"));
String* classname = Getattr(parentNode(n), "name"); String *classname = Getattr(parentNode(n), "sym:name");
String *newclassname = Copy(classname); String *newclassname = Copy(classname);
String *sobj_name = NewString(""); String *sobj_name = NewString("");
String *ctype = NewString(""); String *ctype = NewString("");
@ -863,7 +867,7 @@ public:
Replaceall(newclassname, "::", "_"); Replaceall(newclassname, "::", "_");
// create first argument // create first argument
Printv(sobj_name, "struct Obj", newclassname, NIL); Printv(sobj_name, "struct SwigObj", newclassname, NIL);
ctype = Copy(sobj_name); ctype = Copy(sobj_name);
SwigType_add_pointer(ctype); SwigType_add_pointer(ctype);
Parm *p = NewParm(ctype, "self"); Parm *p = NewParm(ctype, "self");
@ -905,16 +909,16 @@ public:
void emit_runtime_make_object(Node *n, String *classname, String *code) { void emit_runtime_make_object(Node *n, String *classname, String *code) {
// store the name of each class in the hierarchy // store the name of each class in the hierarchy
List *baselist = Getattr(parentNode(n), "bases"); List *baselist = Getattr(parentNode(n), "bases");
Printv(code, "result->typenames[0] = __typename_", classname, ";\n", NIL); Printv(code, "result->typenames[0] = Swig_typename_", classname, ";\n", NIL);
int i = 1; int i = 1;
if (baselist) { if (baselist) {
Iterator it; Iterator it;
for (it = First(baselist); it.item; it = Next(it)) { for (it = First(baselist); it.item; it = Next(it)) {
Printf(code, "result->typenames[%d] = __typename_%s;\n", i++, Getattr(it.item, "name")); Printf(code, "result->typenames[%d] = Swig_typename_%s;\n", i++, Getattr(it.item, "name"));
} }
} }
Printf(code, "result->typenames[%d] = 0;\n", i); Printf(code, "result->typenames[%d] = 0;\n", i);
Printf(code, "__runtime_init();\n"); Printf(code, "Swig_runtime_init();\n");
} }
/* --------------------------------------------------------------------- /* ---------------------------------------------------------------------
@ -925,7 +929,7 @@ public:
if (Getattr(n, "copy_constructor")) if (Getattr(n, "copy_constructor"))
return copyconstructorHandler(n); return copyconstructorHandler(n);
String* classname = Getattr(parentNode(n), "name"); String *classname = Getattr(parentNode(n), "sym:name");
String *newclassname = Copy(classname); String *newclassname = Copy(classname);
String *sobj_name = NewString(""); String *sobj_name = NewString("");
String *ctype; String *ctype;
@ -941,7 +945,7 @@ public:
Append(arg_lnames, Swig_cfunction_call(empty_string, parms)); Append(arg_lnames, Swig_cfunction_call(empty_string, parms));
// set the function return type to the pointer to struct // set the function return type to the pointer to struct
Printv(sobj_name, "struct Obj", newclassname, NIL); Printv(sobj_name, "struct SwigObj", newclassname, NIL);
ctype = Copy(sobj_name); ctype = Copy(sobj_name);
SwigType_add_pointer(ctype); SwigType_add_pointer(ctype);
Setattr(n, "type", ctype); Setattr(n, "type", ctype);
@ -980,7 +984,7 @@ public:
* --------------------------------------------------------------------- */ * --------------------------------------------------------------------- */
virtual int copyconstructorHandler(Node *n) { virtual int copyconstructorHandler(Node *n) {
String* classname = Getattr(parentNode(n), "name"); String *classname = Getattr(parentNode(n), "sym:name");
String *newclassname = Copy(classname); String *newclassname = Copy(classname);
String *sobj_name = NewString(""); String *sobj_name = NewString("");
String *ctype; String *ctype;
@ -993,7 +997,7 @@ public:
Setattr(parms, "lname", "arg1"); Setattr(parms, "lname", "arg1");
// set the function return type to the pointer to struct // set the function return type to the pointer to struct
Printv(sobj_name, "struct Obj", newclassname, NIL); Printv(sobj_name, "struct SwigObj", newclassname, NIL);
ctype = Copy(sobj_name); ctype = Copy(sobj_name);
SwigType_add_pointer(ctype); SwigType_add_pointer(ctype);
Setattr(n, "type", ctype); Setattr(n, "type", ctype);
@ -1031,7 +1035,7 @@ public:
* --------------------------------------------------------------------- */ * --------------------------------------------------------------------- */
virtual int destructorHandler(Node *n) { virtual int destructorHandler(Node *n) {
String* classname = Getattr(parentNode(n), "name"); String *classname = Getattr(parentNode(n), "sym:name");
String *newclassname = Copy(classname); String *newclassname = Copy(classname);
String *sobj_name = NewString(""); String *sobj_name = NewString("");
String *ctype; String *ctype;
@ -1044,7 +1048,7 @@ public:
Replaceall(newclassname, "~", ""); Replaceall(newclassname, "~", "");
// create first argument // create first argument
Printv(sobj_name, "struct Obj", newclassname, " ", NIL); Printv(sobj_name, "struct SwigObj", newclassname, " ", NIL);
ctype = Copy(sobj_name); ctype = Copy(sobj_name);
SwigType_add_pointer(ctype); SwigType_add_pointer(ctype);
p = NewParm(ctype, "self"); p = NewParm(ctype, "self");

View file

@ -1959,6 +1959,12 @@ SKIP_UFFI=
#fi #fi
AC_SUBST(SKIP_UFFI) AC_SUBST(SKIP_UFFI)
SKIP_C=
if test -x "$(CC)" || test -z "$(CXX)" ; then
SKIP_C="1"
fi
AC_SUBST(SKIP_C)
#---------------------------------------------------------------- #----------------------------------------------------------------
# Additional language dependencies # Additional language dependencies
#---------------------------------------------------------------- #----------------------------------------------------------------
@ -2039,6 +2045,7 @@ AC_CONFIG_FILES([ \
Examples/test-suite/cffi/Makefile \ Examples/test-suite/cffi/Makefile \
Examples/test-suite/uffi/Makefile \ Examples/test-suite/uffi/Makefile \
Examples/test-suite/r/Makefile \ Examples/test-suite/r/Makefile \
Examples/test-suite/c/Makefile \
Lib/ocaml/swigp4.ml Lib/ocaml/swigp4.ml
]) ])
AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig]) AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig])