merge revisions 11877-12162 from trunk to gsoc2009-matevz

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12164 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-07-20 23:35:40 +00:00
commit 25ff4e4927
563 changed files with 22917 additions and 17194 deletions

View file

@ -1,14 +1,11 @@
*** ANNOUNCE: SWIG 2.0.0 (in progress) ***
*** ANNOUNCE: SWIG 2.0.1 (in progress) ***
http://www.swig.org
We're pleased to announce SWIG-2.0.0, the latest installment in the
SWIG development effort. SWIG-2.0.0 includes a number of bug fixes
and enhancements.
We're pleased to announce SWIG-2.0.1, the latest SWIG release.
What is SWIG?
-------------
=============
SWIG is a software development tool that reads C/C++ header files and
generates the wrapper code needed to make C and C++ code accessible
@ -20,17 +17,17 @@ SWIG include generation of scripting language extension modules, rapid
prototyping, testing, and user interface development for large C/C++
systems.
Availability:
-------------
Availability
============
The release is available for download on Sourceforge at
http://prdownloads.sourceforge.net/swig/swig-2.0.0.tar.gz
http://prdownloads.sourceforge.net/swig/swig-2.0.1.tar.gz
A Windows version is also available at
http://prdownloads.sourceforge.net/swig/swigwin-2.0.0.zip
http://prdownloads.sourceforge.net/swig/swigwin-2.0.1.zip
Please report problems with this release to the swig-dev mailing list,
Please report problems with this release to the swig-devel mailing list,
details at http://www.swig.org/mail.html.
--- The SWIG Developers

View file

@ -40,8 +40,11 @@ web/ccache-man.html: ccache.yo
yodl2html -o web/ccache-man.html ccache.yo
install: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1
@echo "Installing $(PACKAGE_NAME)"
@echo "Installing $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)"
${INSTALLCMD} -d $(DESTDIR)${bindir}
${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)
@echo "Installing $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1"
${INSTALLCMD} -d $(DESTDIR)${mandir}/man1
${INSTALLCMD} -m 644 ${srcdir}/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
@ -52,9 +55,6 @@ uninstall: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1
clean:
/bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT)
distclean-docs:
rm -f $(PACKAGE_NAME).1 web/ccache-man.html
check : test
test: test.sh
@ -62,11 +62,13 @@ test: test.sh
check: test
distclean: clean distclean-docs
/bin/rm -f Makefile config.h config.sub config.log build-stamp config.status config.h.in ccache_swig_config.h
distclean: clean
/bin/rm -f Makefile config.h config.sub config.log build-stamp config.status ccache_swig_config.h
/bin/rm -rf autom4te.cache
maintainer-clean: distclean
/bin/rm -f configure
/bin/rm -f $(PACKAGE_NAME).1 web/ccache-man.html
# FIXME: To fix this, test.sh needs to be able to take ccache from the
# installed prefix, not from the source dir.

668
CHANGES
View file

