merge frome trunk

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11524 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Baozeng Ding 2009-08-10 01:40:09 +00:00
commit b0e85706b6
60 changed files with 510 additions and 734 deletions

View file

@ -1,6 +1,41 @@
Version 1.3.40 (in progress)
============================
2009-08-08: wsfulton
[Python] More user friendly AttributeError is raised when there are
no constructors generated for the proxy class in the event that the
class is abstract - the error message is now
"No constructor defined - class is abstract" whereas if there are no
public constructors for any other reason and the class is not abstract,
the message remains
"No constructor defined".
[tcl] Similarly for tcl when using -itcl.
2009-08-04: olly
[PHP] Fix generated code to work with PHP 5.3.
2009-08-04: vmiklos
[PHP] Various mathematical functions (which would conflict
with the built-in PHP ones) are now automatically handled by
adding a 'c_' prefix.
2009-08-03: wsfulton
[C#] The std::vector<T> implementation is improved and now uses $typemap such
that the proxy class for T no longer has to be specified in some macros
for correct C# compilation; the following macros are deprecated, where
CSTYPE was the C# type for the C++ class CTYPE:
SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE)
usage should be removed altogether
SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE)
should be replaced with:
SWIG_STD_VECTOR_ENHANCED(CTYPE)
Some more details in csharp/std_vector.i
*** POTENTIAL INCOMPATIBILITY ***
2009-07-31: olly
[Python] Fix indentation so that we give a useful error if the
module can't be loaded. Patch from Gaetan Lehmann in SF#2829853.

View file

@ -447,6 +447,19 @@ $
<p>
This error usually indicates that you forgot to include some object files or libraries in the linking of the native library file.
Make sure you compile both the SWIG wrapper file and the code you are wrapping into the native library file.
If you forget to compile and link in the SWIG wrapper file into your native library file, you will get a message similar to the following:
</p>
<div class="code"><pre>
$ java runme
Exception in thread "main" java.lang.UnsatisfiedLinkError: exampleJNI.gcd(II)I
at exampleJNI.gcd(Native Method)
at example.gcd(example.java:12)
at runme.main(runme.java:18)
</pre></div>
<p>
where <tt>gcd</tt> is the missing JNI function that SWIG generated into the wrapper file.
Also make sure you pass all of the required libraries to the linker.
The <tt>java -verbose:jni</tt> commandline switch is also a great way to get more information on unresolved symbols.
One last piece of advice is to beware of the common faux pas of having more than one native library version in your path.

View file

@ -318,7 +318,7 @@ python_clean:
rm -f *_wrap* *~ .~* mypython@EXEEXT@ *.pyc
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@ *@PYTHON_SO@
if [ -f runme.py ]; then (rm -f runme3.py runme3.py.bak;) fi;
if [ -f runme.py ]; then rm -f runme3.py runme3.py.bak; fi
##################################################################

View file

@ -1,16 +0,0 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS = example.i
TARGET = example
INTERFACE = example.i
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
scilab -nwni < runme.sci
clean::
$(MAKE) -f $(TOP)/Makefile scilab_clean
rm -f *.sce *.so lib*lib.c *_wrap.c
check: all

View file

@ -1,16 +0,0 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS = example.c
TARGET = example
INTERFACE = example.i
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
scilab -nwni < runme.sci
clean::
$(MAKE) -f $(TOP)/Makefile scilab_clean
rm -f *.sce *.so lib*lib.c *_wrap.c
check: all

View file

@ -1,16 +0,0 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS = example.c
TARGET = example
INTERFACE = example.i
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
scilab -nwni < runme.sci
clean::
$(MAKE) -f $(TOP)/Makefile scilab_clean
rm -f *.sce *.so lib*lib.c *_wrap.c
check: all

View file

@ -1,16 +0,0 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS = example.c
TARGET = example
INTERFACE = example.i
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
scilab -nwni < runme.sci
clean::
$(MAKE) -f $(TOP)/Makefile scilab_clean
rm -f *.sce *.so lib*lib.c *_wrap.c
check: all

View file

@ -1,16 +0,0 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS = example.c
TARGET = example
INTERFACE = example.i
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
scilab -nwni < runme.sci
clean::
$(MAKE) -f $(TOP)/Makefile scilab_clean
rm -f *.sce *.so lib*lib.c *_wrap.c
check: all

View file

@ -1,16 +0,0 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS = example.c
TARGET = example
INTERFACE = example.i
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
scilab -nwni < runme.sci
clean::
$(MAKE) -f $(TOP)/Makefile scilab_clean
rm -f *.sce *.so lib*lib.c *_wrap.c
check: all

View file

@ -114,9 +114,9 @@ include $(srcdir)/../common.mk
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.lisp appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
%.clean:
@rm -f $*.cl

View file

@ -38,9 +38,9 @@ CPP_TEST_CASES =
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.lisp appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean: (does nothing, we dont generate extra cffi code)
%.clean:

View file

@ -43,25 +43,25 @@ SWIGOPT += -nounit
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then ( \
$(MAKE) $*.cppproxy; ) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
$(MAKE) $*.cppproxy; \
fi
%.ctest:
$(setup)
+$(swig_and_compile_c)
$(run_testcase)
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then ( \
$(MAKE) $*.cproxy; ) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
$(MAKE) $*.cproxy; \
fi
%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then ( \
$(MAKE) $*.multiproxy; ) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
$(MAKE) $*.multiproxy; \
fi
%.externaltest:
$(setup)
@ -86,9 +86,9 @@ SWIGOPT += -nounit
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.scm appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean
%.clean:

View file

@ -38,9 +38,9 @@ CPP_TEST_CASES =
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.lisp appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISPBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISPBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean: (does nothing, we dont generate extra clisp code)
%.clean:

View file

@ -405,6 +405,7 @@ CPP_TEST_CASES += \
CPP_STD_TEST_CASES += \
director_string \
ignore_template_constructor \
li_std_combinations \
li_std_deque \
li_std_except \
li_std_pair \

View file

@ -121,7 +121,8 @@ int* const globalRet2() {return &GlobalInt;}
%{
static int wxEVT_COMMAND_BUTTON_CLICKEDv;
static int **wxEVT_COMMAND_BUTTON_CLICKEDp;
static int *wxEVT_COMMAND_BUTTON_CLICKEDp;
static int **wxEVT_COMMAND_BUTTON_CLICKEDpp = &wxEVT_COMMAND_BUTTON_CLICKEDp;
#if defined(SWIGR)
#undef lang1 /* conflicts with symbol in R internals */
#endif
@ -137,7 +138,7 @@ char *langs[] ={ lang1 };
#define EWXWEXPORT_VAR
const int* wxEVENT_COMMAND_BUTTON_CLICKEDr = (int*) &wxEVT_COMMAND_BUTTON_CLICKEDv;
const int* wxEVENT_COMMAND_BUTTON_CLICKEDp = (int*) *wxEVT_COMMAND_BUTTON_CLICKEDp;
const int* wxEVENT_COMMAND_BUTTON_CLICKEDp = (int*) *wxEVT_COMMAND_BUTTON_CLICKEDpp;
char **languages1 = &langs[0];
char **languages2 = (char **)&langs[0];
}

View file

@ -73,10 +73,6 @@ public:
%include "std_vector.i"
#if defined(SWIGCSHARP)
SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(Flow, Space::Flow)
#endif
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#define SWIG_GOOD_VECTOR
%ignore std::vector<Space::Flow>::vector(size_type);

View file

@ -59,31 +59,31 @@ setup = \
echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
fi; \
if [ ! -d $* ]; then \
mkdir $*; \
fi;
mkdir $*; \
fi
# Compiles C# files then runs the testcase. A testcase is only run if
# a file is found which has _runme.cs appended after the testcase name.
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` \
$*$(CSHARPPATHSEPARATOR)*.cs' csharp_compile && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; ) \
else ( \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
else \
cd $* && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
CSHARPSRCS='*.cs' csharp_compile; ); \
fi;
CSHARPSRCS='*.cs' csharp_compile && cd .. ; \
fi
# Clean: remove testcase directories
%.clean:
@if [ -d $* ]; then \
rm -rf $*; \
fi;
rm -rf $*; \
fi
clean:
@rm -f *.exe *.exe.mdb

View file

@ -169,7 +169,7 @@ public class li_std_map_runme {
if (keyStringified != " 1 2 3 4 5")
throw new Exception("Wrapped method stringifyKeys test failed. Got " + keyStringified);
// Test a map with a new specialized type (Struct)
// Test a map with a new complex type (Struct)
{
IntStructMap ismap = new IntStructMap();
for (int i = 0; i < 10; i++)
@ -178,12 +178,12 @@ public class li_std_map_runme {
}
if (ismap.Count != 10)
throw new Exception("Count test on specialized map failed");
throw new Exception("Count test on complex type map failed");
foreach (KeyValuePair<int, Struct> p in ismap)
{
if ((p.Key * 10.1) != p.Value.num)
throw new Exception("Iteration test on specialized map failed for index " + p.Key);
throw new Exception("Iteration test on complex type map failed for index " + p.Key);
}
}
@ -196,12 +196,12 @@ public class li_std_map_runme {
}
if (ispmap.Count != 10)
throw new Exception("Count test on specialized pointer map failed");
throw new Exception("Count test on complex type pointer map failed");
foreach (KeyValuePair<int, Struct> p in ispmap)
{
if ((p.Key * 10.1) != p.Value.num)
throw new Exception("Iteration test on specialized pointer map failed for index " + p.Key);
throw new Exception("Iteration test on complex type pointer map failed for index " + p.Key);
}
}
{
@ -212,29 +212,29 @@ public class li_std_map_runme {
}
if (iscpmap.Count != 10)
throw new Exception("Count test on specialized const pointer map failed");
throw new Exception("Count test on complex type const pointer map failed");
foreach (KeyValuePair<int, Struct> p in iscpmap)
{
if ((p.Key * 10.1) != p.Value.num)
throw new Exception("Iteration test on specialized const pointer map failed for index " + p.Key);
throw new Exception("Iteration test on complex type const pointer map failed for index " + p.Key);
}
}
// Test non-specialized map
// Test complex type as key (Struct)
{
StructIntMap limap = new StructIntMap();
Struct s7 = new Struct(7);
Struct s8 = new Struct(8);
limap.setitem(s7 , 8);
if (limap.getitem(s7) != 8)
throw new Exception("Assignment test on non-specialized map failed");
limap[s7] = 8;
if (limap[s7] != 8)
throw new Exception("Assignment test on complex key map failed");
if (!limap.ContainsKey(s7))
throw new Exception("Key test (1) on non-specialized map failed");
throw new Exception("Key test (1) on complex key map failed");
if (limap.ContainsKey(s8))
throw new Exception("Key test (2) on non-specialized map failed");
throw new Exception("Key test (2) on complex key map failed");
}
// All done

View file

@ -14,6 +14,8 @@ public class runme {
throw new Exception("test failed");
if (special_variable_macros.testJim(name) != "multiname num")
throw new Exception("test failed");
if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123)
throw new Exception("test failed");
NewName newName = NewName.factory("factoryname");
name = newName.getStoredName();
}

View file

@ -44,9 +44,9 @@ include $(srcdir)/../common.mk
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.scm appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean
%.clean:

View file

@ -19,16 +19,16 @@ GUILE_RUNTIME=
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.scm appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
setup = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \
else \
echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \
fi;
fi
%.externaltest:
$(local_setup)
@ -41,9 +41,9 @@ local_setup = \
echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \
else \
echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \
fi;
fi
local_run_testcase = \
if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$*$(SCRIPTSUFFIX); \
fi

View file

@ -67,24 +67,24 @@ setup = \
echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
fi; \
if [ ! -d $* ]; then \
mkdir $*; \
fi;
mkdir $*; \
fi
# Compiles java files then runs the testcase. A testcase is only run if
# a file is found which has _runme.java appended after the testcase name.
# Note Java uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows, SHLIB_PATH on HPUX and DYLD_LIBRARY_PATH on Mac OS X.
run_testcase = \
(cd $* && $(COMPILETOOL) $(JAVAC) -classpath . *.java) && \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme;) \
fi;
cd $* && $(COMPILETOOL) $(JAVAC) -classpath . *.java && cd .. && \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme; \
fi
# Clean: remove testcase directories
%.clean:
@if [ -d $* ]; then \
rm -rf $*; \
fi;
rm -rf $*; \
fi
clean:
@rm -f *.class hs_err*.log

View file

@ -24,6 +24,8 @@ public class special_variable_macros_runme {
throw new RuntimeException("test failed");
if (!special_variable_macros.testJim(name).equals("multiname num"))
throw new RuntimeException("test failed");
if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123)
throw new RuntimeException("test failed");
NewName newName = NewName.factory("factoryname");
name = newName.getStoredName();
}

View file

@ -0,0 +1,15 @@
%module li_std_combinations
%include <std_vector.i>
%include <std_string.i>
%include <std_pair.i>
%template(VectorInt) std::vector<int>;
%template(VectorString) std::vector<std::string>;
%template(PairIntString) std::pair<int, std::string>;
%template(VectorPairIntString) std::vector< std::pair<int, std::string> >;
%template(PairIntVectorString) std::pair< int, std::vector<std::string> >;
%template(VectorVectorString) std::vector< std::vector<std::string> >;
%template(PairIntPairIntString) std::pair< int, std::pair<int, std::string> >;

View file

@ -46,18 +46,6 @@ struct Struct {
%}
#if defined(SWIGCSHARP)
// Specialize some more non-default map types
SWIG_STD_MAP_SPECIALIZED(int, int *, int, SWIGTYPE_p_int)
SWIG_STD_MAP_SPECIALIZED(int, const int *, int, SWIGTYPE_p_int)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, Struct)
SWIG_STD_MAP_SPECIALIZED(int, Struct *, int, Struct)
SWIG_STD_MAP_SPECIALIZED(int, const Struct *, int, Struct)
SWIG_STD_MAP_SPECIALIZED(Struct *, int, Struct, int)
#endif
//#if !defined(SWIGR)
// Test out some maps with pointer types

View file

@ -75,12 +75,7 @@ const std::vector<const Struct *> & vecstructconstptr(const std::vector<const St
%}
#if defined(SWIGCSHARP)
SWIG_STD_VECTOR_SPECIALIZE(Struct, Struct *)
SWIG_STD_VECTOR_SPECIALIZE(Struct, const Struct *)
SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, int *)
SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, const int *)
// Also test non-specialized versions
// Also test const and non-const pointers, but not strictly necessary since std::vector was enhanced in swig-1.3.40
%template(StructurePtrVector) std::vector<Structure *>;
%template(StructureConstPtrVector) std::vector<const Structure *>;
#endif
@ -93,10 +88,6 @@ SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, const int *)
%template(StructPtrVector) std::vector<Struct *>;
%template(StructConstPtrVector) std::vector<const Struct *>;
#if defined(SWIGCSHARP)
SWIG_STD_VECTOR_SPECIALIZE(MyClass, MyClass *)
#endif
#if !defined(SWIGTCL)
%inline {
struct MyClass {};

View file

@ -46,9 +46,9 @@ LIBS = -L.
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.lua appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean: (does nothing, we dont generate extra lua code)
%.clean:

View file

@ -36,9 +36,9 @@ include $(srcdir)/../common.mk
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.scm appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(MZSCHEME) -r $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(MZSCHEME) -r $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean
%.clean:

View file

@ -14,13 +14,13 @@ C_TEST_CASES =
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \
-f $(top_srcdir)/Examples/test-suite/$*.list ] ; then ( \
-f $(top_srcdir)/Examples/test-suite/$*.list ] ; then \
$(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
$(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./runme) ; \
elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./runme; \
elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
$(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \
$(RUNTOOL) ./runme) ; \
$(RUNTOOL) ./runme; \
fi ;
check_quant:

View file

@ -56,9 +56,9 @@ LIBS = -L.
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.m appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVEPATH=$(srcdir):OCTAVEPATH $(RUNTOOL) $(OCTAVE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVEPATH=$(srcdir):OCTAVEPATH $(RUNTOOL) $(OCTAVE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean: remove the generated .m file
%.clean:

View file

@ -2,7 +2,7 @@ wrapmacro
a = 2;
b = -1;
wrapmacro.max(a,b);
wrapmacro.max(a/7.0, -b*256);
wrapmacro.maximum(a,b);
wrapmacro.maximum(a/7.0, -b*256);
wrapmacro.GUINT16_SWAP_LE_BE_CONSTANT(1);

View file

@ -49,10 +49,9 @@ include $(srcdir)/../common.mk
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.pl appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PERL) $(TEST_RUNNER) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ; ) \
fi; \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PERL) $(TEST_RUNNER) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean: remove the generated .pm file
%.clean:

View file

@ -9,6 +9,6 @@ require_ok('wrapmacro');
my $a = 2;
my $b = -1;
is(wrapmacro::max($a,$b), 2);
is(wrapmacro::max($a/7.0, -$b*256), 256);
is(wrapmacro::maximum($a,$b), 2);
is(wrapmacro::maximum($a/7.0, -$b*256), 256);
is(wrapmacro::GUINT16_SWAP_LE_BE_CONSTANT(1), 256);

View file

@ -44,12 +44,14 @@ missingtests: missingcpptests missingctests
+$(swig_and_compile_multi_cpp)
+$(run_testcase)
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.php appended after the testcase name.
# Runs the testcase. Tries to run testcase_runme.php, and if that's not
# found, runs testcase.php, except for multicpptests.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php_run;) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php_run; \
elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*.php RUNTOOL=$(RUNTOOL) php_run; \
fi
# Clean: remove the generated .php file
%.clean:

View file

@ -0,0 +1,20 @@
<?php
require "tests.php";
require "import_nomodule.php";
// No new functions
check::functions(array(create_foo,delete_foo,test1));
// No new classes
check::classes(array(import_nomodule,Bar));
// now new vars
check::globals(array());
$f = import_nomodule::create_Foo();
import_nomodule::test1($f,42);
import_nomodule::delete_Foo($f);
$b = new Bar();
import_nomodule::test1($b,37);
check::done();
?>

View file

@ -0,0 +1,19 @@
<?php
require "tests.php";
require "overload_rename.php";
// No new functions
check::functions(array());
// No new classes
check::classes(array(Foo));
// now new vars
check::globals(array());
$f = new Foo(1.0);
$f = new Foo(1.0,1.0);
$f = Foo::Foo_int(1.0,1);
$f = Foo::Foo_int(1.0,1,1.0);
check::done();
?>

View file

@ -70,6 +70,8 @@ class check {
}
function classname($string,$object) {
if (!is_object($object))
return check::fail("The second argument is a " . gettype($object) . ", not an object.");
if (strtolower($string)!=strtolower($classname=get_class($object))) return check::fail("Object: \$object is of class %s not class %s",$classname,$string);
return TRUE;
}

View file

@ -36,9 +36,9 @@ include $(srcdir)/../common.mk
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.pike appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PIKE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PIKE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean: remove the generated .pike file
%.clean:

View file

@ -125,17 +125,16 @@ py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
ifeq (,$(PY3))
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(run_python);)\
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(run_python);\
fi
else
run_testcase = \
if [ -f $(py2_runme) ]; then ( \
$(MAKE) -f $(srcdir)/Makefile $(py3_runme) && \
$(run_python);) \
elif [ -f $(py3_runme) ]; then ( \
$(run_python);) \
fi;
if [ -f $(py2_runme) ]; then \
$(MAKE) -f $(srcdir)/Makefile $(py3_runme) && $(run_python); \
elif [ -f $(py3_runme) ]; then \
$(run_python); \
fi
endif
# Clean: remove the generated .py file
@ -143,7 +142,7 @@ endif
@rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
@rm -f $*.py;
@#We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
@if [ -f $(py2_runme) ]; then (rm -f $(py3_runme) $(py3_runme).bak;) fi;
@if [ -f $(py2_runme) ]; then rm -f $(py3_runme) $(py3_runme).bak; fi
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean

View file

@ -11,4 +11,6 @@ if special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap":
raise "test failed"
if special_variable_macros.testJim(name) != "multiname num":
raise "test failed"
if special_variable_macros.testJohn(special_variable_macros.PairIntBool(10, False)) != 123:
raise "test failed"

View file

@ -1,4 +1,3 @@
import string
from template_typedef_cplx2 import *
from template_typedef_import import *

View file

@ -2,6 +2,6 @@ import wrapmacro
a = 2
b = -1
wrapmacro.max(a,b)
wrapmacro.max(a/7.0, -b*256)
wrapmacro.maximum(a,b)
wrapmacro.maximum(a/7.0, -b*256)
wrapmacro.GUINT16_SWAP_LE_BE_CONSTANT(1)

View file

@ -42,20 +42,19 @@ include $(srcdir)/../common.mk
# Run the runme if it exists. If not just load the R wrapper to
# check for syntactic correctness
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \
$(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ;) \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
else \
($(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(WRAPSUFFIX);) \
fi;
$(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(WRAPSUFFIX); \
fi
run_multitestcase = \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ]; then ( \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \
$(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ;) \
$(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX); \
else \
($(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX);) \
$(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX); \
fi; \
done
# Clean
@ -64,10 +63,10 @@ clean:
%.clean:
@rm -f $*.R $*_wrap.so $*_wrap.cpp $*_wrap.c $*_wrap.o $*_runme.Rout $*.Rout
@if [ -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then ( \
@if [ -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
rm -f $${f}.R $${f}.Rout ; \
done ) \
done \
fi

View file

@ -60,9 +60,9 @@ ruby_naming.cpptest: SWIGOPT += -autorename
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.rb appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean
%.clean:

View file

@ -110,6 +110,40 @@ const char * testJim(Name *jim, int count) {
}
%}
//////////////////////////////////////////////////////////////////////////////////////
// Template types with more than one template parameter
// check $1 and $input get expanded properly when used from $typemap()
%typemap(in) Space::Pair<int, bool> PAIR_INT_BOOL ($1_type temp)
%{
/*%typemap(in) Name *GENERIC start */
temp = Space::Pair<int, bool>(123, true);
(void)$input;
$1 = ($1_ltype)temp;
/*%typemap(in) Name *GENERIC end */
%}
%typemap(in) Space::Pair<int, bool> john {
// %typemap(in) Name *john start
$typemap(in, Space::Pair<int, bool> PAIR_INT_BOOL)
// %typemap(in) Name *john end
}
%inline %{
namespace Space {
template <typename T1, typename T2> struct Pair {
Pair(T1 f, T2 s) : first(f), second(s) {}
Pair() {}
T1 first;
T2 second;
};
int testJohn(Space::Pair<int, bool> john) {
return john.first;
}
}
%}
%template(PairIntBool) Space::Pair<int, bool>;
//////////////////////////////////////////////////////////////////////////////////////
// A real use case for $typemap

View file

@ -45,9 +45,9 @@ include $(srcdir)/../common.mk
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.tcl appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(TCLSH) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(TCLSH) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean
%.clean:

View file

@ -23,10 +23,10 @@
using namespace std;
struct XX {
XX() { cout << "XX()" << endl; }
XX() { if (debug) cout << "XX()" << endl; }
XX(int i) { if (debug) cout << "XX(" << i << ")" << endl; }
XX(const XX &other) { cout << "XX(const XX &)" << endl; }
XX& operator =(const XX &other) { cout << "operator=(const XX &)" << endl; return *this; }
XX(const XX &other) { if (debug) cout << "XX(const XX &)" << endl; }
XX& operator =(const XX &other) { if (debug) cout << "operator=(const XX &)" << endl; return *this; }
~XX() { if (debug) cout << "~XX()" << endl; }
static XX create() {
return XX(123);

View file

@ -38,9 +38,9 @@ CPP_TEST_CASES =
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.lisp appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(UFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(UFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean: (does nothing, we dont generate extra uffi code)
%.clean:

View file

@ -21,7 +21,8 @@ typedef unsigned short guint16;
(guint16) ((guint16) (val) >> 8) | \
(guint16) ((guint16) (val) << 8)))
#define max(a,b) ((a) > (b) ? (a) : (b))
/* Don't use max(), it's a builtin function for PHP. */
#define maximum(a,b) ((a) > (b) ? (a) : (b))
%}
@ -41,8 +42,8 @@ type SWIGMACRO_##name(lparams) {
/* Here, wrapping the macros */
%wrapmacro(guint16, GUINT16_SWAP_LE_BE_CONSTANT, guint16 val, val);
%wrapmacro(size_t, max, PLIST(size_t a, const size_t& b), PLIST(a, b));
%wrapmacro(double, max, PLIST(double a, double b), PLIST(a, b));
%wrapmacro(size_t, maximum, PLIST(size_t a, const size_t& b), PLIST(a, b));
%wrapmacro(double, maximum, PLIST(double a, double b), PLIST(a, b));
/* Maybe in the future, a swig directive will make this easier:

View file

@ -4,25 +4,14 @@
*
* std_map.i
*
* SWIG typemaps for std::map
* SWIG typemaps for std::map< K, T >
*
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>.
*
* Using this wrapper is fairly simple. For example, to create a map from integers to doubles use:
*
* %include <std_map.i>
* %template(Map_Int_Double) std::map<int, double>
*
* Very often the C# generated code will not compile as the C++ template type is not the same as the C#
* proxy type, so use the SWIG_STD_MAP_SPECIALIZED or SWIG_STD_MAP_SPECIALIZED_SIMPLE macros. For example:
*
* SWIG_STD_MAP_SPECIALIZED(MyCppKeyClass, MyCppValueClass, MyCsKeyClass, MyCsValueClass)
* %template(Map_MyCppKeyClass_MyCppValueClass) std::map<MyCppKeyClass, MyCppValueClass >;
*
* Or if the C# class names are the same as the C++ class names, you can use:
*
* SWIG_STD_MAP_SPECIALIZED_SIMPLE(MyKeyClass, MyValueClass)
* %template(Map_MyCppKeyClass_MyCppValueClass) std::map<MyKeyClass, MyValueClass >;
* %template(MapIntDouble) std::map<int, double>
*
* Notes:
* 1) For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code. In this case
@ -39,69 +28,13 @@
#include <stdexcept>
%}
// A minimal implementation to be used when no specialization exists.
%define SWIG_STD_MAP_MINIMAL_INTERNAL(K, T)
public:
map();
map(const map<K, T > &other);
/* K is the C++ key type, T is the C++ value type */
%define SWIG_STD_MAP_INTERNAL(K, T)
typedef K key_type;
typedef T mapped_type;
typedef size_t size_type;
size_type size() const;
bool empty() const;
%rename(Clear) clear;
void clear();
%extend {
const mapped_type& getitem(const key_type& key) throw (std::out_of_range) {
std::map<K,T >::iterator iter = $self->find(key);
if (iter != $self->end())
return iter->second;
else
throw std::out_of_range("key not found");
}
void setitem(const key_type& key, const mapped_type& x) {
(*$self)[key] = x;
}
bool ContainsKey(const key_type& key) {
std::map<K, T >::iterator iter = $self->find(key);
return iter != $self->end();
}
void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) {
std::map<K, T >::iterator iter = $self->find(key);
if (iter != $self->end())
throw std::out_of_range("key already exists");
$self->insert(std::pair<K, T >(key, val));
}
bool Remove(const key_type& key) {
std::map<K, T >::iterator iter = $self->find(key);
if (iter != $self->end()) {
$self->erase(iter);
return true;
}
return false;
}
}
%enddef
/* The specialized std::map implementation
* K is the C++ key type
* T is the C++ value type
* CSKEYTYPE is the C# key type
* CSVALUETYPE is the C# value type
*/
%define SWIG_STD_MAP_SPECIALIZED_INTERNAL(K, T, CSKEYTYPE, CSVALUETYPE)
// add typemaps here
%typemap(csinterfaces) std::map<K, T > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<CSKEYTYPE, CSVALUETYPE>\n#endif\n";
%typemap(csinterfaces) std::map< K, T > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\n";
%typemap(cscode) std::map<K, T > %{
public CSVALUETYPE this[CSKEYTYPE key] {
public $typemap(cstype, T) this[$typemap(cstype, K) key] {
get {
return getitem(key);
}
@ -111,12 +44,12 @@
}
}
public bool TryGetValue(CSKEYTYPE key, out CSVALUETYPE value) {
public bool TryGetValue($typemap(cstype, K) key, out $typemap(cstype, T) value) {
if (this.ContainsKey(key)) {
value = this[key];
return true;
}
value = default(CSVALUETYPE);
value = default($typemap(cstype, T));
return false;
}
@ -134,9 +67,9 @@
#if !SWIG_DOTNET_1
public System.Collections.Generic.ICollection<CSKEYTYPE> Keys {
public System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys {
get {
System.Collections.Generic.ICollection<CSKEYTYPE> keys = new System.Collections.Generic.List<CSKEYTYPE>();
System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new System.Collections.Generic.List<$typemap(cstype, K)>();
IntPtr iter = create_iterator_begin();
try {
while (true) {
@ -148,21 +81,21 @@
}
}
public System.Collections.Generic.ICollection<CSVALUETYPE> Values {
public System.Collections.Generic.ICollection<$typemap(cstype, T)> Values {
get {
System.Collections.Generic.ICollection<CSVALUETYPE> vals = new System.Collections.Generic.List<CSVALUETYPE>();
foreach (System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE> pair in this) {
System.Collections.Generic.ICollection<$typemap(cstype, T)> vals = new System.Collections.Generic.List<$typemap(cstype, T)>();
foreach (System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> pair in this) {
vals.Add(pair.Value);
}
return vals;
}
}
public void Add(System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE> item) {
public void Add(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
Add(item.Key, item.Value);
}
public bool Remove(System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE> item) {
public bool Remove(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
if (Contains(item)) {
return Remove(item.Key);
} else {
@ -170,7 +103,7 @@
}
}
public bool Contains(System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE> item) {
public bool Contains(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
if (this[item.Key] == item.Value) {
return true;
} else {
@ -178,11 +111,11 @@
}
}
public void CopyTo(System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>[] array) {
public void CopyTo(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array) {
CopyTo(array, 0);
}
public void CopyTo(System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>[] array, int arrayIndex) {
public void CopyTo(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array, int arrayIndex) {
if (array == null)
throw new ArgumentNullException("array");
if (arrayIndex < 0)
@ -192,14 +125,14 @@
if (arrayIndex+this.Count > array.Length)
throw new ArgumentException("Number of elements to copy is too large.");
System.Collections.Generic.IList<CSKEYTYPE> keyList = new System.Collections.Generic.List<CSKEYTYPE>(this.Keys);
System.Collections.Generic.IList<$typemap(cstype, K)> keyList = new System.Collections.Generic.List<$typemap(cstype, K)>(this.Keys);
for (int i = 0; i < keyList.Count; i++) {
CSKEYTYPE currentKey = keyList[i];
array.SetValue(new System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>(currentKey, this[currentKey]), arrayIndex+i);
$typemap(cstype, K) currentKey = keyList[i];
array.SetValue(new System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, this[currentKey]), arrayIndex+i);
}
}
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>>.GetEnumerator() {
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>>.GetEnumerator() {
return new $csclassnameEnumerator(this);
}
@ -217,24 +150,24 @@
/// collection but not when one of the elements of the collection is modified as it is a bit
/// tricky to detect unmanaged code that modifies the collection under our feet.
public sealed class $csclassnameEnumerator : System.Collections.IEnumerator,
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>>
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>>
{
private $csclassname collectionRef;
private System.Collections.Generic.IList<CSKEYTYPE> keyCollection;
private System.Collections.Generic.IList<$typemap(cstype, K)> keyCollection;
private int currentIndex;
private object currentObject;
private int currentSize;
public $csclassnameEnumerator($csclassname collection) {
collectionRef = collection;
keyCollection = new System.Collections.Generic.List<CSKEYTYPE>(collection.Keys);
keyCollection = new System.Collections.Generic.List<$typemap(cstype, K)>(collection.Keys);
currentIndex = -1;
currentObject = null;
currentSize = collectionRef.Count;
}
// Type-safe iterator Current
public System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE> Current {
public System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> Current {
get {
if (currentIndex == -1)
throw new InvalidOperationException("Enumeration not started.");
@ -242,7 +175,7 @@
throw new InvalidOperationException("Enumeration finished.");
if (currentObject == null)
throw new InvalidOperationException("Collection modified.");
return (System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>)currentObject;
return (System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>)currentObject;
}
}
@ -258,8 +191,8 @@
bool moveOkay = (currentIndex+1 < size) && (size == currentSize);
if (moveOkay) {
currentIndex++;
CSKEYTYPE currentKey = keyCollection[currentIndex];
currentObject = new System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>(currentKey, collectionRef[currentKey]);
$typemap(cstype, K) currentKey = keyCollection[currentIndex];
currentObject = new System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, collectionRef[currentKey]);
} else {
currentObject = null;
}
@ -285,7 +218,7 @@
public:
map();
map(const map<K, T > &other);
map(const map< K, T > &other);
typedef K key_type;
typedef T mapped_type;
@ -296,7 +229,7 @@
void clear();
%extend {
const mapped_type& getitem(const key_type& key) throw (std::out_of_range) {
std::map<K,T >::iterator iter = $self->find(key);
std::map< K,T >::iterator iter = $self->find(key);
if (iter != $self->end())
return iter->second;
else
@ -308,19 +241,19 @@
}
bool ContainsKey(const key_type& key) {
std::map<K, T >::iterator iter = $self->find(key);
std::map< K, T >::iterator iter = $self->find(key);
return iter != $self->end();
}
void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) {
std::map<K, T >::iterator iter = $self->find(key);
std::map< K, T >::iterator iter = $self->find(key);
if (iter != $self->end())
throw std::out_of_range("key already exists");
$self->insert(std::pair<K, T >(key, val));
$self->insert(std::pair< K, T >(key, val));
}
bool Remove(const key_type& key) {
std::map<K, T >::iterator iter = $self->find(key);
std::map< K, T >::iterator iter = $self->find(key);
if (iter != $self->end()) {
$self->erase(iter);
return true;
@ -329,15 +262,15 @@
}
// create_iterator_begin() and get_next_key() work together to provide a collection of keys to C#
%apply void *VOID_INT_PTR { std::map<K, T >::iterator *std::map<K, T >::create_iterator_begin }
%apply void *VOID_INT_PTR { std::map<K, T >::iterator *swigiterator }
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *create_iterator_begin }
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *swigiterator }
std::map<K, T >::iterator *create_iterator_begin() {
return new std::map<K, T >::iterator($self->begin());
std::map< K, T >::iterator *create_iterator_begin() {
return new std::map< K, T >::iterator($self->begin());
}
const key_type& get_next_key(std::map<K, T >::iterator *swigiterator) throw (std::out_of_range) {
std::map<K, T >::iterator iter = *swigiterator;
const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) throw (std::out_of_range) {
std::map< K, T >::iterator iter = *swigiterator;
if (iter == $self->end()) {
delete swigiterator;
throw std::out_of_range("no more map elements");
@ -348,275 +281,32 @@
}
%csmethodmodifiers std::map<K, T >::size "private"
%csmethodmodifiers std::map<K, T >::getitem "private"
%csmethodmodifiers std::map<K, T >::setitem "private"
%csmethodmodifiers std::map<K, T >::create_iterator_begin "private"
%csmethodmodifiers std::map<K, T >::get_next_key "private"
%enddef
// Main specialization macros
%define SWIG_STD_MAP_SPECIALIZED(K, T, CSKEY, CSVAL)
namespace std {
template<> class map<K, T > {
SWIG_STD_MAP_SPECIALIZED_INTERNAL(K, T, CSKEY, CSVAL)
};
}
%enddef
%define SWIG_STD_MAP_SPECIALIZED_SIMPLE(K, T)
SWIG_STD_MAP_SPECIALIZED(K, T, K, T)
%enddef
// Old macros (deprecated)
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
#warning specialize_std_map_on_key ignored - macro is deprecated, please use SWIG_STD_MAP_MINIMAL_INTERNAL in Lib/csharp/std_map.i
%enddef
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
#warning specialize_std_map_on_value ignored - macro is deprecated, please use SWIG_STD_MAP_MINIMAL_INTERNAL in Lib/csharp/std_map.i
%enddef
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
#warning specialize_std_map_on_both ignored - macro is deprecated, please use SWIG_STD_MAP_MINIMAL_INTERNAL in Lib/csharp/std_map.i
%enddef
%csmethodmodifiers std::map::size "private"
%csmethodmodifiers std::map::getitem "private"
%csmethodmodifiers std::map::setitem "private"
%csmethodmodifiers std::map::create_iterator_begin "private"
%csmethodmodifiers std::map::get_next_key "private"
// Default implementation
namespace std {
template<class K, class T> class map {
SWIG_STD_MAP_MINIMAL_INTERNAL(K, T)
SWIG_STD_MAP_INTERNAL(K, T)
};
}
// specializations for built-ins
SWIG_STD_MAP_SPECIALIZED(std::string, std::string, string, string)
SWIG_STD_MAP_SPECIALIZED(std::string, bool, string, bool)
SWIG_STD_MAP_SPECIALIZED(std::string, int, string, int)
SWIG_STD_MAP_SPECIALIZED(std::string, unsigned long long, string, ulong)
SWIG_STD_MAP_SPECIALIZED(std::string, unsigned long, string, uint)
SWIG_STD_MAP_SPECIALIZED(std::string, unsigned short, string, ushort)
SWIG_STD_MAP_SPECIALIZED(std::string, long long, string, long)
SWIG_STD_MAP_SPECIALIZED(std::string, unsigned int, string, uint)
SWIG_STD_MAP_SPECIALIZED(std::string, unsigned char, string, byte)
SWIG_STD_MAP_SPECIALIZED(std::string, signed char, string, sbyte)
SWIG_STD_MAP_SPECIALIZED(std::string, double, string, double)
SWIG_STD_MAP_SPECIALIZED(std::string, short, string, short)
SWIG_STD_MAP_SPECIALIZED(std::string, float, string, float)
SWIG_STD_MAP_SPECIALIZED(std::string, char, string, char)
SWIG_STD_MAP_SPECIALIZED(std::string, long, string, int)
SWIG_STD_MAP_SPECIALIZED(bool, std::string, bool, string)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, bool)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, int)
SWIG_STD_MAP_SPECIALIZED(bool, unsigned long long, bool, ulong)
SWIG_STD_MAP_SPECIALIZED(bool, unsigned long, bool, uint)
SWIG_STD_MAP_SPECIALIZED(bool, unsigned short, bool, ushort)
SWIG_STD_MAP_SPECIALIZED(bool, long long, bool, long)
SWIG_STD_MAP_SPECIALIZED(bool, unsigned int, bool, uint)
SWIG_STD_MAP_SPECIALIZED(bool, unsigned char, bool, byte)
SWIG_STD_MAP_SPECIALIZED(bool, signed char, bool, sbyte)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, double)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, short)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, float)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, char)
SWIG_STD_MAP_SPECIALIZED(bool, long, bool, int)
SWIG_STD_MAP_SPECIALIZED(int, std::string, int, string)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, bool)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, int)
SWIG_STD_MAP_SPECIALIZED(int, unsigned long long, int, ulong)
SWIG_STD_MAP_SPECIALIZED(int, unsigned long, int, uint)
SWIG_STD_MAP_SPECIALIZED(int, unsigned short, int, ushort)
SWIG_STD_MAP_SPECIALIZED(int, long long, int, long)
SWIG_STD_MAP_SPECIALIZED(int, unsigned int, int, uint)
SWIG_STD_MAP_SPECIALIZED(int, unsigned char, int, byte)
SWIG_STD_MAP_SPECIALIZED(int, signed char, int, sbyte)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, double)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, short)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, float)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, char)
SWIG_STD_MAP_SPECIALIZED(int, long, int, int)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, std::string, ulong, string)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, bool, ulong, bool)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, int, ulong, int)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned long long, ulong, ulong)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned long, ulong, uint)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned short, ulong, ushort)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, long long, ulong, long)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned int, ulong, uint)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned char, ulong, byte)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, signed char, ulong, sbyte)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, double, ulong, double)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, short, ulong, short)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, float, ulong, float)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, char, ulong, char)
SWIG_STD_MAP_SPECIALIZED(unsigned long long, long, ulong, int)
SWIG_STD_MAP_SPECIALIZED(unsigned long, std::string, uint, string)
SWIG_STD_MAP_SPECIALIZED(unsigned long, bool, uint, bool)
SWIG_STD_MAP_SPECIALIZED(unsigned long, int, uint, int)
SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned long long, uint, ulong)
SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned long, uint, uint)
SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned short, uint, ushort)
SWIG_STD_MAP_SPECIALIZED(unsigned long, long long, uint, long)
SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned int, uint, uint)
SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned char, uint, byte)
SWIG_STD_MAP_SPECIALIZED(unsigned long, signed char, uint, sbyte)
SWIG_STD_MAP_SPECIALIZED(unsigned long, double, uint, double)
SWIG_STD_MAP_SPECIALIZED(unsigned long, short, uint, short)
SWIG_STD_MAP_SPECIALIZED(unsigned long, float, uint, float)
SWIG_STD_MAP_SPECIALIZED(unsigned long, char, uint, char)
SWIG_STD_MAP_SPECIALIZED(unsigned long, long, uint, int)
SWIG_STD_MAP_SPECIALIZED(unsigned short, std::string, ushort, string)
SWIG_STD_MAP_SPECIALIZED(unsigned short, bool, ushort, bool)
SWIG_STD_MAP_SPECIALIZED(unsigned short, int, ushort, int)
SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned long long, ushort, ulong)
SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned long, ushort, uint)
SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned short, ushort, ushort)
SWIG_STD_MAP_SPECIALIZED(unsigned short, long long, ushort, long)
SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned int, ushort, uint)
SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned char, ushort, byte)
SWIG_STD_MAP_SPECIALIZED(unsigned short, signed char, ushort, sbyte)
SWIG_STD_MAP_SPECIALIZED(unsigned short, double, ushort, double)
SWIG_STD_MAP_SPECIALIZED(unsigned short, short, ushort, short)
SWIG_STD_MAP_SPECIALIZED(unsigned short, float, ushort, float)
SWIG_STD_MAP_SPECIALIZED(unsigned short, char, ushort, char)
SWIG_STD_MAP_SPECIALIZED(unsigned short, long, ushort, int)
SWIG_STD_MAP_SPECIALIZED(long long, std::string, long, string)
SWIG_STD_MAP_SPECIALIZED(long long, bool, long, bool)
SWIG_STD_MAP_SPECIALIZED(long long, int, long, int)
SWIG_STD_MAP_SPECIALIZED(long long, unsigned long long, long, ulong)
SWIG_STD_MAP_SPECIALIZED(long long, unsigned long, long, uint)
SWIG_STD_MAP_SPECIALIZED(long long, unsigned short, long, ushort)
SWIG_STD_MAP_SPECIALIZED(long long, long long, long, long)
SWIG_STD_MAP_SPECIALIZED(long long, unsigned int, long, uint)
SWIG_STD_MAP_SPECIALIZED(long long, unsigned char, long, byte)
SWIG_STD_MAP_SPECIALIZED(long long, signed char, long, sbyte)
SWIG_STD_MAP_SPECIALIZED(long long, double, long, double)
SWIG_STD_MAP_SPECIALIZED(long long, short, long, short)
SWIG_STD_MAP_SPECIALIZED(long long, float, long, float)
SWIG_STD_MAP_SPECIALIZED(long long, char, long, char)
SWIG_STD_MAP_SPECIALIZED(long long, long, long, int)
SWIG_STD_MAP_SPECIALIZED(unsigned int, std::string, uint, string)
SWIG_STD_MAP_SPECIALIZED(unsigned int, bool, uint, bool)
SWIG_STD_MAP_SPECIALIZED(unsigned int, int, uint, int)
SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned long long, uint, ulong)
SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned long, uint, uint)
SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned short, uint, ushort)
SWIG_STD_MAP_SPECIALIZED(unsigned int, long long, uint, long)
SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned int, uint, uint)
SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned char, uint, byte)
SWIG_STD_MAP_SPECIALIZED(unsigned int, signed char, uint, sbyte)
SWIG_STD_MAP_SPECIALIZED(unsigned int, double, uint, double)
SWIG_STD_MAP_SPECIALIZED(unsigned int, short, uint, short)
SWIG_STD_MAP_SPECIALIZED(unsigned int, float, uint, float)
SWIG_STD_MAP_SPECIALIZED(unsigned int, char, uint, char)
SWIG_STD_MAP_SPECIALIZED(unsigned int, long, uint, int)
SWIG_STD_MAP_SPECIALIZED(unsigned char, std::string, byte, string)
SWIG_STD_MAP_SPECIALIZED(unsigned char, bool, byte, bool)
SWIG_STD_MAP_SPECIALIZED(unsigned char, int, byte, int)
SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned long long, byte, ulong)
SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned long, byte, uint)
SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned short, byte, ushort)
SWIG_STD_MAP_SPECIALIZED(unsigned char, long long, byte, long)
SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned int, byte, uint)
SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned char, byte, byte)
SWIG_STD_MAP_SPECIALIZED(unsigned char, signed char, byte, sbyte)
SWIG_STD_MAP_SPECIALIZED(unsigned char, double, byte, double)
SWIG_STD_MAP_SPECIALIZED(unsigned char, short, byte, short)
SWIG_STD_MAP_SPECIALIZED(unsigned char, float, byte, float)
SWIG_STD_MAP_SPECIALIZED(unsigned char, char, byte, char)
SWIG_STD_MAP_SPECIALIZED(unsigned char, long, byte, int)
SWIG_STD_MAP_SPECIALIZED(signed char, std::string, sbyte, string)
SWIG_STD_MAP_SPECIALIZED(signed char, bool, sbyte, bool)
SWIG_STD_MAP_SPECIALIZED(signed char, int, sbyte, int)
SWIG_STD_MAP_SPECIALIZED(signed char, unsigned long long, sbyte, ulong)
SWIG_STD_MAP_SPECIALIZED(signed char, unsigned long, sbyte, uint)
SWIG_STD_MAP_SPECIALIZED(signed char, unsigned short, sbyte, ushort)
SWIG_STD_MAP_SPECIALIZED(signed char, long long, sbyte, long)
SWIG_STD_MAP_SPECIALIZED(signed char, unsigned int, sbyte, uint)
SWIG_STD_MAP_SPECIALIZED(signed char, unsigned char, sbyte, byte)
SWIG_STD_MAP_SPECIALIZED(signed char, signed char, sbyte, sbyte)
SWIG_STD_MAP_SPECIALIZED(signed char, double, sbyte, double)
SWIG_STD_MAP_SPECIALIZED(signed char, short, sbyte, short)
SWIG_STD_MAP_SPECIALIZED(signed char, float, sbyte, float)
SWIG_STD_MAP_SPECIALIZED(signed char, char, sbyte, char)
SWIG_STD_MAP_SPECIALIZED(signed char, long, sbyte, int)
SWIG_STD_MAP_SPECIALIZED(double, std::string, double, string)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, bool)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, int)
SWIG_STD_MAP_SPECIALIZED(double, unsigned long long, double, ulong)
SWIG_STD_MAP_SPECIALIZED(double, unsigned long, double, uint)
SWIG_STD_MAP_SPECIALIZED(double, unsigned short, double, ushort)
SWIG_STD_MAP_SPECIALIZED(double, long long, double, long)
SWIG_STD_MAP_SPECIALIZED(double, unsigned int, double, uint)
SWIG_STD_MAP_SPECIALIZED(double, unsigned char, double, byte)
SWIG_STD_MAP_SPECIALIZED(double, signed char, double, sbyte)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, double)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, short)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, float)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, char)
SWIG_STD_MAP_SPECIALIZED(double, long, double, int)
SWIG_STD_MAP_SPECIALIZED(short, std::string, short, string)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, bool)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, int)
SWIG_STD_MAP_SPECIALIZED(short, unsigned long long, short, ulong)
SWIG_STD_MAP_SPECIALIZED(short, unsigned long, short, uint)
SWIG_STD_MAP_SPECIALIZED(short, unsigned short, short, ushort)
SWIG_STD_MAP_SPECIALIZED(short, long long, short, long)
SWIG_STD_MAP_SPECIALIZED(short, unsigned int, short, uint)
SWIG_STD_MAP_SPECIALIZED(short, unsigned char, short, byte)
SWIG_STD_MAP_SPECIALIZED(short, signed char, short, sbyte)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, double)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, short)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, float)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, char)
SWIG_STD_MAP_SPECIALIZED(short, long, short, int)
SWIG_STD_MAP_SPECIALIZED(float, std::string, float, string)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, bool)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, int)
SWIG_STD_MAP_SPECIALIZED(float, unsigned long long, float, ulong)
SWIG_STD_MAP_SPECIALIZED(float, unsigned long, float, uint)
SWIG_STD_MAP_SPECIALIZED(float, unsigned short, float, ushort)
SWIG_STD_MAP_SPECIALIZED(float, long long, float, long)
SWIG_STD_MAP_SPECIALIZED(float, unsigned int, float, uint)
SWIG_STD_MAP_SPECIALIZED(float, unsigned char, float, byte)
SWIG_STD_MAP_SPECIALIZED(float, signed char, float, sbyte)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, double)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, short)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, float)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, char)
SWIG_STD_MAP_SPECIALIZED(float, long, float, int)
SWIG_STD_MAP_SPECIALIZED(char, std::string, char, string)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, bool)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, int)
SWIG_STD_MAP_SPECIALIZED(char, unsigned long long, char, ulong)
SWIG_STD_MAP_SPECIALIZED(char, unsigned long, char, uint)
SWIG_STD_MAP_SPECIALIZED(char, unsigned short, char, ushort)
SWIG_STD_MAP_SPECIALIZED(char, long long, char, long)
SWIG_STD_MAP_SPECIALIZED(char, unsigned int, char, uint)
SWIG_STD_MAP_SPECIALIZED(char, unsigned char, char, byte)
SWIG_STD_MAP_SPECIALIZED(char, signed char, char, sbyte)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, double)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, short)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, float)
SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, char)
SWIG_STD_MAP_SPECIALIZED(char, long, char, int)
SWIG_STD_MAP_SPECIALIZED(long, std::string, int, string)
SWIG_STD_MAP_SPECIALIZED(long, bool, int, bool)
SWIG_STD_MAP_SPECIALIZED(long, int, int, int)
SWIG_STD_MAP_SPECIALIZED(long, unsigned long long, int, ulong)
SWIG_STD_MAP_SPECIALIZED(long, unsigned long, int, uint)
SWIG_STD_MAP_SPECIALIZED(long, unsigned short, int, ushort)
SWIG_STD_MAP_SPECIALIZED(long, long long, int, long)
SWIG_STD_MAP_SPECIALIZED(long, unsigned int, int, uint)
SWIG_STD_MAP_SPECIALIZED(long, unsigned char, int, byte)
SWIG_STD_MAP_SPECIALIZED(long, signed char, int, sbyte)
SWIG_STD_MAP_SPECIALIZED(long, double, int, double)
SWIG_STD_MAP_SPECIALIZED(long, short, int, short)
SWIG_STD_MAP_SPECIALIZED(long, float, int, float)
SWIG_STD_MAP_SPECIALIZED(long, char, int, char)
SWIG_STD_MAP_SPECIALIZED(long, long, int, int)
// add specializations here
// Legacy macros (deprecated)
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
#warning specialize_std_map_on_key ignored - macro is deprecated and no longer necessary
%enddef
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
#warning specialize_std_map_on_value ignored - macro is deprecated and no longer necessary
%enddef
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
#warning specialize_std_map_on_both ignored - macro is deprecated and no longer necessary
%enddef

View file

@ -4,23 +4,20 @@
*
* std_vector.i
*
* SWIG typemaps for std::vector
* SWIG typemaps for std::vector<T>
* C# implementation
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.List<> collection.
* For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code; then the C# wrapper is
* made to look and feel like a typesafe C# System.Collections.ArrayList. All the methods in IList
* are defined, but we don't derive from IList as this is a typesafe collection and the C++ operator==
* must always be defined for the collection type (which it isn't).
*
* Very often the C# generated code will not compile as the C++ template type is not the same as the C#
* proxy type, so use the SWIG_STD_VECTOR_SPECIALIZE or SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro, eg
*
* SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(Klass, SomeNamespace::Klass)
* %template(VectKlass) std::vector<SomeNamespace::Klass>;
* made to look and feel like a typesafe C# System.Collections.ArrayList.
*
* Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
* C++ std::vector wrappers. IEnumerable<> is replaced by IList<> wherever we are confident that the
* required C++ operator== is available for correct compilation.
* C++ std::vector wrappers. The IList<> interface is also implemented to provide enhanced functionality
* whenever we are confident that the required C++ operator== is available. This is the case for when
* T is a primitive type or a pointer. If T does define an operator==, then use the SWIG_STD_VECTOR_ENHANCED
* macro to obtain this enhanced functionality, for example:
*
* SWIG_STD_VECTOR_ENHANCED(SomeNamespace::Klass)
* %template(VectKlass) std::vector<SomeNamespace::Klass>;
*
* Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents!
* ----------------------------------------------------------------------------- */
@ -31,14 +28,13 @@
%include <std_common.i>
// MACRO for use within the std::vector class body
// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE_TYPE, CSTYPE, CTYPE...)
%typemap(csinterfaces) std::vector<CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<CSTYPE>\n#endif\n";
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE_TYPE, CTYPE...)
%typemap(csinterfaces) std::vector<CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n";
%typemap(cscode) std::vector<CTYPE > %{
public $csclassname(System.Collections.ICollection c) : this() {
if (c == null)
throw new ArgumentNullException("c");
foreach (CSTYPE element in c) {
foreach ($typemap(cstype, CTYPE) element in c) {
this.Add(element);
}
}
@ -55,7 +51,7 @@
}
}
public CSTYPE this[int index] {
public $typemap(cstype, CTYPE) this[int index] {
get {
return getitem(index);
}
@ -90,7 +86,7 @@
#if SWIG_DOTNET_1
public void CopyTo(System.Array array)
#else
public void CopyTo(CSTYPE[] array)
public void CopyTo($typemap(cstype, CTYPE)[] array)
#endif
{
CopyTo(0, array, 0, this.Count);
@ -99,7 +95,7 @@
#if SWIG_DOTNET_1
public void CopyTo(System.Array array, int arrayIndex)
#else
public void CopyTo(CSTYPE[] array, int arrayIndex)
public void CopyTo($typemap(cstype, CTYPE)[] array, int arrayIndex)
#endif
{
CopyTo(0, array, arrayIndex, this.Count);
@ -108,7 +104,7 @@
#if SWIG_DOTNET_1
public void CopyTo(int index, System.Array array, int arrayIndex, int count)
#else
public void CopyTo(int index, CSTYPE[] array, int arrayIndex, int count)
public void CopyTo(int index, $typemap(cstype, CTYPE)[] array, int arrayIndex, int count)
#endif
{
if (array == null)
@ -128,7 +124,7 @@
}
#if !SWIG_DOTNET_1
System.Collections.Generic.IEnumerator<CSTYPE> System.Collections.Generic.IEnumerable<CSTYPE>.GetEnumerator() {
System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() {
return new $csclassnameEnumerator(this);
}
#endif
@ -148,7 +144,7 @@
/// tricky to detect unmanaged code that modifies the collection under our feet.
public sealed class $csclassnameEnumerator : System.Collections.IEnumerator
#if !SWIG_DOTNET_1
, System.Collections.Generic.IEnumerator<CSTYPE>
, System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)>
#endif
{
private $csclassname collectionRef;
@ -164,7 +160,7 @@
}
// Type-safe iterator Current
public CSTYPE Current {
public $typemap(cstype, CTYPE) Current {
get {
if (currentIndex == -1)
throw new InvalidOperationException("Enumeration not started.");
@ -172,7 +168,7 @@
throw new InvalidOperationException("Enumeration finished.");
if (currentObject == null)
throw new InvalidOperationException("Collection modified.");
return (CSTYPE)currentObject;
return ($typemap(cstype, CTYPE))currentObject;
}
}
@ -326,14 +322,13 @@
}
%enddef
%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...)
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CSTYPE, CTYPE)
%define SWIG_STD_VECTOR_MINIMUM(CTYPE...)
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CTYPE)
%enddef
// Extra methods added to the collection class if operator== is defined for the class being wrapped
// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps
// The class will then implement IList<>, which adds extra functionality
%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE...)
%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...)
%extend {
bool Contains(const value_type& value) {
return std::find($self->begin(), $self->end(), value) != $self->end();
@ -363,23 +358,24 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CSTYPE, CTYPE)
}
%enddef
// Macros for std::vector class specializations
// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps
%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...)
// Macros for std::vector class specializations/enhancements
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
namespace std {
template<> class vector<CTYPE > {
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, CSTYPE, CTYPE)
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE)
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, CTYPE)
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
};
}
%enddef
// Legacy macros
%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...)
#warning SWIG_STD_VECTOR_SPECIALIZE macro deprecated, please see csharp/std_vector.i and switch to SWIG_STD_VECTOR_ENHANCED
SWIG_STD_VECTOR_ENHANCED(CTYPE)
%enddef
%define SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE...)
namespace std {
template<> class vector<CTYPE > {
SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE)
};
}
#warning SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro deprecated, it is no longer required
%enddef
%{
@ -399,36 +395,38 @@ namespace std {
// primary (unspecialized) class template for std::vector
// does not require operator== to be defined
template<class T> class vector {
SWIG_STD_VECTOR_MINIMUM(T, T)
SWIG_STD_VECTOR_MINIMUM(T)
};
// specializations for pointers
template<class T> class vector<T*> {
SWIG_STD_VECTOR_MINIMUM(T, T*)
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, T*)
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T*)
};
template<class T> class vector<const T*> {
SWIG_STD_VECTOR_MINIMUM(T, const T*)
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, const T*)
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(const T*)
};
// bool is a bit different in the C++ standard
template<> class vector<bool> {
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool, bool)
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool, bool)
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool)
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool)
};
}
// template specializations for std::vector
// these provide extra collections methods as operator== is defined
SWIG_STD_VECTOR_SPECIALIZE(char, char)
SWIG_STD_VECTOR_SPECIALIZE(sbyte, signed char)
SWIG_STD_VECTOR_SPECIALIZE(byte, unsigned char)
SWIG_STD_VECTOR_SPECIALIZE(short, short)
SWIG_STD_VECTOR_SPECIALIZE(ushort, unsigned short)
SWIG_STD_VECTOR_SPECIALIZE(int, int)
SWIG_STD_VECTOR_SPECIALIZE(uint, unsigned int)
SWIG_STD_VECTOR_SPECIALIZE(int, long)
SWIG_STD_VECTOR_SPECIALIZE(uint, unsigned long)
SWIG_STD_VECTOR_SPECIALIZE(long, long long)
SWIG_STD_VECTOR_SPECIALIZE(ulong, unsigned long long)
SWIG_STD_VECTOR_SPECIALIZE(float, float)
SWIG_STD_VECTOR_SPECIALIZE(double, double)
SWIG_STD_VECTOR_SPECIALIZE(string, std::string) // also requires a %include <std_string.i>
SWIG_STD_VECTOR_ENHANCED(char)
SWIG_STD_VECTOR_ENHANCED(signed char)
SWIG_STD_VECTOR_ENHANCED(unsigned char)
SWIG_STD_VECTOR_ENHANCED(short)
SWIG_STD_VECTOR_ENHANCED(unsigned short)
SWIG_STD_VECTOR_ENHANCED(int)
SWIG_STD_VECTOR_ENHANCED(unsigned int)
SWIG_STD_VECTOR_ENHANCED(long)
SWIG_STD_VECTOR_ENHANCED(unsigned long)
SWIG_STD_VECTOR_ENHANCED(long long)
SWIG_STD_VECTOR_ENHANCED(unsigned long long)
SWIG_STD_VECTOR_ENHANCED(float)
SWIG_STD_VECTOR_ENHANCED(double)
SWIG_STD_VECTOR_ENHANCED(std::string) // also requires a %include <std_string.i>

View file

@ -11,6 +11,7 @@
#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP",sourcefmt="%(lower)s") `x`
#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP") "::" `x`
#define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x`
/*
@ -455,7 +456,28 @@ PHPCN(SQLiteResult);
PHPCN(SQLiteUnbuffered);
PHPCN(SQLiteException);
/* Built-in PHP functions (incomplete). */
PHPFN(cos);
PHPFN(sin);
PHPFN(tan);
PHPFN(acos);
PHPFN(asin);
PHPFN(atan);
PHPFN(atan2);
PHPFN(cosh);
PHPFN(sinh);
PHPFN(tanh);
PHPFN(exp);
PHPFN(log);
PHPFN(log10);
PHPFN(pow);
PHPFN(sqrt);
PHPFN(ceil);
PHPFN(floor);
PHPFN(fmod);
#undef PHPKW
#undef PHPBN1
#undef PHPBN2
#undef PHPCN
#undef PHPFN

View file

@ -25,6 +25,15 @@ extern "C" {
# define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_NAMED_FE(ZN, N, A)
#endif
#ifndef Z_SET_ISREF_P
// For PHP < 5.3
# define Z_SET_ISREF_P(z) (z)->is_ref = 1
#endif
#ifndef Z_SET_REFCOUNT_P
// For PHP < 5.3
# define Z_SET_REFCOUNT_P(z, rc) (z)->refcount = (rc)
#endif
#define SWIG_LONG_CONSTANT(N, V) zend_register_long_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC)
#define SWIG_DOUBLE_CONSTANT(N, V) zend_register_double_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC)
#define SWIG_STRING_CONSTANT(N, V) zend_register_stringl_constant((char*)#N, sizeof(#N), V, strlen(V), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC)
@ -118,13 +127,13 @@ SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject
/* class names are stored in lowercase */
php_strtolower(Z_STRVAL_PP(&classname), Z_STRLEN_PP(&classname));
if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &ce TSRMLS_CC) != SUCCESS) {
/* class does not exists */
/* class does not exist */
object_init(z);
} else {
object_init_ex(z, *ce);
}
z->refcount = 1;
z->is_ref = 1;
Z_SET_REFCOUNT_P(z, 1);
Z_SET_ISREF_P(z);
zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval), NULL);
FREE_ZVAL(classname);
}

View file

@ -152,7 +152,7 @@
#define %clearnaturalvar %feature("naturalvar","")
/* valuewrapper directives */
#define %valuewrapper %feature("valuewrapper",)
#define %valuewrapper %feature("valuewrapper")
#define %clearvaluewrapper %feature("valuewrapper","")
#define %novaluewrapper %feature("novaluewrapper")
#define %clearnovaluewrapper %feature("novaluewrapper","")

View file

@ -16,17 +16,17 @@
// const declarations are used to guess the intent of the function being
// exported; therefore, the following rationale is applied:
//
// -- f(std::vector<T>), f(const std::vector<T>&), f(const std::vector<T>*):
// -- f(std::vector< T >), f(const std::vector< T >&), f(const std::vector< T >*):
// the parameter being read-only, either a Tcl list or a
// previously wrapped std::vector<T> can be passed.
// -- f(std::vector<T>&), f(std::vector<T>*):
// previously wrapped std::vector< T > can be passed.
// -- f(std::vector< T >&), f(std::vector< T >*):
// the parameter must be modified; therefore, only a wrapped std::vector
// can be passed.
// -- std::vector<T> f():
// -- std::vector< T > f():
// the vector is returned by copy; therefore, a Tcl list of T:s
// is returned which is most easily used in other Tcl functions procs
// -- std::vector<T>& f(), std::vector<T>* f(), const std::vector<T>& f(),
// const std::vector<T>* f():
// -- std::vector< T >& f(), std::vector< T >* f(), const std::vector< T >& f(),
// const std::vector< T >* f():
// the vector is returned by reference; therefore, a wrapped std::vector
// is returned
// ------------------------------------------------------------------------
@ -85,7 +85,7 @@ int SwigDouble_As(Tcl_Interp *interp, Tcl_Obj *o, Type *val) {
namespace std {
template<class T> class vector {
%typemap(in) vector<T> (std::vector<T> *v) {
%typemap(in) vector< T > (std::vector< T > *v) {
Tcl_Obj **listobjv;
int nitems;
int i;
@ -95,11 +95,11 @@ namespace std {
$&1_descriptor, 0) == 0){
$1 = *v;
} else {
// It isn't a vector<T> so it should be a list of T's
// It isn't a vector< T > so it should be a list of T's
if(Tcl_ListObjGetElements(interp, $input, \
&nitems, &listobjv) == TCL_ERROR)
return TCL_ERROR;
$1 = std::vector<T>();
$1 = std::vector< T >();
for (i = 0; i < nitems; i++) {
if ((SWIG_ConvertPtr(listobjv[i],(void **) &temp,
$descriptor(T *),0)) != 0) {
@ -113,8 +113,8 @@ namespace std {
}
}
%typemap(in) const vector<T>* (std::vector<T> *v, std::vector<T> w),
const vector<T>& (std::vector<T> *v, std::vector<T> w) {
%typemap(in) const vector< T >* (std::vector< T > *v, std::vector< T > w),
const vector< T >& (std::vector< T > *v, std::vector< T > w) {
Tcl_Obj **listobjv;
int nitems;
int i;
@ -124,11 +124,11 @@ namespace std {
$&1_descriptor, 0) == 0) {
$1 = v;
} else {
// It isn't a vector<T> so it should be a list of T's
// It isn't a vector< T > so it should be a list of T's
if(Tcl_ListObjGetElements(interp, $input,
&nitems, &listobjv) == TCL_ERROR)
return TCL_ERROR;
w = std::vector<T>();
w = std::vector< T >();
for (i = 0; i < nitems; i++) {
if ((SWIG_ConvertPtr(listobjv[i],(void **) &temp,
$descriptor(T *),0)) != 0) {
@ -143,7 +143,7 @@ namespace std {
}
}
%typemap(out) vector<T> {
%typemap(out) vector< T > {
for (unsigned int i=0; i<$1.size(); i++) {
T* ptr = new T((($1_type &)$1)[i]);
Tcl_ListObjAppendElement(interp, $result, \
@ -153,18 +153,18 @@ namespace std {
}
}
%typecheck(SWIG_TYPECHECK_VECTOR) vector<T> {
%typecheck(SWIG_TYPECHECK_VECTOR) vector< T > {
Tcl_Obj **listobjv;
int nitems;
T* temp;
std::vector<T> *v;
std::vector< T > *v;
if(SWIG_ConvertPtr($input, (void **) &v, \
$&1_descriptor, 0) == 0) {
/* wrapped vector */
$1 = 1;
} else {
// It isn't a vector<T> so it should be a list of T's
// It isn't a vector< T > so it should be a list of T's
if(Tcl_ListObjGetElements(interp, $input,
&nitems, &listobjv) == TCL_ERROR)
$1 = 0;
@ -181,19 +181,19 @@ namespace std {
}
}
%typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&,
const vector<T>* {
%typecheck(SWIG_TYPECHECK_VECTOR) const vector< T >&,
const vector< T >* {
Tcl_Obj **listobjv;
int nitems;
T* temp;
std::vector<T> *v;
std::vector< T > *v;
if(SWIG_ConvertPtr($input, (void **) &v, \
$1_descriptor, 0) == 0){
/* wrapped vector */
$1 = 1;
} else {
// It isn't a vector<T> so it should be a list of T's
// It isn't a vector< T > so it should be a list of T's
if(Tcl_ListObjGetElements(interp, $input,
&nitems, &listobjv) == TCL_ERROR)
$1 = 0;
@ -213,7 +213,7 @@ namespace std {
public:
vector(unsigned int size = 0);
vector(unsigned int size, const T& value);
vector(const vector<T> &);
vector(const vector< T > &);
unsigned int size() const;
bool empty() const;
@ -251,9 +251,9 @@ namespace std {
// specializations for built-ins
%define specialize_std_vector(T, CONVERT_FROM, CONVERT_TO)
template<> class vector<T> {
template<> class vector< T > {
%typemap(in) vector<T> (std::vector<T> *v){
%typemap(in) vector< T > (std::vector< T > *v){
Tcl_Obj **listobjv;
int nitems;
int i;
@ -263,11 +263,11 @@ namespace std {
$&1_descriptor, 0) == 0) {
$1 = *v;
} else {
// It isn't a vector<T> so it should be a list of T's
// It isn't a vector< T > so it should be a list of T's
if(Tcl_ListObjGetElements(interp, $input,
&nitems, &listobjv) == TCL_ERROR)
return TCL_ERROR;
$1 = std::vector<T>();
$1 = std::vector< T >();
for (i = 0; i < nitems; i++) {
if (CONVERT_FROM(interp, listobjv[i], &temp) == TCL_ERROR)
return TCL_ERROR;
@ -276,8 +276,8 @@ namespace std {
}
}
%typemap(in) const vector<T>& (std::vector<T> *v,std::vector<T> w),
const vector<T>* (std::vector<T> *v,std::vector<T> w) {
%typemap(in) const vector< T >& (std::vector< T > *v,std::vector< T > w),
const vector< T >* (std::vector< T > *v,std::vector< T > w) {
Tcl_Obj **listobjv;
int nitems;
int i;
@ -287,11 +287,11 @@ namespace std {
$1_descriptor, 0) == 0) {
$1 = v;
} else {
// It isn't a vector<T> so it should be a list of T's
// It isn't a vector< T > so it should be a list of T's
if(Tcl_ListObjGetElements(interp, $input,
&nitems, &listobjv) == TCL_ERROR)
return TCL_ERROR;
w = std::vector<T>();
w = std::vector< T >();
for (i = 0; i < nitems; i++) {
if (CONVERT_FROM(interp, listobjv[i], &temp) == TCL_ERROR)
return TCL_ERROR;
@ -301,25 +301,25 @@ namespace std {
}
}
%typemap(out) vector<T> {
%typemap(out) vector< T > {
for (unsigned int i=0; i<$1.size(); i++) {
Tcl_ListObjAppendElement(interp, $result, \
CONVERT_TO((($1_type &)$1)[i]));
}
}
%typecheck(SWIG_TYPECHECK_VECTOR) vector<T> {
%typecheck(SWIG_TYPECHECK_VECTOR) vector< T > {
Tcl_Obj **listobjv;
int nitems;
T temp;
std::vector<T> *v;
std::vector< T > *v;
if(SWIG_ConvertPtr($input, (void **) &v, \
$&1_descriptor, 0) == 0){
/* wrapped vector */
$1 = 1;
} else {
// It isn't a vector<T> so it should be a list of T's
// It isn't a vector< T > so it should be a list of T's
if(Tcl_ListObjGetElements(interp, $input,
&nitems, &listobjv) == TCL_ERROR)
$1 = 0;
@ -334,19 +334,19 @@ namespace std {
}
}
%typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&,
const vector<T>*{
%typecheck(SWIG_TYPECHECK_VECTOR) const vector< T >&,
const vector< T >*{
Tcl_Obj **listobjv;
int nitems;
T temp;
std::vector<T> *v;
std::vector< T > *v;
if(SWIG_ConvertPtr($input, (void **) &v, \
$1_descriptor, 0) == 0){
/* wrapped vector */
$1 = 1;
} else {
// It isn't a vector<T> so it should be a list of T's
// It isn't a vector< T > so it should be a list of T's
if(Tcl_ListObjGetElements(interp, $input,
&nitems, &listobjv) == TCL_ERROR)
$1 = 0;
@ -364,7 +364,7 @@ namespace std {
public:
vector(unsigned int size = 0);
vector(unsigned int size, const T& value);
vector(const vector<T> &);
vector(const vector< T > &);
unsigned int size() const;
bool empty() const;

View file

@ -184,7 +184,7 @@ java.actionexample:
else \
echo $(ACTION)ing Examples/$(LANGUAGE)/java; \
(cd Examples/$(LANGUAGE)/java && $(MAKE) -s $(chk-set-env) $(ACTION)) \
fi; \
fi
gifplot-library:
@echo $(ACTION)ing Examples/GIFPlot/Lib

View file

@ -501,6 +501,10 @@ public:
Printf(s_entry, "static zend_function_entry %s_functions[] = {\n", module);
/* start the init section */
Append(s_init, "#if ZEND_MODULE_API_NO <= 20090626\n");
Append(s_init, "#undef ZEND_MODULE_BUILD_ID\n");
Append(s_init, "#define ZEND_MODULE_BUILD_ID (char*)\"API\" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA\n");
Append(s_init, "#endif\n");
Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n" "#if ZEND_MODULE_API_NO > 20010900\n" " STANDARD_MODULE_HEADER,\n" "#endif\n", NIL);
Printf(s_init, " (char*)\"%s\",\n", module);
Printf(s_init, " %s_functions,\n", module);
@ -1022,7 +1026,20 @@ public:
String *output = s_oowrappers;
if (constructor) {
class_has_ctor = true;
methodname = "__construct";
// Skip the Foo:: prefix.
char *ptr = strrchr(GetChar(n, "name"), ':');
if (ptr) {
ptr++;
} else {
ptr = GetChar(n, "name");
}
if (strcmp(ptr, GetChar(n, "constructorHandler:sym:name")) == 0) {
methodname = "__construct";
} else {
// The class has multiple constructors and this one is
// renamed, so this will be a static factory function
methodname = GetChar(n, "constructorHandler:sym:name");
}
} else if (wrapperType == memberfn) {
methodname = Char(Getattr(n, "memberfunctionHandler:sym:name"));
} else if (wrapperType == staticmemberfn) {
@ -1581,7 +1598,11 @@ public:
Printf(output, "%s", prepare);
if (constructor) {
if (!directorsEnabled() || !Swig_directorclass(n)) {
Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke);
if (strcmp(methodname, "__construct") == 0) {
Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke);
} else {
Printf(output, "\t\treturn new %s(%s);\n", "Foo", invoke);
}
} else {
Node *parent = Swig_methodclass(n);
String *classname = Swig_class_name(parent);
@ -1627,8 +1648,14 @@ public:
*/
Printf(output, "\t\tif (is_resource($r)) {\n");
Printf(output, "\t\t\t$class='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix);
Printf(output, "\t\t\treturn new $class($r);\n\t\t}\n");
Printf(output, "\t\telse return $r;\n");
if (Getattr(classLookup(Getattr(n, "type")), "module")) {
Printf(output, "\t\t\treturn new $class($r);\n");
} else {
Printf(output, "\t\t\t$c = new stdClass();\n");
Printf(output, "\t\t\t$c->_cPtr = $r;\n");
Printf(output, "\t\t\treturn $c;\n");
}
Printf(output, "\t\t}\n\t\telse return $r;\n");
} else {
Printf(output, "\t\t$this->%s = $r;\n", SWIG_PTR);
Printf(output, "\t\treturn $this;\n");
@ -1928,7 +1955,7 @@ public:
Printf(s_phpclasses, "class %s%s ", prefix, shadow_classname);
String *baseclass = NULL;
if (base.item) {
if (base.item && Getattr(base.item, "module")) {
baseclass = Getattr(base.item, "sym:name");
if (!baseclass)
baseclass = Getattr(base.item, "name");

View file

@ -2984,7 +2984,7 @@ public:
Delete(realct);
}
if (!have_constructor) {
Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"No constructor defined\")\n", NIL);
Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"", "No constructor defined", (Getattr(n, "abstract") ? " - class is abstract" : ""), "\")\n", NIL);
} else if (fastinit) {
Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL);

View file

@ -931,13 +931,13 @@ public:
Printv(f_shadow, " constructor { } {\n", NIL);
Printv(f_shadow, " # This constructor will fail if called directly\n", NIL);
Printv(f_shadow, " if { [info class] == \"::", class_name, "\" } {\n", NIL);
Printv(f_shadow, " error \"No constructor for class ", class_name, "\"\n", NIL);
Printv(f_shadow, " error \"No constructor for class ", class_name, (Getattr(n, "abstract") ? " - class is abstract" : ""), "\"\n", NIL);
Printv(f_shadow, " }\n", NIL);
Printv(f_shadow, " }\n", NIL);
}
Printv(f_shadow, "}\n\n", NIL);
};
}
Printv(f_wrappers, "static swig_class *swig_", mangled_classname, "_bases[] = {", base_class, "0};\n", NIL);
Printv(f_wrappers, "static const char * swig_", mangled_classname, "_base_names[] = {", base_class_names, "0};\n", NIL);

View file

@ -1699,9 +1699,10 @@ static List *split_embedded_typemap(String *s) {
List *args = 0;
char *c, *start;
int level = 0;
int angle_level = 0;
int leading = 1;
args = NewList();
args = NewList();
c = strchr(Char(s), '(');
assert(c);
c++;
@ -1720,7 +1721,7 @@ static List *split_embedded_typemap(String *s) {
c++;
}
}
if ((level == 0) && ((*c == ',') || (*c == ')'))) {
if ((level == 0) && angle_level == 0 && ((*c == ',') || (*c == ')'))) {
String *tmp = NewStringWithSize(start, c - start);
Append(args, tmp);
Delete(tmp);
@ -1735,6 +1736,10 @@ static List *split_embedded_typemap(String *s) {
level++;
if (*c == ')')
level--;
if (*c == '<')
angle_level++;
if (*c == '>')
angle_level--;
if (isspace((int) *c) && leading)
start++;
if (!isspace((int) *c))
@ -1901,6 +1906,7 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
}
Delete(l);
}
if (syntax_error) {
String *dtypemap = NewString(dollar_typemap);
Replaceall(dtypemap, "$TYPEMAP", "$typemap");