merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11627 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
b6b2fce6ae
103 changed files with 893 additions and 786 deletions
|
|
@ -53,7 +53,7 @@ uninstall: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1
|
|||
clean:
|
||||
/bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT)
|
||||
|
||||
clean-docs:
|
||||
distclean-docs:
|
||||
rm -f $(PACKAGE_NAME).1 web/ccache-man.html
|
||||
|
||||
check : test
|
||||
|
|
@ -63,7 +63,7 @@ test: test.sh
|
|||
|
||||
check: test
|
||||
|
||||
distclean: clean
|
||||
distclean: clean distclean-docs
|
||||
/bin/rm -f Makefile config.h config.sub config.log build-stamp config.status configure config.h
|
||||
|
||||
# FIXME: To fix this, test.sh needs to be able to take ccache from the
|
||||
|
|
|
|||
|
|
@ -1,6 +1,57 @@
|
|||
Version 1.3.40 (in progress)
|
||||
============================
|
||||
|
||||
2009-08-17: olly
|
||||
[Perl] Add "#undef do_exec" to our clean up of Perl global
|
||||
namespace pollution.
|
||||
|
||||
2009-08-17: olly
|
||||
[PHP] Fix to wrap a resource returned by __get() in a PHP object (SF#2549217).
|
||||
|
||||
2009-08-17: wsfulton
|
||||
Fix #2797485 After doing a 'make clean', install fails if yodl2man or yodl2html
|
||||
is not available.
|
||||
|
||||
2009-08-16: wsfulton
|
||||
[Octave] Caught exceptions display the type of the C++ exception instead of the
|
||||
generic "c++-side threw an exception" message.
|
||||
|
||||
2009-08-16: wsfulton
|
||||
[Java] When %catches is used, fix so that any classes specified in the "throws"
|
||||
attribute of the "throws" typemap are generated into the Java method's throws clause.
|
||||
|
||||
2009-08-16: wsfulton
|
||||
[C#] Fix exception handling when %catches is used, reported by Juan Manuel Alvarez.
|
||||
|
||||
2009-08-15: wsfulton
|
||||
Fix %template seg fault on some cases of overloading the templated method.
|
||||
Bug reported by Jan Kupec.
|
||||
|
||||
2009-08-15: wsfulton
|
||||
[Ruby] Add numerous missing wrapped methods for std::vector<bool> specialization
|
||||
as reported by Youssef Jones.
|
||||
|
||||
2009-08-14: wsfulton
|
||||
[Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer
|
||||
memory ownership control. shared_ptr support still to be added. Patch from
|
||||
David Fletcher.
|
||||
|
||||
2009-08-14: olly
|
||||
[PHP] PHP5 now wraps static member variables as documented.
|
||||
|
||||
2009-08-14: olly
|
||||
[PHP] Update the PHP "class" example to work with PHP5 and use
|
||||
modern wrapping features.
|
||||
|
||||
2009-08-13: wsfulton
|
||||
[PHP] std::vector wrappers overhaul. They no longer require the
|
||||
specialize_std_vector() macro. Added wrappers for capacity() and reserve().
|
||||
|
||||
2009-08-13: wsfulton
|
||||
[PHP] Add const reference typemaps. const reference primitive types are
|
||||
now passed by value rather than pointer like the other target languages.
|
||||
Fixes SF#2524029.
|
||||
|
||||
2009-08-08: wsfulton
|
||||
[Python] More user friendly AttributeError is raised when there are
|
||||
no constructors generated for the proxy class in the event that the
|
||||
|
|
@ -81,6 +132,9 @@ Version 1.3.40 (in progress)
|
|||
different name to the class, as such constructors can still take
|
||||
parameters.
|
||||
|
||||
2009-07-12: xavier98
|
||||
[Octave] Add support for Octave 3.2 API
|
||||
|
||||
2009-07-05: olly
|
||||
[PHP] Update the list of PHP keywords - "cfunction" is no longer a
|
||||
keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__",
|
||||
|
|
@ -100,8 +154,8 @@ Version 1.3.40 (in progress)
|
|||
Fix -Wallkw option as reported by Solomon Gibbs.
|
||||
|
||||
2009-07-02: wsfulton
|
||||
Fix syntax error when a nested struct contains a comment containing a * followed eventually by a /.
|
||||
Regression from 1.3.37, reported by Solomon Gibbs.
|
||||
Fix syntax error when a nested struct contains a comment containing a * followed
|
||||
eventually by a /. Regression from 1.3.37, reported by Solomon Gibbs.
|
||||
|
||||
2009-07-01: vmiklos
|
||||
[PHP] Unknown properties are no longer ignored in proxy
|
||||
|
|
|
|||
|
|
@ -2173,7 +2173,7 @@ reference to be used as a char ** datatype.
|
|||
};
|
||||
myav = av_make(len,svs);
|
||||
free(svs);
|
||||
$result = newRV((SV*)myav);
|
||||
$result = newRV_noinc((SV*)myav);
|
||||
sv_2mortal($result);
|
||||
argvi++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -667,7 +667,6 @@ enum boolean {NO=0, YES=1};
|
|||
enum months {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG,
|
||||
SEP, OCT, NOV, DEC};
|
||||
%constant double BLAH = 42.37;
|
||||
#define F_CONST (double) 5 // A floating pointer constant with cast
|
||||
#define PI_4 PI/4
|
||||
#define FLAGS 0x04 | 0x08 | 0x40
|
||||
|
||||
|
|
@ -706,8 +705,15 @@ the declaration
|
|||
<p>
|
||||
defines a constant because <tt>PI</tt> was already defined as a
|
||||
constant and the value is known.
|
||||
However, for the same conservative reasons even a constant with a simple cast will be ignored, such as
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
#define F_CONST (double) 5 // A floating pointer constant with cast
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
The use of constant expressions is allowed, but SWIG does not evaluate
|
||||
them. Rather, it passes them through to the output file and lets the C
|
||||
|
|
@ -2382,6 +2388,10 @@ You can make a <tt>Vector</tt> look a lot like a class by writing a SWIG interfa
|
|||
<p>
|
||||
Note the usage of the <tt>$self</tt> special variable.
|
||||
Its usage is identical to a C++ 'this' pointer and should be used whenever access to the struct instance is required.
|
||||
Also note that C++ constructor and destructor syntax has been used to simulate a constructor and destructor, even for C code.
|
||||
There is one subtle difference to a normal C++ constructor implementation though and that is although the constructor declaration
|
||||
is as per a normal C++ constructor, the newly constructed object must be returned <b>as if</b> the constructor declaration
|
||||
had a return value, a <tt>Vector *</tt> in this case.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
@ -2706,6 +2716,10 @@ initialization code (in that order).
|
|||
</p>
|
||||
|
||||
<ul>
|
||||
<li><b>Begin section</b>. <br>
|
||||
A placeholder to put code at the beginning of the C/C++ wrapper file.
|
||||
</li>
|
||||
|
||||
<li><b>Runtime code</b>. <br>
|
||||
This code is internal to SWIG and is used to include
|
||||
type-checking and other support functions that are used by the rest of the module.
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
# see top-level Makefile.in
|
||||
# (see also top-level configure.in kludge)
|
||||
callback
|
||||
class
|
||||
constants
|
||||
cpointer
|
||||
disown
|
||||
enum
|
||||
extend
|
||||
funcptr
|
||||
overloading
|
||||
pointer
|
||||
pragmas
|
||||
reference
|
||||
proxy
|
||||
reference
|
||||
simple
|
||||
sync
|
||||
value
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ CXXSRCS = example.cxx
|
|||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
LIBS =
|
||||
SWIGOPT = -noproxy
|
||||
SWIGOPT =
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
|
|
|
|||
|
|
@ -1,22 +1,20 @@
|
|||
<?php
|
||||
|
||||
# This file illustrates the low-level C++ interface
|
||||
# created by SWIG. In this case, all of our C++ classes
|
||||
# get converted into function calls.
|
||||
# This example illustrates how member variables are wrapped.
|
||||
|
||||
require("example.php");
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
$c = new_Circle(10);
|
||||
print " Created circle $c\n";
|
||||
$s = new_Square(10);
|
||||
print " Created square $s\n";
|
||||
$c = new Circle(10);
|
||||
print " Created circle\n";
|
||||
$s = new Square(10);
|
||||
print " Created square\n";
|
||||
|
||||
# ----- Access a static member -----
|
||||
|
||||
print "\nA total of " . nshapes() . " shapes were created\n";
|
||||
print "\nA total of " . Shape::get_nshapes() . " shapes were created\n";
|
||||
|
||||
# ----- Member data access -----
|
||||
|
||||
|
|
@ -24,14 +22,14 @@ print "\nA total of " . nshapes() . " shapes were created\n";
|
|||
# Note: methods in the base class Shape are used since
|
||||
# x and y are defined there.
|
||||
|
||||
Shape_x_set($c, 20);
|
||||
Shape_y_set($c, 30);
|
||||
Shape_x_set($s,-10);
|
||||
Shape_y_set($s,5);
|
||||
$c->x = 20;
|
||||
$c->y = 30;
|
||||
$s->x = -10;
|
||||
$s->y = 5;
|
||||
|
||||
print "\nHere is their current position:\n";
|
||||
print " Circle = (" . Shape_x_get($c) . "," . Shape_y_get($c) . ")\n";
|
||||
print " Square = (" . Shape_x_get($s) . "," . Shape_y_get($s) . ")\n";
|
||||
print " Circle = ({$c->x},{$c->y})\n";
|
||||
print " Square = ({$s->x},{$s->y})\n";
|
||||
|
||||
# ----- Call some methods -----
|
||||
|
||||
|
|
@ -39,18 +37,16 @@ print " Square = (" . Shape_x_get($s) . "," . Shape_y_get($s) . ")\n";
|
|||
# invoke the appropriate virtual method on each object.
|
||||
print "\nHere are some properties of the shapes:\n";
|
||||
foreach (array($c,$s) as $o) {
|
||||
print " $o\n";
|
||||
print " area = " . Shape_area($o) . "\n";
|
||||
print " perimeter = " . Shape_perimeter($o) . "\n";
|
||||
}
|
||||
print " ". get_class($o) . "\n";
|
||||
print " area = {$o->area()}\n";
|
||||
print " perimeter = {$o->perimeter()}\n";
|
||||
}
|
||||
|
||||
# ----- Delete everything -----
|
||||
|
||||
print "\nGuess I'll clean up now\n";
|
||||
|
||||
# Note: this invokes the virtual destructor
|
||||
#delete_Shape($c);
|
||||
#delete_Shape($s);
|
||||
$c = NULL;
|
||||
$s = NULL;
|
||||
|
||||
|
|
@ -58,7 +54,7 @@ $s = NULL;
|
|||
# the square.
|
||||
$o = NULL;
|
||||
|
||||
print nshapes() . " shapes remain\n";
|
||||
print Shape::get_nshapes() . " shapes remain\n";
|
||||
print "Goodbye\n";
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ CXXSRCS = example.cxx
|
|||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
LIBS =
|
||||
SWIGOPT = -noproxy
|
||||
SWIGOPT =
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ Vector operator+(const Vector &a, const Vector &b) {
|
|||
return r;
|
||||
}
|
||||
|
||||
char *Vector::print() {
|
||||
char *Vector::as_string() {
|
||||
static char temp[512];
|
||||
sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
|
||||
return temp;
|
||||
|
|
@ -47,4 +47,3 @@ int VectorArray::size() {
|
|||
printf("VectorArray: size %d self=%p\n",maxsize,this);
|
||||
return maxsize;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ public:
|
|||
Vector() : x(0), y(0), z(0) { };
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { };
|
||||
friend Vector operator+(const Vector &a, const Vector &b);
|
||||
char *print();
|
||||
char *as_string();
|
||||
};
|
||||
|
||||
class VectorArray {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* File : example.i */
|
||||
|
||||
/* This file has a few "typical" uses of C++ references. */
|
||||
/* This example has nothing to do with references but the name is used by all
|
||||
* the other languages so it's hard to rename to something more meaningful.
|
||||
*
|
||||
* Mostly it shows how to use %extend.
|
||||
*/
|
||||
|
||||
%module example
|
||||
|
||||
|
|
@ -12,7 +16,7 @@ class Vector {
|
|||
public:
|
||||
Vector(double x, double y, double z);
|
||||
~Vector();
|
||||
char *print();
|
||||
char *as_string();
|
||||
};
|
||||
|
||||
/* This helper function calls an overloaded operator */
|
||||
|
|
@ -41,4 +45,3 @@ public:
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
<?php
|
||||
|
||||
# This file illustrates the manipulation of C++ references in Php.
|
||||
# This uses the low-level interface. Proxy classes work differently.
|
||||
# This file illustrates the manipulation of C++ references in PHP.
|
||||
|
||||
require "example.php";
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
$a = new_Vector(3,4,5);
|
||||
$b = new_Vector(10,11,12);
|
||||
$a = new Vector(3, 4, 5);
|
||||
$b = new Vector(10, 11, 12);
|
||||
|
||||
print " Created a: $a " . Vector_print($a) . "\n";
|
||||
print " Created b: $b " . Vector_print($b) . "\n";
|
||||
print " Created a: {$a->as_string()}\n";
|
||||
print " Created b: {$b->as_string()}\n";
|
||||
|
||||
# ----- Call an overloaded operator -----
|
||||
|
||||
|
|
@ -23,56 +22,28 @@ print " Created b: $b " . Vector_print($b) . "\n";
|
|||
# It returns a new allocated object.
|
||||
|
||||
print "Adding a+b\n";
|
||||
$c = addv($a,$b);
|
||||
print " a+b =". Vector_print($c)."\n";
|
||||
|
||||
# Note: Unless we free the result, a memory leak will occur
|
||||
$c = None;
|
||||
$c = example::addv($a, $b);
|
||||
print " a+b ={$c->as_string()}\n";
|
||||
|
||||
# ----- Create a vector array -----
|
||||
|
||||
# Note: Using the high-level interface here
|
||||
print "Creating an array of vectors\n";
|
||||
$va = new_VectorArray(10);
|
||||
$va = new VectorArray(10);
|
||||
|
||||
print " va: $va size=".VectorArray_size($va)."\n";
|
||||
print " va: size={$va->size()}\n";
|
||||
|
||||
# ----- Set some values in the array -----
|
||||
|
||||
# These operators copy the value of $a and $b to the vector array
|
||||
VectorArray_set($va,0,$a);
|
||||
VectorArray_set($va,1,$b);
|
||||
|
||||
VectorArray_get($va,0);
|
||||
# This will work, but it will cause a memory leak!
|
||||
|
||||
VectorArray_set($va,2,addv($a,$b));
|
||||
|
||||
# The non-leaky way to do it
|
||||
|
||||
$c = addv($a,$b);
|
||||
VectorArray_set($va,3,$c);
|
||||
$c = None;
|
||||
$va->set(0, $a);
|
||||
$va->set(1, $b);
|
||||
$va->set(2, addv($a, $b));
|
||||
|
||||
# Get some values from the array
|
||||
|
||||
print "Getting some array values\n";
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
print "do $i\n";
|
||||
print " va($i) = ". Vector_print(VectorArray_get($va,$i)). "\n";
|
||||
print " va[$i] = {$va->get($i)->as_string()}\n";
|
||||
}
|
||||
|
||||
# Watch under resource meter to check on this
|
||||
#print "Making sure we don't leak memory.\n";
|
||||
#for ($i = 0; $i < 1000000; $i++) {
|
||||
# $c = VectorArray_get($va,$i % 10);
|
||||
#}
|
||||
|
||||
# ----- Clean up -----
|
||||
print "Cleaning up\n";
|
||||
# wants fixing FIXME
|
||||
$va = None;
|
||||
$a = None;
|
||||
$b = None;
|
||||
|
||||
?>
|
||||
|
|
|
|||
33
Examples/test-suite/catches.i
Normal file
33
Examples/test-suite/catches.i
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
%module catches
|
||||
|
||||
%{
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
%}
|
||||
|
||||
%include <exception.i> // for throws(...) typemap
|
||||
|
||||
%catches(int, const char *, const ThreeException&) test_catches(int i);
|
||||
%catches(int, ...) test_exception_specification(int i); // override the exception specification
|
||||
%catches(...) test_catches_all(int i);
|
||||
|
||||
%inline %{
|
||||
struct ThreeException {};
|
||||
void test_catches(int i) {
|
||||
if (i == 1) {
|
||||
throw int(1);
|
||||
} else if (i == 2) {
|
||||
throw (const char *)"two";
|
||||
} else if (i == 3) {
|
||||
throw ThreeException();
|
||||
}
|
||||
}
|
||||
void test_exception_specification(int i) throw(int, const char *, const ThreeException&) {
|
||||
test_catches(i);
|
||||
}
|
||||
void test_catches_all(int i) {
|
||||
test_catches(i);
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -149,6 +149,18 @@ const char global_const_char_array2[sizeof(CPLUSPLUS_MSG)+1] = CPLUSPLUS_MSG;
|
|||
%inline %{
|
||||
|
||||
// char *& tests
|
||||
char *&GetCharPointerRef() {
|
||||
static char str[] = CPLUSPLUS_MSG;
|
||||
static char *ptr = str;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
bool SetCharPointerRef(char *&str, unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
const char *&GetConstCharPointerRef() {
|
||||
static const char str[] = CPLUSPLUS_MSG;
|
||||
static const char *ptr = str;
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ CPP_TEST_CASES += \
|
|||
arrays_scope \
|
||||
bloody_hell \
|
||||
bools \
|
||||
catches \
|
||||
cast_operator \
|
||||
casts \
|
||||
char_strings \
|
||||
|
|
|
|||
66
Examples/test-suite/csharp/catches_runme.cs
Normal file
66
Examples/test-suite/csharp/catches_runme.cs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
using catchesNamespace;
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
// test_catches()
|
||||
try {
|
||||
catches.test_catches(1);
|
||||
throw new Exception("missed exception");
|
||||
} catch (ApplicationException e) {
|
||||
if (e.Message != "C++ int exception thrown, value: 1")
|
||||
throw new ApplicationException("bad exception order: " + e.Message);
|
||||
}
|
||||
|
||||
try {
|
||||
catches.test_catches(2);
|
||||
throw new Exception("missed exception");
|
||||
} catch (ApplicationException e) {
|
||||
if (e.Message != "two")
|
||||
throw new ApplicationException("bad exception order: " + e.Message);
|
||||
}
|
||||
|
||||
try {
|
||||
catches.test_catches(3);
|
||||
throw new Exception("missed exception");
|
||||
} catch (ApplicationException e) {
|
||||
if (e.Message != "C++ ThreeException const & exception thrown")
|
||||
throw new ApplicationException("bad exception order: " + e.Message);
|
||||
}
|
||||
|
||||
// test_exception_specification()
|
||||
try {
|
||||
catches.test_exception_specification(1);
|
||||
throw new Exception("missed exception");
|
||||
} catch (ApplicationException e) {
|
||||
if (e.Message != "C++ int exception thrown, value: 1")
|
||||
throw new ApplicationException("bad exception order: " + e.Message);
|
||||
}
|
||||
|
||||
try {
|
||||
catches.test_exception_specification(2);
|
||||
throw new Exception("missed exception");
|
||||
} catch (ApplicationException e) {
|
||||
if (e.Message != "unknown exception")
|
||||
throw new ApplicationException("bad exception order: " + e.Message);
|
||||
}
|
||||
|
||||
try {
|
||||
catches.test_exception_specification(3);
|
||||
throw new Exception("missed exception");
|
||||
} catch (ApplicationException e) {
|
||||
if (e.Message != "unknown exception")
|
||||
throw new ApplicationException("bad exception order: " + e.Message);
|
||||
}
|
||||
|
||||
// test_catches_all()
|
||||
try {
|
||||
catches.test_catches_all(1);
|
||||
throw new Exception("missed exception");
|
||||
} catch (ApplicationException e) {
|
||||
if (e.Message != "unknown exception")
|
||||
throw new ApplicationException("bad exception order: " + e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -120,15 +120,26 @@ public class char_strings_runme {
|
|||
|
||||
// char *& tests
|
||||
for (i=0; i<count; i++) {
|
||||
String str = char_strings.GetConstCharPointerRef();
|
||||
String str = char_strings.GetCharPointerRef();
|
||||
if (str != CPLUSPLUS_MSG)
|
||||
throw new Exception("Test char pointer ref get failed, iteration " + i);
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (!char_strings.SetConstCharPointerRef(OTHERLAND_MSG + i, i))
|
||||
if (!char_strings.SetCharPointerRef(OTHERLAND_MSG + i, i))
|
||||
throw new Exception("Test char pointer ref set failed, iteration " + i);
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
String str = char_strings.GetConstCharPointerRef();
|
||||
if (str != CPLUSPLUS_MSG)
|
||||
throw new Exception("Test const char pointer ref get failed, iteration " + i);
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (!char_strings.SetConstCharPointerRef(OTHERLAND_MSG + i, i))
|
||||
throw new Exception("Test const char pointer ref set failed, iteration " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
48
Examples/test-suite/csharp/exception_order_runme.cs
Normal file
48
Examples/test-suite/csharp/exception_order_runme.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using exception_orderNamespace;
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
A a = new A();
|
||||
|
||||
try {
|
||||
a.foo();
|
||||
throw new Exception("missed exception");
|
||||
} catch (ApplicationException e) {
|
||||
if (e.Message != "C++ E1 exception thrown")
|
||||
throw new ApplicationException("bad exception order: " + e.Message);
|
||||
}
|
||||
|
||||
try {
|
||||
a.bar();
|
||||
throw new Exception("missed exception");
|
||||
} catch (ApplicationException e) {
|
||||
if (e.Message != "C++ E2 exception thrown")
|
||||
throw new ApplicationException("bad exception order: " + e.Message);
|
||||
}
|
||||
|
||||
try {
|
||||
a.foobar();
|
||||
throw new Exception("missed exception");
|
||||
} catch (ApplicationException e) {
|
||||
if (e.Message != "postcatch unknown")
|
||||
throw new ApplicationException("bad exception order: " + e.Message);
|
||||
}
|
||||
|
||||
try {
|
||||
a.barfoo(1);
|
||||
throw new Exception("missed exception");
|
||||
} catch (ApplicationException e) {
|
||||
if (e.Message != "C++ E1 exception thrown")
|
||||
throw new ApplicationException("bad exception order: " + e.Message);
|
||||
}
|
||||
|
||||
try {
|
||||
a.barfoo(2);
|
||||
throw new Exception("missed exception");
|
||||
} catch (ApplicationException e) {
|
||||
if (e.Message != "C++ E2 * exception thrown")
|
||||
throw new ApplicationException("bad exception order: " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,8 +7,8 @@ public class runme
|
|||
{
|
||||
int f = overload_template.foo();
|
||||
|
||||
f += overload_template.max(3,4);
|
||||
double b = overload_template.max(3.4,5.2);
|
||||
f += overload_template.maximum(3,4);
|
||||
double b = overload_template.maximum(3.4,5.2);
|
||||
b++; // warning suppression
|
||||
|
||||
// mix 1
|
||||
|
|
|
|||
|
|
@ -32,8 +32,14 @@ bar3(foo3 x) {}
|
|||
|
||||
enum sad { boo, hoo = 5 };
|
||||
|
||||
#ifdef __cplusplus /* For Octave and g++ which compiles C test code as C++ */
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Unnamed enum instance */
|
||||
enum { globalinstance1, globalinstance2, globalinstance3 = 30 } GlobalInstance;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Anonymous enum */
|
||||
enum { AnonEnum1, AnonEnum2 = 100 };
|
||||
|
|
|
|||
|
|
@ -127,15 +127,26 @@ public class char_strings_runme {
|
|||
|
||||
// char *& tests
|
||||
for (i=0; i<count; i++) {
|
||||
String str = char_strings.GetConstCharPointerRef();
|
||||
String str = char_strings.GetCharPointerRef();
|
||||
if (!str.equals(CPLUSPLUS_MSG))
|
||||
throw new RuntimeException("Test char pointer ref get failed, iteration " + i);
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (!char_strings.SetConstCharPointerRef(OTHERLAND_MSG + i, i))
|
||||
if (!char_strings.SetCharPointerRef(OTHERLAND_MSG + i, i))
|
||||
throw new RuntimeException("Test char pointer ref set failed, iteration " + i);
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
String str = char_strings.GetConstCharPointerRef();
|
||||
if (!str.equals(CPLUSPLUS_MSG))
|
||||
throw new RuntimeException("Test const char pointer ref get failed, iteration " + i);
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (!char_strings.SetConstCharPointerRef(OTHERLAND_MSG + i, i))
|
||||
throw new RuntimeException("Test const char pointer ref set failed, iteration " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,16 @@ public class java_throws_runme {
|
|||
if (!pass)
|
||||
throw new RuntimeException("Test 2 failed");
|
||||
|
||||
// Check the exception class is used with %catches
|
||||
pass = false;
|
||||
try {
|
||||
java_throws.catches_function(100);
|
||||
}
|
||||
catch (IllegalAccessException e) { pass = true; }
|
||||
|
||||
if (!pass)
|
||||
throw new RuntimeException("Test 3 failed");
|
||||
|
||||
// Check newfree typemap throws attribute
|
||||
try {
|
||||
TestClass tc = java_throws.makeTestClass();
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ public class overload_template_runme {
|
|||
public static void main(String argv[]) {
|
||||
int f = overload_template.foo();
|
||||
|
||||
int a = overload_template.max(3,4);
|
||||
double b = overload_template.max(3.4,5.2);
|
||||
int a = overload_template.maximum(3,4);
|
||||
double b = overload_template.maximum(3.4,5.2);
|
||||
|
||||
// mix 1
|
||||
if (overload_template.mix1("hi") != 101)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,13 @@ public class template_methods_runme {
|
|||
k.KlassTMethodBool();
|
||||
b = Klass.KlassStaticTMethodBoolRenamed(true);
|
||||
Klass.KlassStaticTMethodBool();
|
||||
|
||||
|
||||
//
|
||||
ComponentProperties cp = new ComponentProperties();
|
||||
cp.adda("key1", "val1", "key2", 22.2);
|
||||
cp.adda("key1", "val1", "key2", "val2", "key3", "val3");
|
||||
cp.adda("key1", 1, "key2", 2, "key3", 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,12 +42,16 @@ short full_of_exceptions(int num) {
|
|||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
void throw_spec_function(int value) throw (int) { throw (int)0; }
|
||||
bool throw_spec_function(int value) throw (int) { throw (int)0; }
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
%}
|
||||
|
||||
%catches(int) catches_function(int value);
|
||||
%inline %{
|
||||
bool catches_function(int value) { throw (int)0; }
|
||||
%}
|
||||
|
||||
// Check newfree typemap throws attribute
|
||||
%newobject makeTestClass;
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ code is not functioning properly it will fail to compile.
|
|||
%typemap(in) Animal ()
|
||||
{
|
||||
void *space_needed = malloc(HEIGHT_$1_lextype * WIDTH_$1_lextype);
|
||||
$1 = space_needed;
|
||||
$1 = ($1_ltype)space_needed;
|
||||
}
|
||||
|
||||
%typemap(in) Animal[2] ()
|
||||
{
|
||||
void *space_needed = malloc(2 * HEIGHT_$1_lextype * WIDTH_$1_lextype);
|
||||
$1 = space_needed;
|
||||
$1 = ($1_ltype)space_needed;
|
||||
}
|
||||
|
||||
%inline %{
|
||||
|
|
|
|||
|
|
@ -1,2 +1,7 @@
|
|||
%module li_math
|
||||
#ifdef SWIGPHP
|
||||
// PHP already provides these functions with the same names, so just kill that
|
||||
// warning.
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD);
|
||||
#endif
|
||||
%include math.i
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ require("import") -- the import fn
|
|||
import("overload_template") -- import code
|
||||
for k,v in pairs(overload_template) do _G[k]=v end -- move to global
|
||||
|
||||
-- lua has only one numeric type, so max(int,int) and max(double,double) are the same
|
||||
-- lua has only one numeric type, so maximum(int,int) and maximum(double,double) are the same
|
||||
-- whichever one was wrapper first will be used (which is int)
|
||||
|
||||
f = foo()
|
||||
|
||||
a = max(3,4)
|
||||
a = maximum(3,4)
|
||||
|
||||
-- mix 1
|
||||
assert(mix1("hi") == 101)
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
director_exception
|
||||
|
||||
MyFoo=@() subclass(Foo(),
|
||||
'ping',@(self) raise(NotImplementedError("MyFoo::ping() EXCEPTION")));
|
||||
|
||||
MyFoo2=@() subclass(Foo(),
|
||||
'ping',@(self) true);
|
||||
|
||||
ok = 0;
|
||||
|
||||
a = MyFoo();
|
||||
b = launder(a);
|
||||
|
||||
try
|
||||
b.pong();
|
||||
catch
|
||||
[etype,e]=raised();
|
||||
if (etype=="NotImplementedError")
|
||||
ok=1;
|
||||
endif
|
||||
end_try_catch
|
||||
|
||||
if (!ok)
|
||||
error
|
||||
endif
|
||||
|
||||
ok = 0;
|
||||
|
||||
a = MyFoo2();
|
||||
b = launder(a);
|
||||
|
||||
try
|
||||
b.pong();
|
||||
catch
|
||||
ok = 1;
|
||||
end_try_catch
|
||||
|
||||
if (!ok)
|
||||
error
|
||||
endif
|
||||
|
||||
|
||||
try
|
||||
raise(Exception2());
|
||||
catch
|
||||
if (!strcmp(raised,"Exception2"))
|
||||
rethrow(lasterr);
|
||||
endif
|
||||
end_try_catch
|
||||
|
||||
try
|
||||
raise(Exception1());
|
||||
catch
|
||||
if (!strcmp(raised,"Exception1"))
|
||||
rethrow(lasterr);
|
||||
endif
|
||||
end_try_catch
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
director_finalizer
|
||||
|
||||
MyFoo=@() subclass(Foo(),'__del__',@delete_MyFoo);
|
||||
function delete_MyFoo(self)
|
||||
self.orStatus(2);
|
||||
try
|
||||
Foo.__del__(self);
|
||||
catch
|
||||
end_try_catch
|
||||
endfunction
|
||||
|
||||
resetStatus();
|
||||
|
||||
a = MyFoo();
|
||||
clear a;
|
||||
|
||||
if (getStatus() != 3)
|
||||
error
|
||||
endif
|
||||
|
||||
resetStatus();
|
||||
|
||||
a = MyFoo();
|
||||
launder(a);
|
||||
|
||||
if (getStatus() != 0)
|
||||
error
|
||||
endif
|
||||
|
||||
clear a;
|
||||
|
||||
if (getStatus() != 3)
|
||||
error
|
||||
endif
|
||||
|
||||
resetStatus();
|
||||
|
||||
a = MyFoo().__disown__();
|
||||
deleteFoo(a);
|
||||
|
||||
if (getStatus() != 3)
|
||||
error
|
||||
endif
|
||||
|
||||
resetStatus();
|
||||
|
||||
a = MyFoo().__disown__();
|
||||
deleteFoo(launder(a));
|
||||
|
||||
if (getStatus() != 3)
|
||||
error
|
||||
endif
|
||||
|
||||
resetStatus();
|
||||
|
||||
|
||||
|
|
@ -1,17 +1,2 @@
|
|||
empty
|
||||
|
||||
printf("begin\n");
|
||||
who global
|
||||
|
||||
printf("after load\n");
|
||||
who global
|
||||
|
||||
#clear -g
|
||||
printf("after clear\n");
|
||||
who global
|
||||
|
||||
#clear empty
|
||||
printf("after clear specific\n");
|
||||
who global
|
||||
|
||||
printf("before shutdown\n");
|
||||
|
|
|
|||
|
|
@ -6,40 +6,39 @@ a = A();
|
|||
try
|
||||
a.foo()
|
||||
catch
|
||||
if (!strcmp(raised(),"E1"))
|
||||
error, "bad exception order"
|
||||
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E1\n"))
|
||||
error("bad exception order")
|
||||
endif
|
||||
end_try_catch
|
||||
|
||||
try
|
||||
a.bar()
|
||||
catch
|
||||
if (!strcmp(raised(),"E2"))
|
||||
error, "bad exception order"
|
||||
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E2\n"))
|
||||
error("bad exception order")
|
||||
endif
|
||||
end_try_catch
|
||||
|
||||
try
|
||||
a.foobar()
|
||||
catch
|
||||
[t,e]=raised();
|
||||
if (!strcmp(e.args(0),"postcatch unknown"))
|
||||
error
|
||||
if (!strcmp(lasterror.message, "error: postcatch unknown (SWIG_RuntimeError)\n"))
|
||||
error("bad exception order")
|
||||
endif
|
||||
end_try_catch
|
||||
|
||||
try
|
||||
a.barfoo(1)
|
||||
catch
|
||||
if (!strcmp(raised(),"E1"))
|
||||
error, "bad exception order"
|
||||
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E1\n"))
|
||||
error("bad exception order")
|
||||
endif
|
||||
end_try_catch
|
||||
|
||||
try
|
||||
a.barfoo(2)
|
||||
catch
|
||||
if (!strcmp(raised(),"E2"))
|
||||
error, "bad exception order"
|
||||
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E2 *\n"))
|
||||
error("bad exception order")
|
||||
endif
|
||||
end_try_catch
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# This is the import runtime testcase.
|
||||
|
||||
imports_b
|
||||
imports_a
|
||||
imports_b;
|
||||
imports_a;
|
||||
|
||||
x = imports_b.B();
|
||||
x.hello();
|
||||
|
|
|
|||
|
|
@ -1,160 +1,11 @@
|
|||
li_std_vector
|
||||
|
||||
iv = IntVector(4);
|
||||
for i=0:4,
|
||||
for i=0:3,
|
||||
iv(i) = i;
|
||||
endfor
|
||||
|
||||
x = average(iv);
|
||||
y = average([1,2,3,4]);
|
||||
|
||||
a = half([10,10.5,11,11.5]);
|
||||
|
||||
dv = DoubleVector(10);
|
||||
for i=0:10,
|
||||
dv(i) = i/2.0;
|
||||
endfor
|
||||
|
||||
halve_in_place(dv);
|
||||
|
||||
|
||||
bv = BoolVector(4);
|
||||
bv(0)= 1;
|
||||
bv(1)= 0;
|
||||
bv(2)= 4;
|
||||
bv(3)= 0;
|
||||
|
||||
if (bv(0) != bv(2))
|
||||
error("bad std::vector<bool> mapping")
|
||||
if (x != 1.5)
|
||||
error("average failed");
|
||||
endif
|
||||
|
||||
b = B(5);
|
||||
va = VecA([b,None,b,b]);
|
||||
|
||||
if (va(0).f(1) != 6)
|
||||
error("bad std::vector<A*> mapping")
|
||||
endif
|
||||
|
||||
if (vecAptr(va) != 6)
|
||||
error("bad std::vector<A*> mapping")
|
||||
endif
|
||||
|
||||
b.val = 7;
|
||||
if (va(3).f(1) != 8)
|
||||
error("bad std::vector<A*> mapping")
|
||||
endif
|
||||
|
||||
|
||||
ip = PtrInt();
|
||||
ap = new_ArrInt(10);
|
||||
|
||||
ArrInt_setitem(ip,0,123);
|
||||
ArrInt_setitem(ap,2,123);
|
||||
|
||||
vi = IntPtrVector((ip,ap,None));
|
||||
if (ArrInt_getitem(vi[0],0) != ArrInt_getitem(vi[1],2))
|
||||
error("bad std::vector<int*> mapping")
|
||||
endif
|
||||
|
||||
delete_ArrInt(ap);
|
||||
|
||||
|
||||
a = halfs([10,8,4,3]);
|
||||
|
||||
v = IntVector();
|
||||
v(0:2) = [1,2];
|
||||
if (v(0) != 1 || v[1] != 2)
|
||||
error("bad setslice")
|
||||
endif
|
||||
|
||||
if (v(0:-1)(0) != 1)
|
||||
error("bad getslice")
|
||||
endif
|
||||
|
||||
if (v(0:-2).size() != 0)
|
||||
error("bad getslice")
|
||||
|
||||
v(0:1) = [2];
|
||||
if (v(0) != 2)
|
||||
error("bad setslice")
|
||||
endif
|
||||
|
||||
v(1:) = [3];
|
||||
if (v(1) != 3)
|
||||
error("bad setslice")
|
||||
endif
|
||||
|
||||
v(2:) = [3]
|
||||
if (v(2) != 3)
|
||||
error("bad setslice")
|
||||
endif
|
||||
|
||||
if (v(0:)(0) != v(0))
|
||||
error("bad getslice")
|
||||
endif
|
||||
|
||||
|
||||
v.erase(:)
|
||||
if (v.size() != 0)
|
||||
error("bad getslice")
|
||||
endif
|
||||
|
||||
v.erase(:)
|
||||
if (v.size() != 0)
|
||||
error("bad getslice")
|
||||
endif
|
||||
|
||||
|
||||
|
||||
v = vecStr({"hello ", "world"});
|
||||
if (v(0) != 'hello world')
|
||||
error,"bad std::string+std::vector"
|
||||
endif
|
||||
|
||||
|
||||
pv = pyvector({1, "hello", (1,2)});
|
||||
|
||||
if (pv(1) != "hello")
|
||||
error
|
||||
endif
|
||||
|
||||
|
||||
iv = IntVector(5);
|
||||
for i=0:5,
|
||||
iv(i) = i
|
||||
endif
|
||||
|
||||
iv(1:3) = [];
|
||||
if (iv(1) != 3)
|
||||
error
|
||||
endif
|
||||
|
||||
# Overloading checks
|
||||
if (overloaded1(iv) != "vector<int>")
|
||||
error
|
||||
endif
|
||||
|
||||
if (overloaded1(dv) != "vector<double>")
|
||||
error
|
||||
endif
|
||||
|
||||
if (overloaded2(iv) != "vector<int>")
|
||||
error
|
||||
endif
|
||||
|
||||
if (overloaded2(dv) != "vector<double>")
|
||||
error
|
||||
endif
|
||||
|
||||
if (overloaded3(iv) != "vector<int> *")
|
||||
error
|
||||
endif
|
||||
|
||||
if (overloaded3(None) != "vector<int> *")
|
||||
error
|
||||
endif
|
||||
|
||||
if (overloaded3(100) != "int")
|
||||
error
|
||||
endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
multi_import_a
|
||||
multi_import_b
|
||||
multi_import_a;
|
||||
multi_import_b;
|
||||
|
||||
x = multi_import_b.XXX();
|
||||
if (x.testx() != 0)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
overload_template
|
||||
f = foo();
|
||||
|
||||
a = max(3,4);
|
||||
b = max(3.4,5.2);
|
||||
a = maximum(3,4);
|
||||
b = maximum(3.4,5.2);
|
||||
|
||||
# mix 1
|
||||
if (mix1("hi") != 101)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#ifdef SWIGLUA
|
||||
// lua only has one numeric type, so most of the overloads shadow each other creating warnings
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) foo;
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) max;
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) maximum;
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) specialization;
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) overload;
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) space::nsoverload;
|
||||
|
|
@ -11,12 +11,6 @@
|
|||
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) barT;
|
||||
#endif
|
||||
|
||||
%{
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
int foo() {
|
||||
|
|
@ -29,15 +23,15 @@ template <class T>
|
|||
}
|
||||
|
||||
template<class T>
|
||||
T max(T a, T b) { return (a > b) ? a : b; }
|
||||
T maximum(T a, T b) { return (a > b) ? a : b; }
|
||||
%}
|
||||
|
||||
|
||||
%template(foo) foo<int>;
|
||||
%template(foo) foo<double>;
|
||||
|
||||
%template(max) max<int>;
|
||||
%template(max) max<double>;
|
||||
%template(maximum) maximum<int>;
|
||||
%template(maximum) maximum<double>;
|
||||
|
||||
// Mix template overloading with plain function overload
|
||||
// Mix 1
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "add_link.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "arrayptr.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "arrays_global.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "arrays_global_twodim.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
require "tests.php";
|
||||
require "arrays.php";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "arrays_scope.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "casts.php";
|
||||
|
|
|
|||
43
Examples/test-suite/php/char_strings_runme.php
Normal file
43
Examples/test-suite/php/char_strings_runme.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "char_strings.php";
|
||||
|
||||
$CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
|
||||
$OTHERLAND_MSG_10 = "Little message from the safe world.10";
|
||||
|
||||
check::equal(GetCharHeapString(), $CPLUSPLUS_MSG, "failed GetCharHeapString");
|
||||
check::equal(GetConstCharProgramCodeString(), $CPLUSPLUS_MSG, "failed GetConstCharProgramCodeString");
|
||||
check::equal(GetCharStaticString(), $CPLUSPLUS_MSG, "failed GetCharStaticString");
|
||||
check::equal(GetCharStaticStringFixed(), $CPLUSPLUS_MSG, "failed GetCharStaticStringFixed");
|
||||
check::equal(GetConstCharStaticStringFixed(), $CPLUSPLUS_MSG, "failed GetConstCharStaticStringFixed");
|
||||
|
||||
check::equal(SetCharHeapString($OTHERLAND_MSG_10, 10), true, "failed GetConstCharStaticStringFixed");
|
||||
check::equal(SetCharStaticString($OTHERLAND_MSG_10, 10), true, "failed SetCharStaticString");
|
||||
check::equal(SetCharArrayStaticString($OTHERLAND_MSG_10, 10), true, "failed SetCharArrayStaticString");
|
||||
check::equal(SetConstCharHeapString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharHeapString");
|
||||
check::equal(SetConstCharStaticString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharStaticString");
|
||||
check::equal(SetConstCharArrayStaticString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharArrayStaticString");
|
||||
|
||||
check::equal(CharPingPong($OTHERLAND_MSG_10), $OTHERLAND_MSG_10, "failed CharPingPong");
|
||||
|
||||
Global_char_set($OTHERLAND_MSG_10);
|
||||
check::equal(Global_char_get(), $OTHERLAND_MSG_10, "failed Global_char_get");
|
||||
|
||||
Global_char_array1_set($OTHERLAND_MSG_10);
|
||||
check::equal(Global_char_array1_get(), $OTHERLAND_MSG_10, "failed Global_char_array1_get");
|
||||
|
||||
Global_char_array2_set($OTHERLAND_MSG_10);
|
||||
check::equal(Global_char_array2_get(), $OTHERLAND_MSG_10, "failed Global_char_array2_get");
|
||||
|
||||
check::equal(Global_const_char_get(), $CPLUSPLUS_MSG, "failed Global_const_char");
|
||||
check::equal(Global_const_char_array1_get(), $CPLUSPLUS_MSG, "failed Global_const_char_array1");
|
||||
check::equal(Global_const_char_array2_get(), $CPLUSPLUS_MSG, "failed Global_const_char_array2");
|
||||
|
||||
check::equal(GetCharPointerRef(), $CPLUSPLUS_MSG, "failed GetCharPointerRef");
|
||||
check::equal(SetCharPointerRef($OTHERLAND_MSG_10, 10), true, "failed SetCharPointerRef");
|
||||
check::equal(GetConstCharPointerRef(), $CPLUSPLUS_MSG, "failed GetConstCharPointerRef");
|
||||
check::equal(SetConstCharPointerRef($OTHERLAND_MSG_10, 10), true, "failed SetConstCharPointerRef");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "class_ignore.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "conversion_namespace.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "conversion.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "cpp_static.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "director_nested.php";
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ require "tests.php";
|
|||
require "director_string.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array(a_get_first,a_call_get_first,a_string_length,a_process_text,a_call_process_func,stringvector_size,stringvector_is_empty,stringvector_clear,stringvector_push,stringvector_pop));
|
||||
check::functions(array(a_get_first,a_call_get_first,a_string_length,a_process_text,a_call_process_func,stringvector_size,stringvector_is_empty,stringvector_clear,stringvector_push,stringvector_pop,stringvector_capacity,stringvector_reserve));
|
||||
// No new classes
|
||||
check::classes(array(A,StringVector));
|
||||
// now new vars
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "enum_scope_template.php";
|
||||
|
||||
check::classes(array("enum_scope_template", "TreeInt"));
|
||||
check::functions("chops");
|
||||
check::equal(0,TreeInt_Oak,"0==TreeInt_Oak");
|
||||
check::equal(1,TreeInt_Fir,"0==TreeInt_Fir");
|
||||
check::equal(2,TreeInt_Cedar,"0==TreeInt_Cedar");
|
||||
check::equal(1,TreeInt_Fir,"1==TreeInt_Fir");
|
||||
check::equal(2,TreeInt_Cedar,"2==TreeInt_Cedar");
|
||||
check::equal(TreeInt_Oak,chops(TreeInt_Oak),"TreeInt_Oak==chops(TreeInt_Oak)");
|
||||
check::equal(TreeInt_Fir,chops(TreeInt_Fir),"TreeInt_Fir==chops(TreeInt_Fir)");
|
||||
check::equal(TreeInt_Cedar,chops(TreeInt_Cedar),"TreeInt_Cedar==chops(TreeInt_Cedar)");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "evil_diamond_ns.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "evil_diamond_prop.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "evil_diamond.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "extend_template_ns.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "extend_template.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "grouping.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "ignore_parameter.php";
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "li_carrays.php";
|
||||
|
||||
// No new functions
|
||||
// Check functions.
|
||||
check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem));
|
||||
// No new classes
|
||||
check::classes(array(doubleArray));
|
||||
// now new vars
|
||||
|
||||
// Check classes.
|
||||
// NB An "li_carrays" class is created as a mock namespace.
|
||||
check::classes(array(li_carrays,doubleArray,AB,XY,XYArray));
|
||||
|
||||
// No new global variables.
|
||||
check::globals(array());
|
||||
|
||||
$d = new doubleArray(10);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "li_std_string.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "newobject1.php";
|
||||
|
|
|
|||
15
Examples/test-suite/php/pointer_reference_runme.php
Normal file
15
Examples/test-suite/php/pointer_reference_runme.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "pointer_reference.php";
|
||||
|
||||
$s = pointer_reference::get();
|
||||
check::equal($s->value, 10, "pointer_reference::get() failed");
|
||||
|
||||
$ss = new Struct(20);
|
||||
pointer_reference::set($ss);
|
||||
$i = Struct::instance();
|
||||
check::equal($i->value, 20, "pointer_reference::set() failed");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "prefix.php";
|
||||
|
|
|
|||
25
Examples/test-suite/php/primitive_ref_runme.php
Normal file
25
Examples/test-suite/php/primitive_ref_runme.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "primitive_ref.php";
|
||||
|
||||
check::equal(ref_over(3), 3, "ref_over failed");
|
||||
|
||||
check::equal(ref_int(3), 3, "ref_int failed");
|
||||
check::equal(ref_uint(3), 3, "ref_uint failed");
|
||||
check::equal(ref_short(3), 3, "ref_short failed");
|
||||
check::equal(ref_ushort(3), 3, "ref_ushort failed");
|
||||
check::equal(ref_long(3), 3, "ref_long failed");
|
||||
check::equal(ref_ulong(3), 3, "ref_ulong failed");
|
||||
check::equal(ref_schar(3), 3, "ref_schar failed");
|
||||
check::equal(ref_uchar(3), 3, "ref_uchar failed");
|
||||
check::equal(ref_bool(true), true, "ref_bool failed");
|
||||
check::equal(ref_float(3.5), 3.5, "ref_float failed");
|
||||
check::equal(ref_double(3.5), 3.5, "ref_double failed");
|
||||
check::equal(ref_char('x'), 'x', "ref_char failed");
|
||||
//check::equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longlong failed");
|
||||
//check::equal(ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed");
|
||||
printf("TODO: long long and unsigned long long const reference typemaps\n");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
@ -1,15 +1,14 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "rename_scope.php";
|
||||
|
||||
check::classes(array("rename_scope","Interface_UP","Interface_BP","Natural_UP","Natural_BP","Bucket"));
|
||||
|
||||
check::classmethods("Interface_UP",array("__construct"));
|
||||
check::classmethods("Interface_BP",array("__construct"));
|
||||
check::classmethods("Natural_UP",array("__construct","rtest"));
|
||||
check::classmethods("Natural_BP",array("__construct","rtest"));
|
||||
check::classmethods("Interface_UP",array("__construct","__set","__isset","__get"));
|
||||
check::classmethods("Interface_BP",array("__construct","__set","__isset","__get"));
|
||||
check::classmethods("Natural_UP",array("__construct","__set","__isset","__get","rtest"));
|
||||
check::classmethods("Natural_BP",array("__construct","__set","__isset","__get","rtest"));
|
||||
check::classparent("Natural_UP","Interface_UP");
|
||||
check::classparent("Natural_BP","Interface_BP");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "smart_pointer_rename.php";
|
||||
|
||||
check::classes(array("Foo","Bar"));
|
||||
check::classmethods("foo",array("foo","ftest1","ftest2"));
|
||||
check::classmethods("bar",array("__deref__","bar","test","ftest1","ftest2"));
|
||||
check::classmethods("foo",array("ftest1","ftest2","__set","__isset","__get","__construct"));
|
||||
check::classmethods("bar",array("__deref__","test","ftest1","ftest2","__set","__isset","__get","__construct"));
|
||||
$foo=new foo();
|
||||
check::classname("foo",$foo);
|
||||
$bar=new bar($foo);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "sym.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "template_arg_typename.php";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
// Sample test file
|
||||
|
||||
require "tests.php";
|
||||
require "valuewrapper_base.php";
|
||||
|
|
@ -7,7 +6,7 @@ require "valuewrapper_base.php";
|
|||
check::classes(array("valuewrapper_base","Base","Interface_BP"));
|
||||
check::functions("make_interface_bp");
|
||||
|
||||
$ibp=make_interface_bp();
|
||||
$ibp=valuewrapper_base::make_interface_bp();
|
||||
check::classname("interface_bp",$ibp);
|
||||
|
||||
check::done();
|
||||
|
|
|
|||
|
|
@ -1,20 +1,23 @@
|
|||
%module php_namewarn_rename
|
||||
|
||||
#ifdef SWIGPHP
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) Empty();
|
||||
// FIXME: this doesn't work for me:
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) stdClass;
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) Hello::empty();
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
|
||||
void Empty() {};
|
||||
|
||||
void Empty() {}
|
||||
|
||||
class stdClass
|
||||
class stdClass
|
||||
{
|
||||
};
|
||||
|
||||
struct Hello
|
||||
struct Hello
|
||||
{
|
||||
void empty() {}
|
||||
void empty() {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -139,13 +139,13 @@ endif
|
|||
|
||||
# Clean: remove the generated .py file
|
||||
%.clean:
|
||||
@rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
|
||||
@rm -f $*.py;
|
||||
@#We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
|
||||
@if [ -f $(py2_runme) ]; then rm -f $(py3_runme) $(py3_runme).bak; fi
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean
|
||||
rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
|
||||
|
||||
cvsignore:
|
||||
@echo '*wrap* *.pyc *.so *.dll *.exp *.lib'
|
||||
|
|
@ -168,3 +168,4 @@ hugemod:
|
|||
$(MAKE) hugemod_b.cpptest
|
||||
sh -c "time $(PYTHON) $(hugemod_runme)"
|
||||
sh -c "time $(PYTHON) $(hugemod_runme)"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
from overload_template import *
|
||||
f = foo()
|
||||
|
||||
a = max(3,4)
|
||||
b = max(3.4,5.2)
|
||||
a = maximum(3,4)
|
||||
b = maximum(3.4,5.2)
|
||||
|
||||
# mix 1
|
||||
if (mix1("hi") != 101):
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
enum Polarization { UnaryPolarization, BinaryPolarization };
|
||||
|
||||
template <Polarization P>
|
||||
struct Interface
|
||||
struct Interface_
|
||||
{
|
||||
};
|
||||
}
|
||||
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
namespace oss
|
||||
{
|
||||
// Interface
|
||||
%template(Interface_UP) Interface<UnaryPolarization>;
|
||||
%template(Interface_BP) Interface<BinaryPolarization>;
|
||||
// Interface_
|
||||
%template(Interface_UP) Interface_<UnaryPolarization>;
|
||||
%template(Interface_BP) Interface_<BinaryPolarization>;
|
||||
|
||||
}
|
||||
%inline
|
||||
|
|
@ -27,7 +27,7 @@ namespace oss
|
|||
namespace interfaces
|
||||
{
|
||||
template <Polarization P>
|
||||
struct Natural : Interface<P>
|
||||
struct Natural : Interface_<P>
|
||||
{
|
||||
int test(void) { return 1; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -98,6 +98,13 @@ sv[1] = Li_std_vector::Struct.new
|
|||
|
||||
EOF
|
||||
|
||||
bv = BoolVector.new(2)
|
||||
[true, false, true, true].each { |i| bv.push(i) }
|
||||
0.upto(bv.size-1) { |i| bv[i] = !bv[i] }
|
||||
bv_check = [true, true, false, true, false, false]
|
||||
for i in 0..bv.size-1 do
|
||||
swig_assert(bv_check[i] == bv[i], binding, "bv[#{i}]")
|
||||
end
|
||||
|
||||
swig_assert_each_line(<<'EOF', binding)
|
||||
lv = LanguageVector.new
|
||||
|
|
|
|||
|
|
@ -13,5 +13,5 @@ require 'overload_template'
|
|||
|
||||
f = Overload_template.foo()
|
||||
|
||||
a = Overload_template.max(3,4)
|
||||
b = Overload_template.max(3.4,5.2)
|
||||
a = Overload_template.maximum(3,4)
|
||||
b = Overload_template.maximum(3.4,5.2)
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@
|
|||
enum Polarization { UnaryPolarization, BinaryPolarization };
|
||||
|
||||
template <Polarization P>
|
||||
struct Interface
|
||||
struct Interface_
|
||||
{
|
||||
};
|
||||
|
||||
namespace modules
|
||||
{
|
||||
|
||||
template <class traits, class base = Interface<traits::pmode> >
|
||||
template <class traits, class base = Interface_<traits::pmode> >
|
||||
// *** problem here ****
|
||||
struct Module : base
|
||||
{
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
namespace oss
|
||||
{
|
||||
%template(Interface_UP) Interface<UnaryPolarization>;
|
||||
%template(Interface_UP) Interface_<UnaryPolarization>;
|
||||
namespace modules
|
||||
{
|
||||
%template(Module_etraits) Module<etraits>;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
enum Polarization { UnaryPolarization, BinaryPolarization };
|
||||
|
||||
template <Polarization P>
|
||||
struct Interface
|
||||
struct Interface_
|
||||
{
|
||||
};
|
||||
|
||||
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
namespace oss
|
||||
{
|
||||
%template(Interface_UP) Interface<UnaryPolarization>;
|
||||
%template(Module_UPIUP) Module<UnaryPolarization,Interface<UnaryPolarization> >;
|
||||
%template(Interface_UP) Interface_<UnaryPolarization>;
|
||||
%template(Module_UPIUP) Module<UnaryPolarization,Interface_<UnaryPolarization> >;
|
||||
}
|
||||
|
||||
%inline %{
|
||||
|
|
@ -31,18 +31,18 @@ namespace oss
|
|||
namespace hello
|
||||
{
|
||||
struct HInterface1 :
|
||||
Interface<oss::UnaryPolarization> // this works (with fullns qualification)
|
||||
Interface_<oss::UnaryPolarization> // this works (with fullns qualification)
|
||||
{
|
||||
};
|
||||
|
||||
struct HInterface2 :
|
||||
Interface<UnaryPolarization> // this doesn't work
|
||||
Interface_<UnaryPolarization> // this doesn't work
|
||||
{
|
||||
};
|
||||
|
||||
struct HModule1 : Module<UnaryPolarization, Interface<UnaryPolarization> > {
|
||||
struct HModule1 : Module<UnaryPolarization, Interface_<UnaryPolarization> > {
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
%}
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
enum Polarization { UnaryPolarization, BinaryPolarization };
|
||||
|
||||
template <Polarization P>
|
||||
struct Interface
|
||||
struct Interface_
|
||||
{
|
||||
};
|
||||
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
typedef Traits traits;
|
||||
static const Polarization P = traits::pmode;
|
||||
|
||||
void get(Interface<P> arg) { }; // Here P is only replace by traits::pmode
|
||||
void get(Interface_<P> arg) { }; // Here P is only replace by traits::pmode
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -34,6 +34,6 @@
|
|||
|
||||
namespace oss
|
||||
{
|
||||
%template(Interface_UP) Interface<UnaryPolarization>;
|
||||
%template(Interface_UP) Interface_<UnaryPolarization>;
|
||||
%template(Module_UP) Module<etraits>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
%warnfilter(SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE) convolve1<float>();
|
||||
%warnfilter(SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE) convolve3<float>();
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
///////////////////
|
||||
%ignore convolve1<float>(float a);
|
||||
|
||||
|
|
@ -76,3 +78,23 @@ struct Klass {
|
|||
%template(KlassTMethodBool) Klass::tmethod<bool>;
|
||||
%template(KlassStaticTMethodBool) Klass::statictmethod<bool>;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
%inline %{
|
||||
class ComponentProperties{
|
||||
public:
|
||||
ComponentProperties() {}
|
||||
~ComponentProperties() {}
|
||||
|
||||
template <typename T1> void adda(std::string key, T1 val) {}
|
||||
template <typename T1, typename T2> void adda(std::string key1, T1 val1, std::string key2, T2 val2) {}
|
||||
template <typename T1, typename T2, typename T3> void adda(std::string key1, T1 val1, std::string key2, T2 val2, std::string key3, T3 val3) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%extend ComponentProperties {
|
||||
%template(adda) adda<std::string, double>;
|
||||
%template(adda) adda<std::string, std::string, std::string>; // ERROR OCCURS HERE
|
||||
%template(adda) adda<int, int, int>;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@
|
|||
};
|
||||
|
||||
template <class ArgType, class ResType>
|
||||
struct Function
|
||||
struct Function_
|
||||
{
|
||||
char *test() { return (char *) "test"; }
|
||||
};
|
||||
|
||||
template <class AF, class RF>
|
||||
struct ArithFunction : Function<AF, RF>
|
||||
struct ArithFunction : Function_<AF, RF>
|
||||
{
|
||||
};
|
||||
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
};
|
||||
|
||||
template <class AF, class RF>
|
||||
class Class : public ArithFunction< typename traits<AF, RF>::arg_type,
|
||||
class Class_ : public ArithFunction< typename traits<AF, RF>::arg_type,
|
||||
typename traits<AF, RF>::res_type >
|
||||
{
|
||||
};
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
typename traits<AF, RF>::base
|
||||
make_Class()
|
||||
{
|
||||
return Class<AF, RF>();
|
||||
return Class_<AF, RF>();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -58,9 +58,9 @@
|
|||
|
||||
%{
|
||||
namespace hello {
|
||||
template struct Function <Double, Double>;
|
||||
template struct Function_ <Double, Double>;
|
||||
template struct ArithFunction <Double, Double>;
|
||||
template class Class <Double, Double>;
|
||||
template class Class_ <Double, Double>;
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -69,9 +69,9 @@
|
|||
// This complains only when using a namespace
|
||||
//
|
||||
%template() traits<Double,Double>;
|
||||
%template(Function_DD) Function <Double, Double>;
|
||||
%template(Function_DD) Function_ <Double, Double>;
|
||||
%template(ArithFunction_DD) ArithFunction <Double, Double>;
|
||||
%template(Class_DD) Class <Double, Double>;
|
||||
%template(Class_DD) Class_ <Double, Double>;
|
||||
%template(make_Class_DD) make_Class <Double, Double>;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
};
|
||||
|
||||
template <Polarization P>
|
||||
struct Interface : Base
|
||||
struct Interface_ : Base
|
||||
{
|
||||
Interface(const Base& b) { };
|
||||
Interface_(const Base& b) { };
|
||||
};
|
||||
|
||||
template <class Result>
|
||||
|
|
@ -23,6 +23,6 @@
|
|||
namespace oss
|
||||
{
|
||||
// Interface
|
||||
%template(Interface_BP) Interface<BinaryPolarization>;
|
||||
%template(make_Interface_BP) make<Interface<BinaryPolarization> >;
|
||||
%template(Interface_BP) Interface_<BinaryPolarization>;
|
||||
%template(make_Interface_BP) make<Interface_<BinaryPolarization> >;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,9 +262,15 @@ SWIGINTERN void SWIG_CSharpException(int code, const char *msg) {
|
|||
|
||||
/* rethrow the unknown exception */
|
||||
|
||||
#ifdef SWIGCSHARP
|
||||
%typemap(throws,noblock=1, canthrow=1) (...) {
|
||||
SWIG_exception(SWIG_RuntimeError,"unknown exception");
|
||||
}
|
||||
#else
|
||||
%typemap(throws,noblock=1) (...) {
|
||||
SWIG_exception(SWIG_RuntimeError,"unknown exception");
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,26 @@
|
|||
|
||||
#if OCTAVE_API_VERSION_OPTION>0
|
||||
#define USE_OCTAVE_API_VERSION OCTAVE_API_VERSION_OPTION
|
||||
#else
|
||||
|
||||
#include <octave/version.h>
|
||||
#ifdef OCTAVE_API_VERSION_N
|
||||
#define USE_OCTAVE_API_VERSION OCTAVE_API_VERSION_N
|
||||
|
||||
#else // Interim hack to distinguish between Octave 3.2 and earlier versions.
|
||||
|
||||
#define ComplexLU __ignore
|
||||
#include <octave/CmplxLU.h>
|
||||
#undef ComplexLU
|
||||
#ifdef octave_Complex_LU_h
|
||||
#define USE_OCTAVE_API_VERSION 36
|
||||
#else
|
||||
#define USE_OCTAVE_API_VERSION 37
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
SWIGRUNTIME bool SWIG_check_num_args(const char *func_name, int num_args, int max_args, int min_args, int varargs) {
|
||||
if (num_args > max_args && !varargs)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
#define SWIG_SetConstant(name, obj) SWIG_Octave_SetConstant(module_ns,name,obj)
|
||||
|
||||
// raise
|
||||
#define SWIG_Octave_Raise(obj, type, desc) error("c++-side threw an exception")
|
||||
#define SWIG_Octave_Raise(OBJ, TYPE, DESC) error("C++ side threw an exception of type " TYPE)
|
||||
#define SWIG_Raise(obj, type, desc) SWIG_Octave_Raise(obj, type, desc)
|
||||
|
||||
// Include the unified typemap library
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
#ifdef do_close
|
||||
#undef do_close
|
||||
#endif
|
||||
#ifdef do_exec
|
||||
#undef do_exec
|
||||
#endif
|
||||
#ifdef scalar
|
||||
#undef scalar
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
/* for raw pointers */
|
||||
#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags)
|
||||
#define SWIG_ConvertPtrAndOwn(obj, pp, type, flags,own) SWIG_Perl_ConvertPtrAndOwn(SWIG_PERL_OBJECT_CALL obj, pp, type, flags, own)
|
||||
#define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags)
|
||||
|
||||
/* for raw packed data */
|
||||
|
|
@ -234,10 +235,14 @@ SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) {
|
|||
/* Function for getting a pointer value */
|
||||
|
||||
SWIGRUNTIME int
|
||||
SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) {
|
||||
SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags, int *own) {
|
||||
swig_cast_info *tc;
|
||||
void *voidptr = (void *)0;
|
||||
SV *tsv = 0;
|
||||
|
||||
if (own)
|
||||
*own = 0;
|
||||
|
||||
/* If magical, apply more magic */
|
||||
if (SvGMAGICAL(sv))
|
||||
mg_get(sv);
|
||||
|
|
@ -287,7 +292,11 @@ SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *
|
|||
{
|
||||
int newmemory = 0;
|
||||
*ptr = SWIG_TypeCast(tc,voidptr,&newmemory);
|
||||
assert(!newmemory); /* newmemory handling not yet implemented */
|
||||
if (newmemory == SWIG_CAST_NEW_MEMORY) {
|
||||
assert(own);
|
||||
if (own)
|
||||
*own = *own | SWIG_CAST_NEW_MEMORY;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*ptr = voidptr;
|
||||
|
|
@ -317,9 +326,14 @@ SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
SWIGRUNTIME int
|
||||
SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) {
|
||||
return SWIG_Perl_ConvertPtrAndOwn(sv, ptr, _t, flags, 0);
|
||||
}
|
||||
|
||||
SWIGRUNTIME void
|
||||
SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) {
|
||||
if (ptr && (flags & SWIG_SHADOW)) {
|
||||
if (ptr && (flags & (SWIG_SHADOW | SWIG_POINTER_OWN))) {
|
||||
SV *self;
|
||||
SV *obj=newSV(0);
|
||||
HV *hash=newHV();
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@
|
|||
%pass_by_val(double, CONVERT_FLOAT_IN);
|
||||
|
||||
%pass_by_val(char *, CONVERT_STRING_IN);
|
||||
%typemap(in) char *& = const char *&;
|
||||
%typemap(directorout) char *& = const char *&;
|
||||
|
||||
// char array can be in/out, though the passed string may not be big enough...
|
||||
// so we have to size it
|
||||
|
|
@ -112,6 +114,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) SWIGTYPE *& ($*ltype temp)
|
||||
{
|
||||
if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) {
|
||||
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $*1_descriptor");
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) SWIGTYPE *DISOWN
|
||||
{
|
||||
if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) {
|
||||
|
|
@ -184,6 +194,21 @@
|
|||
ZVAL_LONG(return_value,$1);
|
||||
}
|
||||
|
||||
%typemap(out) const int &,
|
||||
const unsigned int &,
|
||||
const short &,
|
||||
const unsigned short &,
|
||||
const long &,
|
||||
const unsigned long &,
|
||||
const signed char &,
|
||||
const unsigned char &,
|
||||
const bool &,
|
||||
const size_t &,
|
||||
const enum SWIGTYPE &
|
||||
{
|
||||
ZVAL_LONG(return_value,*$1);
|
||||
}
|
||||
|
||||
%typemap(directorin) int,
|
||||
unsigned int,
|
||||
short,
|
||||
|
|
@ -203,6 +228,11 @@
|
|||
ZVAL_BOOL(return_value,($1)?1:0);
|
||||
}
|
||||
|
||||
%typemap(out) const bool &
|
||||
{
|
||||
ZVAL_BOOL(return_value,(*$1)?1:0);
|
||||
}
|
||||
|
||||
%typemap(directorin) bool
|
||||
{
|
||||
ZVAL_BOOL($input,($1_name)?1:0);
|
||||
|
|
@ -214,8 +244,14 @@
|
|||
ZVAL_DOUBLE(return_value,$1);
|
||||
}
|
||||
|
||||
%typemap(out) const float &,
|
||||
const double &
|
||||
{
|
||||
ZVAL_DOUBLE(return_value,*$1);
|
||||
}
|
||||
|
||||
%typemap(directorin) float,
|
||||
double
|
||||
double
|
||||
{
|
||||
ZVAL_DOUBLE($input,$1_name);
|
||||
}
|
||||
|
|
@ -225,6 +261,11 @@
|
|||
ZVAL_STRINGL(return_value,&$1, 1, 1);
|
||||
}
|
||||
|
||||
%typemap(out) const char &
|
||||
{
|
||||
ZVAL_STRINGL(return_value,&*$1, 1, 1);
|
||||
}
|
||||
|
||||
%typemap(out) char *,
|
||||
char []
|
||||
{
|
||||
|
|
@ -235,6 +276,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(out) char *&
|
||||
{
|
||||
if(!*$1) {
|
||||
ZVAL_NULL(return_value);
|
||||
} else {
|
||||
ZVAL_STRING(return_value, (char *)*$1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(out) SWIGTYPE *,
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE &
|
||||
|
|
@ -242,9 +292,14 @@
|
|||
SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner);
|
||||
%}
|
||||
|
||||
%typemap(out) SWIGTYPE *&
|
||||
%{
|
||||
SWIG_SetPointerZval(return_value, (void *)*$1, $*1_descriptor, $owner);
|
||||
%}
|
||||
|
||||
%typemap(directorin) SWIGTYPE *,
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE &
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE &
|
||||
%{
|
||||
SWIG_SetPointerZval($input, (void *)&$1_name, $1_descriptor, $owner);
|
||||
%}
|
||||
|
|
@ -271,17 +326,13 @@
|
|||
#endif
|
||||
|
||||
%typemap(directorin) SWIGTYPE
|
||||
#ifdef __cplusplus
|
||||
{
|
||||
SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1_name), $&1_descriptor, 2);
|
||||
}
|
||||
#else
|
||||
{
|
||||
$&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type));
|
||||
memcpy(resultobj, &$1, sizeof($1_type));
|
||||
SWIG_SetPointerZval($input, (void *)resultobj, $&1_descriptor, 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
|
||||
|
||||
%typemap(out) void "";
|
||||
|
||||
|
|
@ -296,7 +347,7 @@
|
|||
// an argument to be converted from a different PHP type, you must convert
|
||||
// it yourself before passing it (e.g. (string)4.7 or (int)"6").
|
||||
%define %php_typecheck(_type,_prec,is)
|
||||
%typemap(typecheck,precedence=_prec) _type
|
||||
%typemap(typecheck,precedence=_prec) _type, const _type &
|
||||
" $1 = (Z_TYPE_PP($input) == is); "
|
||||
%enddef
|
||||
|
||||
|
|
@ -311,13 +362,12 @@
|
|||
%php_typecheck(size_t,SWIG_TYPECHECK_INT16,IS_LONG)
|
||||
%php_typecheck(enum SWIGTYPE,SWIG_TYPECHECK_INT8,IS_LONG)
|
||||
%php_typecheck(bool,SWIG_TYPECHECK_BOOL,IS_BOOL)
|
||||
|
||||
%php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING)
|
||||
%php_typecheck(char *,SWIG_TYPECHECK_STRING,IS_STRING)
|
||||
%php_typecheck(char [],SWIG_TYPECHECK_STRING,IS_STRING)
|
||||
|
||||
%php_typecheck(float,SWIG_TYPECHECK_FLOAT,IS_DOUBLE)
|
||||
%php_typecheck(double,SWIG_TYPECHECK_BOOL,IS_DOUBLE)
|
||||
%php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING)
|
||||
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&, char []
|
||||
" $1 = (Z_TYPE_PP($input) == IS_STRING); "
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE
|
||||
{
|
||||
|
|
@ -327,7 +377,8 @@
|
|||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *,
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE &
|
||||
SWIGTYPE &,
|
||||
SWIGTYPE *&
|
||||
{
|
||||
void *tmp;
|
||||
_v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP") "::" `x`
|
||||
#define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x`
|
||||
|
||||
|
||||
/*
|
||||
From
|
||||
|
||||
|
|
@ -475,6 +474,8 @@ PHPFN(sqrt);
|
|||
PHPFN(ceil);
|
||||
PHPFN(floor);
|
||||
PHPFN(fmod);
|
||||
PHPFN(min);
|
||||
PHPFN(max);
|
||||
|
||||
#undef PHPKW
|
||||
#undef PHPBN1
|
||||
|
|
|
|||
|
|
@ -113,8 +113,14 @@ SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject
|
|||
value->ptr=ptr;
|
||||
value->newobject=newobject;
|
||||
if (newobject <= 1) {
|
||||
/* Just register the pointer as a resource. */
|
||||
ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata));
|
||||
} else {
|
||||
/*
|
||||
* Wrap the resource in an object, the resource will be accessible
|
||||
* via the "_cPtr" member. This is currently only used by
|
||||
* directorin typemaps.
|
||||
*/
|
||||
value->newobject = 0;
|
||||
zval *resource;
|
||||
MAKE_STD_ZVAL(resource);
|
||||
|
|
|
|||
|
|
@ -3,132 +3,103 @@
|
|||
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
|
||||
*
|
||||
* std_vector.i
|
||||
*
|
||||
* SWIG typemaps for std::vector types
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::vector
|
||||
//
|
||||
// The aim of all that follows would be to integrate std::vector with
|
||||
// PHP as much as possible, namely, to allow the user to pass and
|
||||
// be returned PHP lists.
|
||||
// const declarations are used to guess the intent of the function being
|
||||
// exported; therefore, the following rationale is applied:
|
||||
//
|
||||
// -- f(std::vector<T>), f(const std::vector<T>&), f(const std::vector<T>*):
|
||||
// the parameter being read-only, either a PHP sequence or a
|
||||
// previously wrapped std::vector<T> can be passed.
|
||||
// -- f(std::vector<T>&), f(std::vector<T>*):
|
||||
// the parameter must be modified; therefore, only a wrapped std::vector
|
||||
// can be passed.
|
||||
// -- std::vector<T> f():
|
||||
// the vector is returned by copy; therefore, a PHP sequence of T:s
|
||||
// is returned which is most easily used in other PHP functions
|
||||
// -- std::vector<T>& f(), std::vector<T>* f(), const std::vector<T>& f(),
|
||||
// const std::vector<T>* f():
|
||||
// the vector is returned by reference; therefore, a wrapped std::vector
|
||||
// is returned
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
// exported class
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T> class vector {
|
||||
// add generic typemaps here
|
||||
public:
|
||||
vector(unsigned int size = 0);
|
||||
unsigned int size() const;
|
||||
%rename(is_empty) empty;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%rename(push) push_back;
|
||||
void push_back(const T& x);
|
||||
%extend {
|
||||
T pop() throw (std::out_of_range) {
|
||||
if (self->size() == 0)
|
||||
throw std::out_of_range("pop from empty vector");
|
||||
T x = self->back();
|
||||
self->pop_back();
|
||||
return x;
|
||||
}
|
||||
T& get(int i) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i>=0 && i<size)
|
||||
return (*self)[i];
|
||||
else
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
void set(int i, const T& x) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i>=0 && i<size)
|
||||
(*self)[i] = x;
|
||||
else
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class T> class vector {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef T value_type;
|
||||
typedef const value_type& const_reference;
|
||||
vector();
|
||||
vector(size_type n);
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
void clear();
|
||||
%rename(push) push_back;
|
||||
void push_back(const value_type& x);
|
||||
%extend {
|
||||
bool is_empty() const {
|
||||
return $self->empty();
|
||||
}
|
||||
T pop() throw (std::out_of_range) {
|
||||
if (self->size() == 0)
|
||||
throw std::out_of_range("pop from empty vector");
|
||||
T x = self->back();
|
||||
self->pop_back();
|
||||
return x;
|
||||
}
|
||||
const_reference get(int i) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i>=0 && i<size)
|
||||
return (*self)[i];
|
||||
else
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
void set(int i, const value_type& val) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i>=0 && i<size)
|
||||
(*self)[i] = val;
|
||||
else
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// specializations for built-ins
|
||||
|
||||
%define specialize_std_vector(T)
|
||||
template<> class vector<T> {
|
||||
// add specialized typemaps here
|
||||
public:
|
||||
vector(unsigned int size = 0);
|
||||
unsigned int size() const;
|
||||
%rename(is_empty) empty;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%rename(push) push_back;
|
||||
void push_back(T x);
|
||||
%extend {
|
||||
T pop() throw (std::out_of_range) {
|
||||
if (self->size() == 0)
|
||||
throw std::out_of_range("pop from empty vector");
|
||||
T x = self->back();
|
||||
self->pop_back();
|
||||
return x;
|
||||
}
|
||||
T get(int i) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i>=0 && i<size)
|
||||
return (*self)[i];
|
||||
else
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
void set(int i, T x) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i>=0 && i<size)
|
||||
(*self)[i] = x;
|
||||
else
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
}
|
||||
};
|
||||
%enddef
|
||||
|
||||
specialize_std_vector(bool);
|
||||
specialize_std_vector(char);
|
||||
specialize_std_vector(int);
|
||||
specialize_std_vector(short);
|
||||
specialize_std_vector(long);
|
||||
specialize_std_vector(unsigned char);
|
||||
specialize_std_vector(unsigned int);
|
||||
specialize_std_vector(unsigned short);
|
||||
specialize_std_vector(unsigned long);
|
||||
specialize_std_vector(float);
|
||||
specialize_std_vector(double);
|
||||
|
||||
// bool specialization
|
||||
template<> class vector<bool> {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef bool value_type;
|
||||
typedef bool const_reference;
|
||||
vector();
|
||||
vector(size_type n);
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
void clear();
|
||||
%rename(push) push_back;
|
||||
void push_back(const value_type& x);
|
||||
%extend {
|
||||
bool is_empty() const {
|
||||
return $self->empty();
|
||||
}
|
||||
bool pop() throw (std::out_of_range) {
|
||||
if (self->size() == 0)
|
||||
throw std::out_of_range("pop from empty vector");
|
||||
bool x = self->back();
|
||||
self->pop_back();
|
||||
return x;
|
||||
}
|
||||
const_reference get(int i) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i>=0 && i<size)
|
||||
return (*self)[i];
|
||||
else
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
void set(int i, const value_type& val) throw (std::out_of_range) {
|
||||
int size = int(self->size());
|
||||
if (i>=0 && i<size)
|
||||
(*self)[i] = val;
|
||||
else
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
%define specialize_std_vector(T)
|
||||
#warning "specialize_std_vector - specialization for type T no longer needed"
|
||||
%enddef
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,14 +33,24 @@
|
|||
%enddef
|
||||
|
||||
%define %pass_by_val( TYPE, CONVERT_IN )
|
||||
%typemap(in) TYPE, const TYPE &
|
||||
%typemap(in) TYPE
|
||||
%{
|
||||
CONVERT_IN($1,$1_ltype,$input);
|
||||
%}
|
||||
%typemap(directorout) TYPE, const TYPE &
|
||||
%typemap(in) const TYPE & ($*1_ltype temp)
|
||||
%{
|
||||
CONVERT_IN(temp,$*1_ltype,$input);
|
||||
$1 = &temp;
|
||||
%}
|
||||
%typemap(directorout) TYPE
|
||||
%{
|
||||
CONVERT_IN($result,$1_ltype,$input);
|
||||
%}
|
||||
%typemap(directorout) const TYPE & ($*1_ltype temp)
|
||||
%{
|
||||
CONVERT_IN(temp,$*1_ltype,$input);
|
||||
$result = &temp;
|
||||
%}
|
||||
%enddef
|
||||
|
||||
%fragment("t_output_helper","header") %{
|
||||
|
|
|
|||
|
|
@ -1163,10 +1163,10 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
|
|||
/* here we get the method pointer for callbacks */
|
||||
const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
|
||||
const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
|
||||
if (desc) {
|
||||
if (desc)
|
||||
desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
|
||||
if (!desc) return SWIG_ERROR;
|
||||
}
|
||||
if (!desc)
|
||||
return SWIG_ERROR;
|
||||
if (ty) {
|
||||
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
|
||||
if (tc) {
|
||||
|
|
|
|||
|
|
@ -875,31 +875,8 @@ namespace swig
|
|||
}
|
||||
%enddef
|
||||
|
||||
// ..I don't think %swig_sequence_methods_val are really used at all anymore...
|
||||
%define %swig_sequence_methods_val(Sequence...)
|
||||
%swig_sequence_methods_common(%arg(Sequence))
|
||||
%extend {
|
||||
|
||||
VALUE __getitem__(difference_type i) {
|
||||
VALUE r = Qnil;
|
||||
try {
|
||||
r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) );
|
||||
}
|
||||
catch( std::out_of_range )
|
||||
{
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
VALUE __setitem__(difference_type i, value_type x) {
|
||||
std::size_t len = $self->size();
|
||||
if ( i < 0 ) i = len - i;
|
||||
else if ( static_cast<std::size_t>(i) >= len )
|
||||
$self->resize( i+1, x );
|
||||
else *(swig::getpos(self,i)) = x;
|
||||
return swig::from< Sequence::value_type >( x );
|
||||
}
|
||||
}
|
||||
%swig_sequence_methods(%arg(Sequence))
|
||||
%enddef
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ clean-docs-main:
|
|||
@test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) clean
|
||||
|
||||
clean-docs-ccache:
|
||||
@test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) clean-docs)
|
||||
@# Use distclean-docs-ccache, else a user requires the yodl tools to generate the docs after a clean
|
||||
|
||||
maintainer-clean: clean-libfiles
|
||||
@cd $(SOURCE) && $(MAKE) maintainer-clean
|
||||
|
|
@ -407,6 +407,9 @@ distclean-test-suite:
|
|||
distclean-ccache:
|
||||
test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s distclean)
|
||||
|
||||
distclean-docs-ccache:
|
||||
@test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) distclean-docs)
|
||||
|
||||
distclean-dead:
|
||||
rm -f $(DISTCLEAN-DEAD)
|
||||
|
||||
|
|
|
|||
4
README
4
README
|
|
@ -96,6 +96,10 @@ A SWIG FAQ and other hints can be found on the SWIG Wiki:
|
|||
What's New?
|
||||
===========
|
||||
|
||||
SWIG-1.3.40 summary:
|
||||
- SWIG now supports directors for PHP.
|
||||
- PHP support improved in general.
|
||||
|
||||
SWIG-1.3.39 summary:
|
||||
- Some new small feature enhancements.
|
||||
- Improved C# std::vector wrappers.
|
||||
|
|
|
|||
|
|
@ -2726,7 +2726,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
Parm *ti = targs;
|
||||
String *tv = Getattr(tp,"value");
|
||||
if (!tv) tv = Getattr(tp,"type");
|
||||
while(pi != tp) {
|
||||
while(pi != tp && ti && pi) {
|
||||
String *name = Getattr(ti,"name");
|
||||
String *value = Getattr(pi,"value");
|
||||
if (!value) value = Getattr(pi,"type");
|
||||
|
|
|
|||
|
|
@ -527,8 +527,7 @@ class Allocate:public Dispatcher {
|
|||
}
|
||||
ParmList *throws = Getattr(n, "throws");
|
||||
if (throws) {
|
||||
/* if there is no an explicit catchlist,
|
||||
we catch everything in the throwlist */
|
||||
/* if there is no explicit catchlist, we catch everything in the throws list */
|
||||
if (!catchlist) {
|
||||
Setattr(n, "catchlist", throws);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -898,9 +898,9 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// Get any C# exception classes in the throws typemap
|
||||
// Look for usage of throws typemap and the canthrow flag
|
||||
ParmList *throw_parm_list = NULL;
|
||||
if ((throw_parm_list = Getattr(n, "throws"))) {
|
||||
if ((throw_parm_list = Getattr(n, "catchlist"))) {
|
||||
Swig_typemap_attach_parms("throws", throw_parm_list, f);
|
||||
for (p = throw_parm_list; p; p = nextSibling(p)) {
|
||||
if ((tm = Getattr(p, "tmap:throws"))) {
|
||||
|
|
@ -3063,13 +3063,6 @@ public:
|
|||
return tm;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* addThrows()
|
||||
// TODO: remove
|
||||
* ----------------------------------------------------------------------------- */
|
||||
void addThrows(Node *, const String *, Node *) {
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* canThrow()
|
||||
* Determine whether the code in the typemap can throw a C# exception.
|
||||
|
|
@ -3417,10 +3410,6 @@ public:
|
|||
|
||||
Printf(arg, "j%s", ln);
|
||||
|
||||
/* Add various typemap's 'throws' clauses */
|
||||
addThrows(n, "tmap:directorin", p);
|
||||
addThrows(n, "tmap:out", p);
|
||||
|
||||
/* And add to the upcall args */
|
||||
if (gencomma > 0)
|
||||
Printf(jupcall_args, ", ");
|
||||
|
|
@ -3549,9 +3538,8 @@ public:
|
|||
Printf(declaration, " virtual %s", target);
|
||||
Delete(target);
|
||||
|
||||
// Get any Java exception classes in the throws typemap
|
||||
// Add any exception specifications to the methods in the director class
|
||||
ParmList *throw_parm_list = NULL;
|
||||
|
||||
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
|
||||
int gencomma = 0;
|
||||
|
||||
|
|
@ -3562,13 +3550,10 @@ public:
|
|||
Swig_typemap_attach_parms("throws", throw_parm_list, 0);
|
||||
for (p = throw_parm_list; p; p = nextSibling(p)) {
|
||||
if ((tm = Getattr(p, "tmap:throws"))) {
|
||||
addThrows(n, "tmap:throws", p);
|
||||
|
||||
if (gencomma++) {
|
||||
Append(w->def, ", ");
|
||||
Append(declaration, ", ");
|
||||
}
|
||||
|
||||
Printf(w->def, "%s", SwigType_str(Getattr(p, "type"), 0));
|
||||
Printf(declaration, "%s", SwigType_str(Getattr(p, "type"), 0));
|
||||
}
|
||||
|
|
@ -3621,7 +3606,6 @@ public:
|
|||
|
||||
/* Copy jresult into c_result... */
|
||||
if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) {
|
||||
addThrows(n, "tmap:directorout", tp);
|
||||
Replaceall(tm, "$input", jresult_str);
|
||||
Replaceall(tm, "$result", result_str);
|
||||
Printf(w->code, "%s\n", tm);
|
||||
|
|
|
|||
|
|
@ -980,7 +980,7 @@ public:
|
|||
|
||||
// Get any Java exception classes in the throws typemap
|
||||
ParmList *throw_parm_list = NULL;
|
||||
if ((throw_parm_list = Getattr(n, "throws"))) {
|
||||
if ((throw_parm_list = Getattr(n, "catchlist"))) {
|
||||
Swig_typemap_attach_parms("throws", throw_parm_list, f);
|
||||
for (p = throw_parm_list; p; p = nextSibling(p)) {
|
||||
if ((tm = Getattr(p, "tmap:throws"))) {
|
||||
|
|
@ -3679,6 +3679,7 @@ public:
|
|||
Printf(declaration, " virtual %s", target);
|
||||
Delete(target);
|
||||
|
||||
// Add any exception specifications to the methods in the director class
|
||||
// Get any Java exception classes in the throws typemap
|
||||
ParmList *throw_parm_list = NULL;
|
||||
|
||||
|
|
|
|||
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