Merge branch 'master' into directorargout_and_java_typemaps

This commit is contained in:
Andrey Starodubtsev 2016-10-13 14:14:59 +03:00
commit b9cdc3c5e1
83 changed files with 1602 additions and 946 deletions

View file

@ -162,9 +162,6 @@ matrix:
- compiler: clang
os: osx
env: SWIGLANG=go
- compiler: clang
os: osx
env: SWIGLANG=guile
- compiler: clang
os: osx
env: SWIGLANG=java
@ -199,6 +196,10 @@ matrix:
- compiler: gcc
os: linux
env: SWIGLANG=python SWIG_FEATURES=-O
# brew install guile fails on Travis as OSX 10.9 is too old now, default osx_image needs changing
- compiler: clang
os: osx
env: SWIGLANG=guile
before_install:
- date -u
- uname -a

View file

@ -5,6 +5,120 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 3.0.11 (in progress)
============================
2016-09-29: wsfulton
[Allegrocl, CFFI, GO, Javascript, Ocaml, R, Scilab]
Add missing support for the "ret" typemap in a few target languages.
The documentation also now has info on the "ret" typemap.
2016-09-27: ahmed-usman
[xml] Handle template parameters correctly.
2016-09-27: dontpanic92
[Go] Fix argument names in inherited functions taking more than 8
parameters. Fixes #795.
2016-09-26: smarchetto
[Scilab] mlists that map pointers can be given a custom type name.
2016-09-25: wsfulton
Patch #793 from q-p to expand exception handling to include std::bad_cast
in std_except.i.
2016-09-24: olly
[PHP] Fix code generated for feature("director:except") -
previously the return value of call_user_function() was ignored and
we checked an uninitialised value instead. Fixes #627. Based on
patch from Sergey Seroshtan.
2016-09-22: wsfulton
[Python] More flexible python builtin slots for overloaded C++ function.
The closure names used for builtin slots are mangled with their functype so
that overloaded C++ method names can be used for multiple slots.
For example:
%feature("python:slot", "mp_subscript", functype="binaryfunc") SimpleArray::__getitem__;
%feature("python:slot", "sq_item", functype="ssizeargfunc") SimpleArray::__getitem__(Py_ssize_t n);
will generate closures:
SWIGPY_SSIZEARGFUNC_CLOSURE(_wrap_SimpleArray___getitem__) /* defines _wrap_SimpleArray___getitem___ssizeargfunc_closure */
SWIGPY_BINARYFUNC_CLOSURE(_wrap_SimpleArray___getitem__) /* defines _wrap_SimpleArray___getitem___binaryfunc_closure */
Previously only one name was defined: _wrap_SimpleArray___getitem___closure.
Hence the overloaded __getitem__ method can be used to support both mp_subscript and sq_item slots.
2016-09-17: wsfulton
[Python] Fix iterators for containers of NULL pointers (or Python None) when using
-builtin. Previously iteration would stop at the first element that was NULL.
2016-09-16: olly
[Javascript] Fix SWIG_exception() macro to return from the current
function. Fixes #789, reported by Julien Dutriaux.
2016-09-16: olly
[PHP] Fix SWIG_exception() macro to return from the current function.
Fixes #240, reported by Sergey Seroshtan.
2016-09-12: xypron
[C#] Patch #786 Keyword rename to be CLS compliant by adding an underscore
suffix instead of an underscore suffix to the C symbol name. Please use an explicit
%rename to rename the symbol with a _ prefix if you want the old symbol name.
*** POTENTIAL INCOMPATIBILITY ***
2016-09-09: olly
[Python] Fix import handling for Python 2.6 to work in a frozen
application. Fixes #145, reported by Thomas Kluyver.
2016-09-02: smarchetto
[Scilab] Pointers are mapped to mlist instead of tlist
(mlist better for scilab overloading)
2016-09-02: olly
[PHP] Fix "out" typemap for member function pointers and "in"
typemap for char INPUT[ANY].
2016-09-01: wsfulton
[Python] More efficient Python slicing.
Call reserve for container types that support it to avoid repeated
memory reallocations for new slices or slices that grow in size.
2016-09-01: wsfulton
[Python] #771 - Make builtin types hashable by default.
Default hash is the underlying C/C++ pointer. This matches up with testing for
equivalence (Py_EQ in SwigPyObject_richcompare) which compares the pointers.
2016-08-22: wsfulton
[Python] The following builtin slots can be customized like other slots via the
"python:<x>" and "python:slot" features where <x> is the appropriate slot name:
tp_allocs
tp_bases
tp_basicsize
tp_cache
tp_del
tp_dealloc
tp_flags
tp_frees
tp_getset
tp_is_gc
tp_maxalloc
tp_methods
tp_mro
tp_new
tp_next
tp_prev
tp_richcompare
tp_subclasses
tp_weaklist
was_sq_ass_slice
was_sq_slice
A few documentation improvements for slot customization.
2016-08-09: joequant
[R] Patch #765 Fix extern "C" header includes for C++ code.
2016-08-05: olly
[xml] Fix how the output filename is built to avoid problems when
it contains the embedded strings ".c", ".cpp" or ".cxx".

View file

@ -310,7 +310,7 @@
<li><a href="CPlusPlus11.html#CPlusPlus11_general_purpose_smart_pointers">General-purpose smart pointers</a>
<li><a href="CPlusPlus11.html#CPlusPlus11_extensible_random_number_facility">Extensible random number facility</a>
<li><a href="CPlusPlus11.html#CPlusPlus11_wrapper_reference">Wrapper reference</a>
<li><a href="CPlusPlus11.html#CPlusPlus11_polymorphous_wrappers_for_function_objects">Polymorphous wrappers for function objects</a>
<li><a href="CPlusPlus11.html#CPlusPlus11_polymorphous_wrappers_for_function_objects">Polymorphic wrappers for function objects</a>
<li><a href="CPlusPlus11.html#CPlusPlus11_type_traits_for_metaprogramming">Type traits for metaprogramming</a>
<li><a href="CPlusPlus11.html#CPlusPlus11_uniform_method_for_computing_return_type_of_function_objects">Uniform method for computing return type of function objects</a>
</ul>
@ -457,6 +457,7 @@
<li><a href="Typemaps.html#Typemaps_nn32">"argout" typemap</a>
<li><a href="Typemaps.html#Typemaps_nn33">"freearg" typemap</a>
<li><a href="Typemaps.html#Typemaps_nn34">"newfree" typemap</a>
<li><a href="Typemaps.html#Typemaps_ret">"ret" typemap</a>
<li><a href="Typemaps.html#Typemaps_nn35">"memberin" typemap</a>
<li><a href="Typemaps.html#Typemaps_nn36">"varin" typemap</a>
<li><a href="Typemaps.html#Typemaps_nn37">"varout" typemap</a>
@ -1529,7 +1530,7 @@
<li><a href="Python.html#Python_builtin_types">Built-in Types</a>
<ul>
<li><a href="Python.html#Python_builtin_limitations">Limitations</a>
<li><a href="Python.html#Python_builtin_overloads">Operator overloads -- use them!</a>
<li><a href="Python.html#Python_builtin_overloads">Operator overloads and slots -- use them!</a>
</ul>
<li><a href="Python.html#Python_nn30">Memory management</a>
<li><a href="Python.html#Python_nn31">Python 2.2 and classic classes</a>

View file

@ -51,7 +51,7 @@
<li><a href="#Python_builtin_types">Built-in Types</a>
<ul>
<li><a href="#Python_builtin_limitations">Limitations</a>
<li><a href="#Python_builtin_overloads">Operator overloads -- use them!</a>
<li><a href="#Python_builtin_overloads">Operator overloads and slots -- use them!</a>
</ul>
<li><a href="#Python_nn30">Memory management</a>
<li><a href="#Python_nn31">Python 2.2 and classic classes</a>
@ -2442,7 +2442,7 @@ assert(issubclass(B.Derived, A.Base))
</li>
</ul>
<H4><a name="Python_builtin_overloads">36.4.2.2 Operator overloads -- use them!</a></H4>
<H4><a name="Python_builtin_overloads">36.4.2.2 Operator overloads and slots -- use them!</a></H4>
<p>The entire justification for the <tt>-builtin</tt> option is improved
@ -2494,52 +2494,110 @@ automatically converted to python slot operators, refer to the file
<tt>python/pyopers.swig</tt> in the SWIG library.
</p>
<p>There are other very useful python slots that you
may explicitly define using <tt>%feature</tt> directives. For example,
suppose you want to use instances of a wrapped class as keys in a native python
<tt>dict</tt>. That will work as long as you define a hash function for
instances of your class, and use it to define the python <tt>tp_hash</tt>
slot:
<p>
Read about all of the available python slots here:
<a href="http://docs.python.org/c-api/typeobj.html">http://docs.python.org/c-api/typeobj.html</a></p>
<p>
There are two ways to define a python slot function: dispatch to a
statically defined function; or dispatch to a method defined on the
operand.
</p>
<p>
To dispatch to a statically defined function, use %feature("python:&lt;slot&gt;"),
where &lt;slot&gt; is the name of a field in a <tt>PyTypeObject, PyNumberMethods,
PyMappingMethods, PySequenceMethods</tt> or <tt>PyBufferProcs</tt>.
You may override (almost) all of these slots.
</p>
<p>
Let's consider an example setting the <tt>tp_hash</tt> slot for the <tt>MyClass</tt> type.
This is akin to providing a <tt>__hash__</tt> method (for non-builtin types) to make a type hashable.
The hashable type can then for example be added to a Python <tt>dict</tt>.
</p>
<div class="code">
<pre>
%feature("python:slot", "tp_hash", functype="hashfunc") Cheese::cheeseHashFunc;
%feature("python:tp_hash") MyClass "myHashFunc";
class Cheese {
class MyClass {
public:
Cheese (const char *name);
long cheeseHashFunc () const;
long field1;
long field2;
...
};
%{
#if PY_VERSION_HEX &gt;= 0x03020000
static Py_hash_t myHashFunc(PyObject *pyobj)
#else
static long myHashFunc(PyObject *pyobj)
#endif
{
MyClass *cobj;
// Convert pyobj to cobj
return (cobj-&gt;field1 * (cobj-&gt;field2 &lt;&lt; 7));
}
%}
</pre>
</div>
<p>
If you examine the generated code, the supplied hash function will now be
the function callback in the tp_hash slot for the builtin type for <tt>MyClass</tt>:
</p>
<div class="code">
<pre>
static PyHeapTypeObject SwigPyBuiltin__MyClass_type = {
...
(hashfunc) myHashFunc, /* tp_hash */
...
</pre>
</div>
<p>
NOTE: It is the responsibility of the programmer (that's you!) to ensure
that a statically defined slot function has the correct signature, the <tt>hashfunc</tt>
typedef in this case.
</p>
<p>
If, instead, you want to dispatch to an instance method, you can
use %feature("python:slot"). For example:
</p>
<div class="code">
<pre>
%feature("python:slot", "tp_hash", functype="hashfunc") MyClass::myHashFunc;
#if PY_VERSION_HEX &lt; 0x03020000
#define Py_hash_t long
#endif
class MyClass {
public:
Py_hash_t myHashFunc() const;
...
};
</pre>
</div>
<p>This will allow you to write python code like this:</p>
<p>
NOTE: Some python slots use a method signature which does not
match the signature of SWIG-wrapped methods. For those slots,
SWIG will automatically generate a "closure" function to re-marshal
the arguments before dispatching to the wrapped method. Setting
the "functype" attribute of the feature enables SWIG to generate
the chosen closure function.
</p>
<div class="targetlang">
<pre>
from my MyPackage import Cheese
inventory = {
Cheese("cheddar") : 0,
Cheese("gouda") : 0,
Cheese("camembert") : 0
}
</pre>
</div>
<p>Because you defined the <tt>tp_hash</tt> slot, <tt>Cheese</tt> objects may
be used as hash keys; and when the <tt>cheeseHashFunc</tt> method is invoked
by a python <tt>dict</tt>, it will <b>not</b> go through named method dispatch.
A more detailed discussion about <tt>%feature("python:slot")</tt> can be found
<p>
There is further information on <tt>%feature("python:slot")</tt>
in the file <tt>python/pyopers.swig</tt> in the SWIG library.
You can read about all of the available python slots here:</p>
<p><a href="http://docs.python.org/c-api/typeobj.html">http://docs.python.org/c-api/typeobj.html</a></p>
<p>You may override (almost) all of the slots defined in the <tt>PyTypeObject,
PyNumberMethods, PyMappingMethods, PySequenceMethods</tt>, and <tt>PyBufferProcs</tt>
structs.
</p>

View file

@ -1123,7 +1123,7 @@ But we can use either use the <tt>get_perimeter()</tt> function of the parent cl
<p>
As explained in <a href="http://www.swig.org/Doc3.0/SWIGPlus.html#SWIGPlus_overloaded_methods">6.15</a> SWIG provides support for overloaded functions and constructors.
As explained in <a href="SWIGPlus.html#SWIGPlus_overloaded_methods">6.15</a> SWIG provides support for overloaded functions and constructors.
</p>
<p>As SWIG knows pointer types, the overloading works also with pointer types, here is is an example with a function <tt>magnify</tt> overloaded for the previous classes <tt>Shape</tt> and <tt>Circle</tt>:

View file

@ -63,6 +63,7 @@
<li><a href="#Typemaps_nn32">"argout" typemap</a>
<li><a href="#Typemaps_nn33">"freearg" typemap</a>
<li><a href="#Typemaps_nn34">"newfree" typemap</a>
<li><a href="#Typemaps_ret">"ret" typemap</a>
<li><a href="#Typemaps_nn35">"memberin" typemap</a>
<li><a href="#Typemaps_nn36">"varin" typemap</a>
<li><a href="#Typemaps_nn37">"varout" typemap</a>
@ -2802,7 +2803,46 @@ string *foo();
See <a href="Customization.html#Customization_ownership">Object ownership and %newobject</a> for further details.
</p>
<H3><a name="Typemaps_nn35">11.5.10 "memberin" typemap</a></H3>
<H3><a name="Typemaps_ret">11.5.10 "ret" typemap</a></H3>
<p>
The "ret" typemap is not used very often, but can be useful for anything associated with
the return type, such as resource management, return value error checking, etc.
Usually this can all be done in the "out" typemap, but sometimes it is handy to use the
"out" typemap code untouched and add to the generated code using the code in the "ret" typemap.
One such case is memory clean up. For example, a <tt>stringheap_t</tt> type is defined indicating
that the returned memory must be deleted and a <tt>string_t</tt> type is defined indicating
that the returned memory must not be deleted.
</p>
<div class="code">
<pre>
%typemap(ret) stringheap_t %{
free($1);
%}
typedef char * string_t;
typedef char * stringheap_t;
string_t MakeString1();
stringheap_t MakeString2();
</pre>
</div>
<p>
The "ret" typemap above will only be used for <tt>MakeString2</tt>, but both functions
will use the default "out" typemap for <tt>char *</tt> provided by SWIG.
The code above would ensure the appropriate memory is freed in all target languages as the need
to provide custom "out" typemaps (which involve target language specific code) is not necessary.
</p>
<p>
This approach is an alternative to using the "newfree" typemap and <tt>%newobject</tt> as there
is no need to list all the functions that require the memory cleanup, it is purely done on types.
</p>
<H3><a name="Typemaps_nn35">11.5.11 "memberin" typemap</a></H3>
<p>
@ -2824,7 +2864,7 @@ It is rarely necessary to write "memberin" typemaps---SWIG already provides
a default implementation for arrays, strings, and other objects.
</p>
<H3><a name="Typemaps_nn36">11.5.11 "varin" typemap</a></H3>
<H3><a name="Typemaps_nn36">11.5.12 "varin" typemap</a></H3>
<p>
@ -2832,7 +2872,7 @@ The "varin" typemap is used to convert objects in the target language to C for t
purposes of assigning to a C/C++ global variable. This is implementation specific.
</p>
<H3><a name="Typemaps_nn37">11.5.12 "varout" typemap</a></H3>
<H3><a name="Typemaps_nn37">11.5.13 "varout" typemap</a></H3>
<p>
@ -2840,7 +2880,7 @@ The "varout" typemap is used to convert a C/C++ object to an object in the targe
language when reading a C/C++ global variable. This is implementation specific.
</p>
<H3><a name="throws_typemap">11.5.13 "throws" typemap</a></H3>
<H3><a name="throws_typemap">11.5.14 "throws" typemap</a></H3>
<p>

View file

@ -389,6 +389,7 @@ CPP_TEST_CASES += \
string_constants \
struct_initialization_cpp \
struct_value \
swig_exception \
symbol_clash \
template_arg_replace \
template_arg_scope \
@ -519,6 +520,7 @@ CPP_TEST_CASES += \
valuewrapper_opaque \
varargs \
varargs_overload \
variable_replacement \
virtual_destructor \
virtual_poly \
virtual_vs_nonvirtual_base \

View file

@ -7,6 +7,7 @@ public class li_std_except_runme {
public static void Main() {
Test test = new Test();
try { test.throw_bad_cast(); throw new Exception("throw_bad_cast failed"); } catch (InvalidCastException) {}
try { test.throw_bad_exception(); throw new Exception("throw_bad_exception failed"); } catch (ApplicationException) {}
try { test.throw_domain_error(); throw new Exception("throw_domain_error failed"); } catch (ApplicationException) {}
try { test.throw_exception(); throw new Exception("throw_exception failed"); } catch (ApplicationException) {}

View file

@ -28,6 +28,21 @@ class DirectorMethodException: public Swig::DirectorException {};
%include "std_string.i"
#ifdef SWIGPHP
%feature("director:except") {
if ($error == FAILURE) {
throw Swig::DirectorMethodException();
}
}
%exception {
try { $action }
catch (Swig::DirectorException &) { SWIG_fail; }
}
#endif
#ifdef SWIGPYTHON
%feature("director:except") {

View file

@ -0,0 +1,30 @@
var swig_exception = require("swig_exception");
var c = new swig_exception.Circle(10);
var s = new swig_exception.Square(10);
if (swig_exception.Shape.nshapes != 2) {
throw "Shape.nshapes should be 2, actually " + swig_exception.Shape.nshapes;
}
// ----- Throw exception -----
try {
c.throwException();
throw "Exception wasn't thrown";
} catch (e) {
if (e.message != "OK") {
throw "Exception message should be \"OK\", actually \"" + e.message + "\"";
}
}
// ----- Delete everything -----
c = null;
s = null;
e = null;
/* FIXME: Garbage collection needs to happen before this check will work.
if (swig_exception.Shape.nshapes != 0) {
throw "Shape.nshapes should be 0, actually " + swig_exception.Shape.nshapes;
}
*/

View file

@ -24,6 +24,7 @@
int foo3() throw(E1) { return 0; }
int foo4() throw(E2) { return 0; }
// all the STL exceptions...
void throw_bad_cast() throw(std::bad_cast) { throw std::bad_cast(); }
void throw_bad_exception() throw(std::bad_exception) { throw std::bad_exception(); }
void throw_domain_error() throw(std::domain_error) { throw std::domain_error("oops"); }
void throw_exception() throw(std::exception) { throw std::exception(); }

View file

@ -0,0 +1,20 @@
<?php
require "tests.php";
require "cpp_basic.php";
// New functions
check::functions(array(foo_func1,foo_func2,foo___str__,foosubsub___str__,bar_test,bar_testfoo,get_func1_ptr,get_func2_ptr,test_func_ptr,fl_window_show));
// New classes
check::classes(array(cpp_basic,Foo,FooSub,FooSubSub,Bar,Fl_Window));
// New vars
check::globals(array(foo_num,foo_func_ptr,bar_fptr,bar_fref,bar_fval,bar_cint,bar_global_fptr,bar_global_fref,bar_global_fval));
$f = new Foo(3);
$f->func_ptr = get_func1_ptr();
check::equal(test_func_ptr($f, 7), 2*7*3, "get_func1_ptr() didn't work");
$f->func_ptr = get_func2_ptr();
check::equal(test_func_ptr($f, 7), -7*3, "get_func2_ptr() didn't work");
check::done();
?>

View file

@ -0,0 +1,33 @@
<?php
require("swig_exception.php");
require("tests.php");
$c = new Circle(10);
$s = new Square(10);
if (Shape::nshapes() != 2) {
check::fail("Shape::nshapes() should be 2, actually ".Shape::nshapes());
}
# ----- Throw exception -----
try {
$c->throwException();
check::fail("Exception wasn't thrown");
} catch (Exception $e) {
if ($e->getMessage() != "OK") {
check::fail("Exception getMessage() should be \"OK\", actually \"".$e->getMessage()."\"");
}
}
# ----- Delete everything -----
$c = NULL;
$s = NULL;
$e = NULL;
if (Shape::nshapes() != 0) {
check::fail("Shape::nshapes() should be 0, actually ".Shape::nshapes());
}
?>

View file

@ -35,8 +35,9 @@ class check {
foreach($_original_functions[internal] as $func) unset($df[$func]);
// Now chop out any get/set accessors
foreach(array_keys($df) as $func)
if ((GETSET && ereg('_[gs]et$',$func)) || ereg('^new_', $func)
|| ereg('_(alter|get)_newobject$', $func))
if ((GETSET && preg_match('/_[gs]et$/', $func)) ||
preg_match('/^new_/', $func) ||
preg_match('/_(alter|get)_newobject$/', $func))
$extrags[]=$func;
else $extra[]=$func;
// $extra=array_keys($df);
@ -52,7 +53,8 @@ class check {
if (GETSET) {
$_extra=array();
foreach(check::get_extra_functions(false,1) as $global) {
if (ereg('^(.*)_[sg]et$',$global,$match)) $_extra[$match[1]]=1;
if (preg_match('/^(.*)_[sg]et$/', $global, $match))
$_extra[$match[1]] = 1;
}
$extra=array_keys($_extra);
} else {
@ -61,7 +63,8 @@ class check {
$df=array_flip(array_keys($GLOBALS));
foreach($_original_globals as $func) unset($df[$func]);
// MASK xxxx_LOADED__ variables
foreach(array_keys($df) as $func) if (ereg('_LOADED__$',$func)) unset($df[$func]);
foreach(array_keys($df) as $func)
if (preg_match('/_LOADED__$/', $func)) unset($df[$func]);
$extra=array_keys($df);
}
}
@ -185,7 +188,8 @@ class check {
}
function functionref($a,$type,$message) {
if (! eregi("^_[a-f0-9]+$type$",$a)) return check::fail($message);
if (! preg_match("/^_[a-f0-9]+$type$/i", $a))
return check::fail($message);
return TRUE;
}
@ -196,7 +200,8 @@ class check {
function resource($a,$b,$message) {
$resource=trim(check::var_dump($a));
if (! eregi("^resource\([0-9]+\) of type \($b\)",$resource)) return check::fail($message);
if (! preg_match("/^resource\([0-9]+\) of type \($b\)/i", $resource))
return check::fail($message);
return TRUE;
}

View file

@ -58,6 +58,7 @@ CPP_TEST_CASES += \
primitive_types \
python_abstractbase \
python_append \
python_builtin \
python_destructor_exception \
python_director \
python_docstring \

View file

@ -36,3 +36,21 @@ try:
raise RuntimeError("missed exception")
except TypeError:
pass
b111 = makeB(111)
bNones = BPtrVector([None, b111, None])
bCount = 0
noneCount = 0
for b in bNones:
if b == None:
noneCount = noneCount + 1
else:
if b.val != 111:
raise RuntimeError("b.val is wrong")
bCount = bCount + 1
if bCount != 1:
raise RuntimeError("bCount wrong")
if noneCount != 2:
raise RuntimeError("noneCount wrong")

View file

@ -2,3 +2,9 @@ from li_std_vector import *
if typedef_test(101) != 101:
raise RuntimeError
try:
sv = StructVector([None, None])
raise RuntimeError("Using None should result in a TypeError")
except TypeError:
pass

View file

@ -0,0 +1,94 @@
from python_builtin import *
if is_python_builtin():
# Test 0 for default tp_hash
vs = ValueStruct(1234)
h = hash(vs)
d = dict()
d[h] = "hi"
if h not in d:
raise RuntimeError("h should be in d")
h2 = hash(ValueStruct.inout(vs))
if h != h2:
raise RuntimeError("default tp_hash not working")
# Test 1 for tp_hash
if hash(SimpleValue(222)) != 222:
raise RuntimeError("tp_hash not working")
# Test 2 for tp_hash
try:
# Was incorrectly raising: SystemError: error return without exception set
h = hash(BadHashFunctionReturnType())
raise RuntimeError("Missing TypeError")
except TypeError:
pass
# Test 3 for tp_hash
passed = False
try:
h = hash(ExceptionHashFunction())
except RuntimeError, e:
passed = str(e).find("oops") != -1
pass
if not passed:
raise RuntimeError("did not catch exception in hash()")
# Test 4 for tp_dealloc (which is handled differently to other slots in the SWIG source)
d = Dealloc1()
if cvar.Dealloc1CalledCount != 0:
raise RuntimeError("count should be 0")
del d
if cvar.Dealloc1CalledCount != 1:
raise RuntimeError("count should be 1")
d = Dealloc2()
if cvar.Dealloc2CalledCount != 0:
raise RuntimeError("count should be 0")
del d
if cvar.Dealloc2CalledCount != 1:
raise RuntimeError("count should be 1")
d = Dealloc3()
if cvar.Dealloc3CalledCount != 0:
raise RuntimeError("count should be 0")
del d
if cvar.Dealloc3CalledCount != 1:
raise RuntimeError("count should be 1")
# Test 5 for python:compare feature
m10 = MyClass(10)
m20 = MyClass(20)
m15 = MyClass(15)
if not m10 < m15:
raise RuntimeError("m10 < m15")
if not m10 < m20:
raise RuntimeError("m10 < m20")
if not m15 < m20:
raise RuntimeError("m15 < m20")
if m10 > m15:
raise RuntimeError("m10 > m15")
if m10 > m20:
raise RuntimeError("m10 > m20")
if m15 > m20:
raise RuntimeError("m15 > m20")
if MyClass.less_than_counts != 6:
raise RuntimeError("python:compare feature not working")
sa = SimpleArray(5)
elements = [x for x in sa]
if elements != [0, 10, 20, 30, 40]:
raise RuntimeError("Iteration not working")
if len(sa) != 5:
raise RuntimeError("len not working")
for i in range(5):
if sa[i] != i*10:
raise RuntimeError("indexing not working")
subslice = sa[1:3]
elements = [x for x in subslice]
if elements != [10, 20]:
raise RuntimeError("slice not working")

View file

@ -0,0 +1,201 @@
// Test customizing slots when using the -builtin option
%module python_builtin
%inline %{
#ifdef SWIGPYTHON_BUILTIN
bool is_python_builtin() { return true; }
#else
bool is_python_builtin() { return false; }
#endif
%}
// Test 0 for default tp_hash
%inline %{
struct ValueStruct {
int value;
ValueStruct(int value) : value(value) {}
static ValueStruct *inout(ValueStruct *v) {
return v;
}
};
%}
// Test 1 for tp_hash
#if defined(SWIGPYTHON_BUILTIN)
%feature("python:tp_hash") SimpleValue "SimpleValueHashFunction"
#endif
%inline %{
struct SimpleValue {
int value;
SimpleValue(int value) : value(value) {}
};
%}
%{
#if PY_VERSION_HEX >= 0x03020000
Py_hash_t SimpleValueHashFunction(PyObject *v)
#else
long SimpleValueHashFunction(PyObject *v)
#endif
{
SwigPyObject *sobj = (SwigPyObject *) v;
SimpleValue *p = (SimpleValue *)sobj->ptr;
return p->value;
}
hashfunc test_hashfunc_cast() {
return SimpleValueHashFunction;
}
%}
// Test 2 for tp_hash
#if defined(SWIGPYTHON_BUILTIN)
%feature("python:slot", "tp_hash", functype="hashfunc") BadHashFunctionReturnType::bad_hash_function;
#endif
%inline %{
struct BadHashFunctionReturnType {
static const char * bad_hash_function() {
return "bad hash function";
}
};
%}
// Test 3 for tp_hash
#if defined(SWIGPYTHON_BUILTIN)
%feature("python:slot", "tp_hash", functype="hashfunc") ExceptionHashFunction::exception_hash_function;
#endif
%catches(const char *) exception_hash_function;
%inline %{
#if PY_VERSION_HEX < 0x03020000
#define Py_hash_t long
#endif
struct ExceptionHashFunction {
static Py_hash_t exception_hash_function() {
throw "oops";
}
};
%}
// Test 4 for tp_dealloc (which is handled differently to other slots in the SWIG source)
#if defined(SWIGPYTHON_BUILTIN)
%feature("python:tp_dealloc") Dealloc1 "Dealloc1Destroyer"
%feature("python:tp_dealloc") Dealloc2 "Dealloc2Destroyer"
%feature("python:slot", "tp_dealloc", functype="destructor") Dealloc3::Destroyer;
#endif
%inline %{
static int Dealloc1CalledCount = 0;
static int Dealloc2CalledCount = 0;
static int Dealloc3CalledCount = 0;
struct Dealloc1 {
};
struct Dealloc2 {
~Dealloc2() {}
};
struct Dealloc3 {
void Destroyer() {
Dealloc3CalledCount++;
delete this;
}
};
%}
%{
void Dealloc1Destroyer(PyObject *v) {
SwigPyObject *sobj = (SwigPyObject *) v;
Dealloc1 *p = (Dealloc1 *)sobj->ptr;
delete p;
Dealloc1CalledCount++;
}
void Dealloc2Destroyer(PyObject *v) {
SwigPyObject *sobj = (SwigPyObject *) v;
Dealloc2 *p = (Dealloc2 *)sobj->ptr;
delete p;
Dealloc2CalledCount++;
}
%}
// Test 5 for python:compare feature
%feature("python:compare", "Py_LT") MyClass::lessThan;
%inline %{
class MyClass {
public:
MyClass(int val = 0) : val(val) {}
bool lessThan(const MyClass& other) const {
less_than_counts++;
return val < other.val;
}
int val;
static int less_than_counts;
};
int MyClass::less_than_counts = 0;
%}
// Test 6 add in container __getitem__ to support basic sequence protocol
// Tests overloaded functions being used for more than one slot (mp_subscript and sq_item)
%include <exception.i>
%include <std_except.i>
%apply int {Py_ssize_t}
%typemap(in) PySliceObject * {
if (!PySlice_Check($input))
SWIG_exception(SWIG_TypeError, "in method '$symname', argument $argnum of type '$type'");
$1 = (PySliceObject *)$input;
}
%typemap(typecheck,precedence=300) PySliceObject* {
$1 = PySlice_Check($input);
}
%feature("python:slot", "mp_subscript", functype="binaryfunc") SimpleArray::__getitem__(PySliceObject *slice);
%feature("python:slot", "sq_item", functype="ssizeargfunc") SimpleArray::__getitem__(Py_ssize_t n);
%feature("python:slot", "sq_length", functype="lenfunc") SimpleArray::__len__;
%inline %{
class SimpleArray {
size_t size;
int numbers[5];
public:
SimpleArray(size_t size) : size(size) {
for (size_t x = 0; x<size; ++x)
numbers[x] = x*10;
}
Py_ssize_t __len__() {
return size;
}
int __getitem__(Py_ssize_t n) throw (std::out_of_range) {
if (n >= (int)size)
throw std::out_of_range("Index too large");
return numbers[n];
}
SimpleArray __getitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) {
if (!PySlice_Check(slice))
throw std::invalid_argument("Slice object expected");
Py_ssize_t i, j, step;
#if PY_VERSION_HEX >= 0x03020000
PySlice_GetIndices((PyObject *)slice, size, &i, &j, &step);
#else
PySlice_GetIndices((PySliceObject *)slice, size, &i, &j, &step);
#endif
if (step != 1)
throw std::invalid_argument("Only a step size of 1 is implemented");
{
Py_ssize_t ii = i<0 ? 0 : i>=size ? size-1 : i;
Py_ssize_t jj = j<0 ? 0 : j>=size ? size-1 : j;
if (ii > jj)
throw std::invalid_argument("getitem i should not be larger than j");
SimpleArray n(jj-ii);
for (size_t x = 0; x<size; ++x)
n.numbers[x] = numbers[x+ii];
return n;
}
}
};
%}

View file

@ -0,0 +1,91 @@
/* File : swig_exception.i
* Test SWIG_exception().
*/
%module swig_exception
%include exception.i
%exception {
try {
$action
} catch (std::exception& e) {
SWIG_exception(SWIG_SystemError, e.what());
}
}
%inline %{
class Value {
int a_;
int b_;
public:
Value(int a, int b) : a_(a), b_(b) {}
};
class Shape {
public:
Shape() {
nshapes++;
}
virtual ~Shape() {
nshapes--;
}
double x, y;
void move(double dx, double dy);
virtual double area() = 0;
virtual double perimeter() = 0;
virtual Value throwException();
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { }
virtual double area();
virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { }
virtual double area();
virtual double perimeter();
};
%}
%{
#define PI 3.14159265358979323846
#include <stdexcept>
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
x += dx;
y += dy;
}
Value Shape::throwException() {
throw std::logic_error("OK");
}
int Shape::nshapes = 0;
double Circle::area() {
return PI*radius*radius;
}
double Circle::perimeter() {
return 2*PI*radius;
}
double Square::area() {
return width*width;
}
double Square::perimeter() {
return 4*width;
}
%}

View file

@ -25,23 +25,33 @@ void foo1(Foo<int> f, const Foo<int>& ff) {}
void foo2(Foo<short> f, const Foo<short>& ff) {}
%}
#ifdef SWIGUTL
%typemap(ret) int Bar1::foo() { /* hello1 */ };
%typemap(ret) int Bar2::foo() { /* hello2 */ };
%typemap(ret) int foo() {/* hello3 */ };
#endif
// Check "ret" typemap is implemented
%{
template<typename T> struct NeededForTest {};
%}
%fragment("NeededForTest", "header") %{
template<> struct NeededForTest<short> { NeededForTest(short) {} };
%}
%typemap(ret) short "_ret_typemap_for_short_no_compile"
%typemap(ret, fragment="NeededForTest") short Bar1::foofunction() { /* ret typemap for short */ NeededForTest<short> needed($1); };
%typemap(ret, fragment="NeededForTest") short globalfoofunction() { /* ret typemap for short */ NeededForTest<short> needed($1); };
%inline %{
struct Bar1 {
int foo() { return 1;}
};
struct Bar2 {
int foo() { return 1;}
short foofunction() { return 1;}
};
short globalfoofunction() { return 1;}
%}
%{
void CheckRetTypemapUsed() {
// If the "ret" typemap is not used, the NeededForTest template specialization will not have been
// generated and so the following code will result in a compile failure
NeededForTest<short> needed(111);
(void)needed;
}
%}
%newobject FFoo::Bar(bool) const ;
%typemap(newfree) char* Bar(bool) {
@ -62,7 +72,7 @@ void foo2(Foo<short> f, const Foo<short>& ff) {}
#endif
// Test obscure bug where named typemaps where not being applied when symbol name contained a number
%typemap(out) double "_typemap_for_double_no_compile_"
%typemap(out) double "_out_typemap_for_double_no_compile_"
%typemap(out) double ABCD::meth {$1 = 0.0; TYPEMAP_OUT_INIT}
%typemap(out) double ABCD::m1 {$1 = 0.0; TYPEMAP_OUT_INIT}
%typemap(out) double ABCD::_x2 {$1 = 0.0; TYPEMAP_OUT_INIT}

View file

@ -0,0 +1,16 @@
%module variable_replacement
%inline %{
class A {
public:
int a(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12)
{
return 0;
}
};
class B : public A {
};
%}

View file

@ -2,9 +2,9 @@
#define CSHARP_CSHARPKW_SWG_
/* Warnings for C# keywords */
#define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '_" `x` "'",rename="_%s") `x`
#define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '" `x` "_'",rename="%s_") `x`
#define CSHARPCLASSKW(x) %keywordwarn("'" `x` "' is a special method name used in the C# wrapper classes, class renamed to '_" `x` "'",%$isclass,rename="_%s") `x`
#define CSHARPCLASSKW(x) %keywordwarn("'" `x` "' is a special method name used in the C# wrapper classes, class renamed to '" `x` "_'",%$isclass,rename="%s_") `x`
/*
from

View file

@ -7,6 +7,7 @@
* ----------------------------------------------------------------------------- */
%{
#include <typeinfo>
#include <stdexcept>
%}
@ -16,6 +17,7 @@ namespace std
struct exception {};
}
%typemap(throws, canthrow=1) std::bad_cast "SWIG_CSharpSetPendingException(SWIG_CSharpInvalidCastException, $1.what());\n return $null;"
%typemap(throws, canthrow=1) std::bad_exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
%typemap(throws, canthrow=1) std::domain_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
%typemap(throws, canthrow=1) std::exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"

View file

@ -7,6 +7,7 @@
* ----------------------------------------------------------------------------- */
%{
#include <typeinfo>
#include <stdexcept>
%}
@ -16,6 +17,7 @@ namespace std
struct exception {};
}
%typemap(throws, canthrow=1) std::bad_cast "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
%typemap(throws, canthrow=1) std::bad_exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
%typemap(throws, canthrow=1) std::domain_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
%typemap(throws, canthrow=1) std::exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"

View file

@ -15,7 +15,7 @@
#ifdef SWIGPHP
%{
#include "zend_exceptions.h"
#define SWIG_exception(code, msg) zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC)
#define SWIG_exception(code, msg) do { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); goto thrown; } while (0)
%}
#endif
@ -258,6 +258,7 @@ SWIGINTERN void SWIG_DThrowException(int code, const char *msg) {
}
*/
%{
#include <typeinfo>
#include <stdexcept>
%}
%define SWIG_CATCH_STDEXCEPT
@ -274,6 +275,8 @@ SWIGINTERN void SWIG_DThrowException(int code, const char *msg) {
SWIG_exception(SWIG_IndexError, e.what() );
} catch (std::runtime_error& e) {
SWIG_exception(SWIG_RuntimeError, e.what() );
} catch (std::bad_cast& e) {
SWIG_exception(SWIG_TypeError, e.what() );
} catch (std::exception& e) {
SWIG_exception(SWIG_SystemError, e.what() );
}

View file

@ -7,6 +7,7 @@
* ----------------------------------------------------------------------------- */
%{
#include <typeinfo>
#include <stdexcept>
%}
@ -16,6 +17,7 @@ namespace std
struct exception {};
}
%typemap(throws) std::bad_cast %{_swig_gopanic($1.what());%}
%typemap(throws) std::bad_exception %{_swig_gopanic($1.what());%}
%typemap(throws) std::domain_error %{_swig_gopanic($1.what());%}
%typemap(throws) std::exception %{_swig_gopanic($1.what());%}

View file

@ -1,6 +1,7 @@
// TODO: STL exception handling
// Note that the generic std_except.i file did not work
%{
#include <typeinfo>
#include <stdexcept>
%}

View file

@ -7,6 +7,7 @@
* ----------------------------------------------------------------------------- */
%{
#include <typeinfo>
#include <stdexcept>
%}
@ -16,6 +17,7 @@ namespace std
struct exception {};
}
%typemap(throws) std::bad_cast "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
%typemap(throws) std::bad_exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
%typemap(throws) std::domain_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
%typemap(throws) std::exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"

View file

@ -32,6 +32,7 @@ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject,
size_t argc, const JSValueRef argv[], JSValueRef* exception)
{
SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
fail:
return 0;
}
%}

View file

@ -53,7 +53,7 @@ SWIGINTERN bool JS_veto_set_variable(JSContextRef context, JSObjectRef thisObjec
} else {
SWIG_exception(SWIG_ERROR, msg);
}
fail:
return false;
}

View file

@ -4,7 +4,7 @@
* ---------------------------------------------------------------------------*/
#define SWIG_Error(code, msg) SWIG_JSC_exception(context, exception, code, msg)
#define SWIG_exception(code, msg) SWIG_JSC_exception(context, exception, code, msg)
#define SWIG_exception(code, msg) do { SWIG_JSC_exception(context, exception, code, msg); SWIG_fail; } while (0)
#define SWIG_fail goto fail
SWIGRUNTIME void SWIG_Javascript_Raise(JSContextRef context, JSValueRef *exception, const char* type) {

View file

@ -36,6 +36,7 @@ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
SWIGV8_HANDLESCOPE();
SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
fail:
SWIGV8_RETURN(SWIGV8_UNDEFINED());
}
%}