@ -1,6 +1,668 @@
SWIG (Simplified Wrapper and Interface Generator)
See CHANGES.current for current version.
See the CHANGES.current file for changes in the current version.
See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.0 (2 June 2010)
===========================
2010-06-02: wsfulton
[C#] Fix SWIG_STD_VECTOR_ENHANCED macro used in std::vector to work with
types containing commas, for example:
SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >)
2010-06-01: wsfulton
Add in std_shared_ptr.i for wrapping std::shared_ptr. Requires the %shared_ptr
macro like in the boost_shared_ptr.i library. std::tr1::shared_ptr can also be
wrapped if the following macro is defined:
#define SWIG_SHARED_PTR_SUBNAMESPACE tr1
%include <std_shared_ptr.i>
shared_ptr is also documented in Library.html now.
2010-05-27: wsfulton
Add the ability for $typemap special variable macros to call other $typemap
special variable macros, for example:
%typemap(cstype) CC "CC"
%typemap(cstype) BB "$typemap(cstype, CC)"
%typemap(cstype) AA "$typemap(cstype, BB)"
void hah(AA aa);
This also fixes C# std::vector containers of shared_ptr and %shared_ptr.
Also added diagnostics for $typemap with -debug-tmsearch, for example, the
above displays additional diagnostic lines starting "Containing: ":
example.i:34: Searching for a suitable 'cstype' typemap for: AA aa
Looking for: AA aa
Looking for: AA
Using: %typemap(cstype) AA
Containing: $typemap(cstype, BB)
example.i:31: Searching for a suitable 'cstype' typemap for: BB
Looking for: BB
Using: %typemap(cstype) BB
Containing: $typemap(cstype, CC)
example.i:29: Searching for a suitable 'cstype' typemap for: CC
Looking for: CC
Using: %typemap(cstype) CC
2010-05-26: olly
Fix %attribute2ref not to produce a syntax error if the last
argument (AccessorMethod) is omitted. Patch from David Piepgras
in SF#2235756.
2010-05-26: olly
[PHP] When using %throws or %catches, SWIG-generated PHP5 wrappers
now throw PHP Exception objects instead of giving a PHP error of
type E_ERROR.
This change shouldn't cause incompatibility issues, since you can't
set an error handler for E_ERROR, so previously PHP would just exit
which also happens for unhandled exceptions. The benefit is you can
now catch them if you want to.
Fixes SF#2545578 and SF#2955522.
2010-05-25: olly
[PHP] Add missing directorin typemap for const std::string &.
Fixes SF#3006404 reported by t-Legiaw.
2010-05-23: wsfulton
[C#] Fix #2957375 - SWIGStringHelper and SWIGExceptionHelper not always being
initialized before use in .NET 4 as the classes were not marked beforefieldinit.
A static constructor has been added to the intermediary class like this:
%pragma(csharp) imclasscode=%{
static $imclassname() {
}
%}
If you had added your own custom static constructor to the intermediary class in
the same way as above, you will have to modify your approach to use static variable
initialization or define SWIG_CSHARP_NO_IMCLASS_STATIC_CONSTRUCTOR - See csharphead.swg.
*** POTENTIAL INCOMPATIBILITY ***
2010-05-23: wsfulton
Fix #2408232. Improve shared_ptr and intrusive_ptr wrappers for classes in an
inheritance hierarchy. No special treatment is needed for derived classes.
The proxy class also no longer needs to be specified, it is automatically
deduced. The following macros are deprecated:
SWIG_SHARED_PTR(PROXYCLASS, TYPE)
SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE)
and have been replaced by
%shared_ptr(TYPE)
Similarly for intrusive_ptr wrappers, the following macro is deprecated:
SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE)
SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE)
and have been replaced by
%intrusive_ptr(TYPE)
2010-05-21: olly
[PHP] Stop generating a bogus line of code in certain constructors.
This was mostly harmless, but caused a PHP notice to be issued, if
enabled (SF#2985684).
2010-05-18: wsfulton
[Java] Fix member pointers on 64 bit platforms.
2010-05-14: wsfulton
Fix wrapping of C++ enum boolean values reported by Torsten Landschoff:
typedef enum { PLAY = true, STOP = false } play_state;
2010-05-14: olly
[PHP] Fix wrapping of global variables which was producing
uncompilable code in some cases.
2010-05-12: drjoe
[R] Add two more changes from Wil Nolan. Get garbage
collection to work. Implement newfree
2010-05-09: drjoe
Fix bug reported by Wil Nolan change creation of string so
that R 2.7.0+ can use char hashes
2010-05-07: wsfulton
Apply patch #2955146 from Sergey Satskiy to fix expressions containing divide by
operator in constructor initialization lists.
2010-05-05: wsfulton
[R] Memory leak fix handling const std::string & inputs, reported by Will Nolan.
2010-05-01: wsfulton
Typemap matching enhancement for non-default typemaps. Previously all
qualifiers were stripped in one step, now they are stripped one at a time
starting with the left most qualifier. For example, int const*const
is first stripped to int *const then int *.
*** POTENTIAL INCOMPATIBILITY ***
2010-04-25: bhy
[Python] Fix #2985655 - broken constructor renaming.
2010-04-14: wsfulton
Typemap fragments are now official and documented in Typemaps.html.
2010-04-09: wsfulton
[Ruby] Fix #2048064 and #2408020.
Apply Ubuntu patch to fix Ruby and std::vector wrappers with -minherit.
https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/522874
2010-04-09: wsfulton
[Mzscheme] Apply Ubuntu patch to fix std::map wrappers:
https://bugs.launchpad.net/ubuntu/+source/swig1.3/+bug/203876
2010-04-09: wsfulton
[Python] Apply patch #2952374 - fix directors and the -nortti option.
2010-04-09: wsfulton
[Lua] Fix #2887254 and #2946032 - SWIG_Lua_typename using wrong stack index.
2010-04-03: wsfulton
[Python] Fix exceptions being thrown with the -threads option based on patch from Arto Vuori.
Fixes bug #2818499.
2010-04-03: wsfulton
Fix Makefile targets: distclean and maintainer-clean
2010-04-02: wsfulton
[Lua] Fix char pointers, wchar_t pointers and char arrays so that nil can be passed as a
valid value. Bug reported by Gedalia Pasternak.
2010-04-01: wsfulton
Numerous subtle typemap matching rule fixes when using the default type. The typemap
matching rules are to take a type and find the best default typemap (SWIGTYPE, SWIGTYPE* etc),
then look for the next best match by reducing the chosen default type. The type deduction
now follows C++ class template partial specialization matching rules.
Below are the set of changes made showing the default type deduction
along with the old reduced type and the new version of the reduced type:
SWIGTYPE const &[ANY]
new: SWIGTYPE const &[]
old: SWIGTYPE (&)[ANY]
SWIGTYPE *const [ANY]
new: SWIGTYPE const [ANY]
old: SWIGTYPE *[ANY]
SWIGTYPE const *const [ANY]
new: SWIGTYPE *const [ANY]
old: SWIGTYPE const *[ANY]
SWIGTYPE const *const &
new: SWIGTYPE *const &
old: SWIGTYPE const *&
SWIGTYPE *const *
new: SWIGTYPE const *
old: SWIGTYPE **
SWIGTYPE *const &
new: SWIGTYPE const &
old: SWIGTYPE *&
Additionally, a const SWIGTYPE lookup is used now for any constant type. Some examples, where
T is some reduced type, eg int, struct Foo:
T const
new: SWIGTYPE const
old: SWIGTYPE
T *const
new: SWIGTYPE *const
old: SWIGTYPE *
T const[]
new: SWIGTYPE const[]
old: SWIGTYPE[]
enum T const
new: enum SWIGTYPE const
old: enum SWIGTYPE
T (*const )[]
new: SWIGTYPE (*const )[]
old: SWIGTYPE (*)[]
Reminder: the typemap matching rules can now be seen for any types being wrapped by using
either the -debug-tmsearch or -debug-tmused options.
In practice this leads to some subtle matching rule changes and the majority of users
won't notice any changes, except in the prime area of motivation for this change: Improve
STL containers of const pointers and passing const pointers by reference. This is fixed
because many of the STL containers use a type 'T const&' as parameters and when T is
a const pointer, for example, 'K const*', then the full type is 'K const*const&'. This
means that the 'SWIGTYPE *const&' typemaps now match when T is either a non-const or
const pointer. Furthermore, some target languages incorrectly had 'SWIGTYPE *&' typemaps
when these should have been 'SWIGTYPE *const&'. These have been corrected (Java, C#, Lua, PHP).
*** POTENTIAL INCOMPATIBILITY ***
2010-03-13: wsfulton
[Java] Some very old deprecated pragma warnings are now errors.
2010-03-13: wsfulton
Improve handling of file names and directories containing double/multiple path separators.
2010-03-10: mutandiz (Mikel Bancroft)
[allegrocl] Use fully qualified symbol name of cl::identity in emit_defun().
2010-03-06: wsfulton
[Java] The intermediary JNI class modifiers are now public by default meaning these
intermediary low level functions are now accessible by default from outside any package
used. The proxy class pointer constructor and getCPtr() methods are also now public.
These are needed in order for the nspace option to work without any other mods.
The previous default of protected access can be restored using:
SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE)
%pragma(java) jniclassclassmodifiers = "class"
2010-03-06: wsfulton
[C#] Added the nspace feature for C#. Documentation for the nspace feature is now available.
2010-03-04: wsfulton
Added the nspace feature. This adds some improved namespace support. Currently only Java
is supported for target languages, where C++ namespaces are automatically translated into
Java packages. The feature only applies to classes,struct,unions and enums declared within
a namespace. Methods and variables declared in namespaces still effectively have their
namespaces flattened. Example usage:
%feature(nspace) Outer::Inner1::Color;
%feature(nspace) Outer::Inner2::Color;
namespace Outer {
namespace Inner1 {
struct Color {
...
};
}
namespace Inner2 {
struct Color {
...
};
}
}
For Java, the -package option is also required when using the nspace feature. Say
we use -package com.myco, the two classes can then be accessed as follows from Java:
com.myco.Outer.Inner1.Color and com.myco.Outer.Inner2.Color.
2010-02-27: wsfulton
[Python] Remove -dirvtable from the optimizations included by -O as it this option
currently leads to memory leaks as reported by Johan Blake.
2010-02-27: wsfulton
License code changes: SWIG Source is GPL-v3 and library code license is now clearer
and is provided under a very permissive license. See http://www.swig.org/legal.html.
2010-02-13: wsfulton
[Ruby] A few fixes for compiling under ruby-1.9.x including patch from 'Nibble'.
2010-02-13: wsfulton
[Ruby] Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x
used in various STL wrappers.
2010-02-13: wsfulton
[C#, Java] Fix incorrect multiply defined symbol name error when an enum item
and class name have the same name, as reported by Nathan Krieger. Example:
class Vector {};
namespace Text {
enum Preference { Vector };
}
This also fixes other incorrect corner case target language symbol name clashes.
2010-02-11: wsfulton
Add the -debug-lsymbols option for displaying the target language layer symbols.
2010-02-09: wsfulton
Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as
they should be.
2010-02-08: wsfulton
Fix #1807329 - When Makefile dependencies are being generated using the -M family of options
on Windows, the file paths have been corrected to use single backslashes rather than double
backslashes as path separators.
2010-02-06: wsfulton
Fix #2918902 - language specific files not being generated in correct directory on
Windows when using forward slashes for -o, for example:
swig -python -c++ -o subdirectory/theinterface_wrap.cpp subdirectory/theinterface.i
2010-02-05: wsfulton
Fix #2894405 - assertion when using -xmlout.
2010-01-28: wsfulton
Fix typemap matching bug when a templated type has a typemap both specialized and not
specialized. For example:
template<typename T> struct XX { ... };
%typemap(in) const XX & "..."
%typemap(in) const XX< int > & "..."
resulted in the 2nd typemap being applied for all T in XX< T >.
2010-01-22: wsfulton
Fix #2933129 - typemaps not being found when the unary scope operator (::) is used to denote
global scope, the typemap is now used in situations like this:
struct X {};
%typemap(in) const X & "..."
void m(const ::X &);
and this:
struct X {};
%typemap(in) const ::X & "..."
void m(const X &);
2010-01-20: wsfulton
Fix some unary scope operator (::) denoting global scope problems in the types generated
into the C++ layer. Previously the unary scope operator was dropped in the generated code
if the type had any sort of qualifier, for example when using pointers, references, like
::foo*, ::foo&, bar< ::foo* >.
2010-01-13: olly
[PHP] Add datetime to the list of PHP predefined classes (patch
from David Fletcher in SF#2931042).
2010-01-11: wsfulton
Slight change to warning, error and diagnostic reporting. The warning number is no
longer shown within brackets. This is to help default parsing of warning messages by
other tools, vim on Unix in particular.
Example original display using -Fstandard:
example.i:20: Warning(401): Nothing known about base class 'B'. Ignored.
New display:
example.i:20: Warning 401: Nothing known about base class 'B'. Ignored.
Also subtle fix to -Fmicrosoft format adding in missing space. Example original display:
example.i(20): Warning(401): Nothing known about base class 'Base'. Ignored.
New display:
example.i(20) : Warning 401: Nothing known about base class 'Base'. Ignored.
2010-01-10: wsfulton
Fix a few inconsistencies in reporting of file/line numberings including modifying
the overload warnings 509, 512, 516, 474, 475 to now be two line warnings.
2010-01-10: wsfulton
Modify -debug-tags output to use standard file name/line reporting so that editors
can easily navigate to the appropriate lines.
Was typically:
. top . include . include (/usr/share/swig/temp/trunk/Lib/swig.swg:312)
. top . include . include . include (/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39)
now:
/usr/share/swig/temp/trunk/Lib/swig.swg:312: . top . include . include
/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39: . top . include . include . include
2010-01-03: wsfulton
Fix missing file/line numbers for typemap warnings and in output from the
-debug-tmsearch/-debug-tmused options.
2010-01-03: wsfulton
Add typemaps used debugging option (-debug-tmused). When used each line displays
the typemap used for each type for which code is being generated including the file
and line number related to the type. This is effectively a condensed form of the
-debug-tmsearch option. Documented in Typemaps.html.
2009-12-23: wsfulton
Fix for %javaexception and directors so that all the appropriate throws clauses
are generated. Problem reported by Peter Greenwood.
2009-12-20: wsfulton
Add -debug-tmsearch option for debugging the typemap pattern matching rules.
Documented in Typemaps.html.
2009-12-12: wsfulton
[Octave] Remove the -api option and use the new OCTAVE_API_VERSION_NUMBER
macro provided in the octave headers for determining the api version instead.
2009-12-04: olly
[Ruby] Improve support for Ruby 1.9 under GCC. Addresses part of
SF#2859614.
2009-12-04: olly
Fix handling of modulo operator (%) in constant expressions
(SF#2818562).
2009-12-04: olly
[PHP] "empty" is a reserved word in PHP, so rename empty() method
on STL classes to "is_empty()" (previously this was automatically
renamed to "c_empty()").
*** POTENTIAL INCOMPATIBILITY ***
2009-12-03: olly
[PHP] Add typemaps for long long and unsigned long long, and for
pointer to method.
2009-12-02: olly
[PHP] Fix warning and rename of reserved class name to be case
insensitive.
2009-12-01: wsfulton
Revert support for %extend and memberin typemaps added in swig-1.3.39. The
memberin typemaps are ignored again for member variables within a %extend block.
Documentation inconsistency reported by Torsten Landschoff.
2009-11-29: wsfulton
[Java, C#] Fix generated quoting when using %javaconst(1)/%csconst(1) for
static const char member variables.
%javaconst(1) A;
%csconst(1) A;
struct X {
static const char A = 'A';
};
2009-11-26: wsfulton
[Java, C#] Fix %javaconst(1)/%csconst(1) for static const member variables to
use the actual constant value if it is specified, rather than the C++ code to
access the member.
%javaconst(1) EN;
%csconst(1) EN;
struct X {
static const int EN = 2;
};
2009-11-23: wsfulton
C++ nested typedef classes can now be handled too, for example:
struct Outer {
typedef Foo { } FooTypedef1, FooTypedef2;
};
2009-11-18: wsfulton
The wrappers for C nested structs are now generated in the same order as declared
in the parsed code.
2009-11-18: wsfulton
Fix #491476 - multiple declarations of nested structs, for example:
struct Outer {
struct {
int val;
} inner1, inner2, *inner3, inner4[1];
} outer;
2009-11-17: wsfulton
Fix parsing of enum declaration and initialization, for example:
enum ABC {
a,
b,
c
} A = a, *pC = &C, array[3] = {a, b, c};
2009-11-17: wsfulton
Fix parsing of struct declaration and initialization, for example:
struct S {
int x;
} instance = { 10 };
2009-11-15: wsfulton
Fix #1960977 - Syntax error parsing derived nested class declaration and member
variable instance.
2009-11-14: wsfulton
Fix #2310483 - function pointer typedef within extern "C" block.
2009-11-13: wsfulton
Fix usage of nested template classes within templated classes so that compileable code
is generated.
2009-11-13: olly
[php] Fix place where class prefix (as specified with -prefix)
wasn't being used. Patch from gverbruggen in SF#2892647.
2009-11-12: wsfulton
Fix usage of nested template classes so that compileable code is generated - the nested
template class is now treated like a normal nested classes, that is, as an opaque type
unless the nestedworkaround feature is used.
2009-11-12: wsfulton
Replace SWIGWARN_PARSE_NESTED_CLASS with SWIGWARN_PARSE_NAMED_NESTED_CLASS and
SWIGWARN_PARSE_UNNAMED_NESTED_CLASS for named and unnamed nested classes respectively.
Named nested class ignored warnings can now be suppressed by name using %warnfilter, eg:
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner;
but clearly unnamed nested classes cannot and the global suppression is still required, eg:
#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
2009-11-11: wsfulton
Added the nestedworkaround feature as a way to use the full functionality of a nested class
(C++ mode only). It removes the nested class from SWIG's type information so it is as if SWIG
had never parsed the nested class. The documented nested class workarounds using a global
fake class stopped working when SWIG treated the nested class as an opaque pointer, and
this feature reverts this behaviour. The documentation has been updated with details of how
to use and implement it, see the "Nested classes" section in SWIGPlus.html.
2009-11-11: wsfulton
There were a number of C++ cases where nested classes/structs/unions were being handled
as if C code was being parsed which would oftentimes lead to uncompileable code as an
attempt was made to wrap the nested structs like it is documented for C code. Now all
nested structs/classes/unions are ignored in C++ mode, as was always documented. However,
there is an improvement as usage of nested structs/classes/unions is now always treated
as an opaque type by default, resulting in generated code that should always compile.
*** POTENTIAL INCOMPATIBILITY ***
2009-11-09: drjoe
Fix R for -fcompact and add std_map.i
2009-11-08: wsfulton
Fix inconsistency for nested structs/unions/classes. Uncompileable code was being
generated when inner struct and union declarations were used as types within the
inner struct. The inner struct/union is now treated as a forward declaration making the
behaviour the same as an inner class. (C++ code), eg:
struct Outer {
struct InnerStruct { int x; };
InnerStruct* getInnerStruct();
};
2009-11-08: wsfulton
Ignored nested class/struct warnings now display the name of the ignored class/struct.
2009-11-07: wsfulton
Bug #1514681 - Fix nested template classes within a namespace generated uncompileable
code and introduced strange side effects to other wrapper code especially code
after the nested template class. Note that nested template classes are still ignored.
2009-11-07: wsfulton
Add new debug options:
-debug-symtabs - Display symbol tables information
-debug-symbols - Display target language symbols in the symbol tables
-debug-csymbols - Display C symbols in the symbol tables
2009-11-03: wsfulton
Fix some usage of unary scope operator (::) denoting global scope, for example:
namespace AA { /* ... */ }
using namespace ::AA;
and bug #1816802 - SwigValueWrapper should be used:
struct CC {
CC(int); // no default constructor
};
::CC x();
and in template parameter specializations:
struct S {};
template <typename T> struct X { void a() {}; };
template <> struct X<S> { void b() {}; };
%template(MyTConcrete) X< ::S >;
plus probably some other corner case usage of ::.
2009-11-02: olly
[Python] Fix potential memory leak in initialisation code for the
generated module.
2009-10-23: wsfulton
Fix seg fault when using a named nested template instantiation using %template(name)
within a class. A warning that these are not supported is now issued plus processing
continues as if no name was given.
2009-10-20: wsfulton
[Python] Fix std::vector<const T*>. This would previously compile, but not run correctly.
2009-10-20: wsfulton
Fixed previously fairly poor template partial specialization and explicit
specialization support. Numerous bugs in this area have been fixed including:
- Template argument deduction implemented for template type arguments, eg this now
works:
template<typename T> class X {};
template<typename T> class X<T *> {};
%template(X1) X<const int *>; // Chooses T * specialization
and more complex cases with multiple parameters and a mix of template argument
deduction and explicitly specialised parameters, eg:
template <typename T1, typename T2> struct TwoParm { void a() {} };
template <typename T1> struct TwoParm<T1 *, int *> { void e() {} };
%template(E) TwoParm<int **, int *>;
Note that the primary template must now be in scope, like in C++, when
an explicit or partial specialization is instantiated with %template.
*** POTENTIAL INCOMPATIBILITY ***
2009-09-14: wsfulton
[C#] Add %csattributes for adding C# attributes to enum values, see docs for example.
2009-09-11: wsfulton
Fix memmove regression in cdata.i as reported by Adriaan Renting.
2009-09-07: wsfulton
Fix constant expressions containing <= or >=.
2009-09-02: wsfulton
The following operators in constant expressions now result in type bool for C++
wrappers and remain as type int for C wrappers, as per each standard:
&& || == != < > <= >= (Actually the last 4 are still broken). For example:
#define A 10
#define B 10
#define A_EQ_B A == B // now wrapped as type bool for C++
#define A_AND_B A && B // now wrapped as type bool for C++
2009-09-02: wsfulton
Fix #2845746. true and false are now recognised keywords (only when wrapping C++).
Constants such as the following are now wrapped (as type bool):
#define FOO true
#define BAR FOO && false
Version 1.3.40 (18 August 2009)
===============================
@ -956,7 +1618,7 @@ Version 1.3.35 (7 April 2008)
03/17/2008: olly
Fix memory leak in SWIG's parser (based on patch from Russell
Bryant in SF#1914023).`
Bryant in SF#1914023).
03/12/2008: wsfulton
Fix bug #1878285 - unnecessary cast for C struct creation wrappers.
@ -8256,7 +8918,7 @@ Version 1.3.22 (September 4, 2004)
When needed, use
%inlcude std_string.i // 'char' strings
%inlcude std_wstring.i // 'wchar_t; strings
%inlcude std_wstring.i // 'wchar_t' strings
04/10/2004: mmatus (Marcelo Matus)

View file

@ -1,371 +1,27 @@
Version 1.3.41 (in progress)
============================
This file contains the changes for the current release.
See the CHANGES file for changes in older releases.
See the RELEASENOTES file for a summary of changes in each release.
2010-02-27: wsfulton
[Python] Remove -dirvtable from the optimizations included by -O as it this option
currently leads to memory leaks as reported by Johan Blake.
Version 2.0.1 (in progress)
===========================
2010-02-13: wsfulton
[Ruby] A few fixes for compiling under ruby-1.9.x including patch from 'Nibble'.
2010-07-16: wsfulton
Fix wrapping of function pointers and member function pointers when the function
returns by reference.
2010-02-13: wsfulton
[Ruby] Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x
used in various STL wrappers.
2010-07-08: wsfulton
Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes
the "unref" feature when used on classes with non-public destructors.
2010-02-13: wsfulton
[C#, Java] Fix incorrect multiply defined symbol name error when an enum item
and class name have the same name, as reported by Nathan Krieger. Example:
2010-06-10: wsfulton
[Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple
modules and wrapping strings. Patch from 'Number Cruncher'.
class Vector {};
namespace Text {
enum Preference { Vector };
}
This also fixes other incorrect corner case target language symbol name clashes.
2010-02-11: wsfulton
Add the -debug-lsymbols option for displaying the target language layer symbols.
2010-02-09: wsfulton
Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as
they should be.
2010-02-08: wsfulton
Fix #1807329 - When Makefile dependencies are being generated using the -M family of options
on Windows, the file paths have been corrected to use single backslashes rather than double
backslashes as path separators.
2010-02-06: wsfulton
Fix #2918902 - language specific files not being generated in correct directory on
Windows when using forward slashes for -o, for example:
swig -python -c++ -o subdirectory/theinterface_wrap.cpp subdirectory/theinterface.i
2010-02-05: wsfulton
Fix #2894405 - assertion when using -xmlout.
2010-01-28: wsfulton
Fix typemap matching bug when a templated type has a typemap both specialized and not
specialized. For example:
template<typename T> struct XX { ... };
%typemap(in) const XX & "..."
%typemap(in) const XX< int > & "..."
resulted in the 2nd typemap being applied for all T in XX< T >.
2010-01-22: wsfulton
Fix #2933129 - typemaps not being found when the unary scope operator (::) is used to denote
global scope, the typemap is now used in situations like this:
struct X {};
%typemap(in) const X & "..."
void m(const ::X &);
and this:
struct X {};
%typemap(in) const ::X & "..."
void m(const X &);
2010-01-20: wsfulton
Fix some unary scope operator (::) denoting global scope problems in the types generated
into the C++ layer. Previously the unary scope operator was dropped in the generated code
if the type had any sort of qualifier, for example when using pointers, references, like
::foo*, ::foo&, bar< ::foo* >.
2010-01-13: olly
[PHP] Add datetime to the list of PHP predefined classes (patch
from David Fletcher in SF#2931042).
2010-01-11: wsfulton
Slight change to warning, error and diagnostic reporting. The warning number is no
longer shown within brackets. This is to help default parsing of warning messages by
other tools, vim on Unix in particular.
Example original display using -Fstandard:
example.i:20: Warning(401): Nothing known about base class 'B'. Ignored.
New display:
example.i:20: Warning 401: Nothing known about base class 'B'. Ignored.
Also subtle fix to -Fmicrosoft format adding in missing space. Example original display:
example.i(20): Warning(401): Nothing known about base class 'Base'. Ignored.
New display:
example.i(20) : Warning 401: Nothing known about base class 'Base'. Ignored.
2010-01-10: wsfulton
Fix a few inconsistencies in reporting of file/line numberings including modifying
the overload warnings 509, 512, 516, 474, 475 to now be two line warnings.
2010-01-10: wsfulton
Modify -debug-tags output to use standard file name/line reporting so that editors
can easily navigate to the appropriate lines.
Was typically:
. top . include . include (/usr/share/swig/temp/trunk/Lib/swig.swg:312)
. top . include . include . include (/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39)
now:
/usr/share/swig/temp/trunk/Lib/swig.swg:312: . top . include . include
/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39: . top . include . include . include
2010-01-03: wsfulton
Fix missing file/line numbers for typemap warnings and in output from the
-debug-tmsearch/-debug-tmused options.
2010-01-03: wsfulton
Add typemaps used debugging option (-debug-tmused). When used each line displays
the typemap used for each type for which code is being generated including the file
and line number related to the type. This is effectively a condensed form of the
-debug-tmsearch option. Documented in Typemaps.html.
2009-12-23: wsfulton
Fix for %javaexception and directors so that all the appropriate throws clauses
are generated. Problem reported by Peter Greenwood.
2009-12-20: wsfulton
Add -debug-tmsearch option for debugging the typemap pattern matching rules.
Documented in Typemaps.html.
2009-12-12: wsfulton
[Octave] Remove the -api option and use the new OCTAVE_API_VERSION_NUMBER
macro provided in the octave headers for determining the api version instead.
2009-12-04: olly
[Ruby] Improve support for Ruby 1.9 under GCC. Addresses part of
SF#2859614.
2009-12-04: olly
Fix handling of modulo operator (%) in constant expressions
(SF#2818562).
2009-12-04: olly
[PHP] "empty" is a reserved word in PHP, so rename empty() method
on STL classes to "is_empty()" (previously this was automatically
renamed to "c_empty()").
*** POTENTIAL INCOMPATIBILITY ***
2009-12-03: olly
[PHP] Add typemaps for long long and unsigned long long, and for
pointer to method.
2009-12-02: olly
[PHP] Fix warning and rename of reserved class name to be case
insensitive.
2009-12-01: wsfulton
Revert support for %extend and memberin typemaps added in swig-1.3.39. The
memberin typemaps are ignored again for member variables within a %extend block.
Documentation inconsistency reported by Torsten Landschoff.
2009-11-29: wsfulton
[Java, C#] Fix generated quoting when using %javaconst(1)/%csconst(1) for
static const char member variables.
%javaconst(1) A;
%csconst(1) A;
struct X {
static const char A = 'A';
};
2009-11-26: wsfulton
[Java, C#] Fix %javaconst(1)/%csconst(1) for static const member variables to
use the actual constant value if it is specified, rather than the C++ code to
access the member.
%javaconst(1) EN;
%csconst(1) EN;
struct X {
static const int EN = 2;
};
2009-11-23: wsfulton
C++ nested typedef classes can now be handled too, for example:
struct Outer {
typedef Foo { } FooTypedef1, FooTypedef2;
};
2009-11-18: wsfulton
The wrappers for C nested structs are now generated in the same order as declared
in the parsed code.
2009-11-18: wsfulton
Fix #491476 - multiple declarations of nested structs, for example:
struct Outer {
struct {
int val;
} inner1, inner2, *inner3, inner4[1];
} outer;
2009-11-17: wsfulton
Fix parsing of enum declaration and initialization, for example:
enum ABC {
a,
b,
c
} A = a, *pC = &C, array[3] = {a, b, c};
2009-11-17: wsfulton
Fix parsing of struct declaration and initialization, for example:
struct S {
int x;
} instance = { 10 };
2009-11-15: wsfulton
Fix #1960977 - Syntax error parsing derived nested class declaration and member
variable instance.
2009-11-14: wsfulton
Fix #2310483 - function pointer typedef within extern "C" block.
2009-11-13: wsfulton
Fix usage of nested template classes within templated classes so that compileable code
is generated.
2009-11-13: olly
[php] Fix place where class prefix (as specified with -prefix)
wasn't being used. Patch from gverbruggen in SF#2892647.
2009-11-12: wsfulton
Fix usage of nested template classes so that compileable code is generated - the nested
template class is now treated like a normal nested classes, that is, as an opaque type
unless the nestedworkaround feature is used.
2009-11-12: wsfulton
Replace SWIGWARN_PARSE_NESTED_CLASS with SWIGWARN_PARSE_NAMED_NESTED_CLASS and
SWIGWARN_PARSE_UNNAMED_NESTED_CLASS for named and unnamed nested classes respectively.
Named nested class ignored warnings can now be suppressed by name using %warnfilter, eg:
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner;
but clearly unnamed nested classes cannot and the global suppression is still required, eg:
#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
2009-11-11: wsfulton
Added the nestedworkaround feature as a way to use the full functionality of a nested class
(C++ mode only). It removes the nested class from SWIG's type information so it is as if SWIG
had never parsed the nested class. The documented nested class workarounds using a global
fake class stopped working when SWIG treated the nested class as an opaque pointer, and
this feature reverts this behaviour. The documentation has been updated with details of how
to use and implement it, see the "Nested classes" section in SWIGPlus.html.
2009-11-11: wsfulton
There were a number of C++ cases where nested classes/structs/unions were being handled
as if C code was being parsed which would oftentimes lead to uncompileable code as an
attempt was made to wrap the nested structs like it is documented for C code. Now all
nested structs/classes/unions are ignored in C++ mode, as was always documented. However,
there is an improvement as usage of nested structs/classes/unions is now always treated
as an opaque type by default, resulting in generated code that should always compile.
*** POTENTIAL INCOMPATIBILITY ***
2009-11-09: drjoe
Fix R for -fcompact and add std_map.i
2009-11-08: wsfulton
Fix inconsistency for nested structs/unions/classes. Uncompileable code was being
generated when inner struct and union declarations were used as types within the
inner struct. The inner struct/union is now treated as a forward declaration making the
behaviour the same as an inner class. (C++ code), eg:
struct Outer {
struct InnerStruct { int x; };
InnerStruct* getInnerStruct();
};
2009-11-08: wsfulton
Ignored nested class/struct warnings now display the name of the ignored class/struct.
2009-11-07: wsfulton
Bug #1514681 - Fix nested template classes within a namespace generated uncompileable
code and introduced strange side effects to other wrapper code especially code
after the nested template class. Note that nested template classes are still ignored.
2009-11-07: wsfulton
Add new debug options:
-debug-symtabs - Display symbol tables information
-debug-symbols - Display target language symbols in the symbol tables
-debug-csymbols - Display C symbols in the symbol tables
2009-11-03: wsfulton
Fix some usage of unary scope operator (::) denoting global scope, for example:
namespace AA { /* ... */ }
using namespace ::AA;
and bug #1816802 - SwigValueWrapper should be used:
struct CC {
CC(int); // no default constructor
};
::CC x();
and in template parameter specializations:
struct S {};
template <typename T> struct X { void a() {}; };
template <> struct X<S> { void b() {}; };
%template(MyTConcrete) X< ::S >;
plus probably some other corner case usage of ::.
2009-11-02: olly
[Python] Fix potential memory leak in initialisation code for the
generated module.
2009-10-23: wsfulton
Fix seg fault when using a named nested template instantiation using %template(name)
within a class. A warning that these are not supported is now issued plus processing
continues as if no name was given.
2009-10-20: wsfulton
[Python] Fix std::vector<const T*>. This would previously compile, but not run correctly.
2009-10-20: wsfulton
Fixed previously fairly poor template partial specialization and explicit
specialization support. Numerous bugs in this area have been fixed including:
- Template argument deduction implemented for template type arguments, eg this now
works:
template<typename T> class X {};
template<typename T> class X<T *> {};
%template(X1) X<const int *>; // Chooses T * specialization
and more complex cases with multiple parameters and a mix of template argument
deduction and explicitly specialised parameters, eg:
template <typename T1, typename T2> struct TwoParm { void a() {} };
template <typename T1> struct TwoParm<T1 *, int *> { void e() {} };
%template(E) TwoParm<int **, int *>;
Note that the primary template must now be in scope, like in C++, when
an explicit or partial specialization is instantiated with %template.
*** POTENTIAL INCOMPATIBILITY ***
2009-09-14: wsfulton
[C#] Add %csattributes for adding C# attributes to enum values, see docs for example.
2009-09-11: wsfulton
Fix memmove regression in cdata.i as reported by Adriaan Renting.
2009-09-07: wsfulton
Fix constant expressions containing <= or >=.
2009-09-02: wsfulton
The following operators in constant expressions now result in type bool for C++
wrappers and remain as type int for C wrappers, as per each standard:
&& || == != < > <= >= (Actually the last 4 are still broken). For example:
#define A 10
#define B 10
#define A_EQ_B A == B // now wrapped as type bool for C++
#define A_AND_B A && B // now wrapped as type bool for C++
2009-09-02: wsfulton
Fix #2845746. true and false are now recognised keywords (only when wrapping C++).
Constants such as the following are now wrapped (as type bool):
#define FOO true
#define BAR FOO && false
2010-06-10: olly
[PHP] Fix directors to correctly call a method with has a
different name in PHP to C++ (we were always using the C++ name
in this case).
2010-06-03: wsfulton
Fix uncompileable code when %rename results in two enum items
with the same name. Reported by Vadim Zeitlin.

View file

@ -29,7 +29,7 @@ Past SWIG developers and major contributors include:
Charlie Savage (cfis@interserv.com) (Ruby)
Thien-Thi Nguyen (ttn@glug.org) (build/test/misc)
Richard Palmer (richard@magicality.org) (PHP)
Sam Liddicott - Anonova Ltd (saml@liddicott.com) (PHP)
Sam Liddicott - Ananova Ltd (saml@liddicott.com) (PHP)
Tim Hockin - Sun Microsystems (thockin@sun.com) (PHP)
Kevin Ruland (PHP)
Shibukawa Yoshiki (Japanese Translation)
@ -58,6 +58,42 @@ Past SWIG developers and major contributors include:
Past contributors include:
James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran
Kovuk, Oleg Tolmatcev, Tal Shalif, Lluis Padro, Chris Seatory, Igor Bely, Robin Dunn
(See CHANGES and CHANGES.current for a more complete list).
Kovuk, Oleg Tolmatcev, Tal Shalif, Lluis Padro, Chris Seatory, Igor Bely, Robin Dunn,
Edward Zimmermann, David Ascher, Dominique Dumont, Pier Giorgio Esposito, Hasan Baran Kovuk,
Klaus Wiederänders
(See CHANGES and CHANGES.current and the bug tracker for a more complete list).
Past students:
Songyan Feng (Chicago).
Xinghua Shi (Chicago).
Jing Cao (Chicago).
Aquinas Hobor (Chicago).
Historically, the following people contributed to early versions of SWIG.
Peter Lomdahl, Brad Holian, Shujia Zhou, Niels Jensen, and Tim Germann
at Los Alamos National Laboratory were the first users. Patrick
Tullmann at the University of Utah suggested the idea of automatic
documentation generation. John Schmidt and Kurtis Bleeker at the
University of Utah tested out the early versions. Chris Johnson
supported SWIG's developed at the University of Utah. John Buckman,
Larry Virden, and Tom Schwaller provided valuable input on the first
releases and improving the portability of SWIG. David Fletcher and
Gary Holt have provided a great deal of input on improving SWIG's
Perl5 implementation. Kevin Butler contributed the first Windows NT
port.
Early bug reports and patches:
Adam Hupp, Arthur Smyles, Brad Clements, Brett Williams, Buck Hodges,
Burkhard Kloss, Chia-Liang Kao, Craig Files, Dennis Marsa, Dieter Baron,
Drake Diedrich, Fleur Diana Dragan, Gary Pennington, Geoffrey Hort, Gerald Williams,
Greg Anderson, Greg Kochanski, Greg Troxel, Henry Rowley, Irina Kotlova,
Israel Taller, James Bailey, Jim Fulton, Joel Reed, Jon Travis,
Junio Hamano, Justin Heyes-Jones, Karl Forner, Keith Davidson,
Krzysztof Kozminski, Larry Virden, Luke J Crook, Magnus Ljung, Marc Zonzon,
Mark Howson, Micahel Scharf, Michel Sanner, Mike Romberg, Mike Simons,
Mike Weiblen, Paul Brannan, Ram Bhamidipaty, Reinhard Fobbe, Rich Wales,
Richard Salz, Roy Lecates, Rudy Albachten, Scott Drummonds
Scott Michel, Shaun Lowry, Steve Galser, Tarn Weisner Burton,
Thomas Weidner, Tony Seward, Uwe Steinmann, Vadim Chugunov, Wyss Clemens,
Zhong Ren.

View file

@ -36,7 +36,7 @@ functions to mark whether or not a particular command line option was used. Thi
<h2>Argument Marking</h2>
As command line options are are processed by language modules, the following functions are used
As command line options are processed by language modules, the following functions are used
to mark the arguments as used:
<p>

View file

@ -119,22 +119,25 @@ are case-insensitive on Windows so this convention will prevent you from inadver
creating two files that differ in case-only.
<p>
Each file should include a short abstract, author information, copyright information, and
Each file should include a short abstract, license information and
a SVN revision tag like this:
<blockquote>
<pre>
/* -----------------------------------------------------------------------------
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
* This file is part of SWIG, which is licensed as a whole under version 3
* (or any later version) of the GNU General Public License. Some additional
* terms also apply to certain portions of SWIG. The full details of the SWIG
* license and copyrights can be found in the LICENSE and COPYRIGHT files
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
*
* cwrap.c
* xxx.c
*
* This file defines a variety of wrapping rules for C/C++ handling including
* the naming of local variables, calling conventions, and so forth.
* This file defines ...
* ----------------------------------------------------------------------------- */
char cvsroot_cwrap_c[] = "$Id$";
static char cvs[] = "&#36Id&#36 xxx.c";
#include "swig.h"

View file

@ -42,11 +42,9 @@ David M. Beazley <br>
</ul>
<li><a name="i3" href="#3">3. Types and Typemaps</a>
<li><a name="i4" href="#4">4. Parsing</a>
<li><a name="i5" href="#5">5. Difference Between SWIG 1.1 and SWIG 1.3</a>
<li><a name="i6" href="#6">6. Plans for SWIG 2.0</a>
<li><a name="i7" href="#7">7. C/C++ Wrapper Support Functions</a>
<li><a name="i8" href="#8">8. Symbol Naming Guidelines for Generated C/C++ Code</a>
<li><a name="i9" href="#9">9. Debugging SWIG</a>
<li><a name="i5" href="#5">5. C/C++ Wrapper Support Functions</a>
<li><a name="i6" href="#6">6. Symbol Naming Guidelines for Generated C/C++ Code</a>
<li><a name="i7" href="#7">7. Debugging SWIG</a>
</ul>
<a name="1" href="#i1">
@ -76,9 +74,8 @@ to code).
<tr><td>Examples</td>
<td>This subdir tree contains examples of using SWIG w/ different
scripting languages, including makefiles. Typically, there are the
"simple" and "matrix" examples, w/ some languages offering additional
examples. The GIFPlot example has its own set of per-language
subdirectories. See the README more index.html file in each directory
"simple" and "class" examples, w/ some languages offering additional
examples. See the README more index.html file in each directory
for more info. [FIXME: Ref SWIG user manual.]</td>
</tr>
@ -97,55 +94,35 @@ info.</td>
</tr>
<tr><td>Source</td>
<td>SWIG source code is in this subdir tree. Directories marked w/ "(*)"
are used in building the <tt>swig</tt> executable.
<td>The C and C++ source code for the <tt>swig</tt> executable is in this
subdir tree.</td>
<table border=1>
<tr><td>DOH (*)</td>
<tr><td>DOH</td>
<td>C library providing memory allocation, file access and generic
containers. Result: libdoh.a</td>
containers.</td>
</tr>
<tr><td>Experiment</td>
<td>[TODO]</td>
</tr>
<tr><td>Include (*)</td>
<tr><td>Include</td>
<td>Configuration .h files</td>
</tr>
<tr><td>LParse</td>
<td>Parser (lex / yacc) files and support [why not (*)?!]</td>
<tr><td>CParse</td>
<td>Parser (lex / yacc) files and support</td>
</tr>
<tr><td>Modules</td>
<td>[TODO]</td>
</tr>
<tr><td>Modules1.1 (*)</td>
<td>Language-specific callbacks that does actual code generation (each
language has a .cxx and a .h file). Result: libmodules11.a</td>
language has a .cxx and a .h file).</td>
</tr>
<tr><td>Preprocessor (*)</td>
<td>SWIG-specialized C/C++ preprocessor. Result: libcpp.a</td>
<tr><td>Preprocessor</td>
<td>SWIG-specialized C/C++ preprocessor.</td>
</tr>
<tr><td>SWIG1.1 (*)</td>
<td>Parts of SWIG that are not language-specific, including option
processing and the type-mapping system. Result: libswig11.a.
Note: This directory is currently being phased out. </td>
</tr>
<tr><td>SWIG1.3</td>
<td>[TODO] [funny, nothing here is presently used for swig-1.3].
This directory might turn into a compatibility interface between
SWIG1.3 and the SWIG1.1 modules.</td>
</tr>
<tr><td>Swig (*)</td>
<td>This directory contains the new ANSI C core of the system
<tr><td>Swig</td>
<td>This directory contains the ANSI C core of the system
and contains generic functions related to types, file handling,
scanning, and so forth.</td>
</tr>
@ -154,7 +131,7 @@ are used in building the <tt>swig</tt> executable.
</tr>
<tr><td>Tools</td>
<td>Libtool support and the mkdist.py script.</td>
<td>The mkdist.py script and other tools.</td>
</tr>
<tr><td>Win</td>
@ -173,14 +150,14 @@ to look for code:
<ul>
<li> <tt>Modules1.1/swigmain.cxx:main()</tt> is the program entry
<li> <tt>Modules/swigmain.cxx:main()</tt> is the program entry
point. It parses the language-specifying command-line option (for
example, <tt>-java</tt>), creating a new language-specific wrapping
object (each language is a C++ class derived from base class
<tt>Language</tt>). This object and the command-line is passed to
<tt>SWIG_main()</tt>, whose return value is the program exit value.
<li> <tt>SWIG1.1/main.cxx:SWIG_main()</tt> is the "real" main. It
<li> <tt>Modules/main.cxx:SWIG_main()</tt> is the "real" main. It
initializes the preprocessor and typemap machinery, defines some
preprocessor symbols, locates the SWIG library, processes common
command-line options, and then calls the language-specific command-line
@ -203,7 +180,7 @@ included <tt>-freeze</tt>, go into an infinite loop; otherwise return the
error count.
<li> The language-specific <tt>parse()</tt> (and all other
language-specific code) lives in <tt>Modules1.1/foo.{h,cxx}</tt> for
language-specific code) lives in <tt>Modules/foo.{h,cxx}</tt> for
language Foo. Typically, <tt>FOO::parse()</tt> calls
<tt>FOO::headers()</tt> and then the global function <tt>yyparse()</tt>,
which uses the callbacks registered by <tt>SWIG_main()</tt> above.
@ -553,8 +530,7 @@ list item: listval5
The representation and manipulation of types is currently in the
process of being reorganized and (hopefully) simplified. The
following list describes the current set of functions that are used to
manipulate datatypes. These functions are different than in
SWIG1.1 and may change names in the final SWIG1.3 release.
manipulate datatypes.
<ul>
<li><tt>SwigType_str(SwigType *t, char *name)</tt>.<br>
@ -710,19 +686,7 @@ repeated calls without making any copies.
[TODO]
<a name="5" href="#i5">
<h2>5. Difference Between SWIG 1.1 and SWIG 1.3</h2>
</a>
[TODO]
<a name="6" href="#i6">
<h2>6. Plans for SWIG 2.0</h2>
</a>
[TODO]
<a name="7" href="#i7">
<h2>7. The C/C++ Wrapping Layer</h2>
<h2>5. The C/C++ Wrapping Layer</h2>
</a>
Added: Dave Beazley (July 22, 2000)
@ -1001,8 +965,8 @@ for specifying local variable declarations and argument conversions.
<a name="8" href="#i8">
<h2>8. Symbol Naming Guidelines for Generated C/C++ Code</h2>
<a name="6" href="#i6">
<h2>6. Symbol Naming Guidelines for Generated C/C++ Code</h2>
</a>
The C++ standard (ISO/IEC 14882:1998(E)) states:
<blockquote>
@ -1048,8 +1012,8 @@ For code compiled as C or C++ that attempts to mangle a wrapped symbol:
In the past SWIG has generated many symbols which flout the standard especially double underscores. In fact they may not all be rooted out yet, so please fix them when you see them.
<a name="9" href="#i9">
<h2>9. Debugging SWIG</h2>
<a name="7" href="#i7">
<h2>7. Debugging SWIG</h2>
</a>
Warning. Debugging SWIG is for the very patient.
<p>
@ -1100,7 +1064,7 @@ Please also read the Debugging Functions section in <a href="tree.html">SWIG Par
</p>
<hr>
Copyright (C) 1999-2004 SWIG Development Team.
Copyright (C) 1999-2010 SWIG Development Team.
</body>
</html>

View file

@ -77,7 +77,7 @@ string prior to using this function.
Pushes a token into the scanner. This exact token will be returned by the next call to <tt>Scanner_token()</tt>.
<tt>tokvalue</tt> is the integer token value to return and <tt>val</tt> is the token text to return. This
function is only used to handle very special parsing cases. For instance, if you need the scanner to
return a ficticious token into order to enter a special parsing case.
return a fictitious token into order to enter a special parsing case.
</blockquote>
<p>
@ -238,7 +238,7 @@ SWIG_TOKEN_PERIOD .
SWIG_TOKEN_AT @
SWIG_TOKEN_DOLLAR $
SWIG_TOKEN_ENDLINE Literal newline
SWIG_TOKEN_ID identifer
SWIG_TOKEN_ID identifier
SWIG_TOKEN_FLOAT Floating point with F suffix (e.g., 3.1415F)
SWIG_TOKEN_DOUBLE Floating point (e.g., 3.1415 )
SWIG_TOKEN_INT Integer (e.g., 314)
@ -281,8 +281,3 @@ using these functions to write a yacc-compatible lexer.
</body>
</html>

View file

@ -8,7 +8,7 @@
<body bgcolor="#ffffff">
<H1><a name="Allegrocl_nn1"></a>17 SWIG and Allegro Common Lisp</H1>
<H1><a name="Allegrocl"></a>17 SWIG and Allegro Common Lisp</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@ -1777,7 +1777,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
</div>
<p>
These three typemaps are specifically employed by the the
These three typemaps are specifically employed by the
Allegro CL interface generator. SWIG also implements a number of
other typemaps that can be used for generating code in the C/C++
wrappers. You can read about

View file

@ -81,7 +81,7 @@ One way to deal with this is to use the
%include "typemaps.i"
%apply double *OUTPUT { double *result };
%inlne %{
%inline %{
extern void add(double a, double b, double *result);
%}
</pre></div>

View file

@ -9,35 +9,36 @@
<!-- INDEX -->
<div class="sectiontoc">
<ul>
<li><a href="#csharp_introduction">Introduction</a>
<li><a href="#csharp_differences_java">Differences to the Java module</a>
<li><a href="#CSharp_introduction">Introduction</a>
<li><a href="#CSharp_differences_java">Differences to the Java module</a>
<li><a href="#CSharp_arrays">C# Arrays</a>
<ul>
<li><a href="#CSharp_arrays_swig_library">The SWIG C arrays library</a>
<li><a href="#CSharp_arrays_pinvoke_default_array_marshalling">Managed arrays using P/Invoke default array marshalling</a>
<li><a href="#CSharp_arrays_pinning">Managed arrays using pinning</a>
</ul>
<li><a href="#csharp_exceptions">C# Exceptions</a>
<li><a href="#CSharp_exceptions">C# Exceptions</a>
<ul>
<li><a href="#csharp_exception_example_check_typemap">C# exception example using "check" typemap</a>
<li><a href="#csharp_exception_example_percent_exception">C# exception example using %exception</a>
<li><a href="#csharp_exception_example_exception_specifications">C# exception example using exception specifications</a>
<li><a href="#csharp_custom_application_exception">Custom C# ApplicationException example</a>
<li><a href="#CSharp_exception_example_check_typemap">C# exception example using "check" typemap</a>
<li><a href="#CSharp_exception_example_percent_exception">C# exception example using %exception</a>
<li><a href="#CSharp_exception_example_exception_specifications">C# exception example using exception specifications</a>
<li><a href="#CSharp_custom_application_exception">Custom C# ApplicationException example</a>
</ul>
<li><a href="#csharp_directors">C# Directors</a>
<li><a href="#CSharp_directors">C# Directors</a>
<ul>
<li><a href="#csharp_directors_example">Directors example</a>
<li><a href="#csharp_directors_implementation">Directors implementation</a>
<li><a href="#csharp_director_caveats">Director caveats</a>
<li><a href="#CSharp_directors_example">Directors example</a>
<li><a href="#CSharp_directors_implementation">Directors implementation</a>
<li><a href="#CSharp_director_caveats">Director caveats</a>
</ul>
<li><a href="#csharp_typemap_examples">C# Typemap examples</a>
<li><a href="#CSharp_typemap_examples">C# Typemap examples</a>
<ul>
<li><a href="#csharp_memory_management_member_variables">Memory management when returning references to member variables</a>
<li><a href="#csharp_memory_management_objects">Memory management for objects passed to the C++ layer</a>
<li><a href="#csharp_date_marshalling">Date marshalling using the csin typemap and associated attributes</a>
<li><a href="#csharp_date_properties">A date example demonstrating marshalling of C# properties</a>
<li><a href="#csharp_partial_classes">Turning wrapped classes into partial classes</a>
<li><a href="#csharp_extending_proxy_class">Extending proxy classes with additional C# code</a>
<li><a href="#CSharp_memory_management_member_variables">Memory management when returning references to member variables</a>
<li><a href="#CSharp_memory_management_objects">Memory management for objects passed to the C++ layer</a>
<li><a href="#CSharp_date_marshalling">Date marshalling using the csin typemap and associated attributes</a>
<li><a href="#CSharp_date_properties">A date example demonstrating marshalling of C# properties</a>
<li><a href="#CSharp_partial_classes">Turning wrapped classes into partial classes</a>
<li><a href="#CSharp_extending_proxy_class">Extending proxy classes with additional C# code</a>
<li><a href="#CSharp_enum_underlying_type">Underlying type for enums</a>
</ul>
</ul>
</div>
@ -45,7 +46,7 @@
<H2><a name="csharp_introduction"></a>18.1 Introduction</H2>
<H2><a name="CSharp_introduction"></a>18.1 Introduction</H2>
<p>
@ -54,7 +55,7 @@ The wrapper code implementation uses C# and the Platform Invoke (PInvoke) interf
The PInvoke interface has been chosen over Microsoft's Managed C++ interface as it is portable to both Microsoft Windows and non-Microsoft platforms.
PInvoke is part of the ECMA/ISO C# specification.
It is also better suited for robust production environments due to the Managed C++ flaw called the
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vcconMixedDLLLoadingProblem.asp">Mixed DLL Loading Problem</a>.
<a href="http://msdn.microsoft.com/en-us/library/aa290048(VS.71).aspx">Mixed DLL Loading Problem</a>.
SWIG C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using
<a href="http://www.mono-project.com/">Mono</a> and <a href="http://www.dotgnu.org/pnet.html">Portable.NET</a>.
</p>
@ -65,7 +66,7 @@ The <a href="http://msdn.microsoft.com">Microsoft Developer Network (MSDN)</a> h
Monodoc, available from the Mono project, has a very useful section titled <a href="http://www.mono-project.com/Interop_with_Native_Libraries">Interop with native libraries</a>.
</p>
<H2><a name="csharp_differences_java"></a>18.2 Differences to the Java module</H2>
<H2><a name="CSharp_differences_java"></a>18.2 Differences to the Java module</H2>
<p>
@ -102,6 +103,11 @@ namespace com.bloggs.widget {
Note that by default, the generated C# classes have no namespace and the module name is unrelated to namespaces. The module name is just like in Java and is merely used to name some of the generated classes.
</li>
<li>
The <a href="SWIGPlus.html#SWIGPlus_nspace">nspace feature</a> is also supported as described in this general section with a C# example.
Unlike Java which requires the use of the -package option when using the <tt>nspace</tt> feature, the -namespace option is not mandatory for C#.
</li>
<li>
The <tt>-dllimport &lt;name&gt;</tt> commandline option specifies the name of the DLL for the <tt>DllImport</tt> attribute for every PInvoke method. If this commandline option is not given, the <tt>DllImport</tt> DLL name is the same as the module name. This option is useful for when one wants to invoke SWIG multiple times on different modules, yet compile all the resulting code into a single DLL.
</li>
@ -132,7 +138,7 @@ If it was used, it would generate an illegal runtime initialisation via a PInvok
C# doesn't support the notion of throws clauses.
Therefore there is no 'throws' typemap attribute support for adding exception classes to a throws clause.
Likewise there is no need for an equivalent to <tt>%javaexception</tt>.
In fact, throwing C# exceptions works quite differently, see <a href="CSharp.html#csharp_exceptions">C# Exceptions</a> below.
In fact, throwing C# exceptions works quite differently, see <a href="CSharp.html#CSharp_exceptions">C# Exceptions</a> below.
</li>
<li>
@ -201,6 +207,7 @@ jniclassinterfaces -&gt; imclassinterfaces
$javaclassname -&gt; $csclassname
$&amp;javaclassname -&gt; $&amp;csclassname
$*javaclassname -&gt; $*csclassname
$javaclazzname -&gt; $csclazzname
$javainput -&gt; $csinput
$jnicall -&gt; $imcall
</pre></div>
@ -210,10 +217,10 @@ $jnicall -&gt; $imcall
<p>
Unlike the "javain" typemap, the "csin" typemap does not support the 'pgcpp' attribute as the C# module does not have a premature garbage collection prevention parameter.
The "csin" typemap supports additional optional attributes called 'cshin' and 'terminator'.
The 'cshin' attribute should contain the parameter type and name whenever a <a href="Java.html#java_constructor_helper_function">constructor helper function</a> is generated due to the 'pre' or 'post' attributes.
The 'cshin' attribute should contain the parameter type and name whenever a <a href="Java.html#Java_constructor_helper_function">constructor helper function</a> is generated due to the 'pre' or 'post' attributes.
The 'terminator' attribute normally just contains a closing brace for when the 'pre' attribute contains an opening brace, such as when a C# <tt>using</tt> or <tt>fixed</tt> block is started.
Note that 'pre', 'post', 'terminator' and 'cshin' attributes are not used for marshalling the property set.
Please see the <a href="#csharp_date_marshalling">Date marshalling example</a> and <a href="#csharp_date_properties">Date marshalling of properties example</a> for further understanding of these "csin" applicable attributes.
Please see the <a href="#CSharp_date_marshalling">Date marshalling example</a> and <a href="#CSharp_date_properties">Date marshalling of properties example</a> for further understanding of these "csin" applicable attributes.
</p>
</li>
@ -250,7 +257,7 @@ public static extern IntPtr function(string jarg1);
Support for type attributes.
The 'imtype' and 'cstype' typemaps can have an optional <tt>inattributes</tt> and <tt>outattributes</tt> typemap attribute.
The 'imtype' typemap can also have an optional <tt>directorinattributes</tt> and <tt>directoroutattributes</tt>
typemap attribute which attaches to director delegates, an implementation detail of directors, see <a href="#csharp_directors_implementation">directors implementation</a>.
typemap attribute which attaches to director delegates, an implementation detail of directors, see <a href="#CSharp_directors_implementation">directors implementation</a>.
Note that there are C# attributes and typemap attributes, don't get confused between the two!!
The C# attributes specified in these typemap attributes are generated wherever the type is used in the C# wrappers.
These can be used to specify any C# attribute associated with a C/C++ type, but are more typically used for the C# <tt>MarshalAs</tt> attribute.
@ -305,7 +312,7 @@ The <tt>directorinattributes</tt> and <tt>directoroutattributes</tt> typemap att
<li>
<p>
Support for attaching C# attributes to wrapped methods, variables and enum values.
This is done using the <tt>%csattributes</tt> feature, see <a href="Customization.html#features">%feature directives</a>.
This is done using the <tt>%csattributes</tt> feature, see <a href="Customization.html#Customization_features">%feature directives</a>.
Note that C# attributes are attached to proxy classes and enums using the <tt>csattributes</tt> typemap.
For example, imagine we have a custom attribute class, <tt>ThreadSafeAttribute</tt>, for labelling thread safety.
The following SWIG code shows how to attach this C# attribute to some methods and the class declaration itself:
@ -401,7 +408,7 @@ This feature is useful for some obscure cases where SWIG might get the <tt>virtu
</li>
<li>
<a name="csharp_module_directive"></a>
<a name="CSharp_module_directive"></a>
<p>
The name of the intermediary class can be changed from its default, that is, the module name with PINVOKE appended after it.
The module directive attribute <tt>imclassname</tt> is used to achieve this:
@ -436,7 +443,7 @@ if specified, otherwise it is equivalent to the <b>$module</b> special variable.
<p>
<b><tt>$imclassname</tt></b><br>
This special variable expands to the intermediary class name. For C# this is usually the same as '$modulePINVOKE' ('$moduleJNI' for Java),
unless the imclassname attribute is specified in the <a href="CSharp.html#csharp_module_directive">%module directive</a>.
unless the imclassname attribute is specified in the <a href="CSharp.html#CSharp_module_directive">%module directive</a>.
</p>
<p>
@ -505,7 +512,7 @@ In the P/Invoke default marshalling scheme, one needs to designate whether the i
array parameter as input, output, or both. When the function is invoked, the CLR allocates a separate chunk of memory as big as the given managed array,
which is automatically released at the end of the function call. If the array parameter is marked as being input, the content of the managed array is copied
into this buffer when the call is made. Correspondingly, if the array parameter is marked as being output, the contents of the reserved buffer are copied
back into the managed array after the call returns. A pointer to to this buffer
back into the managed array after the call returns. A pointer to this buffer
is passed to the native function.
</p>
@ -716,7 +723,7 @@ public static extern void myArrayCopy(IntPtr jarg1, IntPtr jarg2, int jarg3);
<H2><a name="csharp_exceptions"></a>18.4 C# Exceptions</H2>
<H2><a name="CSharp_exceptions"></a>18.4 C# Exceptions</H2>
<p>
@ -724,7 +731,7 @@ It is possible to throw a C# Exception from C/C++ code.
SWIG already provides the framework for throwing C# exceptions if it is able to detect that a C++ exception could be thrown.
Automatically detecting that a C++ exception could be thrown is only possible when a C++ exception specification is used,
see <a href="SWIGPlus.html#SWIGPlus_exception_specifications">Exception specifications</a>.
The <a href="Customization.html#exception">Exception handling with %exception</a> section details the <tt>%exception</tt> feature.
The <a href="Customization.html#Customization_exception">Exception handling with %exception</a> section details the <tt>%exception</tt> feature.
Customised code for handling exceptions with or without a C++ exception specification is possible and the details follow.
However anyone wishing to do this should be familiar with the contents of the sections referred to above.
</p>
@ -813,7 +820,7 @@ set so should only be used when a C# exception is not created.
</p>
<H3><a name="csharp_exception_example_check_typemap"></a>18.4.1 C# exception example using "check" typemap</H3>
<H3><a name="CSharp_exception_example_check_typemap"></a>18.4.1 C# exception example using "check" typemap</H3>
<p>
@ -995,12 +1002,12 @@ method and C# code does not handle pending exceptions via the canthrow attribute
Actually it will issue this warning for any function beginning with <tt>SWIG_CSharpSetPendingException</tt>.
</P>
<H3><a name="csharp_exception_example_percent_exception"></a>18.4.2 C# exception example using %exception</H3>
<H3><a name="CSharp_exception_example_percent_exception"></a>18.4.2 C# exception example using %exception</H3>
<p>
Let's consider a similar, but more common example that throws a C++ exception from within a wrapped function.
We can use <tt>%exception</tt> as mentioned in <a href="Customization.html#exception">Exception handling with %exception</a>.
We can use <tt>%exception</tt> as mentioned in <a href="Customization.html#Customization_exception">Exception handling with %exception</a>.
</p>
<div class="code">
@ -1060,7 +1067,7 @@ The managed code generated does check for the pending exception as mentioned ear
</pre>
</div>
<H3><a name="csharp_exception_example_exception_specifications"></a>18.4.3 C# exception example using exception specifications</H3>
<H3><a name="CSharp_exception_example_exception_specifications"></a>18.4.3 C# exception example using exception specifications</H3>
<p>
@ -1117,7 +1124,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) {
Multiple catch handlers are generated should there be more than one exception specifications declared.
</p>
<H3><a name="csharp_custom_application_exception"></a>18.4.4 Custom C# ApplicationException example</H3>
<H3><a name="CSharp_custom_application_exception"></a>18.4.4 Custom C# ApplicationException example</H3>
<p>
@ -1251,7 +1258,7 @@ try {
</pre>
</div>
<H2><a name="csharp_directors"></a>18.5 C# Directors</H2>
<H2><a name="CSharp_directors"></a>18.5 C# Directors</H2>
<p>
@ -1261,10 +1268,10 @@ Essentially, it enables unmanaged C++ code to call back into managed code for vi
<p>
The following sections provide information on the C# director implementation and contain most of the information required to use the C# directors.
However, the <a href="Java.html#java_directors">Java directors</a> section should also be read in order to gain more insight into directors.
However, the <a href="Java.html#Java_directors">Java directors</a> section should also be read in order to gain more insight into directors.
</p>
<H3><a name="csharp_directors_example"></a>18.5.1 Directors example</H3>
<H3><a name="CSharp_directors_example"></a>18.5.1 Directors example</H3>
<p>
@ -1385,7 +1392,7 @@ CSharpDerived - UIntMethod(123)
</pre>
</div>
<H3><a name="csharp_directors_implementation"></a>18.5.2 Directors implementation</H3>
<H3><a name="CSharp_directors_implementation"></a>18.5.2 Directors implementation</H3>
<p>
@ -1571,7 +1578,7 @@ void SwigDirector_Base::BaseBoolMethod(Base const &amp;b, bool flag) {
</pre>
</div>
<H3><a name="csharp_director_caveats"></a>18.5.3 Director caveats</H3>
<H3><a name="CSharp_director_caveats"></a>18.5.3 Director caveats</H3>
<p>
@ -1619,7 +1626,7 @@ However, a call from C# to <tt>CSharpDefaults.DefaultMethod()</tt> will of cours
should pass the call on to <tt>CSharpDefaults.DefaultMethod(int)</tt>using the C++ default value, as shown above.
</p>
<H2><a name="csharp_typemap_examples"></a>18.6 C# Typemap examples</H2>
<H2><a name="CSharp_typemap_examples"></a>18.6 C# Typemap examples</H2>
This section includes a few examples of typemaps. For more examples, you
@ -1627,12 +1634,12 @@ might look at the files "<tt>csharp.swg</tt>" and "<tt>typemaps.i</tt>" in
the SWIG library.
<H3><a name="csharp_memory_management_member_variables"></a>18.6.1 Memory management when returning references to member variables</H3>
<H3><a name="CSharp_memory_management_member_variables"></a>18.6.1 Memory management when returning references to member variables</H3>
<p>
This example shows how to prevent premature garbage collection of objects when the underlying C++ class returns a pointer or reference to a member variable.
The example is a direct equivalent to this <a href="Java.html#java_memory_management_objects">Java equivalent</a>.
The example is a direct equivalent to this <a href="Java.html#Java_memory_management_objects">Java equivalent</a>.
</p>
<p>
@ -1751,11 +1758,11 @@ public class Bike : IDisposable {
Note the <tt>addReference</tt> call.
</p>
<H3><a name="csharp_memory_management_objects"></a>18.6.2 Memory management for objects passed to the C++ layer</H3>
<H3><a name="CSharp_memory_management_objects"></a>18.6.2 Memory management for objects passed to the C++ layer</H3>
<p>
The example is a direct equivalent to this <a href="Java.html#java_memory_management_objects">Java equivalent</a>.
The example is a direct equivalent to this <a href="Java.html#Java_memory_management_objects">Java equivalent</a>.
Managing memory can be tricky when using C++ and C# proxy classes.
The previous example shows one such case and this example looks at memory management for a class passed to a C++ method which expects the object to remain in scope
after the function has returned. Consider the following two C++ classes:
@ -1870,14 +1877,14 @@ The 'cscode' typemap simply adds in the specified code into the C# proxy class.
</div>
<H3><a name="csharp_date_marshalling"></a>18.6.3 Date marshalling using the csin typemap and associated attributes</H3>
<H3><a name="CSharp_date_marshalling"></a>18.6.3 Date marshalling using the csin typemap and associated attributes</H3>
<p>
The <a href="Java.html#nan_exception_typemap">NaN Exception example</a> is a simple example of the "javain" typemap and its 'pre' attribute.
The <a href="Java.html#Java_nan_exception_typemap">NaN Exception example</a> is a simple example of the "javain" typemap and its 'pre' attribute.
This example demonstrates how a C++ date class, say <tt>CDate</tt>, can be mapped onto the standard .NET date class,
<tt>System.DateTime</tt> by using the 'pre', 'post' and 'pgcppname' attributes of the "csin" typemap (the C# equivalent to the "javain" typemap).
The example is an equivalent to the <a href="Java.html#java_date_marshalling">Java Date marshalling example</a>.
The example is an equivalent to the <a href="Java.html#Java_date_marshalling">Java Date marshalling example</a>.
The idea is that the <tt>System.DateTime</tt> is used wherever the C++ API uses a <tt>CDate</tt>.
Let's assume the code being wrapped is as follows:
</p>
@ -2154,7 +2161,7 @@ public class example {
</pre>
</div>
<H3><a name="csharp_date_properties"></a>18.6.4 A date example demonstrating marshalling of C# properties</H3>
<H3><a name="CSharp_date_properties"></a>18.6.4 A date example demonstrating marshalling of C# properties</H3>
<p>
@ -2255,7 +2262,7 @@ Some points to note:
</ul>
<H3><a name="csharp_partial_classes"></a>18.6.5 Turning wrapped classes into partial classes</H3>
<H3><a name="CSharp_partial_classes"></a>18.6.5 Turning wrapped classes into partial classes</H3>
<p>
@ -2355,7 +2362,7 @@ demonstrating that the class contains methods calling both unmanaged code - <tt>
The following example is an alternative approach to adding managed code to the generated proxy class.
</p>
<H3><a name="csharp_extending_proxy_class"></a>18.6.6 Extending proxy classes with additional C# code</H3>
<H3><a name="CSharp_extending_proxy_class"></a>18.6.6 Extending proxy classes with additional C# code</H3>
<p>
@ -2394,6 +2401,38 @@ public class ExtendMe : IDisposable {
</pre>
</div>
<H3><a name="CSharp_enum_underlying_type"></a>18.6.7 Underlying type for enums</H3>
<P>
C# enums use int as the underlying type for each enum item.
If you wish to change the underlying type to something else, then use the <tt>csbase</tt> typemap.
For example when your C++ code uses a value larget than int, this is necessary as the C# compiler will not compile values which are too large to fit into an int.
Here is an example:
</p>
<div class="code">
<pre>
%typemap(csbase) BigNumbers "uint"
%inline %{
enum BigNumbers { big=0x80000000, bigger };
%}
</pre>
</div>
<p>
The generated enum will then use the given underlying type and compile correctly:
</p>
<div class="code">
<pre>
public enum BigNumbers : uint {
big = 0x80000000,
bigger
}
</pre>
</div>
</body>
</html>

View file

@ -35,7 +35,7 @@
<li><a href="#Chicken_nn16">Typemaps</a>
<li><a href="#Chicken_nn17">Pointers</a>
<ul>
<li><a href="#collection">Garbage collection</a>
<li><a href="#Chicken_collection">Garbage collection</a>
</ul>
<li><a href="#Chicken_nn18">Unsupported features and known problems</a>
<ul>
@ -80,14 +80,13 @@
relies on some recent additions to CHICKEN, which are only
present in releases of CHICKEN with version number
<strong>greater than or equal to 1.89</strong>.
To use a chicken version between 1.40 and 1.89, see the <a href="#collection">Garbage collection</a>
To use a chicken version between 1.40 and 1.89, see the <a href="#Chicken_collection">Garbage collection</a>
section below.
</p>
<p>
You may want to look at any of the examples in Examples/chicken/
or Examples/GIFPlot/Chicken for the basic steps to run SWIG
CHICKEN.
directory for the basic steps to run SWIG CHICKEN.
</p>
<H3><a name="Chicken_nn3"></a>19.1.1 Running SWIG in C mode</H3>
@ -226,7 +225,7 @@
a function that must be called, the constant will appear as a
scheme variable. This causes the generated .scm file to just contain the code
<tt>(set! MYCONSTANT1 (MYCONSTANT1))</tt>. See
<a href="Customization.html#features">Features and the %feature directive</a>
<a href="Customization.html#Customization_features">Features and the %feature directive</a>
for info on how to apply the %feature.
</p>
@ -254,7 +253,7 @@
<p>The SWIG chicken module has support for exceptions thrown from
C or C++ code to be caught in scheme.
See <a href="Customization.html#exception">Exception handling with %exception</a>
See <a href="Customization.html#Customization_exception">Exception handling with %exception</a>
for more information about declaring exceptions in the interface file.
</p>
@ -263,7 +262,7 @@
inside the %exception blocks. <code>SWIG_exception</code> will throw a list consisting of the code
(as an integer) and the message. Both of these will throw an exception using <code>(abort)</code>,
which can be handled by <code>(handle-exceptions)</code>. See
<a href="http://www.call-with-current-continuation.org/manual/Exceptions.html#Exceptions">Chicken manual on Exceptions</a>
the Chicken manual on Exceptions
and <a href="http://srfi.schemers.org/srfi-12/srfi-12.html">SFRI-12</a>. Since the exception values are thrown
directly, if <code>(condition-case)</code> is used to catch an exception the exception will come through in the <code>val ()</code> case.
</p>
@ -417,8 +416,8 @@ $ csc -sv modname.scm modname_wrap.c modname_impl.c -o modname.so
</div>
<p>This library can then be loaded by scheme code with the <code>(require 'modname)</code> function.
See <a href="http://www.call-with-current-continuation.org/manual/Loading-extension-libraries.html">
Loading-extension-libraries</a> in the eval unit inside the CHICKEN manual for more information.</p>
See the
Loading-extension-libraries in the eval unit inside the CHICKEN manual for more information.</p>
<p>Another alternative is to run SWIG normally and create a scheme file that contains <code>(declare (uses <i>modname</i>))</code>
and then compile that file into the shared library as well. For example, inside the <tt>mod_load.scm</tt> file,</p>
@ -520,7 +519,7 @@ all the modules.</p>
type. flags is either zero or SWIG_POINTER_DISOWN (see below).
</p>
<H3><a name="collection"></a>19.6.1 Garbage collection</H3>
<H3><a name="Chicken_collection"></a>19.6.1 Garbage collection</H3>
<p>If the owner flag passed to <code>SWIG_NewPointerObj</code> is 1, <code>NewPointerObj</code> will add a
@ -531,12 +530,12 @@ all the modules.</p>
be garbage collected, SWIG will automatically set the owner flag to 1. For other functions,
the <code>%newobject</code> directive must be specified for functions whose return values
should be garbage collected. See
<a href="Customization.html#ownership">Object ownership and %newobject</a> for more information.
<a href="Customization.html#Customization_ownership">Object ownership and %newobject</a> for more information.
</p>
<p>In situations where a C or C++ function will assume ownership of a pointer, and thus
chicken should no longer garbage collect it, SWIG provides the <code>DISOWN</code> input typemap.
After applying this typemap (see the <a href="Typemaps.html">Typemaps chapter</a> for more information on how to apply typemaps),
After applying this typemap (see the <a href="Typemaps.html#Typemaps">Typemaps chapter</a> for more information on how to apply typemaps),
any pointer that gets passed in will no longer be garbage collected.
An object is disowned by passing the <code>SWIG_POINTER_DISOWN</code> flag to <code>SWIG_ConvertPtr</code>.
<b>Warning:</b> Since the lifetime of the object is now controlled by the underlying code, the object might

View file

@ -15,13 +15,12 @@
<div class="sectiontoc">
<ul>
<li><a href="Preface.html#Preface_nn2">Introduction</a>
<li><a href="Preface.html#Preface_nn3">Special Introduction for Version 1.3</a>
<li><a href="Preface.html#Preface_nn4">SWIG Versions</a>
<li><a href="Preface.html#Preface_nn5">SWIG resources</a>
<li><a href="Preface.html#Preface_nn6">Prerequisites</a>
<li><a href="Preface.html#Preface_nn7">Organization of this manual</a>
<li><a href="Preface.html#Preface_nn8">How to avoid reading the manual</a>
<li><a href="Preface.html#Preface_nn9">Backwards Compatibility</a>
<li><a href="Preface.html#Preface_nn9">Backwards compatibility</a>
<li><a href="Preface.html#Preface_nn10">Credits</a>
<li><a href="Preface.html#Preface_nn11">Bug reports</a>
</ul>
@ -122,7 +121,7 @@
<li><a href="SWIG.html#SWIG_nn2">Running SWIG</a>
<ul>
<li><a href="SWIG.html#SWIG_nn3">Input format</a>
<li><a href="SWIG.html#output">SWIG Output</a>
<li><a href="SWIG.html#SWIG_output">SWIG Output</a>
<li><a href="SWIG.html#SWIG_nn5">Comments</a>
<li><a href="SWIG.html#SWIG_nn6">C Preprocessor</a>
<li><a href="SWIG.html#SWIG_nn7">SWIG Directives</a>
@ -223,21 +222,24 @@
<ul>
<li><a href="SWIGPlus.html#SWIGPlus_nn24">Dispatch function generation</a>
<li><a href="SWIGPlus.html#SWIGPlus_nn25">Ambiguity in Overloading</a>
<li><a href="SWIGPlus.html#ambiguity_resolution_renaming">Ambiguity resolution and renaming</a>
<li><a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a>
<li><a href="SWIGPlus.html#SWIGPlus_nn27">Comments on overloading</a>
</ul>
<li><a href="SWIGPlus.html#SWIGPlus_nn28">Wrapping overloaded operators</a>
<li><a href="SWIGPlus.html#SWIGPlus_class_extension">Class extension</a>
<li><a href="SWIGPlus.html#SWIGPlus_nn30">Templates</a>
<li><a href="SWIGPlus.html#SWIGPlus_nn31">Namespaces</a>
<li><a href="SWIGPlus.html#SWIGPlus_namespaces">Namespaces</a>
<ul>
<li><a href="SWIGPlus.html#SWIGPlus_nspace">The nspace feature for namespaces</a>
</ul>
<li><a href="SWIGPlus.html#SWIGPlus_renaming_templated_types_namespaces">Renaming templated types in namespaces</a>
<li><a href="SWIGPlus.html#SWIGPlus_exception_specifications">Exception specifications</a>
<li><a href="SWIGPlus.html#SWIGPlus_catches">Exception handling with %catches</a>
<li><a href="SWIGPlus.html#SWIGPlus_nn33">Pointers to Members</a>
<li><a href="SWIGPlus.html#SWIGPlus_nn34">Smart pointers and operator-&gt;()</a>
<li><a href="SWIGPlus.html#SWIGPlus_smart_pointers">Smart pointers and operator-&gt;()</a>
<li><a href="SWIGPlus.html#SWIGPlus_nn35">Using declarations and inheritance</a>
<li><a href="SWIGPlus.html#SWIGPlus_nested_classes">Nested classes</a>
<li><a href="SWIGPlus.html#SWIGPlus_nn37">A brief rant about const-correctness</a>
<li><a href="SWIGPlus.html#SWIGPlus_const">A brief rant about const-correctness</a>
<li><a href="SWIGPlus.html#SWIGPlus_nn42">Where to go for more information</a>
</ul>
</div>
@ -285,9 +287,10 @@
</ul>
<li><a href="Library.html#Library_stl_cpp_library">STL/C++ Library</a>
<ul>
<li><a href="Library.html#Library_nn14">std_string.i</a>
<li><a href="Library.html#Library_nn15">std_vector.i</a>
<li><a href="Library.html#Library_std_string">std::string</a>
<li><a href="Library.html#Library_std_vector">std::vector</a>
<li><a href="Library.html#Library_stl_exceptions">STL exceptions</a>
<li><a href="Library.html#Library_std_shared_ptr">shared_ptr smart pointer</a>
</ul>
<li><a href="Library.html#Library_nn16">Utility Libraries</a>
<ul>
@ -333,6 +336,7 @@
<li><a href="Typemaps.html#Typemaps_nn6">Reusing typemaps</a>
<li><a href="Typemaps.html#Typemaps_nn7">What can be done with typemaps?</a>
<li><a href="Typemaps.html#Typemaps_nn8">What can't be done with typemaps?</a>
<li><a href="Typemaps.html#Typemaps_aspects">Similarities to Aspect Oriented Programming</a>
<li><a href="Typemaps.html#Typemaps_nn9">The rest of this chapter</a>
</ul>
<li><a href="Typemaps.html#Typemaps_nn10">Typemap specifications</a>
@ -346,10 +350,10 @@
<li><a href="Typemaps.html#Typemaps_pattern_matching">Pattern matching rules</a>
<ul>
<li><a href="Typemaps.html#Typemaps_nn17">Basic matching rules</a>
<li><a href="Typemaps.html#Typemaps_typedef_reductions">Typedef reductions</a>
<li><a href="Typemaps.html#Typemaps_nn19">Default typemaps</a>
<li><a href="Typemaps.html#Typemaps_mixed_default">Mixed default typemaps</a>
<li><a href="Typemaps.html#Typemaps_nn20">Multi-arguments typemaps</a>
<li><a href="Typemaps.html#Typemaps_typedef_reductions">Typedef reductions matching</a>
<li><a href="Typemaps.html#Typemaps_nn19">Default typemap matching rules</a>
<li><a href="Typemaps.html#Typemaps_multi_argument_typemaps_patterns">Multi-arguments typemaps</a>
<li><a href="Typemaps.html#Typemaps_matching_template_comparison">Matching rules compared to C++ templates</a>
<li><a href="Typemaps.html#Typemaps_debugging_search">Debugging typemap pattern matching</a>
</ul>
<li><a href="Typemaps.html#Typemaps_nn21">Code generation rules</a>
@ -387,14 +391,18 @@
<li><a href="Typemaps.html#Typemaps_nn43">Typemaps for multiple target languages</a>
<li><a href="Typemaps.html#Typemaps_optimal">Optimal code generation when returning by value</a>
<li><a href="Typemaps.html#Typemaps_multi_argument_typemaps">Multi-argument typemaps</a>
<li><a href="Typemaps.html#runtime_type_checker">The run-time type checker</a>
<li><a href="Typemaps.html#Typemaps_fragments">Typemap fragments</a>
<ul>
<li><a href="Typemaps.html#Typemaps_fragment_type_specialization">Fragment type specialization</a>
<li><a href="Typemaps.html#Typemaps_automatic_specialization">Fragments and automatic typemap specialization</a>
</ul>
<li><a href="Typemaps.html#Typemaps_runtime_type_checker">The run-time type checker</a>
<ul>
<li><a href="Typemaps.html#Typemaps_nn45">Implementation</a>
<li><a href="Typemaps.html#Typemaps_runtime_type_checker_usage">Usage</a>
</ul>
<li><a href="Typemaps.html#Typemaps_overloading">Typemaps and overloading</a>
<li><a href="Typemaps.html#Typemaps_nn48">More about <tt>%apply</tt> and <tt>%clear</tt></a>
<li><a href="Typemaps.html#Typemaps_nn49">Reducing wrapper code size</a>
<li><a href="Typemaps.html#Typemaps_nn47">Passing data between typemaps</a>
<li><a href="Typemaps.html#Typemaps_nn52">C++ "this" pointer</a>
<li><a href="Typemaps.html#Typemaps_nn51">Where to go for more information?</a>
@ -407,7 +415,7 @@
<!-- INDEX -->
<div class="sectiontoc">
<ul>
<li><a href="Customization.html#exception">Exception handling with %exception</a>
<li><a href="Customization.html#Customization_exception">Exception handling with %exception</a>
<ul>
<li><a href="Customization.html#Customization_nn3">Handling exceptions in C code</a>
<li><a href="Customization.html#Customization_nn4">Exception handling with longjmp()</a>
@ -417,14 +425,14 @@
<li><a href="Customization.html#Customization_exception_special_variables">Special variables for %exception</a>
<li><a href="Customization.html#Customization_nn7">Using The SWIG exception library</a>
</ul>
<li><a href="Customization.html#ownership">Object ownership and %newobject</a>
<li><a href="Customization.html#features">Features and the %feature directive</a>
<li><a href="Customization.html#Customization_ownership">Object ownership and %newobject</a>
<li><a href="Customization.html#Customization_features">Features and the %feature directive</a>
<ul>
<li><a href="Customization.html#Customization_feature_attributes">Feature attributes</a>
<li><a href="Customization.html#Customization_feature_flags">Feature flags</a>
<li><a href="Customization.html#Customization_clearing_features">Clearing features</a>
<li><a href="Customization.html#Customization_features_default_args">Features and default arguments</a>
<li><a href="Customization.html#features_example">Feature example</a>
<li><a href="Customization.html#Customization_features_example">Feature example</a>
</ul>
</ul>
</div>
@ -497,7 +505,7 @@
<li><a href="Modules.html#Modules_introduction">Modules Introduction</a>
<li><a href="Modules.html#Modules_nn1">Basics</a>
<li><a href="Modules.html#Modules_nn2">The SWIG runtime code</a>
<li><a href="Modules.html#external_run_time">External access to the runtime</a>
<li><a href="Modules.html#Modules_external_run_time">External access to the runtime</a>
<li><a href="Modules.html#Modules_nn4">A word of caution about static libraries</a>
<li><a href="Modules.html#Modules_nn5">References</a>
<li><a href="Modules.html#Modules_nn6">Reducing the wrapper file size</a>
@ -620,35 +628,36 @@
<!-- INDEX -->
<div class="sectiontoc">
<ul>
<li><a href="CSharp.html#csharp_introduction">Introduction</a>
<li><a href="CSharp.html#csharp_differences_java">Differences to the Java module</a>
<li><a href="CSharp.html#CSharp_introduction">Introduction</a>
<li><a href="CSharp.html#CSharp_differences_java">Differences to the Java module</a>
<li><a href="CSharp.html#CSharp_arrays">C# Arrays</a>
<ul>
<li><a href="CSharp.html#CSharp_arrays_swig_library">The SWIG C arrays library</a>
<li><a href="CSharp.html#CSharp_arrays_pinvoke_default_array_marshalling">Managed arrays using P/Invoke default array marshalling</a>
<li><a href="CSharp.html#CSharp_arrays_pinning">Managed arrays using pinning</a>
</ul>
<li><a href="CSharp.html#csharp_exceptions">C# Exceptions</a>
<li><a href="CSharp.html#CSharp_exceptions">C# Exceptions</a>
<ul>
<li><a href="CSharp.html#csharp_exception_example_check_typemap">C# exception example using "check" typemap</a>
<li><a href="CSharp.html#csharp_exception_example_percent_exception">C# exception example using %exception</a>
<li><a href="CSharp.html#csharp_exception_example_exception_specifications">C# exception example using exception specifications</a>
<li><a href="CSharp.html#csharp_custom_application_exception">Custom C# ApplicationException example</a>
<li><a href="CSharp.html#CSharp_exception_example_check_typemap">C# exception example using "check" typemap</a>
<li><a href="CSharp.html#CSharp_exception_example_percent_exception">C# exception example using %exception</a>
<li><a href="CSharp.html#CSharp_exception_example_exception_specifications">C# exception example using exception specifications</a>
<li><a href="CSharp.html#CSharp_custom_application_exception">Custom C# ApplicationException example</a>
</ul>
<li><a href="CSharp.html#csharp_directors">C# Directors</a>
<li><a href="CSharp.html#CSharp_directors">C# Directors</a>
<ul>
<li><a href="CSharp.html#csharp_directors_example">Directors example</a>
<li><a href="CSharp.html#csharp_directors_implementation">Directors implementation</a>
<li><a href="CSharp.html#csharp_director_caveats">Director caveats</a>
<li><a href="CSharp.html#CSharp_directors_example">Directors example</a>
<li><a href="CSharp.html#CSharp_directors_implementation">Directors implementation</a>
<li><a href="CSharp.html#CSharp_director_caveats">Director caveats</a>
</ul>
<li><a href="CSharp.html#csharp_typemap_examples">C# Typemap examples</a>
<li><a href="CSharp.html#CSharp_typemap_examples">C# Typemap examples</a>
<ul>
<li><a href="CSharp.html#csharp_memory_management_member_variables">Memory management when returning references to member variables</a>
<li><a href="CSharp.html#csharp_memory_management_objects">Memory management for objects passed to the C++ layer</a>
<li><a href="CSharp.html#csharp_date_marshalling">Date marshalling using the csin typemap and associated attributes</a>
<li><a href="CSharp.html#csharp_date_properties">A date example demonstrating marshalling of C# properties</a>
<li><a href="CSharp.html#csharp_partial_classes">Turning wrapped classes into partial classes</a>
<li><a href="CSharp.html#csharp_extending_proxy_class">Extending proxy classes with additional C# code</a>
<li><a href="CSharp.html#CSharp_memory_management_member_variables">Memory management when returning references to member variables</a>
<li><a href="CSharp.html#CSharp_memory_management_objects">Memory management for objects passed to the C++ layer</a>
<li><a href="CSharp.html#CSharp_date_marshalling">Date marshalling using the csin typemap and associated attributes</a>
<li><a href="CSharp.html#CSharp_date_properties">A date example demonstrating marshalling of C# properties</a>
<li><a href="CSharp.html#CSharp_partial_classes">Turning wrapped classes into partial classes</a>
<li><a href="CSharp.html#CSharp_extending_proxy_class">Extending proxy classes with additional C# code</a>
<li><a href="CSharp.html#CSharp_enum_underlying_type">Underlying type for enums</a>
</ul>
</ul>
</div>
@ -682,7 +691,7 @@
<li><a href="Chicken.html#Chicken_nn16">Typemaps</a>
<li><a href="Chicken.html#Chicken_nn17">Pointers</a>
<ul>
<li><a href="Chicken.html#collection">Garbage collection</a>
<li><a href="Chicken.html#Chicken_collection">Garbage collection</a>
</ul>
<li><a href="Chicken.html#Chicken_nn18">Unsupported features and known problems</a>
<ul>
@ -692,7 +701,36 @@
</div>
<!-- INDEX -->
<h3><a href="Guile.html#Guile">20 SWIG and Guile</a></h3>
<h3><a href="Go.html#Go">20 SWIG and Go</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
<li><a href="Go.html#Go_overview">Overview</a>
<li><a href="Go.html#Go_running_swig">Running SWIG with Go</a>
<ul>
<li><a href="Go.html#Go_commandline">Additional Commandline Options</a>
<li><a href="Go.html#Go_outputs">Go Output Files</a>
</ul>
<li><a href="Go.html#Go_basic_tour">A tour of basic C/C++ wrapping</a>
<ul>
<li><a href="Go.html#Go_package">Go Package Name</a>
<li><a href="Go.html#Go_names">Go Names</a>
<li><a href="Go.html#Go_constants">Go Constants</a>
<li><a href="Go.html#Go_enumerations">Go Enumerations</a>
<li><a href="Go.html#Go_classes">Go Classes</a>
<ul>
<li><a href="Go.html#Go_class_inheritance">Go Class Inheritance</a>
</ul>
<li><a href="Go.html#Go_templates">Go Templates</a>
<li><a href="Go.html#Go_director_classes">Go Director Classes</a>
<li><a href="Go.html#Go_primitive_type_mappings">Default Go primitive type mappings</a>
</ul>
</ul>
</div>
<!-- INDEX -->
<h3><a href="Guile.html#Guile">21 SWIG and Guile</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -727,149 +765,149 @@
</div>
<!-- INDEX -->
<h3><a href="Java.html#Java">21 SWIG and Java</a></h3>
<h3><a href="Java.html#Java">22 SWIG and Java</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
<li><a href="Java.html#java_overview">Overview</a>
<li><a href="Java.html#java_preliminaries">Preliminaries</a>
<li><a href="Java.html#Java_overview">Overview</a>
<li><a href="Java.html#Java_preliminaries">Preliminaries</a>
<ul>
<li><a href="Java.html#running_swig">Running SWIG</a>
<li><a href="Java.html#java_commandline">Additional Commandline Options</a>
<li><a href="Java.html#getting_right_headers">Getting the right header files</a>
<li><a href="Java.html#compiling_dynamic">Compiling a dynamic module</a>
<li><a href="Java.html#using_module">Using your module</a>
<li><a href="Java.html#dynamic_linking_problems">Dynamic linking problems</a>
<li><a href="Java.html#compilation_problems_cpp">Compilation problems and compiling with C++</a>
<li><a href="Java.html#building_windows">Building on Windows</a>
<li><a href="Java.html#Java_running_swig">Running SWIG</a>
<li><a href="Java.html#Java_commandline">Additional Commandline Options</a>
<li><a href="Java.html#Java_getting_right_headers">Getting the right header files</a>
<li><a href="Java.html#Java_compiling_dynamic">Compiling a dynamic module</a>
<li><a href="Java.html#Java_using_module">Using your module</a>
<li><a href="Java.html#Java_dynamic_linking_problems">Dynamic linking problems</a>
<li><a href="Java.html#Java_compilation_problems_cpp">Compilation problems and compiling with C++</a>
<li><a href="Java.html#Java_building_windows">Building on Windows</a>
<ul>
<li><a href="Java.html#visual_studio">Running SWIG from Visual Studio</a>
<li><a href="Java.html#nmake">Using NMAKE</a>
<li><a href="Java.html#Java_visual_studio">Running SWIG from Visual Studio</a>
<li><a href="Java.html#Java_nmake">Using NMAKE</a>
</ul>
</ul>
<li><a href="Java.html#java_basic_tour">A tour of basic C/C++ wrapping</a>
<li><a href="Java.html#Java_basic_tour">A tour of basic C/C++ wrapping</a>
<ul>
<li><a href="Java.html#module_packages_classes">Modules, packages and generated Java classes</a>
<li><a href="Java.html#functions">Functions</a>
<li><a href="Java.html#global_variables">Global variables</a>
<li><a href="Java.html#constants">Constants</a>
<li><a href="Java.html#enumerations">Enumerations</a>
<li><a href="Java.html#Java_module_packages_classes">Modules, packages and generated Java classes</a>
<li><a href="Java.html#Java_functions">Functions</a>
<li><a href="Java.html#Java_global_variables">Global variables</a>
<li><a href="Java.html#Java_constants">Constants</a>
<li><a href="Java.html#Java_enumerations">Enumerations</a>
<ul>
<li><a href="Java.html#anonymous_enums">Anonymous enums</a>
<li><a href="Java.html#typesafe_enums">Typesafe enums</a>
<li><a href="Java.html#proper_enums">Proper Java enums</a>
<li><a href="Java.html#typeunsafe_enums">Type unsafe enums</a>
<li><a href="Java.html#simple_enums">Simple enums</a>
<li><a href="Java.html#Java_anonymous_enums">Anonymous enums</a>
<li><a href="Java.html#Java_typesafe_enums">Typesafe enums</a>
<li><a href="Java.html#Java_proper_enums">Proper Java enums</a>
<li><a href="Java.html#Java_typeunsafe_enums">Type unsafe enums</a>
<li><a href="Java.html#Java_simple_enums">Simple enums</a>
</ul>
<li><a href="Java.html#pointers">Pointers</a>
<li><a href="Java.html#structures">Structures</a>
<li><a href="Java.html#classes">C++ classes</a>
<li><a href="Java.html#inheritance">C++ inheritance</a>
<li><a href="Java.html#pointers_refs_arrays">Pointers, references, arrays and pass by value</a>
<li><a href="Java.html#Java_pointers">Pointers</a>
<li><a href="Java.html#Java_structures">Structures</a>
<li><a href="Java.html#Java_classes">C++ classes</a>
<li><a href="Java.html#Java_inheritance">C++ inheritance</a>
<li><a href="Java.html#Java_pointers_refs_arrays">Pointers, references, arrays and pass by value</a>
<ul>
<li><a href="Java.html#null_pointers">Null pointers</a>
<li><a href="Java.html#Java_null_pointers">Null pointers</a>
</ul>
<li><a href="Java.html#overloaded_functions">C++ overloaded functions</a>
<li><a href="Java.html#java_default_arguments">C++ default arguments</a>
<li><a href="Java.html#namespaces">C++ namespaces</a>
<li><a href="Java.html#templates">C++ templates</a>
<li><a href="Java.html#smart_pointers">C++ Smart Pointers</a>
<li><a href="Java.html#Java_overloaded_functions">C++ overloaded functions</a>
<li><a href="Java.html#Java_default_arguments">C++ default arguments</a>
<li><a href="Java.html#Java_namespaces">C++ namespaces</a>
<li><a href="Java.html#Java_templates">C++ templates</a>
<li><a href="Java.html#Java_smart_pointers">C++ Smart Pointers</a>
</ul>
<li><a href="Java.html#further_details">Further details on the generated Java classes</a>
<li><a href="Java.html#Java_further_details">Further details on the generated Java classes</a>
<ul>
<li><a href="Java.html#imclass">The intermediary JNI class</a>
<li><a href="Java.html#Java_imclass">The intermediary JNI class</a>
<ul>
<li><a href="Java.html#imclass_pragmas">The intermediary JNI class pragmas</a>
<li><a href="Java.html#Java_imclass_pragmas">The intermediary JNI class pragmas</a>
</ul>
<li><a href="Java.html#java_module_class">The Java module class</a>
<li><a href="Java.html#Java_module_class">The Java module class</a>
<ul>
<li><a href="Java.html#module_class_pragmas">The Java module class pragmas</a>
<li><a href="Java.html#Java_module_class_pragmas">The Java module class pragmas</a>
</ul>
<li><a href="Java.html#java_proxy_classes">Java proxy classes</a>
<li><a href="Java.html#Java_proxy_classes">Java proxy classes</a>
<ul>
<li><a href="Java.html#memory_management">Memory management</a>
<li><a href="Java.html#inheritance_mirroring">Inheritance</a>
<li><a href="Java.html#proxy_classes_gc">Proxy classes and garbage collection</a>
<li><a href="Java.html#java_pgcpp">The premature garbage collection prevention parameter for proxy class marshalling</a>
<li><a href="Java.html#java_multithread_libraries">Single threaded applications and thread safety</a>
<li><a href="Java.html#Java_memory_management">Memory management</a>
<li><a href="Java.html#Java_inheritance_mirroring">Inheritance</a>
<li><a href="Java.html#Java_proxy_classes_gc">Proxy classes and garbage collection</a>
<li><a href="Java.html#Java_pgcpp">The premature garbage collection prevention parameter for proxy class marshalling</a>
<li><a href="Java.html#Java_multithread_libraries">Single threaded applications and thread safety</a>
</ul>
<li><a href="Java.html#type_wrapper_classes">Type wrapper classes</a>
<li><a href="Java.html#enum_classes">Enum classes</a>
<li><a href="Java.html#Java_type_wrapper_classes">Type wrapper classes</a>
<li><a href="Java.html#Java_enum_classes">Enum classes</a>
<ul>
<li><a href="Java.html#typesafe_enums_classes">Typesafe enum classes</a>
<li><a href="Java.html#proper_enums_classes">Proper Java enum classes</a>
<li><a href="Java.html#typeunsafe_enums_classes">Type unsafe enum classes</a>
<li><a href="Java.html#Java_typesafe_enums_classes">Typesafe enum classes</a>
<li><a href="Java.html#Java_proper_enums_classes">Proper Java enum classes</a>
<li><a href="Java.html#Java_typeunsafe_enums_classes">Type unsafe enum classes</a>
</ul>
</ul>
<li><a href="Java.html#java_directors">Cross language polymorphism using directors</a>
<li><a href="Java.html#Java_directors">Cross language polymorphism using directors</a>
<ul>
<li><a href="Java.html#java_enabling_directors">Enabling directors</a>
<li><a href="Java.html#java_directors_classes">Director classes</a>
<li><a href="Java.html#java_directors_overhead">Overhead and code bloat</a>
<li><a href="Java.html#java_directors_example">Simple directors example</a>
<li><a href="Java.html#java_directors_threading">Director threading issues</a>
<li><a href="Java.html#Java_enabling_directors">Enabling directors</a>
<li><a href="Java.html#Java_directors_classes">Director classes</a>
<li><a href="Java.html#Java_directors_overhead">Overhead and code bloat</a>
<li><a href="Java.html#Java_directors_example">Simple directors example</a>
<li><a href="Java.html#Java_directors_threading">Director threading issues</a>
</ul>
<li><a href="Java.html#java_allprotected">Accessing protected members</a>
<li><a href="Java.html#common_customization">Common customization features</a>
<li><a href="Java.html#Java_allprotected">Accessing protected members</a>
<li><a href="Java.html#Java_common_customization">Common customization features</a>
<ul>
<li><a href="Java.html#helper_functions">C/C++ helper functions</a>
<li><a href="Java.html#class_extension">Class extension with %extend</a>
<li><a href="Java.html#exception_handling">Exception handling with %exception and %javaexception</a>
<li><a href="Java.html#method_access">Method access with %javamethodmodifiers</a>
<li><a href="Java.html#Java_helper_functions">C/C++ helper functions</a>
<li><a href="Java.html#Java_class_extension">Class extension with %extend</a>
<li><a href="Java.html#Java_exception_handling">Exception handling with %exception and %javaexception</a>
<li><a href="Java.html#Java_method_access">Method access with %javamethodmodifiers</a>
</ul>
<li><a href="Java.html#tips_techniques">Tips and techniques</a>
<li><a href="Java.html#Java_tips_techniques">Tips and techniques</a>
<ul>
<li><a href="Java.html#input_output_parameters">Input and output parameters using primitive pointers and references</a>
<li><a href="Java.html#simple_pointers">Simple pointers</a>
<li><a href="Java.html#c_arrays">Wrapping C arrays with Java arrays</a>
<li><a href="Java.html#unbounded_c_arrays">Unbounded C Arrays</a>
<li><a href="Java.html#java_heap_allocations">Overriding new and delete to allocate from Java heap</a>
<li><a href="Java.html#Java_input_output_parameters">Input and output parameters using primitive pointers and references</a>
<li><a href="Java.html#Java_simple_pointers">Simple pointers</a>
<li><a href="Java.html#Java_c_arrays">Wrapping C arrays with Java arrays</a>
<li><a href="Java.html#Java_unbounded_c_arrays">Unbounded C Arrays</a>
<li><a href="Java.html#Java_heap_allocations">Overriding new and delete to allocate from Java heap</a>
</ul>
<li><a href="Java.html#java_typemaps">Java typemaps</a>
<li><a href="Java.html#Java_typemaps">Java typemaps</a>
<ul>
<li><a href="Java.html#default_primitive_type_mappings">Default primitive type mappings</a>
<li><a href="Java.html#Java_default_primitive_type_mappings">Default primitive type mappings</a>
<li><a href="Java.html#Java_default_non_primitive_typemaps">Default typemaps for non-primitive types</a>
<li><a href="Java.html#jvm64">Sixty four bit JVMs</a>
<li><a href="Java.html#what_is_typemap">What is a typemap?</a>
<li><a href="Java.html#typemaps_c_to_java_types">Typemaps for mapping C/C++ types to Java types</a>
<li><a href="Java.html#typemap_attributes">Java typemap attributes</a>
<li><a href="Java.html#special_variables">Java special variables</a>
<li><a href="Java.html#typemaps_for_c_and_cpp">Typemaps for both C and C++ compilation</a>
<li><a href="Java.html#java_code_typemaps">Java code typemaps</a>
<li><a href="Java.html#java_directors_typemaps">Director specific typemaps</a>
<li><a href="Java.html#Java_jvm64">Sixty four bit JVMs</a>
<li><a href="Java.html#Java_what_is_typemap">What is a typemap?</a>
<li><a href="Java.html#Java_typemaps_c_to_java_types">Typemaps for mapping C/C++ types to Java types</a>
<li><a href="Java.html#Java_typemap_attributes">Java typemap attributes</a>
<li><a href="Java.html#Java_special_variables">Java special variables</a>
<li><a href="Java.html#Java_typemaps_for_c_and_cpp">Typemaps for both C and C++ compilation</a>
<li><a href="Java.html#Java_code_typemaps">Java code typemaps</a>
<li><a href="Java.html#Java_directors_typemaps">Director specific typemaps</a>
</ul>
<li><a href="Java.html#typemap_examples">Typemap Examples</a>
<li><a href="Java.html#Java_typemap_examples">Typemap Examples</a>
<ul>
<li><a href="Java.html#simpler_enum_classes">Simpler Java enums for enums without initializers</a>
<li><a href="Java.html#exception_typemap">Handling C++ exception specifications as Java exceptions</a>
<li><a href="Java.html#nan_exception_typemap">NaN Exception - exception handling for a particular type</a>
<li><a href="Java.html#converting_java_string_arrays">Converting Java String arrays to char ** </a>
<li><a href="Java.html#expanding_java_object">Expanding a Java object to multiple arguments</a>
<li><a href="Java.html#using_typemaps_return_arguments">Using typemaps to return arguments</a>
<li><a href="Java.html#adding_downcasts">Adding Java downcasts to polymorphic return types</a>
<li><a href="Java.html#adding_equals_method">Adding an equals method to the Java classes</a>
<li><a href="Java.html#void_pointers">Void pointers and a common Java base class</a>
<li><a href="Java.html#struct_pointer_pointer">Struct pointer to pointer</a>
<li><a href="Java.html#java_memory_management_member_variables">Memory management when returning references to member variables</a>
<li><a href="Java.html#java_memory_management_objects">Memory management for objects passed to the C++ layer</a>
<li><a href="Java.html#java_date_marshalling">Date marshalling using the javain typemap and associated attributes</a>
<li><a href="Java.html#Java_simpler_enum_classes">Simpler Java enums for enums without initializers</a>
<li><a href="Java.html#Java_exception_typemap">Handling C++ exception specifications as Java exceptions</a>
<li><a href="Java.html#Java_nan_exception_typemap">NaN Exception - exception handling for a particular type</a>
<li><a href="Java.html#Java_converting_java_string_arrays">Converting Java String arrays to char ** </a>
<li><a href="Java.html#Java_expanding_java_object">Expanding a Java object to multiple arguments</a>
<li><a href="Java.html#Java_using_typemaps_return_arguments">Using typemaps to return arguments</a>
<li><a href="Java.html#Java_adding_downcasts">Adding Java downcasts to polymorphic return types</a>
<li><a href="Java.html#Java_adding_equals_method">Adding an equals method to the Java classes</a>
<li><a href="Java.html#Java_void_pointers">Void pointers and a common Java base class</a>
<li><a href="Java.html#Java_struct_pointer_pointer">Struct pointer to pointer</a>
<li><a href="Java.html#Java_memory_management_member_variables">Memory management when returning references to member variables</a>
<li><a href="Java.html#Java_memory_management_objects">Memory management for objects passed to the C++ layer</a>
<li><a href="Java.html#Java_date_marshalling">Date marshalling using the javain typemap and associated attributes</a>
</ul>
<li><a href="Java.html#java_directors_faq">Living with Java Directors</a>
<li><a href="Java.html#odds_ends">Odds and ends</a>
<li><a href="Java.html#Java_directors_faq">Living with Java Directors</a>
<li><a href="Java.html#Java_odds_ends">Odds and ends</a>
<ul>
<li><a href="Java.html#javadoc_comments">JavaDoc comments</a>
<li><a href="Java.html#functional_interface">Functional interface without proxy classes</a>
<li><a href="Java.html#using_own_jni_functions">Using your own JNI functions</a>
<li><a href="Java.html#performance">Performance concerns and hints</a>
<li><a href="Java.html#java_debugging">Debugging</a>
<li><a href="Java.html#Java_javadoc_comments">JavaDoc comments</a>
<li><a href="Java.html#Java_functional_interface">Functional interface without proxy classes</a>
<li><a href="Java.html#Java_using_own_jni_functions">Using your own JNI functions</a>
<li><a href="Java.html#Java_performance">Performance concerns and hints</a>
<li><a href="Java.html#Java_debugging">Debugging</a>
</ul>
<li><a href="Java.html#java_examples">Examples</a>
<li><a href="Java.html#Java_examples">Examples</a>
</ul>
</div>
<!-- INDEX -->
<h3><a href="Lisp.html#Lisp">22 SWIG and Common Lisp</a></h3>
<h3><a href="Lisp.html#Lisp">23 SWIG and Common Lisp</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -892,7 +930,7 @@
</div>
<!-- INDEX -->
<h3><a href="Lua.html#Lua">23 SWIG and Lua</a></h3>
<h3><a href="Lua.html#Lua">24 SWIG and Lua</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -949,48 +987,45 @@
</div>
<!-- INDEX -->
<h3><a href="Modula3.html#Modula3">24 SWIG and Modula-3</a></h3>
<h3><a href="Modula3.html#Modula3">25 SWIG and Modula-3</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
<li><a href="Modula3.html#modula3_overview">Overview</a>
<li><a href="Modula3.html#Modula3_modula3_overview">Overview</a>
<ul>
<li><a href="Modula3.html#whyscripting">Why not scripting ?</a>
<li><a href="Modula3.html#whymodula3">Why Modula-3 ?</a>
<li><a href="Modula3.html#whycpp">Why C / C++ ?</a>
<li><a href="Modula3.html#whyswig">Why SWIG ?</a>
<li><a href="Modula3.html#Modula3_motivation">Motivation</a>
</ul>
<li><a href="Modula3.html#conception">Conception</a>
<li><a href="Modula3.html#Modula3_conception">Conception</a>
<ul>
<li><a href="Modula3.html#cinterface">Interfaces to C libraries</a>
<li><a href="Modula3.html#cppinterface">Interfaces to C++ libraries</a>
<li><a href="Modula3.html#Modula3_cinterface">Interfaces to C libraries</a>
<li><a href="Modula3.html#Modula3_cppinterface">Interfaces to C++ libraries</a>
</ul>
<li><a href="Modula3.html#preliminaries">Preliminaries</a>
<li><a href="Modula3.html#Modula3_preliminaries">Preliminaries</a>
<ul>
<li><a href="Modula3.html#compilers">Compilers</a>
<li><a href="Modula3.html#commandline">Additional Commandline Options</a>
<li><a href="Modula3.html#Modula3_compilers">Compilers</a>
<li><a href="Modula3.html#Modula3_commandline">Additional Commandline Options</a>
</ul>
<li><a href="Modula3.html#modula3_typemaps">Modula-3 typemaps</a>
<li><a href="Modula3.html#Modula3_typemaps">Modula-3 typemaps</a>
<ul>
<li><a href="Modula3.html#inoutparam">Inputs and outputs</a>
<li><a href="Modula3.html#ordinals">Subranges, Enumerations, Sets</a>
<li><a href="Modula3.html#class">Objects</a>
<li><a href="Modula3.html#imports">Imports</a>
<li><a href="Modula3.html#exceptions">Exceptions</a>
<li><a href="Modula3.html#typemap_example">Example</a>
<li><a href="Modula3.html#Modula3_inoutparam">Inputs and outputs</a>
<li><a href="Modula3.html#Modula3_ordinals">Subranges, Enumerations, Sets</a>
<li><a href="Modula3.html#Modula3_class">Objects</a>
<li><a href="Modula3.html#Modula3_imports">Imports</a>
<li><a href="Modula3.html#Modula3_exceptions">Exceptions</a>
<li><a href="Modula3.html#Modula3_typemap_example">Example</a>
</ul>
<li><a href="Modula3.html#hints">More hints to the generator</a>
<li><a href="Modula3.html#Modula3_hints">More hints to the generator</a>
<ul>
<li><a href="Modula3.html#features">Features</a>
<li><a href="Modula3.html#pragmas">Pragmas</a>
<li><a href="Modula3.html#Modula3_features">Features</a>
<li><a href="Modula3.html#Modula3_pragmas">Pragmas</a>
</ul>
<li><a href="Modula3.html#remarks">Remarks</a>
<li><a href="Modula3.html#Modula3_remarks">Remarks</a>
</ul>
</div>
<!-- INDEX -->
<h3><a href="Mzscheme.html#Mzscheme">25 SWIG and MzScheme</a></h3>
<h3><a href="Mzscheme.html#Mzscheme">26 SWIG and MzScheme</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -1000,7 +1035,7 @@
</div>
<!-- INDEX -->
<h3><a href="Ocaml.html#Ocaml">26 SWIG and Ocaml</a></h3>
<h3><a href="Ocaml.html#Ocaml">27 SWIG and Ocaml</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -1051,7 +1086,7 @@
</div>
<!-- INDEX -->
<h3><a href="Octave.html#Octave">27 SWIG and Octave</a></h3>
<h3><a href="Octave.html#Octave">28 SWIG and Octave</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -1086,7 +1121,7 @@
</div>
<!-- INDEX -->
<h3><a href="Perl5.html#Perl5">28 SWIG and Perl5</a></h3>
<h3><a href="Perl5.html#Perl5">29 SWIG and Perl5</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -1153,7 +1188,7 @@
</div>
<!-- INDEX -->
<h3><a href="Php.html#Php">29 SWIG and PHP</a></h3>
<h3><a href="Php.html#Php">30 SWIG and PHP</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -1193,7 +1228,7 @@
</div>
<!-- INDEX -->
<h3><a href="Pike.html#Pike">30 SWIG and Pike</a></h3>
<h3><a href="Pike.html#Pike">31 SWIG and Pike</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -1217,7 +1252,7 @@
</div>
<!-- INDEX -->
<h3><a href="Python.html#Python">31 SWIG and Python</a></h3>
<h3><a href="Python.html#Python">32 SWIG and Python</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -1320,7 +1355,7 @@
</div>
<!-- INDEX -->
<h3><a href="Ruby.html#Ruby">32 SWIG and Ruby</a></h3>
<h3><a href="Ruby.html#Ruby">33 SWIG and Ruby</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -1353,7 +1388,7 @@
<li><a href="Ruby.html#Ruby_nn22">C++ namespaces</a>
<li><a href="Ruby.html#Ruby_nn23">C++ templates</a>
<li><a href="Ruby.html#Ruby_nn23_1">C++ Standard Template Library (STL)</a>
<li><a href="Ruby.html#C_STL_Functors">C++ STL Functors</a>
<li><a href="Ruby.html#Ruby_C_STL_Functors">C++ STL Functors</a>
<li><a href="Ruby.html#Ruby_C_Iterators">C++ STL Iterators</a>
<li><a href="Ruby.html#Ruby_nn24">C++ Smart Pointers</a>
<li><a href="Ruby.html#Ruby_nn25">Cross-Language Polymorphism</a>
@ -1437,7 +1472,7 @@
</ul>
<li><a href="Ruby.html#Ruby_nn53">Advanced Topics</a>
<ul>
<li><a href="Ruby.html#Ruby_nn54">Operator overloading</a>
<li><a href="Ruby.html#Ruby_operator_overloading">Operator overloading</a>
<li><a href="Ruby.html#Ruby_nn55">Creating Multi-Module Packages</a>
<li><a href="Ruby.html#Ruby_nn56">Specifying Mixin Modules</a>
</ul>
@ -1454,7 +1489,7 @@
</div>
<!-- INDEX -->
<h3><a href="Tcl.html#Tcl">33 SWIG and Tcl</a></h3>
<h3><a href="Tcl.html#Tcl">34 SWIG and Tcl</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -1520,7 +1555,7 @@
</div>
<!-- INDEX -->
<h3><a href="R.html#R">34 SWIG and R</a></h3>
<h3><a href="R.html#R">35 SWIG and R</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -1536,7 +1571,7 @@
</div>
<!-- INDEX -->
<h3><a href="Extending.html#Extending">35 Extending SWIG to support new languages</a></h3>
<h3><a href="Extending.html#Extending">36 Extending SWIG to support new languages</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@ -1585,7 +1620,7 @@
<li><a href="Extending.html#Extending_nn36">Entry point to code generation</a>
<li><a href="Extending.html#Extending_nn37">Module I/O and wrapper skeleton</a>
<li><a href="Extending.html#Extending_nn38">Low-level code generators</a>
<li><a href="Extending.html#Extending_nn39">Configuration files</a>
<li><a href="Extending.html#Extending_configuration_files">Configuration files</a>
<li><a href="Extending.html#Extending_nn40">Runtime support</a>
<li><a href="Extending.html#Extending_nn41">Standard library files</a>
<li><a href="Extending.html#Extending_nn42">User examples</a>

View file

@ -10,7 +10,7 @@
<!-- INDEX -->
<div class="sectiontoc">
<ul>
<li><a href="#exception">Exception handling with %exception</a>
<li><a href="#Customization_exception">Exception handling with %exception</a>
<ul>
<li><a href="#Customization_nn3">Handling exceptions in C code</a>
<li><a href="#Customization_nn4">Exception handling with longjmp()</a>
@ -20,14 +20,14 @@
<li><a href="#Customization_exception_special_variables">Special variables for %exception</a>
<li><a href="#Customization_nn7">Using The SWIG exception library</a>
</ul>
<li><a href="#ownership">Object ownership and %newobject</a>
<li><a href="#features">Features and the %feature directive</a>
<li><a href="#Customization_ownership">Object ownership and %newobject</a>
<li><a href="#Customization_features">Features and the %feature directive</a>
<ul>
<li><a href="#Customization_feature_attributes">Feature attributes</a>
<li><a href="#Customization_feature_flags">Feature flags</a>
<li><a href="#Customization_clearing_features">Clearing features</a>
<li><a href="#Customization_features_default_args">Features and default arguments</a>
<li><a href="#features_example">Feature example</a>
<li><a href="#Customization_features_example">Feature example</a>
</ul>
</ul>
</div>
@ -45,7 +45,7 @@ of exception handling is presented. Then, a more general-purpose
customization mechanism known as "features" is described.
</p>
<H2><a name="exception"></a>11.1 Exception handling with %exception</H2>
<H2><a name="Customization_exception"></a>11.1 Exception handling with %exception</H2>
<p>
@ -83,7 +83,7 @@ How the exception is handled depends on the target language, for example, Python
<p>
When defined, the code enclosed in braces is inserted directly into the low-level wrapper
functions. The special variable <tt>$action</tt> is one of a few
<a href="Customization.html#Customization_exception_special_variables">%exception special variable</a>
<a href="Customization.html#Customization_exception_special_variables">%exception special variables</a>
supported and gets replaced with the actual operation
to be performed (a function call, method invocation, attribute access, etc.). An exception handler
remains in effect until it is explicitly deleted. This is done by using either <tt>%exception</tt>
@ -351,7 +351,7 @@ In this case, the exception handler is only attached to declarations
named "allocate". This would include both global and member
functions. The names supplied to <tt>%exception</tt> follow the same
rules as for <tt>%rename</tt> described in the section on
<a href="SWIGPlus.html#ambiguity_resolution_renaming">Ambiguity resolution and renaming</a>.
<a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a>.
For example, if you wanted to define
an exception handler for a specific class, you might write this:
</p>
@ -582,7 +582,7 @@ it can be used elsewhere in SWIG. This includes typemaps and helper
functions.
</p>
<H2><a name="ownership"></a>11.2 Object ownership and %newobject</H2>
<H2><a name="Customization_ownership"></a>11.2 Object ownership and %newobject</H2>
<p>
@ -734,7 +734,7 @@ char *strdup(const char *s);
The results might not be what you expect.
</p>
<H2><a name="features"></a>11.3 Features and the %feature directive</H2>
<H2><a name="Customization_features"></a>11.3 Features and the %feature directive</H2>
<p>
@ -773,9 +773,9 @@ involving <tt>%feature</tt>:
</div>
<p>
The name matching rules outlined in the <a href="SWIGPlus.html#ambiguity_resolution_renaming">Ambiguity resolution and renaming</a>
The name matching rules outlined in the <a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a>
section applies to all <tt>%feature</tt> directives.
In fact the the <tt>%rename</tt> directive is just a special form of <tt>%feature</tt>.
In fact the <tt>%rename</tt> directive is just a special form of <tt>%feature</tt>.
The matching rules mean that features are very flexible and can be applied with
pinpoint accuracy to specific declarations if needed.
Additionally, if no declaration name is given, a global feature is said to be defined.
@ -854,7 +854,7 @@ In the following example, <tt>MyExceptionClass</tt> is the name of the Java clas
</div>
<p>
Further details can be obtained from the <a href="Java.html#exception_handling">Java exception handling</a> section.
Further details can be obtained from the <a href="Java.html#Java_exception_handling">Java exception handling</a> section.
</p>
<H3><a name="Customization_feature_flags"></a>11.3.2 Feature flags</H3>
@ -1123,7 +1123,7 @@ specifying or not specifying default arguments in a feature is not applicable as
in SWIG-1.3.23 when the approach to wrapping methods with default arguments was changed.
</p>
<H3><a name="features_example"></a>11.3.5 Feature example</H3>
<H3><a name="Customization_features_example"></a>11.3.5 Feature example</H3>
<p>

View file

@ -6,7 +6,7 @@
</head>
<body bgcolor="#ffffff">
<H1><a name="Extending"></a>35 Extending SWIG to support new languages</H1>
<H1><a name="Extending"></a>36 Extending SWIG to support new languages</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@ -54,7 +54,7 @@
<li><a href="#Extending_nn36">Entry point to code generation</a>
<li><a href="#Extending_nn37">Module I/O and wrapper skeleton</a>
<li><a href="#Extending_nn38">Low-level code generators</a>
<li><a href="#Extending_nn39">Configuration files</a>
<li><a href="#Extending_configuration_files">Configuration files</a>
<li><a href="#Extending_nn40">Runtime support</a>
<li><a href="#Extending_nn41">Standard library files</a>
<li><a href="#Extending_nn42">User examples</a>
@ -75,7 +75,7 @@
<H2><a name="Extending_nn2"></a>35.1 Introduction</H2>
<H2><a name="Extending_nn2"></a>36.1 Introduction</H2>
<p>
@ -91,7 +91,7 @@ Also, this chapter is not meant to be a hand-holding tutorial. As a starting po
you should probably look at one of SWIG's existing modules.
</p>
<H2><a name="Extending_nn3"></a>35.2 Prerequisites</H2>
<H2><a name="Extending_nn3"></a>36.2 Prerequisites</H2>
<p>
@ -121,7 +121,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of
wrapper code are driven by C++ datatypes.
</p>
<H2><a name="Extending_nn4"></a>35.3 The Big Picture</H2>
<H2><a name="Extending_nn4"></a>36.3 The Big Picture</H2>
<p>
@ -158,7 +158,7 @@ role in making the system work. For example, both typemaps and declaration anno
based on pattern matching and interact heavily with the underlying type system.
</p>
<H2><a name="Extending_nn5"></a>35.4 Execution Model</H2>
<H2><a name="Extending_nn5"></a>36.4 Execution Model</H2>
<p>
@ -203,7 +203,7 @@ latter stage of compilation.
The next few sections briefly describe some of these stages.
</p>
<H3><a name="Extending_nn6"></a>35.4.1 Preprocessing</H3>
<H3><a name="Extending_nn6"></a>36.4.1 Preprocessing</H3>
<p>
@ -284,7 +284,7 @@ been expanded as well as everything else that goes into the low-level
construction of the wrapper code.
</p>
<H3><a name="Extending_nn7"></a>35.4.2 Parsing</H3>
<H3><a name="Extending_nn7"></a>36.4.2 Parsing</H3>
<p>
@ -385,7 +385,7 @@ returning a <tt>foo</tt> and taking types <tt>a</tt> and <tt>b</tt> as
arguments).
</p>
<H3><a name="Extending_nn8"></a>35.4.3 Parse Trees</H3>
<H3><a name="Extending_nn8"></a>36.4.3 Parse Trees</H3>
<p>
@ -640,7 +640,7 @@ $ swig -c++ -python -debug-module 4 example.i
</pre>
</div>
<H3><a name="Extending_nn9"></a>35.4.4 Attribute namespaces</H3>
<H3><a name="Extending_nn9"></a>36.4.4 Attribute namespaces</H3>
<p>
@ -659,7 +659,7 @@ that matches the name of the target language. For example, <tt>python:foo</tt>
<tt>perl:foo</tt>.
</p>
<H3><a name="Extending_nn10"></a>35.4.5 Symbol Tables</H3>
<H3><a name="Extending_nn10"></a>36.4.5 Symbol Tables</H3>
<p>
@ -750,7 +750,7 @@ example.i:5. Previous declaration is foo_i(int )
</pre>
</div>
<H3><a name="Extending_nn11"></a>35.4.6 The %feature directive</H3>
<H3><a name="Extending_nn11"></a>36.4.6 The %feature directive</H3>
<p>
@ -806,7 +806,7 @@ For example, the exception code above is simply
stored without any modifications.
</p>
<H3><a name="Extending_nn12"></a>35.4.7 Code Generation</H3>
<H3><a name="Extending_nn12"></a>36.4.7 Code Generation</H3>
<p>
@ -928,7 +928,7 @@ public :
The role of these functions is described shortly.
</p>
<H3><a name="Extending_nn13"></a>35.4.8 SWIG and XML</H3>
<H3><a name="Extending_nn13"></a>36.4.8 SWIG and XML</H3>
<p>
@ -941,7 +941,7 @@ internal data structures, it may be useful to keep XML in the back of
your mind as a model.
</p>
<H2><a name="Extending_nn14"></a>35.5 Primitive Data Structures</H2>
<H2><a name="Extending_nn14"></a>36.5 Primitive Data Structures</H2>
<p>
@ -987,7 +987,7 @@ typedef Hash Typetab;
</pre>
</div>
<H3><a name="Extending_nn15"></a>35.5.1 Strings</H3>
<H3><a name="Extending_nn15"></a>36.5.1 Strings</H3>
<p>
@ -1128,7 +1128,7 @@ Returns the number of replacements made (if any).
</div>
<H3><a name="Extending_nn16"></a>35.5.2 Hashes</H3>
<H3><a name="Extending_nn16"></a>36.5.2 Hashes</H3>
<p>
@ -1205,7 +1205,7 @@ Returns the list of hash table keys.
</div>
<H3><a name="Extending_nn17"></a>35.5.3 Lists</H3>
<H3><a name="Extending_nn17"></a>36.5.3 Lists</H3>
<p>
@ -1294,7 +1294,7 @@ If <tt>t</tt> is not a standard object, it is assumed to be a <tt>char *</tt>
and is used to create a String object.
</div>
<H3><a name="Extending_nn18"></a>35.5.4 Common operations</H3>
<H3><a name="Extending_nn18"></a>36.5.4 Common operations</H3>
The following operations are applicable to all datatypes.
@ -1349,7 +1349,7 @@ objects and report errors.
Gets the line number associated with <tt>x</tt>.
</div>
<H3><a name="Extending_nn19"></a>35.5.5 Iterating over Lists and Hashes</H3>
<H3><a name="Extending_nn19"></a>36.5.5 Iterating over Lists and Hashes</H3>
To iterate over the elements of a list or a hash table, the following functions are used:
@ -1394,7 +1394,7 @@ for (j = First(j); j.item; j= Next(j)) {
</div>
<H3><a name="Extending_nn20"></a>35.5.6 I/O</H3>
<H3><a name="Extending_nn20"></a>36.5.6 I/O</H3>
Special I/O functions are used for all internal I/O. These operations
@ -1531,7 +1531,7 @@ Similarly, the preprocessor and parser all operate on string-files.
</div>
<H2><a name="Extending_nn21"></a>35.6 Navigating and manipulating parse trees</H2>
<H2><a name="Extending_nn21"></a>36.6 Navigating and manipulating parse trees</H2>
Parse trees are built as collections of hash tables. Each node is a hash table in which
@ -1665,7 +1665,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u
the parent so that sibling nodes are unaffected.
</div>
<H2><a name="Extending_nn22"></a>35.7 Working with attributes</H2>
<H2><a name="Extending_nn22"></a>36.7 Working with attributes</H2>
<p>
@ -1782,7 +1782,7 @@ the attribute is optional. <tt>Swig_restore()</tt> must always be called after
function.
</div>
<H2><a name="Extending_nn23"></a>35.8 Type system</H2>
<H2><a name="Extending_nn23"></a>36.8 Type system</H2>
<p>
@ -1791,7 +1791,7 @@ pointers, references, and pointers to members. A detailed discussion of
type theory is impossible here. However, let's cover the highlights.
</p>
<H3><a name="Extending_nn24"></a>35.8.1 String encoding of types</H3>
<H3><a name="Extending_nn24"></a>36.8.1 String encoding of types</H3>
<p>
@ -1892,7 +1892,7 @@ make the final type, the two parts are just joined together using
string concatenation.
</p>
<H3><a name="Extending_nn25"></a>35.8.2 Type construction</H3>
<H3><a name="Extending_nn25"></a>36.8.2 Type construction</H3>
<p>
@ -2061,7 +2061,7 @@ Returns the prefix of a type. For example, if <tt>ty</tt> is
<tt>ty</tt> is unmodified.
</div>
<H3><a name="Extending_nn26"></a>35.8.3 Type tests</H3>
<H3><a name="Extending_nn26"></a>36.8.3 Type tests</H3>
<p>
@ -2148,7 +2148,7 @@ Checks if <tt>ty</tt> is a varargs type.
Checks if <tt>ty</tt> is a templatized type.
</div>
<H3><a name="Extending_nn27"></a>35.8.4 Typedef and inheritance</H3>
<H3><a name="Extending_nn27"></a>36.8.4 Typedef and inheritance</H3>
<p>
@ -2250,7 +2250,7 @@ Fully reduces <tt>ty</tt> according to typedef rules. Resulting datatype
will consist only of primitive typenames.
</div>
<H3><a name="Extending_nn28"></a>35.8.5 Lvalues</H3>
<H3><a name="Extending_nn28"></a>36.8.5 Lvalues</H3>
<p>
@ -2287,7 +2287,7 @@ Literal y; // type = 'Literal', ltype='p.char'
</pre>
</div>
<H3><a name="Extending_nn29"></a>35.8.6 Output functions</H3>
<H3><a name="Extending_nn29"></a>36.8.6 Output functions</H3>
<p>
@ -2349,7 +2349,7 @@ SWIG, but is most commonly associated with type-descriptor objects
that appear in wrappers (e.g., <tt>SWIGTYPE_p_double</tt>).
</div>
<H2><a name="Extending_nn30"></a>35.9 Parameters</H2>
<H2><a name="Extending_nn30"></a>36.9 Parameters</H2>
<p>
@ -2448,7 +2448,7 @@ included. Used to emit prototypes.
Returns the number of required (non-optional) arguments in <tt>p</tt>.
</div>
<H2><a name="Extending_nn31"></a>35.10 Writing a Language Module</H2>
<H2><a name="Extending_nn31"></a>36.10 Writing a Language Module</H2>
<p>
@ -2463,7 +2463,7 @@ describes the creation of a minimal Python module. You should be able to extra
this to other languages.
</p>
<H3><a name="Extending_nn32"></a>35.10.1 Execution model</H3>
<H3><a name="Extending_nn32"></a>36.10.1 Execution model</H3>
<p>
@ -2473,7 +2473,7 @@ the parsing of command line options, all aspects of code generation are controll
different methods of the <tt>Language</tt> that must be defined by your module.
</p>
<H3><a name="Extending_starting_out"></a>35.10.2 Starting out</H3>
<H3><a name="Extending_starting_out"></a>36.10.2 Starting out</H3>
<p>
@ -2581,7 +2581,7 @@ that activates your module. For example, <tt>swig -python foo.i</tt>. The
messages from your new module should appear.
</p>
<H3><a name="Extending_nn34"></a>35.10.3 Command line options</H3>
<H3><a name="Extending_nn34"></a>36.10.3 Command line options</H3>
<p>
@ -2640,7 +2640,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit
unrecognized command line option error.
</p>
<H3><a name="Extending_nn35"></a>35.10.4 Configuration and preprocessing</H3>
<H3><a name="Extending_nn35"></a>36.10.4 Configuration and preprocessing</H3>
<p>
@ -2689,7 +2689,7 @@ an implementation file <tt>python.cxx</tt> and a configuration file
<tt>python.swg</tt>.
</p>
<H3><a name="Extending_nn36"></a>35.10.5 Entry point to code generation</H3>
<H3><a name="Extending_nn36"></a>36.10.5 Entry point to code generation</H3>
<p>
@ -2747,7 +2747,7 @@ int Python::top(Node *n) {
</pre>
</div>
<H3><a name="Extending_nn37"></a>35.10.6 Module I/O and wrapper skeleton</H3>
<H3><a name="Extending_nn37"></a>36.10.6 Module I/O and wrapper skeleton</H3>
<!-- please report bugs in this section to mgossage -->
@ -2895,7 +2895,7 @@ functionWrapper : void Shape_y_set(Shape *self,double y)
</pre>
</div>
<H3><a name="Extending_nn38"></a>35.10.7 Low-level code generators</H3>
<H3><a name="Extending_nn38"></a>36.10.7 Low-level code generators</H3>
<!-- please report bugs in this section to mgossage -->
@ -3049,7 +3049,7 @@ but without the typemaps, there is still work to do.
</p>
<H3><a name="Extending_nn39"></a>35.10.8 Configuration files</H3>
<H3><a name="Extending_configuration_files"></a>36.10.8 Configuration files</H3>
<!-- please report bugs in this section to ttn -->
@ -3090,8 +3090,6 @@ The nickname is used in four places:
<TR><TD><B>usage</B></TD><TD><B>transform</B></TD></TR>
<TR><TD>"skip" tag</TD><TD>(none)</TD></TR>
<TR><TD>Examples/ subdir name</TD><TD>(none)</TD></TR>
<TR><TD>Examples/GIFPlot/ subdir name</TD>
<TD>capitalize (upcase first letter)</TD></TR>
<TR><TD>Examples/test-suite/ subdir name</TD><TD>(none)</TD></TR>
<!-- add more uses here (remember to adjust header) -->
</TABLE>
@ -3159,8 +3157,8 @@ skip-qux = $(skip-qux99)
<p>
Lastly, you need to modify each of <TT>check-aliveness</TT>,
<TT>check-examples</TT>, <TT>check-test-suite</TT>,
<TT>check-gifplot</TT> (all targets) and <TT>lib-languages</TT> (var).
<TT>check-examples</TT>, <TT>check-test-suite</TT>
and <TT>lib-languages</TT> (var).
Use the nickname for these, not the alias.
Note that you can do this even before you have any tests or examples
set up; the Makefile rules do some sanity checking and skip around
@ -3175,10 +3173,6 @@ and look to the existing languages for examples.
<dd> Do <TT>cp ../python/check.list .</TT> and modify to taste.
One subdir per line.
<dt> <b>Examples/GIFPlot/Qux99/check.list</b>
<dd> Do <TT>cp ../Python/check.list .</TT> and modify to taste.
One subdir per line.
<dt> <b>Lib/qux99/extra-install.list</b>
<dd> If you add your language to the top-level Makefile.in var
<TT>lib-languages</TT>, then <TT>make install</TT> will install
@ -3199,7 +3193,7 @@ politely displays the ignoring language message.
</dl>
<H3><a name="Extending_nn40"></a>35.10.9 Runtime support</H3>
<H3><a name="Extending_nn40"></a>36.10.9 Runtime support</H3>
<p>
@ -3208,7 +3202,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g.
the SWIG files that implement those functions.
</p>
<H3><a name="Extending_nn41"></a>35.10.10 Standard library files</H3>
<H3><a name="Extending_nn41"></a>36.10.10 Standard library files</H3>
<p>
@ -3227,7 +3221,7 @@ The following are the minimum that are usually supported:
Please copy these and modify for any new language.
</p>
<H3><a name="Extending_nn42"></a>35.10.11 User examples</H3>
<H3><a name="Extending_nn42"></a>36.10.11 User examples</H3>
<p>
@ -3252,11 +3246,11 @@ These can be found, for example for Python, in
<p>
By default, all of the examples are built and run when the user types
<tt>make check</tt>. To ensure that your examples are automatically run
during this process, see the section on <a href="#n37a">configuration
during this process, see the section on <a href="#Extending_configuration_files">configuration
files</a>.
</p>
<H3><a name="Extending_test_suite"></a>35.10.12 Test driven development and the test-suite</H3>
<H3><a name="Extending_test_suite"></a>36.10.12 Test driven development and the test-suite</H3>
<p>
@ -3315,7 +3309,7 @@ It is therefore essential that the runtime tests are written in a manner that di
but error/exception out with an error message on stderr on failure.
</p>
<H4><a name="Extending_running_test_suite"></a>35.10.12.1 Running the test-suite</H4>
<H4><a name="Extending_running_test_suite"></a>36.10.12.1 Running the test-suite</H4>
<p>
@ -3475,7 +3469,15 @@ SWIG can be analyzed for bad memory accesses using:
make ret_by_value.ctest SWIGTOOL="valgrind --tool=memcheck --trace-children=yes"
</pre></div>
<H3><a name="Extending_nn43"></a>35.10.13 Documentation</H3>
<p>
A debugger can also be invoked easily on an individual test, for example gdb:
</p>
<div class="shell"><pre>
make ret_by_value.ctest RUNTOOL="gdb --args"
</pre></div>
<H3><a name="Extending_nn43"></a>36.10.13 Documentation</H3>
<p>
@ -3507,7 +3509,7 @@ Some topics that you'll want to be sure to address include:
if available.
</ul>
<H3><a name="Extending_prerequisites"></a>35.10.14 Prerequisites for adding a new language module to the SWIG distribution</H3>
<H3><a name="Extending_prerequisites"></a>36.10.14 Prerequisites for adding a new language module to the SWIG distribution</H3>
<p>
@ -3564,7 +3566,7 @@ should be added should there be an area not already covered by
the existing tests.
</p>
<H3><a name="Extending_coding_style_guidelines"></a>35.10.15 Coding style guidelines</H3>
<H3><a name="Extending_coding_style_guidelines"></a>36.10.15 Coding style guidelines</H3>
<p>
@ -3588,7 +3590,7 @@ The generated C/C++ code should also follow this style as close as possible. How
should be avoided as unlike the SWIG developers, users will never have consistent tab settings.
</p>
<H2><a name="Extending_debugging_options"></a>35.11 Debugging Options</H2>
<H2><a name="Extending_debugging_options"></a>36.11 Debugging Options</H2>
<p>
@ -3613,7 +3615,7 @@ There are various command line options which can aid debugging a SWIG interface
The complete list of command line options for SWIG are available by running <tt>swig -help</tt>.
</p>
<H2><a name="Extending_nn46"></a>35.12 Guide to parse tree nodes</H2>
<H2><a name="Extending_nn46"></a>36.12 Guide to parse tree nodes</H2>
<p>
@ -4021,7 +4023,7 @@ extern "X" { ... } declaration.
</pre>
</div>
<H2><a name="Extending_further_info"></a>35.13 Further Development Information</H2>
<H2><a name="Extending_further_info"></a>36.13 Further Development Information</H2>
<p>

454
Doc/Manual/Go.html Normal file
View file

@ -0,0 +1,454 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SWIG and Go</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body bgcolor="#FFFFFF">
<H1><a name="Go"></a>20 SWIG and Go</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
<li><a href="#Go_overview">Overview</a>
<li><a href="#Go_running_swig">Running SWIG with Go</a>
<ul>
<li><a href="#Go_commandline">Additional Commandline Options</a>
<li><a href="#Go_outputs">Go Output Files</a>
</ul>
<li><a href="#Go_basic_tour">A tour of basic C/C++ wrapping</a>
<ul>
<li><a href="#Go_package">Go Package Name</a>
<li><a href="#Go_names">Go Names</a>
<li><a href="#Go_constants">Go Constants</a>
<li><a href="#Go_enumerations">Go Enumerations</a>
<li><a href="#Go_classes">Go Classes</a>
<ul>
<li><a href="#Go_class_inheritance">Go Class Inheritance</a>
</ul>
<li><a href="#Go_templates">Go Templates</a>
<li><a href="#Go_director_classes">Go Director Classes</a>
<li><a href="#Go_primitive_type_mappings">Default Go primitive type mappings</a>
</ul>
</ul>
</div>
<!-- INDEX -->
<p>
This chapter describes SWIG's support of Go. For more information on
the Go programming language
see <a href="http://golang.org/">golang.org</a>.
</p>
<H2><a name="Go_overview"></a>20.1 Overview</H2>
<p>
Go is a compiled language, not a scripting language. However, it does
not support direct calling of functions written in C/C++. The cgo
program may be used to generate wrappers to call C code from Go, but
there is no convenient way to call C++ code. SWIG fills this gap.
</p>
<p>
There are (at least) two different Go compilers. One is the gc
compiler, normally invoked under the names 6g, 8g, or 5g. The other
is the gccgo compiler, which is a frontend to the gcc compiler suite.
The interface to C/C++ code is completely different for the two Go
compilers. SWIG supports both, selected by a command line option.
</p>
<p>
Because Go is a type-safe compiled language, SWIG's runtime type
checking and runtime library are not used with Go. This should be
borne in mind when reading the rest of the SWIG documentation.
</p>
<H2><a name="Go_running_swig"></a>20.2 Running SWIG with Go</H2>
<p>
To generate Go code, use the <tt>-go</tt> option with SWIG. By
default SWIG will generate code for the gc compilers. To generate
code for gccgo, you should also use the <tt>-gccgo</tt> option.
</p>
<H3><a name="Go_commandline"></a>20.2.1 Additional Commandline Options</H3>
<p>
These are the command line options for SWIG's GO module. They can
also be seen by using:
</p>
<div class="code"><pre>
swig -go -help
</pre></div>
<table summary="Go specific options">
<tr>
<th>Go specific options</th>
</tr>
<tr>
<td>-gccgo</td>
<td>Generate code for gccgo. The default is to generate code for
6g/8g/6g.</td>
</tr>
<tr>
<td>-package &lt;name&gt;</td>
<td>Set the name of the Go package to &lt;name&gt;. The default
package name is the SWIG module name.</td>
</tr>
<tr>
<td>-go-prefix &lt;prefix&gt;</td>
<td>When generating code for gccgo, set the prefix to use. This
corresponds to the <tt>-fgo-prefix</tt> option to gccgo.</td>
</tr>
<tr>
<td>-long-type-size &lt;s&gt;</td>
<td>Set the size for the C/C++ type <tt>long</tt>. This controls
whether <tt>long</tt> is converted to the Go type <tt>int32</tt>
or <tt>int64</tt>. The &lt;s&gt; argument should be 32 or 64.</td>
</tr>
</table>
<H3><a name="Go_outputs"></a>20.2.2 Go Output Files</H3>
<p> When generating Go code, SWIG will generate the following
files:</p>
<ul>
<li>
MODULE.go will contain the Go functions that your Go code will call.
These functions will be wrappers for the C++ functions defined by your
module. This file should, of course, be compiled with the Go
compiler.
<li>
MODULE_wrap.c or MODULE_wrap.cxx will contain C/C++ functions will be
invoked by the Go wrapper code. This file should be compiled with the
usual C or C++ compiler and linked into a shared library.
<li>
MODULE_wrap.h will be generated if you use the directors feature. It
provides a definition of the generated C++ director classes. It is
generally not necessary to use this file, but in some special cases it
may be helpful to include it in your code, compiled with the usual C
or C++ compiler.
<li>
If using the gc compiler, MODULE_gc.c will contain C code which should
be compiled with the C compiler distributed as part of the gc compiler: 6c, 8c,
or 5c. It should then be combined with the compiled MODULE.go using
gopack. This file will not be generated when using gccgo.
</ul>
<p>
A typical command sequence would look like this:
</p>
<div class="code"><pre>
% swig -go example.i
% gcc -c -fpic example.c
% gcc -c -fpic example_wrap.c
% gcc -shared example.o example_wrap.o -o example.so
% 6g example.go
% 6c example_gc.c
% gopack grc example.a example.6 example_gc.6
% 6g main.go # your code, not generated by SWIG
% 6l main.6
</pre></div>
<H2><a name="Go_basic_tour"></a>20.3 A tour of basic C/C++ wrapping</H2>
<p>
By default, SWIG attempts to build a natural Go interface to your
C/C++ code. However, the languages are somewhat different, so some
modifications have to occur. This section briefly covers the
essential aspects of this wrapping.
</p>
<H3><a name="Go_package"></a>20.3.1 Go Package Name</H3>
<p>
All Go source code lives in a package. The name of this package will
default to the name of the module from SWIG's <tt>%module</tt>
directive. You may override this by using SWIG's <tt>-package</tt>
command line option.
</p>
<H3><a name="Go_names"></a>20.3.2 Go Names</H3>
<p>
In Go, a function is only visible outside the current package if the
first letter of the name is uppercase. This is quite different from
C/C++. Because of this, C/C++ names are modified when generating the
Go interface: the first letter is forced to be uppercase if it is not
already. This affects the names of functions, methods, variables,
constants, enums, and classes.
</p>
<p>
C/C++ variables are wrapped with setter and getter functions in Go.
First the first letter of the variable name will be forced to
uppercase, and then <tt>Get</tt> or <tt>Set</tt> will be prepended.
For example, if the C/C++ variable is called <tt>var</tt>, then SWIG
will define the functions <tt>GetVar</tt> and <tt>SetVar</tt>. If a
variable is declared as <tt>const</tt>, or if
SWIG's <a href="SWIG.html#SWIG_readonly_variables">
<tt>%immutable</tt> directive</a> is used for the variable, then only
the getter will be defined.
</p>
<p>
C++ classes will be discussed further below. Here we'll note that the
first letter of the class name will be forced to uppercase to give the
name of a type in Go. A constructor will be named <tt>New</tt>
followed by that name, and the destructor will be
named <tt>Delete</tt> followed by that name.
</p>
<H3><a name="Go_constants"></a>20.3.3 Go Constants</H3>
<p>
C/C++ constants created via <tt>#define</tt> or the <tt>%constant</tt>
directive become Go constants, declared with a <tt>const</tt>
declaration.
<H3><a name="Go_enumerations"></a>20.3.4 Go Enumerations</H3>
<p>
C/C++ enumeration types will cause SWIG to define an integer type with
the name of the enumeration (with first letter forced to uppercase as
usual). The values of the enumeration will become variables in Go;
code should avoid modifying those variables.
</p>
<H3><a name="Go_classes"></a>20.3.5 Go Classes</H3>
<p>
Go has interfaces, methods and inheritance, but it does not have
classes in the same sense as C++. This sections describes how SWIG
represents C++ classes represented in Go.
</p>
<p>
For a C++ class <tt>ClassName</tt>, SWIG will define two types in Go:
an underlying type, which will just hold a pointer to the C++ type,
and an interface type. The interface type will be
named <tt>ClassName</tt>. SWIG will define a
function <tt>NewClassName</tt> which will take any constructor
arguments and return a value of the interface
type <tt>ClassName</tt>. SWIG will also define a
destructor <tt>DeleteClassName</tt>.
</p>
<p>
SWIG will represent any methods of the C++ class as methods on the
underlying type, and also as methods of the interface type. Thus C++
methods may be invoked directly using the
usual <tt>val.MethodName</tt> syntax. Public members of the C++ class
will be given getter and setter functions defined as methods of the
class.
</p>
<p>
SWIG will represent static methods of C++ classes as ordinary Go
functions. SWIG will use names like <tt>ClassName_MethodName</tt>.
SWIG will give static members getter and setter functions with names
like <tt>GetClassName_VarName</tt>.
</p>
<p>
Given a value of the interface type, Go code can retrieve the pointer
to the C++ type by calling the <tt>Swigcptr</tt> method. This will
return a value of type <tt>SwigcptrClassName</tt>, which is just a
name for <tt>uintptr</tt>. A Go type conversion can be used to
convert this value to a different C++ type, but note that this
conversion will not be type checked and is essentially equivalent
to <tt>reinterpret_cast</tt>. This should only be used for very
special cases, such as where C++ would use a <tt>dynamic_cast</tt>.
</p>
<H4><a name="Go_class_inheritance"></a>20.3.5.1 Go Class Inheritance</H4>
<p>
C++ class inheritance is automatically represented in Go due to its
use of interfaces. The interface for a child class will be a superset
of the interface of its parent class. Thus a value of the child class
type in Go may be passed to a function which expects the parent class.
Doing the reverse will require an explicit type assertion, which will
be checked dynamically.
</p>
<H3><a name="Go_templates"></a>20.3.6 Go Templates</H3>
<p>
In order to use C++ templates in Go, you must tell SWIG to create
wrappers for a particular template instantation. To do this, use
the <tt>%template</tt> directive.
<H3><a name="Go_director_classes"></a>20.3.7 Go Director Classes</H3>
<p>
SWIG's director feature permits a Go type to act as the subclass of a
C++ class with virtual methods. This is complicated by the fact that
C++ and Go define inheritance differently. In Go, structs can inherit
methods via anonymous field embedding. However, when a method is
called for an embedded struct, if that method calls any other methods,
they are called for the embedded struct, not for the original type.
Therefore, SWIG must use Go interfaces to represent C++ inheritance.
</p>
<p>
In order to use the director feature in Go, you must define a type in
your Go code. You must then add methods for the type. Define a
method in Go for each C++ virtual function that you want to override.
You must then create a value of your new type, and pass a pointer to
it to the function <tt>NewDirectorClassName</tt>,
where <tt>ClassName</tt> is the name of the C++ class. That will
return a value of type <tt>ClassName</tt>.
</p>
<p>
For example:
</p>
<div class="code">
<pre>
type GoClass struct { }
func (p *GoClass) VirtualFunction() { }
func MakeClass() ClassName {
return NewDirectorClassName(&amp;GoClass{})
}
</pre>
</div>
<p>
Any call in C++ code to the virtual function will wind up calling the
method defined in Go. The Go code may of course call other methods on
itself, and those methods may be defined either in Go or in C++.
</p>
<H3><a name="Go_primitive_type_mappings"></a>20.3.8 Default Go primitive type mappings</H3>
<p>
The following table lists the default type mapping from C/C++ to Go.
This table will tell you which Go type to expect for a function which
uses a given C/C++ type.
</p>
<table BORDER summary="Go primitive type mappings">
<tr>
<td><b>C/C++ type</b></td>
<td><b>Go type</b></td>
</tr>
<tr>
<td>bool</td>
<td>bool</td>
</tr>
<tr>
<td>char</td>
<td>byte</td>
</tr>
<tr>
<td>signed char</td>
<td>int8</td>
</tr>
<tr>
<td>unsigned char</td>
<td>byte</td>
</tr>
<tr>
<td>short</td>
<td>int16</td>
</tr>
<tr>
<td>unsigned short</td>
<td>uint16</td>
</tr>
<tr>
<td>int</td>
<td>int</td>
</tr>
<tr>
<td>unsigned int</td>
<td>uint</td>
</tr>
<tr>
<td>long</td>
<td>int32 or int64, depending on <tt>-long-type-size</tt></td>
</tr>
<tr>
<td>unsigned long</td>
<td>uint32 or uint64, depending on <tt>-long-type-size</tt></td>
</tr>
<tr>
<td>long long</td>
<td>int64</td>
</tr>
<tr>
<td>unsigned long long</td>
<td>uint64</td>
</tr>
<tr>
<td>float</td>
<td>float32</td>
</tr>
<tr>
<td>double</td>
<td>float64</td>
</tr>
<tr>
<td>char *<br>char []</td>
<td>string</td>
</tr>
</table>
<p>
Note that SWIG wraps the C <tt>char</tt> type as a character. Pointers
and arrays of this type are wrapped as strings. The <tt>signed
char</tt> type can be used if you want to treat <tt>char</tt> as a
signed number rather than a character. Also note that all const
references to primitive types are treated as if they are passed by
value.
</p>
<p>
These type mappings are defined by the "gotype" typemap. You may change
that typemap, or add new values, to control how C/C++ types are mapped
into Go types.
</p>
</body>
</html>

View file

@ -8,7 +8,7 @@
<body bgcolor="#ffffff">
<H1><a name="Guile"></a>20 SWIG and Guile</H1>
<H1><a name="Guile"></a>21 SWIG and Guile</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@ -47,7 +47,7 @@
<p>
This section details guile-specific support in SWIG.
<H2><a name="Guile_nn2"></a>20.1 Meaning of "Module"</H2>
<H2><a name="Guile_nn2"></a>21.1 Meaning of "Module"</H2>
<p>
@ -55,7 +55,7 @@ There are three different concepts of "module" involved, defined
separately for SWIG, Guile, and Libtool. To avoid horrible confusion,
we explicitly prefix the context, e.g., "guile-module".
<H2><a name="Guile_nn3"></a>20.2 Using the SCM or GH Guile API</H2>
<H2><a name="Guile_nn3"></a>21.2 Using the SCM or GH Guile API</H2>
<p>The guile module can currently export wrapper files that use the guile GH interface or the
@ -69,7 +69,7 @@ SCM interface is the default. The SCM and GH interface differ greatly in how th
pointers and have completely different run-time code. See below for more info.
<p>The GH interface to guile is deprecated. Read more about why in the
<a href="http://www.gnu.org/software/guile/docs/guile-ref/GH-deprecation.html">Guile manual</a>.
<a href="http://www.gnu.org/software/guile/docs/docs-1.6/guile-ref/GH.html#GH">Guile manual</a>.
The idea of the GH interface was to provide a high level API that other languages and projects
could adopt. This was a good idea, but didn't pan out well for general development. But for the
specific, minimal uses that the SWIG typemaps put the GH interface to use is ideal for
@ -103,7 +103,7 @@ for the specific API. Currently only the guile language module has created a ma
but there is no reason other languages (like mzscheme or chicken) couldn't also use this.
If that happens, there is A LOT less code duplication in the standard typemaps.</p>
<H2><a name="Guile_nn4"></a>20.3 Linkage</H2>
<H2><a name="Guile_nn4"></a>21.3 Linkage</H2>
<p>
@ -111,7 +111,7 @@ Guile support is complicated by a lack of user community cohesiveness,
which manifests in multiple shared-library usage conventions. A set of
policies implementing a usage convention is called a <b>linkage</b>.
<H3><a name="Guile_nn5"></a>20.3.1 Simple Linkage</H3>
<H3><a name="Guile_nn5"></a>21.3.1 Simple Linkage</H3>
<p>
@ -206,7 +206,7 @@ placed between the <code>define-module</code> form and the
<code>SWIG_init</code> via a preprocessor define to avoid symbol
clashes. For this case, however, passive linkage is available.
<H3><a name="Guile_nn6"></a>20.3.2 Passive Linkage</H3>
<H3><a name="Guile_nn6"></a>21.3.2 Passive Linkage</H3>
<p>Passive linkage is just like simple linkage, but it generates an
@ -216,7 +216,7 @@ package name (see below).
<p>You should use passive linkage rather than simple linkage when you
are using multiple modules.
<H3><a name="Guile_nn7"></a>20.3.3 Native Guile Module Linkage</H3>
<H3><a name="Guile_nn7"></a>21.3.3 Native Guile Module Linkage</H3>
<p>SWIG can also generate wrapper code that does all the Guile module
@ -257,7 +257,7 @@ Newer Guile versions have a shorthand procedure for this:
</div>
</ul>
<H3><a name="Guile_nn8"></a>20.3.4 Old Auto-Loading Guile Module Linkage</H3>
<H3><a name="Guile_nn8"></a>21.3.4 Old Auto-Loading Guile Module Linkage</H3>
<p>Guile used to support an autoloading facility for object-code
@ -283,7 +283,7 @@ option, SWIG generates an exported module initialization function with
an appropriate name.
<H3><a name="Guile_nn9"></a>20.3.5 Hobbit4D Linkage</H3>
<H3><a name="Guile_nn9"></a>21.3.5 Hobbit4D Linkage</H3>
<p>
@ -308,7 +308,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very
experimental; the (hobbit4d link) conventions are not well understood.
</p>
<H2><a name="Guile_nn10"></a>20.4 Underscore Folding</H2>
<H2><a name="Guile_nn10"></a>21.4 Underscore Folding</H2>
<p>
@ -320,7 +320,7 @@ complained so far.
<code>%rename</code> to specify the Guile name of the wrapped
functions and variables (see CHANGES).
<H2><a name="Guile_nn11"></a>20.5 Typemaps</H2>
<H2><a name="Guile_nn11"></a>21.5 Typemaps</H2>
<p>
@ -409,10 +409,10 @@ See also the "multivalue" example.
%feature("constasvar") can be applied to any constant, immutable variable, or enum.
Instead of exporting the constant as a function that must be called, the
constant will appear as a scheme variable. See
<a href="Customization.html#features">Features and the %feature directive</a>
<a href="Customization.html#Customization_features">Features and the %feature directive</a>
for info on how to apply the %feature.</p>
<H2><a name="Guile_nn12"></a>20.6 Representation of pointers as smobs</H2>
<H2><a name="Guile_nn12"></a>21.6 Representation of pointers as smobs</H2>
<p>
@ -433,7 +433,7 @@ representing the expected pointer type. See also
If the Scheme object passed was not a SWIG smob representing a compatible
pointer, a <code>wrong-type-arg</code> exception is raised.
<H3><a name="Guile_nn13"></a>20.6.1 GH Smobs</H3>
<H3><a name="Guile_nn13"></a>21.6.1 GH Smobs</H3>
<p>
@ -462,7 +462,7 @@ that created them, so the first module we check will most likely be correct.
Once we have a swig_type_info structure, we loop through the linked list of
casts, using pointer comparisons.</p>
<H3><a name="Guile_nn14"></a>20.6.2 SCM Smobs</H3>
<H3><a name="Guile_nn14"></a>21.6.2 SCM Smobs</H3>
<p>The SCM interface (using the "-scm" argument to swig) uses swigrun.swg.
@ -477,7 +477,7 @@ in the smob tag. If a generated GOOPS module has been loaded, smobs will be wra
GOOPS class.</p>
<H3><a name="Guile_nn15"></a>20.6.3 Garbage Collection</H3>
<H3><a name="Guile_nn15"></a>21.6.3 Garbage Collection</H3>
<p>Garbage collection is a feature of the new SCM interface, and it is automatically included
@ -487,11 +487,11 @@ to the destructor for this type. The destructor is the generated wrapper around
So swig still exports a wrapper for the destructor, it just does not call scm_c_define_gsubr() for
the wrapped delete function. So the only way to delete an object is from the garbage collector, since the
delete function is not available to scripts. How swig determines if a type should be garbage collected
is exactly like described in <a href="Customization.html#ownership">
is exactly like described in <a href="Customization.html#Customization_ownership">
Object ownership and %newobject</a> in the SWIG manual. All typemaps use an $owner var, and
the guile module replaces $owner with 0 or 1 depending on feature:new.</p>
<H2><a name="Guile_nn16"></a>20.7 Exception Handling</H2>
<H2><a name="Guile_nn16"></a>21.7 Exception Handling</H2>
<p>
@ -517,7 +517,7 @@ mapping:
The default when not specified here is to use "swig-error".
See Lib/exception.i for details.
<H2><a name="Guile_nn17"></a>20.8 Procedure documentation</H2>
<H2><a name="Guile_nn17"></a>21.8 Procedure documentation</H2>
<p>If invoked with the command-line option <code>-procdoc
@ -553,7 +553,7 @@ like this:
typemap argument <code>doc</code>. See <code>Lib/guile/typemaps.i</code> for
details.
<H2><a name="Guile_nn18"></a>20.9 Procedures with setters</H2>
<H2><a name="Guile_nn18"></a>21.9 Procedures with setters</H2>
<p>For global variables, SWIG creates a single wrapper procedure
@ -581,7 +581,7 @@ struct members, the procedures <code>(<var>struct</var>-<var>member</var>-get
pointer)</code> and <code>(<var>struct-member</var>-set pointer
value)</code> are <em>not</em> generated.
<H2><a name="Guile_nn19"></a>20.10 GOOPS Proxy Classes</H2>
<H2><a name="Guile_nn19"></a>21.10 GOOPS Proxy Classes</H2>
<p>SWIG can also generate classes and generic functions for use with
@ -730,7 +730,7 @@ Notice that &lt;Foo&gt; is used before it is defined. The fix is to just put th
<code>%import "foo.h"</code> before the <code>%inline</code> block.
</p>
<H3><a name="Guile_nn20"></a>20.10.1 Naming Issues</H3>
<H3><a name="Guile_nn20"></a>21.10.1 Naming Issues</H3>
<p>As you can see in the example above, there are potential naming conflicts. The default exported
@ -767,9 +767,7 @@ guile-modules. For example,</p>
(use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:)))
</pre></div>
<p>TODO: Renaming class name prefixes?</p>
<H3><a name="Guile_nn21"></a>20.10.2 Linking</H3>
<H3><a name="Guile_nn21"></a>21.10.2 Linking</H3>
<p>The guile-modules generated above all need to be linked together. GOOPS support requires

View file

@ -37,7 +37,7 @@
<p>
SWIG is a software development tool that simplifies the task of
interfacing different languages to C and C++ programs. In a
nutshell, SWIG is a compiler that takes C declarations and creates
nutshell, SWIG is a compiler that takes C/C++ declarations and creates
the wrappers needed to access those declarations from other languages including
including Perl, Python, Tcl, Ruby, Guile, and Java. SWIG normally
requires no modifications to existing code and can often be used to
@ -68,7 +68,8 @@ a dedicated IDL compiler). Although
this style of development isn't appropriate for every
project, it is particularly well suited to software development in the
small; especially the research and development work that is commonly found
in scientific and engineering projects.
in scientific and engineering projects. However, nowadays SWIG is known to be used in many
large open source and commercial projects.
<H2><a name="Introduction_nn3"></a>2.2 Why use SWIG?</H2>
@ -365,7 +366,7 @@ possible to support different types of interfaces depending on the application.
<p>
SWIG is a command line tool and as such can be incorporated into any build system that supports invoking external tools/compilers.
SWIG is most commonly invoked from within a Makefile, but is also known to be invoked from from popular IDEs such as
SWIG is most commonly invoked from within a Makefile, but is also known to be invoked from popular IDEs such as
Microsoft Visual Studio.
</p>
@ -375,10 +376,10 @@ If you are using the GNU Autotools
<a href="http://www.gnu.org/software/automake">Automake</a>/
<a href="http://www.gnu.org/software/libtool">Libtool</a>)
to configure SWIG use in your project, the SWIG Autoconf macros can be used.
The primary macro is <tt>ac_pkg_swig</tt>, see
<a href="http://www.gnu.org/software/ac-archive/htmldoc/ac_pkg_swig.html">http://www.gnu.org/software/ac-archive/htmldoc/ac_pkg_swig.html</a>.
The <tt>ac_python_devel</tt> macro is also helpful for generating Python extensions. See the
<a href="http://www.gnu.org/software/ac-archive/htmldoc/index.html">Autoconf Macro Archive</a>
The primary macro is <tt>ax_pkg_swig</tt>, see
<a href="http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html#ax_pkg_swig">http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html#ax_pkg_swig</a>.
The <tt>ax_python_devel</tt> macro is also helpful for generating Python extensions. See the
<a href="http://www.gnu.org/software/autoconf-archive/">Autoconf Archive</a>
for further information on this and other Autoconf macros.
</p>

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more