Many major improvements. Almost all testsuite compiles now.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@11189 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Maciej Drwal 2009-04-15 23:30:16 +00:00
commit 32e03aa13d
25 changed files with 1052 additions and 609 deletions

View file

@ -0,0 +1,17 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SWIGOPT = -I../Include
SRCS =
TARGET = gifplot
INTERFACE = gifplot.i
LIBS = -L.. -lgifplot
INCLUDES = -I../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' LIBS='$(LIBS)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c
clean:
rm -f *.o *.out *.so *.a *.dll *.dylib *.exe *_wrap* *_proxy* *~ runme
check: all

View file

@ -0,0 +1,15 @@
/* Oh what the heck, let's just grab the whole darn header file
and see what happens. */
%module gifplot
%{
/* Note: You still need this part because the %include directive
merely causes SWIG to interpret the contents of a file. It doesn't
include the right include headers for the resulting C code */
#include "../Include/gifplot.h"
%}
%include gifplot.h

View file

@ -1,4 +1,5 @@
# see top-level Makefile.in
class
simple
class
std_vector
exception

View file

@ -0,0 +1,30 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
RUNME = runme.c
PROXY = example_proxy.c
INCLUDES =
MEMTOOL = valgrind --leak-check=full
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INCLUDES='$(INCLUDES)' c_cpp
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
TARGET='$(TARGET)' c_compile
run:
env LD_LIBRARY_PATH=. ./runme
memchk:
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXXFLAGS='-g' INCLUDES='$(INCLUDES)' c_cpp
$(MAKE) -f $(TOP)/Makefile RUNME='$(RUNME)' PROXY='$(PROXY)' \
TARGET='$(TARGET)' CFLAGS='-g' c_compile
env LD_LIBRARY_PATH=. $(MEMTOOL) ./runme
clean:
rm -f *.o *.out *.so *.a *.dll *.dylib *.exe *_wrap* *_proxy* *~ runme
check: all

View file

@ -0,0 +1,2 @@
/* File : example.c */

View file

@ -0,0 +1,18 @@
/* File : example.h */
#include <string>
#include <vector>
class A {
public:
A() : name(""), value(0) {}
A(std::string str, int i) : name(str), value(i) {}
std::string name;
int value;
};
class Klass {
public:
std::vector<int> vi;
std::vector<A> va;
};

View file

@ -0,0 +1,14 @@
/* File : example.i */
%module example
%include <std_string.i>
%include <std_vector.i>
%{
#include "example.h"
%}
/* Let's just grab the original header file here */
%include "example.h"
%template(Vint) std::vector<int>;
%template(VA) std::vector<A>;

View file

@ -0,0 +1,37 @@
#include "example_proxy.h"
int main() {
Klass *klass = new_Klass();
Vint *vint = Klass_vi_get(klass);
VA *va = Klass_va_get(klass);
printf("Vector of ints:\n");
printf("size=%d\ncapacity=%d\n\n", Vint_size(vint), Vint_capacity(vint));
int i;
for (i = 0; i < 10; i++)
Vint_push_back(vint, i*i);
printf("size=%d\ncapacity=%d\n\n", Vint_size(vint), Vint_capacity(vint));
for (i = 0; i < Vint_size(vint); i++)
printf("%d%c", Vint_at(vint, i), i+1 == Vint_size(vint) ? '\n' : ',');
Vint_clear(vint);
Vint_reserve(vint, 100);
printf("\nsize=%d\ncapacity=%d\n", Vint_size(vint), Vint_capacity(vint));
printf("\nVector of objects:\n");
for (i = 0; i < 10; i++) {
A *a = new_A_std_string_i("hello", i);
VA_push_back(va, a);
}
for (i = 0; i < VA_size(va); i++) {
A *a = VA_at(va, i);
printf("%s %d\n", A_name_get(a), A_value_get(a));
}
SWIG_exit(0);
}

View file

@ -10,23 +10,29 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@/..
top_builddir = @top_builddir@/..
C_TEST_CASES =
CPP_TEST_CASES = cast_operator \
char_strings \
exception_order \
exception_partial_info \
enums \
enum_plus
include $(srcdir)/../common.mk
#
# BROKEN TEST CASES:
# default_constructor - last case: when using %extend generates 2 ctors wrappers,
# default_constructor - last case fail: using %extend generates 2 ctors wrappers,
# both using new, while the class constructor is private
# extend* - directive %extend is not fully supported yet
# li* - not supported at all yet
# long_long_apply - no INPUT, OUTPUT, INOUT typemaps defined
# template* - not fully supported yet
#
CPP_TEST_BROKEN_CXX = default_constructor
include $(srcdir)/../common.mk
C_CPP_TEST_BROKEN = \
default_constructor \
extend \
extend_default \
extend_placement \
li_attribute \
li_boost_shared_ptr \
li_carrays \
li_cdata \
li_windows \
long_long_apply
INTERFACEDIR = ../../

View file

@ -1,12 +1,12 @@
#include <stdio.h>
#include "cast_operator/cast_operator_proxy.h"
int main() {
A *a = new_A();
if (strcmp(A_tochar(a), "hi"))
fprintf(stderr, "cast failed\n");
delete_A(a);
SWIG_exit(0);
}
#include <stdio.h>
#include "cast_operator/cast_operator_proxy.h"
int main() {
A *a = new_A();
if (strcmp(A_tochar(a), "hi"))
fprintf(stderr, "cast failed\n");
delete_A(a);
SWIG_exit(0);
}

View file

@ -73,6 +73,7 @@ INTERFACEDIR = ../
# Broken C++ test cases. (Can be run individually using make testcase.cpptest.)
CPP_TEST_BROKEN += \
abstract_access \
constants \
cpp_broken \
exception_partial_info \

View file

@ -15,6 +15,11 @@ see bottom for a set of possible tests
SWIGWARN_IGNORE_OPERATOR_LOR);
#endif
#if defined(SWIGC)
%warnfilter(SWIGWARN_IGNORE_OPERATOR_EQ,
SWIGWARN_IGNORE_OPERATOR_PLUSPLUS);
#endif
#if !defined(SWIGLUA) && !defined(SWIGR)
%rename(Equal) operator =;
%rename(PlusEqual) operator +=;

View file

@ -27,6 +27,19 @@ std::string ExceptionVars(double i, double j) {
%}
%rename(ExceptionVars) Space::exceptionvars;
#ifdef SWIGC
%exception Space::exceptionvars %{
$action
result = (char*)$symname(1.0,2.0).c_str(); // Should expand to ExceptionVars
result = (char*)$name(3.0,4.0).c_str(); // Should expand to Space::exceptionvars
// above will not compile if the variables are not expanded properly
result = "$action $name $symname $overname $wrapname";
%}
#else
%exception Space::exceptionvars %{
$action
result = $symname(1.0,2.0); // Should expand to ExceptionVars
@ -34,6 +47,9 @@ std::string ExceptionVars(double i, double j) {
// above will not compile if the variables are not expanded properly
result = "$action $name $symname $overname $wrapname";
%}
#endif
%inline %{
namespace Space {
std::string exceptionvars(double i, double j) {
@ -43,6 +59,20 @@ std::string exceptionvars(double i, double j) {
%}
#ifdef SWIGC
%exception Space::overloadedmethod %{
$action
result = (char*)Space::$symname(1.0).c_str();
result = (char*)$name().c_str();
result = (char*)$name(2.0).c_str();
// above will not compile if the variables are not expanded properly
result = "$action $name $symname $overname $wrapname";
// $decl
%}
#else
%exception Space::overloadedmethod %{
$action
result = Space::$symname(1.0);
@ -53,6 +83,8 @@ std::string exceptionvars(double i, double j) {
// $decl
%}
#endif
%inline %{
namespace Space {
std::string overloadedmethod(double j) {