View file

@ -83,6 +83,7 @@ SWIGRUNTIME void JS_veto_set_variable(v8::Local<v8::String> property, v8::Local<
} else {
SWIG_exception(SWIG_ERROR, msg);
}
fail: ;
}
%} // v8_helper_functions

View file

@ -97,7 +97,7 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
* ---------------------------------------------------------------------------*/
#define SWIG_Error(code, msg) SWIGV8_ErrorHandler.error(code, msg)
#define SWIG_exception(code, msg) SWIGV8_ErrorHandler.error(code, msg)
#define SWIG_exception(code, msg) do { SWIGV8_ErrorHandler.error(code, msg); SWIG_fail; } while (0)
#define SWIG_fail goto fail
#define SWIGV8_OVERLOAD false

View file

@ -8,6 +8,7 @@
* ----------------------------------------------------------------------------- */
%{
#include <typeinfo>
#include <stdexcept>
%}
%include <exception.i>
@ -27,6 +28,7 @@ namespace std
// normally objects which are thrown are returned to the interpreter as errors
// (which potentially may have problems if they are not copied)
// therefore all classes based upon std::exception are converted to their strings & returned as errors
%typemap(throws) std::bad_cast "SWIG_exception(SWIG_TypeError, $1.what());"
%typemap(throws) std::bad_exception "SWIG_exception(SWIG_RuntimeError, $1.what());"
%typemap(throws) std::domain_error "SWIG_exception(SWIG_ValueError, $1.what());"
%typemap(throws) std::exception "SWIG_exception(SWIG_SystemError, $1.what());"

View file

@ -393,11 +393,7 @@
{
void * p = emalloc(sizeof($1));
memcpy(p, &$1, sizeof($1));
zval * resource;
MAKE_STD_ZVAL(resource);
ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr);
SWIG_SetPointerZval(return_value, (void *)&$1, $1_descriptor, $owner);
ZEND_REGISTER_RESOURCE(return_value, p, swig_member_ptr);
}
%typemap(in, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)

View file

@ -93,9 +93,6 @@ typedef struct {
int newobject;
} swig_object_wrapper;
/* empty zend destructor for types without one */
static ZEND_RSRC_DTOR_FUNC(SWIG_landfill) { (void)rsrc; }
#define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d TSRMLS_CC)
#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))

View file

@ -271,7 +271,7 @@ INT_TYPEMAP(unsigned long long);
%typemap(in) char INPUT[ANY] ( char temp[$1_dim0] )
%{
convert_to_string_ex($input);
strncpy(temp,Z_LVAL_PP($input),$1_dim0);
strncpy(temp,Z_STRVAL_PP($input),$1_dim0);
$1 = temp;
%}
%typemap(in,numinputs=0) char OUTPUT[ANY] ( char temp[$1_dim0] )

View file

@ -1,220 +1,29 @@
#define SWIGPY_UNARYFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_closure(PyObject *a) { \
return wrapper(a, NULL); \
}
#define SWIGPY_DESTRUCTOR_CLOSURE(wrapper) \
SWIGINTERN void \
wrapper##_closure(PyObject *a) { \
SwigPyObject *sobj; \
sobj = (SwigPyObject *)a; \
Py_XDECREF(sobj->dict); \
if (sobj->own) { \
PyObject *o; \
PyObject *val = 0, *type = 0, *tb = 0; \
PyErr_Fetch(&val, &type, &tb); \
o = wrapper(a, NULL); \
if (!o) { \
PyObject *deallocname = PyString_FromString(#wrapper); \
PyErr_WriteUnraisable(deallocname); \
Py_DECREF(deallocname); \
} \
PyErr_Restore(val, type, tb); \
Py_XDECREF(o); \
} \
if (PyType_IS_GC(a->ob_type)) { \
PyObject_GC_Del(a); \
} else { \
PyObject_Del(a); \
} \
}
#define SWIGPY_INQUIRY_CLOSURE(wrapper) \
SWIGINTERN int \
wrapper##_closure(PyObject *a) { \
PyObject *pyresult; \
int result; \
pyresult = wrapper(a, NULL); \
result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0; \
Py_XDECREF(pyresult); \
return result; \
}
#define SWIGPY_BINARYFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_closure(PyObject *a, PyObject *b) { \
PyObject *tuple, *result; \
tuple = PyTuple_New(1); \
assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, b); \
Py_XINCREF(b); \
result = wrapper(a, tuple); \
Py_DECREF(tuple); \
return result; \
}
typedef ternaryfunc ternarycallfunc;
#define SWIGPY_TERNARYFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \
PyObject *tuple, *result; \
tuple = PyTuple_New(2); \
assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, b); \
PyTuple_SET_ITEM(tuple, 1, c); \
Py_XINCREF(b); \
Py_XINCREF(c); \
result = wrapper(a, tuple); \
Py_DECREF(tuple); \
return result; \
}
#define SWIGPY_TERNARYCALLFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_closure(PyObject *callable_object, PyObject *args, PyObject *) { \
return wrapper(callable_object, args); \
}
#define SWIGPY_LENFUNC_CLOSURE(wrapper) \
SWIGINTERN Py_ssize_t \
wrapper##_closure(PyObject *a) { \
PyObject *resultobj; \
Py_ssize_t result; \
resultobj = wrapper(a, NULL); \
result = PyNumber_AsSsize_t(resultobj, NULL); \
Py_DECREF(resultobj); \
return result; \
}
#define SWIGPY_SSIZESSIZEARGFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c) { \
PyObject *tuple, *result; \
tuple = PyTuple_New(2); \
assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \
PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); \
result = wrapper(a, tuple); \
Py_DECREF(tuple); \
return result; \
}
#define SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper) \
SWIGINTERN int \
wrapper##_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { \
PyObject *tuple, *resultobj; \
int result; \
tuple = PyTuple_New(d ? 3 : 2); \
assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \
PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); \
if (d) { \
PyTuple_SET_ITEM(tuple, 2, d); \
Py_INCREF(d); \
} \
resultobj = wrapper(a, tuple); \
result = resultobj ? 0 : -1; \
Py_DECREF(tuple); \
Py_XDECREF(resultobj); \
return result; \
}
#define SWIGPY_SSIZEARGFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_closure(PyObject *a, Py_ssize_t b) { \
PyObject *tuple, *result; \
tuple = PyTuple_New(1); \
assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \
result = wrapper(a, tuple); \
Py_DECREF(tuple); \
return result; \
}
#define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_closure(PyObject *a, Py_ssize_t b) { \
PyObject *arg, *result; \
arg = _PyLong_FromSsize_t(b); \
result = wrapper(a, arg); \
Py_DECREF(arg); \
return result; \
}
#define SWIGPY_SSIZEOBJARGPROC_CLOSURE(wrapper) \
SWIGINTERN int \
wrapper##_closure(PyObject *a, Py_ssize_t b, PyObject *c) { \
PyObject *tuple, *resultobj; \
int result; \
tuple = PyTuple_New(2); \
assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); \
PyTuple_SET_ITEM(tuple, 1, c); \
Py_XINCREF(c); \
resultobj = wrapper(a, tuple); \
result = resultobj ? 0 : -1; \
Py_XDECREF(resultobj); \
Py_DECREF(tuple); \
return result; \
}
#define SWIGPY_OBJOBJARGPROC_CLOSURE(wrapper) \
SWIGINTERN int \
wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \
PyObject *tuple, *resultobj; \
int result; \
tuple = PyTuple_New(c ? 2 : 1); \
assert(tuple); \
PyTuple_SET_ITEM(tuple, 0, b); \
Py_XINCREF(b); \
if (c) { \
PyTuple_SET_ITEM(tuple, 1, c); \
Py_XINCREF(c); \
} \
resultobj = wrapper(a, tuple); \
result = resultobj ? 0 : -1; \
Py_XDECREF(resultobj); \
Py_DECREF(tuple); \
return result; \
}
#define SWIGPY_REPRFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_closure(PyObject *a) { \
return wrapper(a, NULL); \
}
#define SWIGPY_HASHFUNC_CLOSURE(wrapper) \
SWIGINTERN long \
wrapper##_closure(PyObject *a) { \
PyObject *pyresult; \
long result; \
pyresult = wrapper(a, NULL); \
if (!pyresult || !PyLong_Check(pyresult)) \
return -1; \
result = PyLong_AsLong(pyresult); \
Py_DECREF(pyresult); \
return result; \
}
#define SWIGPY_ITERNEXT_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_closure(PyObject *a) { \
PyObject *result; \
result = wrapper(a, NULL); \
if (result && result == Py_None) { \
Py_DECREF(result); \
result = NULL; \
} \
return result; \
}
#ifdef __cplusplus
extern "C" {
#endif
SWIGINTERN Py_hash_t
SwigPyObject_hash(PyObject *obj) {
SwigPyObject *sobj = (SwigPyObject *)obj;
void *ptr = sobj->ptr;
return (Py_hash_t)ptr;
}
SWIGINTERN Py_hash_t
SWIG_PyNumber_AsPyHash(PyObject *obj) {
Py_hash_t result = -1;
#if PY_VERSION_HEX < 0x03020000
if (PyLong_Check(obj))
result = PyLong_AsLong(obj);
#else
if (PyNumber_Check(obj))
result = PyNumber_AsSsize_t(obj, NULL);
#endif
else
PyErr_Format(PyExc_TypeError, "Wrong type for hash function");
return result;
}
SWIGINTERN int
SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *SWIGUNUSEDPARM(kwds)) {
PyErr_Format(PyExc_TypeError, "Cannot create new instances of type '%.300s'", self->ob_type->tp_name);
@ -222,11 +31,10 @@ SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *
}
SWIGINTERN void
SwigPyBuiltin_BadDealloc(PyObject *pyobj) {
SwigPyObject *sobj;
sobj = (SwigPyObject *)pyobj;
SwigPyBuiltin_BadDealloc(PyObject *obj) {
SwigPyObject *sobj = (SwigPyObject *)obj;
if (sobj->own) {
PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", pyobj->ob_type->tp_name);
PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", obj->ob_type->tp_name);
}
}
@ -387,16 +195,15 @@ SwigPyStaticVar_Type(void) {
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
/* PyObject header changed in Python 3 */
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(&PyType_Type, 0)
#else
PyObject_HEAD_INIT(&PyType_Type)
0,
0, /* ob_size */
#endif
"swig_static_var_getset_descriptor",
sizeof(PyGetSetDescrObject),
0,
"swig_static_var_getset_descriptor", /* tp_name */
sizeof(PyGetSetDescrObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
@ -527,6 +334,295 @@ SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype)
#endif
}
/* Start of callback function macros for use in PyTypeObject */
typedef PyObject *(*SwigPyWrapperFunction)(PyObject *, PyObject *);
#define SWIGPY_UNARYFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_unaryfunc_closure(PyObject *a) { \
return SwigPyBuiltin_unaryfunc_closure(wrapper, a); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_unaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
return wrapper(a, NULL);
}
#define SWIGPY_DESTRUCTOR_CLOSURE(wrapper) \
SWIGINTERN void \
wrapper##_destructor_closure(PyObject *a) { \
SwigPyBuiltin_destructor_closure(wrapper, #wrapper, a); \
}
SWIGINTERN void
SwigPyBuiltin_destructor_closure(SwigPyWrapperFunction wrapper, const char *wrappername, PyObject *a) {
SwigPyObject *sobj;
sobj = (SwigPyObject *)a;
Py_XDECREF(sobj->dict);
if (sobj->own) {
PyObject *o;
PyObject *val = 0, *type = 0, *tb = 0;
PyErr_Fetch(&val, &type, &tb);
o = wrapper(a, NULL);
if (!o) {
PyObject *deallocname = PyString_FromString(wrappername);
PyErr_WriteUnraisable(deallocname);
Py_DECREF(deallocname);
}
PyErr_Restore(val, type, tb);
Py_XDECREF(o);
}
if (PyType_IS_GC(a->ob_type)) {
PyObject_GC_Del(a);
} else {
PyObject_Del(a);
}
}
#define SWIGPY_INQUIRY_CLOSURE(wrapper) \
SWIGINTERN int \
wrapper##_inquiry_closure(PyObject *a) { \
return SwigPyBuiltin_inquiry_closure(wrapper, a); \
}
SWIGINTERN int
SwigPyBuiltin_inquiry_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
PyObject *pyresult;
int result;
pyresult = wrapper(a, NULL);
result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0;
Py_XDECREF(pyresult);
return result;
}
#define SWIGPY_GETITERFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_getiterfunc_closure(PyObject *a) { \
return SwigPyBuiltin_getiterfunc_closure(wrapper, a); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_getiterfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
return wrapper(a, NULL);
}
#define SWIGPY_BINARYFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_binaryfunc_closure(PyObject *a, PyObject *b) { \
return SwigPyBuiltin_binaryfunc_closure(wrapper, a, b); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_binaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) {
PyObject *tuple, *result;
tuple = PyTuple_New(1);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, b);
Py_XINCREF(b);
result = wrapper(a, tuple);
Py_DECREF(tuple);
return result;
}
typedef ternaryfunc ternarycallfunc;
#define SWIGPY_TERNARYFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_ternaryfunc_closure(PyObject *a, PyObject *b, PyObject *c) { \
return SwigPyBuiltin_ternaryfunc_closure(wrapper, a, b, c); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_ternaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) {
PyObject *tuple, *result;
tuple = PyTuple_New(2);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, b);
PyTuple_SET_ITEM(tuple, 1, c);
Py_XINCREF(b);
Py_XINCREF(c);
result = wrapper(a, tuple);
Py_DECREF(tuple);
return result;
}
#define SWIGPY_TERNARYCALLFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_ternarycallfunc_closure(PyObject *a, PyObject *b, PyObject *c) { \
return SwigPyBuiltin_ternarycallfunc_closure(wrapper, a, b, c); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_ternarycallfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) {
(void) c;
return wrapper(a, b);
}
#define SWIGPY_LENFUNC_CLOSURE(wrapper) \
SWIGINTERN Py_ssize_t \
wrapper##_lenfunc_closure(PyObject *a) { \
return SwigPyBuiltin_lenfunc_closure(wrapper, a); \
}
SWIGINTERN Py_ssize_t
SwigPyBuiltin_lenfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
PyObject *resultobj;
Py_ssize_t result;
resultobj = wrapper(a, NULL);
result = PyNumber_AsSsize_t(resultobj, NULL);
Py_DECREF(resultobj);
return result;
}
#define SWIGPY_SSIZESSIZEARGFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_ssizessizeargfunc_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c) { \
return SwigPyBuiltin_ssizessizeargfunc_closure(wrapper, a, b, c); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_ssizessizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, Py_ssize_t c) {
PyObject *tuple, *result;
tuple = PyTuple_New(2);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));
PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c));
result = wrapper(a, tuple);
Py_DECREF(tuple);
return result;
}
#define SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper) \
SWIGINTERN int \
wrapper##_ssizessizeobjargproc_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { \
return SwigPyBuiltin_ssizessizeobjargproc_closure(wrapper, a, b, c, d); \
}
SWIGINTERN int
SwigPyBuiltin_ssizessizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) {
PyObject *tuple, *resultobj;
int result;
tuple = PyTuple_New(d ? 3 : 2);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));
PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c));
if (d) {
PyTuple_SET_ITEM(tuple, 2, d);
Py_INCREF(d);
}
resultobj = wrapper(a, tuple);
result = resultobj ? 0 : -1;
Py_DECREF(tuple);
Py_XDECREF(resultobj);
return result;
}
#define SWIGPY_SSIZEARGFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_ssizeargfunc_closure(PyObject *a, Py_ssize_t b) { \
return SwigPyBuiltin_funpack_ssizeargfunc_closure(wrapper, a, b); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_funpack_ssizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b) {
PyObject *tuple, *result;
tuple = PyTuple_New(1);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));
result = wrapper(a, tuple);
Py_DECREF(tuple);
return result;
}
#define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_ssizeargfunc_closure(PyObject *a, Py_ssize_t b) { \
return SwigPyBuiltin_ssizeargfunc_closure(wrapper, a, b); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_ssizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b) {
PyObject *arg, *result;
arg = _PyLong_FromSsize_t(b);
result = wrapper(a, arg);
Py_DECREF(arg);
return result;
}
#define SWIGPY_SSIZEOBJARGPROC_CLOSURE(wrapper) \
SWIGINTERN int \
wrapper##_ssizeobjargproc_closure(PyObject *a, Py_ssize_t b, PyObject *c) { \
return SwigPyBuiltin_ssizeobjargproc_closure(wrapper, a, b, c); \
}
SWIGINTERN int
SwigPyBuiltin_ssizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, PyObject *c) {
PyObject *tuple, *resultobj;
int result;
tuple = PyTuple_New(2);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));
PyTuple_SET_ITEM(tuple, 1, c);
Py_XINCREF(c);
resultobj = wrapper(a, tuple);
result = resultobj ? 0 : -1;
Py_XDECREF(resultobj);
Py_DECREF(tuple);
return result;
}
#define SWIGPY_OBJOBJARGPROC_CLOSURE(wrapper) \
SWIGINTERN int \
wrapper##_objobjargproc_closure(PyObject *a, PyObject *b, PyObject *c) { \
return SwigPyBuiltin_objobjargproc_closure(wrapper, a, b, c); \
}
SWIGINTERN int
SwigPyBuiltin_objobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) {
PyObject *tuple, *resultobj;
int result;
tuple = PyTuple_New(c ? 2 : 1);
assert(tuple);
PyTuple_SET_ITEM(tuple, 0, b);
Py_XINCREF(b);
if (c) {
PyTuple_SET_ITEM(tuple, 1, c);
Py_XINCREF(c);
}
resultobj = wrapper(a, tuple);
result = resultobj ? 0 : -1;
Py_XDECREF(resultobj);
Py_DECREF(tuple);
return result;
}
#define SWIGPY_REPRFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_reprfunc_closure(PyObject *a) { \
return SwigPyBuiltin_reprfunc_closure(wrapper, a); \
}
SWIGINTERN PyObject *
SwigPyBuiltin_reprfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
return wrapper(a, NULL);
}
#define SWIGPY_HASHFUNC_CLOSURE(wrapper) \
SWIGINTERN Py_hash_t \
wrapper##_hashfunc_closure(PyObject *a) { \
return SwigPyBuiltin_hashfunc_closure(wrapper, a); \
}
SWIGINTERN Py_hash_t
SwigPyBuiltin_hashfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
PyObject *pyresult;
Py_hash_t result;
pyresult = wrapper(a, NULL);
if (!pyresult)
return -1;
result = SWIG_PyNumber_AsPyHash(pyresult);
Py_DECREF(pyresult);
return result;
}
#define SWIGPY_ITERNEXTFUNC_CLOSURE(wrapper) \
SWIGINTERN PyObject * \
wrapper##_iternextfunc_closure(PyObject *a) { \
return SwigPyBuiltin_iternextfunc_closure(wrapper, a);\
}
SWIGINTERN PyObject *
SwigPyBuiltin_iternextfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) {
return wrapper(a, NULL);
}
/* End of callback function macros for use in PyTypeObject */
#ifdef __cplusplus
}
#endif

View file

@ -206,7 +206,7 @@ namespace swig {
if (step == 0) {
throw std::invalid_argument("slice step cannot be zero");
} else if (step > 0) {
// Required range: 0 <= i < size, 0 <= j < size
// Required range: 0 <= i < size, 0 <= j < size, i <= j
if (i < 0) {
ii = 0;
} else if (i < (Difference)size) {
@ -214,13 +214,15 @@ namespace swig {
} else if (insert && (i >= (Difference)size)) {
ii = (Difference)size;
}
if ( j < 0 ) {
if (j < 0) {
jj = 0;
} else {
jj = (j < (Difference)size) ? j : (Difference)size;
}
if (jj < ii)
jj = ii;
} else {
// Required range: -1 <= i < size-1, -1 <= j < size-1
// Required range: -1 <= i < size-1, -1 <= j < size-1, i >= j
if (i < -1) {
ii = -1;
} else if (i < (Difference) size) {
@ -233,6 +235,8 @@ namespace swig {
} else {
jj = (j < (Difference)size ) ? j : (Difference)(size-1);
}
if (ii < jj)
ii = jj;
}
}
@ -258,6 +262,13 @@ namespace swig {
seq->erase(position);
}
template <class Sequence>
struct traits_reserve {
static void reserve(Sequence & /*seq*/, typename Sequence::size_type /*n*/) {
// This should be specialized for types that support reserve
}
};
template <class Sequence, class Difference>
inline Sequence*
getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) {
@ -275,6 +286,7 @@ namespace swig {
return new Sequence(sb, se);
} else {
Sequence *sequence = new Sequence();
swig::traits_reserve<Sequence>::reserve(*sequence, (jj - ii + step - 1) / step);
typename Sequence::const_iterator it = sb;
while (it!=se) {
sequence->push_back(*it);
@ -285,17 +297,16 @@ namespace swig {
}
} else {
Sequence *sequence = new Sequence();
if (ii > jj) {
typename Sequence::const_reverse_iterator sb = self->rbegin();
typename Sequence::const_reverse_iterator se = self->rbegin();
std::advance(sb,size-ii-1);
std::advance(se,size-jj-1);
typename Sequence::const_reverse_iterator it = sb;
while (it!=se) {
sequence->push_back(*it);
for (Py_ssize_t c=0; c<-step && it!=se; ++c)
it++;
}
swig::traits_reserve<Sequence>::reserve(*sequence, (ii - jj - step - 1) / -step);
typename Sequence::const_reverse_iterator sb = self->rbegin();
typename Sequence::const_reverse_iterator se = self->rbegin();
std::advance(sb,size-ii-1);
std::advance(se,size-jj-1);
typename Sequence::const_reverse_iterator it = sb;
while (it!=se) {
sequence->push_back(*it);
for (Py_ssize_t c=0; c<-step && it!=se; ++c)
it++;
}
return sequence;
}
@ -309,12 +320,11 @@ namespace swig {
Difference jj = 0;
swig::slice_adjust(i, j, step, size, ii, jj, true);
if (step > 0) {
if (jj < ii)
jj = ii;
if (step == 1) {
size_t ssize = jj - ii;
if (ssize <= is.size()) {
// expanding/staying the same size
swig::traits_reserve<Sequence>::reserve(*self, self->size() - ssize + is.size());
typename Sequence::iterator sb = self->begin();
typename InputSeq::const_iterator isit = is.begin();
std::advance(sb,ii);
@ -348,8 +358,6 @@ namespace swig {
}
}
} else {
if (jj > ii)
jj = ii;
size_t replacecount = (ii - jj - step - 1) / -step;
if (is.size() != replacecount) {
char msg[1024];
@ -375,37 +383,33 @@ namespace swig {
Difference jj = 0;
swig::slice_adjust(i, j, step, size, ii, jj, true);
if (step > 0) {
if (jj > ii) {
typename Sequence::iterator sb = self->begin();
std::advance(sb,ii);
if (step == 1) {
typename Sequence::iterator se = self->begin();
std::advance(se,jj);
self->erase(sb,se);
} else {
typename Sequence::iterator it = sb;
size_t delcount = (jj - ii + step - 1) / step;
while (delcount) {
it = self->erase(it);
for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
it++;
delcount--;
}
}
}
} else {
if (ii > jj) {
typename Sequence::reverse_iterator sb = self->rbegin();
std::advance(sb,size-ii-1);
typename Sequence::reverse_iterator it = sb;
size_t delcount = (ii - jj - step - 1) / -step;
typename Sequence::iterator sb = self->begin();
std::advance(sb,ii);
if (step == 1) {
typename Sequence::iterator se = self->begin();
std::advance(se,jj);
self->erase(sb,se);
} else {
typename Sequence::iterator it = sb;
size_t delcount = (jj - ii + step - 1) / step;
while (delcount) {
it = typename Sequence::reverse_iterator(self->erase((++it).base()));
for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
it = self->erase(it);
for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
it++;
delcount--;
}
}
} else {
typename Sequence::reverse_iterator sb = self->rbegin();
std::advance(sb,size-ii-1);
typename Sequence::reverse_iterator it = sb;
size_t delcount = (ii - jj - step - 1) / -step;
while (delcount) {
it = typename Sequence::reverse_iterator(self->erase((++it).base()));
for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
it++;
delcount--;
}
}
}
}

View file

@ -211,4 +211,5 @@ typedef destructor freefunc;
#if PY_VERSION_HEX < 0x03020000
#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
#define Py_hash_t long
#endif

View file

@ -145,7 +145,6 @@ swig_varlink_type(void) {
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
/* PyObject header changed in Python 3 */
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(NULL, 0)
#else

View file

@ -18,31 +18,35 @@
where <slot> is the name of a field in a PyTypeObject, PyNumberMethods,
PyMappingMethods, PySequenceMethods, or PyBufferProcs. For example:
%{
static long myHashFunc (PyObject *pyobj) {
MyClass *cobj;
// Convert pyobj to cobj
return (cobj->field1 * (cobj->field2 << 7));
}
%}
%feature("python:tp_hash") MyClass "myHashFunc";
class MyClass {
public:
...
};
%{
// Note: Py_hash_t was introduced in Python 3.2
static Py_hash_t myHashFunc(PyObject *pyobj) {
MyClass *cobj;
// Convert pyobj to cobj
return (cobj->field1 * (cobj->field2 << 7));
}
%}
NOTE: It is the responsibility of the programmer (that's you) to ensure
that a statically defined slot function has the correct signature.
If, instead, you want to dispatch to an instance method, you can
use %feature("python:slot"). For example:
%feature("python:slot", "tp_hash", functype="hashfunc") MyClass::myHashFunc;
class MyClass {
public:
long myHashFunc () const;
Py_hash_t myHashFunc () const;
...
};
%feature("python:slot", "tp_hash", functype="hashfunc") MyClass::myHashFunc;
NOTE: Some python slots use a method signature which does not
match the signature of SWIG-wrapped methods. For those slots,
@ -58,20 +62,21 @@
operator overloads for comparison (operator==, operator<, etc.), they
will be called from the generated rich compare function. If you
want to explicitly choose a method to handle a certain comparison
operation, you may use %feature("python:slot") like this:
operation, you may use a different feature, %feature("python:compare")
like this:
%feature("python:compare", "Py_LT") MyClass::lessThan;
class MyClass {
public:
bool lessThan (const MyClass& x) const;
bool lessThan(const MyClass& other) const;
...
};
%feature("python:slot", "Py_LT") MyClass::lessThan;
... where "Py_LT" is one of the rich comparison opcodes defined in the
python header file object.h.
If there's no method defined to handle a particular comparsion operation,
If there's no method defined to handle a particular comparison operation,
the default behavior is to compare pointer values of the wrapped
C++ objects.

View file

@ -312,7 +312,7 @@ SWIG_AsVal_dec(double)(PyObject *obj, double *val)
return SWIG_OK;
%#if PY_VERSION_HEX < 0x03000000
} else if (PyInt_Check(obj)) {
if (val) *val = PyInt_AsLong(obj);
if (val) *val = (double) PyInt_AsLong(obj);
return SWIG_OK;
%#endif
} else if (PyLong_Check(obj)) {

View file

@ -758,7 +758,6 @@ SwigPyObject_TypeOnce(void) {
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
/* PyObject header changed in Python 3 */
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(NULL, 0)
#else
@ -769,7 +768,7 @@ SwigPyObject_TypeOnce(void) {
sizeof(SwigPyObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)SwigPyObject_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_print */
#if PY_VERSION_HEX < 0x02020000
(getattrfunc)SwigPyObject_getattr, /* tp_getattr */
#else
@ -777,7 +776,7 @@ SwigPyObject_TypeOnce(void) {
#endif
(setattrfunc)0, /* tp_setattr */
#if PY_VERSION_HEX >= 0x03000000
0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
#else
(cmpfunc)SwigPyObject_compare, /* tp_compare */
#endif
@ -787,7 +786,7 @@ SwigPyObject_TypeOnce(void) {
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
0, /* tp_str */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
@ -950,7 +949,6 @@ SwigPyPacked_TypeOnce(void) {
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
/* PyObject header changed in Python 3 */
#if PY_VERSION_HEX>=0x03000000
PyVarObject_HEAD_INIT(NULL, 0)
#else

View file

@ -15,6 +15,13 @@
}
}
template <class K, class T>
struct traits_reserve<std::unordered_map<K,T> > {
static void reserve(std::unordered_map<K,T> &seq, typename std::unordered_map<K,T>::size_type n) {
seq.reserve(n);
}
};
template <class K, class T>
struct traits_asptr<std::unordered_map<K,T> > {
typedef std::unordered_map<K,T> unordered_map_type;

View file

@ -16,6 +16,13 @@
}
}
template <class K, class T>
struct traits_reserve<std::unordered_multimap<K,T> > {
static void reserve(std::unordered_multimap<K,T> &seq, typename std::unordered_multimap<K,T>::size_type n) {
seq.reserve(n);
}
};
template <class K, class T>
struct traits_asptr<std::unordered_multimap<K,T> > {
typedef std::unordered_multimap<K,T> unordered_multimap_type;

View file

@ -18,6 +18,13 @@
}
}
template <class T>
struct traits_reserve<std::unordered_multiset<T> > {
static void reserve(std::unordered_multiset<T> &seq, typename std::unordered_multiset<T>::size_type n) {
seq.reserve(n);
}
};
template <class T>
struct traits_asptr<std::unordered_multiset<T> > {
static int asptr(PyObject *obj, std::unordered_multiset<T> **m) {

View file

@ -16,6 +16,13 @@
}
}
template <class T>
struct traits_reserve<std::unordered_set<T> > {
static void reserve(std::unordered_set<T> &seq, typename std::unordered_set<T>::size_type n) {
seq.reserve(n);
}
};
template <class T>
struct traits_asptr<std::unordered_set<T> > {
static int asptr(PyObject *obj, std::unordered_set<T> **s) {

View file

@ -5,6 +5,13 @@
%fragment("StdVectorTraits","header",fragment="StdSequenceTraits")
%{
namespace swig {
template <class T>
struct traits_reserve<std::vector<T> > {
static void reserve(std::vector<T> &seq, typename std::vector<T>::size_type n) {
seq.reserve(n);
}
};
template <class T>
struct traits_asptr<std::vector<T> > {
static int asptr(PyObject *obj, std::vector<T> **vec) {

View file

@ -1,15 +1,4 @@
#ifdef __cplusplus
#include <exception>
extern "C" {
#endif
/* for raw pointer */
#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_R_ConvertPtr(obj, pptr, type, flags)
#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_R_ConvertPtr(obj, pptr, type, flags)
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_R_NewPointerObj(ptr, type, flags)
/* Remove global namespace pollution */
#if !defined(SWIG_NO_R_NO_REMAP)
# define R_NO_REMAP
@ -20,6 +9,17 @@ extern "C" {
#include <Rdefines.h>
#include <Rversion.h>
#ifdef __cplusplus
#include <exception>
extern "C" {
#endif
/* for raw pointer */
#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_R_ConvertPtr(obj, pptr, type, flags)
#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_R_ConvertPtr(obj, pptr, type, flags)
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_R_NewPointerObj(ptr, type, flags)
#include <stdlib.h>
#include <assert.h>

View file

@ -125,7 +125,6 @@ SWIG_SciBoolean_AsIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCo
}
if (isBooleanType(pvApiCtx, piAddrVar)) {
int i;
sciErr = getMatrixOfBoolean(pvApiCtx, piAddrVar, iRows, iCols, piValue);
if (sciErr.iErr) {
printError(&sciErr, 0);

View file

@ -6,7 +6,7 @@
}
%fragment("SWIG_NewPointerObj", "header") {
#define SWIG_NewPointerObj(pointer, pointerDescriptor, flags) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, flags)
#define SWIG_NewPointerObj(pointer, pointerDescriptor, flags) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, flags, NULL)
}
/*
@ -17,7 +17,7 @@
}
%fragment("SWIG_NewFunctionPtrObj", "header") {
#define SWIG_NewFunctionPtrObj(pointer, pointerDescriptor) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, 0)
#define SWIG_NewFunctionPtrObj(pointer, pointerDescriptor) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, 0, NULL)
}
// No fragment used here, the functions "SwigScilabPtrToObject" and "SwigScilabPtrFromObject" are defined in sciruntime.swg

View file

@ -100,8 +100,83 @@ SWIG_Scilab_SetOutput(void *pvApiCtx, SwigSciObject output) {
return SWIG_OK;
}
/* Error functions */
#define SCILAB_API_ARGUMENT_ERROR 999
SWIGINTERN const char*
SWIG_Scilab_ErrorType(int code) {
switch(code) {
case SWIG_MemoryError:
return "MemoryError";
case SWIG_IOError:
return "IOError";
case SWIG_RuntimeError:
return "RuntimeError";
case SWIG_IndexError:
return "IndexError";
case SWIG_TypeError:
return "TypeError";
case SWIG_DivisionByZero:
return "ZeroDivisionError";
case SWIG_OverflowError:
return "OverflowError";
case SWIG_SyntaxError:
return "SyntaxError";
case SWIG_ValueError:
return "ValueError";
case SWIG_SystemError:
return "SystemError";
case SWIG_AttributeError:
return "AttributeError";
default:
return "RuntimeError";
}
}
#define SWIG_ErrorType(code) SWIG_Scilab_ErrorType(code)
#ifndef SWIG_SCILAB_ERROR
#define SWIG_SCILAB_ERROR 20000
#endif
SWIGINTERN void
SWIG_Scilab_Error(int code, const char *msg) {
Scierror(SWIG_SCILAB_ERROR - code, _("SWIG/Scilab: %s: %s\n"), SWIG_Scilab_ErrorType(code), msg);
}
#define SWIG_Error(code, msg) SWIG_Scilab_Error(code, msg)
#define SWIG_fail return SWIG_ERROR;
SWIGRUNTIME void
SWIG_Scilab_Raise_Ex(const char *obj, const char *type, swig_type_info *descriptor) {
if (type) {
if (obj)
Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured: %s\n", type, obj);
else
Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured.\n", type);
}
}
SWIGRUNTIME void
SWIG_Scilab_Raise(const int obj, const char *type, swig_type_info *descriptor) {
Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured.\n", type);
}
/* Module initialization */
static int swig_module_initialized = 0;
SWIGRUNTIME int
SWIG_Module_Initialized() {
return swig_module_initialized;
}
/* Pointer conversion functions */
SWIGRUNTIME swig_type_info *
SWIG_Scilab_TypeQuery(const char *name);
SWIGINTERN int
SwigScilabCheckPtr(void *pvApiCtx, int iVar, swig_type_info *descriptor, char *fname) {
SciErr sciErr;
@ -120,7 +195,7 @@ SwigScilabCheckPtr(void *pvApiCtx, int iVar, swig_type_info *descriptor, char *f
return SWIG_ERROR;
}
if (iType == sci_tlist) {
if (iType == sci_mlist) {
int iItemCount = 0;
void *pvTypeinfo = NULL;
@ -142,10 +217,10 @@ SwigScilabCheckPtr(void *pvApiCtx, int iVar, swig_type_info *descriptor, char *f
if (descriptor) {
swig_cast_info *cast = SWIG_TypeCheck(SWIG_TypeName((swig_type_info*)pvTypeinfo), descriptor);
return (cast != NULL);
}
}
else {
return SWIG_ERROR;
}
}
}
else {
return (iType == sci_pointer);
@ -171,7 +246,7 @@ SwigScilabPtrToObject(void *pvApiCtx, int iVar, void **pvObj, swig_type_info *de
return SWIG_ERROR;
}
if (iType == sci_tlist) {
if (iType == sci_mlist) {
int iItemCount = 0;
void *pvTypeinfo = NULL;
@ -232,34 +307,36 @@ SwigScilabPtrToObject(void *pvApiCtx, int iVar, void **pvObj, swig_type_info *de
}
SWIGRUNTIMEINLINE int
SwigScilabPtrFromObject(void *pvApiCtx, int iVarOut, void *pvObj, swig_type_info *descriptor, int flags) {
SwigScilabPtrFromObject(void *pvApiCtx, int iVarOut, void *pvObj, swig_type_info *descriptor, int flags, const char *pstTypeName) {
SciErr sciErr;
if (descriptor) {
int *piTListAddr = NULL;
const char *pstString;
int *piMListAddr = NULL;
sciErr = createTList(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, 3, &piTListAddr);
sciErr = createMList(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, 3, &piMListAddr);
if (sciErr.iErr) {
printError(&sciErr, 0);
return SWIG_ERROR;
}
pstString = SWIG_TypeName(descriptor);
sciErr = createMatrixOfStringInList(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, piTListAddr, 1, 1, 1, &pstString);
if (pstTypeName == NULL) {
pstTypeName = SWIG_TypeName(descriptor);
}
sciErr = createMatrixOfStringInList(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, piMListAddr, 1, 1, 1, &pstTypeName);
if (sciErr.iErr) {
printError(&sciErr, 0);
return SWIG_ERROR;
}
sciErr = createPointerInList(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, piTListAddr, 2, descriptor);
sciErr = createPointerInList(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, piMListAddr, 2, descriptor);
if (sciErr.iErr) {
printError(&sciErr, 0);
return SWIG_ERROR;
}
sciErr = createPointerInList(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, piTListAddr, 3, pvObj);
sciErr = createPointerInList(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, piMListAddr, 3, pvObj);
if (sciErr.iErr) {
printError(&sciErr, 0);
return SWIG_ERROR;
@ -342,69 +419,7 @@ SWIG_Scilab_NewMemberObj(void *pvApiCtx, int iVarOut, void *ptr, int sz, swig_ty
}
/* Error functions */
#define SCILAB_API_ARGUMENT_ERROR 999
SWIGINTERN const char*
SWIG_Scilab_ErrorType(int code) {
switch(code) {
case SWIG_MemoryError:
return "MemoryError";
case SWIG_IOError:
return "IOError";
case SWIG_RuntimeError:
return "RuntimeError";
case SWIG_IndexError:
return "IndexError";
case SWIG_TypeError:
return "TypeError";
case SWIG_DivisionByZero:
return "ZeroDivisionError";
case SWIG_OverflowError:
return "OverflowError";
case SWIG_SyntaxError:
return "SyntaxError";
case SWIG_ValueError:
return "ValueError";
case SWIG_SystemError:
return "SystemError";
case SWIG_AttributeError:
return "AttributeError";
default:
return "RuntimeError";
}
}
#define SWIG_ErrorType(code) SWIG_Scilab_ErrorType(code)
#ifndef SWIG_SCILAB_ERROR
#define SWIG_SCILAB_ERROR 20000
#endif
SWIGINTERN void
SWIG_Scilab_Error(int code, const char *msg)
{
Scierror(SWIG_SCILAB_ERROR - code, _("SWIG/Scilab: %s: %s\n"), SWIG_Scilab_ErrorType(code), msg);
}
#define SWIG_Error(code, msg) SWIG_Scilab_Error(code, msg)
#define SWIG_fail return SWIG_ERROR;
SWIGRUNTIME void
SWIG_Scilab_Raise_Ex(const char *obj, const char *type, swig_type_info *descriptor) {
if (type) {
if (obj)
Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured: %s\n", type, obj);
else
Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured.\n", type);
}
}
SWIGRUNTIME void
SWIG_Scilab_Raise(const int obj, const char *type, swig_type_info *descriptor) {
Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured.\n", type);
}
/*
* Pointer utility functions
@ -451,7 +466,7 @@ int SWIG_ptr(SWIG_GatewayParameters) {
}
SWIG_Scilab_SetOutputPosition(1);
return SWIG_Scilab_SetOutput(pvApiCtx,
SwigScilabPtrFromObject(pvApiCtx, 1, (void *) (uintptr_t)dValue, NULL, 0));
SwigScilabPtrFromObject(pvApiCtx, 1, (void *) (uintptr_t)dValue, NULL, 0, NULL));
}
else {
return SWIG_ERROR;

View file

@ -1,33 +1,45 @@
%insert(runtime) "swigrun.swg";
%insert(runtime) "swigerrors.swg";
#define %scilabcode %insert("scilab")
%insert(runtime) "scirun.swg";
%init %{
%insert(init) %{
/* Module management functions */
#define SWIG_GetModule(clientdata) SWIG_Scilab_GetModule()
#define SWIG_SetModule(clientdata, pointer) SWIG_Scilab_SetModule(pointer)
SWIGRUNTIME swig_module_info*
SWIG_Scilab_GetModule(void)
{
SWIG_Scilab_GetModule(void) {
return NULL;
}
SWIGRUNTIME void
SWIG_Scilab_SetModule(swig_module_info *swig_module)
{
SWIG_Scilab_SetModule(swig_module_info *swig_module) {
}
%}
%insert(init) "swiginit.swg"
%init %{
%insert(init) %{
SWIGRUNTIME swig_type_info *
SWIG_Scilab_TypeQuery(const char *name) {
if (SWIG_Module_Initialized()) {
return SWIG_TypeQuery(name);
}
else {
SWIG_Error(SWIG_RuntimeError, "the module is not initialized");
return NULL;
}
}
%}
%insert(init) %{
#ifdef __cplusplus
extern "C"
#endif
int <module>_Init(SWIG_GatewayParameters) {
SWIG_InitializeModule(NULL);
SWIG_CreateScilabVariables(pvApiCtx);
swig_module_initialized = 1;
%}

View file

@ -84,7 +84,7 @@ SWIG_FromSet_Sequence_dec(bool)(int size, int *pSequence) {
SWIGINTERN bool
SWIG_AsVal_SequenceItem_dec(bool)(SwigSciObject obj, int *pSequence, int iItemIndex) {
return pSequence[iItemIndex];
return (bool) pSequence[iItemIndex];
}
}

View file

@ -1,5 +1,5 @@
/*
*char
*
* Scilab matrix of string <-> C++ std::string container
*
*/
@ -88,7 +88,7 @@ SWIG_AsVal_SequenceItem_dec(std::string)(SwigSciObject obj, char **pSequence, in
SWIGINTERN int
SWIG_From_SequenceItem_dec(std::string)(char **pSequence, int iItemIndex, std::string itemValue) {
char *pChar = new char(itemValue.size() + 1);
char *pChar = new char((int) itemValue.size() + 1);
strcpy(pChar, itemValue.c_str());
pSequence[iItemIndex] = pChar;
return SWIG_OK;

View file

@ -4,6 +4,13 @@
// to use a pointer to the smart pointer of the type, rather than the usual pointer to the underlying type.
// So for some type T, shared_ptr<T> * is used rather than T *.
// Another key part of the implementation is the smartptr feature:
// %feature("smartptr") T { shared_ptr<T> }
// This feature marks the class T as having a smartptr to it (the shared_ptr<T> type). This is then used to
// support smart pointers and inheritance. Say class D derives from base B, then shared_ptr<D> is marked
// with a fake inheritance from shared_ptr<B> in the type system if the "smartptr" feature is used on both
// B and D. This is to emulate the conversion of shared_ptr<D> to shared_ptr<B> in the target language.
// shared_ptr namespaces could be boost or std or std::tr1
// For example for std::tr1, use:
// #define SWIG_SHARED_PTR_NAMESPACE std

View file

@ -3,6 +3,7 @@
#endif
%{
#include <typeinfo>
#include <stdexcept>
%}
@ -15,6 +16,10 @@ namespace std {
virtual const char* what() const throw();
};
struct bad_cast : exception
{
};
struct bad_exception : exception
{
};

View file

@ -24,6 +24,7 @@
#endif
%{
#include <typeinfo>
#include <stdexcept>
%}
@ -40,6 +41,7 @@
%enddef
namespace std {
%std_exception_map(bad_cast, SWIG_TypeError);
%std_exception_map(bad_exception, SWIG_SystemError);
%std_exception_map(domain_error, SWIG_ValueError);
%std_exception_map(exception, SWIG_SystemError);

View file

@ -203,7 +203,7 @@
* This macro is used to return Character data along with a size
* parameter.
*
* %cstring_output_maxsize(Char *outx, int *max) {
* %cstring_output_withsize(Char *outx, int *max) {
* void foo(Char *outx, int *max) {
* sprintf(outx,"blah blah\n");
* *max = strlen(outx);
@ -236,7 +236,7 @@
* This macro is used to return Character data that was
* allocated with new or malloc.
*
* %cstring_output_allocated(Char **outx, free($1));
* %cstring_output_allocate(Char **outx, free($1));
* void foo(Char **outx) {
* *outx = (Char *) malloc(512);
* sprintf(outx,"blah blah\n");
@ -263,7 +263,7 @@
* This macro is used to return Character data that was
* allocated with new or malloc.
*
* %cstring_output_allocated(Char **outx, int *sz, free($1));
* %cstring_output_allocate_size(Char **outx, int *sz, free($1));
* void foo(Char **outx, int *sz) {
* *outx = (Char *) malloc(512);
* sprintf(outx,"blah blah\n");

View file

@ -20,6 +20,7 @@
%enddef
namespace std {
%std_exception_map(bad_cast, SWIG_TypeError);
%std_exception_map(bad_exception, SWIG_SystemError);
%std_exception_map(domain_error, SWIG_ValueError);
%std_exception_map(exception, SWIG_SystemError);

View file

@ -2722,6 +2722,13 @@ int ALLEGROCL::functionWrapper(Node *n) {
}
}
/* See if there is any return cleanup code */
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
Replaceall(tm, "$source", Swig_cresult_name());
Printf(f->code, "%s\n", tm);
Delete(tm);
}
emit_return_variable(n, t, f);
if (CPlusPlus) {

View file

@ -543,6 +543,14 @@ int CFFI::functionWrapper(Node *n) {
cleanupFunction(n, f, parms);
/* See if there is any return cleanup code */
String *tm = 0;
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
Replaceall(tm, "$source", Swig_cresult_name());
Printf(f->code, "%s\n", tm);
Delete(tm);
}
if (!is_void_return) {
Printf(f->code, " return lresult;\n");
}

View file

@ -2445,7 +2445,8 @@ private:
}
String *code = Copy(Getattr(n, "wrap:action"));
Replaceall(code, Getattr(parms, "lname"), current);
Replace(code, Getattr(parms, "lname"), current, DOH_REPLACE_ANY | DOH_REPLACE_ID);
Delete(current);
Printv(actioncode, code, "\n", NULL);
}
@ -2598,6 +2599,14 @@ private:
Replaceall(f->code, "$cleanup", cleanup);
Delete(cleanup);
/* See if there is any return cleanup code */
String *tm;
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
Replaceall(tm, "$source", Swig_cresult_name());
Printf(f->code, "%s\n", tm);
Delete(tm);
}
Replaceall(f->code, "$symname", Getattr(n, "sym:name"));
}

View file

@ -1354,6 +1354,11 @@ void JSEmitter::emitCleanupCode(Node *n, Wrapper *wrapper, ParmList *params) {
}
}
/* See if there is any return cleanup code */
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
Printf(wrapper->code, "%s\n", tm);
Delete(tm);
}
}
int JSEmitter::switchNamespace(Node *n) {

View file

@ -676,6 +676,14 @@ public:
Printv(f->code, tm, "\n", NIL);
}
}
/* See if there is any return cleanup code */
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
Replaceall(tm, "$source", Swig_cresult_name());
Printf(f->code, "%s\n", tm);
Delete(tm);
}
// Free any memory allocated by the function being wrapped..
if ((tm = Swig_typemap_lookup("swig_result", n, Swig_cresult_name(), 0))) {

View file

@ -1000,6 +1000,7 @@ public:
Delete(tm);
}
Printf(f->code, "thrown:\n");
Printf(f->code, "return;\n");
/* Error handling code */
@ -2356,6 +2357,7 @@ done:
Append(f->code, actioncode);
Delete(actioncode);
Printf(f->code, "thrown:\n");
Append(f->code, "return;\n");
Append(f->code, "fail:\n");
Append(f->code, "SWIG_FAIL(TSRMLS_C);\n");
@ -2623,6 +2625,7 @@ done:
}
/* exception handling */
bool error_used_in_typemap = false;
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
if (!tm) {
tm = Getattr(n, "feature:director:except");
@ -2632,6 +2635,7 @@ done:
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
if (Replaceall(tm, "$error", "error")) {
/* Only declare error if it is used by the typemap. */
error_used_in_typemap = true;
Append(w->code, "int error;\n");
}
} else {
@ -2655,6 +2659,9 @@ done:
/* wrap complex arguments to zvals */
Printv(w->code, wrap_args, NIL);
if (error_used_in_typemap) {
Append(w->code, "error = ");
}
Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,");
Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx);
@ -2715,6 +2722,7 @@ done:
Delete(outarg);
}
Append(w->code, "thrown:\n");
if (!is_void) {
if (!(ignored_method && !pure_virtual)) {
String *rettype = SwigType_str(returntype, 0);

View file

@ -47,11 +47,13 @@ static Hash *f_shadow_imports = 0;
static String *f_shadow_builtin_imports = 0;
static String *f_shadow_stubs = 0;
static Hash *builtin_getset = 0;
static Hash *builtin_closures = 0;
static Hash *class_members = 0;
static File *f_builtins = 0;
static String *builtin_tp_init = 0;
static String *builtin_methods = 0;
static String *builtin_default_unref = 0;
static String *builtin_closures_code = 0;
static String *methods;
static String *class_name;
@ -167,19 +169,19 @@ static const char *usage3 = "\
Function annotation \n\
\n";
static String *getSlot(Node *n = NULL, const char *key = NULL) {
static String *slot_default = NewString("0");
String *val = key && *key ? Getattr(n, key) : NULL;
return val ? val : slot_default;
static String *getSlot(Node *n = NULL, const char *key = NULL, String *default_slot = NULL) {
static String *zero = NewString("0");
String *val = n && key && *key ? Getattr(n, key) : NULL;
return val ? val : default_slot ? default_slot : zero;
}
static void printSlot(File *f, const String *slotval, const char *slotname, const char *functype = NULL) {
String *slotval_override = functype ? NewStringf("(%s) %s", functype, slotval) : 0;
if (slotval_override)
slotval = slotval_override;
static void printSlot(File *f, String *slotval, const char *slotname, const char *functype = NULL) {
String *slotval_override = 0;
if (functype)
slotval = slotval_override = NewStringf("(%s) %s", functype, slotval);
int len = Len(slotval);
int fieldwidth = len > 40 ? 0 : 40 - len;
Printf(f, " %s, %*s/* %s */\n", slotval, fieldwidth, "", slotname);
int fieldwidth = len > 41 ? (len > 61 ? 0 : 61 - len) : 41 - len;
Printf(f, " %s,%*s/* %s */\n", slotval, fieldwidth, "", slotname);
Delete(slotval_override);
}
@ -188,7 +190,7 @@ static String *getClosure(String *functype, String *wrapper, int funpack = 0) {
"unaryfunc", "SWIGPY_UNARYFUNC_CLOSURE",
"destructor", "SWIGPY_DESTRUCTOR_CLOSURE",
"inquiry", "SWIGPY_INQUIRY_CLOSURE",
"getiterfunc", "SWIGPY_UNARYFUNC_CLOSURE",
"getiterfunc", "SWIGPY_GETITERFUNC_CLOSURE",
"binaryfunc", "SWIGPY_BINARYFUNC_CLOSURE",
"ternaryfunc", "SWIGPY_TERNARYFUNC_CLOSURE",
"ternarycallfunc", "SWIGPY_TERNARYCALLFUNC_CLOSURE",
@ -200,7 +202,7 @@ static String *getClosure(String *functype, String *wrapper, int funpack = 0) {
"objobjargproc", "SWIGPY_OBJOBJARGPROC_CLOSURE",
"reprfunc", "SWIGPY_REPRFUNC_CLOSURE",
"hashfunc", "SWIGPY_HASHFUNC_CLOSURE",
"iternextfunc", "SWIGPY_ITERNEXT_CLOSURE",
"iternextfunc", "SWIGPY_ITERNEXTFUNC_CLOSURE",
NULL
};
@ -208,7 +210,7 @@ static String *getClosure(String *functype, String *wrapper, int funpack = 0) {
"unaryfunc", "SWIGPY_UNARYFUNC_CLOSURE",
"destructor", "SWIGPY_DESTRUCTOR_CLOSURE",
"inquiry", "SWIGPY_INQUIRY_CLOSURE",
"getiterfunc", "SWIGPY_UNARYFUNC_CLOSURE",
"getiterfunc", "SWIGPY_GETITERFUNC_CLOSURE",
"ternaryfunc", "SWIGPY_TERNARYFUNC_CLOSURE",
"ternarycallfunc", "SWIGPY_TERNARYCALLFUNC_CLOSURE",
"lenfunc", "SWIGPY_LENFUNC_CLOSURE",
@ -219,7 +221,7 @@ static String *getClosure(String *functype, String *wrapper, int funpack = 0) {
"objobjargproc", "SWIGPY_OBJOBJARGPROC_CLOSURE",
"reprfunc", "SWIGPY_REPRFUNC_CLOSURE",
"hashfunc", "SWIGPY_HASHFUNC_CLOSURE",
"iternextfunc", "SWIGPY_ITERNEXT_CLOSURE",
"iternextfunc", "SWIGPY_ITERNEXTFUNC_CLOSURE",
NULL
};
@ -626,6 +628,8 @@ public:
f_directors_h = NewString("");
f_directors = NewString("");
builtin_getset = NewHash();
builtin_closures = NewHash();
builtin_closures_code = NewString("");
class_members = NewHash();
builtin_methods = NewString("");
builtin_default_unref = NewString("delete $self;");
@ -861,12 +865,13 @@ public:
/* At here, the module may already loaded, so simply import it. */
Printf(f_shadow, tab4 tab8 "import %s\n", module);
Printf(f_shadow, tab4 tab8 "return %s\n", module);
Printv(f_shadow, tab8 "if fp is not None:\n", NULL);
Printv(f_shadow, tab4 tab8 "try:\n", NULL);
Printf(f_shadow, tab8 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module);
Printv(f_shadow, tab4 tab8, "finally:\n", NULL);
Printv(f_shadow, tab8 "try:\n", NULL);
/* imp.load_module() handles fp being None. */
Printf(f_shadow, tab4 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module);
Printv(f_shadow, tab8, "finally:\n", NULL);
Printv(f_shadow, tab4 tab8 "if fp is not None:\n", NULL);
Printv(f_shadow, tab8 tab8, "fp.close()\n", NULL);
Printv(f_shadow, tab4 tab8, "return _mod\n", NULL);
Printv(f_shadow, tab8, "return _mod\n", NULL);
Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module);
Printv(f_shadow, tab4, "del swig_import_helper\n", NULL);
Printv(f_shadow, "else:\n", NULL);
@ -2037,7 +2042,7 @@ public:
// Disregard optional "f" suffix, it can be just dropped in Python as it
// uses doubles for everything anyhow.
for (char* p = end; *p != '\0'; ++p) {
for (char * p = end; *p != '\0'; ++p) {
switch (*p) {
case 'f':
case 'F':
@ -2083,7 +2088,7 @@ public:
// combination of "l" and "u", but not anything else (again, stuff like
// "LL" could be handled, but we don't bother to do it currently).
bool seen_long = false;
for (char* p = end; *p != '\0'; ++p) {
for (char * p = end; *p != '\0'; ++p) {
switch (*p) {
case 'l':
case 'L':
@ -3321,17 +3326,18 @@ public:
}
if (in_class && builtin) {
/* Handle operator overloads overloads for builtin types */
/* Handle operator overloads for builtin types */
String *slot = Getattr(n, "feature:python:slot");
if (slot) {
String *func_type = Getattr(n, "feature:python:slot:functype");
String *closure_decl = getClosure(func_type, wrapper_name, overname ? 0 : funpack);
String *feature_name = NewStringf("feature:python:%s", slot);
String *closure_name = Copy(wrapper_name);
String *closure_name = 0;
if (closure_decl) {
if (!Getattr(n, "sym:overloaded") || !Getattr(n, "sym:nextSibling"))
Printv(f_wrappers, closure_decl, "\n\n", NIL);
Append(closure_name, "_closure");
closure_name = NewStringf("%s_%s_closure", wrapper_name, func_type);
if (!GetFlag(builtin_closures, closure_name))
Printf(builtin_closures_code, "%s /* defines %s */\n\n", closure_decl, closure_name);
SetFlag(builtin_closures, closure_name);
Delete(closure_decl);
}
if (func_type) {
@ -3392,7 +3398,7 @@ public:
Python dictionary. */
if (!have_globals) {
Printf(f_init, "\t PyDict_SetItemString(md,(char*)\"%s\", SWIG_globals());\n", global_name);
Printf(f_init, "\t PyDict_SetItemString(md,(char *)\"%s\", SWIG_globals());\n", global_name);
if (builtin)
Printf(f_init, "\t SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", global_name);
have_globals = 1;
@ -3480,9 +3486,9 @@ public:
Wrapper_print(getf, f_wrappers);
/* Now add this to the variable linking mechanism */
Printf(f_init, "\t SWIG_addvarlink(SWIG_globals(),(char*)\"%s\",%s, %s);\n", iname, vargetname, varsetname);
Printf(f_init, "\t SWIG_addvarlink(SWIG_globals(),(char *)\"%s\",%s, %s);\n", iname, vargetname, varsetname);
if (builtin && shadow && !assignable && !in_class) {
Printf(f_init, "\t PyDict_SetItemString(md, (char*)\"%s\", PyObject_GetAttrString(SWIG_globals(), \"%s\"));\n", iname, iname);
Printf(f_init, "\t PyDict_SetItemString(md, (char *)\"%s\", PyObject_GetAttrString(SWIG_globals(), \"%s\"));\n", iname, iname);
Printf(f_init, "\t SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", iname);
}
Delete(vargetname);
@ -3499,7 +3505,7 @@ public:
* ------------------------------------------------------------ */
/* Determine if the node requires the _swigconstant code to be generated */
bool needs_swigconstant(Node* n) {
bool needs_swigconstant(Node *n) {
SwigType *type = Getattr(n, "type");
SwigType *qtype = SwigType_typedef_resolve_all(type);
SwigType *uqtype = SwigType_strip_qualifiers(qtype);
@ -3576,12 +3582,12 @@ public:
Printf(f_wrappers, tab2 "PyObject *d;\n");
if (modernargs) {
if (fastunpack) {
Printf(f_wrappers, tab2 "if (!SWIG_Python_UnpackTuple(args,(char*)\"swigconstant\", 1, 1,&module)) return NULL;\n");
Printf(f_wrappers, tab2 "if (!SWIG_Python_UnpackTuple(args,(char *)\"swigconstant\", 1, 1,&module)) return NULL;\n");
} else {
Printf(f_wrappers, tab2 "if (!PyArg_UnpackTuple(args,(char*)\"swigconstant\", 1, 1,&module)) return NULL;\n");
Printf(f_wrappers, tab2 "if (!PyArg_UnpackTuple(args,(char *)\"swigconstant\", 1, 1,&module)) return NULL;\n");
}
} else {
Printf(f_wrappers, tab2 "if (!PyArg_ParseTuple(args,(char*)\"O:swigconstant\", &module)) return NULL;\n");
Printf(f_wrappers, tab2 "if (!PyArg_ParseTuple(args,(char *)\"O:swigconstant\", &module)) return NULL;\n");
}
Printf(f_wrappers, tab2 "d = PyModule_GetDict(module);\n");
Printf(f_wrappers, tab2 "if (!d) return NULL;\n");
@ -3737,13 +3743,13 @@ public:
Node *parent = Swig_methodclass(n);
String *basetype = Getattr(parent, "classtype");
Wrapper *w = NewWrapper();
Printf(w->def, "SwigDirector_%s::SwigDirector_%s(PyObject* self) : Swig::Director(self) { \n", classname, classname);
Printf(w->def, "SwigDirector_%s::SwigDirector_%s(PyObject *self) : Swig::Director(self) { \n", classname, classname);
Printf(w->def, " SWIG_DIRECTOR_RGTR((%s *)this, this); \n", basetype);
Append(w->def, "}\n");
Wrapper_print(w, f_directors);
DelWrapper(w);
}
Printf(f_directors_h, " SwigDirector_%s(PyObject* self);\n", classname);
Printf(f_directors_h, " SwigDirector_%s(PyObject *self);\n", classname);
Delete(classname);
return Language::classDirectorDefaultConstructor(n);
}
@ -3919,7 +3925,6 @@ public:
int funpack = modernargs && fastunpack;
Printv(f_init, " SwigPyBuiltin_SetMetaType(builtin_pytype, metatype);\n", NIL);
Printf(f_init, " builtin_pytype->tp_new = PyType_GenericNew;\n");
Printv(f_init, " builtin_base_count = 0;\n", NIL);
List *baselist = Getattr(n, "bases");
if (baselist) {
@ -3933,8 +3938,8 @@ public:
SwigType_add_pointer(base_name);
String *base_mname = SwigType_manglestr(base_name);
Printf(f_init, " builtin_basetype = SWIG_MangledTypeQuery(\"%s\");\n", base_mname);
Printv(f_init, " if (builtin_basetype && builtin_basetype->clientdata && ((SwigPyClientData*) builtin_basetype->clientdata)->pytype) {\n", NIL);
Printv(f_init, " builtin_bases[builtin_base_count++] = ((SwigPyClientData*) builtin_basetype->clientdata)->pytype;\n", NIL);
Printv(f_init, " if (builtin_basetype && builtin_basetype->clientdata && ((SwigPyClientData *) builtin_basetype->clientdata)->pytype) {\n", NIL);
Printv(f_init, " builtin_bases[builtin_base_count++] = ((SwigPyClientData *) builtin_basetype->clientdata)->pytype;\n", NIL);
Printv(f_init, " } else {\n", NIL);
Printf(f_init, " PyErr_SetString(PyExc_TypeError, \"Could not create type '%s' as base '%s' has not been initialized.\\n\");\n", symname, bname);
Printv(f_init, "#if PY_VERSION_HEX >= 0x03000000\n", NIL);
@ -3956,13 +3961,7 @@ public:
// Check for non-public destructor, in which case tp_dealloc will issue
// a warning and allow the memory to leak. Any class that doesn't explicitly
// have a private/protected destructor has an implicit public destructor.
String *tp_dealloc = Getattr(n, "feature:python:tp_dealloc");
if (tp_dealloc) {
Printf(f, "SWIGPY_DESTRUCTOR_CLOSURE(%s)\n", tp_dealloc);
tp_dealloc = NewStringf("%s_closure", tp_dealloc);
} else {
tp_dealloc = NewString("SwigPyBuiltin_BadDealloc");
}
static String *tp_dealloc_bad = NewString("SwigPyBuiltin_BadDealloc");
String *getset_name = NewStringf("%s_getset", templ);
String *methods_name = NewStringf("%s_methods", templ);
@ -3984,12 +3983,12 @@ public:
String *gspair = NewStringf("%s_%s_getset", symname, memname);
Printf(f, "static SwigPyGetSet %s = { %s, %s };\n", gspair, getter ? getter : "0", setter ? setter : "0");
String *entry =
NewStringf("{ (char*) \"%s\", (getter) %s, (setter) %s, (char*)\"%s.%s\", (void*) &%s }\n", memname, getter_closure,
NewStringf("{ (char *) \"%s\", (getter) %s, (setter) %s, (char *)\"%s.%s\", (void *) &%s }\n", memname, getter_closure,
setter_closure, name, memname, gspair);
if (GetFlag(mgetset, "static")) {
Printf(f, "static PyGetSetDef %s_def = %s;\n", gspair, entry);
Printf(f_init, "static_getset = SwigPyStaticVar_new_getset(metatype, &%s_def);\n", gspair);
Printf(f_init, "PyDict_SetItemString(d, static_getset->d_getset->name, (PyObject*) static_getset);\n", memname);
Printf(f_init, "PyDict_SetItemString(d, static_getset->d_getset->name, (PyObject *) static_getset);\n", memname);
Printf(f_init, "Py_DECREF(static_getset);\n");
} else {
Printf(getset_def, " %s,\n", entry);
@ -4057,10 +4056,18 @@ public:
quoted_symname = NewStringf("\"%s\"", symname);
}
String *quoted_tp_doc_str = NewStringf("\"%s\"", getSlot(n, "feature:python:tp_doc"));
char const *tp_init = builtin_tp_init ? Char(builtin_tp_init) : Swig_directorclass(n) ? "0" : "SwigPyBuiltin_BadInit";
String *tp_init = NewString(builtin_tp_init ? Char(builtin_tp_init) : Swig_directorclass(n) ? "0" : "SwigPyBuiltin_BadInit");
String *tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES");
String *py3_tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE");
String *tp_flags_py3 = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE");
static String *tp_basicsize = NewStringf("sizeof(SwigPyObject)");
static String *tp_dictoffset_default = NewString("offsetof(SwigPyObject, dict)");
static String *tp_new = NewString("PyType_GenericNew");
static String *tp_hash = NewString("SwigPyObject_hash");
String *tp_as_number = NewStringf("&%s_type.as_number", templ);
String *tp_as_sequence = NewStringf("&%s_type.as_sequence", templ);
String *tp_as_mapping = NewStringf("&%s_type.as_mapping", templ);
String *tp_as_buffer = NewStringf("&%s_type.as_buffer", templ);
Printf(f, "static PyHeapTypeObject %s_type = {\n", templ);
@ -4073,9 +4080,9 @@ public:
printSlot(f, getSlot(), "ob_size");
Printv(f, "#endif\n", NIL);
printSlot(f, quoted_symname, "tp_name");
printSlot(f, "sizeof(SwigPyObject)", "tp_basicsize");
printSlot(f, getSlot(n, "feature:python:tp_basicsize", tp_basicsize), "tp_basicsize");
printSlot(f, getSlot(n, "feature:python:tp_itemsize"), "tp_itemsize");
printSlot(f, tp_dealloc, "tp_dealloc", "destructor");
printSlot(f, getSlot(n, "feature:python:tp_dealloc", tp_dealloc_bad), "tp_dealloc", "destructor");
printSlot(f, getSlot(n, "feature:python:tp_print"), "tp_print", "printfunc");
printSlot(f, getSlot(n, "feature:python:tp_getattr"), "tp_getattr", "getattrfunc");
printSlot(f, getSlot(n, "feature:python:tp_setattr"), "tp_setattr", "setattrfunc");
@ -4085,46 +4092,46 @@ public:
printSlot(f, getSlot(n, "feature:python:tp_compare"), "tp_compare", "cmpfunc");
Printv(f, "#endif\n", NIL);
printSlot(f, getSlot(n, "feature:python:tp_repr"), "tp_repr", "reprfunc");
Printf(f, " &%s_type.as_number, /* tp_as_number */\n", templ);
Printf(f, " &%s_type.as_sequence, /* tp_as_sequence */\n", templ);
Printf(f, " &%s_type.as_mapping, /* tp_as_mapping */\n", templ);
printSlot(f, getSlot(n, "feature:python:tp_hash"), "tp_hash", "hashfunc");
printSlot(f, getSlot(n, "feature:python:tp_as_number", tp_as_number), "tp_as_number");
printSlot(f, getSlot(n, "feature:python:tp_as_sequence", tp_as_sequence), "tp_as_sequence");
printSlot(f, getSlot(n, "feature:python:tp_as_mapping", tp_as_mapping), "tp_as_mapping");
printSlot(f, getSlot(n, "feature:python:tp_hash", tp_hash), "tp_hash", "hashfunc");
printSlot(f, getSlot(n, "feature:python:tp_call"), "tp_call", "ternaryfunc");
printSlot(f, getSlot(n, "feature:python:tp_str"), "tp_str", "reprfunc");
printSlot(f, getSlot(n, "feature:python:tp_getattro"), "tp_getattro", "getattrofunc");
printSlot(f, getSlot(n, "feature:python:tp_setattro"), "tp_setattro", "setattrofunc");
Printf(f, " &%s_type.as_buffer, /* tp_as_buffer */\n", templ);
printSlot(f, getSlot(n, "feature:python:tp_as_buffer", tp_as_buffer), "tp_as_buffer");
Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL);
printSlot(f, py3_tp_flags, "tp_flags");
printSlot(f, getSlot(n, "feature:python:tp_flags", tp_flags_py3), "tp_flags");
Printv(f, "#else\n", NIL);
printSlot(f, tp_flags, "tp_flags");
printSlot(f, getSlot(n, "feature:python:tp_flags", tp_flags), "tp_flags");
Printv(f, "#endif\n", NIL);
printSlot(f, quoted_tp_doc_str, "tp_doc");
printSlot(f, getSlot(n, "feature:python:tp_traverse"), "tp_traverse", "traverseproc");
printSlot(f, getSlot(n, "feature:python:tp_clear"), "tp_clear", "inquiry");
printSlot(f, richcompare_func, "feature:python:tp_richcompare", "richcmpfunc");
printSlot(f, getSlot(n, "feature:python:tp_richcompare", richcompare_func), "tp_richcompare", "richcmpfunc");
printSlot(f, getSlot(n, "feature:python:tp_weaklistoffset"), "tp_weaklistoffset");
printSlot(f, getSlot(n, "feature:python:tp_iter"), "tp_iter", "getiterfunc");
printSlot(f, getSlot(n, "feature:python:tp_iternext"), "tp_iternext", "iternextfunc");
printSlot(f, methods_name, "tp_methods");
printSlot(f, getSlot(n, "feature:python:tp_methods", methods_name), "tp_methods");
printSlot(f, getSlot(n, "feature:python:tp_members"), "tp_members");
printSlot(f, getset_name, "tp_getset");
printSlot(f, getSlot(n, "feature:python:tp_getset", getset_name), "tp_getset");
printSlot(f, getSlot(n, "feature:python:tp_base"), "tp_base");
printSlot(f, getSlot(n, "feature:python:tp_dict"), "tp_dict");
printSlot(f, getSlot(n, "feature:python:tp_descr_get"), "tp_descr_get", "descrgetfunc");
printSlot(f, getSlot(n, "feature:python:tp_descr_set"), "tp_descr_set", "descrsetfunc");
Printf(f, " (Py_ssize_t)offsetof(SwigPyObject, dict), /* tp_dictoffset */\n");
printSlot(f, tp_init, "tp_init", "initproc");
printSlot(f, getSlot(n, "feature:python:tp_dictoffset", tp_dictoffset_default), "tp_dictoffset", "Py_ssize_t");
printSlot(f, getSlot(n, "feature:python:tp_init", tp_init), "tp_init", "initproc");
printSlot(f, getSlot(n, "feature:python:tp_alloc"), "tp_alloc", "allocfunc");
printSlot(f, "0", "tp_new", "newfunc");
printSlot(f, getSlot(n, "feature:python:tp_new", tp_new), "tp_new", "newfunc");
printSlot(f, getSlot(n, "feature:python:tp_free"), "tp_free", "freefunc");
printSlot(f, getSlot(), "tp_is_gc", "inquiry");
printSlot(f, getSlot(), "tp_bases", "PyObject*");
printSlot(f, getSlot(), "tp_mro", "PyObject*");
printSlot(f, getSlot(), "tp_cache", "PyObject*");
printSlot(f, getSlot(), "tp_subclasses", "PyObject*");
printSlot(f, getSlot(), "tp_weaklist", "PyObject*");
printSlot(f, getSlot(), "tp_del", "destructor");
printSlot(f, getSlot(n, "feature:python:tp_is_gc"), "tp_is_gc", "inquiry");
printSlot(f, getSlot(n, "feature:python:tp_bases"), "tp_bases", "PyObject *");
printSlot(f, getSlot(n, "feature:python:tp_mro"), "tp_mro", "PyObject *");
printSlot(f, getSlot(n, "feature:python:tp_cache"), "tp_cache", "PyObject *");
printSlot(f, getSlot(n, "feature:python:tp_subclasses"), "tp_subclasses", "PyObject *");
printSlot(f, getSlot(n, "feature:python:tp_weaklist"), "tp_weaklist", "PyObject *");
printSlot(f, getSlot(n, "feature:python:tp_del"), "tp_del", "destructor");
Printv(f, "#if PY_VERSION_HEX >= 0x02060000\n", NIL);
printSlot(f, getSlot(n, "feature:python:tp_version_tag"), "tp_version_tag", "int");
Printv(f, "#endif\n", NIL);
@ -4132,13 +4139,13 @@ public:
printSlot(f, getSlot(n, "feature:python:tp_finalize"), "tp_finalize", "destructor");
Printv(f, "#endif\n", NIL);
Printv(f, "#ifdef COUNT_ALLOCS\n", NIL);
printSlot(f, getSlot(), "tp_allocs", "Py_ssize_t");
printSlot(f, getSlot(), "tp_frees", "Py_ssize_t");
printSlot(f, getSlot(), "tp_maxalloc", "Py_ssize_t");
printSlot(f, getSlot(n, "feature:python:tp_allocs"), "tp_allocs", "Py_ssize_t");
printSlot(f, getSlot(n, "feature:python:tp_frees"), "tp_frees", "Py_ssize_t");
printSlot(f, getSlot(n, "feature:python:tp_maxalloc"), "tp_maxalloc", "Py_ssize_t");
Printv(f, "#if PY_VERSION_HEX >= 0x02050000\n", NIL);
printSlot(f, getSlot(), "tp_prev", "struct _typeobject*");
printSlot(f, getSlot(n, "feature:python:tp_prev"), "tp_prev");
Printv(f, "#endif\n", NIL);
printSlot(f, getSlot(), "tp_next", "struct _typeobject*");
printSlot(f, getSlot(n, "feature:python:tp_next"), "tp_next");
Printv(f, "#endif\n", NIL);
Printf(f, " },\n");
@ -4177,7 +4184,7 @@ public:
Printv(f, "#endif\n", NIL);
printSlot(f, getSlot(n, "feature:python:nb_int"), "nb_int", "unaryfunc");
Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL);
printSlot(f, getSlot(n, "feature:python:nb_reserved"), "nb_reserved", "void*");
printSlot(f, getSlot(n, "feature:python:nb_reserved"), "nb_reserved", "void *");
Printv(f, "#else\n", NIL);
printSlot(f, getSlot(n, "feature:python:nb_long"), "nb_long", "unaryfunc");
Printv(f, "#endif\n", NIL);
@ -4226,13 +4233,13 @@ public:
printSlot(f, getSlot(n, "feature:python:sq_repeat"), "sq_repeat", "ssizeargfunc");
printSlot(f, getSlot(n, "feature:python:sq_item"), "sq_item", "ssizeargfunc");
Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL);
printSlot(f, getSlot(n, "feature:was_sq_slice"), "was_sq_slice", "void*");
printSlot(f, getSlot(n, "feature:python:was_sq_slice"), "was_sq_slice", "void *");
Printv(f, "#else\n", NIL);
printSlot(f, getSlot(n, "feature:python:sq_slice"), "sq_slice", "ssizessizeargfunc");
Printv(f, "#endif\n", NIL);
printSlot(f, getSlot(n, "feature:python:sq_ass_item"), "sq_ass_item", "ssizeobjargproc");
Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL);
printSlot(f, getSlot(n, "feature:was_sq_ass_slice"), "was_sq_ass_slice", "void*");
printSlot(f, getSlot(n, "feature:python:was_sq_ass_slice"), "was_sq_ass_slice", "void *");
Printv(f, "#else\n", NIL);
printSlot(f, getSlot(n, "feature:python:sq_ass_slice"), "sq_ass_slice", "ssizessizeobjargproc");
Printv(f, "#endif\n", NIL);
@ -4256,13 +4263,13 @@ public:
Printf(f, " },\n");
// PyObject *ht_name, *ht_slots, *ht_qualname;
printSlot(f, getSlot(n, "feature:python:ht_name"), "ht_name", "PyObject*");
printSlot(f, getSlot(n, "feature:python:ht_slots"), "ht_slots", "PyObject*");
printSlot(f, getSlot(n, "feature:python:ht_name"), "ht_name", "PyObject *");
printSlot(f, getSlot(n, "feature:python:ht_slots"), "ht_slots", "PyObject *");
Printv(f, "#if PY_VERSION_HEX >= 0x03030000\n", NIL);
printSlot(f, getSlot(n, "feature:python:ht_qualname"), "ht_qualname", "PyObject*");
printSlot(f, getSlot(n, "feature:python:ht_qualname"), "ht_qualname", "PyObject *");
// struct _dictkeysobject *ht_cached_keys;
printSlot(f, getSlot(n, "feature:python:ht_cached_keys"), "ht_cached_keys", "struct _dictkeysobject*");
printSlot(f, getSlot(n, "feature:python:ht_cached_keys"), "ht_cached_keys");
Printv(f, "#endif\n", NIL);
Printf(f, "};\n\n");
@ -4281,7 +4288,7 @@ public:
String *clientdata_klass = NewString("0");
if (GetFlag(n, "feature:implicitconv")) {
Clear(clientdata_klass);
Printf(clientdata_klass, "(PyObject*) &%s_type", templ);
Printf(clientdata_klass, "(PyObject *) &%s_type", templ);
}
Printf(f, "SWIGINTERN SwigPyClientData %s_clientdata = {%s, 0, 0, 0, 0, 0, (PyTypeObject *)&%s_type};\n\n", templ, clientdata_klass, templ);
@ -4295,7 +4302,7 @@ public:
Printv(f_init, "#endif\n", NIL);
Printv(f_init, " }\n", NIL);
Printv(f_init, " Py_INCREF(builtin_pytype);\n", NIL);
Printf(f_init, " PyModule_AddObject(m, \"%s\", (PyObject*) builtin_pytype);\n", symname);
Printf(f_init, " PyModule_AddObject(m, \"%s\", (PyObject *)builtin_pytype);\n", symname);
Printf(f_init, " SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", symname);
Printv(f_init, " d = md;\n", NIL);
@ -4306,11 +4313,15 @@ public:
Delete(mname);
Delete(pmname);
Delete(templ);
Delete(tp_dealloc);
Delete(tp_flags);
Delete(py3_tp_flags);
Delete(tp_flags_py3);
Delete(tp_as_buffer);
Delete(tp_as_mapping);
Delete(tp_as_sequence);
Delete(tp_as_number);
Delete(quoted_symname);
Delete(quoted_tp_doc_str);
Delete(tp_init);
Delete(clientdata_klass);
Delete(richcompare_func);
Delete(getset_name);
@ -4483,7 +4494,7 @@ public:
SwigType_add_pointer(p_real_classname);
String *mangle = SwigType_manglestr(p_real_classname);
String *descriptor = NewStringf("SWIGTYPE%s", mangle);
Printv(none_comparison, "self->ob_type != ((SwigPyClientData*) (", descriptor, ")->clientdata)->pytype", NIL);
Printv(none_comparison, "self->ob_type != ((SwigPyClientData *)(", descriptor, ")->clientdata)->pytype", NIL);
Delete(descriptor);
Delete(mangle);
Delete(p_real_classname);
@ -4505,17 +4516,22 @@ public:
SwigType *realct = Copy(real_classname);
SwigType_add_pointer(realct);
SwigType_remember(realct);
if (!builtin) {
if (builtin) {
Printv(f_wrappers, builtin_closures_code, NIL);
Delete(builtin_closures_code);
builtin_closures_code = NewString("");
Clear(builtin_closures);
} else {
Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL);
Printv(f_wrappers, " PyObject *obj;\n", NIL);
if (modernargs) {
if (fastunpack) {
Printv(f_wrappers, " if (!SWIG_Python_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL);
Printv(f_wrappers, " if (!SWIG_Python_UnpackTuple(args,(char *)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL);
} else {
Printv(f_wrappers, " if (!PyArg_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL);
Printv(f_wrappers, " if (!PyArg_UnpackTuple(args,(char *)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL);
}
} else {
Printv(f_wrappers, " if (!PyArg_ParseTuple(args,(char*)\"O:swigregister\", &obj)) return NULL;\n", NIL);
Printv(f_wrappers, " if (!PyArg_ParseTuple(args,(char *)\"O:swigregister\", &obj)) return NULL;\n", NIL);
}
Printv(f_wrappers,
@ -4658,13 +4674,13 @@ public:
int argcount = Getattr(n, "python:argcount") ? atoi(Char(Getattr(n, "python:argcount"))) : 2;
String *ds = have_docstring(n) ? cdocstring(n, AUTODOC_FUNC) : NewString("");
if (check_kwargs(n)) {
Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_VARARGS|METH_KEYWORDS, (char*) \"%s\" },\n", symname, wname, ds);
Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_VARARGS|METH_KEYWORDS, (char *) \"%s\" },\n", symname, wname, ds);
} else if (argcount == 0) {
Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_NOARGS, (char*) \"%s\" },\n", symname, wname, ds);
Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_NOARGS, (char *) \"%s\" },\n", symname, wname, ds);
} else if (argcount == 1) {
Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_O, (char*) \"%s\" },\n", symname, wname, ds);
Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_O, (char *) \"%s\" },\n", symname, wname, ds);
} else {
Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_VARARGS, (char*) \"%s\" },\n", symname, wname, ds);
Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_VARARGS, (char *) \"%s\" },\n", symname, wname, ds);
}
Delete(fullname);
Delete(wname);
@ -4765,7 +4781,7 @@ public:
Append(pyflags, "METH_VARARGS");
if (have_docstring(n)) {
String *ds = cdocstring(n, AUTODOC_STATICFUNC);
Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, %s, (char*) \"%s\" },\n", symname, wname, pyflags, ds);
Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, %s, (char *) \"%s\" },\n", symname, wname, pyflags, ds);
Delete(ds);
} else {
Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, %s, \"\" },\n", symname, wname, pyflags);
@ -4967,12 +4983,10 @@ public:
if (builtin && in_class) {
Node *cls = Swig_methodclass(n);
// Use the destructor for the tp_dealloc slot unless a user overrides it with another method
if (!Getattr(cls, "feature:python:tp_dealloc")) {
String *dealloc = Swig_name_destroy(NSPACE_TODO, symname);
String *wdealloc = Swig_name_wrapper(dealloc);
Setattr(cls, "feature:python:tp_dealloc", wdealloc);
Delete(wdealloc);
Delete(dealloc);
Setattr(n, "feature:python:slot", "tp_dealloc");
Setattr(n, "feature:python:slot:functype", "destructor");
}
}
@ -5552,9 +5566,9 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
Append(w->code, "}\n");
Append(w->code, "#if defined(SWIG_PYTHON_DIRECTOR_VTABLE)\n");
Printf(w->code, "const size_t swig_method_index = %d;\n", director_method_index++);
Printf(w->code, "const char * const swig_method_name = \"%s\";\n", pyname);
Printf(w->code, "const char *const swig_method_name = \"%s\";\n", pyname);
Append(w->code, "PyObject* method = swig_get_method(swig_method_index, swig_method_name);\n");
Append(w->code, "PyObject *method = swig_get_method(swig_method_index, swig_method_name);\n");
if (Len(parse_args) > 0) {
if (use_parse || !modernargs) {
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", Swig_cresult_name(), parse_args, arglist);
@ -5564,7 +5578,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
} else {
if (modernargs) {
Append(w->code, "swig::SwigVar_PyObject args = PyTuple_New(0);\n");
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_Call(method, (PyObject*) args, NULL);\n", Swig_cresult_name());
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_Call(method, (PyObject *) args, NULL);\n", Swig_cresult_name());
} else {
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunction(method, NULL, NULL);\n", Swig_cresult_name());
}

View file

@ -2097,6 +2097,13 @@ int R::functionWrapper(Node *n) {
}
}
/* See if there is any return cleanup code */
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
Replaceall(tm, "$source", Swig_cresult_name());
Printf(f->code, "%s\n", tm);
Delete(tm);
}
Printv(f->code, UnProtectWrapupCode, NIL);
/*If the user gave us something to convert the result in */

View file

@ -412,7 +412,7 @@ public:
emit_return_variable(node, functionReturnType, wrapper);
/* Return the function value if necessary */
String *functionReturnTypemap = Swig_typemap_lookup_out("out", node, "result", wrapper, functionActionCode);
String *functionReturnTypemap = Swig_typemap_lookup_out("out", node, Swig_cresult_name(), wrapper, functionActionCode);
if (functionReturnTypemap) {
// Result is actually the position of output value on stack
if (Len(functionReturnTypemap) > 0) {
@ -471,6 +471,13 @@ public:
}
}
/* See if there is any return cleanup code */
String *tm;
if ((tm = Swig_typemap_lookup("ret", node, Swig_cresult_name(), 0))) {
Replaceall(tm, "$source", Swig_cresult_name());
Printf(wrapper->code, "%s\n", tm);
Delete(tm);
}
/* Close the function(ok) */
Printv(wrapper->code, "return SWIG_OK;\n", NIL);

View file

@ -144,8 +144,8 @@ public:
Xml_print_kwargs(Getattr(obj, k));
} else if (Cmp(k, "parms") == 0 || Cmp(k, "pattern") == 0) {
Xml_print_parmlist(Getattr(obj, k));
} else if (Cmp(k, "catchlist") == 0) {
Xml_print_parmlist(Getattr(obj, k), "catchlist");
} else if (Cmp(k, "catchlist") == 0 || Cmp(k, "templateparms") == 0) {
Xml_print_parmlist(Getattr(obj, k), Char(k));
} else {
DOH *o;
print_indent(0);

View file

@ -78,10 +78,6 @@ outdir = os.path.basename(os.getcwd()) + "/" + dirname + "/"
print "Grabbing tagged release git repository using 'git archive' into " + outdir
os.system("(cd .. && git archive --prefix=" + outdir + " " + tag + " . | tar -xf -)") == 0 or failed()
# Remove the debian directory -- it's not official
os.system("rm -Rf "+dirname+"/debian") == 0 or failed()
# Go build the system
print "Building system"

20
debian/README vendored
View file

@ -1,20 +0,0 @@
The Debian Package swig1.3
--------------------------
This is SWIG 1.3 (Simplified Wrapper and Interface Generator)
packaged for Debian GNU/Linux.
SWIG 1.3 is not fully compatible with SWIG 1.1. It is a re-development
effort of SWIG 1.1 (which was written in C++) in ANSI C. The 1.3
series is in "alpha" state. Release 1.3a5 was rather stable, and it
should be used for new projects rather than the ancient release
1.1p5. See the file `NEW' for information on the new features of the
1.3 series.
This Debian package derives from the release 1.3a5 and corresponds to
the "mkoeppe-1-3-a5-patches" branch of the SWIG CVS repository. It
fixes several bugs and enhances several language backends. See the
top of the file `CHANGES' for details.
Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de>, Mon, 28 May 2001 15:08:55 +0200

66
debian/changelog vendored
View file

@ -1,66 +0,0 @@
swig1.3 (1.3.pnet) unstable; urgency=low
* Support for dotgnu pnet under debian
-- James Michael DuPont <mdupont777@yahoo.com> Wed, 12 Mar 2003 20:55:53 +0200
swig1.3 (1.3.a5+patches-9) unstable; urgency=low
* New upstream version
-- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Wed, 6 Jun 2001 16:11:41 +0200
swig1.3 (1.3.a5+patches-8) unstable; urgency=low
* New upstream version
-- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Wed, 6 Jun 2001 14:06:51 +0200
swig1.3 (1.3.a5+patches-7) unstable; urgency=low
* New upstream version
-- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Wed, 6 Jun 2001 13:34:44 +0200
swig1.3 (1.3.a5+patches-6) unstable; urgency=low
* New upstream version
-- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Tue, 5 Jun 2001 14:11:52 +0200
swig1.3 (1.3.a5+patches-5) unstable; urgency=low
* New upstream version.
-- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Fri, 1 Jun 2001 18:48:59 +0200
swig1.3 (1.3.a5+patches-4) unstable; urgency=low
* Fix hard-coded location of swig library. Added build-dependency on
tcl-dev.
-- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Fri, 1 Jun 2001 13:32:34 +0200
swig1.3 (1.3.a5+patches-3) unstable; urgency=low
* New upstream version
-- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Thu, 31 May 2001 13:15:20 +0200
swig1.3 (1.3.a5+patches-2) unstable; urgency=low
* Binary and manpage now include version number, to improve
cooperation with the "swig" package.
-- Matthias Koeppe <mkoeppe@rotehorn.math.uni-magdeburg.de> Tue, 29 May 2001 15:15:07 +0200
swig1.3 (1.3.a5+patches-1) unstable; urgency=low
* First release.
-- Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de> Sat, 20 Nov 1999 01:09:11 +0100
Local variables:
mode: debian-changelog
add-log-mailing-address: "mkoeppe@mail.math.uni-magdeburg.de"
End:

18
debian/control vendored
View file

@ -1,18 +0,0 @@
Source: swig1.3
Section: interpreters
Priority: optional
Maintainer: Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de>
Build-Depends: debhelper (>> 3.0.0), libguile-dev, python-dev, perl,
ruby-dev, ruby, tcl8.0-dev
Standards-Version: 3.5.2
Package: swig1.3
Architecture: any
Depends: ${shlibs:Depends}
Description: Generate scripting interfaces to C/C++ code
SWIG (Simplified Wrapper and Interface Generator) is a system for
automatically generating wrapper/glue code for several languages
(Tcl, Python, Perl, Ruby, MzScheme, Guile, Java) from annotated C or
C++ header files.
This package represents some point in the SWIG 1.3 development
series. It is not fully compatible with the SWIG 1.1 release.

83
debian/copyright vendored
View file

@ -1,83 +0,0 @@
This is SWIG, written and maintained by:
Dave Beazley (beazley@cs.uchicago.edu) (SWIG core)
Loic Dachary (loic@ceic.com) (Perl5)
Harco de Hilster (Harco.de.Hilster@ATComputing.nl) (Java)
Thien-Thi Nguyen (ttn@glug.org) (Testing/Misc)
Masaki Fukushima (fukusima@goto.info.waseda.ac.jp) (Ruby)
Matthias Koeppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile/MzScheme)
Past contributors:
Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran Kovuk, Gary Holt,
David Fletcher, Oleg Tolmatcev.
SWIG can be obtained by anonymous CVS:
cvs -d :pserver:cvs@swig.cs.uchicago.edu:/cvsroot co SWIG
SWIG is distributed under the following terms:
I.
Copyright (C) 1998-2000
The University of Chicago
Permission is hereby granted, without written agreement and without
license or royalty fees, to use, copy, modify, and distribute this
software and its documentation for any purpose, provided that
(1) The above copyright notice and the following two paragraphs
appear in all copies of the source code and (2) redistributions
including binaries reproduces these notices in the supporting
documentation. Substantial modifications to this software may be
copyrighted by their authors and need not follow the licensing terms
described here, provided that the new terms are clearly indicated in
all files where they apply.
IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CHICAGO, OR
DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS OR
ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
THE AUTHOR AND THE UNIVERSITY OF CHICAGO SPECIFICALLY DISCLAIM ANY
WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE AUTHORS AND
DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
II.
Copyright (c) 1995-1998
The University of Utah and the Regents of the University of California
All Rights Reserved
Permission is hereby granted, without written agreement and without
license or royalty fees, to use, copy, modify, and distribute this
software and its documentation for any purpose, provided that
(1) The above copyright notice and the following two paragraphs
appear in all copies of the source code and (2) redistributions
including binaries reproduces these notices in the supporting
documentation. Substantial modifications to this software may be
copyrighted by their authors and need not follow the licensing terms
described here, provided that the new terms are clearly indicated in
all files where they apply.
IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE
UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH
SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

4
debian/dirs vendored
View file

@ -1,4 +0,0 @@
usr/bin
usr/lib
#usr/share/swig1.3-pnet
#usr/share/doc/swig1.3-pnet

47
debian/docs vendored
View file

@ -1,47 +0,0 @@
README
TODO
ANNOUNCE
CHANGES
NEW
Doc/Devel/engineering.html
Doc/Devel/index.html
Doc/Devel/internals.html
Doc/Devel/migrate.txt
Doc/README
Doc/Manual/About.html
Doc/Manual/Advanced.html
Doc/Manual/Arguments.html
Doc/Manual/Chicken.html
Doc/Manual/Contents.html
Doc/Manual/Copyright.html
Doc/Manual/Customization.html
Doc/Manual/Documentation.html
Doc/Manual/Extending.html
Doc/Manual/Guile.html
Doc/Manual/Introduction.html
Doc/Manual/Java.html
Doc/Manual/Library.html
Doc/Manual/Ocaml.html
Doc/Manual/Perl5.html
Doc/Manual/Php.html
Doc/Manual/Preface.html
Doc/Manual/Preprocessor.html
Doc/Manual/Python.html
Doc/Manual/README
Doc/Manual/Ruby.html
Doc/Manual/SWIG.html
Doc/Manual/SWIGPlus.html
Doc/Manual/Scripting.html
Doc/Manual/Tcl.html
Doc/Manual/Typemaps.html
Doc/Manual/Varargs.html
Doc/Manual/Warnings.html
Doc/Manual/Windows.html
Doc/Manual/ch11.1.png
Doc/Manual/ch11.2.png
Doc/Manual/ch11.3.png
Doc/Manual/ch12.1.png
Doc/Manual/ch2.1.png
Doc/Manual/ch9.table.2.png
Doc/Manual/chapters
Doc/Manual/index.html

45
debian/postinst vendored
View file

@ -1,45 +0,0 @@
#! /bin/sh
# postinst script for swig1.3
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see /usr/share/doc/packaging-manual/
#
# quoting from the policy:
# Any necessary prompting should almost always be confined to the
# post-installation script, and should be protected with a conditional
# so that unnecessary prompting doesn't happen if a package's
# installation fails and the `postinst' is called with `abort-upgrade',
# `abort-remove' or `abort-deconfigure'.
case "$1" in
configure)
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 0
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

76
debian/rules vendored
View file

@ -1,76 +0,0 @@
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
# This is the debhelper compatability version to use.
export DH_COMPAT=3
configure: configure-stamp
configure-stamp:
dh_testdir
./autogen-debian.sh
./configure --prefix=/usr --mandir=/usr/share/man --with-swiglibdir=/usr/share/swig1.3 --program-suffix=-1.3
touch configure-stamp
build: configure-stamp build-stamp
build-stamp:
dh_testdir
$(MAKE)
$(MAKE) runtime
touch build-stamp
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
-$(MAKE) clean
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
$(MAKE) install DESTDIR=$(CURDIR)/debian/swig1.3
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
# dh_installdebconf
dh_installdocs
dh_installexamples
dh_installmenu
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_installinit
# dh_installcron
dh_installman
dh_installinfo
dh_undocumented swig-1.3.1
# dh_installchangelogs CHANGES
dh_link
dh_strip
dh_compress
dh_fixperms
dh_makeshlibs
dh_installdeb
# dh_perl
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

1
debian/substvars vendored
View file

@ -1 +0,0 @@
shlibs:Depends=libc6 (>= 2.2.3-1), libstdc++2.10-glibc2.2