Merged trunk up to revision 12551
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12552 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
93499e12af
160 changed files with 3204 additions and 1238 deletions
20
ANNOUNCE
20
ANNOUNCE
|
|
@ -1,8 +1,8 @@
|
|||
*** ANNOUNCE: SWIG 2.0.2 (in progress) ***
|
||||
*** ANNOUNCE: SWIG 2.0.3 (in progress) ***
|
||||
|
||||
http://www.swig.org
|
||||
|
||||
We're pleased to announce SWIG-2.0.1, the latest SWIG release.
|
||||
We're pleased to announce SWIG-2.0.3, the latest SWIG release.
|
||||
|
||||
What is SWIG?
|
||||
=============
|
||||
|
|
@ -10,22 +10,22 @@ What is SWIG?
|
|||
SWIG is a software development tool that reads C/C++ header files and
|
||||
generates the wrapper code needed to make C and C++ code accessible
|
||||
from other languages including Perl, Python, Tcl, Ruby, PHP, Java,
|
||||
Scheme (Guile, MzScheme, CHICKEN), Ocaml, Lua, Pike, C#, Modula-3, Octave, R,
|
||||
Common Lisp (CLISP, Allegro CL, CFFI, UFFI). SWIG can also export its parse
|
||||
tree in the form of XML and Lisp s-expressions. Major applications of
|
||||
SWIG include generation of scripting language extension modules, rapid
|
||||
prototyping, testing, and user interface development for large C/C++
|
||||
systems.
|
||||
Scheme (Guile, MzScheme, CHICKEN), D, Ocaml, Lua, Pike, C#, Modula-3,
|
||||
Octave, R, Common Lisp (CLISP, Allegro CL, CFFI, UFFI). SWIG can also
|
||||
export its parse tree in the form of XML and Lisp s-expressions. Major
|
||||
applications of SWIG include generation of scripting language extension
|
||||
modules, rapid prototyping, testing, and user interface development for
|
||||
large C/C++ systems.
|
||||
|
||||
Availability
|
||||
============
|
||||
The release is available for download on Sourceforge at
|
||||
|
||||
http://prdownloads.sourceforge.net/swig/swig-2.0.1.tar.gz
|
||||
http://prdownloads.sourceforge.net/swig/swig-2.0.3.tar.gz
|
||||
|
||||
A Windows version is also available at
|
||||
|
||||
http://prdownloads.sourceforge.net/swig/swigwin-2.0.1.zip
|
||||
http://prdownloads.sourceforge.net/swig/swigwin-2.0.3.zip
|
||||
|
||||
Please report problems with this release to the swig-devel mailing list,
|
||||
details at http://www.swig.org/mail.html.
|
||||
|
|
|
|||
163
CHANGES
163
CHANGES
|
|
@ -3,6 +3,169 @@ SWIG (Simplified Wrapper and Interface Generator)
|
|||
See the CHANGES.current file for changes in the current version.
|
||||
See the RELEASENOTES file for a summary of changes in each release.
|
||||
|
||||
Version 2.0.2 (20 February 2011)
|
||||
================================
|
||||
|
||||
2011-02-19: wsfulton
|
||||
[PHP] Add missing INPUT, OUTPUT and INOUT typemaps in the typemaps.i library
|
||||
for primitive reference types as well as signed char * and bool *.
|
||||
|
||||
2011-02-19: olly
|
||||
[PHP] Address bug in PHP on some platforms/architectures which
|
||||
results in zend_error_noreturn() not being available using
|
||||
SWIG_ZEND_ERROR_NORETURN which defaults to zend_error_noreturn but
|
||||
can be overridden when building the module by passing
|
||||
-DSWIG_ZEND_ERROR_NORETURN=zend_error to the compiler. This may
|
||||
result in compiler warnings, but should at least allow a module
|
||||
to be built on those platforms/architectures (SF#3166423).
|
||||
|
||||
2011-02-18: wsfulton
|
||||
Fix #3184549 - vararg functions and function overloading when using the -fastdispatch option.
|
||||
|
||||
2011-02-18: olly
|
||||
[PHP] An overloaded method which can return an object or a
|
||||
primitive type no longer causes SWIG to segfault. Reported by Paul
|
||||
Colby in SF#3168531.
|
||||
|
||||
2011-02-18: olly
|
||||
[PHP] Fix invalid erase during iteration of std::map in generated
|
||||
director code. Reported by Cory Bennett in SF#3175820.
|
||||
|
||||
2011-02-17: wsfulton
|
||||
Preprocessing now warns if extra tokens appear after #else and #end.
|
||||
|
||||
2011-02-16: wsfulton
|
||||
Fix #1653092 Preprocessor does not error out when #elif is missing an expression.
|
||||
This and other cases of missing preprocessor expressions now result in an error.
|
||||
|
||||
2011-02-14: wsfulton
|
||||
[Ocaml] Apply patch #3151788 from Joel Reymont. Brings Ocaml support up to date
|
||||
(ver 3.11 and 3.12), including std::string.
|
||||
|
||||
2011-02-13: wsfulton
|
||||
[Ruby] Apply patch #3176274 from James Masters - typecheck typemap for time_t.
|
||||
|
||||
2011-02-13: wsfulton
|
||||
Apply patch #3171793 from szager - protected director methods failing when -fvirtual is used.
|
||||
|
||||
2011-02-13: wsfulton
|
||||
Fix #1927852 - #include directives don't preprocess the file passed to it. The fix is for
|
||||
#include with -importall or -includeall, %include and %import, for example:
|
||||
#define FILENAME "abc.h"
|
||||
%include FILENAME
|
||||
|
||||
2011-02-12: wsfulton
|
||||
Fix #1940536, overactive preprocessor which was expanding defined(...) outside of #if and #elif
|
||||
preprocessor directives.
|
||||
|
||||
2011-02-05: wsfulton
|
||||
[MzScheme] SF #2942899 Add user supplied documentation to help getting started with MzScheme.
|
||||
Update chapter name to MzScheme/Racket accounting for the rename of MzScheme to Racket.
|
||||
|
||||
2011-02-05: wsfulton
|
||||
[C#] SF #3085906 - Possible fix running test-suite on Mac OSX.
|
||||
|
||||
2011-02-05: wsfulton
|
||||
SF #3173367 Better information during configure about Boost prerequisite for running
|
||||
the test-suite.
|
||||
|
||||
2011-02-05: wsfulton
|
||||
SF #3127633 Fix infinite loop in recursive typedef resolution.
|
||||
|
||||
2011-02-04: wsfulton
|
||||
[R] SF #3168676 Fix %rename not working for member variables and methods.
|
||||
|
||||
2011-02-04: wsfulton
|
||||
[clisp] SF #3148200 Fix segfault parsing nested unions.
|
||||
|
||||
2011-02-01: wsfulton
|
||||
[C#] Directors - a call to a method being defined in the base class, not
|
||||
overridden in a subclass, but again overridden in a class derived from
|
||||
the first subclass was not being dispatched correctly to the most derived class.
|
||||
See director_alternating.i for an example.
|
||||
|
||||
2011-02-01: wsfulton
|
||||
[C#, Java] Any 'using' statements in the protected section of a class were previously
|
||||
ignored with director protected (dirprot) mode.
|
||||
|
||||
2011-01-30: wsfulton
|
||||
Fix overloading with const pointer reference (SWIGTYPE *const&) parameters for a
|
||||
number of scripting languages.
|
||||
|
||||
2011-01-17: wsfulton
|
||||
New warning for smart pointers if only some of the classes in the inheritance
|
||||
chain are marked as smart pointer, eg, %shared_ptr should be used for all classes
|
||||
in an inheritance hierarchy, so this new warning highlights code where this is
|
||||
not the case.
|
||||
|
||||
example.i:12: Warning 520: Base class 'A' of 'B' is not similarly marked as a smart pointer.
|
||||
example.i:16: Warning 520: Derived class 'C' of 'B' is not similarly marked as a smart pointer.
|
||||
|
||||
2011-01-14: wsfulton
|
||||
Added some missing multi-argument typemaps: (char *STRING, size_t LENGTH) and
|
||||
(char *STRING, int LENGTH). Documentation for this updated. Java patch from
|
||||
Volker Grabsch.
|
||||
|
||||
2011-01-11: iant
|
||||
Require Go version 7077 or later.
|
||||
|
||||
2010-12-30: klickverbot
|
||||
[C#, D, Java] Check for collision of parameter names with target
|
||||
language keywords when generating the director glue code.
|
||||
|
||||
The situation in which the generated could would previously be
|
||||
invalid is illustrated in the new 'director_keywords' test case.
|
||||
|
||||
2010-12-23: wsfulton
|
||||
[C#] Fix $csinput special variable not being expanded for csvarin typemaps
|
||||
when used for global variables. Reported by Vadim Zeitlin.
|
||||
|
||||
2010-12-14: wsfulton
|
||||
Fix $basemangle expansion in array typemaps. For example if type is int *[3],
|
||||
$basemangle expands to _p_int.
|
||||
|
||||
2010-12-07: iant
|
||||
Check that we are using a sufficiently new version of the
|
||||
6g or 8g Go compiler during configure time. If not, disable Go.
|
||||
Minimum version is now 6707.
|
||||
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2010-12-06: wsfulton
|
||||
Fix #3127394 - use of network paths on Windows/MSys.
|
||||
|
||||
2010-11-18: klickverbot
|
||||
[D] Added the D language module.
|
||||
|
||||
2010-11-12: vadz
|
||||
Fix handling of multiple regex-using %renames attached to the same
|
||||
declaration. For example, now
|
||||
|
||||
%rename("%(regex/^Set(.*)/put\\1/)s") "";
|
||||
%rename("%(regex/^Get(.*)/get\\1/)s") "";
|
||||
|
||||
works as expected whereas before only the last anonymous rename was
|
||||
taken into account.
|
||||
|
||||
2010-10-17: drjoe
|
||||
[R] Fix failure in overloaded functions which was breaking
|
||||
QuantLib-SWIG
|
||||
|
||||
2010-10-14: olly
|
||||
[PHP] Allow compilation on non-conforming Microsoft C++ compilers
|
||||
which don't accept: return function_returning_void();
|
||||
Reported by Frank Vanden Berghen on the SWIG mailing list.
|
||||
|
||||
2010-10-12: wsfulton
|
||||
Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by
|
||||
Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being
|
||||
incorrectly treated as opaque types.
|
||||
|
||||
Also fixes #2958781 and some other type problems due to better typedef resolution, eg
|
||||
std::vector<T *>::value_type didn't resolve to T * when it should have. The mangled type
|
||||
was incorrectly SWIGTYPE_std__vectorT_Test_p_std__allocatorT_Test_p_t_t__value_type and now
|
||||
it is correctly SWIGTYPE_p_Test.
|
||||
|
||||
Version 2.0.1 (4 October 2010)
|
||||
==============================
|
||||
|
||||
|
|
|
|||
111
CHANGES.current
111
CHANGES.current
|
|
@ -2,88 +2,55 @@ This file contains the changes for the current release.
|
|||
See the CHANGES file for changes in older releases.
|
||||
See the RELEASENOTES file for a summary of changes in each release.
|
||||
|
||||
Version 2.0.2 (in progress)
|
||||
Version 2.0.3 (in progress)
|
||||
===========================
|
||||
|
||||
2011-02-01: wsfulton
|
||||
[C#] Directors - a call to a method being defined in the base class, not
|
||||
overridden in a subclass, but again overridden in a class derived from
|
||||
the first subclass was not being dispatched correctly to the most derived class.
|
||||
See director_alternating.i for an example.
|
||||
2011-03-21: vadz
|
||||
[build] Allow setting PCRE_CFLAGS and PCRE_LIBS to override the values returned by
|
||||
pcre-config, e.g. to allow using a static version of PCRE library.
|
||||
|
||||
2011-02-01: wsfulton
|
||||
[C#, Java] Any 'using' statements in the protected section of a class were previously
|
||||
ignored with director protected (dirprot) mode.
|
||||
2011-03-17: wsfulton
|
||||
[UTL] Add missing headers in generated STL wrappers to fix compilation with gcc-4.6.
|
||||
|
||||
2011-01-30: wsfulton
|
||||
Fix overloading with const pointer reference (SWIGTYPE *const&) parameters for a
|
||||
number of scripting languages.
|
||||
2011-03-17: wsfulton
|
||||
Fix regression introduced in swig-2.0.2 where filenames with spaces were not found
|
||||
when used with %include and %import. Reported by Shane Liesegang.
|
||||
|
||||
2011-01-17: wsfulton
|
||||
New warning for smart pointers if only some of the classes in the inheritance
|
||||
chain are marked as smart pointer, eg, %shared_ptr should be used for all classes
|
||||
in an inheritance hierarchy, so this new warning highlights code where this is
|
||||
not the case.
|
||||
2011-03-15: wsfulton
|
||||
[UTL] Fix overloading when using const char[], problem reported by David Maxwell.
|
||||
Similarly for char[ANY] and const char[ANY].
|
||||
|
||||
example.i:12: Warning 520: Base class 'A' of 'B' is not similarly marked as a smart pointer.
|
||||
example.i:16: Warning 520: Derived class 'C' of 'B' is not similarly marked as a smart pointer.
|
||||
2011-03-15: wsfulton
|
||||
[C#] Apply patch #3212624 fixing std::map Keys property.
|
||||
|
||||
2011-01-14: wsfulton
|
||||
Added some missing multi-argument typemaps: (char *STRING, size_t LENGTH) and
|
||||
(char *STRING, int LENGTH). Documentation for this updated. Java patch from
|
||||
Volker Grabsch.
|
||||
2011-03-14: olly
|
||||
[PHP] Fix handling of overloaded methods/functions where some
|
||||
return void and others don't - whether this worked or not depended
|
||||
on the order they were encountered in (SF#3208299).
|
||||
|
||||
2011-03-13: klickverbot
|
||||
[D] Extended support for C++ namespaces (nspace feature).
|
||||
|
||||
2011-01-11: iant
|
||||
Require Go version 7077 or later.
|
||||
2011-03-12: olly
|
||||
[PHP] Fix sharing of type information between multiple SWIG-wrapped
|
||||
modules (SF#3202463).
|
||||
|
||||
2010-12-30: klickverbot
|
||||
[C#, D, Java] Check for collision of parameter names with target
|
||||
language keywords when generating the director glue code.
|
||||
|
||||
The situation in which the generated could would previously be
|
||||
invalid is illustrated in the new 'director_keywords' test case.
|
||||
2011-03-09: wsfulton
|
||||
[Python] Fix SF #3194294 - corner case bug when 'NULL' is used as the default value
|
||||
for a primitive type parameter in a method declaration.
|
||||
|
||||
2010-12-23: wsfulton
|
||||
[C#] Fix $csinput special variable not being expanded for csvarin typemaps
|
||||
when used for global variables. Reported by Vadim Zeitlin.
|
||||
2011-03-07: olly
|
||||
[PHP] Don't use zend_error_noreturn() for cases where the function
|
||||
returns void - now this issue can only matter if you have a function
|
||||
or method which is directed and returns non-void.
|
||||
|
||||
2010-12-14: wsfulton
|
||||
Fix $basemangle expansion in array typemaps. For example if type is int *[3],
|
||||
$basemangle expands to _p_int.
|
||||
2011-03-06: olly
|
||||
[PHP] Add casts to the typemaps for long long and unsigned long
|
||||
long to avoid issues when they are used with shorter types via
|
||||
%apply.
|
||||
|
||||
2010-12-07: iant
|
||||
Check that we are using a sufficiently new version of the
|
||||
6g or 8g Go compiler during configure time. If not, disable Go.
|
||||
Minimum version is now 6707.
|
||||
2011-03-02: wsfulton
|
||||
Templated smart pointers overloaded with both const and non const operator-> generated uncompilable
|
||||
code when the pointee was a class with either public member variables or static methods.
|
||||
Regression in 2.0.x reported as working in 1.3.40 by xantares on swig-user mailing list.
|
||||
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2010-12-06: wsfulton
|
||||
Fix #3127394 - use of network paths on Windows/MSys.
|
||||
|
||||
2010-11-18: klickverbot
|
||||
[D] Added the D language module.
|
||||
|
||||
2010-11-12: vadz
|
||||
Fix handling of multiple regex-using %renames attached to the same
|
||||
declaration. For example, now
|
||||
|
||||
%rename("%(regex/^Set(.*)/put\\1/)s") "";
|
||||
%rename("%(regex/^Get(.*)/get\\1/)s") "";
|
||||
|
||||
works as expected whereas before only the last anonymous rename was
|
||||
taken into account.
|
||||
|
||||
2010-10-17: drjoe
|
||||
[R] Fix failure in overloaded functions which was breaking
|
||||
QuantLib-SWIG
|
||||
|
||||
2010-10-14: olly
|
||||
[PHP] Allow compilation on non-conforming Microsoft C++ compilers
|
||||
which don't accept: return function_returning_void();
|
||||
Reported by Frank Vanden Berghen on the SWIG mailing list.
|
||||
|
||||
2010-10-12: wsfulton
|
||||
Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by
|
||||
Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being
|
||||
incorrectly treated as opaque types.
|
||||
|
|
|
|||
|
|
@ -900,6 +900,7 @@
|
|||
<li><a href="Java.html#Java_simple_pointers">Simple pointers</a>
|
||||
<li><a href="Java.html#Java_c_arrays">Wrapping C arrays with Java arrays</a>
|
||||
<li><a href="Java.html#Java_unbounded_c_arrays">Unbounded C Arrays</a>
|
||||
<li><a href="Java.html#Java_binary_char">Binary data vs Strings</a>
|
||||
<li><a href="Java.html#Java_heap_allocations">Overriding new and delete to allocate from Java heap</a>
|
||||
</ul>
|
||||
<li><a href="Java.html#Java_typemaps">Java typemaps</a>
|
||||
|
|
@ -1063,12 +1064,14 @@
|
|||
</div>
|
||||
<!-- INDEX -->
|
||||
|
||||
<h3><a href="Mzscheme.html#Mzscheme">27 SWIG and MzScheme</a></h3>
|
||||
<h3><a href="Mzscheme.html#Mzscheme">27 SWIG and MzScheme/Racket</a></h3>
|
||||
|
||||
<!-- INDEX -->
|
||||
<div class="sectiontoc">
|
||||
<ul>
|
||||
<li><a href="Mzscheme.html#MzScheme_nn2">Creating native MzScheme structures</a>
|
||||
<li><a href="Mzscheme.html#MzScheme_nn2">Creating native structures</a>
|
||||
<li><a href="Mzscheme.html#MzScheme_simple">Simple example</a>
|
||||
<li><a href="Mzscheme.html#MzScheme_external_docs">External documentation</a>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- INDEX -->
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
<li><a href="#D_directors">D Directors</a>
|
||||
<li><a href="#D_other_features">Other features</a>
|
||||
<ul>
|
||||
<li><a href="#D_nspace">Extended namespace support (<tt>nspace</tt>)</a></li>
|
||||
<li><a href="#D_native_pointer_support">Native pointer support</a>
|
||||
<li><a href="#D_operator_overloading">Operator overloading</a>
|
||||
<li><a href="#D_test_suite">Running the test-suite</a>
|
||||
|
|
@ -187,6 +188,12 @@
|
|||
<p>There are two other variants available, <tt>$&dclassname</tt> and <tt>$*dclassname</tt>. The former adds a level of indirection, while the latter removes one. For instance, when wrapping <tt>Foo **</tt>, <tt>$*dclassname</tt> would be replaced by the proxy class name corresponding to <tt>Foo *</tt>.</p>
|
||||
</dd>
|
||||
|
||||
<dt><tt>$dclazzname</tt> (C#: <tt>$csclazzname</tt>)</dt>
|
||||
<dd>
|
||||
<p>This special variable expands the fully qualified C++ class into the package name, if used by the <a href="SWIGPlus.html#SWIGPlus_nspace"><tt>nspace</tt> feature</a>, and the proxy class name, mangled for use as a function name. For example, <tt>Namespace1::Namespace2::Klass</tt> is expanded into <tt>Namespace1_Namespace2_Klass_</tt>.</p>
|
||||
<p>This special variable might be useful for calling certain functions in the wrapper layer (e.g. upcast wrappers) which are mangled like this.</p>
|
||||
</dd>
|
||||
|
||||
<dt><tt>$null</tt></dt>
|
||||
<dd><p>In code inserted into the generated C/C++ wrapper functions, this variable is replaced by either <tt>0</tt> or nothing at all, depending on whether the function has a return value or not. It can be used to bail out early e.g. in case of errors (<tt>return $null;</tt>).</p></dd>
|
||||
|
||||
|
|
@ -249,7 +256,7 @@ SomeClass bar() {
|
|||
<p>This macro is only valid inside the <tt><a href="D.html#D_class_code_typemaps">dconstructor</a></tt> typemap and contains the value of the <tt>dconstructor</tt> typemap attribute if the currently wrapped class has directors enabled.</p>
|
||||
<p>This is how the default <tt>dconstructor</tt> typemap looks like (you usually do not want to specify a custom one):</p>
|
||||
<div class="code"><pre>
|
||||
%typemap(dconstructor, excode=SWIGEXCODE,
|
||||
%typemap(dconstructor, excode=SWIGEXCODE,
|
||||
directorconnect="\n swigDirectorConnect();") SWIGTYPE {
|
||||
this($imcall, true);$excode$directorconnect
|
||||
}
|
||||
|
|
@ -331,7 +338,7 @@ struct A {
|
|||
<dd><p>Additional code to be emitted to the imports section of the intermediary D module (the <a href="D.html#D_importtype">$importtype</a> macro can be used here). You probably want to use this in conjunction with the <tt>imdmodulecode</tt> pragma.</p></dd>
|
||||
|
||||
<dt><tt>%pragma(d) proxydmodulecode</tt></dt>
|
||||
<dd><p>Just like <tt>proxydmodulecode</tt>, the argument is copied to the proxy D module (if SWIG is in <a href="D.html#D_splitproxy">split proxy mode</a>, it is emitted to the main proxy D module only).</p></dd>
|
||||
<dd><p>Just like <tt>proxydmodulecode</tt>, the argument is copied to the proxy D module (if SWIG is in <a href="D.html#D_splitproxy">split proxy mode</a> and/or the <tt>nspace</tt> feature is used, it is emitted to the main proxy D module only).</p></dd>
|
||||
|
||||
<dt><tt>%pragma(d) globalproxyimports</tt></dt>
|
||||
<dd>
|
||||
|
|
@ -379,10 +386,13 @@ struct A {
|
|||
<H2><a name="D_other_features"></a>20.8 Other features</H2>
|
||||
|
||||
|
||||
<p>The <a href="SWIGPlus.html#SWIGPlus_nspace"><tt>nspace</tt></a> feature of SWIG is not yet supported for D - all class modules are written to the same package, regardless of which C++ namespace they are in.</p>
|
||||
<H3><a name="D_nspace"></a>20.8.1 Extended namespace support (<tt>nspace</tt>)</H3>
|
||||
|
||||
|
||||
<H3><a name="D_native_pointer_support"></a>20.8.1 Native pointer support</H3>
|
||||
<p>By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the <a href="SWIGPlus.html#SWIGPlus_nspace"><tt>nspace</tt></a> feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, <em>free</em> variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.</p>
|
||||
|
||||
|
||||
<H3><a name="D_native_pointer_support"></a>20.8.2 Native pointer support</H3>
|
||||
|
||||
|
||||
<p>Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a »primtive type« below.</p>
|
||||
|
|
@ -394,7 +404,7 @@ struct A {
|
|||
<p>To determine if a type should be considered primitive, the <tt>cprimitive</tt> attribute on its <tt>dtype</tt> attribute is used. For example, the <tt>dtype</tt> typemap for <tt>float</tt> has <tt>cprimitive="1"</tt>, so the code from the <tt>nativepointer</tt> attribute is taken into account e.g. for <tt>float **</tt> or the function pointer <tt>float (*)(float *)</tt>.</p>
|
||||
|
||||
|
||||
<H3><a name="D_operator_overloading"></a>20.8.2 Operator overloading</H3>
|
||||
<H3><a name="D_operator_overloading"></a>20.8.3 Operator overloading</H3>
|
||||
|
||||
|
||||
<p>The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:</p>
|
||||
|
|
@ -406,7 +416,7 @@ struct A {
|
|||
<p>There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, <tt>[]</tt>, in combination with assignments - while <tt>operator []</tt> in C++ simply returns a reference which is then written to, D resorts to a separate <tt>opIndexAssign</tt> method -, or implicit casting (which was introduced in D2 via <tt>alias this</tt>). Despite the lack of automatic support, manually handling these cases should be perfectly possible.</p>
|
||||
|
||||
|
||||
<H3><a name="D_test_suite"></a>20.8.3 Running the test-suite</H3>
|
||||
<H3><a name="D_test_suite"></a>20.8.4 Running the test-suite</H3>
|
||||
|
||||
|
||||
<p>As with any other language, the SWIG test-suite can be built for D using the <tt>*-d-test-suite</tt> targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional <tt>D_VERSION</tt> variable, e.g. <tt>make check-d-test-suite D_VERSION=2</tt>.</p>
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@
|
|||
<li><a href="#Java_simple_pointers">Simple pointers</a>
|
||||
<li><a href="#Java_c_arrays">Wrapping C arrays with Java arrays</a>
|
||||
<li><a href="#Java_unbounded_c_arrays">Unbounded C Arrays</a>
|
||||
<li><a href="#Java_binary_char">Binary data vs Strings</a>
|
||||
<li><a href="#Java_heap_allocations">Overriding new and delete to allocate from Java heap</a>
|
||||
</ul>
|
||||
<li><a href="#Java_typemaps">Java typemaps</a>
|
||||
|
|
@ -4401,7 +4402,8 @@ well suited for applications in which you need to create buffers,
|
|||
package binary data, etc.
|
||||
</p>
|
||||
|
||||
<H3><a name="Java_binary_char"></a>Binary data vs Strings</H3>
|
||||
<H3><a name="Java_binary_char"></a>23.8.5 Binary data vs Strings</H3>
|
||||
|
||||
|
||||
<p>
|
||||
By default SWIG handles <tt>char *</tt> as a string but there is a handy multi-argument typemap available as mentioned in <a href="Library.html#Library_nn10">Passing binary data</a>.
|
||||
|
|
@ -4444,7 +4446,7 @@ len: 5 data: 68 69 0 6a 6b
|
|||
</pre></div>
|
||||
|
||||
|
||||
<H3><a name="Java_heap_allocations"></a>23.8.5 Overriding new and delete to allocate from Java heap</H3>
|
||||
<H3><a name="Java_heap_allocations"></a>23.8.6 Overriding new and delete to allocate from Java heap</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -2,17 +2,19 @@
|
|||
<!-- Hand-written HTML -->
|
||||
<html>
|
||||
<head>
|
||||
<title>SWIG and MzScheme</title>
|
||||
<title>SWIG and MzScheme/Racket</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
|
||||
<body bgcolor="#ffffff">
|
||||
|
||||
<H1><a name="Mzscheme"></a>27 SWIG and MzScheme</H1>
|
||||
<H1><a name="Mzscheme"></a>27 SWIG and MzScheme/Racket</H1>
|
||||
<!-- INDEX -->
|
||||
<div class="sectiontoc">
|
||||
<ul>
|
||||
<li><a href="#MzScheme_nn2">Creating native MzScheme structures</a>
|
||||
<li><a href="#MzScheme_nn2">Creating native structures</a>
|
||||
<li><a href="#MzScheme_simple">Simple example</a>
|
||||
<li><a href="#MzScheme_external_docs">External documentation</a>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- INDEX -->
|
||||
|
|
@ -20,9 +22,9 @@
|
|||
|
||||
|
||||
<p>
|
||||
This section contains information on SWIG's support of MzScheme.
|
||||
This section contains information on SWIG's support of Racket, formally known as MzScheme.
|
||||
|
||||
<H2><a name="MzScheme_nn2"></a>27.1 Creating native MzScheme structures</H2>
|
||||
<H2><a name="MzScheme_nn2"></a>27.1 Creating native structures</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -63,8 +65,116 @@ Then in scheme, you can use regular struct access procedures like
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<H2><a name="MzScheme_simple"></a>27.2 Simple example</H2>
|
||||
|
||||
|
||||
<p>
|
||||
That's pretty much it. It works with nested structs as well.
|
||||
A few examples are available in the Examples/mzscheme directory.
|
||||
The code and log of a session using SWIG below should help getting started.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
C header file:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
// example.h
|
||||
int fact(int n);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
C source code:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
// File: example.c
|
||||
#include "example.h"
|
||||
|
||||
int fact(int n) {
|
||||
if (n < 0) { /* This should probably return an error, but this is simpler */
|
||||
return 0;
|
||||
}
|
||||
if (n == 0) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
/* testing for overflow would be a good idea here */
|
||||
return n * fact(n-1);
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
SWIG interface file:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
/* File: example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
int fact(int n);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
The session below using the above files is on an OS X machine, but the points to be made are more general. On OS X, libtool is the tool which creates libraries, which are named .dylib, rather than .so on other unixes, or .dll on Windows.
|
||||
</p>
|
||||
|
||||
<div class="shell">
|
||||
<pre>
|
||||
% swig -mzscheme -declaremodule example.i
|
||||
% gcc -c -m32 -o example.o example.c # force 32-bit object file (mzscheme is 32-bit only)
|
||||
% libtool -dynamic -o libexample.dylib example.o # make it into a library
|
||||
% ls # what've we got so far?
|
||||
example.c example.o
|
||||
example.h example_wrap.c
|
||||
example.i libexample.dylib*
|
||||
% mzc --cgc --cc example_wrap.c # compile the wrapping code
|
||||
% LDFLAGS="-L. -lexample" mzc --ld example_wrap.dylib example_wrap.o # ...and link it
|
||||
% mzscheme -e '(path->string (build-path "compiled" "native" (system-library-subpath)))'
|
||||
"compiled/native/i386-macosx/3m"
|
||||
% mkdir -p compiled/native/i386-macosx/3m # move the extension library to a magic place
|
||||
% mv example_wrap.dylib compiled/native/i386-macosx/3m/example_ss.dylib
|
||||
% mzscheme
|
||||
Welcome to MzScheme v4.2.4 [3m], Copyright (c) 2004-2010 PLT Scheme Inc.
|
||||
> (require "example.ss")
|
||||
> (fact 5)
|
||||
120
|
||||
> ^D
|
||||
% echo 'It works!'
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
Some points of interest:
|
||||
</p>
|
||||
<ul>
|
||||
<li> This is on a 64-bit machine, so we have to include the -m32 option when building the object file
|
||||
<li> If you want to declare a scheme module (and you probably do), it's important that you include the -declaremodule option to swig (if you miss this out, it'll appear to work, but fail later).
|
||||
<li> Use mzc to compile and then link the wrapped code. You'll probably need to adjust the link flags to refer to the library you're wrapping (you can either do this with an LDFLAGS declaration, as here, or with multiple ++ldf options to mzc).
|
||||
<li> Create the directory with path (build-path "compiled" "native" (system-library-subpath)) and move the freshly-generated .dylib to there, changing its name to module-name_ss.dylib. After that, you can REQUIRE the new module with (require "module-name.ss").
|
||||
<li> The above requests mzc to create an extension using the CGC garbage-collector. The alternative -- the 3m collector -- has generally better performance, but work is still required for SWIG to emit code which is compatible with it.
|
||||
</ul>
|
||||
|
||||
<H2><a name="MzScheme_external_docs"></a>27.3 External documentation</H2>
|
||||
|
||||
|
||||
<p>
|
||||
See the <a href="http://docs.racket-lang.org/inside/index.html">C API</a> for more description of using the mechanism for adding extensions. The main documentation is <a href="http://docs.racket-lang.org/">here</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Tip: mzc's --vv option is very useful for debugging the inevitable library problems you'll encounter.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -2236,7 +2236,8 @@ rest to lower case.
|
|||
And now, a final note about function pointer support. Although SWIG
|
||||
does not normally allow callback functions to be written in the target language, this
|
||||
can be accomplished with the use of typemaps and other advanced SWIG features.
|
||||
This is described in a later chapter.
|
||||
See the <a href="Typemaps.html#Typemaps">Typemaps chapter</a> for more about typemaps
|
||||
and individual target language chapters for more on callbacks and the 'director' feature.
|
||||
</p>
|
||||
|
||||
<H2><a name="SWIG_nn31"></a>5.5 Structures and unions</H2>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<body bgcolor="#ffffff">
|
||||
<H1><a name="Sections"></a>SWIG-2.0 Documentation</H1>
|
||||
|
||||
Last update : SWIG-2.0.2 (in progress)
|
||||
Last update : SWIG-2.0.3 (in progress)
|
||||
|
||||
<H2>Sections</H2>
|
||||
|
||||
|
|
|
|||
|
|
@ -381,8 +381,12 @@ example.i(4) : Syntax error in input.
|
|||
|
||||
|
||||
<ul>
|
||||
<li>201. Unable to find 'filename'.
|
||||
<li>202. Could not evaluate 'expr'.
|
||||
<li>201. Unable to find <em>filename</em>.
|
||||
<li>202. Could not evaluate expression <em>expr</em>.
|
||||
<li>203. Both includeall and importall are defined: using includeall.
|
||||
<li>204. CPP #warning, "<em>warning</em>".
|
||||
<li>205. CPP #error, "<em>error</em>".
|
||||
<li>206. Unexpected tokens after #<em>directive</em> directive.
|
||||
</ul>
|
||||
|
||||
<H3><a name="Warnings_nn12"></a>14.9.3 C/C++ Parser (300-399)</H3>
|
||||
|
|
|
|||
|
|
@ -632,7 +632,7 @@ ocaml_static_cpp: $(SRCS)
|
|||
$(OCAMLCORE)
|
||||
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
|
||||
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
||||
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||
$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
|
||||
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
|
||||
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
|
||||
|
|
@ -643,13 +643,13 @@ ocaml_static_cpp: $(SRCS)
|
|||
$(INTERFACE:%.i=%.cmo) \
|
||||
$(PROGFILE:%.ml=%.cmo) \
|
||||
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
|
||||
-cclib "$(LIBS)" -cc '$(CXX)'
|
||||
-cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
|
||||
|
||||
ocaml_static_cpp_toplevel: $(SRCS)
|
||||
$(OCAMLCORE)
|
||||
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
|
||||
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
||||
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||
$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
|
||||
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
|
||||
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
|
||||
|
|
@ -657,17 +657,17 @@ ocaml_static_cpp_toplevel: $(SRCS)
|
|||
$(OCC) $(OCAMLPP) -c $(PROGFILE)
|
||||
$(NOLINK) || $(OCAMLMKTOP) \
|
||||
swig.cmo \
|
||||
-I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \
|
||||
-I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo \
|
||||
-g -ccopt -g -cclib -g -custom -o $(TARGET)_top \
|
||||
$(INTERFACE:%.i=%.cmo) \
|
||||
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
|
||||
-cclib "$(LIBS)" -cc '$(CXX)'
|
||||
-cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
|
||||
|
||||
ocaml_dynamic_cpp: $(SRCS)
|
||||
$(OCAMLCORE)
|
||||
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
|
||||
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
||||
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||
$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC
|
||||
$(CXXSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
|
||||
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
|
||||
|
|
@ -684,7 +684,7 @@ ocaml_dynamic_cpp: $(SRCS)
|
|||
$(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom \
|
||||
-o $(TARGET) \
|
||||
-package dl -linkpkg \
|
||||
$(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX)'
|
||||
$(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings'
|
||||
|
||||
ocaml_clean:
|
||||
rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo
|
||||
|
|
@ -781,7 +781,7 @@ PHP=@PHP@
|
|||
PHPSCRIPT ?= runme.php
|
||||
|
||||
php_run:
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT)
|
||||
$(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Cleaning the PHP examples
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func main() {
|
|||
|
||||
// Now try the typemap library
|
||||
// Now it is no longer necessary to manufacture pointers.
|
||||
// Instead we use a single element array which in Java is modifiable.
|
||||
// Instead we use a single element slice which in Go is modifiable.
|
||||
|
||||
fmt.Println("Trying the typemap library")
|
||||
r := []int{0}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
extern "C" void factor(int &x, int &y);
|
||||
%}
|
||||
|
||||
extern "C" void factor(int &x, int &y);
|
||||
|
|
|
|||
|
|
@ -46,3 +46,5 @@ void draw_depth_map( volume *v, int div_x, int div_y ) {
|
|||
}
|
||||
|
||||
double volume::depth( double x, double y ) { return 0.0; }
|
||||
|
||||
volume::~volume() { }
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ public:
|
|||
|
||||
class volume {
|
||||
public:
|
||||
virtual double depth( double x, double y );
|
||||
virtual double depth( double x, double y );
|
||||
virtual ~volume();
|
||||
};
|
||||
|
||||
extern void draw_shape_coverage( shape *s, int div_x, int div_y );
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
--- New ---
|
||||
|
||||
It's not possible to access std::(w)string at the moment as it breaks other string examples.
|
||||
|
||||
--- Old ---
|
||||
|
||||
This example shows how to use both std::string and std::wstring in Ocaml,
|
||||
and also demonstrates that one might use this to make a locale-obedient
|
||||
Ocaml program.
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
/* -*- mode: c++ -*- */
|
||||
/* File : example.h -- Tests all string typemaps */
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
void takes_std_string( std::string in ) {
|
||||
cout << "takes_std_string( \"" << in << "\" );" << endl;
|
||||
}
|
||||
|
||||
std::string gives_std_string() {
|
||||
time_t t;
|
||||
|
||||
return std::string( asctime( localtime( &t ) ) );
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
return std::string( asctime( localtime( &tv.tv_sec ) ) );
|
||||
}
|
||||
|
||||
void takes_char_ptr( char *p ) {
|
||||
|
|
@ -24,10 +28,10 @@ void takes_and_gives_std_string( std::string &inout ) {
|
|||
inout.insert( inout.end(), ']' );
|
||||
}
|
||||
|
||||
void takes_and_gives_char_ptr( char *&ptr ) {
|
||||
char *pout = strchr( ptr, '.' );
|
||||
if( pout ) ptr = pout + 1;
|
||||
else ptr = "foo";
|
||||
void takes_and_gives_char_ptr( char *&inout ) {
|
||||
char *pout = strchr( inout, '.' );
|
||||
if( pout ) inout = pout + 1;
|
||||
else inout = "foo";
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ CPP_TEST_CASES += \
|
|||
cpp_static \
|
||||
cpp_typedef \
|
||||
default_args \
|
||||
default_arg_values \
|
||||
default_constructor \
|
||||
defvalue_constructor \
|
||||
derived_byvalue \
|
||||
|
|
@ -268,6 +269,7 @@ CPP_TEST_CASES += \
|
|||
overload_copy \
|
||||
overload_extend \
|
||||
overload_rename \
|
||||
overload_return_type \
|
||||
overload_simple \
|
||||
overload_subtype \
|
||||
overload_template \
|
||||
|
|
@ -287,6 +289,7 @@ CPP_TEST_CASES += \
|
|||
rename3 \
|
||||
rename4 \
|
||||
rename_scope \
|
||||
rename_simple \
|
||||
rename_strip_encoder \
|
||||
rename_pcre_encoder \
|
||||
rename_pcre_enum \
|
||||
|
|
@ -311,6 +314,7 @@ CPP_TEST_CASES += \
|
|||
smart_pointer_rename \
|
||||
smart_pointer_simple \
|
||||
smart_pointer_static \
|
||||
smart_pointer_template_const_overload \
|
||||
smart_pointer_templatemethods \
|
||||
smart_pointer_templatevariables \
|
||||
smart_pointer_typedef \
|
||||
|
|
@ -428,6 +432,7 @@ CPP_TEST_CASES += \
|
|||
valuewrapper_const \
|
||||
valuewrapper_opaque \
|
||||
varargs \
|
||||
varargs_overload \
|
||||
virtual_destructor \
|
||||
virtual_poly \
|
||||
voidtest \
|
||||
|
|
@ -492,6 +497,8 @@ C_TEST_CASES += \
|
|||
overload_extendc \
|
||||
preproc \
|
||||
preproc_constants_c \
|
||||
preproc_defined \
|
||||
preproc_include \
|
||||
preproc_line_file \
|
||||
ret_by_value \
|
||||
simple_array \
|
||||
|
|
@ -516,6 +523,7 @@ MULTI_CPP_TEST_CASES += \
|
|||
|
||||
# Custom tests - tests with additional commandline options
|
||||
wallkw.cpptest: SWIGOPT += -Wallkw
|
||||
preproc_include.ctest: SWIGOPT += -includeall
|
||||
|
||||
|
||||
NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
|
||||
|
|
|
|||
|
|
@ -8,6 +8,12 @@
|
|||
|
||||
%newobject Bar::testFoo;
|
||||
|
||||
%{
|
||||
#if defined(__SUNPRO_CC)
|
||||
#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
class Foo {
|
||||
|
|
|
|||
|
|
@ -64,12 +64,13 @@ setup = \
|
|||
# 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.
|
||||
# DYLD_FALLBACK_LIBRARY_PATH is cleared for MacOSX.
|
||||
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)` `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; \
|
||||
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
|
||||
else \
|
||||
cd $* && \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public class li_std_map_runme {
|
|||
{
|
||||
IList<string> keys = new List<string>(simap.Keys);
|
||||
IList<int> values = new List<int>(simap.Values);
|
||||
Dictionary<string, int> check = new Dictionary<string, int>();
|
||||
if (keys.Count != collectionSize)
|
||||
throw new Exception("Keys count test failed");
|
||||
|
||||
|
|
@ -78,6 +79,13 @@ public class li_std_map_runme {
|
|||
{
|
||||
if (simap[keys[i]] != values[i])
|
||||
throw new Exception("Keys and values test failed for index " + i);
|
||||
check.Add(keys[i], values[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < collectionSize; i++)
|
||||
{
|
||||
if (!check.ContainsKey(i.ToString()))
|
||||
throw new Exception("Keys and Values ContainsKey test " + i + " failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ using System;
|
|||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
static void Main()
|
||||
{
|
||||
// constructors and destructors
|
||||
nspaceNamespace.Outer.Inner1.Color color1 = new nspaceNamespace.Outer.Inner1.Color();
|
||||
|
|
@ -62,7 +62,7 @@ public class runme
|
|||
throw new ApplicationException("Transmission2 wrong");
|
||||
|
||||
// turn feature off / ignoring
|
||||
nspaceNamespace.Outer.nspace ns = new nspaceNamespace.Outer.nspace();
|
||||
nspaceNamespace.Outer.namespce ns = new nspaceNamespace.Outer.namespce();
|
||||
ns.Dispose();
|
||||
nspaceNamespace.NoNSpacePlease nons = new nspaceNamespace.NoNSpacePlease();
|
||||
nons.Dispose();
|
||||
|
|
|
|||
30
Examples/test-suite/csharp/rename_simple_runme.cs
Normal file
30
Examples/test-suite/csharp/rename_simple_runme.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
using System;
|
||||
using rename_simpleNamespace;
|
||||
|
||||
public class rename_simple_runme {
|
||||
|
||||
public static void Main() {
|
||||
NewStruct s = new NewStruct();
|
||||
check(111, s.NewInstanceVariable, "NewInstanceVariable");
|
||||
check(222, s.NewInstanceMethod(), "NewInstanceMethod");
|
||||
check(333, NewStruct.NewStaticMethod(), "NewStaticMethod");
|
||||
check(444, NewStruct.NewStaticVariable, "NewStaticVariable");
|
||||
check(555, rename_simple.NewFunction(), "NewFunction");
|
||||
check(666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
|
||||
|
||||
s.NewInstanceVariable = 1111;
|
||||
NewStruct.NewStaticVariable = 4444;
|
||||
rename_simple.NewGlobalVariable = 6666;
|
||||
|
||||
check(1111, s.NewInstanceVariable, "NewInstanceVariable");
|
||||
check(4444, NewStruct.NewStaticVariable, "NewStaticVariable");
|
||||
check(6666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
|
||||
}
|
||||
|
||||
public static void check(int expected, int actual, string msg) {
|
||||
if (expected != actual)
|
||||
throw new Exception("Failed: Expected: " + expected + " actual: " + actual + " " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -65,13 +65,13 @@ run_testcase = \
|
|||
cd $*$(VERSIONSUFFIX) && \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
DFLAGS='-of$*_runme' \
|
||||
DSRCS='../$(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) $*/*.d' d_compile && \
|
||||
DSRCS='../$(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) `find $* -name *.d`' d_compile && \
|
||||
env LD_LIBRARY_PATH=".:$$LD_LIBRARY_PATH" $(RUNTOOL) ./$*_runme; \
|
||||
else \
|
||||
cd $*$(VERSIONSUFFIX) && \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
DFLAGS='-c' \
|
||||
DSRCS='$*/*.d' d_compile && cd .. ; \
|
||||
DSRCS='`find $* -name *.d`' d_compile && cd .. ; \
|
||||
fi
|
||||
|
||||
# Clean: remove testcase directories
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@ void main() {
|
|||
enforce(!canFind!`a == 20 * 10`(vector[]), "canFind test 4 failed");
|
||||
|
||||
foreach (i, _; vector) {
|
||||
enforce(indexOf(vector[], i * 10) == i, "indexOf test failed, i: " ~ to!string(i));
|
||||
enforce(countUntil(vector[], i * 10) == i, "indexOf test failed, i: " ~ to!string(i));
|
||||
}
|
||||
|
||||
enforce(indexOf(vector[], 42) == -1, "non-existant item indexOf test failed");
|
||||
enforce(countUntil(vector[], 42) == -1, "non-existant item indexOf test failed");
|
||||
|
||||
vector.clear();
|
||||
enforce(vector.length == 0, "clear test failed");
|
||||
|
|
|
|||
32
Examples/test-suite/d/nspace_extend_runme.1.d
Normal file
32
Examples/test-suite/d/nspace_extend_runme.1.d
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
module nspace_extend_runme;
|
||||
|
||||
static import oi1c = nspace_extend.Outer.Inner1.Color;
|
||||
static import oi2c = nspace_extend.Outer.Inner2.Color;
|
||||
|
||||
void main() {
|
||||
{
|
||||
// constructors and destructors
|
||||
scope color1 = new oi1c.Color();
|
||||
scope color = new oi1c.Color(color1);
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
oi1c.Color.colorStaticMethod(20.0);
|
||||
auto created = oi1c.Color.create();
|
||||
}
|
||||
{
|
||||
// constructors and destructors
|
||||
scope color2 = new oi2c.Color();
|
||||
scope color = new oi2c.Color(color2);
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
oi2c.Color.colorStaticMethod(20.0);
|
||||
auto created = oi2c.Color.create();
|
||||
|
||||
// Same class different namespaces
|
||||
auto col1 = new oi1c.Color();
|
||||
auto col2 = oi2c.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
}
|
||||
}
|
||||
32
Examples/test-suite/d/nspace_extend_runme.2.d
Normal file
32
Examples/test-suite/d/nspace_extend_runme.2.d
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
module nspace_extend_runme;
|
||||
|
||||
static import oi1c = nspace_extend.Outer.Inner1.Color;
|
||||
static import oi2c = nspace_extend.Outer.Inner2.Color;
|
||||
|
||||
void main() {
|
||||
{
|
||||
// constructors and destructors
|
||||
scope color1 = new oi1c.Color();
|
||||
scope color = new oi1c.Color(color1);
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
oi1c.Color.colorStaticMethod(20.0);
|
||||
auto created = oi1c.Color.create();
|
||||
}
|
||||
{
|
||||
// constructors and destructors
|
||||
scope color2 = new oi2c.Color();
|
||||
scope color = new oi2c.Color(color2);
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
oi2c.Color.colorStaticMethod(20.0);
|
||||
auto created = oi2c.Color.create();
|
||||
|
||||
// Same class different namespaces
|
||||
auto col1 = new oi1c.Color();
|
||||
auto col2 = oi2c.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
}
|
||||
}
|
||||
87
Examples/test-suite/d/nspace_runme.1.d
Normal file
87
Examples/test-suite/d/nspace_runme.1.d
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
module nspace_runme;
|
||||
|
||||
import nspace.nspace;
|
||||
static import nspace.NoNSpacePlease;
|
||||
static import nspace.Outer.namespce;
|
||||
static import nspace.Outer.Inner1.Channel;
|
||||
static import oi1c = nspace.Outer.Inner1.Color;
|
||||
static import nspace.Outer.Inner2.Channel;
|
||||
static import nspace.Outer.Inner2.Color;
|
||||
static import nspace.Outer.Inner3.Blue;
|
||||
static import nspace.Outer.Inner4.Blue;
|
||||
static import nspace.Outer.SomeClass;
|
||||
|
||||
void main() {
|
||||
// constructors and destructors
|
||||
auto color1 = new oi1c.Color();
|
||||
auto color = new oi1c.Color(color1);
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
oi1c.Color.colorStaticMethod(20.0);
|
||||
auto created = oi1c.Color.create();
|
||||
|
||||
// class enums
|
||||
auto someClass = new nspace.Outer.SomeClass.SomeClass();
|
||||
auto channel = someClass.GetInner1ColorChannel();
|
||||
if (channel != oi1c.Color.Channel.Transmission) {
|
||||
throw new Exception("Transmission wrong");
|
||||
}
|
||||
|
||||
// class anonymous enums
|
||||
int val1 = oi1c.Color.ColorEnumVal1;
|
||||
int val2 = oi1c.Color.ColorEnumVal2;
|
||||
if (val1 != 0 || val2 != 0x22) {
|
||||
throw new Exception("ColorEnumVal wrong");
|
||||
}
|
||||
|
||||
// instance member variables
|
||||
color.instanceMemberVariable = 123;
|
||||
if (color.instanceMemberVariable != 123) {
|
||||
throw new Exception("instance member variable failed");
|
||||
}
|
||||
|
||||
// static member variables
|
||||
oi1c.Color.staticMemberVariable = 789;
|
||||
if (oi1c.Color.staticMemberVariable != 789) {
|
||||
throw new Exception("static member variable failed");
|
||||
}
|
||||
if (oi1c.Color.staticConstMemberVariable != 222) {
|
||||
throw new Exception("static const member variable failed");
|
||||
}
|
||||
if (oi1c.Color.staticConstEnumMemberVariable != oi1c.Color.Channel.Transmission) {
|
||||
throw new Exception("static const enum member variable failed");
|
||||
}
|
||||
|
||||
// check globals in a namespace don't get mangled with the nspace option
|
||||
nspace.nspace.namespaceFunction(color);
|
||||
nspace.nspace.namespaceVar = 111;
|
||||
if (nspace.nspace.namespaceVar != 111) {
|
||||
throw new Exception("global var failed");
|
||||
}
|
||||
|
||||
// Same class different namespaces
|
||||
auto col1 = new oi1c.Color();
|
||||
auto col2 = nspace.Outer.Inner2.Color.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
|
||||
// global enums
|
||||
auto outerChannel1 = someClass.GetInner1Channel();
|
||||
if (outerChannel1 != nspace.Outer.Inner1.Channel.Channel.Transmission1) {
|
||||
throw new Exception("Transmission1 wrong");
|
||||
}
|
||||
auto outerChannel2 = someClass.GetInner2Channel();
|
||||
if (outerChannel2 != nspace.Outer.Inner2.Channel.Channel.Transmission2) {
|
||||
throw new Exception("Transmission2 wrong");
|
||||
}
|
||||
|
||||
// turn feature off / ignoring
|
||||
auto ns = new nspace.Outer.namespce.namespce();
|
||||
auto nons = new nspace.NoNSpacePlease.NoNSpacePlease();
|
||||
|
||||
// Derived class
|
||||
auto blue3 = new nspace.Outer.Inner3.Blue.Blue();
|
||||
blue3.blueInstanceMethod();
|
||||
auto blue4 = new nspace.Outer.Inner4.Blue.Blue();
|
||||
blue4.blueInstanceMethod();
|
||||
}
|
||||
77
Examples/test-suite/d/nspace_runme.2.d
Normal file
77
Examples/test-suite/d/nspace_runme.2.d
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
module nspace_runme;
|
||||
|
||||
import std.exception;
|
||||
import nspace.nspace;
|
||||
static import nspace.NoNSpacePlease;
|
||||
static import nspace.Outer.namespce;
|
||||
static import nspace.Outer.Inner1.Channel;
|
||||
static import oi1c = nspace.Outer.Inner1.Color;
|
||||
static import nspace.Outer.Inner2.Channel;
|
||||
static import nspace.Outer.Inner2.Color;
|
||||
static import nspace.Outer.Inner3.Blue;
|
||||
static import nspace.Outer.Inner4.Blue;
|
||||
static import nspace.Outer.SomeClass;
|
||||
|
||||
void main() {
|
||||
// constructors and destructors
|
||||
auto color1 = new oi1c.Color();
|
||||
auto color = new oi1c.Color(color1);
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
oi1c.Color.colorStaticMethod(20.0);
|
||||
auto created = oi1c.Color.create();
|
||||
|
||||
// class enums
|
||||
auto someClass = new nspace.Outer.SomeClass.SomeClass();
|
||||
auto channel = someClass.GetInner1ColorChannel();
|
||||
enforce(channel == oi1c.Color.Channel.Transmission,
|
||||
"Transmission wrong");
|
||||
|
||||
// class anonymous enums
|
||||
int val1 = oi1c.Color.ColorEnumVal1;
|
||||
int val2 = oi1c.Color.ColorEnumVal2;
|
||||
enforce(val1 == 0 && val2 == 0x22, "ColorEnumVal wrong");
|
||||
|
||||
// instance member variables
|
||||
color.instanceMemberVariable = 123;
|
||||
enforce(color.instanceMemberVariable == 123,
|
||||
"instance member variable failed");
|
||||
|
||||
// static member variables
|
||||
oi1c.Color.staticMemberVariable = 789;
|
||||
enforce(oi1c.Color.staticMemberVariable == 789,
|
||||
"static member variable failed");
|
||||
enforce(oi1c.Color.staticConstMemberVariable == 222,
|
||||
"static const member variable failed");
|
||||
enforce(oi1c.Color.staticConstEnumMemberVariable == oi1c.Color.Channel.Transmission,
|
||||
"static const enum member variable failed");
|
||||
|
||||
// check globals in a namespace don't get mangled with the nspace option
|
||||
nspace.nspace.namespaceFunction(color);
|
||||
nspace.nspace.namespaceVar = 111;
|
||||
enforce(nspace.nspace.namespaceVar == 111, "global var failed");
|
||||
|
||||
// Same class different namespaces
|
||||
auto col1 = new oi1c.Color();
|
||||
auto col2 = nspace.Outer.Inner2.Color.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
|
||||
// global enums
|
||||
auto outerChannel1 = someClass.GetInner1Channel();
|
||||
enforce(outerChannel1 == nspace.Outer.Inner1.Channel.Channel.Transmission1,
|
||||
"Transmission1 wrong");
|
||||
auto outerChannel2 = someClass.GetInner2Channel();
|
||||
enforce(outerChannel2 == nspace.Outer.Inner2.Channel.Channel.Transmission2,
|
||||
"Transmission2 wrong");
|
||||
|
||||
// turn feature off / ignoring
|
||||
auto ns = new nspace.Outer.namespce.namespce();
|
||||
auto nons = new nspace.NoNSpacePlease.NoNSpacePlease();
|
||||
|
||||
// Derived class
|
||||
auto blue3 = new nspace.Outer.Inner3.Blue.Blue();
|
||||
blue3.blueInstanceMethod();
|
||||
auto blue4 = new nspace.Outer.Inner4.Blue.Blue();
|
||||
blue4.blueInstanceMethod();
|
||||
}
|
||||
18
Examples/test-suite/default_arg_values.i
Normal file
18
Examples/test-suite/default_arg_values.i
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
%module default_arg_values
|
||||
|
||||
%{
|
||||
struct Display {
|
||||
// Some compilers warn about 'float v = NULL', so only SWIG sees this peculiarity
|
||||
// Bad Python wrappers were being generated when NULL used for primitive type
|
||||
float draw1(float v = 0) { return v; }
|
||||
float draw2(float *v = 0) { return v ? *v : 0; }
|
||||
};
|
||||
float* createPtr(float v) { static float val; val = v; return &val; }
|
||||
%}
|
||||
|
||||
struct Display {
|
||||
// Bad Python wrappers were being generated when NULL used for primitive type
|
||||
float draw1(float v = NULL) { return v; }
|
||||
float draw2(float *v = NULL) { return v ? *v : 0; }
|
||||
};
|
||||
float* createPtr(float v) { static float val; val = v; return &val; }
|
||||
|
|
@ -10,6 +10,12 @@
|
|||
|
||||
%include "std_string.i"
|
||||
|
||||
%{
|
||||
#if defined(__SUNPRO_CC)
|
||||
#pragma error_messages (off, hidevf)
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
|
|
|
|||
13
Examples/test-suite/errors/cpp_overload_const.i
Normal file
13
Examples/test-suite/errors/cpp_overload_const.i
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
%module xxx
|
||||
|
||||
void check(const int *v) {}
|
||||
void check(int *v) {}
|
||||
void check(int &v) {}
|
||||
void check(const int &v) {} // note: no warning as marshalled by value
|
||||
|
||||
struct OverStruct {};
|
||||
void check(const OverStruct *v) {}
|
||||
void check(OverStruct *v) {}
|
||||
void check(OverStruct &v) {}
|
||||
void check(const OverStruct &v) {}
|
||||
|
||||
4
Examples/test-suite/errors/cpp_recursive_typedef.i
Normal file
4
Examples/test-suite/errors/cpp_recursive_typedef.i
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
%module cpp_recursive_typedef
|
||||
|
||||
typedef std::set<pds> pds;
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ c_varargs_neg.i:3: Error: Argument count in %varargs must be positive.
|
|||
No module name specified using %module or -module.
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_badeval.i :::::::::::::::::::::::::::::::::::
|
||||
pp_badeval.i:4: Warning 202: Could not evaluate 'FOO==4+'
|
||||
pp_badeval.i:4: Warning 202: Could not evaluate expression 'FOO==4+'
|
||||
pp_badeval.i:4: Warning 202: Error: 'Expected an expression'
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_constant.i :::::::::::::::::::::::::::::::::::
|
||||
|
|
@ -84,13 +84,12 @@ pp_constant.i:49: Warning 305: Bad constant value (ignored).
|
|||
|
||||
:::::::::::::::::::::::::::::::: pp_defined.i :::::::::::::::::::::::::::::::::::
|
||||
pp_defined.i:6: Error: No arguments given to defined()
|
||||
pp_defined.i:6: Warning 202: Could not evaluate 'defined'
|
||||
pp_defined.i:6: Warning 202: Error: 'Expected an expression'
|
||||
pp_defined.i:6: Error: Missing expression for #if.
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_deprecated.i :::::::::::::::::::::::::::::::::::
|
||||
pp_deprecated.i:4: Warning 101: %extern is deprecated. Use %import instead.
|
||||
pp_deprecated.i:4: Error: Unable to find 'ext;'
|
||||
pp_deprecated.i:6: Warning 204: CPP #warning, Print this warning
|
||||
pp_deprecated.i:6: Warning 204: CPP #warning, "Print this warning".
|
||||
pp_deprecated.i:8: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing.
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_illegal_argument.i :::::::::::::::::::::::::::::::::::
|
||||
|
|
@ -119,6 +118,20 @@ pp_macro_expansion_multiline.i:30: Warning 509: as it is shadowed by bar(int *).
|
|||
pp_macro_inline_unterminated.i:9: Error: Unterminated call invoking macro 'foo'
|
||||
pp_macro_inline_unterminated.i:12: Error: Syntax error in input(3).
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_macro_missing_expression.i :::::::::::::::::::::::::::::::::::
|
||||
pp_macro_missing_expression.i:4: Error: Missing identifier for #ifdef.
|
||||
pp_macro_missing_expression.i:7: Error: Missing identifier for #ifndef.
|
||||
pp_macro_missing_expression.i:10: Error: Missing expression for #if.
|
||||
pp_macro_missing_expression.i:14: Error: Missing expression for #elif.
|
||||
pp_macro_missing_expression.i:21: Error: Missing expression for #elif.
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_macro_unexpected_tokens.i :::::::::::::::::::::::::::::::::::
|
||||
pp_macro_unexpected_tokens.i:5: Warning 206: Unexpected tokens after #endif directive.
|
||||
pp_macro_unexpected_tokens.i:8: Warning 206: Unexpected tokens after #endif directive.
|
||||
pp_macro_unexpected_tokens.i:11: Warning 206: Unexpected tokens after #else directive.
|
||||
pp_macro_unexpected_tokens.i:18: Warning 206: Unexpected tokens after #endif directive.
|
||||
pp_macro_unexpected_tokens.i:21: Warning 206: Unexpected tokens after #else directive.
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_macro_nargs.i :::::::::::::::::::::::::::::::::::
|
||||
pp_macro_nargs.i:7: Error: Macro 'foo' expects 2 arguments
|
||||
pp_macro_nargs.i:8: Error: Macro 'foo' expects 2 arguments
|
||||
|
|
@ -227,8 +240,8 @@ cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using
|
|||
cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_macro_locator.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_macro_locator.i:66: Warning 204: CPP #warning, inline warning message one
|
||||
cpp_macro_locator.i:96: Warning 204: CPP #warning, an inline warning message 2
|
||||
cpp_macro_locator.i:66: Warning 204: CPP #warning, "inline warning message one".
|
||||
cpp_macro_locator.i:96: Warning 204: CPP #warning, "an inline warning message 2".
|
||||
cpp_macro_locator.i:50: Warning 325: Nested struct not currently supported (Inner ignored)
|
||||
cpp_macro_locator.i:53: Warning 509: Overloaded method overload1(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:52: Warning 509: as it is shadowed by overload1(int *).
|
||||
|
|
@ -275,12 +288,27 @@ cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using
|
|||
|
||||
:::::::::::::::::::::::::::::::: cpp_overload.i :::::::::::::::::::::::::::::::::::
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_overload_const.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_overload_const.i:4: Warning 509: Overloaded method check(int *) effectively ignored,
|
||||
cpp_overload_const.i:3: Warning 509: as it is shadowed by check(int const *).
|
||||
cpp_overload_const.i:5: Warning 509: Overloaded method check(int &) effectively ignored,
|
||||
cpp_overload_const.i:3: Warning 509: as it is shadowed by check(int const *).
|
||||
cpp_overload_const.i:10: Warning 509: Overloaded method check(OverStruct *) effectively ignored,
|
||||
cpp_overload_const.i:9: Warning 509: as it is shadowed by check(OverStruct const *).
|
||||
cpp_overload_const.i:11: Warning 509: Overloaded method check(OverStruct &) effectively ignored,
|
||||
cpp_overload_const.i:9: Warning 509: as it is shadowed by check(OverStruct const *).
|
||||
cpp_overload_const.i:12: Warning 509: Overloaded method check(OverStruct const &) effectively ignored,
|
||||
cpp_overload_const.i:9: Warning 509: as it is shadowed by check(OverStruct const *).
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_private_defvalue.i :::::::::::::::::::::::::::::::::::
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_private_inherit.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_private_inherit.i:6: Warning 309: private inheritance from base 'Foo' (ignored).
|
||||
cpp_private_inherit.i:9: Warning 309: protected inheritance from base 'Foo' (ignored).
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_recursive_typedef.i :::::::::::::::::::::::::::::::::::
|
||||
:1: Error: Recursive typedef detected resolving 'pds *' to 'std::set< pds > *' to 'std::set< std::set< pds > > *' and so on...
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_shared_ptr.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_shared_ptr.i:20: Warning 520: Base class 'A' of 'C' is not similarly marked as a smart pointer.
|
||||
cpp_shared_ptr.i:24: Warning 520: Derived class 'D' of 'C' is not similarly marked as a smart pointer.
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ pp_macro_defined_unterminated
|
|||
pp_macro_expansion
|
||||
pp_macro_expansion_multiline
|
||||
pp_macro_inline_unterminated
|
||||
pp_macro_missing_expression
|
||||
pp_macro_unexpected_tokens
|
||||
pp_macro_nargs
|
||||
pp_macro_redef
|
||||
pp_macro_rparen
|
||||
|
|
@ -74,8 +76,10 @@ cpp_nested
|
|||
cpp_no_access
|
||||
cpp_nobase
|
||||
cpp_overload
|
||||
cpp_overload_const
|
||||
cpp_private_defvalue
|
||||
cpp_private_inherit
|
||||
cpp_recursive_typedef
|
||||
cpp_shared_ptr
|
||||
cpp_template_argname
|
||||
cpp_template_nargs
|
||||
|
|
|
|||
22
Examples/test-suite/errors/pp_macro_missing_expression.i
Normal file
22
Examples/test-suite/errors/pp_macro_missing_expression.i
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// Test "Missing identifier for ..." errrors
|
||||
%module xxx
|
||||
|
||||
#ifdef
|
||||
#endif
|
||||
|
||||
#ifndef
|
||||
#endif
|
||||
|
||||
#if
|
||||
#endif
|
||||
|
||||
#if defined(AAA)
|
||||
#elif
|
||||
#endif
|
||||
|
||||
|
||||
#define BBB
|
||||
|
||||
#if !defined(BBB)
|
||||
#elif
|
||||
#endif
|
||||
23
Examples/test-suite/errors/pp_macro_unexpected_tokens.i
Normal file
23
Examples/test-suite/errors/pp_macro_unexpected_tokens.i
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Test "Unexpected tokens after ..." errors
|
||||
%module xxx
|
||||
|
||||
#ifndef AAA
|
||||
#endif rubbish
|
||||
|
||||
#ifdef AAA
|
||||
#endif rubbish
|
||||
|
||||
#ifdef AAA
|
||||
#else rubbish
|
||||
#endif
|
||||
|
||||
#define BBB
|
||||
|
||||
#ifdef BBB
|
||||
#else
|
||||
#endif rubbish
|
||||
|
||||
#if !defined(BBB)
|
||||
#else rubbish
|
||||
#endif
|
||||
|
||||
|
|
@ -1,5 +1,11 @@
|
|||
%module funcptr_cpp
|
||||
|
||||
%{
|
||||
#if defined(__SUNPRO_CC)
|
||||
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
int addByValue(const int &a, int b) { return a+b; }
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ typedef int Integer;
|
|||
return x;
|
||||
}
|
||||
|
||||
::Integer bar() {
|
||||
::Integer bar_fn() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ func main() {
|
|||
defaults1 := NewDefaults1(1000)
|
||||
defaults1 = NewDefaults1()
|
||||
|
||||
if defaults1.Ret(float64(10.0)) != 10.0 {
|
||||
println(1, defaults1.Ret(float64(10.0)))
|
||||
panic(defaults1.Ret(float64(10.0)))
|
||||
if defaults1.Ret(10.0) != 10.0 {
|
||||
println(1, defaults1.Ret(10.0))
|
||||
panic(defaults1.Ret(10.0))
|
||||
}
|
||||
|
||||
if defaults1.Ret() != -1.0 {
|
||||
|
|
@ -19,8 +19,8 @@ func main() {
|
|||
defaults2 := NewDefaults2(1000)
|
||||
defaults2 = NewDefaults2()
|
||||
|
||||
if defaults2.Ret(float64(10.0)) != 10.0 {
|
||||
panic(defaults2.Ret(float64(10.0)))
|
||||
if defaults2.Ret(10.0) != 10.0 {
|
||||
panic(defaults2.Ret(10.0))
|
||||
}
|
||||
|
||||
if defaults2.Ret() != -1.0 {
|
||||
|
|
|
|||
10
Examples/test-suite/go/director_alternating_runme.go
Normal file
10
Examples/test-suite/go/director_alternating_runme.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import . "./director_alternating"
|
||||
|
||||
func main() {
|
||||
id := GetBar().Id()
|
||||
if id != IdFromGetBar() {
|
||||
panic(id)
|
||||
}
|
||||
}
|
||||
|
|
@ -15,11 +15,17 @@ func (p *FooBar2) Pang() string {
|
|||
return "FooBar2::pang();"
|
||||
}
|
||||
|
||||
type FooBar3 struct{} // From Bar
|
||||
func (p *FooBar3) Cheer() string {
|
||||
return "FooBar3::cheer();"
|
||||
}
|
||||
|
||||
func main() {
|
||||
b := NewBar()
|
||||
f := b.Create()
|
||||
fb := NewDirectorBar(&FooBar{})
|
||||
fb2 := NewDirectorBar(&FooBar2{})
|
||||
fb3 := NewDirectorBar(&FooBar3{})
|
||||
|
||||
s := fb.Used()
|
||||
if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();" {
|
||||
|
|
@ -45,4 +51,23 @@ func main() {
|
|||
if s != "Bar::pong();Foo::pong();FooBar::ping();" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
s = fb3.DirectorInterface().(*FooBar3).Cheer()
|
||||
if s != "FooBar3::cheer();" {
|
||||
panic(s)
|
||||
}
|
||||
if fb2.Callping() != "FooBar2::ping();" {
|
||||
panic("bad fb2.callping")
|
||||
}
|
||||
if fb2.Callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();" {
|
||||
panic("bad fb2.callcheer")
|
||||
}
|
||||
|
||||
if fb3.Callping() != "Bar::ping();" {
|
||||
panic("bad fb3.callping")
|
||||
}
|
||||
|
||||
if fb3.Callcheer() != "FooBar3::cheer();" {
|
||||
panic("bad fb3.callcheer")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ func main() {
|
|||
foo.Spam(1, 1)
|
||||
foo.Spam(1, 1, 1)
|
||||
foo.Spam(extend_placement.NewFoo())
|
||||
foo.Spam(extend_placement.NewFoo(), float64(1.0))
|
||||
foo.Spam(extend_placement.NewFoo(), 1.0)
|
||||
|
||||
bar := extend_placement.NewBar()
|
||||
bar = extend_placement.NewBar(1)
|
||||
|
|
@ -22,7 +22,7 @@ func main() {
|
|||
bar.Spam(1, 1)
|
||||
bar.Spam(1, 1, 1)
|
||||
bar.Spam(extend_placement.NewBar())
|
||||
bar.Spam(extend_placement.NewBar(), float64(1.0))
|
||||
bar.Spam(extend_placement.NewBar(), 1.0)
|
||||
|
||||
footi := extend_placement.NewFooTi()
|
||||
footi = extend_placement.NewFooTi(1)
|
||||
|
|
@ -33,7 +33,7 @@ func main() {
|
|||
footi.Spam(1, 1)
|
||||
footi.Spam(1, 1, 1)
|
||||
footi.Spam(extend_placement.NewFoo())
|
||||
footi.Spam(extend_placement.NewFoo(), float64(1.0))
|
||||
footi.Spam(extend_placement.NewFoo(), 1.0)
|
||||
|
||||
barti := extend_placement.NewBarTi()
|
||||
barti = extend_placement.NewBarTi(1)
|
||||
|
|
@ -43,5 +43,5 @@ func main() {
|
|||
barti.Spam(1, 1)
|
||||
barti.Spam(1, 1, 1)
|
||||
barti.Spam(extend_placement.NewBar())
|
||||
barti.Spam(extend_placement.NewBar(), float64(1.0))
|
||||
barti.Spam(extend_placement.NewBar(), 1.0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ func main() {
|
|||
panic(0)
|
||||
}
|
||||
|
||||
friends.Set(di, float64(4.0))
|
||||
friends.Set(dd, float64(1.3))
|
||||
friends.Set(di, 4.0)
|
||||
friends.Set(dd, 1.3)
|
||||
|
||||
if friends.Get_val1(di).(float64) != 4 {
|
||||
panic(0)
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ import . "./global_ns_arg"
|
|||
|
||||
func main() {
|
||||
Foo(1)
|
||||
Bar()
|
||||
Bar_fn()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ func main() {
|
|||
panic(0)
|
||||
}
|
||||
|
||||
c := cmplx(float64(2), float64(3))
|
||||
c := complex(2, 3)
|
||||
r := real(c)
|
||||
|
||||
if Ctest1(c) != r {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ func main() {
|
|||
if f.Test(float64(3), float64(2)).(float64) != 5 {
|
||||
panic(0)
|
||||
}
|
||||
if f.Test(float64(3.0)).(float64) != 1003 {
|
||||
if f.Test(3.0).(float64) != 1003 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ func main() {
|
|||
if f.Test("hello") != 2 {
|
||||
panic(0)
|
||||
}
|
||||
if f.Test(float64(3.5), float64(2.5)) != 3 {
|
||||
if f.Test(3.5, 2.5) != 3 {
|
||||
panic(0)
|
||||
}
|
||||
if f.Test("hello", 20) != 1020 {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ func main() {
|
|||
panic("foo(int)")
|
||||
}
|
||||
|
||||
if Foo(float64(3.0)) != "foo:double" {
|
||||
if Foo(3.0) != "foo:double" {
|
||||
panic("foo(double)")
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ func main() {
|
|||
panic("Spam::foo(int)")
|
||||
}
|
||||
|
||||
if s.Foo(float64(3.0)) != "foo:double" {
|
||||
if s.Foo(3.0) != "foo:double" {
|
||||
panic("Spam::foo(double)")
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ func main() {
|
|||
panic("Spam::bar(int)")
|
||||
}
|
||||
|
||||
if SpamBar(float64(3.0)) != "bar:double" {
|
||||
if SpamBar(3.0) != "bar:double" {
|
||||
panic("Spam::bar(double)")
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ func main() {
|
|||
panic("Spam(int)")
|
||||
}
|
||||
|
||||
s = NewSpam(float64(3.4))
|
||||
s = NewSpam(3.4)
|
||||
if s.GetXtype() != "double" {
|
||||
panic("Spam(double)")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,18 +6,18 @@ func main() {
|
|||
_ = Foo()
|
||||
|
||||
_ = Maximum(3, 4)
|
||||
_ = Maximum(float64(3.4), float64(5.2))
|
||||
_ = Maximum(3.4, 5.2)
|
||||
|
||||
// mix 1
|
||||
if Mix1("hi") != 101 {
|
||||
panic("mix1(const char*)")
|
||||
}
|
||||
|
||||
if Mix1(float64(1.0), float64(1.0)) != 102 {
|
||||
if Mix1(1.0, 1.0) != 102 {
|
||||
panic("mix1(double, const double &)")
|
||||
}
|
||||
|
||||
if Mix1(float64(1.0)) != 103 {
|
||||
if Mix1(1.0) != 103 {
|
||||
panic("mix1(double)")
|
||||
}
|
||||
|
||||
|
|
@ -26,11 +26,11 @@ func main() {
|
|||
panic("mix2(const char*)")
|
||||
}
|
||||
|
||||
if Mix2(float64(1.0), float64(1.0)) != 102 {
|
||||
if Mix2(1.0, 1.0) != 102 {
|
||||
panic("mix2(double, const double &)")
|
||||
}
|
||||
|
||||
if Mix2(float64(1.0)) != 103 {
|
||||
if Mix2(1.0) != 103 {
|
||||
panic("mix2(double)")
|
||||
}
|
||||
|
||||
|
|
@ -39,11 +39,11 @@ func main() {
|
|||
panic("mix3(const char*)")
|
||||
}
|
||||
|
||||
if Mix3(float64(1.0), float64(1.0)) != 102 {
|
||||
if Mix3(1.0, 1.0) != 102 {
|
||||
panic("mix3(double, const double &)")
|
||||
}
|
||||
|
||||
if Mix3(float64(1.0)) != 103 {
|
||||
if Mix3(1.0) != 103 {
|
||||
panic("mix3(double)")
|
||||
}
|
||||
|
||||
|
|
@ -52,12 +52,12 @@ func main() {
|
|||
panic("overtparams1(int)")
|
||||
}
|
||||
|
||||
if Overtparams1(float64(100.0), 100) != 20 {
|
||||
if Overtparams1(100.0, 100) != 20 {
|
||||
panic("overtparams1(double, int)")
|
||||
}
|
||||
|
||||
// Combination 2
|
||||
if Overtparams2(float64(100.0), 100) != 40 {
|
||||
if Overtparams2(100.0, 100) != 40 {
|
||||
panic("overtparams2(double, int)")
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ func main() {
|
|||
panic("overloaded()")
|
||||
}
|
||||
|
||||
if Overloaded(float64(100.0), 100) != 70 {
|
||||
if Overloaded(100.0, 100) != 70 {
|
||||
panic("overloaded(double, int)")
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ func main() {
|
|||
panic("specialization(int)")
|
||||
}
|
||||
|
||||
if Specialization(float64(10.0)) != 203 {
|
||||
if Specialization(10.0) != 203 {
|
||||
panic("specialization(double)")
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ func main() {
|
|||
panic("specialization(int, int)")
|
||||
}
|
||||
|
||||
if Specialization(float64(10.0), float64(10.0)) != 205 {
|
||||
if Specialization(10.0, 10.0) != 205 {
|
||||
panic("specialization(double, double)")
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +135,7 @@ func main() {
|
|||
panic("overload(Klass t, const char *)")
|
||||
}
|
||||
|
||||
if Overload(float64(10.0), "hi") != 40 {
|
||||
if Overload(10.0, "hi") != 40 {
|
||||
panic("overload(double t, const char *)")
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ func main() {
|
|||
panic("nsoverload(Klass t, const char *)")
|
||||
}
|
||||
|
||||
if Nsoverload(float64(10.0), "hi") != 1040 {
|
||||
if Nsoverload(10.0, "hi") != 1040 {
|
||||
panic("nsoverload(double t, const char *)")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,18 +6,18 @@ func main() {
|
|||
_ = Foo()
|
||||
|
||||
_ = Maximum(3, 4)
|
||||
_ = Maximum(float64(3.4), float64(5.2))
|
||||
_ = Maximum(3.4, 5.2)
|
||||
|
||||
// mix 1
|
||||
if Mix1("hi") != 101 {
|
||||
panic("mix1(const char*)")
|
||||
}
|
||||
|
||||
if Mix1(float64(1.0), float64(1.0)) != 102 {
|
||||
if Mix1(1.0, 1.0) != 102 {
|
||||
panic("mix1(double, const double &)")
|
||||
}
|
||||
|
||||
if Mix1(float64(1.0)) != 103 {
|
||||
if Mix1(1.0) != 103 {
|
||||
panic("mix1(double)")
|
||||
}
|
||||
|
||||
|
|
@ -26,11 +26,11 @@ func main() {
|
|||
panic("mix2(const char*)")
|
||||
}
|
||||
|
||||
if Mix2(float64(1.0), float64(1.0)) != 102 {
|
||||
if Mix2(1.0, 1.0) != 102 {
|
||||
panic("mix2(double, const double &)")
|
||||
}
|
||||
|
||||
if Mix2(float64(1.0)) != 103 {
|
||||
if Mix2(1.0) != 103 {
|
||||
panic("mix2(double)")
|
||||
}
|
||||
|
||||
|
|
@ -39,11 +39,11 @@ func main() {
|
|||
panic("mix3(const char*)")
|
||||
}
|
||||
|
||||
if Mix3(float64(1.0), float64(1.0)) != 102 {
|
||||
if Mix3(1.0, 1.0) != 102 {
|
||||
panic("mix3(double, const double &)")
|
||||
}
|
||||
|
||||
if Mix3(float64(1.0)) != 103 {
|
||||
if Mix3(1.0) != 103 {
|
||||
panic("mix3(double)")
|
||||
}
|
||||
|
||||
|
|
@ -52,12 +52,12 @@ func main() {
|
|||
panic("overtparams1(int)")
|
||||
}
|
||||
|
||||
if Overtparams1(float64(100.0), 100) != 20 {
|
||||
if Overtparams1(100.0, 100) != 20 {
|
||||
panic("overtparams1(double, int)")
|
||||
}
|
||||
|
||||
// Combination 2
|
||||
if Overtparams2(float64(100.0), 100) != 40 {
|
||||
if Overtparams2(100.0, 100) != 40 {
|
||||
panic("overtparams2(double, int)")
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ func main() {
|
|||
panic("overloaded()")
|
||||
}
|
||||
|
||||
if Overloaded(float64(100.0), 100) != 70 {
|
||||
if Overloaded(100.0, 100) != 70 {
|
||||
panic("overloaded(double, int)")
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ func main() {
|
|||
panic("specialization(int)")
|
||||
}
|
||||
|
||||
if Specialization(float64(10.0)) != 203 {
|
||||
if Specialization(10.0) != 203 {
|
||||
panic("specialization(double)")
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ func main() {
|
|||
panic("specialization(int, int)")
|
||||
}
|
||||
|
||||
if Specialization(float64(10.0), float64(10.0)) != 205 {
|
||||
if Specialization(10.0, 10.0) != 205 {
|
||||
panic("specialization(double, double)")
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ func main() {
|
|||
panic("overload(Klass t, const char *)")
|
||||
}
|
||||
|
||||
if Overload(float64(10.0), "hi") != 40 {
|
||||
if Overload(10.0, "hi") != 40 {
|
||||
panic("overload(double t, const char *)")
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ func main() {
|
|||
panic("nsoverload(Klass t, const char *)")
|
||||
}
|
||||
|
||||
if Nsoverload(float64(10.0), "hi") != 1040 {
|
||||
if Nsoverload(10.0, "hi") != 1040 {
|
||||
panic("nsoverload(double t, const char *)")
|
||||
}
|
||||
|
||||
|
|
|
|||
29
Examples/test-suite/go/rename_simple_runme.go
Normal file
29
Examples/test-suite/go/rename_simple_runme.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import . "./rename_simple"
|
||||
|
||||
func main() {
|
||||
s := NewNewStruct()
|
||||
check(111, s.GetNewInstanceVariable(), "NewInstanceVariable")
|
||||
check(222, s.NewInstanceMethod(), "NewInstanceMethod")
|
||||
check(333, NewStructNewStaticMethod(), "NewStaticMethod")
|
||||
check(444, GetNewStructNewStaticVariable(), "NewStaticVariable")
|
||||
check(555, NewFunction(), "NewFunction")
|
||||
check(666, GetNewGlobalVariable(), "NewGlobalVariable")
|
||||
|
||||
s.SetNewInstanceVariable(1111)
|
||||
SetNewStructNewStaticVariable(4444)
|
||||
SetNewGlobalVariable(6666)
|
||||
|
||||
check(1111, s.GetNewInstanceVariable(), "NewInstanceVariable")
|
||||
check(4444, GetNewStructNewStaticVariable(), "NewStaticVariable")
|
||||
check(6666, GetNewGlobalVariable(), "NewGlobalVariable")
|
||||
}
|
||||
|
||||
func check(expected, actual int, msg string) {
|
||||
if expected != actual {
|
||||
panic("Failed: Expected: " + fmt.Sprint(expected) +
|
||||
" actual: " + fmt.Sprint(actual) + " " + msg)
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ func main() {
|
|||
if f.Test(3) != 1 {
|
||||
panic(0)
|
||||
}
|
||||
if f.Test(float64(3.5)) != 2 {
|
||||
if f.Test(3.5) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
if f.Test("hello") != 3 {
|
||||
|
|
@ -19,7 +19,7 @@ func main() {
|
|||
if b.Test(3) != 1 {
|
||||
panic(0)
|
||||
}
|
||||
if b.Test(float64(3.5)) != 2 {
|
||||
if b.Test(3.5) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
if b.Test("hello") != 3 {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ func main() {
|
|||
helloInt.Foo(template_default_arg.Hello_intHi)
|
||||
|
||||
x := template_default_arg.NewX_int()
|
||||
if x.Meth(float64(20.0), 200).(int) != 200 {
|
||||
if x.Meth(20.0, 200).(int) != 200 {
|
||||
panic("X_int test 1 failed")
|
||||
}
|
||||
if x.Meth(20).(int) != 20 {
|
||||
|
|
@ -18,7 +18,7 @@ func main() {
|
|||
}
|
||||
|
||||
y := template_default_arg.NewY_unsigned()
|
||||
if y.Meth(float64(20.0), uint(200)).(uint) != 200 {
|
||||
if y.Meth(20.0, uint(200)).(uint) != 200 {
|
||||
panic("Y_unsigned test 1 failed")
|
||||
}
|
||||
if y.Meth(uint(20)).(uint) != 20 {
|
||||
|
|
@ -29,19 +29,19 @@ func main() {
|
|||
}
|
||||
|
||||
_ = template_default_arg.NewX_longlong()
|
||||
_ = template_default_arg.NewX_longlong(float64(20.0))
|
||||
_ = template_default_arg.NewX_longlong(float64(20.0), int64(200))
|
||||
_ = template_default_arg.NewX_longlong(20.0)
|
||||
_ = template_default_arg.NewX_longlong(20.0, int64(200))
|
||||
|
||||
_ = template_default_arg.NewX_int()
|
||||
_ = template_default_arg.NewX_int(float64(20.0))
|
||||
_ = template_default_arg.NewX_int(float64(20.0), 200)
|
||||
_ = template_default_arg.NewX_int(20.0)
|
||||
_ = template_default_arg.NewX_int(20.0, 200)
|
||||
|
||||
_ = template_default_arg.NewX_hello_unsigned()
|
||||
_ = template_default_arg.NewX_hello_unsigned(float64(20.0))
|
||||
_ = template_default_arg.NewX_hello_unsigned(float64(20.0), template_default_arg.NewHello_int())
|
||||
_ = template_default_arg.NewX_hello_unsigned(20.0)
|
||||
_ = template_default_arg.NewX_hello_unsigned(20.0, template_default_arg.NewHello_int())
|
||||
|
||||
yy := template_default_arg.NewY_hello_unsigned()
|
||||
yy.Meth(float64(20.0), template_default_arg.NewHello_int())
|
||||
yy.Meth(20.0, template_default_arg.NewHello_int())
|
||||
yy.Meth(template_default_arg.NewHello_int())
|
||||
yy.Meth()
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ func main() {
|
|||
}
|
||||
|
||||
// %template(ott) ott<double>
|
||||
if template_default_arg.Ott(template_default_arg.NewHello_int(), float64(1.0)) != 60 {
|
||||
if template_default_arg.Ott(template_default_arg.NewHello_int(), 1.0) != 60 {
|
||||
panic("ott test 12 failed")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ func main() {
|
|||
panic(0)
|
||||
}
|
||||
|
||||
p3 := NewPairdd(float64(3.5), float64(2.5))
|
||||
p3 := NewPairdd(3.5, 2.5)
|
||||
p4 := NewPairdd(p3)
|
||||
|
||||
if p4.GetFirst() != 3.5 {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ func main() {
|
|||
panic("FooBar::blah(int)")
|
||||
}
|
||||
|
||||
if f.Blah(float64(3.5)).(float64) != 3.5 {
|
||||
if f.Blah(3.5) != 3.5 {
|
||||
panic("FooBar::blah(double)")
|
||||
}
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ func main() {
|
|||
panic("FooBar2::blah(int)")
|
||||
}
|
||||
|
||||
if f2.Blah(float64(3.5)).(float64) != 3.5 {
|
||||
if f2.Blah(3.5) != 3.5 {
|
||||
panic("FooBar2::blah(double)")
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ func main() {
|
|||
panic("FooBar3::blah(int)")
|
||||
}
|
||||
|
||||
if f3.Blah(float64(3.5)).(float64) != 3.5 {
|
||||
if f3.Blah(3.5) != 3.5 {
|
||||
panic("FooBar3::blah(double)")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ func main() {
|
|||
panic("blah(int)")
|
||||
}
|
||||
|
||||
if f.Blah(float64(3.5)).(float64) != 3.5 {
|
||||
if f.Blah(3.5) != 3.5 {
|
||||
panic("blah(double)")
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ func main() {
|
|||
panic("blah(int,int)")
|
||||
}
|
||||
|
||||
if f.Blah(float64(3.5), float64(7.5)).(float64) != (3.5 + 7.5) {
|
||||
if f.Blah(3.5, 7.5) != (3.5 + 7.5) {
|
||||
panic("blah(double,double)")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ func main() {
|
|||
panic("Bar::test(int)")
|
||||
}
|
||||
|
||||
if b.Test(float64(3.5)).(float64) != 3.5 {
|
||||
if b.Test(3.5).(float64) != 3.5 {
|
||||
panic("Bar::test(double)")
|
||||
}
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ func main() {
|
|||
panic("Bar2::test(int)")
|
||||
}
|
||||
|
||||
if b2.Test(float64(3.5)).(float64) != 7.0 {
|
||||
if b2.Test(3.5).(float64) != 7.0 {
|
||||
panic("Bar2::test(double)")
|
||||
}
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ func main() {
|
|||
panic("Bar3::test(int)")
|
||||
}
|
||||
|
||||
if b3.Test(float64(3.5)).(float64) != 7.0 {
|
||||
if b3.Test(3.5).(float64) != 7.0 {
|
||||
panic("Bar3::test(double)")
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ func main() {
|
|||
panic("Bar4::test(int)")
|
||||
}
|
||||
|
||||
if b4.Test(float64(3.5)).(float64) != 7.0 {
|
||||
if b4.Test(3.5).(float64) != 7.0 {
|
||||
panic("Bar4::test(double)")
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ func main() {
|
|||
panic("Fred1::test(int)")
|
||||
}
|
||||
|
||||
if bf1.Test(float64(3.5)).(float64) != 7.0 {
|
||||
if bf1.Test(3.5).(float64) != 7.0 {
|
||||
panic("Fred1::test(double)")
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ func main() {
|
|||
panic("Fred2::test(int)")
|
||||
}
|
||||
|
||||
if bf2.Test(float64(3.5)).(float64) != 7.0 {
|
||||
if bf2.Test(3.5).(float64) != 7.0 {
|
||||
panic("Fred2::test(double)")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
38
Examples/test-suite/go/varargs_overload_runme.go
Normal file
38
Examples/test-suite/go/varargs_overload_runme.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package main
|
||||
|
||||
import "./varargs_overload"
|
||||
|
||||
func main() {
|
||||
if varargs_overload.Vararg_over1("Hello") != "Hello" {
|
||||
panic(0)
|
||||
}
|
||||
if varargs_overload.Vararg_over1(2) != "2" {
|
||||
panic(1)
|
||||
}
|
||||
|
||||
if varargs_overload.Vararg_over2("Hello") != "Hello" {
|
||||
panic(2)
|
||||
}
|
||||
if varargs_overload.Vararg_over2(2, 2.2) != "2 2.2" {
|
||||
panic(3)
|
||||
}
|
||||
|
||||
if varargs_overload.Vararg_over3("Hello") != "Hello" {
|
||||
panic(4)
|
||||
}
|
||||
if varargs_overload.Vararg_over3(2, 2.2, "hey") != "2 2.2 hey" {
|
||||
panic(5)
|
||||
}
|
||||
|
||||
if varargs_overload.Vararg_over4("Hello") != "Hello" {
|
||||
panic(6)
|
||||
}
|
||||
|
||||
if varargs_overload.Vararg_over4(123) != "123" {
|
||||
panic(7)
|
||||
}
|
||||
|
||||
if varargs_overload.Vararg_over4("Hello", 123) != "Hello" {
|
||||
panic(8)
|
||||
}
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ public class nspace_runme {
|
|||
throw new RuntimeException("Transmission2 wrong");
|
||||
|
||||
// turn feature off / ignoring
|
||||
nspacePackage.Outer.nspace ns = new nspacePackage.Outer.nspace();
|
||||
nspacePackage.Outer.namespce ns = new nspacePackage.Outer.namespce();
|
||||
nspacePackage.NoNSpacePlease nons = new nspacePackage.NoNSpacePlease();
|
||||
|
||||
// Derived class
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
%module li_std_stream
|
||||
|
||||
%{
|
||||
#if defined(__SUNPRO_CC)
|
||||
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
struct A;
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
%module li_std_wstream
|
||||
|
||||
%{
|
||||
#if defined(__SUNPRO_CC)
|
||||
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
struct A;
|
||||
%}
|
||||
|
|
@ -49,6 +55,7 @@
|
|||
%}
|
||||
|
||||
%extend std::basic_ostream<wchar_t>{
|
||||
extern "C"
|
||||
std::basic_ostream<wchar_t>&
|
||||
operator<<(const A& a)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
%module member_funcptr_galore
|
||||
|
||||
%{
|
||||
#if defined(__SUNPRO_CC)
|
||||
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
|
||||
#pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */
|
||||
#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace FunkSpace {
|
||||
|
|
@ -50,6 +58,10 @@ double (Space::Shape::*areapt(Space::Shape &ref, int & (FunkSpace::Funktions::*d
|
|||
return &Space::Shape::area;
|
||||
}
|
||||
|
||||
double (Space::Shape::*areapt())(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
double (Space::Shape::*abcpt())(Thing<short>, Thing< const Space::Shape * >[]) {
|
||||
return &Space::Shape::abc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
%module member_pointer
|
||||
|
||||
%{
|
||||
#if defined(__SUNPRO_CC)
|
||||
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
|
||||
#pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */
|
||||
#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
class Shape {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,11 @@
|
|||
%module namespace_spaces
|
||||
|
||||
%{
|
||||
#if defined(__SUNPRO_CC)
|
||||
#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
class Foo {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ struct Outer {
|
|||
};
|
||||
|
||||
///////////////////////////////////////////
|
||||
#ifdef SWIG
|
||||
/* some compilers do not accept these */
|
||||
class {
|
||||
public:
|
||||
Integer a;
|
||||
|
|
@ -47,6 +49,7 @@ struct Outer {
|
|||
struct {
|
||||
Integer b;
|
||||
};
|
||||
#endif
|
||||
|
||||
union {
|
||||
Integer c;
|
||||
|
|
@ -151,6 +154,8 @@ struct Outer {
|
|||
Integer xx;
|
||||
} MultipleInstanceAnonDerived1, MultipleInstanceAnonDerived2, *MultipleInstanceAnonDerived3, MultipleInstanceAnonDerived4[2];
|
||||
|
||||
#ifdef SWIG
|
||||
/* some compilers do not accept these */
|
||||
struct : public InnerMultiple {
|
||||
Integer xx;
|
||||
};
|
||||
|
|
@ -159,6 +164,7 @@ struct Outer {
|
|||
public:
|
||||
Integer yy;
|
||||
};
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
%module nspace
|
||||
|
||||
// nspace feature only supported by these languages
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
|
||||
|
||||
%nspace;
|
||||
%nonspace Outer::Inner2::NoNSpacePlease;
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
%inline %{
|
||||
|
||||
namespace Outer {
|
||||
class nspace {
|
||||
class namespce {
|
||||
};
|
||||
namespace Inner1 {
|
||||
enum Channel { Diffuse, Specular = 0x10, Transmission1 };
|
||||
|
|
@ -33,12 +33,12 @@ namespace Outer {
|
|||
static const Channel staticConstEnumMemberVariable = Transmission;
|
||||
void colorInstanceMethod(double d) {}
|
||||
static void colorStaticMethod(double d) {}
|
||||
}; // Color
|
||||
}; // Color
|
||||
int Color::staticMemberVariable = 0;
|
||||
|
||||
Color namespaceFunction(Color k) { return k; }
|
||||
int namespaceVar = 0;
|
||||
} // Inner1
|
||||
} // Inner1
|
||||
|
||||
namespace Inner2 {
|
||||
enum Channel { Diffuse, Specular = 0x30, Transmission2 };
|
||||
|
|
@ -56,12 +56,12 @@ namespace Outer {
|
|||
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,
|
||||
void colors(const Inner1::Color& col1a,
|
||||
const Outer::Inner1::Color& col1b,
|
||||
const Color &col2a,
|
||||
const Inner2::Color& col2b,
|
||||
const Outer::Inner2::Color& col2c) {}
|
||||
}; // Color
|
||||
}; // Color
|
||||
int Color::staticMemberVariable = 0;
|
||||
class NoNSpacePlease {};
|
||||
} // Inner2
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
%module nspace_extend
|
||||
|
||||
// nspace feature only supported by these languages
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
|
||||
|
||||
%nspace;
|
||||
|
||||
|
|
@ -39,10 +39,10 @@ namespace Outer {
|
|||
|
||||
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,
|
||||
void colors(const Inner1::Color& col1a,
|
||||
const Outer::Inner1::Color& col1b,
|
||||
const Color &col2a,
|
||||
const Inner2::Color& col2b,
|
||||
const Outer::Inner2::Color& col2c) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,44 +1,42 @@
|
|||
exception_order
|
||||
|
||||
function check_lasterror(expected)
|
||||
if (!strcmp(lasterror.message, expected))
|
||||
# Take account of older versions prefixing with "error: " and adding a newline at the end
|
||||
if (!strcmp(regexprep(lasterror.message, 'error: (.*)\n$', '$1'), expected))
|
||||
error(["Bad exception order. Expected: \"", expected, "\" Got: \"", lasterror.message, "\""])
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
a = A();
|
||||
|
||||
try
|
||||
a.foo()
|
||||
catch
|
||||
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E1\n"))
|
||||
error("bad exception order")
|
||||
endif
|
||||
check_lasterror("C++ side threw an exception of type E1")
|
||||
end_try_catch
|
||||
|
||||
try
|
||||
a.bar()
|
||||
catch
|
||||
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E2\n"))
|
||||
error("bad exception order")
|
||||
endif
|
||||
check_lasterror("C++ side threw an exception of type E2")
|
||||
end_try_catch
|
||||
|
||||
try
|
||||
a.foobar()
|
||||
catch
|
||||
if (!strcmp(lasterror.message, "error: postcatch unknown (SWIG_RuntimeError)\n"))
|
||||
error("bad exception order")
|
||||
endif
|
||||
check_lasterror("postcatch unknown (SWIG_RuntimeError)")
|
||||
end_try_catch
|
||||
|
||||
try
|
||||
a.barfoo(1)
|
||||
catch
|
||||
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E1\n"))
|
||||
error("bad exception order")
|
||||
endif
|
||||
check_lasterror("C++ side threw an exception of type E1")
|
||||
end_try_catch
|
||||
|
||||
try
|
||||
a.barfoo(2)
|
||||
catch
|
||||
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E2 *\n"))
|
||||
error("bad exception order")
|
||||
endif
|
||||
check_lasterror("C++ side threw an exception of type E2 *")
|
||||
end_try_catch
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
global_ns_arg
|
||||
|
||||
a = foo(1);
|
||||
b = bar();
|
||||
b = bar_fn();
|
||||
|
||||
|
|
|
|||
24
Examples/test-suite/octave/preproc_constants_runme.m
Normal file
24
Examples/test-suite/octave/preproc_constants_runme.m
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
preproc_constants
|
||||
|
||||
assert(CONST_INT1, 10)
|
||||
assert(CONST_DOUBLE3, 12.3)
|
||||
assert(CONST_BOOL1, true)
|
||||
assert(CONST_CHAR, 'x')
|
||||
assert(CONST_STRING1, "const string")
|
||||
|
||||
# Test global constants can be seen within functions
|
||||
function test_global()
|
||||
global CONST_INT1
|
||||
global CONST_DOUBLE3
|
||||
global CONST_BOOL1
|
||||
global CONST_CHAR
|
||||
global CONST_STRING1
|
||||
|
||||
assert(CONST_INT1, 10)
|
||||
assert(CONST_DOUBLE3, 12.3)
|
||||
assert(CONST_BOOL1, true)
|
||||
assert(CONST_CHAR, 'x')
|
||||
assert(CONST_STRING1, "const string")
|
||||
endfunction
|
||||
|
||||
test_global
|
||||
|
|
@ -8,11 +8,12 @@
|
|||
%typemap(default) double y "$1=1000;";
|
||||
#endif
|
||||
|
||||
#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) test;
|
||||
#endif
|
||||
|
||||
#ifdef SWIGLUA
|
||||
// lua only has one numeric type, so some overloads shadow each other creating warnings
|
||||
%warnfilter(SWIGWARN_PARSE_REDEFINED, SWIGWARN_LANG_OVERLOAD_SHADOW) Foo::test;
|
||||
#else
|
||||
%warnfilter(SWIGWARN_PARSE_REDEFINED) Foo::test;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
23
Examples/test-suite/overload_return_type.i
Normal file
23
Examples/test-suite/overload_return_type.i
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
%module overload_return_type
|
||||
|
||||
// Regression test for PHP from SF#3168531 (SWIG <= 2.0.1 segfaults).
|
||||
|
||||
%inline %{
|
||||
|
||||
class A { };
|
||||
class B {
|
||||
public:
|
||||
int foo(int x) { return 0; }
|
||||
A foo(const char * y) { return A(); }
|
||||
};
|
||||
|
||||
// Regression test for PHP from SF#3208299 (there bar()'s return type wa
|
||||
// treated as always void).
|
||||
|
||||
void foo(int i) {}
|
||||
int foo() { return 1; }
|
||||
|
||||
int bar() { return 1; }
|
||||
void bar(int i) {}
|
||||
|
||||
%}
|
||||
|
|
@ -50,7 +50,7 @@ missingtests: missingcpptests missingctests
|
|||
$(MAKE) $*.ctest
|
||||
@echo ' $(CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
|
||||
$(MAKE) $*.cpptest
|
||||
@echo ' $(MULTICPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
|
||||
@echo ' $(MULTI_CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
|
||||
$(MAKE) $*.multicpptest
|
||||
|
||||
# Runs the testcase. Tries to run testcase_runme.php, and if that's not
|
||||
|
|
|
|||
13
Examples/test-suite/php/overload_return_type_runme.php
Normal file
13
Examples/test-suite/php/overload_return_type_runme.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "overload_return_type.php";
|
||||
|
||||
$b = new B;
|
||||
check::equal($b->foo(1), 0, "");
|
||||
check::classname("A", $b->foo("test"));
|
||||
|
||||
check::equal(overload_return_type::foo(), 1, "overload_return_type::foo() should be 1");
|
||||
check::equal(overload_return_type::bar(), 1, "overload_return_type::bar() should be 1");
|
||||
|
||||
?>
|
||||
|
|
@ -6,8 +6,10 @@
|
|||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_CONST; /* Ruby, wrong constant name */
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_PROTOTYPES; /* Ruby, wrong constant name */
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_TOKEN_PASTE; /* Ruby, wrong constant name */
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_TOKEN_PASTE; /* Ruby, wrong constant name */
|
||||
|
||||
#pragma SWIG nowarn=890 /* lots of Go name conflicts */
|
||||
#pragma SWIG nowarn=206 /* Unexpected tokens after #endif directive. */
|
||||
|
||||
/* check __cplusplus case */
|
||||
%header
|
||||
|
|
|
|||
109
Examples/test-suite/preproc_defined.i
Normal file
109
Examples/test-suite/preproc_defined.i
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
%module preproc_defined
|
||||
|
||||
// Check 'defined' passes through the preprocessor without being processed like '#if defined(ABC)' would be (SF bug #1940536)
|
||||
|
||||
%define DEFINED_MACRO
|
||||
%{
|
||||
int defined(int b) {
|
||||
return b > 10;
|
||||
}
|
||||
int vvv = -1;
|
||||
void fn(int val) {
|
||||
if (defined(val))
|
||||
vvv = 1;
|
||||
else
|
||||
vvv = 0;
|
||||
}
|
||||
%}
|
||||
%enddef
|
||||
|
||||
DEFINED_MACRO
|
||||
|
||||
%{
|
||||
int checking(void) {
|
||||
int okay;
|
||||
fn(11);
|
||||
okay = (vvv == 1);
|
||||
fn(9);
|
||||
okay = okay && (vvv == 0);
|
||||
return okay; /* should be 1 */
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
int call_checking(void) {
|
||||
return checking();
|
||||
}
|
||||
%}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Check #if/#elif defined() macro expansions
|
||||
Also checks #if/#elif defined() works correctly within macros... this is not
|
||||
standard C, but is now relied on in the SWIG library. */
|
||||
/*****************************************************************************/
|
||||
|
||||
#define AAA
|
||||
#define BBB
|
||||
#define CCC
|
||||
|
||||
#if defined(AAA)\
|
||||
&& defined(BBB) \
|
||||
&& defined(CCC)
|
||||
%{
|
||||
void thing(int i) {}
|
||||
void stuff(int i) {}
|
||||
struct Defined {
|
||||
int defined;
|
||||
};
|
||||
void bumpf(int i) {}
|
||||
%}
|
||||
#else
|
||||
#endif
|
||||
|
||||
%define ANOTHER_MACRO(TYPE)
|
||||
|
||||
#if defined(AAA) && defined(BBB) && defined(CCC)
|
||||
void thing(TYPE) {}
|
||||
#else
|
||||
void thing_not(TYPE) {}
|
||||
#endif
|
||||
|
||||
#if defined(AAA) &&\
|
||||
defined(BBB) \\
|
||||
&& defined(CCC)
|
||||
void stuff(TYPE) {}
|
||||
#else
|
||||
void stuff_not(TYPE);
|
||||
#endif
|
||||
|
||||
#if defined(0)
|
||||
void defined_not(TYPE);
|
||||
#elif defined(AAA) && defined( BBB ) && defined(CCC)
|
||||
struct Defined {
|
||||
int defined;
|
||||
};
|
||||
#else
|
||||
void defined_not(TYPE);
|
||||
#endif
|
||||
|
||||
#if !( defined(AAA) \
|
||||
defined(BBB) \\
|
||||
&& defined(CCC) )
|
||||
void bumpf_not(TYPE);
|
||||
#else
|
||||
void bumpf(TYPE) {}
|
||||
#endif
|
||||
|
||||
%enddef
|
||||
|
||||
ANOTHER_MACRO(int)
|
||||
|
||||
%{
|
||||
void another_macro_checking(void) {
|
||||
struct Defined d;
|
||||
d.defined = 10;
|
||||
thing(10);
|
||||
stuff(10);
|
||||
bumpf(10);
|
||||
}
|
||||
%}
|
||||
37
Examples/test-suite/preproc_include.i
Normal file
37
Examples/test-suite/preproc_include.i
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
%module preproc_include
|
||||
|
||||
%{
|
||||
#include "preproc_include_a.h"
|
||||
#include "preproc_include_b.h"
|
||||
int multiply10(int a) { return a*10; }
|
||||
int multiply20(int a) { return a*20; }
|
||||
int multiply30(int a) { return a*30; }
|
||||
int multiply40(int a) { return a*40; }
|
||||
int multiply50(int a) { return a*50; }
|
||||
%}
|
||||
|
||||
#define INCLUDE_B preproc_include_b.h
|
||||
#define FILE_INCLUDE(FNAME) #FNAME
|
||||
|
||||
%include FILE_INCLUDE(preproc_include_a.h)
|
||||
|
||||
// Note that this test uses -includeall, so including preproc_include_b.h also includes preproc_include_c.h
|
||||
%include INCLUDE_B
|
||||
|
||||
%include"preproc_include_d withspace.h"
|
||||
|
||||
#define INCLUDE_E "preproc_include_e withspace.h"
|
||||
|
||||
%include INCLUDE_E
|
||||
|
||||
%inline %{
|
||||
#define INCLUDE_F /*comments*/ "preproc_include_f withspace.h"/*testing*/
|
||||
#include INCLUDE_F
|
||||
#include /*oooo*/"preproc_include_g.h"/*ahhh*/
|
||||
%}
|
||||
|
||||
%{
|
||||
int multiply60(int a) { return a*60; }
|
||||
int multiply70(int a) { return a*70; }
|
||||
%}
|
||||
|
||||
3
Examples/test-suite/preproc_include_a.h
Normal file
3
Examples/test-suite/preproc_include_a.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
int multiply10(int a);
|
||||
|
||||
7
Examples/test-suite/preproc_include_b.h
Normal file
7
Examples/test-suite/preproc_include_b.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
int multiply20(int a);
|
||||
|
||||
#define PREPROC_INCLUDE_C "preproc_include_c.h"
|
||||
|
||||
#include PREPROC_INCLUDE_C
|
||||
|
||||
3
Examples/test-suite/preproc_include_c.h
Normal file
3
Examples/test-suite/preproc_include_c.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
int multiply30(int a);
|
||||
|
||||
3
Examples/test-suite/preproc_include_d withspace.h
Normal file
3
Examples/test-suite/preproc_include_d withspace.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
int multiply40(int a);
|
||||
|
||||
3
Examples/test-suite/preproc_include_e withspace.h
Normal file
3
Examples/test-suite/preproc_include_e withspace.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
int multiply50(int a);
|
||||
|
||||
3
Examples/test-suite/preproc_include_f withspace.h
Normal file
3
Examples/test-suite/preproc_include_f withspace.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
int multiply60(int a);
|
||||
|
||||
3
Examples/test-suite/preproc_include_g.h
Normal file
3
Examples/test-suite/preproc_include_g.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
int multiply70(int a);
|
||||
|
||||
17
Examples/test-suite/python/default_arg_values_runme.py
Normal file
17
Examples/test-suite/python/default_arg_values_runme.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from default_arg_values import *
|
||||
|
||||
d = Display()
|
||||
|
||||
if d.draw1() != 0:
|
||||
raise RuntimeError
|
||||
|
||||
if d.draw1(12) != 12:
|
||||
raise RuntimeError
|
||||
|
||||
p = createPtr(123);
|
||||
if d.draw2() != 0:
|
||||
raise RuntimeError
|
||||
|
||||
if d.draw2(p) != 123:
|
||||
raise RuntimeError
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
from global_ns_arg import *
|
||||
|
||||
a = foo(1)
|
||||
b = bar()
|
||||
b = bar_fn()
|
||||
|
||||
|
|
|
|||
11
Examples/test-suite/python/preproc_defined_runme.py
Normal file
11
Examples/test-suite/python/preproc_defined_runme.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import preproc_defined
|
||||
|
||||
if preproc_defined.call_checking() != 1:
|
||||
raise RuntimeError
|
||||
|
||||
d = preproc_defined.Defined()
|
||||
d.defined = 10
|
||||
|
||||
preproc_defined.thing(10)
|
||||
preproc_defined.stuff(10)
|
||||
preproc_defined.bumpf(10)
|
||||
23
Examples/test-suite/python/preproc_include_runme.py
Normal file
23
Examples/test-suite/python/preproc_include_runme.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import preproc_include
|
||||
|
||||
if preproc_include.multiply10(10) != 100:
|
||||
raise RuntimeError
|
||||
|
||||
if preproc_include.multiply20(10) != 200:
|
||||
raise RuntimeError
|
||||
|
||||
if preproc_include.multiply30(10) != 300:
|
||||
raise RuntimeError
|
||||
|
||||
if preproc_include.multiply40(10) != 400:
|
||||
raise RuntimeError
|
||||
|
||||
if preproc_include.multiply50(10) != 500:
|
||||
raise RuntimeError
|
||||
|
||||
if preproc_include.multiply60(10) != 600:
|
||||
raise RuntimeError
|
||||
|
||||
if preproc_include.multiply70(10) != 700:
|
||||
raise RuntimeError
|
||||
|
||||
20
Examples/test-suite/r/rename_simple_runme.R
Normal file
20
Examples/test-suite/r/rename_simple_runme.R
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
source("unittest.R")
|
||||
dyn.load(paste("rename_simple", .Platform$dynlib.ext, sep=""))
|
||||
source("rename_simple.R")
|
||||
cacheMetaData(1)
|
||||
|
||||
s <- NewStruct();
|
||||
unittest(111, s$NewInstanceVariable)
|
||||
unittest(222, s$NewInstanceMethod())
|
||||
unittest(333, NewStruct_NewStaticMethod())
|
||||
unittest(444, NewStruct_NewStaticVariable())
|
||||
unittest(555, NewFunction())
|
||||
unittest(666, NewGlobalVariable())
|
||||
|
||||
s$NewInstanceVariable <- 1111
|
||||
NewStruct_NewStaticVariable(4444)
|
||||
NewGlobalVariable(6666)
|
||||
|
||||
unittest(1111, s$NewInstanceVariable)
|
||||
unittest(4444, NewStruct_NewStaticVariable())
|
||||
unittest(6666, NewGlobalVariable())
|
||||
|
|
@ -1,9 +1,17 @@
|
|||
unittest <- function (x,y) {
|
||||
if (x==y) print("PASS")
|
||||
else print("FAIL")
|
||||
if (x==y) {
|
||||
print("PASS")
|
||||
} else {
|
||||
print("FAIL")
|
||||
stop("Test failed")
|
||||
}
|
||||
}
|
||||
|
||||
unittesttol <- function(x,y,z) {
|
||||
if (abs(x-y) < z) print("PASS")
|
||||
else print("FAIL")
|
||||
}
|
||||
if (abs(x-y) < z) {
|
||||
print("PASS")
|
||||
} else {
|
||||
print("FAIL")
|
||||
stop("Test failed")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
24
Examples/test-suite/rename_simple.i
Normal file
24
Examples/test-suite/rename_simple.i
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
%module rename_simple
|
||||
|
||||
%rename(NewStruct) OldStruct;
|
||||
%rename(NewVariable) OldVariable;
|
||||
%rename(NewInstanceMethod) OldInstanceMethod;
|
||||
%rename(NewInstanceVariable) OldInstanceVariable;
|
||||
%rename(NewStaticMethod) OldStaticMethod;
|
||||
%rename(NewStaticVariable) OldStaticVariable;
|
||||
%rename(NewFunction) OldFunction;
|
||||
%rename(NewGlobalVariable) OldGlobalVariable;
|
||||
|
||||
%inline %{
|
||||
struct OldStruct {
|
||||
OldStruct() : OldInstanceVariable(111) {}
|
||||
int OldInstanceVariable;
|
||||
int OldInstanceMethod() { return 222; }
|
||||
static int OldStaticVariable;
|
||||
static int OldStaticMethod() { return 333; }
|
||||
};
|
||||
int OldStruct::OldStaticVariable = 444;
|
||||
|
||||
int OldFunction() { return 555; }
|
||||
int OldGlobalVariable = 666;
|
||||
%}
|
||||
|
|
@ -1,7 +1,15 @@
|
|||
%module restrict_cplusplus
|
||||
|
||||
%inline %{
|
||||
%{
|
||||
// For PHP 5.3 / gcc-4.4
|
||||
#ifdef restrict
|
||||
#undef restrict
|
||||
#endif
|
||||
struct Foo {
|
||||
int restrict;
|
||||
};
|
||||
%}
|
||||
|
||||
struct Foo {
|
||||
int restrict;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
// Test cases for classes that do *NOT* result in smart-pointer wrapping
|
||||
%module smart_pointer_not
|
||||
|
||||
%{
|
||||
#if defined(__SUNPRO_CC)
|
||||
#pragma error_messages (off, arrowrtn) /* Questionable return type for ... */
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
struct Foo {
|
||||
int x;
|
||||
|
|
|
|||
37
Examples/test-suite/smart_pointer_template_const_overload.i
Normal file
37
Examples/test-suite/smart_pointer_template_const_overload.i
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
%module smart_pointer_template_const_overload
|
||||
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) SmartPointer<FooImplementation>::operator->; // Overloaded method SmartPointer< FooImplementation >::operator ->() ignored
|
||||
|
||||
%inline %{
|
||||
template <class T> class SmartPointer {
|
||||
T *ptr;
|
||||
public:
|
||||
SmartPointer(T *t = 0) : ptr(t) {}
|
||||
inline const T * operator->() const { return ptr; }
|
||||
inline T * operator->() { return ptr; }
|
||||
};
|
||||
|
||||
class FooImplementation {
|
||||
public:
|
||||
int mingy() {}
|
||||
int constmingy() const {}
|
||||
static int thingy() {}
|
||||
static int svariable;
|
||||
static const int constsvariable;
|
||||
int normalvariable;
|
||||
};
|
||||
int FooImplementation::svariable = 0;
|
||||
const int FooImplementation::constsvariable = 2;
|
||||
|
||||
void tester() {
|
||||
SmartPointer<FooImplementation> p;
|
||||
p->mingy();
|
||||
p->constmingy();
|
||||
p->thingy();
|
||||
int a = p->svariable;
|
||||
a = p->constsvariable;
|
||||
a = p->normalvariable;
|
||||
}
|
||||
%}
|
||||
|
||||
%template(FooSmartPointer) SmartPointer<FooImplementation>;
|
||||
|
|
@ -2,6 +2,13 @@
|
|||
|
||||
%module typedef_mptr
|
||||
|
||||
%{
|
||||
#if defined(__SUNPRO_CC)
|
||||
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
|
||||
#pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */
|
||||
#endif
|
||||
%}
|
||||
|
||||
#if defined(SWIGPYTHON) || defined(SWIGOCAML)
|
||||
|
||||
%inline %{
|
||||
|
|
|
|||
|
|
@ -7,6 +7,12 @@
|
|||
%warnfilter(SWIGWARN_JAVA_COVARIANT_RET, SWIGWARN_CSHARP_COVARIANT_RET) covariant3; /* Java, C# covariant return types */
|
||||
%warnfilter(SWIGWARN_JAVA_COVARIANT_RET, SWIGWARN_CSHARP_COVARIANT_RET) covariant4; /* Java, C# covariant return types */
|
||||
|
||||
%{
|
||||
#if defined(__SUNPRO_CC)
|
||||
#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
|
||||
#endif
|
||||
%}
|
||||
|
||||
//
|
||||
// Check this example with directors wherever possible.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@
|
|||
|
||||
const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) {
|
||||
std::map< K, T >::iterator iter = *swigiterator;
|
||||
swigiterator++;
|
||||
(*swigiterator)++;
|
||||
return (*iter).first;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ private void* swigCPtr;
|
|||
private bool swigCMemOwn;
|
||||
|
||||
public this(void* cObject, bool ownCObject) {
|
||||
super($imdmodule.$dclassnameSmartPtrUpcast(cObject), ownCObject);
|
||||
super($imdmodule.$dclazznameSmartPtrUpcast(cObject), ownCObject);
|
||||
swigCPtr = cObject;
|
||||
swigCMemOwn = ownCObject;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ mixin $imdmodule.SwigOperatorDefinitions;
|
|||
private void* swigCPtr;
|
||||
|
||||
public this(void* cObject, bool ownCObject) {
|
||||
super($imdmodule.$dclassnameUpcast(cObject), ownCObject);
|
||||
super($imdmodule.$dclazznameUpcast(cObject), ownCObject);
|
||||
swigCPtr = cObject;
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue