merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12002 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
07cb6351f1
181 changed files with 4467 additions and 6779 deletions
|
|
@ -84,6 +84,11 @@ CXXSHARED= @CXXSHARED@
|
|||
|
||||
OBJS = $(SRCS:.c=.@OBJEXT@) $(CXXSRCS:.cxx=.@OBJEXT@)
|
||||
|
||||
distclean:
|
||||
rm -f Makefile
|
||||
rm -f guile/Makefile
|
||||
rm -f xml/Makefile
|
||||
|
||||
##################################################################
|
||||
##### Tcl/Tk ######
|
||||
##################################################################
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ SWIG Examples
|
|||
|
||||
The "perl5", "python", "tcl", "guile", "java", "mzscheme", "ruby", and
|
||||
"chicken" directories contain a number of simple examples that are
|
||||
primarily used for testing. The "GIFPlot" directory contains a more
|
||||
complicated example that illustrates some of SWIG's more advanced
|
||||
capabilities.
|
||||
primarily used for testing.
|
||||
|
||||
The file 'index.html' is the top of a hyperlinked document that
|
||||
contains information about all of the examples along with various
|
||||
|
|
|
|||
|
|
@ -12,6 +12,3 @@ std_vector -- C++ STL vector<int> and vector<double>
|
|||
Note that the examples in this directory build a special version of
|
||||
Guile which includes the wrapped functions in the top-level module.
|
||||
|
||||
If you want to put the wrapped functions into an own module,
|
||||
statically or dynamically linked, see the Examples/GIFPlot/Guile
|
||||
directory.
|
||||
|
|
|
|||
|
|
@ -46,12 +46,6 @@ language:
|
|||
|
||||
If your target platform is Windows, make sure you also see the <a href="../Doc/Manual/Windows.html">Windows</a> page in the main manual.
|
||||
|
||||
<h2>Real Life</h2>
|
||||
|
||||
The <a href="GIFPlot/">GIFPlot</a> directory contains examples that illustrate the use of SWIG with
|
||||
a moderately complex C library for creating GIF images. Many of these
|
||||
examples illustrate more advanced SWIG features.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
|||
|
|
@ -66,24 +66,6 @@ The examples have been extensively tested on the following platforms:
|
|||
|
||||
Please see the <a href="../../Doc/Manual/Windows.html">Windows</a> page in the main manual for information on using the examples on Windows. <p>
|
||||
|
||||
The most recent version of Perl used for testing is as follows:
|
||||
|
||||
<blockquote>
|
||||
<pre>
|
||||
% perl -version
|
||||
This is perl, v5.6.0 built for sun4-solaris
|
||||
|
||||
Copyright 1987-2000, Larry Wall
|
||||
|
||||
Perl may be copied only under the terms of either the Artistic License or the
|
||||
GNU General Public License, which may be found in the Perl 5.0 source kit.
|
||||
|
||||
Complete documentation for Perl, including FAQ lists, should be found on
|
||||
this system using `man perl' or `perldoc perl'. If you have access to the
|
||||
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
<p>
|
||||
Due to wide variations in the Perl C API and differences between versions such as the ActivePerl release for Windows,
|
||||
the code generated by SWIG is extremely messy. We have made every attempt to maintain compatibility with
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
int printf(const char *fmt, ...);
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,51 @@
|
|||
# file: runme.py
|
||||
|
||||
from example import *
|
||||
# This file illustrates the proxy class C++ interface generated
|
||||
# by SWIG.
|
||||
|
||||
printf("hello\n")
|
||||
import example
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:"
|
||||
c = example.Circle(10)
|
||||
print " Created circle", c
|
||||
s = example.Square(10)
|
||||
print " Created square", s
|
||||
|
||||
# ----- Access a static member -----
|
||||
|
||||
print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
|
||||
|
||||
# ----- Member data access -----
|
||||
|
||||
# Set the location of the object
|
||||
|
||||
c.x = 20
|
||||
c.y = 30
|
||||
|
||||
s.x = -10
|
||||
s.y = 5
|
||||
|
||||
print "\nHere is their current position:"
|
||||
print " Circle = (%f, %f)" % (c.x,c.y)
|
||||
print " Square = (%f, %f)" % (s.x,s.y)
|
||||
|
||||
# ----- Call some methods -----
|
||||
|
||||
print "\nHere are some properties of the shapes:"
|
||||
for o in [c,s]:
|
||||
print " ", o
|
||||
print " area = ", o.area()
|
||||
print " perimeter = ", o.perimeter()
|
||||
|
||||
print "\nGuess I'll clean up now"
|
||||
|
||||
# Note: this invokes the virtual destructor
|
||||
del c
|
||||
del s
|
||||
|
||||
s = 3
|
||||
print example.cvar.Shape_nshapes,"shapes remain"
|
||||
print "Goodbye"
|
||||
|
||||
name = "%shoot"
|
||||
num = 22
|
||||
printf("Hello %s. Your number is %d\n" % (name, num))
|
||||
print("hello there %s." % name);
|
||||
printf("Your result is 90%.\n")
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
LIBS = -lm
|
||||
SWIGOPT =
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile python_clean
|
||||
rm -f $(TARGET).py
|
||||
|
||||
check: all
|
||||
$(MAKE) -f $(TOP)/Makefile python_run
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
This directory contains a simple example to test weave support for
|
||||
SWIG wrapped objects.
|
||||
|
||||
The weave package provides tools for including C/C++ code in Python
|
||||
code. This offers both another level of optimization to those who need
|
||||
it, and an easy way to modify and extend any supported extension
|
||||
libraries. Weave automatically builds an extension module from the
|
||||
given C/C++ code and runs that. This can result in very significant
|
||||
speedups (of upto 500x) depending on the problem. Weave also supports
|
||||
inlining SWIG-1.3.x wrapped objects.
|
||||
|
||||
The example in this directory requires that weave be installed. Weave
|
||||
is distributed as part of SciPy (http://www.scipy.org). More
|
||||
information on Weave may be had from here:
|
||||
|
||||
http://www.scipy.org/documentation/weave
|
||||
|
||||
As of November 22, 2004, this example only works with weave from CVS.
|
||||
If there is a more recent release of SciPy after this date, it should
|
||||
work fine.
|
||||
|
||||
|
||||
Also, you need to replace the weave file swigptr2.py by the one
|
||||
provided here.
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#ifndef _EXAMPLE_H
|
||||
#define _EXAMPLE_H
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
int x;
|
||||
};
|
||||
|
||||
class Bar {
|
||||
public:
|
||||
int y;
|
||||
};
|
||||
|
||||
class FooBar : public Foo, public Bar {
|
||||
public:
|
||||
int z;
|
||||
};
|
||||
#endif
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
%module(directors="1") example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_vector.i"
|
||||
|
||||
%director Foo;
|
||||
%director Bar;
|
||||
%include "example.h"
|
||||
|
||||
|
||||
%template(VectorBar) std::vector<Bar*>;
|
||||
%template(VectorFoo) std::vector<Foo*>;
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
"""
|
||||
Test weave support for SWIG wrapped objects.
|
||||
|
||||
This example requires that one has weave installed. Weave is
|
||||
distributed as part of SciPy (http://www.scipy.org). More information
|
||||
on Weave may be had from here:
|
||||
|
||||
http://www.scipy.org/documentation/weave
|
||||
|
||||
As of November 22, 2004, this only works with weave from CVS. If
|
||||
there is a more recent release of SciPy after this date, it should
|
||||
work fine.
|
||||
|
||||
"""
|
||||
|
||||
import example
|
||||
import weave
|
||||
from weave import converters
|
||||
from weave import swig2_spec
|
||||
|
||||
# Weave does not support swig2 by default (yet). So add this to the
|
||||
# list of default converters to test.
|
||||
converters.default.insert(0, swig2_spec.swig2_converter())
|
||||
|
||||
def test():
|
||||
""" A simple test case for weave."""
|
||||
a = example.Foo()
|
||||
a.x = 1
|
||||
b = example.Bar()
|
||||
b.y = 2
|
||||
c = example.FooBar()
|
||||
c.x = 1
|
||||
c.y = 2
|
||||
c.z = 3
|
||||
v = example.VectorBar()
|
||||
v.append(b)
|
||||
v.append(c)
|
||||
d = v[0]
|
||||
e = v[1]
|
||||
v = example.VectorFoo()
|
||||
v.append(a)
|
||||
v.append(c)
|
||||
f = v[0]
|
||||
g = v[1]
|
||||
|
||||
code = """
|
||||
std::cout << a->x << std::endl;
|
||||
assert(a->x == 1);
|
||||
std::cout << b->y << std::endl;
|
||||
assert(b->y == 2);
|
||||
std::cout << c->x << std::endl;
|
||||
std::cout << c->y << std::endl;
|
||||
std::cout << c->z << std::endl;
|
||||
assert(c->x == 1);
|
||||
assert(c->y == 2);
|
||||
assert(c->z == 3);
|
||||
std::cout << d->y << std::endl;
|
||||
assert(d->y == 2);
|
||||
std::cout << e->y << std::endl;
|
||||
assert(e->y == 2);
|
||||
std::cout << f->x << std::endl;
|
||||
assert(f->x == 1);
|
||||
std::cout << g->x << std::endl;
|
||||
assert(g->x == 1);
|
||||
"""
|
||||
weave.inline(code, ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
|
||||
include_dirs=['.'],
|
||||
headers=['"example.h"'],
|
||||
verbose=2)
|
||||
|
||||
if __name__ == "__main__":
|
||||
test()
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -20,7 +20,7 @@ extern int gcd(int x, int y);
|
|||
if (TYPE($input) != T_ARRAY) {
|
||||
SWIG_exception(SWIG_ValueError, "Expected an array");
|
||||
}
|
||||
$1 = RARRAY($input)->len;
|
||||
$1 = RARRAY_LEN($input);
|
||||
if ($1 == 0) {
|
||||
SWIG_exception(SWIG_ValueError, "List must contain at least 1 element");
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ extern int gcdmain(int argc, char *argv[]);
|
|||
SWIG_exception(SWIG_ValueError, "Expected a string");
|
||||
}
|
||||
$1 = STR2CSTR($input);
|
||||
$2 = RSTRING($input)->len;
|
||||
$2 = RSTRING_LEN($input);
|
||||
}
|
||||
|
||||
extern int count(char *bytes, int len, char c);
|
||||
|
|
@ -61,7 +61,7 @@ extern int count(char *bytes, int len, char c);
|
|||
SWIG_exception(SWIG_ValueError,"Expected a string");
|
||||
}
|
||||
temp = STR2CSTR($input);
|
||||
$2 = RSTRING($input)->len;
|
||||
$2 = RSTRING_LEN($input);
|
||||
$1 = (char *) malloc($2+1);
|
||||
memmove($1,temp,$2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -312,67 +312,6 @@ is no representation."
|
|||
|
||||
;; Test instances
|
||||
|
||||
#||
|
||||
|
||||
#+ignore
|
||||
(defvar *gifplot-interface*
|
||||
(run-swig (merge-pathnames "Examples/GIFPlot/Interface/gifplot.i"
|
||||
*swig-source-directory*)
|
||||
:directory-search-list (list (merge-pathnames "Examples/GIFPlot/Interface/" *swig-source-directory*))))
|
||||
|
||||
(defvar *simple-gifplot-interface*
|
||||
(run-swig (merge-pathnames "Examples/GIFPlot/Include/gifplot.h"
|
||||
*swig-source-directory*)
|
||||
:directory-search-list (list (merge-pathnames "Examples/GIFPlot/Interface/" *swig-source-directory*))
|
||||
:module "gifplot"))
|
||||
|
||||
(defvar *cplex-glue-directory* #p"/home/mkoeppe/cvs/cplex-glue/")
|
||||
|
||||
(defvar *cplex-glue-interface*
|
||||
(run-swig (merge-pathnames "cplex.i" *cplex-glue-directory*)
|
||||
:directory-search-list (list (merge-pathnames "Lib/guile"
|
||||
*swig-source-directory*)
|
||||
*cplex-glue-directory*)
|
||||
:ignore-errors t))
|
||||
|
||||
|
||||
|
||||
(require 'uffi)
|
||||
|
||||
;;(let ((*uffi-primitive-type-alist* (cons '("Pixel" . :unsigned-int) *uffi-default-primitive-type-alist*)))
|
||||
;; (eval (cons 'progn (compute-uffi-definitions *simple-gifplot-interface*))))
|
||||
|
||||
|
||||
(with-open-file (f "/tmp/swig-uffi.lisp" :direction :output
|
||||
:if-exists :supersede)
|
||||
(let ((*uffi-definitions* '())
|
||||
(*uffi-output* f)
|
||||
(*uffi-primitive-type-alist*
|
||||
(cons '("Pixel" . :unsigned-int) *uffi-default-primitive-type-alist*)))
|
||||
(apply 'handle-node *simple-gifplot-interface*)))
|
||||
|
||||
#+cplex
|
||||
(with-open-file (f "/tmp/swig-uffi.lisp" :direction :output)
|
||||
(let ((*uffi-definitions* '())
|
||||
(*uffi-output* f)
|
||||
(*uffi-primitive-type-alist*
|
||||
(cons '("Pixel" . :unsigned-int) *uffi-default-primitive-type-alist*)))
|
||||
(apply 'handle-node *cplex-glue-interface*)))
|
||||
|
||||
(compile-file "/tmp/swig-uffi.lisp")
|
||||
|
||||
(uffi:load-foreign-library (merge-pathnames "Examples/GIFPlot/libgifplot.a"
|
||||
*swig-source-directory*))
|
||||
|
||||
(load "/tmp/swig-uffi.lisp")
|
||||
|
||||
(load (merge-pathnames "Examples/GIFPlot/Common-Lisp/full/runme.lisp" *swig-source-directory*))
|
||||
|
||||
(action (namestring (merge-pathnames "Examples/GIFPlot/Common-Lisp/full/cmap"
|
||||
*swig-source-directory*)))
|
||||
|
||||
||#
|
||||
|
||||
;;; Link to SWIG itself
|
||||
|
||||
#||
|
||||
|
|
|
|||
|
|
@ -109,6 +109,12 @@ bool SetConstCharArrayStaticString(const char str[], unsigned int number) {
|
|||
char *CharPingPong(char *str) {
|
||||
return str;
|
||||
}
|
||||
char *CharArrayPingPong(char abcstr[]) {
|
||||
return abcstr;
|
||||
}
|
||||
char *CharArrayDimsPingPong(char abcstr[16]) {
|
||||
return abcstr;
|
||||
}
|
||||
|
||||
// variables
|
||||
char *global_char = NULL;
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ CPP_TEST_CASES += \
|
|||
constructor_exception \
|
||||
constructor_explicit \
|
||||
constructor_ignore \
|
||||
constructor_rename \
|
||||
constructor_value \
|
||||
contract \
|
||||
conversion \
|
||||
|
|
@ -198,6 +199,7 @@ CPP_TEST_CASES += \
|
|||
fvirtual \
|
||||
global_namespace \
|
||||
global_ns_arg \
|
||||
global_scope_types \
|
||||
global_vars \
|
||||
grouping \
|
||||
ignore_parameter \
|
||||
|
|
@ -241,6 +243,8 @@ CPP_TEST_CASES += \
|
|||
namespace_typemap \
|
||||
namespace_union \
|
||||
namespace_virtual_method \
|
||||
nspace \
|
||||
nspace_extend \
|
||||
naturalvar \
|
||||
nested_class \
|
||||
nested_comment \
|
||||
|
|
@ -304,6 +308,7 @@ CPP_TEST_CASES += \
|
|||
static_const_member_2 \
|
||||
struct_initialization_cpp \
|
||||
struct_value \
|
||||
symbol_clash \
|
||||
template \
|
||||
template_arg_replace \
|
||||
template_arg_scope \
|
||||
|
|
@ -371,6 +376,7 @@ CPP_TEST_CASES += \
|
|||
template_virtual \
|
||||
template_whitespace \
|
||||
threads \
|
||||
threads_exception \
|
||||
throw_exception \
|
||||
typedef_array_member \
|
||||
typedef_class \
|
||||
|
|
@ -381,9 +387,11 @@ CPP_TEST_CASES += \
|
|||
typedef_scope \
|
||||
typedef_sizet \
|
||||
typedef_struct \
|
||||
typemap_global_scope \
|
||||
typemap_namespace \
|
||||
typemap_ns_using \
|
||||
typemap_numinputs \
|
||||
typemap_template \
|
||||
typemap_out_optimal \
|
||||
typemap_variables \
|
||||
typemap_various \
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
/* % didn't work in SWIG 1.3.40 and earlier. */
|
||||
const int X = 123%7;
|
||||
#define FOO 12 % 6
|
||||
double d_array[12 % 6];
|
||||
#define FOO 12 % 9
|
||||
double d_array[12 % 9];
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ public:
|
|||
|
||||
void ret6(int*& a) {}
|
||||
int*& ret7() {return GlobalIntPtr;}
|
||||
void ret8(int*const& a) {}
|
||||
int*const& ret9() {return GlobalIntPtr;}
|
||||
ReturnValuesTest() : int3(NULL) {}
|
||||
private:
|
||||
ReturnValuesTest& operator=(const ReturnValuesTest&);
|
||||
|
|
@ -112,7 +114,7 @@ int* const globalRet2() {return &GlobalInt;}
|
|||
return b;
|
||||
}
|
||||
|
||||
B const*& cbar(B const*& b) {
|
||||
B *const& cbar(B *const& b) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
Examples/test-suite/constructor_rename.i
Normal file
12
Examples/test-suite/constructor_rename.i
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
%module constructor_rename
|
||||
|
||||
%{
|
||||
struct Foo {
|
||||
Foo() {}
|
||||
};
|
||||
%}
|
||||
|
||||
struct Foo {
|
||||
%rename(RenamedConstructor) Foo();
|
||||
Foo() {}
|
||||
};
|
||||
|
|
@ -69,14 +69,13 @@ run_testcase = \
|
|||
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 && \
|
||||
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
|
||||
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 && cd .. ; \
|
||||
CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \
|
||||
fi
|
||||
|
||||
# Clean: remove testcase directories
|
||||
|
|
|
|||
39
Examples/test-suite/csharp/nspace_extend_runme.cs
Normal file
39
Examples/test-suite/csharp/nspace_extend_runme.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
{
|
||||
// constructors and destructors
|
||||
nspace_extendNamespace.Outer.Inner1.Color color1 = new nspace_extendNamespace.Outer.Inner1.Color();
|
||||
nspace_extendNamespace.Outer.Inner1.Color color = new nspace_extendNamespace.Outer.Inner1.Color(color1);
|
||||
color1.Dispose();
|
||||
color1 = null;
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
nspace_extendNamespace.Outer.Inner1.Color.colorStaticMethod(20.0);
|
||||
nspace_extendNamespace.Outer.Inner1.Color created = nspace_extendNamespace.Outer.Inner1.Color.create();
|
||||
created.Dispose();
|
||||
}
|
||||
{
|
||||
// constructors and destructors
|
||||
nspace_extendNamespace.Outer.Inner2.Color color2 = new nspace_extendNamespace.Outer.Inner2.Color();
|
||||
nspace_extendNamespace.Outer.Inner2.Color color = new nspace_extendNamespace.Outer.Inner2.Color(color2);
|
||||
color2.Dispose();
|
||||
color2 = null;
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
nspace_extendNamespace.Outer.Inner2.Color.colorStaticMethod(20.0);
|
||||
nspace_extendNamespace.Outer.Inner2.Color created = nspace_extendNamespace.Outer.Inner2.Color.create();
|
||||
created.Dispose();
|
||||
|
||||
// Same class different namespaces
|
||||
nspace_extendNamespace.Outer.Inner1.Color col1 = new nspace_extendNamespace.Outer.Inner1.Color();
|
||||
nspace_extendNamespace.Outer.Inner2.Color col2 = nspace_extendNamespace.Outer.Inner2.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
}
|
||||
}
|
||||
}
|
||||
76
Examples/test-suite/csharp/nspace_runme.cs
Normal file
76
Examples/test-suite/csharp/nspace_runme.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using System;
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
// constructors and destructors
|
||||
nspaceNamespace.Outer.Inner1.Color color1 = new nspaceNamespace.Outer.Inner1.Color();
|
||||
nspaceNamespace.Outer.Inner1.Color color = new nspaceNamespace.Outer.Inner1.Color(color1);
|
||||
color1.Dispose();
|
||||
color1 = null;
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
nspaceNamespace.Outer.Inner1.Color.colorStaticMethod(20.0);
|
||||
nspaceNamespace.Outer.Inner1.Color created = nspaceNamespace.Outer.Inner1.Color.create();
|
||||
created.Dispose();
|
||||
|
||||
// class enums
|
||||
nspaceNamespace.Outer.SomeClass someClass = new nspaceNamespace.Outer.SomeClass();
|
||||
nspaceNamespace.Outer.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel();
|
||||
if (channel != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission)
|
||||
throw new ApplicationException("Transmission wrong");
|
||||
|
||||
// class anonymous enums
|
||||
int val1 = nspaceNamespace.Outer.Inner1.Color.ColorEnumVal1;
|
||||
int val2 = nspaceNamespace.Outer.Inner1.Color.ColorEnumVal2;
|
||||
if (val1 != 0 || val2 != 0x22)
|
||||
throw new ApplicationException("ColorEnumVal wrong");
|
||||
|
||||
// instance member variables
|
||||
color.instanceMemberVariable = 123;
|
||||
if (color.instanceMemberVariable != 123)
|
||||
throw new ApplicationException("instance member variable failed");
|
||||
|
||||
// static member variables
|
||||
nspaceNamespace.Outer.Inner1.Color.staticMemberVariable = 789;
|
||||
if (nspaceNamespace.Outer.Inner1.Color.staticMemberVariable != 789)
|
||||
throw new ApplicationException("static member variable failed");
|
||||
if (nspaceNamespace.Outer.Inner1.Color.staticConstMemberVariable != 222)
|
||||
throw new ApplicationException("static const member variable failed");
|
||||
if (nspaceNamespace.Outer.Inner1.Color.staticConstEnumMemberVariable != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission)
|
||||
throw new ApplicationException("static const enum member variable failed");
|
||||
|
||||
// check globals in a namespace don't get mangled with the nspaceNamespace option
|
||||
nspaceNamespace.nspace.namespaceFunction(color);
|
||||
nspaceNamespace.nspace.namespaceVar = 111;
|
||||
if (nspaceNamespace.nspace.namespaceVar != 111)
|
||||
throw new ApplicationException("global var failed");
|
||||
|
||||
// Same class different namespaces
|
||||
nspaceNamespace.Outer.Inner1.Color col1 = new nspaceNamespace.Outer.Inner1.Color();
|
||||
nspaceNamespace.Outer.Inner2.Color col2 = nspaceNamespace.Outer.Inner2.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
|
||||
// global enums
|
||||
nspaceNamespace.Outer.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
|
||||
if (outerChannel1 != nspaceNamespace.Outer.Inner1.Channel.Transmission1)
|
||||
throw new ApplicationException("Transmission1 wrong");
|
||||
nspaceNamespace.Outer.Inner2.Channel outerChannel2 = someClass.GetInner2Channel();
|
||||
if (outerChannel2 != nspaceNamespace.Outer.Inner2.Channel.Transmission2)
|
||||
throw new ApplicationException("Transmission2 wrong");
|
||||
|
||||
// turn feature off / ignoring
|
||||
nspaceNamespace.Outer.nspace ns = new nspaceNamespace.Outer.nspace();
|
||||
ns.Dispose();
|
||||
nspaceNamespace.NoNSpacePlease nons = new nspaceNamespace.NoNSpacePlease();
|
||||
nons.Dispose();
|
||||
|
||||
// Derived class
|
||||
nspaceNamespace.Outer.Inner3.Blue blue3 = new nspaceNamespace.Outer.Inner3.Blue();
|
||||
blue3.blueInstanceMethod();
|
||||
nspaceNamespace.Outer.Inner4.Blue blue4 = new nspaceNamespace.Outer.Inner4.Blue();
|
||||
blue4.blueInstanceMethod();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
%module extend_template
|
||||
%module xxx
|
||||
%module xxx // should be ignored
|
||||
namespace oss { // this doesn't
|
||||
%extend Foo<0> {
|
||||
int test1(int x) { return x; }
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ class Klass6 {};
|
|||
class Klass7 {};
|
||||
|
||||
struct KlassMethods {
|
||||
static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, Klass7*& pr) {}
|
||||
static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*& pr) {}
|
||||
static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, ::Klass7*const& pr) {}
|
||||
static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*const& pr) {}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
@ -28,8 +28,8 @@ class XYZ7 {};
|
|||
}
|
||||
|
||||
struct XYZMethods {
|
||||
static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, Space::XYZ7*& pr) {}
|
||||
static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*& pr) {}
|
||||
static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, ::Space::XYZ7*const& pr) {}
|
||||
static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*const& pr) {}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
44
Examples/test-suite/global_scope_types.i
Normal file
44
Examples/test-suite/global_scope_types.i
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
%module global_scope_types
|
||||
|
||||
// no constructor/destructor wrappers as they do not use global scope operator which we are trying to test here
|
||||
%nodefaultctor Dingaling;
|
||||
%nodefaultdtor Dingaling;
|
||||
|
||||
%inline %{
|
||||
struct Dingaling {};
|
||||
typedef Dingaling DINGALING;
|
||||
template <typename T> struct MyTemplate {
|
||||
T tt(T t) { return t; }
|
||||
T& ttr(T& t) { return t; }
|
||||
};
|
||||
|
||||
#ifndef SWIG
|
||||
// This is added so that the code will not compile, if the global scope operator on Dingaling is omitted in the generated code
|
||||
namespace Spac {
|
||||
class Dingaling {
|
||||
Dingaling();
|
||||
Dingaling(const Dingaling& t);
|
||||
Dingaling& operator=(const Dingaling t);
|
||||
};
|
||||
}
|
||||
using namespace Spac;
|
||||
#endif
|
||||
|
||||
namespace Spac {
|
||||
|
||||
struct Ting {};
|
||||
typedef Ting TING;
|
||||
|
||||
class Test {
|
||||
public:
|
||||
void something(::Dingaling t, ::Dingaling* pt, ::Dingaling& rt, const ::Dingaling& crt) {}
|
||||
void tsomething(MyTemplate< ::Dingaling > t1, MyTemplate< const ::Dingaling* > t2) {}
|
||||
// void usomething(::MyTemplate< ::DINGALING > t3, ::MyTemplate< ::DINGALING *> t4) {} // needs fixing
|
||||
void nothing(::Spac::Ting*, ::Spac::TING&) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void funcptrtest( void (*)(::Dingaling) ) {}
|
||||
%}
|
||||
|
||||
|
|
@ -37,26 +37,28 @@ CPP_TEST_CASES = \
|
|||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
SWIGOPT += -package $*
|
||||
JAVA_PACKAGE = $*
|
||||
SWIGOPT += -package $(JAVA_PACKAGE)
|
||||
INTERFACEDIR = ../../
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
# none!
|
||||
nspace.%: JAVA_PACKAGE = $*Package
|
||||
nspace_extend.%: JAVA_PACKAGE = $*Package
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
+(cd $* && $(swig_and_compile_cpp))
|
||||
+(cd $(JAVA_PACKAGE) && $(swig_and_compile_cpp))
|
||||
$(run_testcase)
|
||||
|
||||
%.ctest:
|
||||
$(setup)
|
||||
+(cd $* && $(swig_and_compile_c))
|
||||
+(cd $(JAVA_PACKAGE) && $(swig_and_compile_c))
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+(cd $* && $(swig_and_compile_multi_cpp))
|
||||
+(cd $(JAVA_PACKAGE) && $(swig_and_compile_multi_cpp))
|
||||
$(run_testcase)
|
||||
|
||||
# Makes a directory for the testcase if it does not exist
|
||||
|
|
@ -66,24 +68,24 @@ setup = \
|
|||
else \
|
||||
echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
|
||||
fi; \
|
||||
if [ ! -d $* ]; then \
|
||||
mkdir $*; \
|
||||
if [ ! -d $(JAVA_PACKAGE) ]; then \
|
||||
mkdir $(JAVA_PACKAGE); \
|
||||
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 && cd .. && \
|
||||
cd $(JAVA_PACKAGE) && $(COMPILETOOL) $(JAVAC) -classpath . `find . -name "*.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; \
|
||||
env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme; \
|
||||
fi
|
||||
|
||||
# Clean: remove testcase directories
|
||||
%.clean:
|
||||
@if [ -d $* ]; then \
|
||||
rm -rf $*; \
|
||||
@if [ -d $(JAVA_PACKAGE) ]; then \
|
||||
rm -rf $(JAVA_PACKAGE); \
|
||||
fi
|
||||
|
||||
clean:
|
||||
|
|
|
|||
44
Examples/test-suite/java/nspace_extend_runme.java
Normal file
44
Examples/test-suite/java/nspace_extend_runme.java
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// This tests changes the package name from nspace to nspacePackage as javac can't seem to resolve classes and packages having the same name
|
||||
public class nspace_extend_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("nspace_extend");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
{
|
||||
// constructors and destructors
|
||||
nspace_extendPackage.Outer.Inner1.Color color1 = new nspace_extendPackage.Outer.Inner1.Color();
|
||||
nspace_extendPackage.Outer.Inner1.Color color = new nspace_extendPackage.Outer.Inner1.Color(color1);
|
||||
color1.delete();
|
||||
color1 = null;
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
nspace_extendPackage.Outer.Inner1.Color.colorStaticMethod(20.0);
|
||||
nspace_extendPackage.Outer.Inner1.Color created = nspace_extendPackage.Outer.Inner1.Color.create();
|
||||
}
|
||||
{
|
||||
// constructors and destructors
|
||||
nspace_extendPackage.Outer.Inner2.Color color2 = new nspace_extendPackage.Outer.Inner2.Color();
|
||||
nspace_extendPackage.Outer.Inner2.Color color = new nspace_extendPackage.Outer.Inner2.Color(color2);
|
||||
color2.delete();
|
||||
color2 = null;
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
nspace_extendPackage.Outer.Inner2.Color.colorStaticMethod(20.0);
|
||||
nspace_extendPackage.Outer.Inner2.Color created = nspace_extendPackage.Outer.Inner2.Color.create();
|
||||
|
||||
// Same class different namespaces
|
||||
nspace_extendPackage.Outer.Inner1.Color col1 = new nspace_extendPackage.Outer.Inner1.Color();
|
||||
nspace_extendPackage.Outer.Inner2.Color col2 = nspace_extendPackage.Outer.Inner2.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
}
|
||||
}
|
||||
}
|
||||
80
Examples/test-suite/java/nspace_runme.java
Normal file
80
Examples/test-suite/java/nspace_runme.java
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
// This tests changes the package name from nspace to nspacePackage as javac can't seem to resolve classes and packages having the same name
|
||||
public class nspace_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("nspace");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
// constructors and destructors
|
||||
nspacePackage.Outer.Inner1.Color color1 = new nspacePackage.Outer.Inner1.Color();
|
||||
nspacePackage.Outer.Inner1.Color color = new nspacePackage.Outer.Inner1.Color(color1);
|
||||
color1.delete();
|
||||
color1 = null;
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
nspacePackage.Outer.Inner1.Color.colorStaticMethod(20.0);
|
||||
nspacePackage.Outer.Inner1.Color created = nspacePackage.Outer.Inner1.Color.create();
|
||||
|
||||
// class enums
|
||||
nspacePackage.Outer.SomeClass someClass = new nspacePackage.Outer.SomeClass();
|
||||
nspacePackage.Outer.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel();
|
||||
if (channel != nspacePackage.Outer.Inner1.Color.Channel.Transmission)
|
||||
throw new RuntimeException("Transmission wrong");
|
||||
|
||||
// class anonymous enums
|
||||
int val1 = nspacePackage.Outer.Inner1.Color.ColorEnumVal1;
|
||||
int val2 = nspacePackage.Outer.Inner1.Color.ColorEnumVal2;
|
||||
if (val1 != 0 || val2 != 0x22)
|
||||
throw new RuntimeException("ColorEnumVal wrong");
|
||||
|
||||
// instance member variables
|
||||
color.setInstanceMemberVariable(123);
|
||||
if (color.getInstanceMemberVariable() != 123)
|
||||
throw new RuntimeException("instance member variable failed");
|
||||
|
||||
// static member variables
|
||||
nspacePackage.Outer.Inner1.Color.setStaticMemberVariable(789);
|
||||
if (nspacePackage.Outer.Inner1.Color.getStaticMemberVariable() != 789)
|
||||
throw new RuntimeException("static member variable failed");
|
||||
if (nspacePackage.Outer.Inner1.Color.staticConstMemberVariable != 222)
|
||||
throw new RuntimeException("static const member variable failed");
|
||||
if (nspacePackage.Outer.Inner1.Color.staticConstEnumMemberVariable != nspacePackage.Outer.Inner1.Color.Channel.Transmission)
|
||||
throw new RuntimeException("static const enum member variable failed");
|
||||
|
||||
// Same class different namespaces
|
||||
nspacePackage.Outer.Inner1.Color col1 = new nspacePackage.Outer.Inner1.Color();
|
||||
nspacePackage.Outer.Inner2.Color col2 = nspacePackage.Outer.Inner2.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
|
||||
// check globals in a namespace don't get mangled with the nspacePackage option
|
||||
nspacePackage.nspace.namespaceFunction(color);
|
||||
nspacePackage.nspace.setNamespaceVar(111);
|
||||
if (nspacePackage.nspace.getNamespaceVar() != 111)
|
||||
throw new RuntimeException("global var failed");
|
||||
|
||||
// global enums
|
||||
nspacePackage.Outer.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
|
||||
if (outerChannel1 != nspacePackage.Outer.Inner1.Channel.Transmission1)
|
||||
throw new RuntimeException("Transmission1 wrong");
|
||||
nspacePackage.Outer.Inner2.Channel outerChannel2 = someClass.GetInner2Channel();
|
||||
if (outerChannel2 != nspacePackage.Outer.Inner2.Channel.Transmission2)
|
||||
throw new RuntimeException("Transmission2 wrong");
|
||||
|
||||
// turn feature off / ignoring
|
||||
nspacePackage.Outer.nspace ns = new nspacePackage.Outer.nspace();
|
||||
nspacePackage.NoNSpacePlease nons = new nspacePackage.NoNSpacePlease();
|
||||
|
||||
// Derived class
|
||||
nspacePackage.Outer.Inner3.Blue blue3 = new nspacePackage.Outer.Inner3.Blue();
|
||||
blue3.blueInstanceMethod();
|
||||
nspacePackage.Outer.Inner4.Blue blue4 = new nspacePackage.Outer.Inner4.Blue();
|
||||
blue4.blueInstanceMethod();
|
||||
}
|
||||
}
|
||||
|
|
@ -16,21 +16,21 @@
|
|||
%typemap(jstype) Space::Classic ** " Classic "
|
||||
%typemap(javain) Space::Classic ** "Classic.getCPtr($javainput)"
|
||||
|
||||
// Default typemaps for pass by value, ref, pointer and pointer reference should use pgcpp
|
||||
// Default typemaps for pass by value, ref, pointer and pointer const reference should use pgcpp
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
struct Classic {
|
||||
Classic() {}
|
||||
Classic(Classic c1, Classic& c2, Classic* c3, Classic*& c4, Classic** c5) {}
|
||||
Classic(const Classic c1, const Classic& c2, const Classic* c3, const Classic*& c4, const Classic** c5, bool b) {}
|
||||
Classic(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {}
|
||||
Classic(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5, bool b) {}
|
||||
|
||||
void method(Classic c1, Classic& c2, Classic* c3, Classic*& c4, Classic** c5) {}
|
||||
void methodconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*& c4, const Classic** c5) {}
|
||||
void method(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {}
|
||||
void methodconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5) {}
|
||||
};
|
||||
|
||||
void function(Classic c1, Classic& c2, Classic* c3, Classic*& c4, Classic** c5) {}
|
||||
void functionconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*& c4, const Classic** c5) {}
|
||||
void function(Classic c1, Classic& c2, Classic* c3, Classic*const& c4, Classic** c5) {}
|
||||
void functionconst(const Classic c1, const Classic& c2, const Classic* c3, const Classic*const& c4, const Classic** c5) {}
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ Klass& reftest(Klass& k) {
|
|||
k.append(" reftest");
|
||||
return k;
|
||||
}
|
||||
Klass*& pointerreftest(Klass*& k) {
|
||||
Klass *const& pointerreftest(Klass *const& k) {
|
||||
k->append(" pointerreftest");
|
||||
return k;
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ std::string overload_rawbyptr(int i) { return "int"; }
|
|||
std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; }
|
||||
|
||||
std::string overload_rawbyptrref(int i) { return "int"; }
|
||||
std::string overload_rawbyptrref(Klass *&k) { return "rawbyptrref"; }
|
||||
std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; }
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ Klass& reftest(Klass& k) {
|
|||
k.append(" reftest");
|
||||
return k;
|
||||
}
|
||||
Klass*& pointerreftest(Klass*& k) {
|
||||
Klass *const& pointerreftest(Klass *const& k) {
|
||||
k->append(" pointerreftest");
|
||||
return k;
|
||||
}
|
||||
|
|
@ -275,7 +275,7 @@ std::string overload_rawbyptr(int i) { return "int"; }
|
|||
std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; }
|
||||
|
||||
std::string overload_rawbyptrref(int i) { return "int"; }
|
||||
std::string overload_rawbyptrref(Klass *&k) { return "rawbyptrref"; }
|
||||
std::string overload_rawbyptrref(Klass *const&k) { return "rawbyptrref"; }
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -74,12 +74,6 @@ const std::vector<Struct *> & vecstructptr(const std::vector<Struct *> & vec) {
|
|||
const std::vector<const Struct *> & vecstructconstptr(const std::vector<const Struct *> & vec) { return vec; }
|
||||
%}
|
||||
|
||||
#if defined(SWIGCSHARP)
|
||||
// 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
|
||||
|
||||
#if !defined(SWIGR)
|
||||
%template(IntPtrVector) std::vector<int *>;
|
||||
%template(IntConstPtrVector) std::vector<const int *>;
|
||||
|
|
@ -88,7 +82,6 @@ const std::vector<const Struct *> & vecstructconstptr(const std::vector<const St
|
|||
%template(StructPtrVector) std::vector<Struct *>;
|
||||
%template(StructConstPtrVector) std::vector<const Struct *>;
|
||||
|
||||
#if !defined(SWIGTCL)
|
||||
%inline {
|
||||
struct MyClass {};
|
||||
typedef MyClass *MyClassPtr;
|
||||
|
|
@ -106,7 +99,6 @@ const std::vector<const Struct *> & vecstructconstptr(const std::vector<const St
|
|||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SWIGRUBY)
|
||||
%template(LanguageVector) std::vector< swig::LANGUAGE_OBJ >;
|
||||
|
|
|
|||
12
Examples/test-suite/lua/char_strings_runme.lua
Normal file
12
Examples/test-suite/lua/char_strings_runme.lua
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
require("import") -- the import fn
|
||||
import("char_strings") -- import code
|
||||
|
||||
assert (char_strings.CharPingPong("hi there") == "hi there")
|
||||
assert (char_strings.CharPingPong(nil) == nil)
|
||||
|
||||
assert (char_strings.CharArrayPingPong("hi there") == "hi there")
|
||||
assert (char_strings.CharArrayPingPong(nil) == nil)
|
||||
|
||||
assert (char_strings.CharArrayDimsPingPong("hi there") == "hi there")
|
||||
assert (char_strings.CharArrayDimsPingPong(nil) == nil)
|
||||
|
||||
|
|
@ -75,3 +75,8 @@ int wget(SpamPtr f) {
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
// Was causing runtime error in Ruby
|
||||
%include <std_vector.i>
|
||||
%template(IntVector) std::vector<int>;
|
||||
|
||||
|
|
|
|||
103
Examples/test-suite/nspace.i
Normal file
103
Examples/test-suite/nspace.i
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
// Test the nspace feature
|
||||
%module nspace
|
||||
|
||||
// nspace feature only supported by these languages
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
|
||||
%nspace;
|
||||
%nonspace Outer::Inner2::NoNSpacePlease;
|
||||
|
||||
%copyctor;
|
||||
%ignore Outer::Inner2::Color::Color();
|
||||
|
||||
#define CONSTANT100 100
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace Outer {
|
||||
class nspace {
|
||||
};
|
||||
namespace Inner1 {
|
||||
enum Channel { Diffuse, Specular = 0x10, Transmission1 };
|
||||
enum { ColorEnumVal1, ColorEnumVal2 = 0x11, ColorEnumVal3 };
|
||||
|
||||
struct Color {
|
||||
static Color* create() { return new Color(); }
|
||||
|
||||
enum Channel { Diffuse, Specular = 0x20, Transmission };
|
||||
enum { ColorEnumVal1, ColorEnumVal2 = 0x22, ColorEnumVal3 };
|
||||
|
||||
int instanceMemberVariable;
|
||||
static int staticMemberVariable;
|
||||
static const int staticConstMemberVariable = 222;
|
||||
static const Channel staticConstEnumMemberVariable = Transmission;
|
||||
void colorInstanceMethod(double d) {}
|
||||
static void colorStaticMethod(double d) {}
|
||||
}; // Color
|
||||
int Color::staticMemberVariable = 0;
|
||||
|
||||
Color namespaceFunction(Color k) { return k; }
|
||||
int namespaceVar = 0;
|
||||
} // Inner1
|
||||
|
||||
namespace Inner2 {
|
||||
enum Channel { Diffuse, Specular = 0x30, Transmission2 };
|
||||
|
||||
struct Color {
|
||||
Color() : instanceMemberVariable(0) {}
|
||||
static Color* create() { return new Color(); }
|
||||
|
||||
enum Channel { Diffuse, Specular = 0x40, Transmission };
|
||||
enum { ColorEnumVal1, ColorEnumVal2 = 0x33, ColorEnumVal3 };
|
||||
|
||||
int instanceMemberVariable;
|
||||
static int staticMemberVariable;
|
||||
static const int staticConstMemberVariable = 333;
|
||||
static const Channel staticConstEnumMemberVariable = Transmission;
|
||||
void colorInstanceMethod(double d) {}
|
||||
static void colorStaticMethod(double d) {}
|
||||
void colors(const Inner1::Color& col1a,
|
||||
const Outer::Inner1::Color& col1b,
|
||||
const Color &col2a,
|
||||
const Inner2::Color& col2b,
|
||||
const Outer::Inner2::Color& col2c) {}
|
||||
}; // Color
|
||||
int Color::staticMemberVariable = 0;
|
||||
class NoNSpacePlease {};
|
||||
} // Inner2
|
||||
|
||||
// Derived class
|
||||
namespace Inner3 {
|
||||
struct Blue : Inner2::Color {
|
||||
void blueInstanceMethod() {}
|
||||
};
|
||||
}
|
||||
namespace Inner4 {
|
||||
struct Blue : Inner2::Color {
|
||||
void blueInstanceMethod() {}
|
||||
};
|
||||
}
|
||||
|
||||
class SomeClass {
|
||||
public:
|
||||
Inner1::Color::Channel GetInner1ColorChannel() { return Inner1::Color::Transmission; }
|
||||
Inner2::Color::Channel GetInner2ColorChannel() { return Inner2::Color::Transmission; }
|
||||
Inner1::Channel GetInner1Channel() { return Inner1::Transmission1; }
|
||||
Inner2::Channel GetInner2Channel() { return Inner2::Transmission2; }
|
||||
}; // SomeClass
|
||||
|
||||
} // Outer
|
||||
|
||||
namespace Outer {
|
||||
struct MyWorldPart2 {};
|
||||
}
|
||||
|
||||
struct GlobalClass {
|
||||
void gmethod() {}
|
||||
};
|
||||
|
||||
void test_classes(Outer::SomeClass c, Outer::Inner2::Color cc) {}
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
50
Examples/test-suite/nspace_extend.i
Normal file
50
Examples/test-suite/nspace_extend.i
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// Test the nspace feature and %extend
|
||||
%module nspace_extend
|
||||
|
||||
// nspace feature only supported by these languages
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
|
||||
%nspace;
|
||||
|
||||
%extend Outer::Inner1::Color {
|
||||
Color() { return new Outer::Inner1::Color(); }
|
||||
virtual ~Color() { delete $self; }
|
||||
static Color* create() { return new Outer::Inner1::Color(); }
|
||||
Color(const Color& other) { return new Outer::Inner1::Color(other); }
|
||||
|
||||
void colorInstanceMethod(double d) {}
|
||||
static void colorStaticMethod(double d) {}
|
||||
}
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace Outer {
|
||||
namespace Inner1 {
|
||||
struct Color {
|
||||
};
|
||||
}
|
||||
|
||||
namespace Inner2 {
|
||||
struct Color {
|
||||
};
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
%extend Outer::Inner2::Color {
|
||||
Color() { return new Outer::Inner2::Color(); }
|
||||
~Color() { delete $self; }
|
||||
static Color* create() { return new Outer::Inner2::Color(); }
|
||||
Color(const Color& other) { return new Outer::Inner2::Color(other); }
|
||||
|
||||
void colorInstanceMethod(double d) {}
|
||||
static void colorStaticMethod(double d) {}
|
||||
void colors(const Inner1::Color& col1a,
|
||||
const Outer::Inner1::Color& col1b,
|
||||
const Color &col2a,
|
||||
const Inner2::Color& col2b,
|
||||
const Outer::Inner2::Color& col2c) {}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -29,10 +29,10 @@ struct Struct {
|
|||
static Struct *pInstance;
|
||||
};
|
||||
|
||||
void set(Struct *& s) {
|
||||
void set(Struct *const& s) {
|
||||
Struct::instance = *s;
|
||||
}
|
||||
Struct *& get() {
|
||||
Struct *const& get() {
|
||||
return Struct::pInstance;
|
||||
}
|
||||
%}
|
||||
|
|
|
|||
3
Examples/test-suite/python/constructor_rename_runme.py
Normal file
3
Examples/test-suite/python/constructor_rename_runme.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from constructor_rename import *
|
||||
|
||||
x = RenamedConstructor()
|
||||
36
Examples/test-suite/python/threads_exception_runme.py
Executable file
36
Examples/test-suite/python/threads_exception_runme.py
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
import threads_exception
|
||||
|
||||
t = threads_exception.Test()
|
||||
try:
|
||||
t.unknown()
|
||||
except RuntimeError,e:
|
||||
pass
|
||||
|
||||
try:
|
||||
t.simple()
|
||||
except RuntimeError,e:
|
||||
if e.args[0] != 37:
|
||||
raise RuntimeError
|
||||
|
||||
try:
|
||||
t.message()
|
||||
except RuntimeError,e:
|
||||
if e.args[0] != "I died.":
|
||||
raise RuntimeError
|
||||
|
||||
try:
|
||||
t.hosed()
|
||||
except threads_exception.Exc,e:
|
||||
if e.code != 42:
|
||||
raise RuntimeError
|
||||
if e.msg != "Hosed":
|
||||
raise RuntimeError
|
||||
|
||||
for i in range(1,4):
|
||||
try:
|
||||
t.multi(i)
|
||||
except RuntimeError,e:
|
||||
pass
|
||||
except threads_exception.Exc,e:
|
||||
pass
|
||||
|
||||
28
Examples/test-suite/symbol_clash.i
Normal file
28
Examples/test-suite/symbol_clash.i
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
%module symbol_clash
|
||||
|
||||
// ::Vector and ::Text::Vector were incorrectly clashing in the target language symbol tables
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
|
||||
#if defined(SWIGJAVA)
|
||||
%include "enumtypeunsafe.swg"
|
||||
#elif defined(SWIGCSHARP)
|
||||
%include "enumsimple.swg"
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
class Vector
|
||||
{
|
||||
};
|
||||
|
||||
namespace Text
|
||||
{
|
||||
enum Preference
|
||||
{
|
||||
Raster,
|
||||
Vector
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
#endif
|
||||
54
Examples/test-suite/threads_exception.i
Executable file
54
Examples/test-suite/threads_exception.i
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
// Throw a lot of exceptions
|
||||
|
||||
// The Python runtime tests were previously failing with the -threads option on Windows due to SWIG_PYTHON_THREAD_BEGIN_ALLOW not being within the try block.
|
||||
|
||||
%module(threads="1") threads_exception
|
||||
|
||||
%{
|
||||
struct A {};
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
#include <string>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
|
||||
class Exc {
|
||||
public:
|
||||
Exc(int c, const char *m) {
|
||||
code = c;
|
||||
strncpy(msg,m,255);
|
||||
}
|
||||
int code;
|
||||
char msg[256];
|
||||
};
|
||||
|
||||
class Test {
|
||||
public:
|
||||
int simple() throw(int) {
|
||||
throw(37);
|
||||
return 1;
|
||||
}
|
||||
int message() throw(const char *) {
|
||||
throw("I died.");
|
||||
return 1;
|
||||
}
|
||||
int hosed() throw(Exc) {
|
||||
throw(Exc(42,"Hosed"));
|
||||
return 1;
|
||||
}
|
||||
int unknown() throw(A*) {
|
||||
static A a;
|
||||
throw &a;
|
||||
return 1;
|
||||
}
|
||||
int multi(int x) throw(int, const char *, Exc) {
|
||||
if (x == 1) throw(37);
|
||||
if (x == 2) throw("Bleah!");
|
||||
if (x == 3) throw(Exc(42,"No-go-diggy-die"));
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
%}
|
||||
215
Examples/test-suite/typemap_global_scope.i
Normal file
215
Examples/test-suite/typemap_global_scope.i
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
%module typemap_global_scope
|
||||
|
||||
// Test global scope operator :: for typemaps. Previously SWIG would not use a typemap that did not specify the global scope
|
||||
// operator for a type that did have it, and vice-versa.
|
||||
|
||||
%typemap(in) SWIGTYPE "_this_will_not_compile_SWIGTYPE_ \"$type\""
|
||||
%typemap(in) const SWIGTYPE & "_this_will_not_compile_const_SWIGTYPE_REF_ \"$type\""
|
||||
%typemap(in) enum SWIGTYPE "_this_will_not_compile_enum_SWIGTYPE_ \"$type\""
|
||||
%typemap(in) const enum SWIGTYPE & "_this_will_not_compile_const_enum_SWIGTYPE_REF_ \"$type\""
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Structs
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
%typemap(in) Test1, ::Test2, Space::Test3, ::Space::Test4 "/*in typemap for $type*/"
|
||||
%typemap(in) const Test1 &, const ::Test2 &, const Space::Test3 &, const ::Space::Test4 & "/*in typemap for $type*/"
|
||||
%inline %{
|
||||
struct Test1 {};
|
||||
struct Test2 {};
|
||||
namespace Space {
|
||||
struct Test3 {};
|
||||
struct Test4 {};
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
void test1a(Test1 t, const Test1 &tt) {}
|
||||
void test1b(::Test1 t, const ::Test1 &tt) {}
|
||||
|
||||
void test2a(Test2 t, const Test2 &tt) {}
|
||||
void test2b(::Test2 t, const ::Test2 &tt) {}
|
||||
|
||||
void test3a(Space::Test3 t, const Space::Test3 &tt) {}
|
||||
void test3b(::Space::Test3 t, const ::Space::Test3 &tt) {}
|
||||
namespace Space {
|
||||
void test3c(Space::Test3 t, const Space::Test3 &tt) {}
|
||||
void test3d(::Space::Test3 t, const ::Space::Test3 &tt) {}
|
||||
void test3e(Test3 t, const Test3 &tt) {}
|
||||
}
|
||||
|
||||
void test4a(Space::Test4 t, const Space::Test4 &tt) {}
|
||||
void test4b(::Space::Test4 t, const ::Space::Test4 &tt) {}
|
||||
namespace Space {
|
||||
void test4c(Space::Test4 t, const Space::Test4 &tt) {}
|
||||
void test4d(::Space::Test4 t, const ::Space::Test4 &tt) {}
|
||||
void test4e(Test4 t, const Test4 &tt) {}
|
||||
}
|
||||
%}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Templates
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
%inline %{
|
||||
struct XX {};
|
||||
%}
|
||||
|
||||
%typemap(in) TemplateTest1< ::XX >, ::TemplateTest2< ::XX >, Space::TemplateTest3< ::XX >, ::Space::TemplateTest4< ::XX > "/* in typemap for $type */"
|
||||
%typemap(in) const TemplateTest1< XX > &, const ::TemplateTest2< XX > &, const Space::TemplateTest3< XX > &, const ::Space::TemplateTest4< XX > & "/* in typemap for $type */"
|
||||
%inline %{
|
||||
template<typename T> struct TemplateTest1 { T m_t; };
|
||||
template<typename T> struct TemplateTest2 { T m_t; };
|
||||
namespace Space {
|
||||
template<typename T> struct TemplateTest3 { T m_t; };
|
||||
template<typename T> struct TemplateTest4 { T m_t; };
|
||||
}
|
||||
%}
|
||||
|
||||
%template(TemplateTest1XX) TemplateTest1< ::XX >;
|
||||
%template(TemplateTest2XX) TemplateTest2< ::XX >;
|
||||
%template(TemplateTest3XX) Space::TemplateTest3< ::XX >;
|
||||
%template(TemplateTest4XX) Space::TemplateTest4< ::XX >;
|
||||
|
||||
%inline %{
|
||||
void test_template_1a(TemplateTest1< ::XX > t, const TemplateTest1< ::XX > &tt) {}
|
||||
void test_template_1b(::TemplateTest1< ::XX > t, const ::TemplateTest1< ::XX > &tt) {}
|
||||
|
||||
void test_template_2a(TemplateTest2< ::XX > t, const TemplateTest2< ::XX > &tt) {}
|
||||
void test_template_2b(::TemplateTest2< ::XX > t, const ::TemplateTest2< ::XX > &tt) {}
|
||||
|
||||
void test_template_3a(Space::TemplateTest3< ::XX > t, const Space::TemplateTest3< ::XX > &tt) {}
|
||||
void test_template_3b(::Space::TemplateTest3< ::XX > t, const ::Space::TemplateTest3< ::XX > &tt) {}
|
||||
namespace Space {
|
||||
void test_template_3c(Space::TemplateTest3< ::XX > t, const Space::TemplateTest3< ::XX > &tt) {}
|
||||
void test_template_3d(::Space::TemplateTest3< ::XX > t, const ::Space::TemplateTest3< ::XX > &tt) {}
|
||||
void test_template_3e(TemplateTest3< ::XX > t, const TemplateTest3< ::XX > &tt) {}
|
||||
}
|
||||
|
||||
void test_template_4a(Space::TemplateTest4< ::XX > t, const Space::TemplateTest4< ::XX > &tt) {}
|
||||
void test_template_4b(::Space::TemplateTest4< ::XX > t, const ::Space::TemplateTest4< ::XX > &tt) {}
|
||||
namespace Space {
|
||||
void test_template_4c(Space::TemplateTest4< ::XX > t, const Space::TemplateTest4< ::XX > &tt) {}
|
||||
void test_template_4d(::Space::TemplateTest4< ::XX > t, const ::Space::TemplateTest4< ::XX > &tt) {}
|
||||
void test_template_4e(TemplateTest4< ::XX > t, const TemplateTest4< ::XX > &tt) {}
|
||||
}
|
||||
%}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Enums
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
%typemap(in) Enum1, ::Enum2, Space::Enum3, ::Space::Enum4 "/*in typemap for $type*/"
|
||||
%typemap(in) const Enum1 &, const ::Enum2 &, const Space::Enum3 &, const ::Space::Enum4 & "/*in typemap for $type*/"
|
||||
%inline %{
|
||||
enum Enum1 { enum_1 };
|
||||
enum Enum2 { enum_2 };
|
||||
namespace Space {
|
||||
enum Enum3 { enum_3 };
|
||||
enum Enum4 { enum_4 };
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
void test_enum_1a(Enum1 t, const Enum1 &tt) {}
|
||||
void test_enum_1b(::Enum1 t, const ::Enum1 &tt) {}
|
||||
|
||||
void test_enum_2a(Enum2 t, const Enum2 &tt) {}
|
||||
void test_enum_2b(::Enum2 t, const ::Enum2 &tt) {}
|
||||
|
||||
void test_enum_3a(Space::Enum3 t, const Space::Enum3 &tt) {}
|
||||
void test_enum_3b(::Space::Enum3 t, const ::Space::Enum3 &tt) {}
|
||||
namespace Space {
|
||||
void test_enum_3c(Space::Enum3 t, const Space::Enum3 &tt) {}
|
||||
void test_enum_3d(::Space::Enum3 t, const ::Space::Enum3 &tt) {}
|
||||
void test_enum_3e(Enum3 t, const Enum3 &tt) {}
|
||||
}
|
||||
|
||||
void test_enum_4a(Space::Enum4 t, const Space::Enum4 &tt) {}
|
||||
void test_enum_4b(::Space::Enum4 t, const ::Space::Enum4 &tt) {}
|
||||
namespace Space {
|
||||
void test_enum_4c(Space::Enum4 t, const Space::Enum4 &tt) {}
|
||||
void test_enum_4d(::Space::Enum4 t, const ::Space::Enum4 &tt) {}
|
||||
void test_enum_4e(Enum4 t, const Enum4 &tt) {}
|
||||
}
|
||||
%}
|
||||
|
||||
#if 0
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Enums with enum specified in typemap
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
%typemap(in) enum Mune1, enum ::Mune2, enum Space::Mune3, enum ::Space::Mune4 "/*in typemap for $type*/"
|
||||
%typemap(in) const enum Mune1 &, const enum ::Mune2 &, const enum Space::Mune3 &, const enum ::Space::Mune4 & "/*in typemap for $type*/"
|
||||
%inline %{
|
||||
enum Mune1 { mune_1 };
|
||||
enum Mune2 { mune_2 };
|
||||
namespace Space {
|
||||
enum Mune3 { mune_3 };
|
||||
enum Mune4 { mune_4 };
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
void test_mune_1a(Mune1 t, const Mune1 &tt) {}
|
||||
void test_mune_1b(::Mune1 t, const ::Mune1 &tt) {}
|
||||
|
||||
void test_mune_2a(Mune2 t, const Mune2 &tt) {}
|
||||
void test_mune_2b(::Mune2 t, const ::Mune2 &tt) {}
|
||||
|
||||
void test_mune_3a(Space::Mune3 t, const Space::Mune3 &tt) {}
|
||||
void test_mune_3b(::Space::Mune3 t, const ::Space::Mune3 &tt) {}
|
||||
namespace Space {
|
||||
void test_mune_3c(Space::Mune3 t, const Space::Mune3 &tt) {}
|
||||
void test_mune_3d(::Space::Mune3 t, const ::Space::Mune3 &tt) {}
|
||||
void test_mune_3e(Mune3 t, const Mune3 &tt) {}
|
||||
}
|
||||
|
||||
void test_mune_4a(Space::Mune4 t, const Space::Mune4 &tt) {}
|
||||
void test_mune_4b(::Space::Mune4 t, const ::Space::Mune4 &tt) {}
|
||||
namespace Space {
|
||||
void test_mune_4c(Space::Mune4 t, const Space::Mune4 &tt) {}
|
||||
void test_mune_4d(::Space::Mune4 t, const ::Space::Mune4 &tt) {}
|
||||
void test_mune_4e(Mune4 t, const Mune4 &tt) {}
|
||||
}
|
||||
%}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Enums with enum specified in type
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
%typemap(in) Nemu1, ::Nemu2, Space::Nemu3, ::Space::Nemu4 "/*in typemap for $type*/"
|
||||
%typemap(in) const Nemu1 &, const ::Nemu2 &, const Space::Nemu3 &, const ::Space::Nemu4 & "/*in typemap for $type*/"
|
||||
%inline %{
|
||||
enum Nemu1 { nemu_1 };
|
||||
enum Nemu2 { nemu_2 };
|
||||
namespace Space {
|
||||
enum Nemu3 { nemu_3 };
|
||||
enum Nemu4 { nemu_4 };
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
void test_nemu_1a(enum Nemu1 t, const enum Nemu1 &tt) {}
|
||||
void test_nemu_1b(enum ::Nemu1 t, const enum ::Nemu1 &tt) {}
|
||||
|
||||
void test_nemu_2a(enum Nemu2 t, const enum Nemu2 &tt) {}
|
||||
void test_nemu_2b(enum ::Nemu2 t, const enum ::Nemu2 &tt) {}
|
||||
|
||||
void test_nemu_3a(enum Space::Nemu3 t, const enum Space::Nemu3 &tt) {}
|
||||
void test_nemu_3b(enum ::Space::Nemu3 t, const enum ::Space::Nemu3 &tt) {}
|
||||
namespace Space {
|
||||
void test_nemu_3c(enum Space::Nemu3 t, const enum Space::Nemu3 &tt) {}
|
||||
void test_nemu_3d(enum ::Space::Nemu3 t, const enum ::Space::Nemu3 &tt) {}
|
||||
void test_nemu_3e(enum Nemu3 t, const enum Nemu3 &tt) {}
|
||||
}
|
||||
|
||||
void test_nemu_4a(enum Space::Nemu4 t, const enum Space::Nemu4 &tt) {}
|
||||
void test_nemu_4b(enum ::Space::Nemu4 t, const enum ::Space::Nemu4 &tt) {}
|
||||
namespace Space {
|
||||
void test_nemu_4c(enum Space::Nemu4 t, const enum Space::Nemu4 &tt) {}
|
||||
void test_nemu_4d(enum ::Space::Nemu4 t, const enum ::Space::Nemu4 &tt) {}
|
||||
void test_nemu_4e(enum Nemu4 t, const enum Nemu4 &tt) {}
|
||||
}
|
||||
%}
|
||||
#endif
|
||||
34
Examples/test-suite/typemap_template.i
Normal file
34
Examples/test-suite/typemap_template.i
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
%module typemap_template
|
||||
|
||||
/* Test bug in 1.3.40 where the presence of a generic/unspecialized typemap caused the incorrect specialized typemap to be used */
|
||||
|
||||
%typemap(in) SWIGTYPE "/*_this_will_not_compile_SWIGTYPE_ \"$type\" */ "
|
||||
%typemap(in) const SWIGTYPE & "/*_this_will_not_compile_const_SWIGTYPE_REF_\"$type\" */ "
|
||||
|
||||
%typemap(in) const TemplateTest1 & {$1 = (TemplateTest1<YY> *)0; /* in typemap generic for $type */}
|
||||
%typemap(in) const TemplateTest1< ZZ > & {$1 = (TemplateTest1<ZZ> *)0; /* in typemap ZZ for $type */}
|
||||
%typemap(in) const TemplateTest1< int > & {$1 = (TemplateTest1<int> *)0; /* in typemap int for $type */}
|
||||
|
||||
%inline %{
|
||||
template<typename T> struct TemplateTest1 {
|
||||
void setT(const TemplateTest1& t) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
struct YY {};
|
||||
struct ZZ {};
|
||||
%}
|
||||
|
||||
|
||||
%template(TTYY) TemplateTest1< YY >;
|
||||
%template(TTZZ) TemplateTest1< ZZ >;
|
||||
%template(TTint) TemplateTest1< int >;
|
||||
|
||||
%inline %{
|
||||
void extratest(const TemplateTest1< YY > &t,
|
||||
const TemplateTest1< ZZ > &tt,
|
||||
const TemplateTest1< int > &ttt)
|
||||
{}
|
||||
%}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue