Swig

Latest version: v4.2.1

Safety actively analyzes 638437 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 8 of 13

1.3.31

==================================

11/12/2006: Luigi Ballabio
[Python] Alternate fix for Python exceptions bug 1578346 (the previous one broke Python
properties in modern classes)

11/12/2006: wsfulton
-fakeversion commandline option now generates the fake version into the generated wrappers
as well as displaying it when the -version commandline option is used.

14/11/2006: mgossage
[lua] update to typemap for object by value, to make it c89 compliant

1.3.30

==================================

11/12/2006: wsfulton
[java] Remove DetachCurrentThread patch from 08/11/2006 - it causes segfaults
on some systems.

11/12/2006: wsfulton
[python] Fix 1578346 - Python exceptions with -modern

11/10/2006: wsfulton
Fix 1593291 - Smart pointers and inheriting from templates

11/09/2006: wsfulton
Fix director operator pointer/reference casts - 1592173.

11/07/2006: wsfulton
Add $self special variable for %extend methods. Please use this instead of just 'self'
as the C++ 'this' pointer.

11/07/2006: mutandiz
[allegrocl]
allegrocl.swg: swig-defvar updated to allow specifying of
non-default foreign type (via :ftype keyword arg).
allegrocl.cxx: Specify proper access type for enum values.

11/03/2006: wsfulton
[Java/C] Fix const std::string& return types for directors as reported by
Mark Donselzmann

10/29/2006: wsfulton
[Java] Remove DeleteLocalRef from end of director methods for now as it is causing a
seg fault when run on Solaris 8.

10/29/2006: wuzzeb (John Lenz)
[Guile] Patch from Chris Shoemaker to clean up some warnings in the generated code.

10/29/2006: wsfulton
[Java] Important fix to prevent early garbage collection of the Java proxy class
while it is being used in a native method. The finalizer could destroy the underlying
C++ object while it was being used. The problem occurs when the proxy class is no
longer strongly reachable after a native call. The problem seems to occur in
memory stress situations on some JVMs. It does not seem to occur on the
Sun client JVM up to jdk 1.5. However the 1.6 client jdk has a more aggressive garbage
collector and so the problem does occur. It does occur on the Sun server
JVMs (certainly 1.4 onwards). The fix entails passing the proxy class into the native
method in addition to the C++ pointer in the long parameter, as Java classes are not
collected when they are passed into JNI methods. The extra parameter can be suppressed
by setting the nopgcpp attribute in the jtype typemap to "1" or using the new -nopgcpp
commandline option.

See Java.htmljava_pgcpp for further details on this topic.

10/24/2006: wsfulton
[C] Fix smart pointer wrappers. The virtual/override/new keyword is not generated
for each method as the smart pointer class does not mirror the underlying pointer
class inheritance hierarchy. SF 1496535

10/24/2006: mgossage
[lua] added support for native methods & member function pointers.
fixed test cases arrays_dimensionless & cpp_basic. Added new example (functor).
tidied up a little of the code (around classHandler).

10/17/2006: wsfulton
[C, Java] directorout typemap changes to fall in line with the other director
languages. $result is now used where $1 used to be used. Please change your typemaps
if you have a custom directorout typemap.

10/18/2006: wsfulton
Some fixes for applying the char array typemaps to unsigned char arrays.

10/17/2006: wsfulton
[C, Java] Add in const size_t& and const std::size_t& typemaps.

10/15/2006: efuzzyone
[CFFI] Suppress generating defctype for enums, thanks to Arthur Smyles. Patch 1560983.

10/14/2006: wuzzeb (John Lenz)
[Chicken] Minor fix to make SWIG work with the (as yet unreleased) chicken 2.5

[Guile,Chicken] Fix SF Bug 1573892. Added an ext_test to the test suite to test
this bug, but this test can not really be made generic because the external code must
plug into the target language interpreter directly.
See Examples/test-suite/chicken/ext_test.i and ext_test_external.cxx

Added a %.externaltest to common.mk, and any interested language modules can
copy and slightly modify either the chicken or the guile ext_test.i

10/14/2006: mgossage
[Lua] added OUTPUT& for all number types, added a long long type
fixed several test cases.
update: changed typemaps to use SWIG_ConvertPtr rather than SWIG_MustGetPointer
started spliting lua.swg into smaller parts to make it neater

10/13/2006: wsfulton
[C, Java] Marginally better support for multiple inheritance only in that you can
control what the base class is. This is done using the new 'replace' attribute in the
javabase/csbase typemap, eg in the following, 'Me' will be the base class,
no matter what Foo is really derived from in the C++ layer.

%typemap(javabase, replace="1") Foo "Me"
%typemap(csbase, replace="1") Foo "Me"

Previously it was not possible for the javabase/csbase typemaps to override the C++ base.

10/12/2006: wsfulton
[Java] Remove potential race condition on the proxy class' delete() method
(it is now a synchronized method, but is now customisable by changing the
methodmodifiers attribute in the javadestruct or javadestruct_derived typemap)

[C] Remove potential race condition on the proxy class' Dispose() method,
similar to Java's delete() above.

*** POTENTIAL INCOMPATIBILITY ***

10/12/2006: wsfulton
[Ruby, Python] Remove redundant director code in %extend methods (%extend
methods cannot be director methods)

10/12/2006: wsfulton
[Ruby, Python] Fix 1505594 - director objects not returned as director objects
in %extend methods.

10/11/2006: wsfulton
[Java] Fix 1238798 - Directors using unsigned long long or any other type
marshalled across the JNI boundary using a Java class (where the jni typemap
contains jobject).

10/06/2006: wsfulton
Fix 1162194 - include/%include within a structure

10/06/2006: wsfulton
Fix 1450661, string truncation in String_seek truncating Java/C enums.

10/06/2006: mgossage
[Lua] Fix 1569587. The name is now correct.

10/04/2006: wsfulton
Director fixes for virtual conversion operators

10/04/2006: olly
[php] Fix 1569587 for PHP. Don't use sizeof() except with string
literals. Change some "//" comments to "/* */" for portability.

10/04/2006: mgossage
[Lua] Partial Fix 1569587. The type is now correct, but the name is still not correct.

10/03/2006: wsfulton
[Ruby] Fix 1527885 - Overloaded director virtual methods sometimes produced
uncompilable code when used with the director:except feature.

10/03/2006: wsfulton
Directors: Directors are output in the order in which they are declared in
the C++ class rather than in some pseudo-random order.

10/03/2006: mmatus
Fix 1486281 and 1471039.

10/03/2006: olly
[Perl] Fix for handling strings with zero bytes from Stephen Hutsal.

09/30/2006: efuzzyone
[CFFI] Bitfield support and vararg support due to Arthur Smyles.
C expression to Lisp conversion, thanks to Arthur Smyles for the initial
idea, it now supports conversion for a whole range of C expressions.

09/28/2006: wsfulton
Fix 1508327 - Overloaded methods are hidden when using -fvirtual optimisation.
Overloaded methods are no longer candidates for elimination - this mimics
C++ behaviour where all overloaded methods must be defined and implemented
in a derived class in order for them to be available.

09/25/2006: wsfulton
[Ruby, Python, Ocaml] Fix 1505591 Throwing exceptions in extended directors

09/25/2006: wsfulton
Fix 1056100 - virtual operators.

09/24/2006: olly
Don't accidentally create a "<:" token (which is the same as "[" in C++).
Fixes bug 1521788.

09/23/2006: olly
[Ruby] Support building with recent versions of the Ruby 1.9
development branch. Fixes bug 1560092.

09/23/2006: olly
Templates can now be instantiated using negative numbers and
constant expressions, e.g.:

template<int q> class x {};
%template(x_minus1) x<-1>;
%template(x_1plus2) x<1+2>;

Also, constant expressions can now include comparisons (>, <, >=,
<=, !=, ==), modulus (%), and ternary conditionals (a ? b : c).

Fixes bugs 646275, 925555, 956282, 994301.

09/22/2006: wsfulton
Fix %ignore on director methods - Bugs 1546254, 1543533

09/20/2006: wsfulton
Fix %ignore on director constructors

09/20/2006: wsfulton
Fix seg faults and asserts when director methods are ignored (1543533)

09/20/2006: wsfulton
Fix out of source builds - bug 1544718

09/20/2006: olly
Treat a nested class definition as a forward declaration rather
than ignoring it completely, so that we generate correct code for
passing opaque pointers to the nested class (fixes SF bug 909387).

09/20/2006: olly
*** POTENTIAL INCOMPATIBILITY ***
[php] Overload resolution now works. However to allow this, SWIG
generated wrappers no longer coerce PHP types (which reverts a change
made in 1.3.26). So for example, if a method takes a string, you
can no longer pass a number without explicitly converting it to a
string in PHP using: (string)x

09/18/2006: mgossage
[ALL] fix on swiginit.swg, has been reported to crash on several test cases
found and fixed problem in imports under python (mingw)

09/16/2006: wsfulton
[Python] Patch from Michal Marek for Python 2.5 to fix 64 bit array indexes on
64 bit machines.

09/13/2006: wsfulton
The explicitcall feature has been scrapped. This feature was introduced primarily
to solve recursive director method calls. Director upcall improvements made instead:

[Python, Ruby, Ocaml] The swig_up flag is no longer used. The required mutexes
wrapping this flag are also no longer needed. The recursive calls going from C++
to the target language and back again etc are now avoided by a subtlely different
approach. Instead of using the swig_up flag in each director method to indicate
whether the explicit C++ call to the appropriate base class method or a normal
polymorphic C++ call should be made, the new approach makes one of these calls
directly from the wrapper method.

[Java, C] The recursive call problem when calling a C++ base class method from
Java/C is now fixed. The implementation is slightly different to the other languages
as the detection as to whether the explicit call or a normal polymorphic call is made
in the Java/C layer rather than in the C++ layer.

09/11/2006: mgossage
[ALL] updated swiginit.swg to allow multiple interpreters to use multiple
swig modules at once. This has been tested in Lua (mingw & linux),
perl5 & python (linux) only.

09/11/2006: mgossage
[lua] added support for passing function pointers as well as native lua object
into wrappered function.
Added example funcptr3 to demonstrate this feature

09/05/2006: olly
[php] Rename ErrorCode and ErrorMsg define-s to SWIG_ErrorCode
and SWIG_ErrorMsg to avoid clashes with code the user might be
wrapping (patch from Darren Warner in SF bug 1466086). Any
user typemaps which use ErrorCode and/or ErrorMsg directly will
need adjusting - you can easily fix them to work with both old
and new SWIG by changing to use SWIG_ErrorMsg and adding:

ifndef SWIG_ErrorMsg
define SWIG_ErrorMsg() ErrorMsg()
endif

08/29/2006: olly
[php] Move constant initialisation from RINIT to MINIT to fix a
warning when using Apache and mod_php. We only need to create
PHP constants once when we're first initialised, not for every HTTP
request.

08/21/2006: mgossage
[Lua]
Bugfix 1542466 added code to allow mapping Lua nil's <-> C/C++ NULL's
updated various typemaps to work correctly with the changes
added voidtest_runme.lua to show the features working

08/19/2006: wuzzeb (John Lenz)
[Guile] Add feature:constasvar to export constants as variables instead of functions
that return the constant value.

08/11/2006: wsfulton
[Java] DetachCurrentThread calls have been added so that natively created threads
no longer prevent the JVM from exiting. Bug reported by Thomas Dudziak and
Paul Noll.

08/10/2006: wsfulton
[C] Fix director protected methods so they work

07/25/2006: mutandiz
[allegrocl]
more additions to std::string, some tweaks and small bug fixes
-nocwrap mode.

07/21/2006: mgossage
[Lua]
Bugfix 1526022 pdated std::string to support strings with '\0' inside them
updated typemaps.i to add support for pointer to pointers

07/19/2006: mutandiz
[allegrocl]
- Add std_string.i support.
- Add newobject patch submitted by mkoeppe (thanks!)
- Fix type name mismatch issue for nested type definitions.
specifically typedefs in templated class defns.

07/18/2006: mgossage
Bugfix 1522858
updated lua.cxx to support -external-runtime command

07/14/2006: wuzzeb (John Lenz)
Increment the SWIG_RUNTIME_VERSION to 3, because of the
addition of the owndata member in swig_type_info.
Reported by: Prabhu Ramachandran

07/05/2006: wsfulton
Search path fixes:
- Fix search path for library files to behave as documented in Library.html.
- Fix mingw/msys builds which did not find the SWIG library when installed.
- Windows builds also output the mingw/msys install location when running
swig -swiglib.
- The non-existent and undocumented config directory in the search path has
been removed.

07/05/2006: wsfulton
Fix $symname special variable expansion.

07/04/2006: wuzzeb (John Lenz)
[Chicken]
Add %feature("constasvar"), which instead of exporting a constant as a
scheme function, exports the constant as a scheme variable. Update the
documentation as well.

07/04/2006: wsfulton
[See entry of 09/13/2006 - explicitcall feature and documentation to it removed]
New explicitcall feature which generates additional wrappers for virtual methods
that call the method explicitly, not relying on polymorphism to make the method
call. The feature is a feature flag and is enabled like any other feature flag.
It also recognises an attribute, "suffix" for mangling the feature name, see
SWIGPlus.htmlSWIGPlus_explicitcall documentation for more details.

[Java, C]
The explicitcall feature is also a workaround for solving the recursive calls
problem when a director method makes a call to a base class method. See
Java.htmljava_directors_explicitcall for updated documentation.

06/28/2006: joe (Joseph Wang)
[r] Initial support for R

06/20/2006: wuzzeb (John Lenz)
[Chicken]
Minor fixes to get apply_strings.i testsuite to pass
Remove integers_runme.scm from the testsuite, because SWIG and Chicken does
handle overflows.

06/19/2005: olly
[php] Add support for generating PHP5 class wrappers for C++
classes (use "swig -php5").

06/17/2006: olly
[php] Added some missing keywords to the PHP4 keyword list, and
fixed __LINE__ and __FILE__ which were in the wrong category.
Also added all the keywords new in PHP5, and added comments
noting the PHP4 keywords which aren't keywords in PHP5.

06/17/2006: olly
[php] Don't segfault if PHP Null is passed as this pointer (e.g.
Class_method(Null)) - give a PHP Error instead.

06/15/2006: mutandiz
[allegrocl]
Add initial support for std::list container class.
Fix a few bugs in helper functions.

05/13/2006: wsfulton
[Java] Replace JNIEXPORT with SWIGEXPORT, thereby enabling the possibility
of using gcc -fvisibility=hidden for potentially smaller faster loading wrappers.

05/13/2006: wsfulton
Fix for Makefiles for autoconf-2.60 beta

05/13/2006: wsfulton
Vladimir Menshakov patch for compiling wrappers with python-2.5 alpha.

05/12/2006: wsfulton
Fix buffer overflow error when using large %feature(docstring) reported
by Joseph Winston.

05/12/2006: wsfulton
[Perl] Operator overload fix from Daniel Moore.

05/25/2006: mutandiz
[allegrocl]
Fix bug in generation of CLOS type declarations for unions
and equivalent types.

05/24/2006: mutandiz
[allegrocl]
Don't require a full class definition to generate a CLOS wrapper.

05/20/2006: olly
[php] GCC Visibility support now works with PHP.

05/19/2006: olly
[php] Removed support for -dlname (use -module instead). Fixed
naming of PHP extension module to be consistent with PHP
conventions (no "php_" prefix on Unix; on PHP >= 4.3.0, handle Unix
platforms which use something other than ".so" as the extension.)

05/13/2006: wsfulton
[C] Director support added

05/07/2006: olly
[php] Don't segfault if PHP Null is passed where a C++ reference
is wanted.

05/05/2006: olly
[php] Fix wrappers generated for global 'char' variables to not
include a terminating zero byte in the PHP string.

05/03/2006: wsfulton
Modify typemaps so that char * can be applied to unsigned char * or signed char *
types and visa versa.

05/03/2006: efuzzyone
[cffi]Thanks to Luke J Crook for this idea.
- a struct/enum/union is replaced with :pointer only if
that slot is actually a pointer to that type. So,:
struct a_struct { int x; } and
struct b_struct { a_struct struct_1; };
will be converted as:
(cffi:defcstruct b_struct
(struct_1 a_struct))
- Other minor fixes in lispifying names.

05/02/2006: wsfulton
Fix possible redefinition of _CRT_SECURE_NO_DEPRECATE for VC++.

04/14/2006: efuzzyone
[cffi]
Thanks to Thomas Weidner for the patch.
- when feature export is set (export 'foo) is
generated for every symbol
- when feature inline is set (declaim (inline foo)) is
generated before every function definition
- when feature intern_function is set
.(value-of-intern-function "name" "nodeType" package)
is emitted instead of the plain symbol. A sample swig-lispify
is provided.
- every symbol is prefixed by it's package.

04/13/2006: efuzzyone
[cffi]
Fixed the generation of wrappers for global variables.
Added the option [no]swig-lisp which turns on/off generation
of code for swig helper lisp macro, functions, etc.

1.3.29

===============================

04/05/2006: mutandiz
[allegrocl]
Fix output typemap of char so it produces a character instead
of an integer. Also adds input/output typemaps for 'char *'.

add command-line argument -isolate to generate an interface
file that won't interfere with other SWIG generated files that
may be used in the same application.

03/20/2005: mutandiz
[allegrocl]
More tweaks to INPUT/OUTPUT typemaps for bool.

Fix constantWrapper for char and string literals.

find-definition keybindings should work in ELI/SLIME.
Output (in-package <module-name>) to lisp wrapper
instead of (in-package .*swig-module-name*).

slight rework of multiple return values.

doc updates.

03/17/2005: mutandiz
[allegrocl]
mangle names of constants generated via constantWrapper.

When using OUTPUT typemaps and the function has a non-void
return value, it should be first in the values-list, followed
by the OUTPUT mapped values.

Fix bug with boolean parameters, which needed to be
passed in as int values, rather than T or NIL.

03/15/2006: mutandiz
[allegrocl]
Generate wrappers for constants when in C++ or -cwrap mode.
Make -cwrap the default, since it is most correct. Users
can use the -nocwrap option to avoid the creation of a .cxx
file when interfacing to C code.

When in -nocwrap mode, improve the handling of converting
infix literals to prefix notation for lisp. This is very
basic and not likely to be improved upon since this only
applies to the -nocwrap case. Literals we can't figure out
will result in a warning and be included in the generated
code.

validIdentifier now more closely approximates what may be
a legal common lisp symbol.

Fix typemap error in allegrocl.swg

03/12/2006: mutandiz
[allegrocl]
fix up INPUT/OUTPUT typemaps for bool.
Generate c++ style wrapper functions for struct/union members
when -cwrap option specified.

03/10/2006: mutandiz
[allegrocl]
Fix bug in C wrapper generation introduced by last allegrocl
commit.

03/10/2006: wsfulton
[Java]
Commit 1447337 - Delete LocalRefs at the end of director methods to fix potential leak

03/10/2006: wsfulton
Fix 1444949 - configure does not honor --program-prefix.
Removed non-standard configure option --with-release-suffix. Fix the autoconf standard
options --program-prefix and --program-suffix which were being shown in the help,
but were being ignored. Use --program-suffix instead of --with-release-suffix now.

03/10/2006: wsfulton
[Java]
Fix 1446319 with patch from andreasth - more than one wstring parameter in director methods

03/07/2006: mkoeppe
[Guile]
Fix for module names containing a "-" in non-"shadow" mode.
Patch from Aaron VanDevender (1441474).

03/04/2006: mmatus
- Add -O to the main program, which now enables -fastdispatch

[Python]

- Add the -fastinit option to enable faster __init__
methods. Setting 'this' as 'self.this.append(this)' in the python
code confuses PyLucene. Now the initialization is done in the
the C++ side, as reported by Andi and Robin.

- Add the -fastquery option to enable faster SWIG_TypeQuery via a
python dict cache, as proposed by Andi Vajda

- Avoid to call PyObject_GetAttr inside SWIG_Python_GetSwigThis,
since this confuses PyLucene, as reported by Andi Vajda.

03/02/2006: wsfulton
[Java]
Removed extra (void *) cast when casting pointers to and from jlong as this
was suppressing gcc's "dereferencing type-punned pointer will break strict-aliasing rules"
warning. This warning could be ignored in versions of gcc prior to 4.0, but now the
warning is useful as gcc -O2 and higher optimisation levels includes -fstrict-aliasing which
generates code that doesn't work with these casts. The assignment is simply never made.
Please use -fno-strict-aliasing to both suppress the warning and fix the bad assembly
code generated. Note that the warning is only generated by the C compiler, but not
the C++ compiler, yet the C++ compiler will also generate broken code. Alternatively use
-Wno-strict-aliasing to suppress the warning for gcc-3.x. The typemaps affected
are the "in" and "out" typemaps in java.swg and arrays_java.swg. Users ought to fix
their own typemaps to do the same. Note that removal of the void * cast simply prevents
suppression of the warning for the C compiler and nothing else. Typical change:

From:
%typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)(void *)&$input; %}
To:
%typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %}

From:
%typemap(out) SWIGTYPE * %{ *($&1_ltype)(void *)&$result = $1; %}
To:
%typemap(out) SWIGTYPE * %{ *($&1_ltype)&$result = $1; %}

03/02/2006: mkoeppe
[Guile -scm]
Add typemaps for "long long"; whether the generated code compiles, however, depends
on the version and configuration of Guile.

03/02/2006: wsfulton
[C]
Add support for inner exceptions. If any of the delegates are called which construct
a pending exception and there is already a pending exception, it will create the new
exception with the pending exception as an inner exception.

03/02/2006: wsfulton
[Php]
Added support for Php5 exceptions if compiling against Php5 (patch from Olly Betts).

03/01/2006: mmatus
Use the GCC visibility attribute in SWIGEXPORT.

Now you can compile (with gcc 3.4 or later) using
CFLAGS="-fvisibility=hidden".

Check the difference for the 'std_containers.i' python
test case:

Sizes:

3305432 _std_containers.so
2383992 _std_containers.so.hidden

Exported symbols (nm -D <file>.so | wc -l):

6146 _std_containers.so
174 _std_containers.so.hidden

Execution times:

real 0m0.050s user 0m0.039s sys 0m0.005s _std_containers.so
real 0m0.039s user 0m0.026s sys 0m0.007s _std_containers.so.hidden

Read http://gcc.gnu.org/wiki/Visibility for more details.


02/27/2006: mutandiz
[allegrocl]
Add support for INPUT, OUTPUT, and INOUT typemaps.
For OUTPUT variables, the lisp wrapper returns multiple
values.

02/26/2006: mmatus

[Ruby] add argcargv.i library file.

Use it as follow:

%include argcargv.i

%apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) }

%inline {
int mainApp(size_t argc, const char **argv)
{
return argc;
}
}

then in the ruby side:

args = ["asdf", "asdf2"]
n = mainApp(args);


This is the similar to the python version Lib/python/argcargv.i

02/24/2006: mgossage

Small update Lua documents on troubleshooting problems

02/22/2006: mmatus

Fix all the errors reported for 1.3.28.
- fix bug 1158178
- fix bug 1060789
- fix bug 1263457
- fix 'const char*&' typemap in the UTL, reported by Geoff Hutchison
- fixes for python 2.1 and the runtime library
- fix copyctor + template bug 1432125
- fix [ 1432152 ] %rename friend operators in namespace
- fix gcc warning reported by R. Bernstein
- avoid assert when finding a recursive scope inheritance,
emit a warning in the worst case, reported by Nitro
- fix premature object deletion reported by Paul in tcl3d
- fix warning reported by Nitro in VC7
- more fixes for old Solaris compiler
- fix for python 2.3 and gc_refs issue reported by Luigi
- fix fastproxy for methods using kwargs
- fix overload + protected member issue reported by Colin McDonald
- fix seterrormsg as reported by Colin McDonald
- fix directors, now the test-suite runs again using -directors
- fix for friend operator and Visual studio and bug 1432152
- fix bug 1435090
- fix using + %extend as reported by William
- fix bug 1094964
- fix for Py_NotImplemented as reported by Olly and Amaury
- fix nested namespace issue reported by Charlie

and also:

- allow director protected members by default
- delete extra new lines in swigmacros[UTL]
- cosmetic for generated python code
- add the factory.i library for UTL
- add swigregister proxy method and move __repr__ to a
single global module [python]

02/22/2006: mmatus

When using directors, now swig will emit all the virtual
protected methods by default.

In previous releases, you needed to use the 'dirprot'
option to achieve the same.

If you want, you can disable the new default behaviour,
use the 'nodirprot' option:

swig -nodirprot ...

and/or the %nodirector feature for specific methods, i.e.:

%nodirector Foo::bar;

struct Foo {
virtual ~Foo();

protected:
virtual void bar();
};


As before, pure abstract protected members are allways
emitted, independent of the 'dirprot/nodirprot' options.


02/22/2006: mmatus
Add the factory.i library for languages using the UTL (python,tcl,ruby,perl).

factory.i implements a more natural wrap for factory methods.

For example, if you have:

---- geometry.h --------
struct Geometry {
enum GeomType{
POINT,
CIRCLE
};

virtual ~Geometry() {}
virtual int draw() = 0;

//
// Factory method for all the Geometry objects
//
static Geometry *create(GeomType i);
};

struct Point : Geometry {
int draw() { return 1; }
double width() { return 1.0; }
};

struct Circle : Geometry {
int draw() { return 2; }
double radius() { return 1.5; }
};

//
// Factory method for all the Geometry objects
//
Geometry *Geometry::create(GeomType type) {
switch (type) {
case POINT: return new Point();
case CIRCLE: return new Circle();
default: return 0;
}
}
---- geometry.h --------


You can use the %factory with the Geometry::create method as follows:

%newobject Geometry::create;
%factory(Geometry *Geometry::create, Point, Circle);
%include "geometry.h"

and Geometry::create will return a 'Point' or 'Circle' instance
instead of the plain 'Geometry' type. For example, in python:

circle = Geometry.create(Geometry.CIRCLE)
r = circle.radius()

where 'circle' now is a Circle proxy instance.


02/17/2006: mkoeppe
[MzScheme] Typemaps for all integral types now accept the full range of integral
values, and they signal an error when a value outside the valid range is passed.
[Guile] Typemaps for all integral types now signal an error when a value outside
the valid range is passed.

02/13/2006: mgossage
[Documents] updated the extending documents to give a skeleton swigging code
with a few typemaps.
[Lua] added an extra typemap for void* [in], so a function which requires a void*
can take any kind of pointer

1.3.28

==================================

02/11/2006: mmatus
Fix many issues with line counting and error reports.

02/11/2006: mmatus
[Python] Better static data member support, if you have

struct Foo {
static int bar;
};

then now is valid to access the static data member, ie:

f = Foo()
f.bar = 3

just as in C++.


02/11/2006: wsfulton
[Perl]
Fixed code generation to work again with old versions of Perl
(5.004 and later tested)

02/04/2006: mmatus
[Python] Add the %extend_smart_pointer() directive to extend
SWIG smart pointer support in python.

For example, if you have a smart pointer as:

template <class Type> class RCPtr {
public:
...
RCPtr(Type *p);
Type * operator->() const;
...
};

you use the %extend_smart_pointer directive as:

%extend_smart_pointer(RCPtr<A>);
%template(RCPtr_A) RCPtr<A>;

then, if you have something like:

RCPtr<A> make_ptr();
int foo(A *);

you can do the following:

a = make_ptr();
b = foo(a);

ie, swig will accept a RCPtr<A> object where a 'A *' is
expected.

Also, when using vectors

%extend_smart_pointer(RCPtr<A>);
%template(RCPtr_A) RCPtr<A>;
%template(vector_A) std::vector<RCPtr<A> >;

you can type

a = A();
v = vector_A(2)
v[0] = a

ie, an 'A *' object is accepted, via implicit conversion,
where a RCPtr<A> object is expected. Additionally

x = v[0]

returns (and sets 'x' as) a copy of v[0], making reference
counting possible and consistent.

%extend_smart_pointer is just a collections of new/old
tricks, including %typemaps and the new %implicitconv
directive.

02/02/2006: mgossage
bugfix 1356577, changed double=>lua_number in a few places.
added the std::pair wrapping

01/30/2006: wsfulton
std::string and std::wstring member variables and global variables now use
%naturalvar by default, meaning they will now be wrapped as expected in all languages.
Previously these were wrapped as a pointer rather than a target language string.
It is no longer necessary to add the following workaround to wrap these as strings:

%apply const std::string & { std::string *}

*** POTENTIAL INCOMPATIBILITY ***

01/28/2006: mkoeppe
[Guile -scm]
Add typemaps for handling of member function pointers.

01/24/2006: mmatus
- Better support for the %naturalvar directive, now it
works with the scripting languages as well as
Java/C.

Now, it can also be applied to class types:

%naturalvar std::string;
%include <std_string.i>

that will tell swig to use the 'natural' wrapping
mechanism to all std::string global and member
variables.

- Add support for the %allowexcept feature along the
scripting languages, which allows the %exception feature
to be applied to the variable access methods. Also, add
the %exceptionvar directive to specify a distintic
exception mechanism only for variables.


- Add more docs for the %delobject directive to mark a method as a
destructor, 'disowning' the first argument. For example:

%newobject create_foo;
%delobject destroy_foo;

Foo *create_foo() { return new Foo(); }
void destroy_foo(Foo *foo) { delete foo; }

or in a member method as:

%delobject Foo::destroy;

class Foo {
public:
void destroy() { delete this;}

private:
~Foo();
};


01/24/2006: mgossage
[Lua]
- Removed the type swig_lua_command_info & replace with luaL_reg
(which then broke the code), fixed this
- added an additional cast in the typemaps for enum's
due to the issue that VC.Net will not allow casting of
a double to an enum directly. Therefore cast to int then to enum
(thanks to Jason Rego for this observation)

01/16/2006: mmatus (Change disabled... will be back in CVS soon)
Add initial support for regexp via the external library
RxSpencer. SWIG doesn't require this library to compile
and/or run. But if you specify --with-rxspencer, and the
library is found during installation, then swig will use
it in three places:

- In %renames rules, via the new rxsmatch rules, for example:

%rename("%(lowercase)",rxsmatch$name="GSL_.*") "";
%rename("%(lowercase)",rxsmatch$nodeType="enum GSL_.*") "";

rxsmatch is similar to the match rule, it just uses
the RxSpencer regexp library to decide if there is a
match with the provided regexp. As with the match
rule, you can also use the negate rule notrxsmatch.

- In the %rename target name via the rxstarget option, for example:

%rename("%(lowercase)",rxstarget=1) "GSL_.*";

where the target name "GSL.*" is now understood as a
regexp to be matched.

- In the new encoder "rxspencer", which looks like:

%(rxspencer:[regexp][replace])s

where "regexp" is the regular expression and "replace"
is a string used as a replacement, where the 0,1,...,9
pseudo arguments are used to represent the
corresponding matching items in the reg expression.

For example:

%(rxspencer:[GSL.*][0])s <- Hello ->
%(rxspencer:[GSL.*][0])s <- GSLHello -> GSLHello
%(rxspencer:[GSL(.*)][1])s <- GSLHello -> Hello
%(rxspencer:[GSL(.*)][gsl1])s <- GSLHello -> gslHello

Another example could be:

%rename("%(lowercase)s",sourcefmt="%(rxspencer:[GSL_(.*)][1])s",%$isfunction) "";

which take out the prefix "GSL_" and returns all the
function names in lower cases, as following:

void GSL_Hello(); -> hello();
void GSL_Hi(); -> hi();
const int GSL_MAX; -> GSL_MAX; // no change, is not a function

We use the RxSpencer as an initial test bed to
implemention while we decide which library will be
finally added to swig.

You can obtain the RxSpencer library from

http://arglist.com/regex (Unix)

or

http://gnuwin32.sourceforge.net/packages.html (Windows)

Once installed, use "man rxspencer" to get more info
about the regexp format, or just google rxspencer.

Since now you can enable the rxsmatch rules (see above),
the simple or '|' support for the match rules
(01/12/2006: mmatus) is disabled. Still, if you have
problems with the rxspencer library, you can re-enable
the simple 'match or' support using
-DSWIG_USE_SIMPLE_MATCHOR.


01/16/2006: mmatus
Change the %rename predicates to use the prefix '%$', as in:

%rename("%(utitle)s",%$isfunction,%$ismember) "";

to avoid clashes with other swig macros/directives.

01/14/2006: cfisavage
[Ruby]
Added support for Ruby bang! methods via a new %bang feature.
Bang methods end in exclamation points and indicate that the
object being processed will be modified in-place as
opposed to being copied.

01/12/2006: cfisavage
[Ruby]
Updated the Ruby module to automatically convert
method names to lower_case_with_underscores using the
new %rename functionality.

01/12/2006: mmatus
- Add aliases for 'case' encoders used with %rename/%namewarn

%(uppercase)s hello_world -> HELLO_WORLD
%(lowercase)s HelloWorld -> helloworld
%(camelcase)s hello_world -> HelloWorld
%(undercase)s HelloWorld -> hello_world


01/12/2006: mmatus
- Add the -dump_parse_module and -dump_parse_top options,
which are similar to -dump_module and -dump_top, but they
dump the node trees just after parsing, showing only the
attributes visible at the parsing stage, and not the added
later in typemap.cxx, allocate.cxx, lang.cxx or elsewhere.

Besides debugging porpuses, these options are very useful
if you plan to use %rename in an "advance way", since it
shows only and all the node's attributes you can use
inside the match rules.


01/12/2006: mmatus
- Add predicates to %rename, so, you don't need to
remember, for example, how to match a member function.

Now it is easy, for example to use the 'utitle' encoder
in all the member methods, you type:

%rename("%(utitle)s",%isfunction,%ismember) "";

or to ignore all the enumitems in a given class:

%rename("$ignore", %isenumitem, %classname="MyClass") "";

Available predicates are (see swig.swg):

%isenum
%isenumitem
%isaccess
%isclass
%isextend
%isextend
%isconstructor
%isdestructor
%isnamespace
%istemplate
%isconstant

%isunion
%isfunction
%isvariable
%isimmutable

%isstatic
%isfriend
%istypedef
%isvirtual
%isexplicit
%isextern

%ismember
%isglobal
%innamespace

%ispublic
%isprotected
%isprivate

%classname

These predicates correspond to specific 'match'
declarations, which sometimes are not as evident as the
predicates names.


- Add the or '|' operation in %rename match, for
example to capitalize all the constants (%constant or
const cdecl):

%rename("%(upper)s",match="cdecl|constant",%isimmutable) "";



01/12/2006: mgossage
- Partial fixed of errors under C89, bug 1356574
(converted C++ style comments to C style)
- Added patches from neomantrausers.sf.net 1379988 and 1388343
missing a 'return' statement for error conditions
also updated the %init block bug 1356586

01/10/2006: mmatus
- Add the 'utitle' encoder, as an example of how to add
your own encoder. I added the encoder method in misc.c
but developers can add others, the same way, inside any
target language.

Well, 'utitle' is the reverse of 'ctitle', ie:

%rename("%(ctitle)s") camel_case; -> CamelCase;
%rename("%(utitle)s") CamelCase; -> camel_case;


01/10/2006: cfisavage
[Ruby]
Updated Ruby Exception handling. Classes that are specified in throws clauses,
or are marked as %exceptionclass, are now inherited from rb_eRuntimeError.
This allows instances of these classes to be returned to Ruby as exceptions.
Thus if a C++ method throws an instance of MyException, the calling Ruby
method will get back a MyException object. To see an example,
look at ruby/examples/exception_class.

01/10/2006: mmatus

- Add the %catches directive, which complements the %exception
directive in a more automatic way. For example, if you have

int foo() throw(E1);

swig generates the proper try/catch code to dispatch E1.

But if you have:


int barfoo(int i) {
if (i == 1) {
throw E1();
} else {
throw E2();
}
return 0;
}

ie, where there is no explicit exception specification in the decl, you
end up doing:

%exception barfoo {
try {
$action
} catch(E1) { ... }
} catch(E2) { ... }
}

which is very tedious. Well, the %catches directive defines
the list of exceptions to catch, and from swig:

%catches(E1,E2) barfoo(int i);
int barfoo(int i);

is equivalent to

int barfoo(int i) throw(E1,E2);

Note, however, that the %catches list doesn't have to
correspond to the C++ exception specification. For example, if you
have:

struct E {};
struct E1 : E {};
struct E2 : E {};

int barfoo(int i) throw(E1,E2);

you can define

%catches(E) barfoo(int i);

and swig will generate an action code equivalent to

try {
$action
} catch(E &_e) {
<raise _e>;
}

Of course, you still have to satisfy the C++ restrictions,
and the catches list must be compatible (not the same)
as the original list of types in the exception specification.

Also, you can now specify that you want to catch the
unknown exception '...', for example:

%catches(E1,E2,...) barfoo(int);

In any case, the %catches directive will emit the
code to convert into the target language error/exception
using the 'throws' typemap.

For the '...' case to work, you need to
write the proper typemap in your target language. In the
UTL, this looks like:

%typemap(throws) (...) {
SWIG_exception(SWIG_RuntimeError,"unknown exception");
}

01/09/2006: mutandiz
[Allegrocl]

Fixes a number of SEGVs primarily in the handling of
various anonymous types. Found in a pass through the
swig test-suite. Still more to do here, but this is a
good checkpoint.

Adds -cwrap and -nocwrap as an allegrocl specific
command-line argument. Controls generating of a C
wrapper file when wrapping C code. By default only a
lisp file is created for C code wrapping.

Doc updates for the command-line arguments and fixes as
pointed out on swig-devel

01/05/2006: wsfulton
[Java] Fix unsigned long long and const unsigned long long & typemaps
- Bug 1398394 with patch from Dries Decock

01/06/2006: mmatus
Add 'named' warning codes, now in addition to:

%warnfilter(813);

you can use

%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE);

just use the same code name found in Source/Include/swigwarn.h
plus the 'SWIG' prefix.

If a developer adds a new warning code, the Lib/swigwarn.swg file
will be generated when running the top level make.

01/05/2006: cfisavage
[Ruby]
Reimplemented object tracking for Ruby. The new implementation works
by expanding the swig_class structure for Ruby by adding a trackObjects
field. This field can be set/unset via %trackobjects as explained
in the Ruby documentation. The new implementation is more robust
and takes less code to implement.

01/05/2006: wsfulton
Fix for %extend and static const integral types, eg:

class Foo {
public:
%extend {
static const int bar = 42;
}
};

12/30/2005: mmatus

- Add info for old and new debug options:

-dump_top - Print information of the entire node tree, including system nodes
-dump_module - Print information of the module node tree, avoiding system nodes
-dump_classes - Print information about the classes found in the interface
-dump_typedef - Print information about the types and typedefs found in the interface
-dump_tags - Print information about the tags found in the interface
-debug_typemap - Print information for debugging typemaps
-debug_template - Print information for debugging templates

- Add the fakeversion. If you have a project that uses
configure/setup.py, or another automatic building system
and requires a specific swig version, let say 1.3.22
you can use:

SWIG_FEATURES="-fakeversion 1.3.22"

or

swig -fakeversion 1.3.22

and then swig -version will report 1.3.22 instead of the
current version.

Typical use would be

SWIG_FEATURES="-fakeversion 1.3.22" ./configure

12/30/2005: mmatus

- Add option/format support to %rename and %namewarn.
Now %namewarn can force renaming, for example:

%namewarn("314: import is a keyword",rename="_%s") "import";

and rename can also support format forms:

%rename("swig_%s") import;

Now, since the format is processed via swig Printf, you
can use encoders as follows:

%rename("%(title)s") import; -> Import
%rename("%(upper)s") import; -> IMPORT
%rename("%(lower)s") Import; -> import
%rename("%(ctitle)s") camel_case; -> CamelCase

This will allow us to add more encoders, as the
expected one for regular expressions.

- Add the above 'ctitle' encoder, which does the camel case:

camel_case -> CamelCase

- Also, while we get the regexp support, add the 'command' encoder,
you can use it as follows

%rename("%(command:sed -e 's/\([a-z]\)/\U\\1/' <<< )s") import;

then swig will popen the command

"sed -e 's/\([a-z]\)/\U\\1/' <<< import"

see below for anonymous renames for better examples.

- The rename directive now also allows:

- simple match: only apply the rename if a type match
happen, for example

%rename(%(title)s,match="enumitem") hello;

enum Hello {
hi, hello -> hi, Hello
};
int hello() -> hello;

- extended match: only apply the rename if the 'extended attribute' match
occurred, for example:

// same as simple match
%rename(%(title)s,match$nodeType="enumitem") hello;

enum Hello {
hi, hello -> hi, Hello
};

Note that the symbol '$' is used to define the attribute name in
a 'recursive' way, for example:

// match only hello in 'enum Hello'
%rename(%(title)s,match$parentNode$type="enum Hello") hello;

enum Hello {
hi, hello -> hi, Hello // match
};

enum Hi {
hi, hello -> hi, hello // no match
};

here, for Hello::hi, the "parentNode" is "Hello", and its "type"
is "enum Hello".


- Anonymous renames: you can use 'anonymous' rename directives, for example:

// rename all the enum items in Hello
%rename(%(title)s,match$parentNode$type="enum Hello") "";

enum Hello {
hi, hello -> Hi, Hello // match both
};

enum Hi {
hi, hello -> hi, hello // no match
};

// rename all the enum items
%rename(%(title)s,match$nodeType="enumitem") "";

// rename all the items in given command (sloooow, but...)
%rename(%(command:<my external cmd>)s) "";


Anonymous renames with commands can be very powerful, since you
can 'outsource' all the renaming mechanism (or part of it) to an
external program:

// Uppercase all (and only) the names that start with 'i'
%rename("%(command:awk '/^i/{print toupper($1)}' <<<)s") "";

int imported() -> IMPORTED;
int hello() -> hello

Note that if the 'command' encoder returns an empty string, swig
understands that no rename is necessary.

Also note that %rename 'passes' the matched name. For example, in
this case

namespace ns1 {
int foo();
}

namespace ns2 {
int bar();
}

the external program only receives "foo" and "bar". If needed,
however, you can request the 'fullname'

%rename("%(command:awk 'awk '/ns1::/{l=split($1,a,"::"); print toupper(a[l])}'' <<<)s",fullname=1) "";

ns1::foo -> FOO
ns2::bar -> bar

- Mixing encoders and matching: of course, you can do mix commands
and match fields, for example:

%rename("%(<my encoder for fncs>)",match="cdecl") "";
%rename("%(<my encoder for enums>)",match="enumitem") "";
%rename("%(<my encoder for enums inside a class>)",match="enumitem",
match$parentNode$parentNode$nodeType="class") "";

Use "swig -dump_parse_module" to see the attribute names you can use to
match a specific case.

- 'sourcefmt' and 'targetfmt': sometimes you need to
process the 'source' name before comparing, for example

%namewarn("314: empty is a keyword",sourcefmt="%(lower)s") "empty";

then if you have

int Empty(); // "Empty" is the source

you will get the keyword warning since 'Empty' will be
lower cased, via the sourcefmt="%(lower)s" option,
before been compared to the 'target' "empty".

There is an additional 'targetfmt' option to process the
'target' before comparing.

- complementing 'match': you can use 'notmatch', for example

%namewarn("314: empty is a keyword",sourcefmt="%(lower)s",notmatch="namespace") "empty";

here, the name warning will be applied to all the symbols except namespaces.


12/30/2005: mmatus

- Add initial support for gcj and Java -> <target language> mechanism.

See examples in:

Examples/python/java
Examples/ruby/java
Examples/tcl/java

to see how to use gcj+swig to export java classes into
python/ruby/tcl.

The idea is to put all the common code for gcj inside

Lib/gcj

and localize specific types such as jstring, as can be found
in

Lib/python/jstring.i
Lib/ruby/jstring.i
Lib/tcl/jstring.i

Using the UTL, this is very easy, and the perl version for
jstring.i will be next.


12/29/2005: mmatus
- Add the copyctor feature/directive/option to enable the automatic
generation of copy constructors. Use as in:

%copyctor A;

struct A {

};

then this will work

a1 = A();
a2 = A(a1);

Also, since it is a feature, if you just type

%copyctor;

that will enable the automatic generation for all the
classes. It is also equivalent to

swig -copyctor -c++ ...

Notes:

1.- The feature only works in C++ mode.

2.- The automatic creation of the copy constructor will
usually produce overloading. Hence, if the target
language doesn't support overloading, a special name
will be used (A_copy).

3.- For the overloading reasons above, it is probably not
a good idea to use the flag when, for example, you are
using keywords in Python.

4.- The copyctor automatic mechanism follows more or less
the same rules as the default constructor mechanism,
i.e., a copy constructor will not be added if the
class is abstract or if there is a pertinent non-public
copy ctor in the class or its hierarchy.

Hence, it might be necessary for you to complete the
class declaration with the proper non-public copy ctor
to avoid a wrong constructor addition.

- Fix features/rename for templates ctor/dtor and other
things around while adding the copyctor mechanism.


12/27/2005: mmatus
- Add the 'match' option to typemaps. Assume you have:

%typemap(in) SWIGTYPE * (int res) {..}
%typemap(freearg) SWIGTYPE * { if (res$argnum) ...}

then if you do

%typemap(in) A * {...}

swig will 'overload the 'in' typemap, but the 'freearg'
typemap will be also applied, even when this is wrong. The old
solutions is to write:

%typemap(in) A * {...}
%typemap(freeag) A * ""

overload 'freearg' with an empty definition.

The problem is, however, there is no way to know you need
to do that until you start getting broken C++ code, or
worse, broken runtime code.

The same applies to the infamous 'typecheck' typemap,
which always confuses people, since the first thing you do
is to just write the 'in' typemap.

The 'match' option solves the problem, and if instead you write:

%typemap(in) SWIGTYPE * (int res) {..}
%typemap(freearg,match="in") SWIGTYPE * { if (res$argnum) ...}
%typemap(typecheck,match="in",precedence...) SWIGTYPE * {...}

it will tell swig to apply the 'freearg/typecheck'
typemaps only if they 'match' the type of the 'in'
typemap. The same can be done with other typemaps as:

%typemap(directorout) SWIGTYPE * {...}
%typemap(directorfree,match="directorout") SWIGTYPE * {...}


12/27/2005: mmatus
- Add the 'naturalvar' option/mode/feature to treat member
variables in a more natural way, ie, similar to the global
variable behavior.

You can use it in a global way via the command line

swig -naturalvar ...

or the module mode option

%module(naturalvar=1)

both forms make swig treat all the member variables in the
same way it treats global variables.

Also, you can use it in a case by case approach for
specific member variables using the directive form:

%naturalvar Bar::s;

Then, in the following case for example:

std::string s;
struct Bar {
std::string s;
};

you can do:

b = Bar()
b.s ="hello"
cvar.s = "hello"

if (b.s != cvar.s):
raise RuntimeError


This is valid for all the languages, and the
implementation is based on forcing the use of the
const SWIGTYPE& (C++)/SWIGTYPE (C) typemaps for the
get/set methods instead of the SWIGTYPE * typemaps.
Hence, for 'naturalvar' to work, each target language
must implement 'typemap(in/out) const Type&' properly.

The 'naturalvar' option replaces or makes workarounds such as:

%apply const std::string & { std::string *}

unnecessary.

Note1: If your interface has other kinds of workarounds to
deal with the old 'unnatural' way to deal with member
variables (returning/expecting pointers), the
'naturalvar' option could break them.

Note2: the option has no effect on unnamed types, such
as unnamed nested unions.


12/27/2005: mmatus
- Add more 'expressive' result states for the typemap
libraries.

In the past, for scripting languages, you would do checking something like:

if (ConvertPtr(obj,&vptr,ty,flags) != -1) {
// success
} else {
// error
}

Now the result state can carry more information,
including:

- Error state: like the old -1/0, but with error codes from swigerrors.swg.

int res = ConvertPtr(obj,&vptr,ty,flags);
if (SWIG_IsOK(res)) {
// success code
} else {
SWIG_Error(res); // res carries the error code
}

- Cast rank: when returning a simple successful
conversion, you just return SWIG_OK, but if you need
to do a 'cast', you can add the casting rank, ie:

if (PyFloat_Check(obj)) {
value = PyFloat_AsDouble(obj);
return SWIG_OK;
} else if (PyInt_Check(obj)) {
value = (double) PyInt_AsLong(obj);
return SWIG_AddCast(SWIG_OK);
}

later, the casting rank is used to properly dispatch
the overloaded function, for example. This of course
requires your language to support and use the new
dispatch cast/rank mechanism (Now mainly supported in
perl and python, and easily expandable to ruby and tcl).

- [UTL] Add support for the new 'expressive' result states.

12/27/2005: mmatus
- Add support for the C++ implicit conversion mechanism, which
required some modifications in parser.y (to recognize
'explicit') and overload.cxx (to replace $implicitconv as
needed).

Still, real support in each target language requires each
target language to be modified. Python provides an example,
see below.


- Add support for native C++ implicit conversions, ie, if you
have

%implicitconv A;

struct A {
int ii;
A() {ii = 1;}
A(int) {ii = 2;}
A(double) {ii = 3;}
explicit A(char *s) {ii = 4;}
};

int get(const A& a) {return a.ii;}

you can call:

a = A()
ai = A(1)
ad = A(1.0)
as = A("hello")

old forms
get(a) -> 1
get(ai) -> 2
get(ad) -> 3
get(as) -> 4

implicit conversions
get(1) -> 2
get(1.0) -> 3
get("hello") -> Error, explicit constructor

Also, as in C++, now implicit conversions are supported in
variable assigments, and if you have:

A ga;
struct Bar {
A a;
};

you can do:

cvar.ga = A(1)
cvar.ga = 1
cvar.ga = 1.0
cvar.ga = A("hello")
cvar.ga = "hello" -> error, explicit constructor

b = Bar()
b.a = A("hello")
b.a = 1
b.a = 1.0
b.a = "hello" -> error, explicit constructor

Note that the last case, assigning a member var directly,
also requires the 'naturalvar' option.

This support now makes the old '%implicit' macro, which
was found in 'implicit.i' and it was fragile in many ways,
obsolete, and you should use the new '%implicitconv'
directive instead.

Note that we follow the C++ conventions, ie, in the
following the implicit conversion is allowed:

int get(A a) {return a.ii;}
int get(const A& a) {return a.ii;}

but not in these cases:

int get(A *a) {return a->ii;}
int get(A& a) {return a.ii;}

Also, it works for director methods that return a by value
result, ie, the following will work:

virtual A get_a() = 0;

def get_a(self):
return 1

but not in this case:

virtual const A& get_a() = 0;
virtual A& get_a() = 0;
virtual A* get_a() = 0;

Notes:

- the implicitconv mechanism is implemented by directly
calling/dispatching the python constructor, triggering a
call to the __init__method. Hence, if you expanded the
__init__ method, like in:

class A:
def __init__(self,args):
<swig code>
<my code here>

then 'my code' will also be executed.

- Since the %implicitconv directive is a SWIG feature, if you type:

%implicitconv;

that will enable implicit conversion for all the classes in
your module.

But if you are worried about performance, maybe that will be
too much, especially if you have overloaded methods, since
to resolve the dispatching problem, python will efectively
try to call all the implicit constructors as needed.

- For the same reason, it is highly recommended that you use
the new 'castmode' when mixing implicit conversion and
overloading.

- [python] The %implicit directive is declared obsolete, and
you should use %implicitconv instead. If you include
the implicit.i file, a warning will remind you of this.

Note: Since %implicit is fragile, just replacing it by
%implicitconv could lead to different behavior. Hence, we
don't automatically switch from to the other, and the user
must migrate to the new %implicitconv directive manually.


12/26/2005: wsfulton
[C]
Modify std::vector wrappers to use std::vector::value_type as this is
closer to the real STL declarations for some methods, eg for push_back().
Fixes some compilation errors for some compilers eg when the templated
type is a pointer.

[Java]
std::vector improvements - a few more methods are wrapped and specializations are
no longer required. The specialize_std_vector macro is no longer needed (a
warning is issued if an attempt is made to use it).

12/26/2005: wsfulton
[Java, C]
Add in pointer reference typemaps. This also enables one to easily wrap
std::vector<T> where T is a pointer.

12/24/2005: efuzzyone
[CFFI] The cffi module for SWIG:
- Fully supports C, but provides limited supports for C++, in
particular C++ support for templates and overloading needs to
be worked upon.

12/23/2005: mmatus
[python] Add the castmode that allows the python
type casting to occur.

For example, if you have 'int foo(int)', now

class Ai():
def __init__(self,x):
self.x = x
def __int__(self):
return self.x

foo(1) // Ok
foo(1.0) // Ok
foo(1.3) // Error
ai = Ai(4)
foo(ai) // Ok

The castmode, which can be enabled either with the
'-castmode' option or the %module("castmode") option, uses
the new cast/rank dispatch mechanism. Hence, now if you
have 'int foo(int); int foo(double);', the following works
as expected:

foo(1) -> foo(int)
foo(1.0) -> foo(double)
ai = Ai(4)
foo(ai) -> foo(int)

Note1: the 'castmode' could disrupt some specialized
typemaps. In particular, the "implicit.i" library seems to
have problem with the castmode. But besides that one, the
entire test-suite compiles fine with and without the
castmode.

Note2: the cast mode can't be combined with the fast
dispatch mode, ie, the -fastdispatch option has no effect
when the cast mode is selected. The penalties, however,
are minimum since the cast dispatch code is already based
on the same fast dispatch mechanism.

See the file overload_dispatch_cast_runme.py file for
new cases and examples.

12/22/2005: mmatus
Add the cast and rank mechanism to dispatch overloading
functions. The UTF supports it now, but for each language
it must be decided how to implement and/or when to use it.

[perl] Now perl uses the new cast and rank dispatch
mechanism, which solves all the past problems known
in perl, such as the old '+ 1' problem:

int foo(int);

$n = 1
$n = $n + 1
$r = foo(n)

also works:

foo(1);
foo("1");
foo(1.0);
foo("1.0");

but fails

foo("l");

and when overloading foo(int) and foo(double);

foo(1) -> foo(int)
foo(1.0) -> foo(double)
foo("1") -> foo(int)
foo("1.0") -> foo(double)
foo("l") -> error
foo($n) -> foo(int) for good perl versions
foo($n) -> foo(double) for old bad perl versions

when overloading foo(int), foo(char*) and foo(double):

foo(1) -> foo(int)
foo(1.0) -> foo(double)
foo("1") -> foo(char*)
foo("1.0") -> foo(char*)
foo("l") -> foo(char*)

Note: In perl the old dispatch mechanism was broken,
so, we don't provide an option to enable the old one
since, again, it was really really broken.

See 'overload_simple_runme.pl' for more cases and tests.

PS: all the old known issues are declared resolved, any
new "problem" that could be discovered is declared,
a priori, as "features" of the new dispatch mechanism
(until we find another solution at least).


*** POTENTIAL INCOMPATIBILITY ***

As with the introduction of the UTF, some things could
now start to work as expected, and people used to deal or
workaround previous bugs related to the dispatch
mechanism, could see now a difference in perl behavior.

12/21/2005: mmatus
- The '-nodefault' flag (pragma and feature) now generates
a warning, and recommends to use the explicit
-nodefaultctor and -nodefaultdtor options.

The reason to split the 'nodefault' behavior is that, in
general, ignoring the default destructor generates memory
leaks in the target language. Hence, is too risky just to
disable both the default constructor and destructor
at the same time.

If you need to disable the default destructor, it is
also recommended you use the directive form:

%nodefaultdtor MyVerySpecialClass;

for specific classes, and always avoid using the global
-nodefault and -nodefaultdtor options.

12/21/2005: wsfulton
[Java, C]
Fix incorrect code generation when the intermediary classname is changed
in the module directive from its default. For example:

%module(jniclassname="myimclassnewname") "mymodule" // Java
%module(imclassname="myimclassnewname") "mymodule" // C

Add in new special variable $imclassname. See docs.

12/17/2005: mmatus
[Python]
- Add the -aliasobj0/-noaliasobj0 options to use with
-fastunpack and/or -O and old typemaps that use 'obj0'
directly.

So, if you compile your code using -O and get errors about
the undeclared 'obj0' variable, run again using

swig -O -aliasobj0 -python ....

For new typemaps, never use 'obj0' directly, if needed,
use the '$self' name that will be properly expanded to
'obj0' (nofastunpack) or 'swig_obj[0]' (fastunpack).

If you have no idea what I am talking about, better, that
means you have no typemap with this problem.


12/14/2005: mmatus
[Python]
- Add the -fastunpack/-nofastunpack options to enable/disable
the use of the internal UnpackTuple method, instead of
calling the one from the python C API.

The option -O now also implies -fastunpack.


12/11/2005: mmatus
[Python]
- Add the -proxydel/-noproxydel options to enable/disable
the generation of proxy/shadow __del__ methods, even
when now they are redundant, since they are empty.
However, old interfaces could rely on calling them.

The default behavior is to generate the __del__ methods
as in 1.3.27 or older swig versions.

The option -O now also implies -noproxydel.

12/10/2005: mmatus
[UTF]
- Fix unnecessary calls to SWIG_TypeQuery for 'char *'
and 'wchar_t *', problem found by Clay Culver while
profiling the PyOgre project.


[Python]
- Add the -dirvtable/-nodirvtable to enable/disable
a pseudo virtual table used for directors, avoiding
the need to resolve the python method at each call.

- Add the -safecstrings/-nosafecstrings options to
enable/disable the use of safe conversions from PyString
to char *. Python requires you to never change the internal
buffer directly, and hence 'safectrings' warranties that
but returning a copy of the internal python string buffer.

The default, as in previous releases, is to return a
pointer to the buffer (nosafecstrings), so, it is the user's
responsibility to avoid its modification.

- Add the -O option to enable all the optimization options
at once, initially equivalent to

-modern -fastdispatch -dirvtable -nosafecstrings -fvirtual

12/08/2005: mmatus

- Add the -fastdispatch option (fastdispatch feature). This
enables the "fast dispatch" mechanism for overloaded
methods provided by Salvador Fandi~no Garc'ia (930586).

The resulting code is smaller and faster since less type
checking is performed. However, the error messages you
get when the overloading is not resolved could be
different from what the traditional method returns.

With the old method you always get an error such as

"No matching function for overloaded ..."

with the new method you can also get errors such as

"Type error in argument 1 of type ..."

See bug report 930586 for more details.

So, this optimization must be explicitly enabled by users.

The new mechanism can be used as:

swig -fastdispatch

or using the feature form

%feature("fastdispatch") method;
or
%fastdispatch method;


12/06/2005: mmatus

- Several memory and speed improvements, specially for
templates. Now swig is up to 20 faster than before for
large template interfaces, such as the std_containers.i
and template_matrix.i files in the python test-suite.

Memory footprint is also reduced in consideration of small
pcs/architectures.

- add commandline options -cpperraswarn and -nocpperraswarn" to force
the swig preprocessor to treat the error directive as a warning.

the pragmas

pragma SWIG cpperraswarn=1
pragma SWIG cpperraswarn=0

are equivalent to the command line options, respectively.


12/06/2005: mmatus
[Python] The generated code is now more portable, especially
for Windows. Following

http://www.python.org/doc/faq/windows.html

Py_None is never accessed as a structure, plus other
tricks mentioned there.

12/06/2005: mmatus
[Python] Added initial support for threads based in the
proposal by Joseph Winston.

The user interface is as follows:

1.- the module thread support is enable via the "threads" module
option, i.e.

%module("threads"=1)

2.- Equivalent to that, is the new '-threads' swig option

swig -threads -python ...

3.- You can partially disable thread support for a given
method using:

%feature("nothread") method;
or
%nothread method;

also, you can disable sections of the thread support,
for example

%feature("nothreadblock") method;
or
%nothreadblock method;

%feature("nothreadallow") method;
or
%nothreadallow method;

the first disables the C++/python thread protection, and the
second disables the python/C++ thread protection.

4.- The current thread support is based in the PyGIL
extension present in python version 2.3 or later, but
you can provide the thread code for older versions by
defining the macros in pythreads.swg.

If you get a working implementation for older versions,
please send us a patch.

For the curious about performance, here are some numbers
for the profiletest.i test, which is used to check the speed
of the wrapped code:

nothread 9.6s (no thread code)
nothreadblock 12.2s (only 'allow' code)
nothreadallow 13.6s (only 'block' code)
full thread 15.5s ('allow' + 'block' code)

i.e., full thread code decreases the wrapping performance by
around 60%. If that is important to your application, you
can tune each method using the different 'nothread',
'nothreadblock' or 'nothreadallow' features as
needed. Note that for some methods deactivating the
'thread block' or 'thread allow' code is not an option,
so, be careful.


11/26/2005: wsfulton
SWIG library files use system angle brackets everywhere for %include, eg
%include "std_common.i"
becomes
%include <std_common.i>

11/26/2005: wsfulton
[Java, C]
Typesafe enums and proper enums have an extra constructor so that enum item values that
are initialised by another enum item value can be wrapped without having to use %javaconstvalue/
%csconstvalue for when using %javaconst(1)/%csconst(1). Suggestion by
Bob Marinier/Douglas Pearson.
For example:

typedef enum
{
xyz,
last = xyz
} repeat;

11/21/2005: mmatus
[ruby + python]

Fixes for directors + pointers. This is an ugly problem without an easy
solution. Before we identified this case as problematic:

virtual const MyClass& my_method();

but it turns out that all the cases where a pointer, array or
reference is returned, are problematic, even for
primitive types (as int, double, char*, etc).

To try to fix the issue, a new typemap was added,
'directorfree', which is used to 'free' the resources
allocated during the 'directorout' phase. At the same
time, a primitive garbage collector engine was added to
deal with orphaned addresses, when needed.

The situation is much better now, but still it is possible to have
memory exhaustation if recursion is used.

So, still you need to avoid returning pointers, arrays or
references when using director methods.

- Added stdint.i - typemaps for latest C99 integral types found in stdint.h.

11/14/2005: wsfulton
More types added to windows.i, eg UINT8, WORD, BYTE etc.
Including windows.i will also enable SWIG to parse the __declspec Microsoft
extension, eg __declspec(dllimport). Also other Windows calling conventions
such as __stdcall.

11/10/2005: wsfulton
New library file for Windows - windows.i. This file will contain useful type
information for users who include windows.h. Initial support is for the
non ISO integral types: __int8, __int16, __int32, __int64 and unsigned versions.
The unsigned versions previously could not be parsed by SWIG. SF 872013.

11/09/2005: wsfulton
[Java, C] Portability warning for files which will overwrite each other on case
insensitive file systems such as FAT32/NTFS. This will occur, for example, when two
class names are the same barring case. The warning is issued on all platforms and
can be suppressed with the usual warning suppression techniques. SF bug 1084507.

11/09/2005: wsfulton
./configure --with-python --with-ruby --with-perl5 etc enable these languages,
ie the --with-xxxx options, where no path is specified, work the same as if
the option was not specified at all. Based on patches 1335042 1329048 1329047.

11/09/2005: dancy

[Allegrocl]
Add C++ support to the Allegrocl module. Further
enhances the C support as well. Some of the
features:

- MUCH better generation of foreign types based on
the C/C++ types for use in defining the FFI on
the lisp side. We don't pass everything as a (* :void)
any longer.

- Uses typemaps for better control of type conversions
and code generation in the generated lisp and c++ wrapper
code.

- CLOS wrapping of pointers returned from foreign space
makes it easier to differentiate pointers in user code.
The wrapping objects can be passed directly to FF calls.

- Defun wrapping of FF calls, allowing for more lispy
interface. Conversion, GCing, of lisp objects to
foreign objects can be done in the wrapping defun via
the use of typemaps.

- overload dispatching implemented on the lisp side
using generic functions.

- Templates and synonymous types supported.

11/07/2005: mmatus

[Python] Adding proper support for multi-inheritance in
the python side, ie, if you have two C++ wrapped class, Foo
and Bar, now:

class MyPythonClass(Foo,Bar):
....

will properly work, even with directors, and the
deallocation of Foo.this and Bar.this will follow
correctly. Before, a class could only have one 'this'
instance (unlike C++), only the last base class was
properly deleted, or detected with directors.

Now 'self.this' can be a list, which will contain the C++
instance pointers for all the base classes.

Also, swig.this is responsible for deallocating the C++
instance(s), and the __del__ method is not emitted unless
the user preppend/append some code to it.

- Swig can now detect memory leaks, ie, if you still
don't use proxy/shadow classes, and type something like

import _example
f = _example.new_Foo()

and forget to call _example.delete_Foo(f), then swig will
tell you that there is a memory leak.

Otherwise, if you always use the proxy classes, you probably
you will never ever see this warning unless there is
something wrong inside the swig wrapping code.


*** POTENTIAL INCOMPATIBILITY ***

If you overloaded the __del__ method, and call the base
one without a try block, as in

class MyClass(SwigClass):

def __del__(self):
<your code here>
SwigClass.__del__(self)

python could complain that the method SwigClass.__del__ is
undefined. Try to use instead:

def __del__(self):
<your code here>
try: SwigClass.__del__(self)
except: pass

or simply

def __del__(self):
<your code here>

11/02/2005: mmatus

[Python] Adding more fun to STL/STD containers, now you
can do

%template(pyset) std::set<PyObject *>;
%template(pyvector) std::vector<PyObject *>;
%template() std::pair<PyObject *,PyObject *>;
%template(pyvector) std::map<PyObject *,PyObject *>;
....

The same applies to std::list, std::deque, std::multiset, etc.

Then, at the python side you can do now:

C++ std::vector as native python sequence
v = pyvector([1,"hello",(1,2)])
print v[1]
>> 'hello'
print v[2]
>> (1,2)

C++ std::set as native python sequence
s = pyset()
s.insert((1,2))
s.insert(1)
s.insert("hello")
sum=()
for i in s:
sum +=(i,)
print sum
>>> (1, 'hello', (1, 2))

C++ std::map as native python sequence
m = pymap()
m["foo"] = "hello"
m[1] = (1,2)
pm = {}
for k in m:
pm[k] = m[k]
print pm
>>> {1: (1, 2), 'foo': 'hello'}

ie, the STD/STL containers work as real native python
container, with arbitrary item types and so.

But since normal C++ containers do not properly ref/unref
their items, you should use the safer versions:

%template(pyset) std::set<swig::PyObject_ptr>;
%template(pyvector) std::vector<swig::PyObject_ptr>;
%template() std::pair<swig::PyObject_ptr, swig::PyObject_ptr>;
%template(pyvector) std::map<swig::PyObject_ptr,swig::PyObject_ptr>;
....

where swig::PyObject_ptr is a PyObject * envelope class provided
to safely incref/decref the python object.

So, now you can use all the STL/STD containers as native
Python containers.

Note 1: std::map, std::set and the other 'ordered'
containers will properly use PyObject_Compare for sorting,
when needed.

Note 2: all the STL/STD containers have a limit size of
SIZE_MAX, ie, you can have manage containers larger than
INT_MAX, the python limit.


11/02/2005: mmatus

[Python]
- add 'iterator()' method for all sequences and additionally
'key_iterator()' for maps.

'iterator()' will always return the native C++ iterator.
Additionally, in maps, 'key_iterator()' will return a python
iterator using only the map keys.

In general the sequence method __iter__ will call
'iterator()', returning the native C++ iterator, but in
maps it will call 'key_iterator()', maintaining
backward compatibility.

Hence, for std::maps, you can play then with the native
C++ iterator, which value is a (key, value) pair, by
calling map.iterator(), as with map.begin(), map.end(), etc.

The difference is that map.iterator() returns a safe
'closed' iterator, while map.begin() and map.end() are
'open' iterators.

A 'closed' iterator knows the begin and the end of the
sequence, and it never can seg. fault. An 'open'
iterator, as in C++, can seg. fault at the C++ side.

a closed iterator is safe in the following example.
the next() method will throw a StopIteration
exception as needed

i = seq.iterator()
try:
while True:
sum += i.next()
except: pass

an open iterator always need to be checked,
or it will crash at the C++ side

current = seq.begin()
end = seq.end()
while (current != end):
sum += current.next()


[Python]
- Finally, when we call

f = Foo()

the construction is 'one-way'. Before construction was done
something like

Foo() (python) -> _new_Foo() (C++)
new_Foo() (C++) -> FooPtr() (python)
FooPtr() (python) -> Foo() (python)

and returning a pointer was done like

NewPointerObj() (C++) -> FooPtr() (python)
FooPtr(python) -> Foo() (python)


ie, we when going back and forward between the C++ and
python side.

Now since there is no FooPtr the construction process is

Foo() (python) -> _new_Foo() (C++)
_new_Foo() (C++) -> NewPointerObj() (C++) (no shadow class)

and returning a pointer is done

NewPointerObj() (C++) (with shadow class) -> NewInstaceObj() (C++)

where NewInstanceObj creates a new instance without
calling __init__ and it doesn't go 'back' to python, is
'pure' C API.

- With this change, and the other ones in the
PySwigObject type, which now carries the thisown and
swig_type_info pointer, the generated code should be as
fast as boost::Python and/or the other python wrappers
based in pure Python/C API calls.

As a reference, the profiletest_runme.py example, which
does a simple call function many times, such as this code:

import profiletest

a = profiletest.A()
b = profiletest.B()
for i in range(0,1000000)
a = b.fn(a)


where fn is defined as 'A* B::fn(A *a) {return a;}',
produces the following times

nomodern modern
swig-1.3.26 19.70s 5.98s
swig-CVS 0.99s 0.98s


Clearly, there is a large improvement for the python
'nomodern' mode. Still, the 'modern' mode is around
6 times faster than before. For the same test, but
using the non-shadow version of the module, we get

_profiletest (non-shadow)
swig-1.3.26 0.80s
swig-CVS 0.60s

Hence, now for practical purposes, the proxy overhead
is insignificant.

Note that the performance numbers we are showing is for
a simple module (two types) and a simple function (one
argument). For real situations, for modules with many
more types and/or functions with many more parameters,
you will see even better results.


10/31/2005: mmatus
[Python]

- Finally, no more ClassPtr proxy classes. You will see
only a clean Class proxy class in the .py file.

- No more 'real' thisown attribute either, the PySwigObject now
carries the ownership info.

You can also do something like

print self.this.own()
>>> True

self.this.disown()
self.this.own(0)
print self.this.own()
>>> False

self.this.acquire()
self.this.own(1)
print self.this.own()
>>> True

Still the old way,

print self.thisown
>>> True

self.thisown = 0
print self.thisown
>>> False

self.thisown = 1
print self.thisown
>>> True

is supported, and python dispatches the proper method
calls as needed.


- Support for iterators in STL/STD containers, for example, if you have

%template<set_string> std::set<std::string>;

you can use the C++ iterators as:

s = set_string()

s.append("c")
s.append("a")
s.append("b")

b = s.begin()
e = s.end()
sum = ""
while (b != e):
sum += b.next()
print sum

>>> "abc"

advance the iterator as in C++

current = s.begin()
current += 1
print current.value()
>>> "b"

now using the reverse operators

b = s.rbegin()
e = s.rend()
sum = ""
while (b != e):
sum += b.next()
print sum

>>> "cba"

or the 'previous' method

b = s.begin()
e = s.end()
sum = ""
while (b != e):
sum += e.previous()
print sum

>>> "cba"

or just as in a python fashion

for i in s:
sum += i

Note 1: Iterators in C++ are very powerful, but
dangerous too. And in python you can shoot yourself in the foot
just like in C++, so, be careful.

Note 2: the iterators are 'light', ie, they do not
convert sequence elements until you request to do so, via
next(), value() or previous(). If you just increment/decrement one
no conversion is performed, for example:


b = s.begin()
b += 1
b.incr()
b.incr(2)
b.decr(2)
b.decr()
b -= 1

only the iterator is modified, and not value wrapper
is generated. Other typical C++ operations are also
available, such as:

print s.end() - s.begin()
>>> 3
f = s.begin() + 1
print f.value()
>>> "b"
l = s.end() - 1
print l.value()
>>> "c"

etc. Of course, the 'find', 'insert', 'erase', and
so on methods also supports iterators now, ie:

i = s.begin()
i += 1
s.erase(i)
for i in s:
sum += i
print sum
>>> "ac"

*** POTENTIAL INCOMPATIBILITY ***

There is no more 'thisown' attribute. If you use it, python
will translate the following code as follows:

if (self.thisown): ==> if (self.this.own()):
self.thisown = 1 ==> self.this.own(1)
self.thisown = 0 ==> self.this.own(0)

Still, maybe in some unusual cases the translation will not be
100% correct, so if you have a problem, please report it
and/or use the new 'self.this.own()' accessor.


*** POTENTIAL INCOMPATIBILITY ***

There is no more ClassPtr classes in the python code. Hence,
if in the past you needed to resort to some kind of trickery
with them, or overcome their presence, it is no longer
required, but the extra code you added could now break
things.

If needed, you can use the option -classptr, i.e.,

swig -classptr -python ...

to generate the old ClassPtr classes.


10/30/2005: mkoeppe
[Guile] Make declared and defined linkage of SWIG_init consistent.
Reported by Steven G. Johnson (SF patch 1315498).

10/26/2005: mmatus

- Added the attribute.i file to the global library director.
Now it can be used from other languages that do not use
the unified typemap library as well.

So, if you have something like:

%include attribute.i

%attribute(A, int, a, get_a, set_a);

struct A
{
int get_a() const;
void set_a(int aa);
};

%attribute_ref(B, int, c);

struct B
{
int& c();
};

then in the target language the 'A.a' and 'B.c' attributes will
be visible, ie, you can access them as plain variables:

f = A()
f.a = 3
g = B()
g.c = 3

h = f.a + g.c

and the proper get/set methods will be dispatched. See
attribute.i for more info.

- More cleanups around and adding more test-cases. The
DISOWN typemap now is tested and working in all the
languages that use the unified typemap library, ie, tcl,
ruby, perl and python.


10/25/2005: mmatus

- Perl, complete the DISOWN typemap.

- added the attribute.i file to the unified typemap
library (before was only usable from python).

- unify the names for the setter and getter methods in
perl,tcl,ruby and python, so, the attribute.i library
can work across them.

- see the li_attribute.i test-case or the library file

Lib/typemaps/attribute.swg

for more info about how to use it.




10/24/2005: mmatus

- Perl now uses the unified typemap library.

- Changes in ruby to use the $track option in typemaps.

- Changes in the unified typemap library to follow the
convention that all macros that are not used in the
C/C++ side starts with %, such as

%delete
%new_array

etc.

- Documenting fragments, see fragments.swg.

- Cleaner way to use the unified typemap library, include
just <typemaps/swigtypes.swg>.

Check some of the supported languages: perl, tcl, ruby,
python.

Always start with the head file, such as

python/python.swg
tcl/tcl8.swg
ruby/ruby.swg
perl5/perl5.swg

and the principal file that invokes the unified library, such as

python/pytypemaps.swg
tcl/tcltypemaps.swg
ruby/rubytypemaps.swg
perl/perltypemaps.swg

The file that provide the specialization for each
language are the one that provides the basic types:

python/pyprimtypes.swg
ruby/rubyprimtypes.swg
tcl/tclprimtypes.swg
perl5/perlprimtypes.swg

and the string manipulation:

python/pystrings.swg
ruby/rubystrings.swg
tcl/tclstrings.swg
perl5/perlstrings.swg


The rest of the files, such as carray.i, are mostly one
line files that include the proper typemap library
version.

*** POTENTIAL INCOMPATIBILITY in Perl ***

Some missing/wrong typemaps could start working properly,
and change the old expected behavior in Perl.

10/23/2005: wuzzeb
Chicken:
+ pointers to member functions finally work properly
+ add test of member function pointers to cpp_basic.i

10/20/2005: dancy
[allegrocl] Added C++ support. Large update, many changes. See
newly added Allegro Common Lisp section in lisp.html

10/20/2005: mmatus
Ruby, Tcl, Python:

- Uniform way to fail (label fail:), now finally
SWIG_exception works across the three languages and all
the typemaps.

- Add proper cleanup code to ruby

- More valgrind fixes

- Simplify the inline use, it seems a small interface of
20,000 lines (plus many many templates) can break
gcc -O3 easily.

- Finalize the typemaps library. All the old *.i files
(carray.i, cpointer.i, exception.i) had been implemented
in the new typemaps library.


10/19/2005: wuzzeb
Update the Runtime Typemap documentation in Typemaps.html

10/18/2005: wuzzeb
Chicken:
- Correctly handle %ignored classes
- Correctly convert long, long long, unsigned long, etc
to chicken primitives. (Thanks to Felix Winkelmann)
- Using argout parameters when the return value was a
wrapped pointer caused a memory corruption. The chicken
garbage collector moved a pointer out from under us.
This is now fixed by running all the proxy creation
functions as continuations after the wrapper function
returns. As part of this, we no longer need the
chickenfastproxy flag on output typemaps.
- using -proxy and -nocollection together works now
Before, it was not exporting the destructor in the proxy
wrapper.

10/18/2005: mmatus

Added the Unified Typemap Library (UTL). It unifies the typemaps for

python, ruby, tcl

and in the process, fixes several problems in each of the three
languages to work in a "canonical" way now established in
the typemap library

SWIG/Lib/typempas

The current status of the unification is that everything
compiles and runs inside the test-suite and examples
directories. And for the first time we have three
languages than pass the primitive_types.i case.

Also, we have a uniform way to treat the errors, for example
if you do something like

>>> from primitive_types import *
>>> print val_uchar(10)
10
>>> print val_uchar(1000)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OverflowError: in argument 1 of type 'unsigned char'

you get the same exception in all the three languages.

And well, many more good things will come from this
unification, for example, proper support of the STL/STD classes
for all the languages, and hopefully, we can keep
adding other languages.

The hardest part, writing a common typemap library
that suites the three different languages, is done,
and adding another language should now be easy.

Still the global unification is not complete, the STL/STD
part is next, and probably as well as adding one or two more
languages.

If you are curious, look at the python, ruby and/or tcl
directories to see what is needed to support the new
common typemaps library. Still, the final way to
integrate a new language could change as we move to
integrate the STD/STL.

*** POTENTIAL INCOMPATIBILITY in Ruby/Tcl ***

Some missing/wrong typemaps could start working properly,
and change the old behavior, specially in ruby and tcl.

1.3.27

=================================

10/15/2005: wsfulton
[Java] Fix for typesafe enum wrapping so that it is possible to
overload a method with 2 different enum types.

10/15/2005: wsfulton
Fix for %feature("immutable","0") attempting to generate setters
for constants.

Restored %immutable and %makedefault to clear the feature as it
behaved in SWIG-1.3.25 and earlier.

10/14/2005: mmatus
Fix bug in anonymous typedef structures which was leading to
strange behaviour.

10/13/2005: mmatus
Several minor changes:

- Improve the wchar_t type support
- Add a warning for when you define the 'in' typemap but
you don't define the 'typecheck' one. Very common mistake.
- Add proper default rule for function pointers, now you
can define a typemap such as:

%typemap(in) SWIGTYPE ((*)(ANY)) {...}

That will apply to all the pointer to functions. The
rule in C++ also apply to the function 'reference', ie,
in both cases

typedef int (*fptr)(int a);
typedef int (func)(int a);

This was needed since it seems to be 'illegal' in C++ to
do something like:

void *ptr = static_cast<void *>(fptr);

and probably, as for member functions, it is not
warrantied that the pointer sizes will match.

- Add the error/warning directives to swig's cpp.

- Add the noblock option for typemaps, which is used as
follows: supposed you a typemap, like this


%typemap(in,noblock=1) Hello {
....
}

then the typemap will be inserted without the block
imposed by the brackets, similar to

%typemap(in) Hello "..."

So, why you don't just use the quote style?, because:

1.- The quote style doesn't get preprocessed, for example

%typemap(in) Hello "$1= SWIG_macro($1);"

here, SWIG_macro doesn't get expanded

2.- Inside a quote typemap, you have to use
quotes carefully

%typemap(in) Hello "$1 = \"hello\" "

3.- You can't make emacs and/or other editors
to indent inside a string!.


So, why do you want to remove the block?, because an extra
block when not needed (no local variables in it):

1.- makes the code harder to read
2.- makes the code larger
3.- or in short, for the same reason we have the quote style.

1.3.26

================================

10/08/2005: wsfulton
[Php] Added 'throws' typemaps.

10/08/2005: wsfulton
Fixes for languages that don't support multiple inheritance. The
first non-ignored class in the public base class list is used for inheritance.
by the proxy class. Previously, if the first class in the list was ignored, then
the proxy class wouldn't have any base classes.

10/07/2005: mmatus
Update more features to follow new convention, including:

callback
ref/unref
except

All of them use not only the feature as a flag, but also
as code value. To deal with those features, we use now
GetFlagAttr, which is similar to GetFlag, but instead or
returning 1 or 0, it returns the attr value, if happens
to be different of "0" of course.

Now there are also more uniform directive names for the
ones based in features, for example, for the old
%newobject directive now we have three directives defined:


define %newobject %feature("new")
define %nonewobject %feature("new","0")
define %clearnewobject %feature("new","")

and so on for all the other feature directives.

*** POTENTIAL INCOMPATIBILITY ***

09/30/2005: wsfulton
Subtle change to some features. Previously it was not possible to disable many
features once they had been enabled. This was for most features that behave as
flags. These features now work as follows:

%feature("name") // enables the feature
%feature("name", "1") // enables the feature
%feature("name", "0") // disables the feature
%feature("name", "") // clears the feature

In fact any non-empty value other than "0" will enable the feature (like C boolean logic).
Previously "1", "0" or any other non-empty value would enable the feature and it would
only be possible to disable the feature by clearing it (assuming there was no global enable).

The following features are affected:

allowexcept
compactdefaultargs
classic (Python)
cs:const (C)
director
exceptionclass (Python)
ignore
immutable
java:const (Java)
java:downcast (Java)
kwargs
modern (Python)
new
noautodoc (Python)
nodefault
nodirector
noref
notabstract
nounref
novaluewrapper
python:maybecall (Python)
python:nondynamic (Python)
modula3:multiretval (Modula3)
predicate (Ruby)
trackobjects (Ruby)
valuewrapper

It is now possible, for example to ignore all methods/classes in a header file, except for a
few targetted methods, for example:

%feature("ignore"); // ignore all methods/classes
%feature("ignore","0") some_function(int, double); // do not ignore this function
%feature("ignore","0") SomeClass; // do not ignore this Class
%feature("ignore","0") SomeClass::method; // do not ignore this method
%include "bigheader.h"

Removed %pythondynamic - it never worked properly. Use %pythonnondynamic instead.
Removed %feature("nokwargs") - it wasn't fully implemented - use %feature("kwargs","0") instead.

*** POTENTIAL INCOMPATIBILITY ***

09/25/2005: mkoeppe
[Guile] Add "throws" typemaps.

09/24/2005: cfisavage
[Ruby] Adds new %trackobjects functionality that maps C++ objects to
Ruby objects. This functionality makes it much easier to implement
mark functions for the garbage collector. For more information
refer to the update documentation and examples.

09/20/2005: wsfulton
[Perl] Patch 1116431 from Josh Cherry. Fixes non member functions inadvertently
being called instead of member functions.

09/20/2005: wsfulton
[Lua] Patch from Mark Gossage to add support for Lua-5.1, std::string,
std::vector, std::exception and documentation.

09/14/2005: mmatus
[Python] Add -nocppcast. Now the default behavior is to
always use the cppcast operators. Before that was the case
only when you used the -cppcast option.

If this seems to break your code... your welcome!, it
means it was broken before, and you never notice.

If you thing the error is due to one of the SWIG typemaps,
send us an example.

Use -nocppcast only with very old C++ compilers that
do not support the cppcast operations.

So, here applies:

This change doesn't break compatibility, it was broken before.

09/13/2005: wsfulton
[Java] Fix for director methods when a class is passed by value as a
parameter.

09/11/2005: mmatus
Adding the module option to the %import directive. Now you
can use it as

%import(module="BigModule") foo.i

where subfile could (or not) define the module name via
the %module directive. The module option take precedence
and it has the same effects than having the directive

%module BigModule

inside the imported file foo.i.

You can use the option in mainly two cases:

1.- You used the -module option when you generated the
module to be imported, and hence the module name in
the imported %module directive is not really useful.

2.- The module you want to import is very large, and it
has several .i/.h files. Then, if you just one to
import a class or so from the module, says 'foo', and
not the entire module via importing the main
BigModule.i file, then you just do:

%import(module="BigModule") foo.h

or

%import(module="BigModule") foo.i

where foo.i contains the 'foo' declaration and maybe a
couple of extra %include directives, as needed.


09/11/2005: mmatus
Fix bug 1282637, about the -module option not having effect
in places where it was needed.

09/11/2005: wsfulton
When wrapping variables, ensure that none of the typemaps used for the
set wrappers are used when generating the get wrappers. I doubt this was a
problem for any languages except for the recently introduced null attribute
in the out typemap (C only).

09/08/2005: wsfulton
More descriptive error messages when files fail to open.

09/06/2005: mmatus

Allow a %define a macro inside another %define macro, for example

%define hello(name, Type)
%define name a(Type)
%typemap(in) Type "hello;"
%enddef
%enddef

To learn how to use this new features in your own typemaps library, see
python/cstring.i, python/cwstring.i and python/cwstrbase.i.

[Python] Normalize the cstring.i implementation to use fragments, and add
cwstring.i, which implements the same typemaps but for wchar_t strings.

[Python] Bug fixed: 1247477, 1245591, 1249878 and others.

08/18/2005: wsfulton
[Ruby] Implement support for SWIGTYPE* DISOWN typemap (like in Python) for
better control of memory management, eg when adding an object created in Ruby
to a C++ container. Patch 1261692 from Charlie Savage.

08/18/2005: wsfulton
[Tcl] 64 bit platform fixes for the varargs handling in SWIG_GetArgs. This is an
improved fix for bug 1011604 as suggested by Jeremy Lin.

08/18/2005: wsfulton
[Tcl] Bug 1240469 - %newobject support for Tcl. Patch from Bob Marinier.

08/16/2005: wsfulton
[Perl] Bug 1254494 - Fix for global namespace pollution by perl header files
(bool define) prevented STL headers from being used on some systems, eg
Windows with Visual Studio.

08/16/2005: wsfulton
[Java] Bug 1240937 - Redefinition of __int64 typedef for Intel compilers.

08/15/2005: wsfulton
[Xml] Bug 1251832 - C++ template may generate invalid XML file

08/15/2005: wsfulton
[Lua] Support added for Lua. Patch 1242772 from Mark Gossage.
It supports most C/C++ features (functions, struct, classes, arrays, pointers,
exceptions), as well as lots of documentation and a few test cases & examples.

08/14/2005: wsfulton
[Xml] Fix incorrect xml escaping in base class name when base class is a template.

08/13/2005: efuzzyone
[CLISP] Added support for handling enums. Does not adds the return type declaration
to the function definition, if a function returns void.

08/09/2005: mkoeppe
New language module, Common Lisp with UFFI, from Utz-Uwe Haus.

08/09/2005: mkoeppe
Fix the Lisp s-expression output module; it no longer complains about "unknown targets".

07/27/2005: wsfulton
Modifications to STL wrappers so that it is possible for a user's %exception directive
to be applied to the STL wrapper methods. Previously the following global %exception
directive would not be used on the wrapper methods:

%exception {
try {
$action
} catch (...) {
// handle uncaught exceptions
}
}

This has been implemented by replacing %exception directives for specific STL wrapper
methods with an exception specification declared on the wrapper methods. throws typemaps
are now supplied for handling the STL exception specification. These can also be easily
overridden, for example the std::out_of_range exception, which is used a lot in the STL
wrappers, can be customised easily:

%include "std_vector.i"
%typemap(throws) std::out_of_range {
// custom exception handler
}
%template(VectInt) std::vector<int>;

07/22/2005: efuzzyone
[CLISP] The clisp module for SWIG:
- It can only handle C, clisp currently does not supports ffi bindings to C++.
- It has two options, (a) -extern-all this will generate wrappers for all functions
and variablestions, (b) -generate-typedef this will generate wrappers "def-c-type"
wrappers for typedefs
- Can handle pointers to functions, complex types such as n-dimensional arrays of
pointers of depth d
- Generates wrappers for constants as well as variables
- Correctly distinguishes between the declaration of variables in structures and functions
- Creates a defpackage "declaration" with the module name as the package name, the created
package exports both functions and variables
- tries to guess when should a pointer variable be declared as c-ptr or c-pointer

07/22/2005: wsfulton
[C] Changes to support C structs returned by value. The changes required are:
- Using an optional 'null' attribute in the out typemap. If this attribute is specified,
then it is used for the $null special variable substitution.
- The ctype used in the C/C++ wrappers is no longer initialised to 0 on declaration.
Both of these changes fix the situations where an attempt was made to assign 0 to the
returned struct. Marshalling structs as value types still requires user defined typemaps.
See documentation for an example.

07/22/2005: wsfulton
[C, Java] Fix SWIG_exception usage to work with compilers that don't support empty macro
arguments. Unfortunately this fix will stop usage of SWIG_exception being used within typemaps
that use "" or %{ %} delimiters, but continues to work with typemaps using {} delimiters.
Please use the SWIG_CSharpSetPendingExceptionArgument or SWIG_JavaThrowException methods instead
as SWIG_exception is really intended as a platform independent macro for the SWIG library writers.

07/16/2005: mkoeppe
[Allegro CL] Use specific foreign types rather than (* :void).
Use *swig-identifier-converter*.

06/27/2005: wsfulton
Functions declared as 'extern' no longer have an additional function declaration added to the
wrapper files. There are some cases where SWIG does not get this right, eg bug 1205859 (extern
functions with default arguments declared in a namespace). Also SWIG cannot get non-standard
calling conventions correct, eg Windows calling conventions are usually handled like this:

%{
define DLLIMPORT __declspec(dllimport)
define STDCALL __stdcall
%}
define DLLIMPORT
define STDCALL
%inline %{
DLLIMPORT extern STDCALL void function(int);
%}

SWIG incorrectly generates:

extern void function(int);

To which there is no solution as SWIG doesn't handle non-standard calling conventions. The extra
'extern' function that SWIG generates is superfluous unless a user has forgotten to add the function
declaration into the wrappers.

The -noextern commandline argument is now redundant and a new commandline argument -addextern can
be used to obtain the original behaviour. This shouldn't be necessary unless the header file
containing the function declaration was inadvertently not added to the wrappers. To fix this
add the function declaration into your wrappers, For example, replace:

extern void foo(int);

with:

%inline %{
extern void foo(int);
%}

*** POTENTIAL INCOMPATIBILITY ***

06/22/2005: wsfulton
[C, Java, Modula3, Ocaml]
The intermediary function names have been changed when wrapping variables to
match the other language modules so that %extend for a member variable works
uniformly across all language modules, eg:

%extend ExtendMe {
Var;
};

%{
void ExtendMe_Var_set(ExtendMe *, double) {...}
double ExtendMe_Var_get(ExtendMe *) {...}
%}

The methods implementing the get/set used to be:

%{
void set_ExtendMe_Var(ExtendMe *, double) {...}
double get_ExtendMe_Var(ExtendMe *) {...}
%}

This also changes the name of variable wrapper functions when using -noproxy.
The original names can be generated with the -oldvarnames commandline option.

*** POTENTIAL INCOMPATIBILITY ***

Page 8 of 13

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.