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:
parent
f585c69d02
commit
a13c5976b5
35 changed files with 925 additions and 639 deletions
|
|
@ -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=)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,20 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
|
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::
|
|
||||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
all::
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c_cpp
|
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c_cpp
|
||||||
clean:
|
|
||||||
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~
|
run:
|
||||||
|
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
|
||||||
|
TARGET='$(TARGET)' c_compile
|
||||||
|
env LD_LIBRARY_PATH=. ./runme
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,52 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
public:
|
public:
|
||||||
int i;
|
int i;
|
||||||
A(int i) : i(i) {}
|
A(int i) : i(i) {}
|
||||||
void foo() {
|
void foo() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class B : public A {
|
class B : public A {
|
||||||
public:
|
public:
|
||||||
B(int i) : A(i) {}
|
B(int i) : A(i) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyClass {
|
class MyClass {
|
||||||
public:
|
public:
|
||||||
void foo(A a, A* aa, A* aaa[5]) {
|
void foo(A a, A* aa, A* aaa[5]) {
|
||||||
printf("a.i = %d\n", a.i);
|
printf("a.i = %d\n", a.i);
|
||||||
printf("aa->i = %d\n", aa->i);
|
printf("aa->i = %d\n", aa->i);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (aaa[i]) {
|
while (aaa[i]) {
|
||||||
printf("aaa[%d]->i = %d\n", i, aaa[i]->i);
|
printf("aaa[%d]->i = %d\n", i, aaa[i]->i);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bar(int x, int* px, int** xs) {
|
void bar(int x, int* px, int** xs) {
|
||||||
printf("x = %d\n", x);
|
printf("x = %d\n", x);
|
||||||
printf("*px = %d\n", *px);
|
printf("*px = %d\n", *px);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (xs[i]) {
|
while (xs[i]) {
|
||||||
printf("*xs[%d] = %d\n", i, *xs[i]);
|
printf("*xs[%d] = %d\n", i, *xs[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void foo_1(A& a, A& b) {
|
void foo_1(A& a, A& b) {
|
||||||
printf("a.i = %d\n", a.i);
|
printf("a.i = %d\n", a.i);
|
||||||
printf("b.i = %d\n", b.i);
|
printf("b.i = %d\n", b.i);
|
||||||
a.i++;
|
a.i++;
|
||||||
b.i++;
|
b.i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void foo_2(int& x, double& d) {
|
void foo_2(int& x, double& d) {
|
||||||
printf("x = %d d = %f\n", x, d);
|
printf("x = %d d = %f\n", x, d);
|
||||||
x++;
|
x++;
|
||||||
d++;
|
d++;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
%module example
|
%module example
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "example.h"
|
%include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
36
Examples/c/arguments/runme.c
Normal file
36
Examples/c/arguments/runme.c
Normal 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
4
Examples/c/check.list
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
# see top-level Makefile.in
|
||||||
|
class
|
||||||
|
reference
|
||||||
|
simple
|
||||||
|
|
@ -1,14 +1,20 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
|
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::
|
|
||||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
all::
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c_cpp
|
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c_cpp
|
||||||
clean:
|
|
||||||
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~
|
run:
|
||||||
|
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
|
||||||
|
TARGET='$(TARGET)' c_compile
|
||||||
|
env LD_LIBRARY_PATH=. ./runme
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
/* File : example.c */
|
/* File : example.c */
|
||||||
|
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
#define M_PI 3.14159265358979323846
|
#define M_PI 3.14159265358979323846
|
||||||
|
|
||||||
/* Move the shape to a new location */
|
/* Move the shape to a new location */
|
||||||
void Shape::move(double dx, double dy) {
|
void Shape::move(double dx, double dy) {
|
||||||
x += dx;
|
x += dx;
|
||||||
y += dy;
|
y += dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Shape::nshapes = 0;
|
int Shape::nshapes = 0;
|
||||||
|
|
||||||
double Circle::area(void) {
|
double Circle::area(void) {
|
||||||
return M_PI*radius*radius;
|
return M_PI*radius*radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Circle::perimeter(void) {
|
double Circle::perimeter(void) {
|
||||||
return 2*M_PI*radius;
|
return 2*M_PI*radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Square::area(void) {
|
double Square::area(void) {
|
||||||
return width*width;
|
return width*width;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Square::perimeter(void) {
|
double Square::perimeter(void) {
|
||||||
return 4*width;
|
return 4*width;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,39 @@
|
||||||
/* File : example.h */
|
/* File : example.h */
|
||||||
|
|
||||||
class Shape {
|
class Shape {
|
||||||
public:
|
public:
|
||||||
Shape() {
|
Shape() {
|
||||||
nshapes++;
|
nshapes++;
|
||||||
}
|
}
|
||||||
virtual ~Shape() {
|
virtual ~Shape() {
|
||||||
nshapes--;
|
nshapes--;
|
||||||
};
|
};
|
||||||
double x, y;
|
double x, y;
|
||||||
void move(double dx, double dy);
|
void move(double dx, double dy);
|
||||||
virtual double area(void) = 0;
|
virtual double area(void) = 0;
|
||||||
virtual double perimeter(void) = 0;
|
virtual double perimeter(void) = 0;
|
||||||
static int nshapes;
|
static int nshapes;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Circle : public Shape {
|
class Circle : public Shape {
|
||||||
private:
|
private:
|
||||||
double radius;
|
double radius;
|
||||||
public:
|
public:
|
||||||
Circle(double r) : radius(r) { };
|
Circle(double r) : radius(r) { };
|
||||||
virtual double area(void);
|
virtual double area(void);
|
||||||
virtual double perimeter(void);
|
virtual double perimeter(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Square : public Shape {
|
class Square : public Shape {
|
||||||
private:
|
private:
|
||||||
double width;
|
double width;
|
||||||
public:
|
public:
|
||||||
Square(double w) : width(w) { };
|
Square(double w) : width(w) { };
|
||||||
virtual double area(void);
|
virtual double area(void);
|
||||||
virtual double perimeter(void);
|
virtual double perimeter(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module example
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/* Let's just grab the original header file here */
|
/* Let's just grab the original header file here */
|
||||||
%include "example.h"
|
%include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
43
Examples/c/class/runme.c
Normal file
43
Examples/c/class/runme.c
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,14 +1,20 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
|
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::
|
|
||||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
all::
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c_cpp
|
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c_cpp
|
||||||
clean:
|
|
||||||
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~
|
run:
|
||||||
|
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
|
||||||
|
TARGET='$(TARGET)' c_compile
|
||||||
|
env LD_LIBRARY_PATH=. ./runme
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
|
|
||||||
void foo_by_val(Bar bar) {
|
void foo_by_val(Bar bar) {
|
||||||
bar.set(123);
|
bar.set(123);
|
||||||
printf("inside foo_by_val: %d\n", bar.get());
|
printf("inside foo_by_val: %d\n", bar.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void foo_by_ref(Bar& bar) {
|
void foo_by_ref(Bar& bar) {
|
||||||
bar.set(123);
|
bar.set(123);
|
||||||
printf("inside foo_by_ref: %d\n", bar.get());
|
printf("inside foo_by_ref: %d\n", bar.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void foo_by_ptr(Bar* bar) {
|
void foo_by_ptr(Bar* bar) {
|
||||||
bar->set(123);
|
bar->set(123);
|
||||||
printf("inside foo_by_ptr: %d\n", bar->get());
|
printf("inside foo_by_ptr: %d\n", bar->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
class Bar {
|
class Bar {
|
||||||
private:
|
private:
|
||||||
int x;
|
int x;
|
||||||
public:
|
public:
|
||||||
Bar() : x(0) {}
|
Bar() : x(0) {}
|
||||||
~Bar() {}
|
~Bar() {}
|
||||||
void set(int x) { this->x = x; }
|
void set(int x) { this->x = x; }
|
||||||
int get() { return x; }
|
int get() { return x; }
|
||||||
};
|
};
|
||||||
|
|
||||||
void foo_by_val(Bar bar);
|
void foo_by_val(Bar bar);
|
||||||
void foo_by_ref(Bar& bar);
|
void foo_by_ref(Bar& bar);
|
||||||
void foo_by_ptr(Bar* bar);
|
void foo_by_ptr(Bar* bar);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
%module example
|
%module example
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "example.h"
|
%include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
21
Examples/c/reference/runme.c
Normal file
21
Examples/c/reference/runme.c
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,14 +1,20 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
|
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::
|
|
||||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
all::
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c_cpp
|
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||||
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c_cpp
|
||||||
clean:
|
|
||||||
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~
|
run:
|
||||||
|
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
|
||||||
|
TARGET='$(TARGET)' c_compile
|
||||||
|
env LD_LIBRARY_PATH=. ./runme
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
|
|
||||||
Bar foo_ret_val() {
|
Bar foo_ret_val() {
|
||||||
return Bar();
|
return Bar();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bar* foo_ret_ptr(Bar* bar) {
|
Bar* foo_ret_ptr(Bar* bar) {
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
class Bar {
|
class Bar {
|
||||||
private:
|
private:
|
||||||
int x;
|
int x;
|
||||||
public:
|
public:
|
||||||
Bar() : x(0) {}
|
Bar() : x(0) {}
|
||||||
~Bar() {}
|
~Bar() {}
|
||||||
void set(int x) { this->x = x; }
|
void set(int x) { this->x = x; }
|
||||||
int get() { return x; }
|
int get() { return x; }
|
||||||
};
|
};
|
||||||
|
|
||||||
Bar foo_ret_val();
|
Bar foo_ret_val();
|
||||||
//Bar& foo_ret_ref(Bar* bar);
|
//Bar& foo_ret_ref(Bar* bar);
|
||||||
Bar* foo_ret_ptr(Bar* bar);
|
Bar* foo_ret_ptr(Bar* bar);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
%module example
|
%module example
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "example.h"
|
%include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
11
Examples/c/return/runme.c
Normal file
11
Examples/c/return/runme.c
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,14 +1,20 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
|
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::
|
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
all::
|
||||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c
|
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||||
|
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c
|
||||||
clean:
|
|
||||||
rm -f *.o *.so *.out *.a *.exe *.dll *_wrap* *_proxy* *~
|
run:
|
||||||
|
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
|
||||||
|
TARGET='$(TARGET)' c_compile
|
||||||
|
env LD_LIBRARY_PATH=. ./runme
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.so *.out *.a *.exe *.dll *_wrap* *_proxy* *~
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
/* File : example.c */
|
/* File : example.c */
|
||||||
|
|
||||||
/* A global variable */
|
/* A global variable */
|
||||||
double Foo = 3.0;
|
double Foo = 3.0;
|
||||||
|
|
||||||
double *Foo_ptr = &Foo;
|
double *Foo_ptr = &Foo;
|
||||||
char *my_str = "hello, world!";
|
char *my_str = "hello, world!";
|
||||||
char *array_of_strs[] = { "one", "two" };
|
char *array_of_strs[] = { "one", "two" };
|
||||||
|
|
||||||
char *get_str(int i, void* ptr, float ff) {
|
char *get_str(int i, void* ptr, float ff) {
|
||||||
return array_of_strs[i];
|
return array_of_strs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute the greatest common divisor of positive integers */
|
/* Compute the greatest common divisor of positive integers */
|
||||||
int gcd(int x, int y) {
|
int gcd(int x, int y) {
|
||||||
int g;
|
int g;
|
||||||
g = y;
|
g = y;
|
||||||
while (x > 0) {
|
while (x > 0) {
|
||||||
g = x;
|
g = x;
|
||||||
x = y % x;
|
x = y % x;
|
||||||
y = g;
|
y = g;
|
||||||
}
|
}
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module example
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
extern double Foo;
|
extern double Foo;
|
||||||
extern double *Foo_ptr;
|
extern double *Foo_ptr;
|
||||||
extern char *my_str;
|
extern char *my_str;
|
||||||
extern char **array_of_strs;
|
extern char **array_of_strs;
|
||||||
extern char *get_str(int i, void* ptr, float ff);
|
extern char *get_str(int i, void* ptr, float ff);
|
||||||
extern int gcd(int x, int y);
|
extern int gcd(int x, int y);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
15
Examples/c/simple/runme.c
Normal file
15
Examples/c/simple/runme.c
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
62
Examples/test-suite/c/Makefile.in
Normal file
62
Examples/test-suite/c/Makefile.in
Normal 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
|
||||||
17
Examples/test-suite/c/c_arguments_runme.c
Normal file
17
Examples/test-suite/c/c_arguments_runme.c
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
20
Examples/test-suite/c_arguments.i
Normal file
20
Examples/test-suite/c_arguments.i
Normal 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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
%}
|
||||||
165
Lib/c/c.swg
165
Lib/c/c.swg
|
|
@ -1,80 +1,85 @@
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* See the LICENSE file for information on copyright, usage and redistribution
|
* See the LICENSE file for information on copyright, usage and redistribution
|
||||||
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
|
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
|
||||||
*
|
*
|
||||||
* c.swg
|
* c.swg
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
%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) 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) void*, short*, int*, long*, char*, float*, double* "$1_type"
|
||||||
%typemap(ctype) const short, const int, const long, const char, const float, const double "$1_basetype"
|
%typemap(ctype) unsigned short*, unsigned int*, unsigned long*, unsigned char* "$1_type"
|
||||||
%typemap(ctype) bool "_Bool"
|
%typemap(ctype) short&, int&, long&, char&, float&, double& "$1_basetype *"
|
||||||
%typemap(ctype) SWIGTYPE "$1_type"
|
%typemap(ctype) unsigned short&, unsigned int&, unsigned long&, unsigned char& "$1_basetype *"
|
||||||
%typemap(ctype) SWIGTYPE * "$1_type"
|
%typemap(ctype) const short, const int, const long, const char, const float, const double "$1_basetype"
|
||||||
%typemap(ctype) SWIGTYPE & "$1_type"
|
%typemap(ctype) const unsigned short, const unsigned int, const unsigned long, const unsigned char "$1_basetype"
|
||||||
%typemap(ctype) SWIGTYPE * [ANY] "$1_basetype*"
|
%typemap(ctype) bool "_Bool"
|
||||||
%typemap(ctype) SWIGCLASSTYPE "struct Obj$1_type *"
|
%typemap(ctype) SWIGTYPE "$1_type"
|
||||||
%typemap(ctype) SWIGCLASSTYPE * "struct Obj$1_type"
|
%typemap(ctype) SWIGTYPE * "$1_type"
|
||||||
%typemap(ctype) SWIGCLASSTYPE & "struct Obj$*1_ltype *"
|
%typemap(ctype) SWIGTYPE & "$1_type"
|
||||||
%typemap(ctype) SWIGCLASSTYPE * [ANY] "struct Obj$1_basetype*"
|
%typemap(ctype) SWIGTYPE * [ANY] "$1_basetype*"
|
||||||
|
%typemap(ctype) SWIGCLASSTYPE "struct SwigObj$1_type *"
|
||||||
%typemap(in) short, int, long, char, float, double, bool "$1 = ($1_basetype) $input;"
|
%typemap(ctype) SWIGCLASSTYPE * "struct SwigObj$1_type"
|
||||||
%typemap(in) void*, short*, int*, long*, char*, float*, double*, bool* "$1 = ($1_basetype *) $input;"
|
%typemap(ctype) SWIGCLASSTYPE & "struct SwigObj$*1_ltype *"
|
||||||
%typemap(in) short&, int&, long&, char&, float&, double&, bool& "$1 = ($1_basetype *) $input;"
|
%typemap(ctype) SWIGCLASSTYPE * [ANY] "struct SwigObj$1_basetype *"
|
||||||
%typemap(in) SWIGTYPE "$1 = ($1_type) $input;"
|
|
||||||
%typemap(in) SWIGTYPE * "$1 = ($1_type) $input;"
|
%typemap(in) short, int, long, char, float, double, bool "$1 = ($1_basetype) $input;"
|
||||||
%typemap(in) SWIGTYPE & "$1 = ($1_type) $input;"
|
%typemap(in) void*, short*, int*, long*, char*, float*, double*, bool* "$1 = ($1_basetype *) $input;"
|
||||||
%typemap(in) SWIGTYPE * [ANY] "$1 = ($1_basetype*) $input;"
|
%typemap(in) short&, int&, long&, char&, float&, double&, bool& "$1 = ($1_basetype *) $input;"
|
||||||
%typemap(in) SWIGCLASSTYPE {
|
|
||||||
$1 = * ($1_type *) ($input->obj);
|
%typemap(in) SWIGTYPE "$1 = ($1_type) $input;"
|
||||||
}
|
%typemap(in) SWIGTYPE * "$1 = ($1_type) $input;"
|
||||||
|
%typemap(in) SWIGTYPE & "$1 = ($1_type) $input;"
|
||||||
%typemap(in) SWIGCLASSTYPE * {
|
%typemap(in) SWIGTYPE * [ANY] "$1 = ($1_basetype*) $input;"
|
||||||
$1 = ($1_type) $input->obj;
|
%typemap(in) SWIGCLASSTYPE {
|
||||||
}
|
$1 = * ($1_type *) ($input->obj);
|
||||||
|
}
|
||||||
%typemap(in) SWIGCLASSTYPE * [ANY] {
|
|
||||||
$1 = ($1_basetype*) malloc($1_dim0 * sizeof($1_basetype));
|
%typemap(in) SWIGCLASSTYPE * {
|
||||||
int i;
|
$1 = ($1_type) $input->obj;
|
||||||
for (i = 0; i < $1_dim0; ++i)
|
}
|
||||||
if ($input[i])
|
|
||||||
$1[i] = ($1_basetype) $input[i]->obj;
|
%typemap(in) SWIGCLASSTYPE * [ANY] {
|
||||||
else
|
$1 = ($1_basetype*) malloc($1_dim0 * sizeof($1_basetype));
|
||||||
$1[i] = ($1_basetype) 0;
|
int i;
|
||||||
}
|
for (i = 0; i < $1_dim0; ++i)
|
||||||
|
if ($input[i])
|
||||||
%typemap(in) SWIGCLASSTYPE & {
|
$1[i] = ($1_basetype) $input[i]->obj;
|
||||||
$1 = ($*1_ltype *) $input->obj;
|
else
|
||||||
}
|
$1[i] = ($1_basetype) 0;
|
||||||
|
}
|
||||||
// typemaps for return values
|
|
||||||
|
%typemap(in) SWIGCLASSTYPE & {
|
||||||
%typemap(couttype) void, short, int, long, char, float, double "$1_type"
|
$1 = ($*1_ltype *) $input->obj;
|
||||||
%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) bool "_Bool"
|
// typemaps for return values
|
||||||
%typemap(couttype) SWIGTYPE "struct Obj$1_type"
|
|
||||||
%typemap(couttype) SWIGTYPE * "struct Obj$*1_type *"
|
%typemap(couttype) void, short, int, long, char, float, double "$1_type"
|
||||||
|
%typemap(couttype) void*, short*, int*, long*, char*, float*, double* "$1_type"
|
||||||
%typemap(out) short, int, long, char, float, double, bool "$result = $1;"
|
%typemap(couttype) const short, const int, const long, const char, const float, const double "$1_basetype"
|
||||||
%typemap(out) void*, short*, int*, long*, char*, float*, double*, bool* "$result = $1;"
|
%typemap(couttype) bool "_Bool"
|
||||||
%typemap(out) void ""
|
%typemap(couttype) SWIGTYPE "struct SwigObj$1_type"
|
||||||
|
%typemap(couttype) SWIGTYPE * "struct SwigObj$*1_type *"
|
||||||
%typemap(out) SWIGTYPE {
|
|
||||||
$result.obj = (void*) &$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 ""
|
||||||
%typemap(out) SWIGTYPE * {
|
|
||||||
$result->obj = (void*) $1;
|
%typemap(out) SWIGTYPE {
|
||||||
}
|
$result.obj = (void*) &$1;
|
||||||
|
}
|
||||||
%typemap(out) SWIGTYPE & {
|
|
||||||
// return by reference
|
%typemap(out) SWIGTYPE * {
|
||||||
}
|
$result->obj = (void*) $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
%typemap(out) SWIGTYPE & {
|
||||||
|
// return by reference
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,32 @@
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* clabels.swg
|
* clabels.swg
|
||||||
*
|
*
|
||||||
* Definitions of C specific preprocessor symbols.
|
* Definitions of C specific preprocessor symbols.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
// this is used instead of default SWIGEXPORT symbol
|
// this is used instead of default SWIGEXPORT symbol
|
||||||
|
|
||||||
#ifndef SWIGEXPORTC
|
#ifndef SWIGEXPORTC
|
||||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||||
# define SWIGEXPORTC
|
# define SWIGEXPORTC
|
||||||
# else
|
# else
|
||||||
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
||||||
# define SWIGEXPORTC __attribute__ ((visibility("default")))
|
# define SWIGEXPORTC __attribute__ ((visibility("default")))
|
||||||
# else
|
# else
|
||||||
# define SWIGEXPORTC
|
# define SWIGEXPORTC
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SWIGPROTECT
|
#ifndef SWIGPROTECT
|
||||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||||
# define SWIGPROTECT(x)
|
# define SWIGPROTECT(x)
|
||||||
# else
|
# else
|
||||||
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
||||||
# define SWIGPROTECT(x) __attribute__ ((visibility("protected"))) x
|
# define SWIGPROTECT(x) __attribute__ ((visibility("protected"))) x
|
||||||
# else
|
# else
|
||||||
# define SWIGPROTECT(x)
|
# define SWIGPROTECT(x)
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* cproxy.swg
|
* cproxy.swg
|
||||||
*
|
*
|
||||||
* Definitions of C specific preprocessor symbols for proxies.
|
* Definitions of C specific preprocessor symbols for proxies.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifndef SWIGIMPORT
|
#ifndef SWIGIMPORT
|
||||||
# ifndef __GNUC__
|
# ifndef __GNUC__
|
||||||
# define __DLL_IMPORT __declspec(dllimport)
|
# define __DLL_IMPORT __declspec(dllimport)
|
||||||
# else
|
# else
|
||||||
# define __DLL_IMPORT __attribute__((dllimport)) extern
|
# define __DLL_IMPORT __attribute__((dllimport)) extern
|
||||||
# endif
|
# endif
|
||||||
# if !defined (__WIN32__)
|
# if !defined (__WIN32__)
|
||||||
# define SWIGIMPORT extern
|
# define SWIGIMPORT extern
|
||||||
# else
|
# else
|
||||||
# define SWIGIMPORT __DLL_IMPORT
|
# define SWIGIMPORT __DLL_IMPORT
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
23
Makefile.in
23
Makefile.in
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
@ -209,12 +212,12 @@ public:
|
||||||
* ------------------------------------------------------------------------ */
|
* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
virtual int globalfunctionHandler(Node *n ) {
|
virtual int globalfunctionHandler(Node *n ) {
|
||||||
String* action = NewString("");
|
String *action = NewString("");
|
||||||
String* vis_hint = NewString("");
|
String *vis_hint = NewString("");
|
||||||
String* return_type_str = SwigType_str(Getattr(n, "type"), 0);
|
String *return_type_str = SwigType_str(Getattr(n, "type"), 0);
|
||||||
String* name = Getattr(n, "sym:name");
|
String *name = Getattr(n, "sym:name");
|
||||||
ParmList* parms = Getattr(n, "parms");
|
ParmList *parms = Getattr(n, "parms");
|
||||||
String* arg_list = NewString("");
|
String *arg_list = NewString("");
|
||||||
|
|
||||||
if (SwigType_type(Getattr(n, "type")) != T_VOID) {
|
if (SwigType_type(Getattr(n, "type")) != T_VOID) {
|
||||||
Printv(action, "$cppresult = (", SwigType_str(Getattr(n, "type"), 0), ") ", NIL);
|
Printv(action, "$cppresult = (", SwigType_str(Getattr(n, "type"), 0), ") ", NIL);
|
||||||
|
|
@ -272,8 +275,8 @@ public:
|
||||||
* incomplete for now...
|
* incomplete for now...
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
const char* getTypeSymbol(String* type) {
|
const char *getTypeSymbol(String *type) {
|
||||||
char* c = Char(type);
|
char *c = Char(type);
|
||||||
if (strcmp(c, "int") == 0)
|
if (strcmp(c, "int") == 0)
|
||||||
return "i";
|
return "i";
|
||||||
if (strcmp(c, "double") == 0)
|
if (strcmp(c, "double") == 0)
|
||||||
|
|
@ -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);
|
||||||
|
|
@ -518,25 +521,25 @@ public:
|
||||||
* emit_runtime_typecheck()
|
* emit_runtime_typecheck()
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
void emit_runtime_typecheck(String* classname, String* funcname, String* code) {
|
void emit_runtime_typecheck(String *classname, String *funcname, String *code) {
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
* copy_node()
|
* copy_node()
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
Node* copy_node(Node *node) {
|
Node *copy_node(Node *node) {
|
||||||
Node* new_node = NewHash();
|
Node *new_node = NewHash();
|
||||||
Setattr(new_node, "name", Copy(Getattr(node, "name")));
|
Setattr(new_node, "name", Copy(Getattr(node, "name")));
|
||||||
Setattr(new_node, "ismember", Copy(Getattr(node, "ismember")));
|
Setattr(new_node, "ismember", Copy(Getattr(node, "ismember")));
|
||||||
Setattr(new_node, "view", Copy(Getattr(node, "view")));
|
Setattr(new_node, "view", Copy(Getattr(node, "view")));
|
||||||
|
|
@ -549,13 +552,13 @@ 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
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
bool is_in(String* name, Node* n) {
|
bool is_in(String *name, Node *n) {
|
||||||
Hash* h;
|
Hash *h;
|
||||||
for (h = firstChild(n); h; h = nextSibling(h)) {
|
for (h = firstChild(n); h; h = nextSibling(h)) {
|
||||||
if (Cmp(name, Getattr(h, "name")) == 0)
|
if (Cmp(name, Getattr(h, "name")) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -567,10 +570,10 @@ public:
|
||||||
* classHandler()
|
* classHandler()
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
virtual int classHandler(Node* n) {
|
virtual int classHandler(Node *n) {
|
||||||
String* name = Copy(Getattr(n, "name"));
|
String *name = Copy(Getattr(n, "name"));
|
||||||
String* sobj = NewString("");
|
String *sobj = NewString("");
|
||||||
List* baselist = Getattr(n, "bases");
|
List *baselist = Getattr(n, "bases");
|
||||||
Replaceall(name, "::", "_");
|
Replaceall(name, "::", "_");
|
||||||
|
|
||||||
if (CPlusPlus) {
|
if (CPlusPlus) {
|
||||||
|
|
@ -579,7 +582,7 @@ public:
|
||||||
Iterator i;
|
Iterator i;
|
||||||
for (i = First(baselist); i.item; i = Next(i)) {
|
for (i = First(baselist); i.item; i = Next(i)) {
|
||||||
// look for member variables and functions
|
// look for member variables and functions
|
||||||
Node* node;
|
Node *node;
|
||||||
for (node = firstChild(i.item); node; node = nextSibling(node)) {
|
for (node = firstChild(i.item); node; node = nextSibling(node)) {
|
||||||
if ((Cmp(Getattr(node, "kind"), "variable") == 0)
|
if ((Cmp(Getattr(node, "kind"), "variable") == 0)
|
||||||
|| (Cmp(Getattr(node, "kind"), "function") == 0)) {
|
|| (Cmp(Getattr(node, "kind"), "function") == 0)) {
|
||||||
|
|
@ -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);
|
||||||
|
|
@ -649,14 +652,14 @@ public:
|
||||||
* staticmemberfunctionHandler()
|
* staticmemberfunctionHandler()
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
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("");
|
||||||
String* arg_lnames = NewString("");
|
String *arg_lnames = NewString("");
|
||||||
ParmList* parms = Getattr(n, "parms");
|
ParmList *parms = Getattr(n, "parms");
|
||||||
|
|
||||||
Replaceall(newclassname, "::", "_");
|
Replaceall(newclassname, "::", "_");
|
||||||
|
|
||||||
|
|
@ -687,25 +690,25 @@ public:
|
||||||
* memberfunctionHandler()
|
* memberfunctionHandler()
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
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("");
|
||||||
String* stype = NewString("");
|
String *stype = NewString("");
|
||||||
String* new_name = NewString("");
|
String *new_name = NewString("");
|
||||||
String* code = NewString("");
|
String *code = NewString("");
|
||||||
String* arg_lnames = NewString("");
|
String *arg_lnames = NewString("");
|
||||||
ParmList* parms = Getattr(n, "parms");
|
ParmList *parms = Getattr(n, "parms");
|
||||||
|
|
||||||
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");
|
||||||
stype = Copy(newclassname);
|
stype = Copy(newclassname);
|
||||||
SwigType_add_pointer(stype);
|
SwigType_add_pointer(stype);
|
||||||
Setattr(p, "c:stype", stype);
|
Setattr(p, "c:stype", stype);
|
||||||
|
|
@ -719,7 +722,7 @@ public:
|
||||||
Append(arg_lnames, Swig_cfunction_call(empty_string, parms));
|
Append(arg_lnames, Swig_cfunction_call(empty_string, parms));
|
||||||
|
|
||||||
// omit first argument in method call
|
// omit first argument in method call
|
||||||
String* arg_call_lnames = Strstr(arg_lnames, "*arg2");
|
String *arg_call_lnames = Strstr(arg_lnames, "*arg2");
|
||||||
if (!arg_call_lnames)
|
if (!arg_call_lnames)
|
||||||
arg_call_lnames = Strstr(arg_lnames, "arg2");
|
arg_call_lnames = Strstr(arg_lnames, "arg2");
|
||||||
if (!arg_call_lnames)
|
if (!arg_call_lnames)
|
||||||
|
|
@ -754,15 +757,15 @@ public:
|
||||||
* wrap_get_variable()
|
* wrap_get_variable()
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
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
|
||||||
String* action = NewString("");
|
String *action = NewString("");
|
||||||
ParmList* parms = Getattr(n, "parms");
|
ParmList *parms = Getattr(n, "parms");
|
||||||
if (parms)
|
if (parms)
|
||||||
if (runtime_flag && Getattr(parms, "c:objstruct"))
|
if (runtime_flag && Getattr(parms, "c:objstruct"))
|
||||||
emit_runtime_typecheck(newclassname, new_name, action);
|
emit_runtime_typecheck(newclassname, new_name, action);
|
||||||
|
|
@ -785,15 +788,15 @@ public:
|
||||||
* wrap_set_variable()
|
* wrap_set_variable()
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
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
|
||||||
String* action = NewString("");
|
String *action = NewString("");
|
||||||
ParmList* parms = Getattr(n, "parms");
|
ParmList *parms = Getattr(n, "parms");
|
||||||
if (parms)
|
if (parms)
|
||||||
if (runtime_flag && Getattr(parms, "c:objstruct"))
|
if (runtime_flag && Getattr(parms, "c:objstruct"))
|
||||||
emit_runtime_typecheck(newclassname, new_name, action);
|
emit_runtime_typecheck(newclassname, new_name, action);
|
||||||
|
|
@ -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);
|
||||||
|
|
||||||
|
|
@ -815,13 +819,13 @@ public:
|
||||||
* staticmembervariableHandler()
|
* staticmembervariableHandler()
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
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("");
|
||||||
Replaceall(newclassname, "::", "_");
|
Replaceall(newclassname, "::", "_");
|
||||||
|
|
||||||
// create code for 'get' function
|
// create code for 'get' function
|
||||||
|
|
@ -829,7 +833,7 @@ public:
|
||||||
wrap_get_variable(n, classname, newclassname, name, code);
|
wrap_get_variable(n, classname, newclassname, name, code);
|
||||||
|
|
||||||
// create parameter for 'set' function
|
// create parameter for 'set' function
|
||||||
Parm* p = NewParm(Getattr(n, "type"), "value");
|
Parm *p = NewParm(Getattr(n, "type"), "value");
|
||||||
Setattr(p, "lname", "arg1");
|
Setattr(p, "lname", "arg1");
|
||||||
Setattr(n, "parms", p);
|
Setattr(n, "parms", p);
|
||||||
|
|
||||||
|
|
@ -851,22 +855,22 @@ public:
|
||||||
* membervariableHandler()
|
* membervariableHandler()
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
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("");
|
||||||
String* stype;
|
String *stype;
|
||||||
String* new_name = NewString("");
|
String *new_name = NewString("");
|
||||||
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");
|
||||||
stype = Copy(newclassname);
|
stype = Copy(newclassname);
|
||||||
SwigType_add_pointer(stype);
|
SwigType_add_pointer(stype);
|
||||||
Setattr(p, "c:stype", stype);
|
Setattr(p, "c:stype", stype);
|
||||||
|
|
@ -874,7 +878,7 @@ public:
|
||||||
Setattr(p, "lname", "arg1");
|
Setattr(p, "lname", "arg1");
|
||||||
|
|
||||||
// create second argument
|
// create second argument
|
||||||
Parm* t = NewParm(Getattr(n, "type"), "value");
|
Parm *t = NewParm(Getattr(n, "type"), "value");
|
||||||
Setattr(t, "lname", "arg2");
|
Setattr(t, "lname", "arg2");
|
||||||
|
|
||||||
// create 'get' function
|
// create 'get' function
|
||||||
|
|
@ -902,38 +906,38 @@ public:
|
||||||
* emit_runtime_make_object()
|
* emit_runtime_make_object()
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
* constructorHandler()
|
* constructorHandler()
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
virtual int constructorHandler(Node* n) {
|
virtual int constructorHandler(Node *n) {
|
||||||
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;
|
||||||
String* stype;
|
String *stype;
|
||||||
String* code = NewString("");
|
String *code = NewString("");
|
||||||
String* constr_name = NewString("");
|
String *constr_name = NewString("");
|
||||||
String* arg_lnames = NewString("");
|
String *arg_lnames = NewString("");
|
||||||
ParmList* parms = Getattr(n, "parms");
|
ParmList *parms = Getattr(n, "parms");
|
||||||
|
|
||||||
Replaceall(newclassname, "::", "_");
|
Replaceall(newclassname, "::", "_");
|
||||||
|
|
||||||
|
|
@ -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,20 +984,20 @@ 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;
|
||||||
String* stype;
|
String *stype;
|
||||||
String* code = NewString("");
|
String *code = NewString("");
|
||||||
String* constr_name = NewString("");
|
String *constr_name = NewString("");
|
||||||
ParmList* parms = Getattr(n, "parms");
|
ParmList *parms = Getattr(n, "parms");
|
||||||
|
|
||||||
Replaceall(newclassname, "::", "_");
|
Replaceall(newclassname, "::", "_");
|
||||||
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);
|
||||||
|
|
@ -1030,21 +1034,21 @@ public:
|
||||||
* destructorHandler()
|
* destructorHandler()
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
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;
|
||||||
String* stype;
|
String *stype;
|
||||||
String* code = NewString("");
|
String *code = NewString("");
|
||||||
String* destr_name = NewString("");
|
String *destr_name = NewString("");
|
||||||
Parm* p;
|
Parm *p;
|
||||||
|
|
||||||
Replaceall(newclassname, "::", "_");
|
Replaceall(newclassname, "::", "_");
|
||||||
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");
|
||||||
|
|
|
||||||
|
|
@ -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])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue