+Depending on your operating system and version of Java and how you are using threads, you might find the JVM hangs on exit.
+There are a couple of solutions to try out. The preferred solution requires jdk-1.4 and later and uses AttachCurrentThreadAsDaemon instead of AttachCurrentThread whenever a call into the JVM is required. This can be enabled by defining the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro when compiling the C++ wrapper code. For older JVMs define SWIG_JAVA_NO_DETACH_CURRENT_THREAD instead, to avoid the DetachCurrentThread call but this will result in a memory leak instead. For further details inspect the source code in the java/director.swg library file.
+
+
+
+Macros can be defined on the commandline when compiling your C++ code, or alternatively added to the C++ wrapper file as shown below:
+
-This is great for reducing the size of the wrappers, but the caveat is it does not work for the strongly typed languages
-which don't have optional arguments in the language, such as C# and Java.
+This is great for reducing the size of the wrappers, but the caveat is it does not work for the statically typed languages,
+such as C# and Java,
+which don't have optional arguments in the language,
Another restriction of this feature is that it cannot handle default arguments that are not public.
The following example illustrates this:
Implementation
@@ -702,7 +702,7 @@ variables (parms). The purpose of these variables will be explained shortly.
code specifies the code used in the typemap.
-Usually this is C/C++ code, but in the strongly typed target languages, such as Java and C#, this can contain target language code for certain typemaps.
+Usually this is C/C++ code, but in the statically typed target languages, such as Java and C#, this can contain target language code for certain typemaps.
It can take any one of the following forms:
@@ -1933,7 +1933,7 @@ to implement customized conversions.
In addition, the "in" typemap allows the number of converted arguments to be
-specified. For example:
+specified. The numinputs attributes facilitates this. For example:
@@ -1946,7 +1946,12 @@ specified. For example:
-At this time, only zero or one arguments may be converted.
+At this time, only zero or one arguments may be converted.
+When numinputs is set to 0, the argument is effectively ignored and cannot be supplied from the target language.
+The argument is still required when making the C/C++ call and the above typemap
+shows the value used is instead obtained from a locally declared variable called temp.
+Usually numinputs is not specified, whereupon the default value is 1, that is, there is a one to one mapping of the number of arguments when used from the target language to the C/C++ call.
+Multi-argument typemaps provide a similar concept where the number of arguments mapped from the target language to C/C++ can be changed for more tha multiple adjacent C/C++ arguments.
@@ -2811,7 +2816,7 @@ optimal attribute usage in the out typemap at example.i:7.
However, it doesn't always get it right, for example when $1 is within some commented out code.
-
10.9 Multi-argument typemaps
+
10.9 Multi-argument typemaps
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 39d5d3f01..0b3cb37e9 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -373,7 +373,7 @@ example.i(4): Syntax error in input.
117. Deprecated %new directive.
118. Deprecated %typemap(except).
119. Deprecated %typemap(ignore).
-
120. Deprecated command line option (-c).
+
120. Deprecated command line option (-runtime, -noruntime).
+This chapter describes SWIG's support for creating ANSI C wrappers. This module has a special purpose and thus is different from most other modules.
+
+
+
+NOTE: this module is still under development.
+
+
+
+
36.1 Overview
+
+
+
+SWIG is normally used to generate scripting language interface to C or C++ libraries. In the process, it performs analysis of library header files, generates intermediary C code, from which a set of language specific functions is constructed, which can be then accessed in the scripting language code. Having the C code needed to generate wrapper functions for specific language module, we are only one step away from being able to generate pure ANSI C interface to the input C or C++ library. Then we can think of C as just any other target language supported by SWIG.
+
+
+
+With wrapper interface generated by SWIG, it is easy to use functionality of C++ libraries inside application code written in C. The module may also be useful to generate custom API for a library, to suit particular needs, e.g. to supply the function calls with error checking or to implement "design by contract" approach.
+
+
+
+Flattening C++ language constructs into a set of C-style functions obviously comes with many limitations and inconveniences. All data and functions becomes global. Manipulating objects requires explicit calls to special functions. We are losing the high level abstraction and have to work around it.
+
+
+
36.2 Preliminaries
+
+
+
36.2.1 Running SWIG
+
+
+
+Consider following simple example. Suppose we have an interface file like:
+
+To build a C module, run SWIG using the -c option :
+
+
+%swig -c example.i
+
+
+
+If building C++, add the -c++ option:
+
+
+
+$ swig -c++ -c example.i
+
+
+
+This will generate example_wrap.c file or, in the latter case, example_wrap.cxx file, along with example_proxy.h and example_proxy.c files. The name of the file is derived from the name of the input file. To change this, you can use the -o option.
+
+
+
+The wrap file contains the wrapper functions, which perform the main functionality of SWIG: they translate input arguments from C to C++, make call to original functions and all the neccessery actions, and translate C++ output back to C data. The proxy header file contains the interface we can use in C application code. The additional .c file contains calls to the wrapper functions, allowing us to preserve names of the original functions.
+
+
+
36.2.2 Command line options
+
+
+
+The following table list the additional commandline options available for the C module. They can also be seen by using:
+
+
+
+swig -c -help
+
+
+
+
+
C specific options
+
+
+
+
-noproxy
+
do not generate proxy files (i.e. filename_proxy.h and filename_proxy.c)
+
+
+
+
-noexcept
+
generate wrappers with no support of exception handling; see Exceptions chapter for more details
+
+
+
+
+
36.2.3 Compiling dynamic module
+
+
+The next step is to build dynamically loadable module, which we can link to our application. This can be done easily, for example using gcc compiler (Linux, MINGW, etc.):
+
+
+Now the shared library module is ready to use. Note that the name of generated module is important: is should be prefixed with lib, and have the specific extension, like .dll for Windows or .so for Unix systems.
+
+
+
36.2.4 Using generated module
+
+
+
+The simplest way to use generated shared module is to link it to the application code on the compiling stage. We have to compile the proxy file as well. The process is usually similar to the shown below:
+
+This will compile application code (runme.c), along with proxy and link it against the generated shared module. Following the -L option is the path to the directory containing the shared module. The output executable is ready to use. The last thing to do is to supply the operating system the information of location of our module. This is system dependant, for instance Unix systems look for shared modules in certain directories, like /usr/lib, and additionally we can set the environment variable LD_LIBRARY_PATH for other directories.
+
+
+
36.3 Basic C wrapping
+
+
+
36.3.1 Functions
+
+
+
36.3.2 Variables
+
+
+
36.4 Basic C++ wrapping
+
+
+
36.4.1 Classes
+
+
+
36.5 Exception handling
+
+
+
+
+
+
diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters
index 55a0aec13..840709d89 100644
--- a/Doc/Manual/chapters
+++ b/Doc/Manual/chapters
@@ -14,6 +14,7 @@ Varargs.html
Warnings.html
Modules.html
Allegrocl.html
+C.html
CSharp.html
Chicken.html
Guile.html
From 40fd778b2338e5c5033cfc1cf3745c98516449ab Mon Sep 17 00:00:00 2001
From: Maciej Drwal
Date: Sun, 24 Aug 2008 12:39:30 +0000
Subject: [PATCH 040/508] 1. char_strings runtime test 2. next chapters of HTML
doc 3. minor bugfixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10796 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/C.html | 193 +++++++++++++++++++-
Examples/test-suite/c/Makefile.in | 10 +-
Examples/test-suite/c/char_strings_runme.c | 198 +++++++++++++++++++++
Lib/c/c.swg | 18 ++
Source/Modules/c.cxx | 95 +++++++---
5 files changed, 485 insertions(+), 29 deletions(-)
create mode 100644 Examples/test-suite/c/char_strings_runme.c
diff --git a/Doc/Manual/C.html b/Doc/Manual/C.html
index f489c02c1..0bab1a479 100644
--- a/Doc/Manual/C.html
+++ b/Doc/Manual/C.html
@@ -54,7 +54,7 @@ With wrapper interface generated by SWIG, it is easy to use functionality of C++
-Flattening C++ language constructs into a set of C-style functions obviously comes with many limitations and inconveniences. All data and functions becomes global. Manipulating objects requires explicit calls to special functions. We are losing the high level abstraction and have to work around it.
+Flattening C++ language constructs into a set of C-style functions obviously comes with many limitations and inconveniences. All data and functions become global. Manipulating objects requires explicit calls to special functions. We are losing the high level abstraction and have to work around it.
36.2 Preliminaries
@@ -132,7 +132,9 @@ swig -c -help
36.2.3 Compiling dynamic module
+
The next step is to build dynamically loadable module, which we can link to our application. This can be done easily, for example using gcc compiler (Linux, MINGW, etc.):
+
$ swig -c example.i
@@ -172,18 +174,207 @@ This will compile application code (runme.c), along with proxy and link
36.3 Basic C wrapping
+
+Wrapping C functions and variables is obviously performed in straightforward way. There is no need to perform type conversions, and all language constructs can be preserved in their original form. However, SWIG allows you to enchance the code with some additional elements, for instance using check typemap or %extend directive.
+
+
36.3.1 Functions
+
+For each C function declared in the interface file a wrapper function is created. Basically, the wrapper function performs a call to the original function, and returns its result.
+
+
+
+For example, for function declaration:
+
+
+
+int gcd(int x, int y);
+
+
+
+The output is simply:
+
+
+
+int _wrap_gcd(int arg1, int arg2) {
+ int result;
+ result = gcd(arg1,arg2);
+ return result;
+}
+
+
+
+Then again, this wrapper function is usually called from C using helper function declared in proxy file, preserving the original name:
+
+Now one might think, what's the use of creating such functions in C? The answer is, you can apply special rules to the generated code. Take for example constraint checking. You can write a "check" typemap in your interface file:
+
+
+
+%typemap(check) int POSITIVE {
+ if ($1 <= 0)
+ fprintf(stderr, "Expected positive value in $name.\n");
+}
+
+int gcd(int POSITIVE, int POSITIVE);
+
+
+
+And now the generated result looks like:
+
+
+
+int _wrap_gcd(int arg1, int arg2) {
+ {
+ if (arg1 <= 0)
+ fprintf(stderr, "Expected positive value in gcd.\n");
+ }
+ {
+ if (arg1 <= 0)
+ fprintf(stderr, "Expected positive value in gcd.\n");
+ }
+ int result;
+ result = gcd(arg1,arg2);
+ return result;
+}
+
+
+
+This time calling gcd with negative value argument will trigger an error message. This can save you time writing all the constraint checking code by hand.
+
+
36.3.2 Variables
+
+Wrapping variables comes also without any special issues. All global variables are directly accessible from application code. There is a difference in the semantics of struct definition in C and C++. When handling C struct, SWIG simply rewrites its declaration. In C++ struct is handled as class declaration.
+
+
+
+You can still apply some of the SWIG features when handling structs, e.g. %extend directive. Suppose, you have a C struct declaration:
+
+The main reason of having the C module in SWIG is to be able to access C++ from C. In this chapter we will take a look at the rules of wrapping elements of C++ language.
+
+
36.4.1 Classes
+
+Consider the following example. We have a C++ class, and want to refer to it in C.
+
+What we need to do is to create an object of the class, then to be able to manipulate on it, and finally, to be able to destroy it. SWIG generates C functions for this purpose each time a class declaration is encountered in the interface file.
+
+
+
+The first two generated functions are used to create and destroy instances of class Circle. Such an instances are represented on the C side as pointers to special structs, called SwigObj. They are all "renamed" (via typedef) to the original class names, so that you can refer to the object instances on the C side using pointers like:
+
+
+
+Circle *circle;
+
+
+
+The generated functions make calls to class' constructors and destructors, respectively. They also do all the necessary things required by the SWIG object management system in C.
+
+For each public method, an appropriate function is generated:
+
+
+
+double Circle_area(Circle * self);
+
+
+
+You can see that in order to refer to the generated object we need to provide a pointer to the object instance (struct Circle in this case) as the first function argument. In fact, this struct is basically wrapping pointer to the "real" C++ object.
+
diff --git a/Examples/test-suite/c/Makefile.in b/Examples/test-suite/c/Makefile.in
index bef483450..4c8134231 100644
--- a/Examples/test-suite/c/Makefile.in
+++ b/Examples/test-suite/c/Makefile.in
@@ -13,10 +13,12 @@ top_builddir = @top_builddir@/..
C_TEST_CASES =
CPP_TEST_CASES = \
- exception_order \
- exception_partial_info \
- enums \
- enum_plus \
+ cast_operator \
+ char_strings \
+ exception_order \
+ exception_partial_info \
+ enums \
+ enum_plus \
include $(srcdir)/../common.mk
diff --git a/Examples/test-suite/c/char_strings_runme.c b/Examples/test-suite/c/char_strings_runme.c
new file mode 100644
index 000000000..6e831d5c2
--- /dev/null
+++ b/Examples/test-suite/c/char_strings_runme.c
@@ -0,0 +1,198 @@
+#include
+
+#include "char_strings/char_strings_proxy.h"
+
+int main() {
+ char *CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
+ char *OTHERLAND_MSG = "Little message from the safe world.";
+
+ long count = 10000;
+ long i = 0;
+
+ // get functions
+ for (i=0; i}
@@ -58,6 +61,9 @@
%typemap(in) const short &, const int &, const long &, const char &, const float &, const double & "$1 = ($1_basetype *) $input;"
%typemap(in) unsigned short &, unsigned int &, unsigned long &, unsigned char & "$1 = ($1_basetype *) $input;"
%typemap(in) const unsigned short &, const unsigned int &, const unsigned long &, const unsigned char & "$1 = ($1_basetype *) $input;"
+
+%typemap(in) short *&, int *&, long *&, char *&, float *&, double *& "$1 = ($1_ltype) $input;"
+%typemap(in) const short *&, const int *&, const long *&, const char *&, const float *&, const double *& "$1 = ($1_ltype) $input;"
%typemap(in) short [ANY], int [ANY], long [ANY], char [ANY], float [ANY], double [ANY] "$1 = ($1_basetype *) $input;"
%typemap(in) void * [ANY], short * [ANY], int * [ANY], long * [ANY], char * [ANY], float * [ANY], double * [ANY] "$1 = ($1_basetype *) $input;"
@@ -119,6 +125,13 @@
$1 = ($1_basetype *) 0;
}
+%typemap(in) SWIGTYPE *& {
+ if ($input)
+ $1 = ($1_basetype **) &(*$input)->obj;
+ else
+ $1 = ($1_basetype **) 0;
+}
+
// typemaps for return values
%typemap(couttype) void, short, int, long, char, float, double "$1_type"
@@ -127,6 +140,8 @@
%typemap(couttype) const void *, const short *, const int *, const long *, const char *, const float *, const double * "$1_type"
%typemap(couttype) short &, int &, long &, char &, float &, double & "$1_basetype *"
%typemap(couttype) const short &, const int &, const long &, const char &, const float &, const double & "$1_basetype const *"
+%typemap(couttype) short *&, int *&, long *&, char *&, float *&, double *& "$1_basetype **"
+%typemap(couttype) const short *&, const int *&, const long *&, const char *&, const float *&, const double *& "$1_basetype **"
%typemap(couttype) short [ANY], int [ANY], long [ANY], char [ANY], float [ANY], double [ANY] "$1_basetype *"
%typemap(couttype) SWIGTYPE "SwigObj *"
%typemap(couttype) SWIGTYPE * "SwigObj *"
@@ -149,6 +164,8 @@
%typemap(out) unsigned short &, unsigned int &, unsigned long &, unsigned char & "$result = $1;"
%typemap(out) const short &, const int &, const long &, const char &, const float &, const double & "$result = $1;"
%typemap(out) const unsigned short &, const unsigned int &, const unsigned long &, const unsigned char & "$result = $1;"
+%typemap(out) short *&, int *&, long *&, char *&, float *&, double *& "$result = $1;"
+%typemap(out) const short *&, const int *&, const long *&, const char *&, const float *&, const double *& "$result = $1;"
%typemap(out) short [ANY], int [ANY], long [ANY], char [ANY], float [ANY], double [ANY] "$result = $1;"
%typemap(out) void ""
@@ -202,6 +219,7 @@
$result = (SwigObj***) 0;
}
+
#ifdef SWIG_C_EXCEPT
%insert("runtime") %{
typedef struct {
diff --git a/Source/Modules/c.cxx b/Source/Modules/c.cxx
index 3755d1446..162a96c5f 100644
--- a/Source/Modules/c.cxx
+++ b/Source/Modules/c.cxx
@@ -78,6 +78,9 @@ public:
}
}
+ if (!CPlusPlus)
+ except_flag = false;
+
// add a symbol to the parser for conditional compilation
Preprocessor_define("SWIGC 1", 0);
Preprocessor_define("SWIG_C_RUNTME 1", 0);
@@ -256,8 +259,19 @@ public:
SwigType *type = Getattr(n, "type");
if (SwigType_isenum(type))
type = make_enum_type(n, type);
- String *type_str = SwigType_str(type, 0);
- Printv(f_proxy_header, "SWIGIMPORT ", type_str, " ", name, ";\n\n", NIL);
+ String *type_str = Copy(SwigType_str(type, 0));
+ if (SwigType_isarray(type)) {
+ String *dims = Strchr(type_str, '[');
+ char *c = Char(type_str);
+ c[Len(type_str) - Len(dims) - 1] = '\0';
+ String *bare_type = NewStringf("%s", c);
+ //Printv(f_proxy_header, "SWIGIMPORT ", bare_type, " *", name, ";\n\n", NIL);
+ Printv(f_proxy_header, "SWIGIMPORT ", bare_type, " ", name, "[];\n\n", NIL);
+ Delete(bare_type);
+ }
+ else
+ Printv(f_proxy_header, "SWIGIMPORT ", type_str, " ", name, ";\n\n", NIL);
+ Delete(type_str);
return SWIG_OK;
}
@@ -452,6 +466,23 @@ ready:
gencomma = 1;
}
Printv(wrapper->def, return_type, " ", wname, "(", proto, ") {\n", NIL);
+
+ // attach 'check' typemaps
+ Swig_typemap_attach_parms("check", parms, wrapper);
+
+ // insert constraint checking
+ for (p = parms; p; ) {
+ if ((tm = Getattr(p, "tmap:check"))) {
+ Replaceall(tm, "$target", Getattr(p, "lname"));
+ Replaceall(tm, "$name", name);
+ Printv(wrapper->code, tm, "\n", NIL);
+ p = Getattr(p, "tmap:check:next");
+ }
+ else {
+ p = nextSibling(p);
+ }
+ }
+
Append(wrapper->code, prepend_feature(n));
if (!is_void_return) {
Printv(wrapper->code, return_type, " result;\n", NIL);
@@ -538,6 +569,9 @@ ready:
return_var_type = SwigType_base(type);
SwigType_add_pointer(return_var_type);
}
+ if (SwigType_ispointer(type)) {
+ SwigType_add_pointer(return_var_type);
+ }
SwigType_add_reference(type);
}
else if (SwigType_isarray(type)) {
@@ -562,6 +596,8 @@ ready:
else if (SwigType_isreference(type)) {
return_var_type = SwigType_base(type);
SwigType_add_pointer(return_var_type);
+ if (SwigType_ispointer(type))
+ SwigType_add_pointer(return_var_type);
}
else if (SwigType_isarray(type)) {
return_var_type = SwigType_base(type);
@@ -682,6 +718,19 @@ ready:
// emit variable for holding function return value
emit_return_variable(n, return_type, wrapper);
+ // insert constraint checking
+ for (p = parms; p; ) {
+ if ((tm = Getattr(p, "tmap:check"))) {
+ Replaceall(tm, "$target", Getattr(p, "lname"));
+ Replaceall(tm, "$name", name);
+ Printv(wrapper->code, tm, "\n", NIL);
+ p = Getattr(p, "tmap:check:next");
+ }
+ else {
+ p = nextSibling(p);
+ }
+ }
+
// emit action code
String *action = emit_action(n);
String *except = Getattr(n, "feature:except");
@@ -724,18 +773,6 @@ ready:
Append(wrapper->code, action);
}
- // insert constraint checking
- for (p = parms; p; ) {
- if ((tm = Getattr(p, "tmap:check"))) {
- Replaceall(tm, "$target", Getattr(p, "lname"));
- Printv(wrapper->code, tm, "\n", NIL);
- p = Getattr(p, "tmap:check:next");
- }
- else {
- p = nextSibling(p);
- }
- }
-
// insert cleanup code
for (p = parms; p; ) {
if ((tm = Getattr(p, "tmap:freearg"))) {
@@ -822,6 +859,24 @@ ready:
return false;
}
+ /* ---------------------------------------------------------------------
+ * emit_c_struct_def()
+ * --------------------------------------------------------------------- */
+
+ void emit_c_struct_def(Node *node) {
+ for ( ; node; node = nextSibling(node)) {
+ String* kind = Getattr(node, "kind");
+ if ((Cmp(kind, "variable") == 0) || (Cmp(kind, "function") == 0)) {
+ String* type = NewString("");
+ Printv(type, Getattr(node, "decl"), Getattr(node, "type"), NIL);
+ Printv(f_proxy_header, " ", SwigType_str(type, 0), " ", Getattr(node, "name"), ";\n", NIL);
+ Delete(type);
+ }
+ if (Cmp(nodeType(node), "extend") == 0)
+ emit_c_struct_def(firstChild(node));
+ }
+ }
+
/* ---------------------------------------------------------------------
* classHandler()
* --------------------------------------------------------------------- */
@@ -877,16 +932,8 @@ ready:
// this is C struct, just declare it in proxy
if (proxy_flag) {
Printv(f_proxy_header, "struct ", name, " {\n", NIL);
- Node* node;
- for (node = firstChild(n); node; node = nextSibling(node)) {
- String* kind = Getattr(node, "kind");
- if ((Cmp(kind, "variable") == 0) || (Cmp(kind, "function") == 0)) {
- String* type = NewString("");
- Printv(type, Getattr(node, "decl"), Getattr(node, "type"), NIL);
- Printv(f_proxy_header, " ", SwigType_str(type, 0), " ", Getattr(node, "name"), ";\n", NIL);
- Delete(type);
- }
- }
+ Node *node = firstChild(n);
+ emit_c_struct_def(node);
Append(f_proxy_header, "};\n\n");
}
From f2cd76308ee55378cb6fc8fb060eee81854974ad Mon Sep 17 00:00:00 2001
From: Maciej Drwal
Date: Sun, 24 Aug 2008 12:59:17 +0000
Subject: [PATCH 041/508] include in char_strings_runme.c
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10797 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/c/char_strings_runme.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/Examples/test-suite/c/char_strings_runme.c b/Examples/test-suite/c/char_strings_runme.c
index 6e831d5c2..4ddc217d0 100644
--- a/Examples/test-suite/c/char_strings_runme.c
+++ b/Examples/test-suite/c/char_strings_runme.c
@@ -1,4 +1,5 @@
#include
+#include
#include "char_strings/char_strings_proxy.h"
From c7942801c0915961fbcfa92025754810fc01c8a1 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 7 Sep 2008 21:59:24 +0000
Subject: [PATCH 042/508] minor display fix for swig -help
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10814 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/Modules/c.cxx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Source/Modules/c.cxx b/Source/Modules/c.cxx
index 162a96c5f..d15f88d60 100644
--- a/Source/Modules/c.cxx
+++ b/Source/Modules/c.cxx
@@ -1480,7 +1480,7 @@ extern "C" Language *swig_c(void) {
const char *C::usage = (char *) "\
C Options (available with -c)\n\
- -noproxy - do not generate proxy interface\n\
- -noexcept - do not generate exception handling code\n\
+ -noproxy - do not generate proxy interface\n\
+ -noexcept - do not generate exception handling code\n\
\n";
From fde19227a364ad92f3ca206c34d159bdab92f7f2 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 7 Sep 2008 21:59:57 +0000
Subject: [PATCH 043/508] Fix typos after proof read
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10815 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/C.html | 49 +++++++++++++++++++++++++++--------------------
1 file changed, 28 insertions(+), 21 deletions(-)
diff --git a/Doc/Manual/C.html b/Doc/Manual/C.html
index 0bab1a479..80146298f 100644
--- a/Doc/Manual/C.html
+++ b/Doc/Manual/C.html
@@ -1,11 +1,11 @@
-SWIG and C
+SWIG and C as the target language
-
36 SWIG and C
+
36 SWIG and C as the target language
@@ -46,11 +46,14 @@ This chapter describes SWIG's support for creating ANSI C wrappers. This module
-SWIG is normally used to generate scripting language interface to C or C++ libraries. In the process, it performs analysis of library header files, generates intermediary C code, from which a set of language specific functions is constructed, which can be then accessed in the scripting language code. Having the C code needed to generate wrapper functions for specific language module, we are only one step away from being able to generate pure ANSI C interface to the input C or C++ library. Then we can think of C as just any other target language supported by SWIG.
+SWIG is normally used to provide access to C or C++ libraries from target languages such as scripting languages or languages running on a virtual machine.
+SWIG performs analysis of the input C/C++ library header files from which it generates further code. For most target languages this code consists of two layers; namely an intermediary C code layer and a set of language specific proxy classes and functions on top of the C code layer.
+We could also think of C as just another target language supported by SWIG.
+The aim then is to generate a pure ANSI C interface to the input C or C++ library and hence the C target language module.
-With wrapper interface generated by SWIG, it is easy to use functionality of C++ libraries inside application code written in C. The module may also be useful to generate custom API for a library, to suit particular needs, e.g. to supply the function calls with error checking or to implement "design by contract" approach.
+With wrapper interfaces generated by SWIG, it is easy to use the functionality of C++ libraries inside application code written in C. This module may also be useful to generate custom APIs for a library, to suit particular needs, e.g. to supply function calls with error checking or to implement a "design by contract".
@@ -64,7 +67,7 @@ Flattening C++ language constructs into a set of C-style functions obviously com
-Consider following simple example. Suppose we have an interface file like:
+Consider the following simple example. Suppose we have an interface file like:
@@ -79,14 +82,14 @@ int fact(int n);
-To build a C module, run SWIG using the -c option :
+To build a C module (C as the target language), run SWIG using the -c option :
%swig -c example.i
-If building C++, add the -c++ option:
+The above assumes C as the input language. If the input language is C++ add the -c++ option:
@@ -94,11 +97,15 @@ $ swig -c++ -c example.i
-This will generate example_wrap.c file or, in the latter case, example_wrap.cxx file, along with example_proxy.h and example_proxy.c files. The name of the file is derived from the name of the input file. To change this, you can use the -o option.
+Note that -c is the option specifying the target language and -c++ controls what the input language is.
+
+
+
+This will generate an example_wrap.c file or, in the latter case, example_wrap.cxx file, along with example_proxy.h and example_proxy.c files. The name of the file is derived from the name of the input file. To change this, you can use the -o option common to all language modules.
-The wrap file contains the wrapper functions, which perform the main functionality of SWIG: they translate input arguments from C to C++, make call to original functions and all the neccessery actions, and translate C++ output back to C data. The proxy header file contains the interface we can use in C application code. The additional .c file contains calls to the wrapper functions, allowing us to preserve names of the original functions.
+The wrap file contains the wrapper functions, which perform the main functionality of SWIG: it translates the input arguments from C to C++, makes calls to the original functions and marshalls C++ output back to C data. The proxy header file contains the interface we can use in C application code. The additional .c file contains calls to the wrapper functions, allowing us to preserve names of the original functions.
36.2.2 Command line options
@@ -129,11 +136,11 @@ swig -c -help
-
36.2.3 Compiling dynamic module
+
36.2.3 Compiling a dynamic module
-The next step is to build dynamically loadable module, which we can link to our application. This can be done easily, for example using gcc compiler (Linux, MINGW, etc.):
+The next step is to build a dynamically loadable module, which we can link to our application. This can be done easily, for example using the gcc compiler (Linux, MinGW, etc.):
-Now the shared library module is ready to use. Note that the name of generated module is important: is should be prefixed with lib, and have the specific extension, like .dll for Windows or .so for Unix systems.
+Now the shared library module is ready to use. Note that the name of the generated module is important: is should be prefixed with lib on Unix, and have the specific extension, like .dll for Windows or .so for Unix systems.
-
36.2.4 Using generated module
+
36.2.4 Using the generated module
-The simplest way to use generated shared module is to link it to the application code on the compiling stage. We have to compile the proxy file as well. The process is usually similar to the shown below:
+The simplest way to use the generated shared module is to link it to the application code during the compilation stage. We have to compile the proxy file as well. The process is usually similar to this:
-This will compile application code (runme.c), along with proxy and link it against the generated shared module. Following the -L option is the path to the directory containing the shared module. The output executable is ready to use. The last thing to do is to supply the operating system the information of location of our module. This is system dependant, for instance Unix systems look for shared modules in certain directories, like /usr/lib, and additionally we can set the environment variable LD_LIBRARY_PATH for other directories.
+This will compile the application code (runme.c), along with the proxy code and link it against the generated shared module. Following the -L option is the path to the directory containing the shared module. The output executable is ready to use. The last thing to do is to supply to the operating system the information of location of our module. This is system dependant, for instance Unix systems look for shared modules in certain directories, like /usr/lib, and additionally we can set the environment variable LD_LIBRARY_PATH (Unix) or PATH (Windows) for other directories.
36.3 Basic C wrapping
-Wrapping C functions and variables is obviously performed in straightforward way. There is no need to perform type conversions, and all language constructs can be preserved in their original form. However, SWIG allows you to enchance the code with some additional elements, for instance using check typemap or %extend directive.
+Wrapping C functions and variables is obviously performed in a straightforward way. There is no need to perform type conversions, and all language constructs can be preserved in their original form. However, SWIG allows you to enchance the code with some additional elements, for instance using check typemap or %extend directive.
36.3.1 Functions
@@ -294,14 +301,14 @@ ms.d = 123.123;
-The main reason of having the C module in SWIG is to be able to access C++ from C. In this chapter we will take a look at the rules of wrapping elements of C++ language.
+The main reason of having the C module in SWIG is to be able to access C++ from C. In this chapter we will take a look at the rules of wrapping elements of the C++ language.
36.4.1 Classes
-Consider the following example. We have a C++ class, and want to refer to it in C.
+Consider the following example. We have a C++ class, and want to use it from C code.
@@ -315,11 +322,11 @@ public:
-What we need to do is to create an object of the class, then to be able to manipulate on it, and finally, to be able to destroy it. SWIG generates C functions for this purpose each time a class declaration is encountered in the interface file.
+What we need to do is to create an object of the class, manipulate it, and finally, destroy it. SWIG generates C functions for this purpose each time a class declaration is encountered in the interface file.
-The first two generated functions are used to create and destroy instances of class Circle. Such an instances are represented on the C side as pointers to special structs, called SwigObj. They are all "renamed" (via typedef) to the original class names, so that you can refer to the object instances on the C side using pointers like:
+The first two generated functions are used to create and destroy instances of class Circle. Such instances are represented on the C side as pointers to special structs, called SwigObj. They are all "renamed" (via typedef) to the original class names, so that you can use the object instances on the C side using pointers like:
-You can see that in order to refer to the generated object we need to provide a pointer to the object instance (struct Circle in this case) as the first function argument. In fact, this struct is basically wrapping pointer to the "real" C++ object.
+You can see that in order to use the generated object we need to provide a pointer to the object instance (struct Circle in this case) as the first function argument. In fact, this struct is basically wrapping pointer to the "real" C++ object.
@@ -42,7 +42,7 @@ This chapter describes SWIG's support for creating ANSI C wrappers. This module
-
36.1 Overview
+
17.1 Overview
@@ -60,10 +60,10 @@ With wrapper interfaces generated by SWIG, it is easy to use the functionality o
Flattening C++ language constructs into a set of C-style functions obviously comes with many limitations and inconveniences. All data and functions become global. Manipulating objects requires explicit calls to special functions. We are losing the high level abstraction and have to work around it.
-
36.2 Preliminaries
+
17.2 Preliminaries
-
36.2.1 Running SWIG
+
17.2.1 Running SWIG
@@ -98,7 +98,7 @@ $ swig -c++ -c example.i
Note that -c is the option specifying the target language and -c++ controls what the input language is.
-
+
This will generate an example_wrap.c file or, in the latter case, example_wrap.cxx file, along with example_proxy.h and example_proxy.c files. The name of the file is derived from the name of the input file. To change this, you can use the -o option common to all language modules.
@@ -108,7 +108,7 @@ This will generate an example_wrap.c file or, in the latter case, e
The wrap file contains the wrapper functions, which perform the main functionality of SWIG: it translates the input arguments from C to C++, makes calls to the original functions and marshalls C++ output back to C data. The proxy header file contains the interface we can use in C application code. The additional .c file contains calls to the wrapper functions, allowing us to preserve names of the original functions.
-
36.2.2 Command line options
+
17.2.2 Command line options
@@ -136,7 +136,7 @@ swig -c -help
-
36.2.3 Compiling a dynamic module
+
17.2.3 Compiling a dynamic module
@@ -163,7 +163,7 @@ $ g++ -shared example_wrap.o -o libexample.so
Now the shared library module is ready to use. Note that the name of the generated module is important: is should be prefixed with lib on Unix, and have the specific extension, like .dll for Windows or .so for Unix systems.
-
36.2.4 Using the generated module
+
17.2.4 Using the generated module
@@ -178,14 +178,14 @@ $ gcc runme.c example_proxy.c -L. -lexample -o runme
This will compile the application code (runme.c), along with the proxy code and link it against the generated shared module. Following the -L option is the path to the directory containing the shared module. The output executable is ready to use. The last thing to do is to supply to the operating system the information of location of our module. This is system dependant, for instance Unix systems look for shared modules in certain directories, like /usr/lib, and additionally we can set the environment variable LD_LIBRARY_PATH (Unix) or PATH (Windows) for other directories.
-
36.3 Basic C wrapping
+
17.3 Basic C wrapping
Wrapping C functions and variables is obviously performed in a straightforward way. There is no need to perform type conversions, and all language constructs can be preserved in their original form. However, SWIG allows you to enchance the code with some additional elements, for instance using check typemap or %extend directive.
-
36.3.1 Functions
+
17.3.1 Functions
@@ -259,7 +259,7 @@ int _wrap_gcd(int arg1, int arg2) {
This time calling gcd with negative value argument will trigger an error message. This can save you time writing all the constraint checking code by hand.
-
36.3.2 Variables
+
17.3.2 Variables
@@ -297,14 +297,14 @@ ms.x = 123;
ms.d = 123.123;
-
36.4 Basic C++ wrapping
+
17.4 Basic C++ wrapping
The main reason of having the C module in SWIG is to be able to access C++ from C. In this chapter we will take a look at the rules of wrapping elements of the C++ language.
@@ -397,7 +397,7 @@ Windows users can also get the examples working using a
Cygwin or MinGW environment for automatic configuration of the example makefiles.
Any one of the three C# compilers (Portable.NET, Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path.
-
17.3 C# Exceptions
+
18.3 C# Exceptions
@@ -494,7 +494,7 @@ set so should only be used when a C# exception is not created.
-
17.3.1 C# exception example using "check" typemap
+
18.3.1 C# exception example using "check" typemap
@@ -676,7 +676,7 @@ method and C# code does not handle pending exceptions via the canthrow attribute
Actually it will issue this warning for any function beginning with SWIG_CSharpSetPendingException.
-
17.3.2 C# exception example using %exception
+
18.3.2 C# exception example using %exception
@@ -741,7 +741,7 @@ The managed code generated does check for the pending exception as mentioned ear
-
17.3.3 C# exception example using exception specifications
+
18.3.3 C# exception example using exception specifications
@@ -798,7 +798,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) {
Multiple catch handlers are generated should there be more than one exception specifications declared.
-
17.3.4 Custom C# ApplicationException example
+
18.3.4 Custom C# ApplicationException example
@@ -932,7 +932,7 @@ try {
-
17.4 C# Directors
+
18.4 C# Directors
@@ -945,7 +945,7 @@ The following sections provide information on the C# director implementation and
However, the Java directors section should also be read in order to gain more insight into directors.
@@ -1300,7 +1300,7 @@ However, a call from C# to CSharpDefaults.DefaultMethod() will of cours
should pass the call on to CSharpDefaults.DefaultMethod(int)using the C++ default value, as shown above.
-
17.5 C# Typemap examples
+
18.5 C# Typemap examples
This section includes a few examples of typemaps. For more examples, you
@@ -1308,7 +1308,7 @@ might look at the files "csharp.swg" and "typemaps.i" in
the SWIG library.
-
17.5.1 Memory management when returning references to member variables
+
18.5.1 Memory management when returning references to member variables
@@ -1432,7 +1432,7 @@ public class Bike : IDisposable {
Note the addReference call.
-
17.5.2 Memory management for objects passed to the C++ layer
+
18.5.2 Memory management for objects passed to the C++ layer
@@ -1551,7 +1551,7 @@ The 'cscode' typemap simply adds in the specified code into the C# proxy class.
-
17.5.3 Date marshalling using the csin typemap and associated attributes
+
18.5.3 Date marshalling using the csin typemap and associated attributes
@@ -1788,7 +1788,7 @@ public class example {
-
17.5.4 A date example demonstrating marshalling of C# properties
+
18.5.4 A date example demonstrating marshalling of C# properties
@@ -1888,7 +1888,7 @@ Some points to note:
-
17.5.5 Turning wrapped classes into partial classes
+
18.5.5 Turning wrapped classes into partial classes
@@ -1988,7 +1988,7 @@ demonstrating that the class contains methods calling both unmanaged code -
The following example is an alternative approach to adding managed code to the generated proxy class.
-
17.5.6 Extending proxy classes with additional C# code
+
18.5.6 Extending proxy classes with additional C# code
@@ -230,7 +230,7 @@
for info on how to apply the %feature.
-
18.2.4 Functions
+
19.2.4 Functions
@@ -249,7 +249,7 @@
parameters). The return values can then be accessed with (call-with-values).
-
18.2.5 Exceptions
+
19.2.5 Exceptions
The SWIG chicken module has support for exceptions thrown from
@@ -291,7 +291,7 @@
-
18.3 TinyCLOS
+
19.3 TinyCLOS
@@ -334,7 +334,7 @@
-
18.4 Linkage
+
19.4 Linkage
@@ -355,7 +355,7 @@
-
18.4.1 Static binary or shared library linked at compile time
+
19.4.1 Static binary or shared library linked at compile time
We can easily use csc to build a static binary.
@@ -396,7 +396,7 @@ in which case the test script does not need to be linked with example.so. The t
be run with csi.
-
18.4.2 Building chicken extension libraries
+
19.4.2 Building chicken extension libraries
Building a shared library like in the above section only works if the library
@@ -454,7 +454,7 @@ distributed and used by anyone, even if SWIG is not installed.
See the Examples/chicken/egg directory in the SWIG source for an example that builds
two eggs, one using the first method and one using the second method.
-
18.4.3 Linking multiple SWIG modules with TinyCLOS
+
19.4.3 Linking multiple SWIG modules with TinyCLOS
Linking together multiple modules that share type information using the %import
@@ -478,7 +478,7 @@ with (declare (uses ...)).
To create an extension library or an egg, just create a module_load.scm file that (declare (uses ...))
all the modules.
-
18.5 Typemaps
+
19.5 Typemaps
@@ -487,7 +487,7 @@ all the modules.
Lib/chicken/chicken.swg.
-
18.6 Pointers
+
19.6 Pointers
@@ -520,7 +520,7 @@ all the modules.
type. flags is either zero or SWIG_POINTER_DISOWN (see below).
-
18.6.1 Garbage collection
+
19.6.1 Garbage collection
If the owner flag passed to SWIG_NewPointerObj is 1, NewPointerObj will add a
@@ -551,7 +551,7 @@ all the modules.
18.7.1 TinyCLOS problems with Chicken version <= 1.92
+
19.7.1 TinyCLOS problems with Chicken version <= 1.92
In Chicken versions equal to or below 1.92, TinyCLOS has a limitation such that generic methods do not properly work on methods
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index c3197b9dc..ed90dc6d1 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -581,7 +581,34 @@
-
@@ -89,7 +89,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.
-
34.2 Prerequisites
+
35.2 Prerequisites
@@ -119,7 +119,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of
wrapper code are driven by C++ datatypes.
-
34.3 The Big Picture
+
35.3 The Big Picture
@@ -156,7 +156,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.
-
34.4 Execution Model
+
35.4 Execution Model
@@ -201,7 +201,7 @@ latter stage of compilation.
The next few sections briefly describe some of these stages.
-
34.4.1 Preprocessing
+
35.4.1 Preprocessing
@@ -281,7 +281,7 @@ been expanded as well as everything else that goes into the low-level
construction of the wrapper code.
-
34.4.2 Parsing
+
35.4.2 Parsing
@@ -382,7 +382,7 @@ returning a foo and taking types a and b as
arguments).
@@ -655,7 +655,7 @@ that matches the name of the target language. For example, python:fooperl:foo.
-
34.4.5 Symbol Tables
+
35.4.5 Symbol Tables
@@ -746,7 +746,7 @@ example.i:5. Previous declaration is foo_i(int )
-
34.4.6 The %feature directive
+
35.4.6 The %feature directive
@@ -802,7 +802,7 @@ For example, the exception code above is simply
stored without any modifications.
-
34.4.7 Code Generation
+
35.4.7 Code Generation
@@ -924,7 +924,7 @@ public :
The role of these functions is described shortly.
-
34.4.8 SWIG and XML
+
35.4.8 SWIG and XML
@@ -937,7 +937,7 @@ internal data structures, it may be useful to keep XML in the back of
your mind as a model.
-
34.5 Primitive Data Structures
+
35.5 Primitive Data Structures
@@ -983,7 +983,7 @@ typedef Hash Typetab;
-
34.5.1 Strings
+
35.5.1 Strings
@@ -1124,7 +1124,7 @@ Returns the number of replacements made (if any).
-
34.5.2 Hashes
+
35.5.2 Hashes
@@ -1201,7 +1201,7 @@ Returns the list of hash table keys.
-
34.5.3 Lists
+
35.5.3 Lists
@@ -1290,7 +1290,7 @@ If t is not a standard object, it is assumed to be a char *
and is used to create a String object.
-
34.5.4 Common operations
+
35.5.4 Common operations
The following operations are applicable to all datatypes.
@@ -1345,7 +1345,7 @@ objects and report errors.
Gets the line number associated with x.
-
34.5.5 Iterating over Lists and Hashes
+
35.5.5 Iterating over Lists and Hashes
To iterate over the elements of a list or a hash table, the following functions are used:
@@ -1390,7 +1390,7 @@ for (j = First(j); j.item; j= Next(j)) {
-
34.5.6 I/O
+
35.5.6 I/O
Special I/O functions are used for all internal I/O. These operations
@@ -1526,7 +1526,7 @@ Similarly, the preprocessor and parser all operate on string-files.
-
34.6 Navigating and manipulating parse trees
+
35.6 Navigating and manipulating parse trees
Parse trees are built as collections of hash tables. Each node is a hash table in which
@@ -1660,7 +1660,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u
the parent so that sibling nodes are unaffected.
-
34.7 Working with attributes
+
35.7 Working with attributes
@@ -1777,7 +1777,7 @@ the attribute is optional. Swig_restore() must always be called after
function.
-
34.8 Type system
+
35.8 Type system
@@ -1786,7 +1786,7 @@ pointers, references, and pointers to members. A detailed discussion of
type theory is impossible here. However, let's cover the highlights.
-
34.8.1 String encoding of types
+
35.8.1 String encoding of types
@@ -1887,7 +1887,7 @@ make the final type, the two parts are just joined together using
string concatenation.
-
34.8.2 Type construction
+
35.8.2 Type construction
@@ -2056,7 +2056,7 @@ Returns the prefix of a type. For example, if ty is
ty is unmodified.
-
34.8.3 Type tests
+
35.8.3 Type tests
@@ -2143,7 +2143,7 @@ Checks if ty is a varargs type.
Checks if ty is a templatized type.
-
34.8.4 Typedef and inheritance
+
35.8.4 Typedef and inheritance
@@ -2245,7 +2245,7 @@ Fully reduces ty according to typedef rules. Resulting datatype
will consist only of primitive typenames.
-
@@ -2344,7 +2344,7 @@ SWIG, but is most commonly associated with type-descriptor objects
that appear in wrappers (e.g., SWIGTYPE_p_double).
-
34.9 Parameters
+
35.9 Parameters
@@ -2443,7 +2443,7 @@ included. Used to emit prototypes.
Returns the number of required (non-optional) arguments in p.
-
34.10 Writing a Language Module
+
35.10 Writing a Language Module
@@ -2458,7 +2458,7 @@ describes the creation of a minimal Python module. You should be able to extra
this to other languages.
-
34.10.1 Execution model
+
35.10.1 Execution model
@@ -2468,7 +2468,7 @@ the parsing of command line options, all aspects of code generation are controll
different methods of the Language that must be defined by your module.
-
34.10.2 Starting out
+
35.10.2 Starting out
@@ -2576,7 +2576,7 @@ that activates your module. For example, swig -python foo.i. The
messages from your new module should appear.
-
34.10.3 Command line options
+
35.10.3 Command line options
@@ -2635,7 +2635,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit
unrecognized command line option error.
-
34.10.4 Configuration and preprocessing
+
35.10.4 Configuration and preprocessing
@@ -2684,7 +2684,7 @@ an implementation file python.cxx and a configuration file
python.swg.
-
34.10.5 Entry point to code generation
+
35.10.5 Entry point to code generation
@@ -2742,7 +2742,7 @@ int Python::top(Node *n) {
-
@@ -3038,7 +3038,7 @@ but without the typemaps, there is still work to do.
-
34.10.8 Configuration files
+
35.10.8 Configuration files
@@ -3188,7 +3188,7 @@ politely displays the ignoring language message.
-
34.10.9 Runtime support
+
35.10.9 Runtime support
@@ -3197,7 +3197,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g.
the SWIG files that implement those functions.
-
34.10.10 Standard library files
+
35.10.10 Standard library files
@@ -3216,7 +3216,7 @@ The following are the minimum that are usually supported:
Please copy these and modify for any new language.
-
34.10.11 Examples and test cases
+
35.10.11 Examples and test cases
@@ -3245,7 +3245,7 @@ during this process, see the section on configuration
files.
-
34.10.12 Documentation
+
35.10.12 Documentation
@@ -3277,7 +3277,7 @@ Some topics that you'll want to be sure to address include:
if available.
-
34.10.13 Prerequisites for adding a new language module to the SWIG distribution
+
35.10.13 Prerequisites for adding a new language module to the SWIG distribution
@@ -3334,7 +3334,7 @@ should be added should there be an area not already covered by
the existing tests.
-
34.10.14 Coding style guidelines
+
35.10.14 Coding style guidelines
@@ -3358,13 +3358,13 @@ 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.
This section details guile-specific support in SWIG.
-
19.1 Meaning of "Module"
+
20.1 Meaning of "Module"
@@ -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".
-
19.2 Using the SCM or GH Guile API
+
20.2 Using the SCM or GH Guile API
The guile module can currently export wrapper files that use the guile GH interface or the
@@ -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.
-
19.3 Linkage
+
20.3 Linkage
@@ -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 linkage.
-
19.3.1 Simple Linkage
+
20.3.1 Simple Linkage
@@ -206,7 +206,7 @@ placed between the define-module form and the
SWIG_init via a preprocessor define to avoid symbol
clashes. For this case, however, passive linkage is available.
-
19.3.2 Passive Linkage
+
20.3.2 Passive Linkage
Passive linkage is just like simple linkage, but it generates an
@@ -216,7 +216,7 @@ package name (see below).
You should use passive linkage rather than simple linkage when you
are using multiple modules.
-
19.3.3 Native Guile Module Linkage
+
20.3.3 Native Guile Module Linkage
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:
-
19.3.4 Old Auto-Loading Guile Module Linkage
+
20.3.4 Old Auto-Loading Guile Module Linkage
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.
-
19.3.5 Hobbit4D Linkage
+
20.3.5 Hobbit4D Linkage
@@ -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.
-
19.4 Underscore Folding
+
20.4 Underscore Folding
@@ -320,7 +320,7 @@ complained so far.
%rename to specify the Guile name of the wrapped
functions and variables (see CHANGES).
-
19.5 Typemaps
+
20.5 Typemaps
@@ -412,7 +412,7 @@ constant will appear as a scheme variable. See
Features and the %feature directive
for info on how to apply the %feature.
-
19.6 Representation of pointers as smobs
+
20.6 Representation of pointers as smobs
@@ -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 wrong-type-arg exception is raised.
-
19.6.1 GH Smobs
+
20.6.1 GH Smobs
@@ -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.
-
19.6.2 SCM Smobs
+
20.6.2 SCM Smobs
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.
-
19.6.3 Garbage Collection
+
20.6.3 Garbage Collection
Garbage collection is a feature of the new SCM interface, and it is automatically included
@@ -491,7 +491,7 @@ is exactly like described in
Object ownership and %newobject in the SWIG manual. All typemaps use an $owner var, and
the guile module replaces $owner with 0 or 1 depending on feature:new.
-
19.7 Exception Handling
+
20.7 Exception Handling
@@ -517,7 +517,7 @@ mapping:
The default when not specified here is to use "swig-error".
See Lib/exception.i for details.
-
19.8 Procedure documentation
+
20.8 Procedure documentation
If invoked with the command-line option -procdoc
@@ -553,7 +553,7 @@ like this:
typemap argument doc. See Lib/guile/typemaps.i for
details.
-
19.9 Procedures with setters
+
20.9 Procedures with setters
For global variables, SWIG creates a single wrapper procedure
@@ -581,7 +581,7 @@ struct members, the procedures (struct-member-get
pointer) and (struct-member-set pointer
value) are not generated.
-
19.10 GOOPS Proxy Classes
+
20.10 GOOPS Proxy Classes
SWIG can also generate classes and generic functions for use with
@@ -730,7 +730,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th
%import "foo.h" before the %inline block.
-
19.10.1 Naming Issues
+
20.10.1 Naming Issues
As you can see in the example above, there are potential naming conflicts. The default exported
@@ -769,7 +769,7 @@ guile-modules. For example,
TODO: Renaming class name prefixes?
-
19.10.2 Linking
+
20.10.2 Linking
The guile-modules generated above all need to be linked together. GOOPS support requires
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index 164fc21e7..4b8993184 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -5,7 +5,7 @@
-
20 SWIG and Java
+
21 SWIG and Java
@@ -154,7 +154,7 @@ It covers most SWIG features, but certain low-level details are covered in less
-
20.1 Overview
+
21.1 Overview
@@ -189,7 +189,7 @@ Various customisation tips and techniques using SWIG directives are covered.
The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.
-
20.2 Preliminaries
+
21.2 Preliminaries
@@ -205,7 +205,7 @@ Run make -k check from the SWIG root directory after installing SWIG on
The Java module requires your system to support shared libraries and dynamic loading.
This is the commonly used method to load JNI code so your system will more than likely support this.
-
20.2.1 Running SWIG
+
21.2.1 Running SWIG
@@ -258,7 +258,7 @@ The following sections have further practical examples and details on how you mi
compiling and using the generated files.
-
20.2.2 Additional Commandline Options
+
21.2.2 Additional Commandline Options
@@ -295,7 +295,7 @@ swig -java -help
Their use will become clearer by the time you have finished reading this section on SWIG and Java.
-
20.2.3 Getting the right header files
+
21.2.3 Getting the right header files
@@ -310,7 +310,7 @@ They are usually in directories like this:
The exact location may vary on your machine, but the above locations are typical.
-
20.2.4 Compiling a dynamic module
+
21.2.4 Compiling a dynamic module
@@ -346,7 +346,7 @@ The name of the shared library output file is important.
If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information).
The name of the module is specified using the %module directive or -module command line option.
-
20.2.5 Using your module
+
21.2.5 Using your module
@@ -381,7 +381,7 @@ $
If it doesn't work have a look at the following section which discusses problems loading the shared library.
-
20.2.6 Dynamic linking problems
+
21.2.6 Dynamic linking problems
@@ -455,7 +455,7 @@ The following section also contains some C++ specific linking problems and solut
-
20.2.7 Compilation problems and compiling with C++
+
21.2.7 Compilation problems and compiling with C++
@@ -508,7 +508,7 @@ Finally make sure the version of JDK header files matches the version of Java th
-
20.2.8 Building on Windows
+
21.2.8 Building on Windows
@@ -517,7 +517,7 @@ You will want to produce a DLL that can be loaded by the Java Virtual Machine.
This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers.
In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.
-
20.2.8.1 Running SWIG from Visual Studio
+
21.2.8.1 Running SWIG from Visual Studio
@@ -556,7 +556,7 @@ To run the native code in the DLL (example.dll), make sure that it is in your pa
If the library fails to load have a look at Dynamic linking problems.
-
20.2.8.2 Using NMAKE
+
21.2.8.2 Using NMAKE
@@ -615,7 +615,7 @@ Of course you may want to make changes for it to work for C++ by adding in the -
-
20.3 A tour of basic C/C++ wrapping
+
21.3 A tour of basic C/C++ wrapping
@@ -625,7 +625,7 @@ variables are wrapped with JavaBean type getters and setters and so forth.
This section briefly covers the essential aspects of this wrapping.
-
20.3.1 Modules, packages and generated Java classes
+
21.3.1 Modules, packages and generated Java classes
@@ -659,7 +659,7 @@ swig -java -package com.bloggs.swig -outdir com/bloggs/swig example.i
SWIG won't create the directory, so make sure it exists beforehand.
-
@@ -920,7 +920,7 @@ Or if you decide this practice isn't so bad and your own class implements ex
-
20.3.5 Enumerations
+
21.3.5 Enumerations
@@ -934,7 +934,7 @@ The final two approaches use simple integers for each enum item.
Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.
-
20.3.5.1 Anonymous enums
+
21.3.5.1 Anonymous enums
@@ -997,7 +997,7 @@ As in the case of constants, you can access them through either the module class
-
20.3.5.2 Typesafe enums
+
21.3.5.2 Typesafe enums
@@ -1090,7 +1090,7 @@ When upgrading to JDK 1.5 or later, proper Java enums could be used instead, wit
The following section details proper Java enum generation.
@@ -1191,7 +1191,7 @@ Note that unlike typesafe enums, this approach requires users to mostly use diff
Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.
-
20.3.5.5 Simple enums
+
21.3.5.5 Simple enums
@@ -1210,7 +1210,7 @@ SWIG-1.3.21 and earlier versions wrapped all enums using this approach.
The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.
-
20.3.6 Pointers
+
21.3.6 Pointers
@@ -1298,7 +1298,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
a NULL pointer if the conversion can't be performed.
-
20.3.7 Structures
+
21.3.7 Structures
@@ -1466,7 +1466,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a
-
20.3.8 C++ classes
+
21.3.8 C++ classes
@@ -1529,7 +1529,7 @@ int bar = Spam.getBar();
-
20.3.9 C++ inheritance
+
21.3.9 C++ inheritance
@@ -1590,7 +1590,7 @@ Note that Java does not support multiple inheritance so any multiple inheritance
A warning is given when multiple inheritance is detected and only the first base class is used.
-
20.3.10 Pointers, references, arrays and pass by value
+
21.3.10 Pointers, references, arrays and pass by value
@@ -1645,7 +1645,7 @@ to hold the result and a pointer is returned (Java will release this memory
when the returned object's finalizer is run by the garbage collector).
-
20.3.10.1 Null pointers
+
21.3.10.1 Null pointers
@@ -1669,7 +1669,7 @@ For spam1 and spam4 above the Java null gets translat
The converse also occurs, that is, NULL pointers are translated into null Java objects when returned from a C/C++ function.
20.4 Further details on the generated Java classes
+
21.4 Further details on the generated Java classes
@@ -2035,7 +2035,7 @@ Finally enum classes are covered.
First, the crucial intermediary JNI class is considered.
-
20.4.1 The intermediary JNI class
+
21.4.1 The intermediary JNI class
@@ -2155,7 +2155,7 @@ If name is the same as modulename then the module class name g
from modulename to modulenameModule.
-
20.4.1.1 The intermediary JNI class pragmas
+
21.4.1.1 The intermediary JNI class pragmas
@@ -2234,7 +2234,7 @@ For example, let's change the intermediary JNI class access to public.
All the methods in the intermediary JNI class will then be callable outside of the package as the method modifiers are public by default.
-
20.4.2 The Java module class
+
21.4.2 The Java module class
@@ -2265,7 +2265,7 @@ example.egg(new Foo());
The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a Foo can be passed to the egg function, whereas any long can be passed to the egg function in the intermediary JNI class.
@@ -3046,7 +3046,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... }
-
20.4.5 Enum classes
+
21.4.5 Enum classes
@@ -3055,7 +3055,7 @@ The Enumerations section discussed these but omitted
The following sub-sections detail the various types of enum classes that can be generated.
-
20.4.5.1 Typesafe enum classes
+
21.4.5.1 Typesafe enum classes
@@ -3139,7 +3139,7 @@ The swigValue method is used for marshalling in the other direction.
The toString method is overridden so that the enum name is available.
-
20.4.5.2 Proper Java enum classes
+
21.4.5.2 Proper Java enum classes
@@ -3217,7 +3217,7 @@ These needn't be generated if the enum being wrapped does not have any initializ
Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this.
-
20.4.5.3 Type unsafe enum classes
+
21.4.5.3 Type unsafe enum classes
@@ -3248,7 +3248,7 @@ public final class Beverage {
-
20.5 Cross language polymorphism using directors
+
21.5 Cross language polymorphism using directors
@@ -3270,7 +3270,7 @@ The upshot is that C++ classes can be extended in Java and from C++ these extens
Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.
-
20.5.1 Enabling directors
+
21.5.1 Enabling directors
@@ -3341,7 +3341,7 @@ public:
-
20.5.2 Director classes
+
21.5.2 Director classes
@@ -3368,7 +3368,7 @@ If the correct implementation is in Java, the Java API is used to call the metho
-
20.5.3 Overhead and code bloat
+
21.5.3 Overhead and code bloat
@@ -3386,7 +3386,7 @@ This situation can be optimized by selectively enabling director methods (using
@@ -3471,7 +3471,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern
-
20.6 Accessing protected members
+
21.6 Accessing protected members
@@ -3567,7 +3567,7 @@ class MyProtectedBase extends ProtectedBase
-
20.7 Common customization features
+
21.7 Common customization features
@@ -3579,7 +3579,7 @@ be awkward. This section describes some common SWIG features that are used
to improve the interface to existing C/C++ code.
-
20.7.1 C/C++ helper functions
+
21.7.1 C/C++ helper functions
@@ -3645,7 +3645,7 @@ hard to implement. It is possible to improve on this using Java code, typemaps,
customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.
-
20.7.2 Class extension with %extend
+
21.7.2 Class extension with %extend
@@ -3708,7 +3708,7 @@ Vector(2,3,4)
in any way---the extensions only show up in the Java interface.
-
20.7.3 Exception handling with %exception and %javaexception
+
21.7.3 Exception handling with %exception and %javaexception
@@ -3901,7 +3901,7 @@ strings and arrays. This chapter discusses the common techniques for
solving these problems.
-
20.8.1 Input and output parameters using primitive pointers and references
+
21.8.1 Input and output parameters using primitive pointers and references
@@ -4075,7 +4075,7 @@ void foo(Bar *OUTPUT);
will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.
-
20.8.2 Simple pointers
+
21.8.2 Simple pointers
@@ -4141,7 +4141,7 @@ System.out.println("3 + 4 = " + result);
See the SWIG Library chapter for further details.
-
20.8.3 Wrapping C arrays with Java arrays
+
21.8.3 Wrapping C arrays with Java arrays
@@ -4208,7 +4208,7 @@ Please be aware that the typemaps in this library are not efficient as all the e
There is an alternative approach using the SWIG array library and this is covered in the next section.
-
20.8.4 Unbounded C Arrays
+
21.8.4 Unbounded C Arrays
@@ -4353,7 +4353,7 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
-
20.8.5 Overriding new and delete to allocate from Java heap
+
21.8.5 Overriding new and delete to allocate from Java heap
@@ -4470,7 +4470,7 @@ model and use these functions in place of malloc and free in your own
code.
-
20.9 Java typemaps
+
21.9 Java typemaps
@@ -4491,7 +4491,7 @@ Before proceeding, it should be stressed that typemaps are not a required
part of using SWIG---the default wrapping behavior is enough in most cases.
Typemaps are only used if you want to change some aspect of the generated code.
-
20.9.1 Default primitive type mappings
+
21.9.1 Default primitive type mappings
@@ -4643,7 +4643,7 @@ However, the mappings allow the full range of values for each C type from Java.
-
20.9.2 Default typemaps for non-primitive types
+
21.9.2 Default typemaps for non-primitive types
@@ -4658,7 +4658,7 @@ So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit
The Java type is either the proxy class or type wrapper class.
-
20.9.3 Sixty four bit JVMs
+
21.9.3 Sixty four bit JVMs
@@ -4671,7 +4671,7 @@ Unfortunately it won't of course hold true for JNI code.
-
20.9.4 What is a typemap?
+
21.9.4 What is a typemap?
@@ -4794,7 +4794,7 @@ int c = example.count('e',"Hello World");
-
20.9.5 Typemaps for mapping C/C++ types to Java types
+
21.9.5 Typemaps for mapping C/C++ types to Java types
@@ -5054,7 +5054,7 @@ These are listed below:
-
20.9.6 Java typemap attributes
+
21.9.6 Java typemap attributes
@@ -5100,7 +5100,7 @@ The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes.
Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action.
-
20.9.7 Java special variables
+
21.9.7 Java special variables
@@ -5243,7 +5243,7 @@ This special variable expands to the intermediary class name. Usually this is th
unless the jniclassname attribute is specified in the %module directive.
-
20.9.8 Typemaps for both C and C++ compilation
+
21.9.8 Typemaps for both C and C++ compilation
@@ -5280,7 +5280,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps
-
20.9.9 Java code typemaps
+
21.9.9 Java code typemaps
@@ -5476,7 +5476,7 @@ For the typemap to be used in all type wrapper classes, all the different types
Again this is the same that is in "java.swg", barring the method modifier for getCPtr.
-
20.9.10 Director specific typemaps
+
21.9.10 Director specific typemaps
@@ -5701,7 +5701,7 @@ The basic strategy here is to provide a default package typemap for the majority
-
20.10 Typemap Examples
+
21.10 Typemap Examples
@@ -5711,7 +5711,7 @@ the SWIG library.
-
20.10.1 Simpler Java enums for enums without initializers
+
21.10.1 Simpler Java enums for enums without initializers
@@ -5790,7 +5790,7 @@ This would be done by using the original versions of these typemaps in "enums.sw
-
20.10.2 Handling C++ exception specifications as Java exceptions
+
21.10.2 Handling C++ exception specifications as Java exceptions
@@ -5915,7 +5915,7 @@ We could alternatively have used %rename to rename what() into
-
20.10.3 NaN Exception - exception handling for a particular type
+
21.10.3 NaN Exception - exception handling for a particular type
@@ -6070,7 +6070,7 @@ If we were a martyr to the JNI cause, we could replace the succinct code within
If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.
-
20.10.4 Converting Java String arrays to char **
+
21.10.4 Converting Java String arrays to char **
@@ -6214,7 +6214,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify
what Java types to use.
-
20.10.5 Expanding a Java object to multiple arguments
+
21.10.5 Expanding a Java object to multiple arguments
20.10.7 Adding Java downcasts to polymorphic return types
+
21.10.7 Adding Java downcasts to polymorphic return types
@@ -6620,7 +6620,7 @@ SWIG usually generates code which constructs the proxy classes using Java code a
Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.
-
20.10.8 Adding an equals method to the Java classes
+
21.10.8 Adding an equals method to the Java classes
20.10.9 Void pointers and a common Java base class
+
21.10.9 Void pointers and a common Java base class
@@ -6723,7 +6723,7 @@ This example contains some useful functionality which you may want in your code.
It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer.
-
20.10.10 Struct pointer to pointer
+
21.10.10 Struct pointer to pointer
@@ -6903,7 +6903,7 @@ The C functional interface has been completely morphed into an object-oriented i
the Butler class would behave much like any pure Java class and feel more natural to Java users.
-
20.10.11 Memory management when returning references to member variables
+
21.10.11 Memory management when returning references to member variables
@@ -7026,7 +7026,7 @@ public class Bike {
Note the addReference call.
-
20.10.12 Memory management for objects passed to the C++ layer
+
21.10.12 Memory management for objects passed to the C++ layer
@@ -7142,7 +7142,7 @@ The 'javacode' typemap simply adds in the specified code into the Java proxy cla
-
20.10.13 Date marshalling using the javain typemap and associated attributes
+
21.10.13 Date marshalling using the javain typemap and associated attributes
@@ -7319,7 +7319,7 @@ A few things to note:
-
20.11 Living with Java Directors
+
21.11 Living with Java Directors
@@ -7500,10 +7500,10 @@ public abstract class UserVisibleFoo extends Foo {
-
20.12 Odds and ends
+
21.12 Odds and ends
-
20.12.1 JavaDoc comments
+
21.12.1 JavaDoc comments
@@ -7559,7 +7559,7 @@ public class Barmy {
-
20.12.2 Functional interface without proxy classes
+
21.12.2 Functional interface without proxy classes
@@ -7620,7 +7620,7 @@ All destructors have to be called manually for example the delete_Foo(foo)
-
20.12.3 Using your own JNI functions
+
21.12.3 Using your own JNI functions
@@ -7670,7 +7670,7 @@ This directive is only really useful if you want to mix your own hand crafted JN
-
20.12.4 Performance concerns and hints
+
21.12.4 Performance concerns and hints
@@ -7691,7 +7691,7 @@ However, you will have to be careful about memory management and make sure that
This method normally calls the C++ destructor or free() for C code.
-
20.12.5 Debugging
+
21.12.5 Debugging
@@ -7713,7 +7713,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh
@@ -77,7 +77,7 @@ swig -cffi -module module-namefile-name
files and the various things which you can do with them.
-
21.2.1 Additional Commandline Options
+
22.2.1 Additional Commandline Options
@@ -118,7 +118,7 @@ swig -cffi -help
-
21.2.2 Generating CFFI bindings
+
22.2.2 Generating CFFI bindings
As we mentioned earlier the ideal way to use SWIG is to use interface
@@ -392,7 +392,7 @@ The feature intern_function ensures that all C names are
-
21.2.3 Generating CFFI bindings for C++ code
+
22.2.3 Generating CFFI bindings for C++ code
This feature to SWIG (for CFFI) is very new and still far from
@@ -568,7 +568,7 @@ If you have any questions, suggestions, patches, etc., related to CFFI
module feel free to contact us on the SWIG mailing list, and
also please add a "[CFFI]" tag in the subject line.
-
21.2.4 Inserting user code into generated files
+
22.2.4 Inserting user code into generated files
@@ -608,7 +608,7 @@ Note that the block %{ ... %} is effectively a shortcut for
-
21.3 CLISP
+
22.3 CLISP
@@ -638,7 +638,7 @@ swig -clisp -module module-namefile-name
interface file for the CLISP module. The CLISP module tries to
produce code which is both human readable and easily modifyable.
-
21.3.1 Additional Commandline Options
+
22.3.1 Additional Commandline Options
@@ -671,7 +671,7 @@ and global variables will be created otherwise only definitions for
-
Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). Its also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org
-
22.1 Preliminaries
+
23.1 Preliminaries
The current SWIG implementation is designed to work with Lua 5.0.x and Lua 5.1.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. ((Currently SWIG generated code has only been tested on Windows with MingW, though given the nature of Lua, is should not have problems on other OS's)). It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms).
-
22.2 Running SWIG
+
23.2 Running SWIG
@@ -90,7 +90,7 @@ This creates a C/C++ source file example_wrap.c or example_wrap.cxx
The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrappered module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module.
@@ -205,7 +205,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib
-
22.2.3 Using your module
+
23.2.3 Using your module
@@ -223,19 +223,19 @@ $ ./my_lua
>
-
22.3 A tour of basic C/C++ wrapping
+
23.3 A tour of basic C/C++ wrapping
By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.
-
22.3.1 Modules
+
23.3.1 Modules
The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.
-
22.3.2 Functions
+
23.3.2 Functions
@@ -273,7 +273,7 @@ It is also possible to rename the module with an assignment.
24
-
22.3.3 Global variables
+
23.3.3 Global variables
@@ -347,7 +347,7 @@ nil
3.142
-
22.3.4 Constants and enums
+
23.3.4 Constants and enums
@@ -370,7 +370,7 @@ example.SUNDAY=0
Constants are not guaranteed to remain constant in Lua. The name of the constant could be accidentally reassigned to refer to some other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.
-
22.3.5 Pointers
+
23.3.5 Pointers
@@ -408,7 +408,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor
nil
-
22.3.6 Structures
+
23.3.6 Structures
@@ -494,7 +494,7 @@ Because the pointer points inside the structure, you can modify the contents and
> x.a = 3 -- Modifies the same structure
-
22.3.7 C++ classes
+
23.3.7 C++ classes
@@ -555,7 +555,7 @@ It is not (currently) possible to access static members of an instance:
-- does NOT work
-
22.3.8 C++ inheritance
+
23.3.8 C++ inheritance
@@ -580,7 +580,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas
It is safe to use multiple inheritance with SWIG.
-
22.3.9 Pointers, references, values, and arrays
+
23.3.9 Pointers, references, values, and arrays
@@ -611,7 +611,7 @@ Foo spam7();
then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.
-
22.3.10 C++ overloaded functions
+
23.3.10 C++ overloaded functions
@@ -697,7 +697,7 @@ Please refer to the "SWIG and C++" chapter for more information about overloadin
Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.
-
22.3.11 C++ operators
+
23.3.11 C++ operators
@@ -809,7 +809,7 @@ It is also possible to overload the operator[], but currently this cann
};
-
22.3.12 Class extension with %extend
+
23.3.12 Class extension with %extend
@@ -864,7 +864,7 @@ true
Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).
-
22.3.13 C++ templates
+
23.3.13 C++ templates
@@ -899,7 +899,7 @@ In Lua:
Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.
-
22.3.14 C++ Smart Pointers
+
23.3.14 C++ Smart Pointers
@@ -951,7 +951,7 @@ If you ever need to access the underlying pointer returned by operator->(
> f = p:__deref__() -- Returns underlying Foo *
-
22.3.15 C++ Exceptions
+
23.3.15 C++ Exceptions
@@ -1098,7 +1098,7 @@ add exception specification to functions or globally (respectively).
-
22.3.16 Writing your own custom wrappers
+
23.3.16 Writing your own custom wrappers
@@ -1117,7 +1117,7 @@ int native_function(lua_State*L) // my native code
The %native directive in the above example, tells SWIG that there is a function int native_function(lua_State*L); which is to be added into the module under the name 'my_func'. SWIG will not add any wrappering for this function, beyond adding it into the function table. How you write your code is entirely up to you.
-
22.3.17 Adding additional Lua code
+
23.3.17 Adding additional Lua code
@@ -1155,7 +1155,7 @@ Good uses for this feature is adding of new code, or writing helper functions to
See Examples/lua/arrays for an example of this code.
-
22.4 Details on the Lua binding
+
23.4 Details on the Lua binding
@@ -1166,7 +1166,7 @@ See Examples/lua/arrays for an example of this code.
-
22.4.1 Binding global data into the module.
+
23.4.1 Binding global data into the module.
@@ -1226,7 +1226,7 @@ end
That way when you call 'a=example.Foo', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code 'example.Foo=10', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.
-
22.4.2 Userdata and Metatables
+
23.4.2 Userdata and Metatables
@@ -1306,7 +1306,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrappered classes/s
Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.
@@ -80,7 +80,7 @@ If you're not familiar with the Objective Caml language, you can visit
The Ocaml Website.
-
25.1 Preliminaries
+
26.1 Preliminaries
@@ -99,7 +99,7 @@ file Examples/Makefile illustrate how to compile and link SWIG modules that
will be loaded dynamically. This has only been tested on Linux so far.
-
25.1.1 Running SWIG
+
26.1.1 Running SWIG
@@ -122,7 +122,7 @@ you will compile the file example_wrap.c with ocamlc or
the resulting .ml and .mli files as well, and do the final link with -custom
(not needed for native link).
-
25.1.2 Compiling the code
+
26.1.2 Compiling the code
@@ -158,7 +158,7 @@ the user more freedom with respect to custom typing.
-
25.1.3 The camlp4 module
+
26.1.3 The camlp4 module
@@ -234,7 +234,7 @@ let b = C_string (getenv "PATH")
-
25.1.4 Using your module
+
26.1.4 Using your module
@@ -248,7 +248,7 @@ When linking any ocaml bytecode with your module, use the -custom
option is not needed when you build native code.
-
25.1.5 Compilation problems and compiling with C++
+
26.1.5 Compilation problems and compiling with C++
@@ -259,7 +259,7 @@ liberal with pointer types may not compile under the C++ compiler.
Most code meant to be compiled as C++ will not have problems.
-
25.2 The low-level Ocaml/C interface
+
26.2 The low-level Ocaml/C interface
@@ -360,7 +360,7 @@ is that you must append them to the return list with swig_result = caml_list_a
signature for a function that uses value in this way.
-
25.2.1 The generated module
+
26.2.1 The generated module
@@ -394,7 +394,7 @@ it describes the output SWIG will generate for class definitions.
-
25.2.2 Enums
+
26.2.2 Enums
@@ -457,7 +457,7 @@ val x : Enum_test.c_obj = C_enum `a
-
25.2.2.1 Enum typing in Ocaml
+
26.2.2.1 Enum typing in Ocaml
@@ -470,10 +470,10 @@ functions imported from different modules. You must convert values to master
values using the swig_val function before sharing them with another module.
-
25.2.3 Arrays
+
26.2.3 Arrays
-
25.2.3.1 Simple types of bounded arrays
+
26.2.3.1 Simple types of bounded arrays
@@ -494,7 +494,7 @@ arrays of simple types with known bounds in your code, but this only works
for arrays whose bounds are completely specified.
-
25.2.3.2 Complex and unbounded arrays
+
26.2.3.2 Complex and unbounded arrays
@@ -507,7 +507,7 @@ SWIG can't predict which of these methods will be used in the array,
so you have to specify it for yourself in the form of a typemap.
-
25.2.3.3 Using an object
+
26.2.3.3 Using an object
@@ -521,7 +521,7 @@ Consider writing an object when the ending condition of your array is complex,
such as using a required sentinel, etc.
-
25.2.3.4 Example typemap for a function taking float * and int
+
26.2.3.4 Example typemap for a function taking float * and int
@@ -572,7 +572,7 @@ void printfloats( float *tab, int len );
-
25.2.4 C++ Classes
+
26.2.4 C++ Classes
@@ -615,7 +615,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the
returned value for the same object.
@@ -770,10 +770,10 @@ Assuming you have a working installation of QT, you will see a window
containing the string "hi" in a button.
-
25.2.5 Director Classes
+
26.2.5 Director Classes
-
25.2.5.1 Director Introduction
+
26.2.5.1 Director Introduction
@@ -800,7 +800,7 @@ class foo {
};
-
25.2.5.2 Overriding Methods in Ocaml
+
26.2.5.2 Overriding Methods in Ocaml
@@ -828,7 +828,7 @@ In this example, I'll examine the objective caml code involved in providing
an overloaded class. This example is contained in Examples/ocaml/shapes.
-
25.2.5.3 Director Usage Example
+
26.2.5.3 Director Usage Example
@@ -887,7 +887,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the
program in C++.
-
25.2.5.4 Creating director objects
+
26.2.5.4 Creating director objects
@@ -928,7 +928,7 @@ object from causing a core dump, as long as the object is destroyed
properly.
-
25.2.5.5 Typemaps for directors, directorin, directorout, directorargout
+
26.2.5.5 Typemaps for directors, directorin, directorout, directorargout
@@ -939,7 +939,7 @@ well as a function return value in the same way you provide function arguments,
and to receive arguments the same way you normally receive function returns.
-
25.2.5.6 directorin typemap
+
26.2.5.6 directorin typemap
@@ -950,7 +950,7 @@ code receives when you are called. In general, a simple directorin typ
can use the same body as a simple out typemap.
-
25.2.5.7 directorout typemap
+
26.2.5.7 directorout typemap
@@ -961,7 +961,7 @@ for the same type, except when there are special requirements for object
ownership, etc.
-
25.2.5.8 directorargout typemap
+
26.2.5.8 directorargout typemap
@@ -978,7 +978,7 @@ In the event that you don't specify all of the necessary values, integral
values will read zero, and struct or object returns have undefined results.
The current SWIG implemention is based on Octave 2.9.12. Support for other versions (in particular the recent 3.0) has not been tested, nor has support for any OS other than Linux.
-
26.2 Running SWIG
+
27.2 Running SWIG
@@ -89,7 +89,7 @@ This creates a C/C++ source file example_wrap.cxx. The generated C++ so
The swig command line has a number of options you can use, like to redirect it's output. Use swig --help to learn about these.
@@ -318,7 +318,7 @@ octave:2> f=example.fopen("not there","r");
error: value on right hand side of assignment is undefined
error: evaluating assignment expression near line 2, column 2
-
26.3.6 Structures and C++ classes
+
27.3.6 Structures and C++ classes
@@ -453,7 +453,7 @@ ans = 1
Depending on the ownership setting of a swig_ref, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.
-
26.3.7 C++ inheritance
+
27.3.7 C++ inheritance
@@ -462,7 +462,7 @@ This information contains the full class hierarchy. When an indexing operation (
the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the swig_ref.
-
26.3.8 C++ overloaded functions
+
27.3.8 C++ overloaded functions
@@ -472,7 +472,7 @@ The dispatch function selects which overload to call (if any) based on the passe
typecheck typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.
-
26.3.9 C++ operators
+
27.3.9 C++ operators
@@ -572,7 +572,7 @@ On the C++ side, the default mappings are as follows:
%rename(__brace) *::operator[];
-
C++ smart pointers are fully supported as in other modules.
-
26.3.13 Directors (calling Octave from C++ code)
+
27.3.13 Directors (calling Octave from C++ code)
@@ -766,14 +766,14 @@ c-side routine called
octave-side routine called
-
26.3.14 Threads
+
27.3.14 Threads
The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.
-
26.3.15 Memory management
+
27.3.15 Memory management
@@ -807,14 +807,14 @@ The %newobject directive may be used to control this behavior for pointers retur
In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/subclass()'ing).
-
26.3.16 STL support
+
27.3.16 STL support
This is some skeleton support for various STL containers.
@@ -87,7 +87,7 @@ later. Earlier versions are problematic and SWIG generated extensions
may not compile or run correctly.
-
27.1 Overview
+
28.1 Overview
@@ -108,7 +108,7 @@ described. Advanced customization features, typemaps, and other
options are found near the end of the chapter.
-
27.2 Preliminaries
+
28.2 Preliminaries
@@ -133,7 +133,7 @@ To build the module, you will need to compile the file
example_wrap.c and link it with the rest of your program.
-
27.2.1 Getting the right header files
+
28.2.1 Getting the right header files
@@ -165,7 +165,7 @@ loaded, an easy way to find out is to run Perl itself.
-
27.2.2 Compiling a dynamic module
+
28.2.2 Compiling a dynamic module
@@ -198,7 +198,7 @@ the target should be named `example.so',
`example.sl', or the appropriate dynamic module name on your system.
-
27.2.3 Building a dynamic module with MakeMaker
+
28.2.3 Building a dynamic module with MakeMaker
@@ -232,7 +232,7 @@ the preferred approach to compilation. More information about MakeMaker can be
found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen,
and Randal Schwartz.
-
27.2.4 Building a static version of Perl
+
28.2.4 Building a static version of Perl
@@ -301,7 +301,7 @@ added to it. Depending on your machine, you may need to link with
additional libraries such as -lsocket, -lnsl, -ldl, etc.
-
27.2.5 Using the module
+
28.2.5 Using the module
@@ -456,7 +456,7 @@ system configuration (this requires root access and you will need to
read the man pages).
-
27.2.6 Compilation problems and compiling with C++
+
28.2.6 Compilation problems and compiling with C++
@@ -599,7 +599,7 @@ have to find the macro that conflicts and add an #undef into the .i file. Pleas
any conflicting macros you find to swig-user mailing list.
-
27.2.7 Compiling for 64-bit platforms
+
28.2.7 Compiling for 64-bit platforms
@@ -626,7 +626,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
-
27.3 Building Perl Extensions under Windows
+
28.3 Building Perl Extensions under Windows
@@ -637,7 +637,7 @@ section assumes you are using SWIG with Microsoft Visual C++
although the procedure may be similar with other compilers.
-
27.3.1 Running SWIG from Developer Studio
+
28.3.1 Running SWIG from Developer Studio
@@ -700,7 +700,7 @@ print "$a\n";
-
27.3.2 Using other compilers
+
28.3.2 Using other compilers
@@ -708,7 +708,7 @@ SWIG is known to work with Cygwin and may work with other compilers on Windows.
For general hints and suggestions refer to the Windows chapter.
-
27.4 The low-level interface
+
28.4 The low-level interface
@@ -718,7 +718,7 @@ can be used to control your application. However, it is also used to
construct more user-friendly proxy classes as described in the next section.
-
27.4.1 Functions
+
28.4.1 Functions
@@ -741,7 +741,7 @@ use example;
$a = &example::fact(2);
-
27.4.2 Global variables
+
28.4.2 Global variables
@@ -811,7 +811,7 @@ extern char *path; // Declared later in the input
-
27.4.3 Constants
+
28.4.3 Constants
@@ -838,7 +838,7 @@ $example::FOO = 2; # Error
-
27.4.4 Pointers
+
28.4.4 Pointers
@@ -947,7 +947,7 @@ as XS and xsubpp. Given the advancement of the SWIG typesystem and the
SWIG and XS, this is no longer supported.
@@ -1146,7 +1146,7 @@ provides direct access to C++ objects. A higher level interface using Perl prox
can be built using these low-level accessors. This is described shortly.
-
27.4.7 C++ classes and type-checking
+
28.4.7 C++ classes and type-checking
@@ -1182,7 +1182,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece
multiple inheritance is used).
-
27.4.8 C++ overloaded functions
+
28.4.8 C++ overloaded functions
@@ -1226,7 +1226,7 @@ example::Spam_foo_d($s,3.14);
Please refer to the "SWIG Basics" chapter for more information.
-
27.4.9 Operators
+
28.4.9 Operators
@@ -1253,7 +1253,7 @@ The following C++ operators are currently supported by the Perl module:
operator or
-
27.4.10 Modules and packages
+
28.4.10 Modules and packages
@@ -1348,7 +1348,7 @@ print Foo::fact(4),"\n"; # Call a function in package FooBar
-->
-
27.5 Input and output parameters
+
28.5 Input and output parameters
@@ -1567,7 +1567,7 @@ print "$c\n";
Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).
-
27.6 Exception handling
+
28.6 Exception handling
@@ -1732,7 +1732,7 @@ This is still supported, but it is deprecated. The newer %exception di
functionality, but it has additional capabilities that make it more powerful.
-
27.7 Remapping datatypes with typemaps
+
28.7 Remapping datatypes with typemaps
@@ -1749,7 +1749,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Perl interface.
@@ -2345,7 +2345,7 @@ the "in" typemap in the previous section would be used to convert an
to copy the converted array into a C data structure.
-
27.8.5 Turning Perl references into C pointers
+
28.8.5 Turning Perl references into C pointers
@@ -2410,7 +2410,7 @@ print "$c\n";
-
27.8.6 Pointer handling
+
28.8.6 Pointer handling
@@ -2489,7 +2489,7 @@ For example:
-
27.9 Proxy classes
+
28.9 Proxy classes
@@ -2505,7 +2505,7 @@ to the underlying code. This section describes the implementation
details of the proxy interface.
-
27.9.1 Preliminaries
+
28.9.1 Preliminaries
@@ -2527,7 +2527,7 @@ SWIG creates a collection of high-level Perl wrappers. In your scripts, you wil
high level wrappers. The wrappers, in turn, interact with the low-level procedural module.
-
27.9.2 Structure and class wrappers
+
28.9.2 Structure and class wrappers
@@ -2653,7 +2653,7 @@ $v->DESTROY();
-
27.9.3 Object Ownership
+
28.9.3 Object Ownership
@@ -2740,7 +2740,7 @@ counting, garbage collection, or advanced features one might find in
sophisticated languages.
@@ -67,7 +67,7 @@ your extension into php directly, you will need the complete PHP source tree
available.
-
28.1 Generating PHP Extensions
+
29.1 Generating PHP Extensions
@@ -114,7 +114,7 @@ this approach, but if you really want to do this, the -phpfull
command line argument to swig may be of use - see below for details.
-
28.1.1 Building a loadable extension
+
29.1.1 Building a loadable extension
@@ -138,7 +138,7 @@ add them to your Makefile or other build system directly. We recommend that
you don't use -make and it's likely to be removed at some point.
-
28.1.2 Building extensions into PHP
+
29.1.2 Building extensions into PHP
@@ -257,7 +257,7 @@ which contains your new module. You can test it with a php script which
does not have the 'dl' command as used above.
-
28.1.3 Using PHP Extensions
+
29.1.3 Using PHP Extensions
@@ -288,7 +288,7 @@ attempts to do the dl() call for you:
include("example.php");
-
28.2 Basic PHP interface
+
29.2 Basic PHP interface
@@ -298,7 +298,7 @@ possible for names of symbols in one extension module to clash with
other symbols unless care is taken to %rename them.
-
28.2.1 Constants
+
29.2.1 Constants
@@ -423,7 +423,7 @@ both point to the same value, without the case test taking place. (
Apologies, this paragraph needs rewriting to make some sense. )
-
28.2.2 Global Variables
+
29.2.2 Global Variables
@@ -472,7 +472,7 @@ undefined.
At this time SWIG does not support custom accessor methods.
-
28.2.3 Functions
+
29.2.3 Functions
@@ -525,7 +525,7 @@ print $s; # The value of $s was not changed.
-->
-
28.2.4 Overloading
+
29.2.4 Overloading
@@ -581,7 +581,7 @@ taking the integer argument.
-->
-
28.2.5 Pointers and References
+
29.2.5 Pointers and References
@@ -713,7 +713,7 @@ PHP in a number of ways: by using unset on an existing
variable, or assigning NULL to a variable.
-
28.2.6 Structures and C++ classes
+
29.2.6 Structures and C++ classes
@@ -783,7 +783,7 @@ Would be used in the following way from either PHP4 or PHP5:
Member variables and methods are accessed using the -> operator.
@@ -125,7 +125,7 @@ very least, make sure you read the "SWIG
Basics" chapter.
-
30.1 Overview
+
31.1 Overview
@@ -152,10 +152,10 @@ described followed by a discussion of low-level implementation
details.
-
30.2 Preliminaries
+
31.2 Preliminaries
-
30.2.1 Running SWIG
+
31.2.1 Running SWIG
@@ -253,7 +253,7 @@ The following sections have further practical examples and details on
how you might go about compiling and using the generated files.
-
30.2.2 Using distutils
+
31.2.2 Using distutils
@@ -345,7 +345,7 @@ This same approach works on all platforms if the appropriate compiler is install
can even build extensions to the standard Windows Python using MingGW)
-
30.2.3 Hand compiling a dynamic module
+
31.2.3 Hand compiling a dynamic module
@@ -393,7 +393,7 @@ module actually consists of two files; socket.py and
-
30.2.4 Static linking
+
31.2.4 Static linking
@@ -472,7 +472,7 @@ If using static linking, you might want to rely on a different approach
(perhaps using distutils).
-
30.2.5 Using your module
+
31.2.5 Using your module
@@ -629,7 +629,7 @@ system configuration (this requires root access and you will need to
read the man pages).
-
30.2.6 Compilation of C++ extensions
+
31.2.6 Compilation of C++ extensions
@@ -728,7 +728,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
-
30.2.7 Compiling for 64-bit platforms
+
31.2.7 Compiling for 64-bit platforms
@@ -765,7 +765,7 @@ and -m64 allow you to choose the desired binary format for your python
extension.
-
30.2.8 Building Python Extensions under Windows
+
31.2.8 Building Python Extensions under Windows
@@ -874,7 +874,7 @@ SWIG Wiki.
-
30.3 A tour of basic C/C++ wrapping
+
31.3 A tour of basic C/C++ wrapping
@@ -883,7 +883,7 @@ to your C/C++ code. Functions are wrapped as functions, classes are wrapped as
This section briefly covers the essential aspects of this wrapping.
-
30.3.1 Modules
+
31.3.1 Modules
@@ -896,7 +896,7 @@ module name, make sure you don't use the same name as a built-in
Python command or standard module name.
-
30.3.2 Functions
+
31.3.2 Functions
@@ -920,7 +920,7 @@ like you think it does:
>>>
-
30.3.3 Global variables
+
31.3.3 Global variables
@@ -1058,7 +1058,7 @@ that starts with a leading underscore. SWIG does not create cvar
if there are no global variables in a module.
-
30.3.4 Constants and enums
+
31.3.4 Constants and enums
@@ -1098,7 +1098,7 @@ other object. Unfortunately, there is no easy way for SWIG to
generate code that prevents this. You will just have to be careful.
-
30.3.5 Pointers
+
31.3.5 Pointers
@@ -1239,7 +1239,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
None if the conversion can't be performed.
-
30.3.6 Structures
+
31.3.6 Structures
@@ -1428,7 +1428,7 @@ everything works just like you would expect. For example:
-
30.3.7 C++ classes
+
31.3.7 C++ classes
@@ -1517,7 +1517,7 @@ they are accessed through cvar like this:
-
30.3.8 C++ inheritance
+
31.3.8 C++ inheritance
@@ -1572,7 +1572,7 @@ then the function spam() accepts Foo * or a pointer to any cla
It is safe to use multiple inheritance with SWIG.
-
30.3.9 Pointers, references, values, and arrays
+
31.3.9 Pointers, references, values, and arrays
@@ -1633,7 +1633,7 @@ treated as a returning value, and it will follow the same
allocation/deallocation process.
-
30.3.10 C++ overloaded functions
+
31.3.10 C++ overloaded functions
@@ -1756,7 +1756,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
-
30.3.11 C++ operators
+
31.3.11 C++ operators
@@ -1845,7 +1845,7 @@ Also, be aware that certain operators don't map cleanly to Python. For instance
overloaded assignment operators don't map to Python semantics and will be ignored.
-
30.3.12 C++ namespaces
+
31.3.12 C++ namespaces
@@ -1912,7 +1912,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
-
30.3.13 C++ templates
+
31.3.13 C++ templates
@@ -1966,7 +1966,7 @@ Some more complicated
examples will appear later.
-
30.3.14 C++ Smart Pointers
+
31.3.14 C++ Smart Pointers
@@ -2051,7 +2051,7 @@ simply use the __deref__() method. For example:
-
30.3.15 C++ Reference Counted Objects (ref/unref)
+
31.3.15 C++ Reference Counted Objects (ref/unref)
@@ -2213,7 +2213,7 @@ python releases the proxy instance.
-
30.4 Further details on the Python class interface
+
31.4 Further details on the Python class interface
@@ -2226,7 +2226,7 @@ of low-level details were omitted. This section provides a brief overview
of how the proxy classes work.
-
30.4.1 Proxy classes
+
31.4.1 Proxy classes
@@ -2315,7 +2315,7 @@ you can attach new Python methods to the class and you can even inherit from it
by Python built-in types until Python 2.2).
-
30.4.2 Memory management
+
31.4.2 Memory management
@@ -2507,7 +2507,7 @@ It is also possible to deal with situations like this using
typemaps--an advanced topic discussed later.
-
30.4.3 Python 2.2 and classic classes
+
31.4.3 Python 2.2 and classic classes
@@ -2544,7 +2544,7 @@ class itself. In Python-2.1 and earlier, they have to be accessed as a global
function or through an instance (see the earlier section).
-
30.5 Cross language polymorphism
+
31.5 Cross language polymorphism
@@ -2578,7 +2578,7 @@ proxy classes, director classes, and C wrapper functions takes care of
all the cross-language method routing transparently.
-
30.5.1 Enabling directors
+
31.5.1 Enabling directors
@@ -2671,7 +2671,7 @@ class MyFoo(mymodule.Foo):
-
30.5.2 Director classes
+
31.5.2 Director classes
@@ -2753,7 +2753,7 @@ so there is no need for the extra overhead involved with routing the
calls through Python.
-
30.5.3 Ownership and object destruction
+
31.5.3 Ownership and object destruction
@@ -2820,7 +2820,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard
references to the Foo objects remain in Python.
-
30.5.4 Exception unrolling
+
31.5.4 Exception unrolling
@@ -2879,7 +2879,7 @@ Swig::DirectorMethodException is thrown, Python will register the
exception as soon as the C wrapper function returns.
-
30.5.5 Overhead and code bloat
+
31.5.5 Overhead and code bloat
@@ -2913,7 +2913,7 @@ directive) for only those methods that are likely to be extended in
Python.
-
30.5.6 Typemaps
+
31.5.6 Typemaps
@@ -2927,7 +2927,7 @@ need to be supported.
-
30.5.7 Miscellaneous
+
31.5.7 Miscellaneous
@@ -2974,7 +2974,7 @@ methods that return const references.
-
30.6 Common customization features
+
31.6 Common customization features
@@ -2987,7 +2987,7 @@ This section describes some common SWIG features that are used to
improve your the interface to an extension module.
-
30.6.1 C/C++ helper functions
+
31.6.1 C/C++ helper functions
@@ -3068,7 +3068,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps,
customization features as covered in later sections.
-
30.6.2 Adding additional Python code
+
31.6.2 Adding additional Python code
@@ -3217,7 +3217,7 @@ public:
-
30.6.3 Class extension with %extend
+
31.6.3 Class extension with %extend
@@ -3306,7 +3306,7 @@ Vector(12,14,16)
in any way---the extensions only show up in the Python interface.
-
30.6.4 Exception handling with %exception
+
31.6.4 Exception handling with %exception
@@ -3432,7 +3432,7 @@ The language-independent exception.i library file can also be used
to raise exceptions. See the SWIG Library chapter.
-
30.7 Tips and techniques
+
31.7 Tips and techniques
@@ -3442,7 +3442,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques
solving these problems.
-
30.7.1 Input and output parameters
+
31.7.1 Input and output parameters
@@ -3655,7 +3655,7 @@ void foo(Bar *OUTPUT);
may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.
-
30.7.2 Simple pointers
+
31.7.2 Simple pointers
@@ -3724,7 +3724,7 @@ If you replace %pointer_functions() by %pointer_class(type,name)SWIG Library chapter for further details.
-
30.7.3 Unbounded C Arrays
+
31.7.3 Unbounded C Arrays
@@ -3786,7 +3786,7 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
-
30.7.4 String handling
+
31.7.4 String handling
@@ -3855,16 +3855,16 @@ If you need to return binary data, you might use the
also be used to extra binary data from arbitrary pointers.
-
30.7.5 Arrays
+
31.7.5 Arrays
-
30.7.6 String arrays
+
31.7.6 String arrays
-
30.7.7 STL wrappers
+
31.7.7 STL wrappers
-
30.8 Typemaps
+
31.8 Typemaps
@@ -3881,7 +3881,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Python interface or if you want to elevate your guru status.
-
30.8.1 What is a typemap?
+
31.8.1 What is a typemap?
@@ -3997,7 +3997,7 @@ parameter is omitted):
-
30.8.2 Python typemaps
+
31.8.2 Python typemaps
@@ -4038,7 +4038,7 @@ a look at the SWIG library version 1.3.20 or so.
-
30.8.3 Typemap variables
+
31.8.3 Typemap variables
@@ -4109,7 +4109,7 @@ properly assigned.
The Python name of the wrapper function being created.
-
30.8.4 Useful Python Functions
+
31.8.4 Useful Python Functions
@@ -4237,7 +4237,7 @@ write me
-
30.9 Typemap Examples
+
31.9 Typemap Examples
@@ -4246,7 +4246,7 @@ might look at the files "python.swg" and "typemaps.i" in
the SWIG library.
-
30.9.1 Converting Python list to a char **
+
31.9.1 Converting Python list to a char **
@@ -4326,7 +4326,7 @@ memory allocation is used to allocate memory for the array, the
the C function.
-
30.9.2 Expanding a Python object into multiple arguments
+
31.9.2 Expanding a Python object into multiple arguments
@@ -4405,7 +4405,7 @@ to supply the argument count. This is automatically set by the typemap code. F
-
30.9.3 Using typemaps to return arguments
+
31.9.3 Using typemaps to return arguments
@@ -4494,7 +4494,7 @@ function can now be used as follows:
>>>
-
30.9.4 Mapping Python tuples into small arrays
+
31.9.4 Mapping Python tuples into small arrays
@@ -4543,7 +4543,7 @@ array, such an approach would not be recommended for huge arrays, but
for small structures, this approach works fine.
-
30.9.5 Mapping sequences to C arrays
+
31.9.5 Mapping sequences to C arrays
@@ -4632,7 +4632,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) {
-
30.9.6 Pointer handling
+
31.9.6 Pointer handling
@@ -4729,7 +4729,7 @@ class object (if applicable).
-
30.10 Docstring Features
+
31.10 Docstring Features
@@ -4757,7 +4757,7 @@ of your users much simpler.
-
30.10.1 Module docstring
+
31.10.1 Module docstring
@@ -4791,7 +4791,7 @@ layout of controls on a panel, etc. to be loaded from an XML file."
-
30.10.2 %feature("autodoc")
+
31.10.2 %feature("autodoc")
@@ -4818,7 +4818,7 @@ names, default values if any, and return type if any. There are also
three options for autodoc controlled by the value given to the
feature, described below.
-
@@ -33,7 +33,7 @@ compile and run an R interface to QuantLib running on Mandriva Linux
with gcc. The R bindings also work on Microsoft Windows using Visual C++.
-
33.1 Bugs
+
34.1 Bugs
@@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:
C Array wrappings
-
33.2 Using R and SWIG
+
34.2 Using R and SWIG
@@ -99,7 +99,7 @@ Without it, inheritance of wrapped objects may fail.
These two files can be loaded in any order
-
33.3 Precompiling large R files
+
34.3 Precompiling large R files
In cases where the R file is large, one make save a lot of loading
@@ -117,7 +117,7 @@ will save a large amount of loading time.
-
33.4 General policy
+
34.4 General policy
@@ -126,7 +126,7 @@ wrapping over the underlying functions and rely on the R type system
to provide R syntax.
-
33.5 Language conventions
+
34.5 Language conventions
@@ -135,7 +135,7 @@ and [ are overloaded to allow for R syntax (one based indices and
slices)
-
33.6 C++ classes
+
34.6 C++ classes
@@ -147,7 +147,7 @@ keep track of the pointer object which removes the necessity for a lot
of the proxy class baggage you see in other languages.
SWIG 1.3 is known to work with Ruby versions 1.6 and later.
@@ -190,7 +190,7 @@ of Ruby.
-
31.1.1 Running SWIG
+
32.1.1 Running SWIG
To build a Ruby module, run SWIG using the -ruby
@@ -244,7 +244,7 @@ to compile this file and link it with the rest of your program.
-
31.1.2 Getting the right header files
+
32.1.2 Getting the right header files
In order to compile the wrapper code, the compiler needs the ruby.h
@@ -288,7 +288,7 @@ installed, you can run Ruby to find out. For example:
-
31.1.3 Compiling a dynamic module
+
32.1.3 Compiling a dynamic module
Ruby extension modules are typically compiled into shared
@@ -443,7 +443,7 @@ manual pages for your compiler and linker to determine the correct set
of options. You might also check the SWIG Wiki
for additional information.
-
31.1.4 Using your module
+
32.1.4 Using your module
Ruby module names must be capitalized,
@@ -498,7 +498,7 @@ begins with:
-
31.1.5 Static linking
+
32.1.5 Static linking
An alternative approach to dynamic linking is to rebuild the
@@ -519,7 +519,7 @@ finally rebuilding Ruby.
-
31.1.6 Compilation of C++ extensions
+
32.1.6 Compilation of C++ extensions
On most machines, C++ extension modules should be linked
@@ -571,7 +571,7 @@ extension, e.g.
-
31.2 Building Ruby Extensions under Windows 95/NT
+
32.2 Building Ruby Extensions under Windows 95/NT
Building a SWIG extension to Ruby under Windows 95/NT is
@@ -610,7 +610,7 @@ files.
-
31.2.1 Running SWIG from Developer Studio
+
32.2.1 Running SWIG from Developer Studio
If you are developing your application within Microsoft
@@ -752,7 +752,7 @@ directory, then run the Ruby script from the DOS/Command prompt:
-
31.3 The Ruby-to-C/C++ Mapping
+
32.3 The Ruby-to-C/C++ Mapping
This section describes the basics of how SWIG maps C or C++
@@ -762,7 +762,7 @@ declarations in your SWIG interface files to Ruby constructs.
There are three ways to raise exceptions from C++ code to
@@ -4621,7 +4621,7 @@ the built-in Ruby exception types.
-
31.6.4 Exception classes
+
32.6.4 Exception classes
Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass
@@ -4679,7 +4679,7 @@ providing for a more natural integration between C++ code and Ruby code.
-
31.7 Typemaps
+
32.7 Typemaps
This section describes how you can modify SWIG's default
@@ -4702,7 +4702,7 @@ of the primitive C-Ruby interface.
-
31.7.1 What is a typemap?
+
32.7.1 What is a typemap?
A typemap is nothing more than a code generation rule that is
@@ -4964,7 +4964,7 @@ to be used as follows (notice how the length parameter is omitted):
-
31.7.2 Typemap scope
+
32.7.2 Typemap scope
Once defined, a typemap remains in effect for all of the
@@ -5012,7 +5012,7 @@ where the class itself is defined. For example:
-
31.7.3 Copying a typemap
+
32.7.3 Copying a typemap
A typemap is copied by using assignment. For example:
@@ -5114,7 +5114,7 @@ rules as for
-
31.7.4 Deleting a typemap
+
32.7.4 Deleting a typemap
A typemap can be deleted by simply defining no code. For
@@ -5166,7 +5166,7 @@ typemaps immediately after the clear operation.
-
31.7.5 Placement of typemaps
+
32.7.5 Placement of typemaps
Typemap declarations can be declared in the global scope,
@@ -5250,7 +5250,7 @@ string
-
31.7.6 Ruby typemaps
+
32.7.6 Ruby typemaps
The following list details all of the typemap methods that
@@ -5260,7 +5260,7 @@ can be used by the Ruby module:
-
31.7.6.1 "in" typemap
+
32.7.6.1 "in" typemap
Converts Ruby objects to input
@@ -5503,7 +5503,7 @@ arguments to be specified. For example:
-
31.7.6.2 "typecheck" typemap
+
32.7.6.2 "typecheck" typemap
The "typecheck" typemap is used to support overloaded
@@ -5544,7 +5544,7 @@ on "Typemaps and Overloading."
-
31.7.6.3 "out" typemap
+
32.7.6.3 "out" typemap
Converts return value of a C function
@@ -5776,7 +5776,7 @@ version of the C datatype matched by the typemap.
-
31.7.6.4 "arginit" typemap
+
32.7.6.4 "arginit" typemap
The "arginit" typemap is used to set the initial value of a
@@ -5801,7 +5801,7 @@ applications. For example:
-
31.7.6.5 "default" typemap
+
32.7.6.5 "default" typemap
The "default" typemap is used to turn an argument into a
@@ -5843,7 +5843,7 @@ default argument wrapping.
-
31.7.6.6 "check" typemap
+
32.7.6.6 "check" typemap
The "check" typemap is used to supply value checking code
@@ -5867,7 +5867,7 @@ arguments have been converted. For example:
-
31.7.6.7 "argout" typemap
+
32.7.6.7 "argout" typemap
The "argout" typemap is used to return values from arguments.
@@ -6025,7 +6025,7 @@ some function like SWIG_Ruby_AppendOutput.
-
31.7.6.8 "freearg" typemap
+
32.7.6.8 "freearg" typemap
The "freearg" typemap is used to cleanup argument data. It is
@@ -6061,7 +6061,7 @@ abort prematurely.
-
31.7.6.9 "newfree" typemap
+
32.7.6.9 "newfree" typemap
The "newfree" typemap is used in conjunction with the %newobject
@@ -6092,7 +6092,7 @@ ownership and %newobject for further details.
-
31.7.6.10 "memberin" typemap
+
32.7.6.10 "memberin" typemap
The "memberin" typemap is used to copy data from an
@@ -6125,7 +6125,7 @@ other objects.
-
31.7.6.11 "varin" typemap
+
32.7.6.11 "varin" typemap
The "varin" typemap is used to convert objects in the target
@@ -6136,7 +6136,7 @@ This is implementation specific.
-
31.7.6.12 "varout" typemap
+
32.7.6.12 "varout" typemap
The "varout" typemap is used to convert a C/C++ object to an
@@ -6147,7 +6147,7 @@ This is implementation specific.
-
31.7.6.13 "throws" typemap
+
32.7.6.13 "throws" typemap
The "throws" typemap is only used when SWIG parses a C++
@@ -6206,7 +6206,7 @@ handling with %exception section.
-
31.7.6.14 directorin typemap
+
32.7.6.14 directorin typemap
Converts C++ objects in director
@@ -6460,7 +6460,7 @@ referring to the class itself.
-
31.7.6.15 directorout typemap
+
32.7.6.15 directorout typemap
Converts Ruby objects in director
@@ -6720,7 +6720,7 @@ exception.
-
31.7.6.16 directorargout typemap
+
32.7.6.16 directorargout typemap
Output argument processing in director
@@ -6960,7 +6960,7 @@ referring to the instance of the class itself
-
31.7.6.17 ret typemap
+
32.7.6.17 ret typemap
Cleanup of function return values
@@ -6970,7 +6970,7 @@ referring to the instance of the class itself
-
31.7.6.18 globalin typemap
+
32.7.6.18 globalin typemap
Setting of C global variables
@@ -6980,7 +6980,7 @@ referring to the instance of the class itself
-
31.7.7 Typemap variables
+
32.7.7 Typemap variables
@@ -7090,7 +7090,7 @@ being created.
-
31.7.8 Useful Functions
+
32.7.8 Useful Functions
When you write a typemap, you usually have to work directly
@@ -7114,7 +7114,7 @@ across multiple languages.
-
31.7.8.1 C Datatypes to Ruby Objects
+
32.7.8.1 C Datatypes to Ruby Objects
@@ -7170,7 +7170,7 @@ SWIG_From_float(float)
-
31.7.8.2 Ruby Objects to C Datatypes
+
32.7.8.2 Ruby Objects to C Datatypes
Here, while the Ruby versions return the value directly, the SWIG
@@ -7259,7 +7259,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input
-
The Ruby language doesn't support multiple inheritance, but
@@ -9802,7 +9802,7 @@ Features") for more details).
-
31.10 Memory Management
+
32.10 Memory Management
One of the most common issues in generating SWIG bindings for
@@ -9849,7 +9849,7 @@ understanding of how the underlying library manages memory.
-
31.10.1 Mark and Sweep Garbage Collector
+
32.10.1 Mark and Sweep Garbage Collector
Ruby uses a mark and sweep garbage collector. When the garbage
@@ -9897,7 +9897,7 @@ this memory.
-
31.10.2 Object Ownership
+
32.10.2 Object Ownership
As described above, memory management depends on clearly
@@ -10124,7 +10124,7 @@ classes is:
-
31.10.3 Object Tracking
+
32.10.3 Object Tracking
The remaining parts of this section will use the class library
@@ -10338,7 +10338,7 @@ methods.
-
31.10.4 Mark Functions
+
32.10.4 Mark Functions
With a bit more testing, we see that our class library still
@@ -10456,7 +10456,7 @@ test suite.
-
31.10.5 Free Functions
+
32.10.5 Free Functions
By default, SWIG creates a "free" function that is called when
@@ -10611,7 +10611,7 @@ been freed, and thus raises a runtime exception.
-
31.10.6 Embedded Ruby and the C++ Stack
+
32.10.6 Embedded Ruby and the C++ Stack
As has been said, the Ruby GC runs and marks objects before
diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html
index e837a5b17..b36395cab 100644
--- a/Doc/Manual/Tcl.html
+++ b/Doc/Manual/Tcl.html
@@ -6,7 +6,7 @@
-
32 SWIG and Tcl
+
33 SWIG and Tcl
@@ -82,7 +82,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but
this is no longer supported.
-
32.1 Preliminaries
+
33.1 Preliminaries
@@ -108,7 +108,7 @@ build a Tcl extension module. To finish building the module, you
need to compile this file and link it with the rest of your program.
-
32.1.1 Getting the right header files
+
33.1.1 Getting the right header files
@@ -126,7 +126,7 @@ this is the case, you should probably make a symbolic link so that tcl.h
-
32.1.2 Compiling a dynamic module
+
33.1.2 Compiling a dynamic module
@@ -161,7 +161,7 @@ The name of the module is specified using the %module directive or the
-module command line option.
-
32.1.3 Static linking
+
33.1.3 Static linking
@@ -227,7 +227,7 @@ minimal in most situations (and quite frankly not worth the extra
hassle in the opinion of this author).
-
32.1.4 Using your module
+
33.1.4 Using your module
@@ -355,7 +355,7 @@ to the default system configuration (this requires root access and you will need
the man pages).
-
32.1.5 Compilation of C++ extensions
+
33.1.5 Compilation of C++ extensions
@@ -438,7 +438,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
-
32.1.6 Compiling for 64-bit platforms
+
33.1.6 Compiling for 64-bit platforms
@@ -465,7 +465,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
-
32.1.7 Setting a package prefix
+
33.1.7 Setting a package prefix
@@ -484,7 +484,7 @@ option will append the prefix to the name when creating a command and
call it "Foo_bar".
-
32.1.8 Using namespaces
+
33.1.8 Using namespaces
@@ -506,7 +506,7 @@ When the -namespace option is used, objects in the module
are always accessed with the namespace name such as Foo::bar.
-
32.2 Building Tcl/Tk Extensions under Windows 95/NT
+
33.2 Building Tcl/Tk Extensions under Windows 95/NT
@@ -517,7 +517,7 @@ covers the process of using SWIG with Microsoft Visual C++.
although the procedure may be similar with other compilers.
-
32.2.1 Running SWIG from Developer Studio
+
33.2.1 Running SWIG from Developer Studio
@@ -575,7 +575,7 @@ MSDOS > tclsh80
%
-
32.2.2 Using NMAKE
+
33.2.2 Using NMAKE
@@ -638,7 +638,7 @@ to get you started. With a little practice, you'll be making lots of
Tcl extensions.
-
32.3 A tour of basic C/C++ wrapping
+
33.3 A tour of basic C/C++ wrapping
@@ -649,7 +649,7 @@ classes. This section briefly covers the essential aspects of this
wrapping.
-
32.3.1 Modules
+
33.3.1 Modules
@@ -683,7 +683,7 @@ To fix this, supply an extra argument to load like this:
-
@@ -872,7 +872,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l
conversion. This allows the global statement to be omitted.
-
32.3.5 Pointers
+
33.3.5 Pointers
@@ -968,7 +968,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
None if the conversion can't be performed.
-
32.3.6 Structures
+
33.3.6 Structures
@@ -1250,7 +1250,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the
memory management section that appears shortly.
-
32.3.7 C++ classes
+
33.3.7 C++ classes
@@ -1317,7 +1317,7 @@ In Tcl, the static member is accessed as follows:
-
32.3.8 C++ inheritance
+
33.3.8 C++ inheritance
@@ -1366,7 +1366,7 @@ For instance:
It is safe to use multiple inheritance with SWIG.
-
32.3.9 Pointers, references, values, and arrays
+
33.3.9 Pointers, references, values, and arrays
@@ -1420,7 +1420,7 @@ to hold the result and a pointer is returned (Tcl will release this memory
when the return value is garbage collected).
-
32.3.10 C++ overloaded functions
+
33.3.10 C++ overloaded functions
@@ -1543,7 +1543,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
-
32.3.11 C++ operators
+
33.3.11 C++ operators
@@ -1645,7 +1645,7 @@ There are ways to make this operator appear as part of the class using the %
Keep reading.
-
32.3.12 C++ namespaces
+
33.3.12 C++ namespaces
@@ -1709,7 +1709,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
@@ -2433,7 +2433,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex
See the chapter on "Customization Features" for more examples.
-
32.7 Typemaps
+
33.7 Typemaps
@@ -2450,7 +2450,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Tcl interface.
-
32.7.1 What is a typemap?
+
33.7.1 What is a typemap?
@@ -2567,7 +2567,7 @@ parameter is omitted):
-
32.7.2 Tcl typemaps
+
33.7.2 Tcl typemaps
@@ -2705,7 +2705,7 @@ Initialize an argument to a value before any conversions occur.
Examples of these methods will appear shortly.
-
32.7.3 Typemap variables
+
33.7.3 Typemap variables
@@ -2776,7 +2776,7 @@ properly assigned.
The Tcl name of the wrapper function being created.
-
32.7.4 Converting a Tcl list to a char **
+
33.7.4 Converting a Tcl list to a char **
@@ -2838,7 +2838,7 @@ argv[2] = Larry
3
-
32.7.5 Returning values in arguments
+
33.7.5 Returning values in arguments
@@ -2880,7 +2880,7 @@ result, a Tcl function using these typemaps will work like this :
%
-
32.7.6 Useful functions
+
33.7.6 Useful functions
@@ -2957,7 +2957,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
-
32.7.7 Standard typemaps
+
33.7.7 Standard typemaps
@@ -3041,7 +3041,7 @@ work)
-
32.7.8 Pointer handling
+
33.7.8 Pointer handling
@@ -3117,7 +3117,7 @@ For example:
-
32.8 Turning a SWIG module into a Tcl Package.
+
33.8 Turning a SWIG module into a Tcl Package.
@@ -3189,7 +3189,7 @@ As a final note, most SWIG examples do not yet use the
to use the load command instead.
-
32.9 Building new kinds of Tcl interfaces (in Tcl)
+
33.9 Building new kinds of Tcl interfaces (in Tcl)
@@ -3288,7 +3288,7 @@ danger of blowing something up (although it is easily accomplished
with an out of bounds array access).
@@ -42,7 +42,7 @@ This chapter describes SWIG's support for creating ANSI C wrappers. This module
-
17.1 Overview
+
36.1 Overview
@@ -60,10 +60,10 @@ With wrapper interfaces generated by SWIG, it is easy to use the functionality o
Flattening C++ language constructs into a set of C-style functions obviously comes with many limitations and inconveniences. All data and functions become global. Manipulating objects requires explicit calls to special functions. We are losing the high level abstraction and have to work around it.
-
17.2 Preliminaries
+
36.2 Preliminaries
-
17.2.1 Running SWIG
+
36.2.1 Running SWIG
@@ -98,7 +98,7 @@ $ swig -c++ -c example.i
Note that -c is the option specifying the target language and -c++ controls what the input language is.
-
+
This will generate an example_wrap.c file or, in the latter case, example_wrap.cxx file, along with example_proxy.h and example_proxy.c files. The name of the file is derived from the name of the input file. To change this, you can use the -o option common to all language modules.
@@ -108,7 +108,7 @@ This will generate an example_wrap.c file or, in the latter case, e
The wrap file contains the wrapper functions, which perform the main functionality of SWIG: it translates the input arguments from C to C++, makes calls to the original functions and marshalls C++ output back to C data. The proxy header file contains the interface we can use in C application code. The additional .c file contains calls to the wrapper functions, allowing us to preserve names of the original functions.
-
17.2.2 Command line options
+
36.2.2 Command line options
@@ -136,7 +136,7 @@ swig -c -help
-
17.2.3 Compiling a dynamic module
+
36.2.3 Compiling a dynamic module
@@ -163,7 +163,7 @@ $ g++ -shared example_wrap.o -o libexample.so
Now the shared library module is ready to use. Note that the name of the generated module is important: is should be prefixed with lib on Unix, and have the specific extension, like .dll for Windows or .so for Unix systems.
-
17.2.4 Using the generated module
+
36.2.4 Using the generated module
@@ -178,14 +178,14 @@ $ gcc runme.c example_proxy.c -L. -lexample -o runme
This will compile the application code (runme.c), along with the proxy code and link it against the generated shared module. Following the -L option is the path to the directory containing the shared module. The output executable is ready to use. The last thing to do is to supply to the operating system the information of location of our module. This is system dependant, for instance Unix systems look for shared modules in certain directories, like /usr/lib, and additionally we can set the environment variable LD_LIBRARY_PATH (Unix) or PATH (Windows) for other directories.
-
17.3 Basic C wrapping
+
36.3 Basic C wrapping
Wrapping C functions and variables is obviously performed in a straightforward way. There is no need to perform type conversions, and all language constructs can be preserved in their original form. However, SWIG allows you to enchance the code with some additional elements, for instance using check typemap or %extend directive.
-
17.3.1 Functions
+
36.3.1 Functions
@@ -259,7 +259,7 @@ int _wrap_gcd(int arg1, int arg2) {
This time calling gcd with negative value argument will trigger an error message. This can save you time writing all the constraint checking code by hand.
The main reason of having the C module in SWIG is to be able to access C++ from C. In this chapter we will take a look at the rules of wrapping elements of the C++ language.
@@ -397,7 +397,7 @@ Windows users can also get the examples working using a
Cygwin or MinGW environment for automatic configuration of the example makefiles.
Any one of the three C# compilers (Portable.NET, Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path.
-
18.3 C# Exceptions
+
17.3 C# Exceptions
@@ -494,7 +494,7 @@ set so should only be used when a C# exception is not created.
-
18.3.1 C# exception example using "check" typemap
+
17.3.1 C# exception example using "check" typemap
@@ -676,7 +676,7 @@ method and C# code does not handle pending exceptions via the canthrow attribute
Actually it will issue this warning for any function beginning with SWIG_CSharpSetPendingException.
-
18.3.2 C# exception example using %exception
+
17.3.2 C# exception example using %exception
@@ -741,7 +741,7 @@ The managed code generated does check for the pending exception as mentioned ear
-
18.3.3 C# exception example using exception specifications
+
17.3.3 C# exception example using exception specifications
@@ -798,7 +798,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) {
Multiple catch handlers are generated should there be more than one exception specifications declared.
-
18.3.4 Custom C# ApplicationException example
+
17.3.4 Custom C# ApplicationException example
@@ -932,7 +932,7 @@ try {
-
18.4 C# Directors
+
17.4 C# Directors
@@ -945,7 +945,7 @@ The following sections provide information on the C# director implementation and
However, the Java directors section should also be read in order to gain more insight into directors.
@@ -1300,7 +1300,7 @@ However, a call from C# to CSharpDefaults.DefaultMethod() will of cours
should pass the call on to CSharpDefaults.DefaultMethod(int)using the C++ default value, as shown above.
-
18.5 C# Typemap examples
+
17.5 C# Typemap examples
This section includes a few examples of typemaps. For more examples, you
@@ -1308,7 +1308,7 @@ might look at the files "csharp.swg" and "typemaps.i" in
the SWIG library.
-
18.5.1 Memory management when returning references to member variables
+
17.5.1 Memory management when returning references to member variables
@@ -1432,7 +1432,7 @@ public class Bike : IDisposable {
Note the addReference call.
-
18.5.2 Memory management for objects passed to the C++ layer
+
17.5.2 Memory management for objects passed to the C++ layer
@@ -1551,7 +1551,7 @@ The 'cscode' typemap simply adds in the specified code into the C# proxy class.
-
18.5.3 Date marshalling using the csin typemap and associated attributes
+
17.5.3 Date marshalling using the csin typemap and associated attributes
@@ -1788,7 +1788,7 @@ public class example {
-
18.5.4 A date example demonstrating marshalling of C# properties
+
17.5.4 A date example demonstrating marshalling of C# properties
@@ -1888,7 +1888,7 @@ Some points to note:
-
18.5.5 Turning wrapped classes into partial classes
+
17.5.5 Turning wrapped classes into partial classes
@@ -1988,7 +1988,7 @@ demonstrating that the class contains methods calling both unmanaged code -
The following example is an alternative approach to adding managed code to the generated proxy class.
-
18.5.6 Extending proxy classes with additional C# code
+
17.5.6 Extending proxy classes with additional C# code
@@ -230,7 +230,7 @@
for info on how to apply the %feature.
-
19.2.4 Functions
+
18.2.4 Functions
@@ -249,7 +249,7 @@
parameters). The return values can then be accessed with (call-with-values).
-
19.2.5 Exceptions
+
18.2.5 Exceptions
The SWIG chicken module has support for exceptions thrown from
@@ -291,7 +291,7 @@
-
19.3 TinyCLOS
+
18.3 TinyCLOS
@@ -334,7 +334,7 @@
-
19.4 Linkage
+
18.4 Linkage
@@ -355,7 +355,7 @@
-
19.4.1 Static binary or shared library linked at compile time
+
18.4.1 Static binary or shared library linked at compile time
We can easily use csc to build a static binary.
@@ -396,7 +396,7 @@ in which case the test script does not need to be linked with example.so. The t
be run with csi.
-
19.4.2 Building chicken extension libraries
+
18.4.2 Building chicken extension libraries
Building a shared library like in the above section only works if the library
@@ -454,7 +454,7 @@ distributed and used by anyone, even if SWIG is not installed.
See the Examples/chicken/egg directory in the SWIG source for an example that builds
two eggs, one using the first method and one using the second method.
-
19.4.3 Linking multiple SWIG modules with TinyCLOS
+
18.4.3 Linking multiple SWIG modules with TinyCLOS
Linking together multiple modules that share type information using the %import
@@ -478,7 +478,7 @@ with (declare (uses ...)).
To create an extension library or an egg, just create a module_load.scm file that (declare (uses ...))
all the modules.
-
19.5 Typemaps
+
18.5 Typemaps
@@ -487,7 +487,7 @@ all the modules.
Lib/chicken/chicken.swg.
-
19.6 Pointers
+
18.6 Pointers
@@ -520,7 +520,7 @@ all the modules.
type. flags is either zero or SWIG_POINTER_DISOWN (see below).
-
19.6.1 Garbage collection
+
18.6.1 Garbage collection
If the owner flag passed to SWIG_NewPointerObj is 1, NewPointerObj will add a
@@ -551,7 +551,7 @@ all the modules.
19.7.1 TinyCLOS problems with Chicken version <= 1.92
+
18.7.1 TinyCLOS problems with Chicken version <= 1.92
In Chicken versions equal to or below 1.92, TinyCLOS has a limitation such that generic methods do not properly work on methods
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index ed90dc6d1..c3197b9dc 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -581,34 +581,7 @@
-
@@ -89,7 +89,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.
-
35.2 Prerequisites
+
34.2 Prerequisites
@@ -119,7 +119,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of
wrapper code are driven by C++ datatypes.
-
35.3 The Big Picture
+
34.3 The Big Picture
@@ -156,7 +156,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.
-
35.4 Execution Model
+
34.4 Execution Model
@@ -201,7 +201,7 @@ latter stage of compilation.
The next few sections briefly describe some of these stages.
-
35.4.1 Preprocessing
+
34.4.1 Preprocessing
@@ -281,7 +281,7 @@ been expanded as well as everything else that goes into the low-level
construction of the wrapper code.
-
35.4.2 Parsing
+
34.4.2 Parsing
@@ -382,7 +382,7 @@ returning a foo and taking types a and b as
arguments).
@@ -655,7 +655,7 @@ that matches the name of the target language. For example, python:fooperl:foo.
-
35.4.5 Symbol Tables
+
34.4.5 Symbol Tables
@@ -746,7 +746,7 @@ example.i:5. Previous declaration is foo_i(int )
-
35.4.6 The %feature directive
+
34.4.6 The %feature directive
@@ -802,7 +802,7 @@ For example, the exception code above is simply
stored without any modifications.
-
35.4.7 Code Generation
+
34.4.7 Code Generation
@@ -924,7 +924,7 @@ public :
The role of these functions is described shortly.
-
35.4.8 SWIG and XML
+
34.4.8 SWIG and XML
@@ -937,7 +937,7 @@ internal data structures, it may be useful to keep XML in the back of
your mind as a model.
-
35.5 Primitive Data Structures
+
34.5 Primitive Data Structures
@@ -983,7 +983,7 @@ typedef Hash Typetab;
-
35.5.1 Strings
+
34.5.1 Strings
@@ -1124,7 +1124,7 @@ Returns the number of replacements made (if any).
-
35.5.2 Hashes
+
34.5.2 Hashes
@@ -1201,7 +1201,7 @@ Returns the list of hash table keys.
-
35.5.3 Lists
+
34.5.3 Lists
@@ -1290,7 +1290,7 @@ If t is not a standard object, it is assumed to be a char *
and is used to create a String object.
-
35.5.4 Common operations
+
34.5.4 Common operations
The following operations are applicable to all datatypes.
@@ -1345,7 +1345,7 @@ objects and report errors.
Gets the line number associated with x.
-
35.5.5 Iterating over Lists and Hashes
+
34.5.5 Iterating over Lists and Hashes
To iterate over the elements of a list or a hash table, the following functions are used:
@@ -1390,7 +1390,7 @@ for (j = First(j); j.item; j= Next(j)) {
-
35.5.6 I/O
+
34.5.6 I/O
Special I/O functions are used for all internal I/O. These operations
@@ -1526,7 +1526,7 @@ Similarly, the preprocessor and parser all operate on string-files.
-
35.6 Navigating and manipulating parse trees
+
34.6 Navigating and manipulating parse trees
Parse trees are built as collections of hash tables. Each node is a hash table in which
@@ -1660,7 +1660,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u
the parent so that sibling nodes are unaffected.
-
35.7 Working with attributes
+
34.7 Working with attributes
@@ -1777,7 +1777,7 @@ the attribute is optional. Swig_restore() must always be called after
function.
-
35.8 Type system
+
34.8 Type system
@@ -1786,7 +1786,7 @@ pointers, references, and pointers to members. A detailed discussion of
type theory is impossible here. However, let's cover the highlights.
-
35.8.1 String encoding of types
+
34.8.1 String encoding of types
@@ -1887,7 +1887,7 @@ make the final type, the two parts are just joined together using
string concatenation.
-
35.8.2 Type construction
+
34.8.2 Type construction
@@ -2056,7 +2056,7 @@ Returns the prefix of a type. For example, if ty is
ty is unmodified.
-
35.8.3 Type tests
+
34.8.3 Type tests
@@ -2143,7 +2143,7 @@ Checks if ty is a varargs type.
Checks if ty is a templatized type.
-
35.8.4 Typedef and inheritance
+
34.8.4 Typedef and inheritance
@@ -2245,7 +2245,7 @@ Fully reduces ty according to typedef rules. Resulting datatype
will consist only of primitive typenames.
-
@@ -2344,7 +2344,7 @@ SWIG, but is most commonly associated with type-descriptor objects
that appear in wrappers (e.g., SWIGTYPE_p_double).
-
35.9 Parameters
+
34.9 Parameters
@@ -2443,7 +2443,7 @@ included. Used to emit prototypes.
Returns the number of required (non-optional) arguments in p.
-
35.10 Writing a Language Module
+
34.10 Writing a Language Module
@@ -2458,7 +2458,7 @@ describes the creation of a minimal Python module. You should be able to extra
this to other languages.
-
35.10.1 Execution model
+
34.10.1 Execution model
@@ -2468,7 +2468,7 @@ the parsing of command line options, all aspects of code generation are controll
different methods of the Language that must be defined by your module.
-
35.10.2 Starting out
+
34.10.2 Starting out
@@ -2576,7 +2576,7 @@ that activates your module. For example, swig -python foo.i. The
messages from your new module should appear.
-
35.10.3 Command line options
+
34.10.3 Command line options
@@ -2635,7 +2635,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit
unrecognized command line option error.
-
35.10.4 Configuration and preprocessing
+
34.10.4 Configuration and preprocessing
@@ -2684,7 +2684,7 @@ an implementation file python.cxx and a configuration file
python.swg.
-
35.10.5 Entry point to code generation
+
34.10.5 Entry point to code generation
@@ -2742,7 +2742,7 @@ int Python::top(Node *n) {
-
@@ -3038,7 +3038,7 @@ but without the typemaps, there is still work to do.
-
35.10.8 Configuration files
+
34.10.8 Configuration files
@@ -3188,7 +3188,7 @@ politely displays the ignoring language message.
-
35.10.9 Runtime support
+
34.10.9 Runtime support
@@ -3197,7 +3197,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g.
the SWIG files that implement those functions.
-
35.10.10 Standard library files
+
34.10.10 Standard library files
@@ -3216,7 +3216,7 @@ The following are the minimum that are usually supported:
Please copy these and modify for any new language.
-
35.10.11 Examples and test cases
+
34.10.11 Examples and test cases
@@ -3245,7 +3245,7 @@ during this process, see the section on configuration
files.
-
35.10.12 Documentation
+
34.10.12 Documentation
@@ -3277,7 +3277,7 @@ Some topics that you'll want to be sure to address include:
if available.
-
35.10.13 Prerequisites for adding a new language module to the SWIG distribution
+
34.10.13 Prerequisites for adding a new language module to the SWIG distribution
@@ -3334,7 +3334,7 @@ should be added should there be an area not already covered by
the existing tests.
-
35.10.14 Coding style guidelines
+
34.10.14 Coding style guidelines
@@ -3358,13 +3358,13 @@ 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.
This section details guile-specific support in SWIG.
-
20.1 Meaning of "Module"
+
19.1 Meaning of "Module"
@@ -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".
-
20.2 Using the SCM or GH Guile API
+
19.2 Using the SCM or GH Guile API
The guile module can currently export wrapper files that use the guile GH interface or the
@@ -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.
-
20.3 Linkage
+
19.3 Linkage
@@ -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 linkage.
-
20.3.1 Simple Linkage
+
19.3.1 Simple Linkage
@@ -206,7 +206,7 @@ placed between the define-module form and the
SWIG_init via a preprocessor define to avoid symbol
clashes. For this case, however, passive linkage is available.
-
20.3.2 Passive Linkage
+
19.3.2 Passive Linkage
Passive linkage is just like simple linkage, but it generates an
@@ -216,7 +216,7 @@ package name (see below).
You should use passive linkage rather than simple linkage when you
are using multiple modules.
-
20.3.3 Native Guile Module Linkage
+
19.3.3 Native Guile Module Linkage
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:
-
20.3.4 Old Auto-Loading Guile Module Linkage
+
19.3.4 Old Auto-Loading Guile Module Linkage
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.
-
20.3.5 Hobbit4D Linkage
+
19.3.5 Hobbit4D Linkage
@@ -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.
-
20.4 Underscore Folding
+
19.4 Underscore Folding
@@ -320,7 +320,7 @@ complained so far.
%rename to specify the Guile name of the wrapped
functions and variables (see CHANGES).
-
20.5 Typemaps
+
19.5 Typemaps
@@ -412,7 +412,7 @@ constant will appear as a scheme variable. See
Features and the %feature directive
for info on how to apply the %feature.
-
20.6 Representation of pointers as smobs
+
19.6 Representation of pointers as smobs
@@ -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 wrong-type-arg exception is raised.
-
20.6.1 GH Smobs
+
19.6.1 GH Smobs
@@ -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.
-
20.6.2 SCM Smobs
+
19.6.2 SCM Smobs
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.
-
20.6.3 Garbage Collection
+
19.6.3 Garbage Collection
Garbage collection is a feature of the new SCM interface, and it is automatically included
@@ -491,7 +491,7 @@ is exactly like described in
Object ownership and %newobject in the SWIG manual. All typemaps use an $owner var, and
the guile module replaces $owner with 0 or 1 depending on feature:new.
-
20.7 Exception Handling
+
19.7 Exception Handling
@@ -517,7 +517,7 @@ mapping:
The default when not specified here is to use "swig-error".
See Lib/exception.i for details.
-
20.8 Procedure documentation
+
19.8 Procedure documentation
If invoked with the command-line option -procdoc
@@ -553,7 +553,7 @@ like this:
typemap argument doc. See Lib/guile/typemaps.i for
details.
-
20.9 Procedures with setters
+
19.9 Procedures with setters
For global variables, SWIG creates a single wrapper procedure
@@ -581,7 +581,7 @@ struct members, the procedures (struct-member-get
pointer) and (struct-member-set pointer
value) are not generated.
-
20.10 GOOPS Proxy Classes
+
19.10 GOOPS Proxy Classes
SWIG can also generate classes and generic functions for use with
@@ -730,7 +730,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th
%import "foo.h" before the %inline block.
-
20.10.1 Naming Issues
+
19.10.1 Naming Issues
As you can see in the example above, there are potential naming conflicts. The default exported
@@ -769,7 +769,7 @@ guile-modules. For example,
TODO: Renaming class name prefixes?
-
20.10.2 Linking
+
19.10.2 Linking
The guile-modules generated above all need to be linked together. GOOPS support requires
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index 4b8993184..164fc21e7 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -5,7 +5,7 @@
-
21 SWIG and Java
+
20 SWIG and Java
@@ -154,7 +154,7 @@ It covers most SWIG features, but certain low-level details are covered in less
-
21.1 Overview
+
20.1 Overview
@@ -189,7 +189,7 @@ Various customisation tips and techniques using SWIG directives are covered.
The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.
-
21.2 Preliminaries
+
20.2 Preliminaries
@@ -205,7 +205,7 @@ Run make -k check from the SWIG root directory after installing SWIG on
The Java module requires your system to support shared libraries and dynamic loading.
This is the commonly used method to load JNI code so your system will more than likely support this.
-
21.2.1 Running SWIG
+
20.2.1 Running SWIG
@@ -258,7 +258,7 @@ The following sections have further practical examples and details on how you mi
compiling and using the generated files.
-
21.2.2 Additional Commandline Options
+
20.2.2 Additional Commandline Options
@@ -295,7 +295,7 @@ swig -java -help
Their use will become clearer by the time you have finished reading this section on SWIG and Java.
-
21.2.3 Getting the right header files
+
20.2.3 Getting the right header files
@@ -310,7 +310,7 @@ They are usually in directories like this:
The exact location may vary on your machine, but the above locations are typical.
-
21.2.4 Compiling a dynamic module
+
20.2.4 Compiling a dynamic module
@@ -346,7 +346,7 @@ The name of the shared library output file is important.
If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information).
The name of the module is specified using the %module directive or -module command line option.
-
21.2.5 Using your module
+
20.2.5 Using your module
@@ -381,7 +381,7 @@ $
If it doesn't work have a look at the following section which discusses problems loading the shared library.
-
21.2.6 Dynamic linking problems
+
20.2.6 Dynamic linking problems
@@ -455,7 +455,7 @@ The following section also contains some C++ specific linking problems and solut
-
21.2.7 Compilation problems and compiling with C++
+
20.2.7 Compilation problems and compiling with C++
@@ -508,7 +508,7 @@ Finally make sure the version of JDK header files matches the version of Java th
-
21.2.8 Building on Windows
+
20.2.8 Building on Windows
@@ -517,7 +517,7 @@ You will want to produce a DLL that can be loaded by the Java Virtual Machine.
This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers.
In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.
-
21.2.8.1 Running SWIG from Visual Studio
+
20.2.8.1 Running SWIG from Visual Studio
@@ -556,7 +556,7 @@ To run the native code in the DLL (example.dll), make sure that it is in your pa
If the library fails to load have a look at Dynamic linking problems.
-
21.2.8.2 Using NMAKE
+
20.2.8.2 Using NMAKE
@@ -615,7 +615,7 @@ Of course you may want to make changes for it to work for C++ by adding in the -
-
21.3 A tour of basic C/C++ wrapping
+
20.3 A tour of basic C/C++ wrapping
@@ -625,7 +625,7 @@ variables are wrapped with JavaBean type getters and setters and so forth.
This section briefly covers the essential aspects of this wrapping.
-
21.3.1 Modules, packages and generated Java classes
+
20.3.1 Modules, packages and generated Java classes
@@ -659,7 +659,7 @@ swig -java -package com.bloggs.swig -outdir com/bloggs/swig example.i
SWIG won't create the directory, so make sure it exists beforehand.
-
@@ -920,7 +920,7 @@ Or if you decide this practice isn't so bad and your own class implements ex
-
21.3.5 Enumerations
+
20.3.5 Enumerations
@@ -934,7 +934,7 @@ The final two approaches use simple integers for each enum item.
Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.
-
21.3.5.1 Anonymous enums
+
20.3.5.1 Anonymous enums
@@ -997,7 +997,7 @@ As in the case of constants, you can access them through either the module class
-
21.3.5.2 Typesafe enums
+
20.3.5.2 Typesafe enums
@@ -1090,7 +1090,7 @@ When upgrading to JDK 1.5 or later, proper Java enums could be used instead, wit
The following section details proper Java enum generation.
@@ -1191,7 +1191,7 @@ Note that unlike typesafe enums, this approach requires users to mostly use diff
Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.
-
21.3.5.5 Simple enums
+
20.3.5.5 Simple enums
@@ -1210,7 +1210,7 @@ SWIG-1.3.21 and earlier versions wrapped all enums using this approach.
The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.
-
21.3.6 Pointers
+
20.3.6 Pointers
@@ -1298,7 +1298,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
a NULL pointer if the conversion can't be performed.
-
21.3.7 Structures
+
20.3.7 Structures
@@ -1466,7 +1466,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a
-
21.3.8 C++ classes
+
20.3.8 C++ classes
@@ -1529,7 +1529,7 @@ int bar = Spam.getBar();
-
21.3.9 C++ inheritance
+
20.3.9 C++ inheritance
@@ -1590,7 +1590,7 @@ Note that Java does not support multiple inheritance so any multiple inheritance
A warning is given when multiple inheritance is detected and only the first base class is used.
-
21.3.10 Pointers, references, arrays and pass by value
+
20.3.10 Pointers, references, arrays and pass by value
@@ -1645,7 +1645,7 @@ to hold the result and a pointer is returned (Java will release this memory
when the returned object's finalizer is run by the garbage collector).
-
21.3.10.1 Null pointers
+
20.3.10.1 Null pointers
@@ -1669,7 +1669,7 @@ For spam1 and spam4 above the Java null gets translat
The converse also occurs, that is, NULL pointers are translated into null Java objects when returned from a C/C++ function.
21.4 Further details on the generated Java classes
+
20.4 Further details on the generated Java classes
@@ -2035,7 +2035,7 @@ Finally enum classes are covered.
First, the crucial intermediary JNI class is considered.
-
21.4.1 The intermediary JNI class
+
20.4.1 The intermediary JNI class
@@ -2155,7 +2155,7 @@ If name is the same as modulename then the module class name g
from modulename to modulenameModule.
-
21.4.1.1 The intermediary JNI class pragmas
+
20.4.1.1 The intermediary JNI class pragmas
@@ -2234,7 +2234,7 @@ For example, let's change the intermediary JNI class access to public.
All the methods in the intermediary JNI class will then be callable outside of the package as the method modifiers are public by default.
-
21.4.2 The Java module class
+
20.4.2 The Java module class
@@ -2265,7 +2265,7 @@ example.egg(new Foo());
The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a Foo can be passed to the egg function, whereas any long can be passed to the egg function in the intermediary JNI class.
@@ -3046,7 +3046,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... }
-
21.4.5 Enum classes
+
20.4.5 Enum classes
@@ -3055,7 +3055,7 @@ The Enumerations section discussed these but omitted
The following sub-sections detail the various types of enum classes that can be generated.
-
21.4.5.1 Typesafe enum classes
+
20.4.5.1 Typesafe enum classes
@@ -3139,7 +3139,7 @@ The swigValue method is used for marshalling in the other direction.
The toString method is overridden so that the enum name is available.
-
21.4.5.2 Proper Java enum classes
+
20.4.5.2 Proper Java enum classes
@@ -3217,7 +3217,7 @@ These needn't be generated if the enum being wrapped does not have any initializ
Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this.
-
21.4.5.3 Type unsafe enum classes
+
20.4.5.3 Type unsafe enum classes
@@ -3248,7 +3248,7 @@ public final class Beverage {
-
21.5 Cross language polymorphism using directors
+
20.5 Cross language polymorphism using directors
@@ -3270,7 +3270,7 @@ The upshot is that C++ classes can be extended in Java and from C++ these extens
Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.
-
21.5.1 Enabling directors
+
20.5.1 Enabling directors
@@ -3341,7 +3341,7 @@ public:
-
21.5.2 Director classes
+
20.5.2 Director classes
@@ -3368,7 +3368,7 @@ If the correct implementation is in Java, the Java API is used to call the metho
-
21.5.3 Overhead and code bloat
+
20.5.3 Overhead and code bloat
@@ -3386,7 +3386,7 @@ This situation can be optimized by selectively enabling director methods (using
@@ -3471,7 +3471,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern
-
21.6 Accessing protected members
+
20.6 Accessing protected members
@@ -3567,7 +3567,7 @@ class MyProtectedBase extends ProtectedBase
-
21.7 Common customization features
+
20.7 Common customization features
@@ -3579,7 +3579,7 @@ be awkward. This section describes some common SWIG features that are used
to improve the interface to existing C/C++ code.
-
21.7.1 C/C++ helper functions
+
20.7.1 C/C++ helper functions
@@ -3645,7 +3645,7 @@ hard to implement. It is possible to improve on this using Java code, typemaps,
customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.
-
21.7.2 Class extension with %extend
+
20.7.2 Class extension with %extend
@@ -3708,7 +3708,7 @@ Vector(2,3,4)
in any way---the extensions only show up in the Java interface.
-
21.7.3 Exception handling with %exception and %javaexception
+
20.7.3 Exception handling with %exception and %javaexception
@@ -3901,7 +3901,7 @@ strings and arrays. This chapter discusses the common techniques for
solving these problems.
-
21.8.1 Input and output parameters using primitive pointers and references
+
20.8.1 Input and output parameters using primitive pointers and references
@@ -4075,7 +4075,7 @@ void foo(Bar *OUTPUT);
will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.
-
21.8.2 Simple pointers
+
20.8.2 Simple pointers
@@ -4141,7 +4141,7 @@ System.out.println("3 + 4 = " + result);
See the SWIG Library chapter for further details.
-
21.8.3 Wrapping C arrays with Java arrays
+
20.8.3 Wrapping C arrays with Java arrays
@@ -4208,7 +4208,7 @@ Please be aware that the typemaps in this library are not efficient as all the e
There is an alternative approach using the SWIG array library and this is covered in the next section.
-
21.8.4 Unbounded C Arrays
+
20.8.4 Unbounded C Arrays
@@ -4353,7 +4353,7 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
-
21.8.5 Overriding new and delete to allocate from Java heap
+
20.8.5 Overriding new and delete to allocate from Java heap
@@ -4470,7 +4470,7 @@ model and use these functions in place of malloc and free in your own
code.
-
21.9 Java typemaps
+
20.9 Java typemaps
@@ -4491,7 +4491,7 @@ Before proceeding, it should be stressed that typemaps are not a required
part of using SWIG---the default wrapping behavior is enough in most cases.
Typemaps are only used if you want to change some aspect of the generated code.
-
21.9.1 Default primitive type mappings
+
20.9.1 Default primitive type mappings
@@ -4643,7 +4643,7 @@ However, the mappings allow the full range of values for each C type from Java.
-
21.9.2 Default typemaps for non-primitive types
+
20.9.2 Default typemaps for non-primitive types
@@ -4658,7 +4658,7 @@ So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit
The Java type is either the proxy class or type wrapper class.
-
21.9.3 Sixty four bit JVMs
+
20.9.3 Sixty four bit JVMs
@@ -4671,7 +4671,7 @@ Unfortunately it won't of course hold true for JNI code.
-
21.9.4 What is a typemap?
+
20.9.4 What is a typemap?
@@ -4794,7 +4794,7 @@ int c = example.count('e',"Hello World");
-
21.9.5 Typemaps for mapping C/C++ types to Java types
+
20.9.5 Typemaps for mapping C/C++ types to Java types
@@ -5054,7 +5054,7 @@ These are listed below:
-
21.9.6 Java typemap attributes
+
20.9.6 Java typemap attributes
@@ -5100,7 +5100,7 @@ The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes.
Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action.
-
21.9.7 Java special variables
+
20.9.7 Java special variables
@@ -5243,7 +5243,7 @@ This special variable expands to the intermediary class name. Usually this is th
unless the jniclassname attribute is specified in the %module directive.
-
21.9.8 Typemaps for both C and C++ compilation
+
20.9.8 Typemaps for both C and C++ compilation
@@ -5280,7 +5280,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps
-
21.9.9 Java code typemaps
+
20.9.9 Java code typemaps
@@ -5476,7 +5476,7 @@ For the typemap to be used in all type wrapper classes, all the different types
Again this is the same that is in "java.swg", barring the method modifier for getCPtr.
-
21.9.10 Director specific typemaps
+
20.9.10 Director specific typemaps
@@ -5701,7 +5701,7 @@ The basic strategy here is to provide a default package typemap for the majority
-
21.10 Typemap Examples
+
20.10 Typemap Examples
@@ -5711,7 +5711,7 @@ the SWIG library.
-
21.10.1 Simpler Java enums for enums without initializers
+
20.10.1 Simpler Java enums for enums without initializers
@@ -5790,7 +5790,7 @@ This would be done by using the original versions of these typemaps in "enums.sw
-
21.10.2 Handling C++ exception specifications as Java exceptions
+
20.10.2 Handling C++ exception specifications as Java exceptions
@@ -5915,7 +5915,7 @@ We could alternatively have used %rename to rename what() into
-
21.10.3 NaN Exception - exception handling for a particular type
+
20.10.3 NaN Exception - exception handling for a particular type
@@ -6070,7 +6070,7 @@ If we were a martyr to the JNI cause, we could replace the succinct code within
If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.
-
21.10.4 Converting Java String arrays to char **
+
20.10.4 Converting Java String arrays to char **
@@ -6214,7 +6214,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify
what Java types to use.
-
21.10.5 Expanding a Java object to multiple arguments
+
20.10.5 Expanding a Java object to multiple arguments
21.10.7 Adding Java downcasts to polymorphic return types
+
20.10.7 Adding Java downcasts to polymorphic return types
@@ -6620,7 +6620,7 @@ SWIG usually generates code which constructs the proxy classes using Java code a
Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.
-
21.10.8 Adding an equals method to the Java classes
+
20.10.8 Adding an equals method to the Java classes
21.10.9 Void pointers and a common Java base class
+
20.10.9 Void pointers and a common Java base class
@@ -6723,7 +6723,7 @@ This example contains some useful functionality which you may want in your code.
It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer.
-
21.10.10 Struct pointer to pointer
+
20.10.10 Struct pointer to pointer
@@ -6903,7 +6903,7 @@ The C functional interface has been completely morphed into an object-oriented i
the Butler class would behave much like any pure Java class and feel more natural to Java users.
-
21.10.11 Memory management when returning references to member variables
+
20.10.11 Memory management when returning references to member variables
@@ -7026,7 +7026,7 @@ public class Bike {
Note the addReference call.
-
21.10.12 Memory management for objects passed to the C++ layer
+
20.10.12 Memory management for objects passed to the C++ layer
@@ -7142,7 +7142,7 @@ The 'javacode' typemap simply adds in the specified code into the Java proxy cla
-
21.10.13 Date marshalling using the javain typemap and associated attributes
+
20.10.13 Date marshalling using the javain typemap and associated attributes
@@ -7319,7 +7319,7 @@ A few things to note:
-
21.11 Living with Java Directors
+
20.11 Living with Java Directors
@@ -7500,10 +7500,10 @@ public abstract class UserVisibleFoo extends Foo {
-
21.12 Odds and ends
+
20.12 Odds and ends
-
21.12.1 JavaDoc comments
+
20.12.1 JavaDoc comments
@@ -7559,7 +7559,7 @@ public class Barmy {
-
21.12.2 Functional interface without proxy classes
+
20.12.2 Functional interface without proxy classes
@@ -7620,7 +7620,7 @@ All destructors have to be called manually for example the delete_Foo(foo)
-
21.12.3 Using your own JNI functions
+
20.12.3 Using your own JNI functions
@@ -7670,7 +7670,7 @@ This directive is only really useful if you want to mix your own hand crafted JN
-
21.12.4 Performance concerns and hints
+
20.12.4 Performance concerns and hints
@@ -7691,7 +7691,7 @@ However, you will have to be careful about memory management and make sure that
This method normally calls the C++ destructor or free() for C code.
-
21.12.5 Debugging
+
20.12.5 Debugging
@@ -7713,7 +7713,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh
@@ -77,7 +77,7 @@ swig -cffi -module module-namefile-name
files and the various things which you can do with them.
-
22.2.1 Additional Commandline Options
+
21.2.1 Additional Commandline Options
@@ -118,7 +118,7 @@ swig -cffi -help
-
22.2.2 Generating CFFI bindings
+
21.2.2 Generating CFFI bindings
As we mentioned earlier the ideal way to use SWIG is to use interface
@@ -392,7 +392,7 @@ The feature intern_function ensures that all C names are
-
22.2.3 Generating CFFI bindings for C++ code
+
21.2.3 Generating CFFI bindings for C++ code
This feature to SWIG (for CFFI) is very new and still far from
@@ -568,7 +568,7 @@ If you have any questions, suggestions, patches, etc., related to CFFI
module feel free to contact us on the SWIG mailing list, and
also please add a "[CFFI]" tag in the subject line.
-
22.2.4 Inserting user code into generated files
+
21.2.4 Inserting user code into generated files
@@ -608,7 +608,7 @@ Note that the block %{ ... %} is effectively a shortcut for
-
22.3 CLISP
+
21.3 CLISP
@@ -638,7 +638,7 @@ swig -clisp -module module-namefile-name
interface file for the CLISP module. The CLISP module tries to
produce code which is both human readable and easily modifyable.
-
22.3.1 Additional Commandline Options
+
21.3.1 Additional Commandline Options
@@ -671,7 +671,7 @@ and global variables will be created otherwise only definitions for
-
Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). Its also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org
-
23.1 Preliminaries
+
22.1 Preliminaries
The current SWIG implementation is designed to work with Lua 5.0.x and Lua 5.1.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. ((Currently SWIG generated code has only been tested on Windows with MingW, though given the nature of Lua, is should not have problems on other OS's)). It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms).
-
23.2 Running SWIG
+
22.2 Running SWIG
@@ -90,7 +90,7 @@ This creates a C/C++ source file example_wrap.c or example_wrap.cxx
The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrappered module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module.
@@ -205,7 +205,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib
-
23.2.3 Using your module
+
22.2.3 Using your module
@@ -223,19 +223,19 @@ $ ./my_lua
>
-
23.3 A tour of basic C/C++ wrapping
+
22.3 A tour of basic C/C++ wrapping
By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.
-
23.3.1 Modules
+
22.3.1 Modules
The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.
-
23.3.2 Functions
+
22.3.2 Functions
@@ -273,7 +273,7 @@ It is also possible to rename the module with an assignment.
24
-
23.3.3 Global variables
+
22.3.3 Global variables
@@ -347,7 +347,7 @@ nil
3.142
-
23.3.4 Constants and enums
+
22.3.4 Constants and enums
@@ -370,7 +370,7 @@ example.SUNDAY=0
Constants are not guaranteed to remain constant in Lua. The name of the constant could be accidentally reassigned to refer to some other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.
-
23.3.5 Pointers
+
22.3.5 Pointers
@@ -408,7 +408,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor
nil
-
23.3.6 Structures
+
22.3.6 Structures
@@ -494,7 +494,7 @@ Because the pointer points inside the structure, you can modify the contents and
> x.a = 3 -- Modifies the same structure
-
23.3.7 C++ classes
+
22.3.7 C++ classes
@@ -555,7 +555,7 @@ It is not (currently) possible to access static members of an instance:
-- does NOT work
-
23.3.8 C++ inheritance
+
22.3.8 C++ inheritance
@@ -580,7 +580,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas
It is safe to use multiple inheritance with SWIG.
-
23.3.9 Pointers, references, values, and arrays
+
22.3.9 Pointers, references, values, and arrays
@@ -611,7 +611,7 @@ Foo spam7();
then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.
-
23.3.10 C++ overloaded functions
+
22.3.10 C++ overloaded functions
@@ -697,7 +697,7 @@ Please refer to the "SWIG and C++" chapter for more information about overloadin
Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.
-
23.3.11 C++ operators
+
22.3.11 C++ operators
@@ -809,7 +809,7 @@ It is also possible to overload the operator[], but currently this cann
};
-
23.3.12 Class extension with %extend
+
22.3.12 Class extension with %extend
@@ -864,7 +864,7 @@ true
Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).
-
23.3.13 C++ templates
+
22.3.13 C++ templates
@@ -899,7 +899,7 @@ In Lua:
Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.
-
23.3.14 C++ Smart Pointers
+
22.3.14 C++ Smart Pointers
@@ -951,7 +951,7 @@ If you ever need to access the underlying pointer returned by operator->(
> f = p:__deref__() -- Returns underlying Foo *
-
23.3.15 C++ Exceptions
+
22.3.15 C++ Exceptions
@@ -1098,7 +1098,7 @@ add exception specification to functions or globally (respectively).
-
23.3.16 Writing your own custom wrappers
+
22.3.16 Writing your own custom wrappers
@@ -1117,7 +1117,7 @@ int native_function(lua_State*L) // my native code
The %native directive in the above example, tells SWIG that there is a function int native_function(lua_State*L); which is to be added into the module under the name 'my_func'. SWIG will not add any wrappering for this function, beyond adding it into the function table. How you write your code is entirely up to you.
-
23.3.17 Adding additional Lua code
+
22.3.17 Adding additional Lua code
@@ -1155,7 +1155,7 @@ Good uses for this feature is adding of new code, or writing helper functions to
See Examples/lua/arrays for an example of this code.
-
23.4 Details on the Lua binding
+
22.4 Details on the Lua binding
@@ -1166,7 +1166,7 @@ See Examples/lua/arrays for an example of this code.
-
23.4.1 Binding global data into the module.
+
22.4.1 Binding global data into the module.
@@ -1226,7 +1226,7 @@ end
That way when you call 'a=example.Foo', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code 'example.Foo=10', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.
-
23.4.2 Userdata and Metatables
+
22.4.2 Userdata and Metatables
@@ -1306,7 +1306,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrappered classes/s
Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.
@@ -80,7 +80,7 @@ If you're not familiar with the Objective Caml language, you can visit
The Ocaml Website.
-
26.1 Preliminaries
+
25.1 Preliminaries
@@ -99,7 +99,7 @@ file Examples/Makefile illustrate how to compile and link SWIG modules that
will be loaded dynamically. This has only been tested on Linux so far.
-
26.1.1 Running SWIG
+
25.1.1 Running SWIG
@@ -122,7 +122,7 @@ you will compile the file example_wrap.c with ocamlc or
the resulting .ml and .mli files as well, and do the final link with -custom
(not needed for native link).
-
26.1.2 Compiling the code
+
25.1.2 Compiling the code
@@ -158,7 +158,7 @@ the user more freedom with respect to custom typing.
-
26.1.3 The camlp4 module
+
25.1.3 The camlp4 module
@@ -234,7 +234,7 @@ let b = C_string (getenv "PATH")
-
26.1.4 Using your module
+
25.1.4 Using your module
@@ -248,7 +248,7 @@ When linking any ocaml bytecode with your module, use the -custom
option is not needed when you build native code.
-
26.1.5 Compilation problems and compiling with C++
+
25.1.5 Compilation problems and compiling with C++
@@ -259,7 +259,7 @@ liberal with pointer types may not compile under the C++ compiler.
Most code meant to be compiled as C++ will not have problems.
-
26.2 The low-level Ocaml/C interface
+
25.2 The low-level Ocaml/C interface
@@ -360,7 +360,7 @@ is that you must append them to the return list with swig_result = caml_list_a
signature for a function that uses value in this way.
-
26.2.1 The generated module
+
25.2.1 The generated module
@@ -394,7 +394,7 @@ it describes the output SWIG will generate for class definitions.
-
26.2.2 Enums
+
25.2.2 Enums
@@ -457,7 +457,7 @@ val x : Enum_test.c_obj = C_enum `a
-
26.2.2.1 Enum typing in Ocaml
+
25.2.2.1 Enum typing in Ocaml
@@ -470,10 +470,10 @@ functions imported from different modules. You must convert values to master
values using the swig_val function before sharing them with another module.
-
26.2.3 Arrays
+
25.2.3 Arrays
-
26.2.3.1 Simple types of bounded arrays
+
25.2.3.1 Simple types of bounded arrays
@@ -494,7 +494,7 @@ arrays of simple types with known bounds in your code, but this only works
for arrays whose bounds are completely specified.
-
26.2.3.2 Complex and unbounded arrays
+
25.2.3.2 Complex and unbounded arrays
@@ -507,7 +507,7 @@ SWIG can't predict which of these methods will be used in the array,
so you have to specify it for yourself in the form of a typemap.
-
26.2.3.3 Using an object
+
25.2.3.3 Using an object
@@ -521,7 +521,7 @@ Consider writing an object when the ending condition of your array is complex,
such as using a required sentinel, etc.
-
26.2.3.4 Example typemap for a function taking float * and int
+
25.2.3.4 Example typemap for a function taking float * and int
@@ -572,7 +572,7 @@ void printfloats( float *tab, int len );
-
26.2.4 C++ Classes
+
25.2.4 C++ Classes
@@ -615,7 +615,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the
returned value for the same object.
@@ -770,10 +770,10 @@ Assuming you have a working installation of QT, you will see a window
containing the string "hi" in a button.
-
26.2.5 Director Classes
+
25.2.5 Director Classes
-
26.2.5.1 Director Introduction
+
25.2.5.1 Director Introduction
@@ -800,7 +800,7 @@ class foo {
};
-
26.2.5.2 Overriding Methods in Ocaml
+
25.2.5.2 Overriding Methods in Ocaml
@@ -828,7 +828,7 @@ In this example, I'll examine the objective caml code involved in providing
an overloaded class. This example is contained in Examples/ocaml/shapes.
-
26.2.5.3 Director Usage Example
+
25.2.5.3 Director Usage Example
@@ -887,7 +887,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the
program in C++.
-
26.2.5.4 Creating director objects
+
25.2.5.4 Creating director objects
@@ -928,7 +928,7 @@ object from causing a core dump, as long as the object is destroyed
properly.
-
26.2.5.5 Typemaps for directors, directorin, directorout, directorargout
+
25.2.5.5 Typemaps for directors, directorin, directorout, directorargout
@@ -939,7 +939,7 @@ well as a function return value in the same way you provide function arguments,
and to receive arguments the same way you normally receive function returns.
-
26.2.5.6 directorin typemap
+
25.2.5.6 directorin typemap
@@ -950,7 +950,7 @@ code receives when you are called. In general, a simple directorin typ
can use the same body as a simple out typemap.
-
26.2.5.7 directorout typemap
+
25.2.5.7 directorout typemap
@@ -961,7 +961,7 @@ for the same type, except when there are special requirements for object
ownership, etc.
-
26.2.5.8 directorargout typemap
+
25.2.5.8 directorargout typemap
@@ -978,7 +978,7 @@ In the event that you don't specify all of the necessary values, integral
values will read zero, and struct or object returns have undefined results.
The current SWIG implemention is based on Octave 2.9.12. Support for other versions (in particular the recent 3.0) has not been tested, nor has support for any OS other than Linux.
-
27.2 Running SWIG
+
26.2 Running SWIG
@@ -89,7 +89,7 @@ This creates a C/C++ source file example_wrap.cxx. The generated C++ so
The swig command line has a number of options you can use, like to redirect it's output. Use swig --help to learn about these.
@@ -318,7 +318,7 @@ octave:2> f=example.fopen("not there","r");
error: value on right hand side of assignment is undefined
error: evaluating assignment expression near line 2, column 2
-
27.3.6 Structures and C++ classes
+
26.3.6 Structures and C++ classes
@@ -453,7 +453,7 @@ ans = 1
Depending on the ownership setting of a swig_ref, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.
-
27.3.7 C++ inheritance
+
26.3.7 C++ inheritance
@@ -462,7 +462,7 @@ This information contains the full class hierarchy. When an indexing operation (
the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the swig_ref.
-
27.3.8 C++ overloaded functions
+
26.3.8 C++ overloaded functions
@@ -472,7 +472,7 @@ The dispatch function selects which overload to call (if any) based on the passe
typecheck typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.
-
27.3.9 C++ operators
+
26.3.9 C++ operators
@@ -572,7 +572,7 @@ On the C++ side, the default mappings are as follows:
%rename(__brace) *::operator[];
-
C++ smart pointers are fully supported as in other modules.
-
27.3.13 Directors (calling Octave from C++ code)
+
26.3.13 Directors (calling Octave from C++ code)
@@ -766,14 +766,14 @@ c-side routine called
octave-side routine called
-
27.3.14 Threads
+
26.3.14 Threads
The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.
-
27.3.15 Memory management
+
26.3.15 Memory management
@@ -807,14 +807,14 @@ The %newobject directive may be used to control this behavior for pointers retur
In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/subclass()'ing).
-
27.3.16 STL support
+
26.3.16 STL support
This is some skeleton support for various STL containers.
@@ -87,7 +87,7 @@ later. Earlier versions are problematic and SWIG generated extensions
may not compile or run correctly.
-
28.1 Overview
+
27.1 Overview
@@ -108,7 +108,7 @@ described. Advanced customization features, typemaps, and other
options are found near the end of the chapter.
-
28.2 Preliminaries
+
27.2 Preliminaries
@@ -133,7 +133,7 @@ To build the module, you will need to compile the file
example_wrap.c and link it with the rest of your program.
-
28.2.1 Getting the right header files
+
27.2.1 Getting the right header files
@@ -165,7 +165,7 @@ loaded, an easy way to find out is to run Perl itself.
-
28.2.2 Compiling a dynamic module
+
27.2.2 Compiling a dynamic module
@@ -198,7 +198,7 @@ the target should be named `example.so',
`example.sl', or the appropriate dynamic module name on your system.
-
28.2.3 Building a dynamic module with MakeMaker
+
27.2.3 Building a dynamic module with MakeMaker
@@ -232,7 +232,7 @@ the preferred approach to compilation. More information about MakeMaker can be
found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen,
and Randal Schwartz.
-
28.2.4 Building a static version of Perl
+
27.2.4 Building a static version of Perl
@@ -301,7 +301,7 @@ added to it. Depending on your machine, you may need to link with
additional libraries such as -lsocket, -lnsl, -ldl, etc.
-
28.2.5 Using the module
+
27.2.5 Using the module
@@ -456,7 +456,7 @@ system configuration (this requires root access and you will need to
read the man pages).
-
28.2.6 Compilation problems and compiling with C++
+
27.2.6 Compilation problems and compiling with C++
@@ -599,7 +599,7 @@ have to find the macro that conflicts and add an #undef into the .i file. Pleas
any conflicting macros you find to swig-user mailing list.
-
28.2.7 Compiling for 64-bit platforms
+
27.2.7 Compiling for 64-bit platforms
@@ -626,7 +626,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
-
28.3 Building Perl Extensions under Windows
+
27.3 Building Perl Extensions under Windows
@@ -637,7 +637,7 @@ section assumes you are using SWIG with Microsoft Visual C++
although the procedure may be similar with other compilers.
-
28.3.1 Running SWIG from Developer Studio
+
27.3.1 Running SWIG from Developer Studio
@@ -700,7 +700,7 @@ print "$a\n";
-
28.3.2 Using other compilers
+
27.3.2 Using other compilers
@@ -708,7 +708,7 @@ SWIG is known to work with Cygwin and may work with other compilers on Windows.
For general hints and suggestions refer to the Windows chapter.
-
28.4 The low-level interface
+
27.4 The low-level interface
@@ -718,7 +718,7 @@ can be used to control your application. However, it is also used to
construct more user-friendly proxy classes as described in the next section.
-
28.4.1 Functions
+
27.4.1 Functions
@@ -741,7 +741,7 @@ use example;
$a = &example::fact(2);
-
28.4.2 Global variables
+
27.4.2 Global variables
@@ -811,7 +811,7 @@ extern char *path; // Declared later in the input
-
28.4.3 Constants
+
27.4.3 Constants
@@ -838,7 +838,7 @@ $example::FOO = 2; # Error
-
28.4.4 Pointers
+
27.4.4 Pointers
@@ -947,7 +947,7 @@ as XS and xsubpp. Given the advancement of the SWIG typesystem and the
SWIG and XS, this is no longer supported.
@@ -1146,7 +1146,7 @@ provides direct access to C++ objects. A higher level interface using Perl prox
can be built using these low-level accessors. This is described shortly.
-
28.4.7 C++ classes and type-checking
+
27.4.7 C++ classes and type-checking
@@ -1182,7 +1182,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece
multiple inheritance is used).
-
28.4.8 C++ overloaded functions
+
27.4.8 C++ overloaded functions
@@ -1226,7 +1226,7 @@ example::Spam_foo_d($s,3.14);
Please refer to the "SWIG Basics" chapter for more information.
-
28.4.9 Operators
+
27.4.9 Operators
@@ -1253,7 +1253,7 @@ The following C++ operators are currently supported by the Perl module:
operator or
-
28.4.10 Modules and packages
+
27.4.10 Modules and packages
@@ -1348,7 +1348,7 @@ print Foo::fact(4),"\n"; # Call a function in package FooBar
-->
-
28.5 Input and output parameters
+
27.5 Input and output parameters
@@ -1567,7 +1567,7 @@ print "$c\n";
Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).
-
28.6 Exception handling
+
27.6 Exception handling
@@ -1732,7 +1732,7 @@ This is still supported, but it is deprecated. The newer %exception di
functionality, but it has additional capabilities that make it more powerful.
-
28.7 Remapping datatypes with typemaps
+
27.7 Remapping datatypes with typemaps
@@ -1749,7 +1749,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Perl interface.
@@ -2345,7 +2345,7 @@ the "in" typemap in the previous section would be used to convert an
to copy the converted array into a C data structure.
-
28.8.5 Turning Perl references into C pointers
+
27.8.5 Turning Perl references into C pointers
@@ -2410,7 +2410,7 @@ print "$c\n";
-
28.8.6 Pointer handling
+
27.8.6 Pointer handling
@@ -2489,7 +2489,7 @@ For example:
-
28.9 Proxy classes
+
27.9 Proxy classes
@@ -2505,7 +2505,7 @@ to the underlying code. This section describes the implementation
details of the proxy interface.
-
28.9.1 Preliminaries
+
27.9.1 Preliminaries
@@ -2527,7 +2527,7 @@ SWIG creates a collection of high-level Perl wrappers. In your scripts, you wil
high level wrappers. The wrappers, in turn, interact with the low-level procedural module.
-
28.9.2 Structure and class wrappers
+
27.9.2 Structure and class wrappers
@@ -2653,7 +2653,7 @@ $v->DESTROY();
-
28.9.3 Object Ownership
+
27.9.3 Object Ownership
@@ -2740,7 +2740,7 @@ counting, garbage collection, or advanced features one might find in
sophisticated languages.
@@ -67,7 +67,7 @@ your extension into php directly, you will need the complete PHP source tree
available.
-
29.1 Generating PHP Extensions
+
28.1 Generating PHP Extensions
@@ -114,7 +114,7 @@ this approach, but if you really want to do this, the -phpfull
command line argument to swig may be of use - see below for details.
-
29.1.1 Building a loadable extension
+
28.1.1 Building a loadable extension
@@ -138,7 +138,7 @@ add them to your Makefile or other build system directly. We recommend that
you don't use -make and it's likely to be removed at some point.
-
29.1.2 Building extensions into PHP
+
28.1.2 Building extensions into PHP
@@ -257,7 +257,7 @@ which contains your new module. You can test it with a php script which
does not have the 'dl' command as used above.
-
29.1.3 Using PHP Extensions
+
28.1.3 Using PHP Extensions
@@ -288,7 +288,7 @@ attempts to do the dl() call for you:
include("example.php");
-
29.2 Basic PHP interface
+
28.2 Basic PHP interface
@@ -298,7 +298,7 @@ possible for names of symbols in one extension module to clash with
other symbols unless care is taken to %rename them.
-
29.2.1 Constants
+
28.2.1 Constants
@@ -423,7 +423,7 @@ both point to the same value, without the case test taking place. (
Apologies, this paragraph needs rewriting to make some sense. )
-
29.2.2 Global Variables
+
28.2.2 Global Variables
@@ -472,7 +472,7 @@ undefined.
At this time SWIG does not support custom accessor methods.
-
29.2.3 Functions
+
28.2.3 Functions
@@ -525,7 +525,7 @@ print $s; # The value of $s was not changed.
-->
-
29.2.4 Overloading
+
28.2.4 Overloading
@@ -581,7 +581,7 @@ taking the integer argument.
-->
-
29.2.5 Pointers and References
+
28.2.5 Pointers and References
@@ -713,7 +713,7 @@ PHP in a number of ways: by using unset on an existing
variable, or assigning NULL to a variable.
-
29.2.6 Structures and C++ classes
+
28.2.6 Structures and C++ classes
@@ -783,7 +783,7 @@ Would be used in the following way from either PHP4 or PHP5:
Member variables and methods are accessed using the -> operator.
@@ -125,7 +125,7 @@ very least, make sure you read the "SWIG
Basics" chapter.
-
31.1 Overview
+
30.1 Overview
@@ -152,10 +152,10 @@ described followed by a discussion of low-level implementation
details.
-
31.2 Preliminaries
+
30.2 Preliminaries
-
31.2.1 Running SWIG
+
30.2.1 Running SWIG
@@ -253,7 +253,7 @@ The following sections have further practical examples and details on
how you might go about compiling and using the generated files.
-
31.2.2 Using distutils
+
30.2.2 Using distutils
@@ -345,7 +345,7 @@ This same approach works on all platforms if the appropriate compiler is install
can even build extensions to the standard Windows Python using MingGW)
-
31.2.3 Hand compiling a dynamic module
+
30.2.3 Hand compiling a dynamic module
@@ -393,7 +393,7 @@ module actually consists of two files; socket.py and
-
31.2.4 Static linking
+
30.2.4 Static linking
@@ -472,7 +472,7 @@ If using static linking, you might want to rely on a different approach
(perhaps using distutils).
-
31.2.5 Using your module
+
30.2.5 Using your module
@@ -629,7 +629,7 @@ system configuration (this requires root access and you will need to
read the man pages).
-
31.2.6 Compilation of C++ extensions
+
30.2.6 Compilation of C++ extensions
@@ -728,7 +728,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
-
31.2.7 Compiling for 64-bit platforms
+
30.2.7 Compiling for 64-bit platforms
@@ -765,7 +765,7 @@ and -m64 allow you to choose the desired binary format for your python
extension.
-
31.2.8 Building Python Extensions under Windows
+
30.2.8 Building Python Extensions under Windows
@@ -874,7 +874,7 @@ SWIG Wiki.
-
31.3 A tour of basic C/C++ wrapping
+
30.3 A tour of basic C/C++ wrapping
@@ -883,7 +883,7 @@ to your C/C++ code. Functions are wrapped as functions, classes are wrapped as
This section briefly covers the essential aspects of this wrapping.
-
31.3.1 Modules
+
30.3.1 Modules
@@ -896,7 +896,7 @@ module name, make sure you don't use the same name as a built-in
Python command or standard module name.
-
31.3.2 Functions
+
30.3.2 Functions
@@ -920,7 +920,7 @@ like you think it does:
>>>
-
31.3.3 Global variables
+
30.3.3 Global variables
@@ -1058,7 +1058,7 @@ that starts with a leading underscore. SWIG does not create cvar
if there are no global variables in a module.
-
31.3.4 Constants and enums
+
30.3.4 Constants and enums
@@ -1098,7 +1098,7 @@ other object. Unfortunately, there is no easy way for SWIG to
generate code that prevents this. You will just have to be careful.
-
31.3.5 Pointers
+
30.3.5 Pointers
@@ -1239,7 +1239,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
None if the conversion can't be performed.
-
31.3.6 Structures
+
30.3.6 Structures
@@ -1428,7 +1428,7 @@ everything works just like you would expect. For example:
-
31.3.7 C++ classes
+
30.3.7 C++ classes
@@ -1517,7 +1517,7 @@ they are accessed through cvar like this:
-
31.3.8 C++ inheritance
+
30.3.8 C++ inheritance
@@ -1572,7 +1572,7 @@ then the function spam() accepts Foo * or a pointer to any cla
It is safe to use multiple inheritance with SWIG.
-
31.3.9 Pointers, references, values, and arrays
+
30.3.9 Pointers, references, values, and arrays
@@ -1633,7 +1633,7 @@ treated as a returning value, and it will follow the same
allocation/deallocation process.
-
31.3.10 C++ overloaded functions
+
30.3.10 C++ overloaded functions
@@ -1756,7 +1756,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
-
31.3.11 C++ operators
+
30.3.11 C++ operators
@@ -1845,7 +1845,7 @@ Also, be aware that certain operators don't map cleanly to Python. For instance
overloaded assignment operators don't map to Python semantics and will be ignored.
-
31.3.12 C++ namespaces
+
30.3.12 C++ namespaces
@@ -1912,7 +1912,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
-
31.3.13 C++ templates
+
30.3.13 C++ templates
@@ -1966,7 +1966,7 @@ Some more complicated
examples will appear later.
-
31.3.14 C++ Smart Pointers
+
30.3.14 C++ Smart Pointers
@@ -2051,7 +2051,7 @@ simply use the __deref__() method. For example:
-
31.3.15 C++ Reference Counted Objects (ref/unref)
+
30.3.15 C++ Reference Counted Objects (ref/unref)
@@ -2213,7 +2213,7 @@ python releases the proxy instance.
-
31.4 Further details on the Python class interface
+
30.4 Further details on the Python class interface
@@ -2226,7 +2226,7 @@ of low-level details were omitted. This section provides a brief overview
of how the proxy classes work.
-
31.4.1 Proxy classes
+
30.4.1 Proxy classes
@@ -2315,7 +2315,7 @@ you can attach new Python methods to the class and you can even inherit from it
by Python built-in types until Python 2.2).
-
31.4.2 Memory management
+
30.4.2 Memory management
@@ -2507,7 +2507,7 @@ It is also possible to deal with situations like this using
typemaps--an advanced topic discussed later.
-
31.4.3 Python 2.2 and classic classes
+
30.4.3 Python 2.2 and classic classes
@@ -2544,7 +2544,7 @@ class itself. In Python-2.1 and earlier, they have to be accessed as a global
function or through an instance (see the earlier section).
-
31.5 Cross language polymorphism
+
30.5 Cross language polymorphism
@@ -2578,7 +2578,7 @@ proxy classes, director classes, and C wrapper functions takes care of
all the cross-language method routing transparently.
-
31.5.1 Enabling directors
+
30.5.1 Enabling directors
@@ -2671,7 +2671,7 @@ class MyFoo(mymodule.Foo):
-
31.5.2 Director classes
+
30.5.2 Director classes
@@ -2753,7 +2753,7 @@ so there is no need for the extra overhead involved with routing the
calls through Python.
-
31.5.3 Ownership and object destruction
+
30.5.3 Ownership and object destruction
@@ -2820,7 +2820,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard
references to the Foo objects remain in Python.
-
31.5.4 Exception unrolling
+
30.5.4 Exception unrolling
@@ -2879,7 +2879,7 @@ Swig::DirectorMethodException is thrown, Python will register the
exception as soon as the C wrapper function returns.
-
31.5.5 Overhead and code bloat
+
30.5.5 Overhead and code bloat
@@ -2913,7 +2913,7 @@ directive) for only those methods that are likely to be extended in
Python.
-
31.5.6 Typemaps
+
30.5.6 Typemaps
@@ -2927,7 +2927,7 @@ need to be supported.
-
31.5.7 Miscellaneous
+
30.5.7 Miscellaneous
@@ -2974,7 +2974,7 @@ methods that return const references.
-
31.6 Common customization features
+
30.6 Common customization features
@@ -2987,7 +2987,7 @@ This section describes some common SWIG features that are used to
improve your the interface to an extension module.
-
31.6.1 C/C++ helper functions
+
30.6.1 C/C++ helper functions
@@ -3068,7 +3068,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps,
customization features as covered in later sections.
-
31.6.2 Adding additional Python code
+
30.6.2 Adding additional Python code
@@ -3217,7 +3217,7 @@ public:
-
31.6.3 Class extension with %extend
+
30.6.3 Class extension with %extend
@@ -3306,7 +3306,7 @@ Vector(12,14,16)
in any way---the extensions only show up in the Python interface.
-
31.6.4 Exception handling with %exception
+
30.6.4 Exception handling with %exception
@@ -3432,7 +3432,7 @@ The language-independent exception.i library file can also be used
to raise exceptions. See the SWIG Library chapter.
-
31.7 Tips and techniques
+
30.7 Tips and techniques
@@ -3442,7 +3442,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques
solving these problems.
-
31.7.1 Input and output parameters
+
30.7.1 Input and output parameters
@@ -3655,7 +3655,7 @@ void foo(Bar *OUTPUT);
may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.
-
31.7.2 Simple pointers
+
30.7.2 Simple pointers
@@ -3724,7 +3724,7 @@ If you replace %pointer_functions() by %pointer_class(type,name)SWIG Library chapter for further details.
-
31.7.3 Unbounded C Arrays
+
30.7.3 Unbounded C Arrays
@@ -3786,7 +3786,7 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
-
31.7.4 String handling
+
30.7.4 String handling
@@ -3855,16 +3855,16 @@ If you need to return binary data, you might use the
also be used to extra binary data from arbitrary pointers.
-
31.7.5 Arrays
+
30.7.5 Arrays
-
31.7.6 String arrays
+
30.7.6 String arrays
-
31.7.7 STL wrappers
+
30.7.7 STL wrappers
-
31.8 Typemaps
+
30.8 Typemaps
@@ -3881,7 +3881,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Python interface or if you want to elevate your guru status.
-
31.8.1 What is a typemap?
+
30.8.1 What is a typemap?
@@ -3997,7 +3997,7 @@ parameter is omitted):
-
31.8.2 Python typemaps
+
30.8.2 Python typemaps
@@ -4038,7 +4038,7 @@ a look at the SWIG library version 1.3.20 or so.
-
31.8.3 Typemap variables
+
30.8.3 Typemap variables
@@ -4109,7 +4109,7 @@ properly assigned.
The Python name of the wrapper function being created.
-
31.8.4 Useful Python Functions
+
30.8.4 Useful Python Functions
@@ -4237,7 +4237,7 @@ write me
-
31.9 Typemap Examples
+
30.9 Typemap Examples
@@ -4246,7 +4246,7 @@ might look at the files "python.swg" and "typemaps.i" in
the SWIG library.
-
31.9.1 Converting Python list to a char **
+
30.9.1 Converting Python list to a char **
@@ -4326,7 +4326,7 @@ memory allocation is used to allocate memory for the array, the
the C function.
-
31.9.2 Expanding a Python object into multiple arguments
+
30.9.2 Expanding a Python object into multiple arguments
@@ -4405,7 +4405,7 @@ to supply the argument count. This is automatically set by the typemap code. F
-
31.9.3 Using typemaps to return arguments
+
30.9.3 Using typemaps to return arguments
@@ -4494,7 +4494,7 @@ function can now be used as follows:
>>>
-
31.9.4 Mapping Python tuples into small arrays
+
30.9.4 Mapping Python tuples into small arrays
@@ -4543,7 +4543,7 @@ array, such an approach would not be recommended for huge arrays, but
for small structures, this approach works fine.
-
31.9.5 Mapping sequences to C arrays
+
30.9.5 Mapping sequences to C arrays
@@ -4632,7 +4632,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) {
-
31.9.6 Pointer handling
+
30.9.6 Pointer handling
@@ -4729,7 +4729,7 @@ class object (if applicable).
-
31.10 Docstring Features
+
30.10 Docstring Features
@@ -4757,7 +4757,7 @@ of your users much simpler.
-
31.10.1 Module docstring
+
30.10.1 Module docstring
@@ -4791,7 +4791,7 @@ layout of controls on a panel, etc. to be loaded from an XML file."
-
31.10.2 %feature("autodoc")
+
30.10.2 %feature("autodoc")
@@ -4818,7 +4818,7 @@ names, default values if any, and return type if any. There are also
three options for autodoc controlled by the value given to the
feature, described below.
-
@@ -33,7 +33,7 @@ compile and run an R interface to QuantLib running on Mandriva Linux
with gcc. The R bindings also work on Microsoft Windows using Visual C++.
-
34.1 Bugs
+
33.1 Bugs
@@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:
C Array wrappings
-
34.2 Using R and SWIG
+
33.2 Using R and SWIG
@@ -99,7 +99,7 @@ Without it, inheritance of wrapped objects may fail.
These two files can be loaded in any order
-
34.3 Precompiling large R files
+
33.3 Precompiling large R files
In cases where the R file is large, one make save a lot of loading
@@ -117,7 +117,7 @@ will save a large amount of loading time.
-
34.4 General policy
+
33.4 General policy
@@ -126,7 +126,7 @@ wrapping over the underlying functions and rely on the R type system
to provide R syntax.
-
34.5 Language conventions
+
33.5 Language conventions
@@ -135,7 +135,7 @@ and [ are overloaded to allow for R syntax (one based indices and
slices)
-
34.6 C++ classes
+
33.6 C++ classes
@@ -147,7 +147,7 @@ keep track of the pointer object which removes the necessity for a lot
of the proxy class baggage you see in other languages.
SWIG 1.3 is known to work with Ruby versions 1.6 and later.
@@ -190,7 +190,7 @@ of Ruby.
-
32.1.1 Running SWIG
+
31.1.1 Running SWIG
To build a Ruby module, run SWIG using the -ruby
@@ -244,7 +244,7 @@ to compile this file and link it with the rest of your program.
-
32.1.2 Getting the right header files
+
31.1.2 Getting the right header files
In order to compile the wrapper code, the compiler needs the ruby.h
@@ -288,7 +288,7 @@ installed, you can run Ruby to find out. For example:
-
32.1.3 Compiling a dynamic module
+
31.1.3 Compiling a dynamic module
Ruby extension modules are typically compiled into shared
@@ -443,7 +443,7 @@ manual pages for your compiler and linker to determine the correct set
of options. You might also check the SWIG Wiki
for additional information.
-
32.1.4 Using your module
+
31.1.4 Using your module
Ruby module names must be capitalized,
@@ -498,7 +498,7 @@ begins with:
-
32.1.5 Static linking
+
31.1.5 Static linking
An alternative approach to dynamic linking is to rebuild the
@@ -519,7 +519,7 @@ finally rebuilding Ruby.
-
32.1.6 Compilation of C++ extensions
+
31.1.6 Compilation of C++ extensions
On most machines, C++ extension modules should be linked
@@ -571,7 +571,7 @@ extension, e.g.
-
32.2 Building Ruby Extensions under Windows 95/NT
+
31.2 Building Ruby Extensions under Windows 95/NT
Building a SWIG extension to Ruby under Windows 95/NT is
@@ -610,7 +610,7 @@ files.
-
32.2.1 Running SWIG from Developer Studio
+
31.2.1 Running SWIG from Developer Studio
If you are developing your application within Microsoft
@@ -752,7 +752,7 @@ directory, then run the Ruby script from the DOS/Command prompt:
-
32.3 The Ruby-to-C/C++ Mapping
+
31.3 The Ruby-to-C/C++ Mapping
This section describes the basics of how SWIG maps C or C++
@@ -762,7 +762,7 @@ declarations in your SWIG interface files to Ruby constructs.
There are three ways to raise exceptions from C++ code to
@@ -4621,7 +4621,7 @@ the built-in Ruby exception types.
-
32.6.4 Exception classes
+
31.6.4 Exception classes
Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass
@@ -4679,7 +4679,7 @@ providing for a more natural integration between C++ code and Ruby code.
-
32.7 Typemaps
+
31.7 Typemaps
This section describes how you can modify SWIG's default
@@ -4702,7 +4702,7 @@ of the primitive C-Ruby interface.
-
32.7.1 What is a typemap?
+
31.7.1 What is a typemap?
A typemap is nothing more than a code generation rule that is
@@ -4964,7 +4964,7 @@ to be used as follows (notice how the length parameter is omitted):
-
32.7.2 Typemap scope
+
31.7.2 Typemap scope
Once defined, a typemap remains in effect for all of the
@@ -5012,7 +5012,7 @@ where the class itself is defined. For example:
-
32.7.3 Copying a typemap
+
31.7.3 Copying a typemap
A typemap is copied by using assignment. For example:
@@ -5114,7 +5114,7 @@ rules as for
-
32.7.4 Deleting a typemap
+
31.7.4 Deleting a typemap
A typemap can be deleted by simply defining no code. For
@@ -5166,7 +5166,7 @@ typemaps immediately after the clear operation.
-
32.7.5 Placement of typemaps
+
31.7.5 Placement of typemaps
Typemap declarations can be declared in the global scope,
@@ -5250,7 +5250,7 @@ string
-
32.7.6 Ruby typemaps
+
31.7.6 Ruby typemaps
The following list details all of the typemap methods that
@@ -5260,7 +5260,7 @@ can be used by the Ruby module:
-
32.7.6.1 "in" typemap
+
31.7.6.1 "in" typemap
Converts Ruby objects to input
@@ -5503,7 +5503,7 @@ arguments to be specified. For example:
-
32.7.6.2 "typecheck" typemap
+
31.7.6.2 "typecheck" typemap
The "typecheck" typemap is used to support overloaded
@@ -5544,7 +5544,7 @@ on "Typemaps and Overloading."
-
32.7.6.3 "out" typemap
+
31.7.6.3 "out" typemap
Converts return value of a C function
@@ -5776,7 +5776,7 @@ version of the C datatype matched by the typemap.
-
32.7.6.4 "arginit" typemap
+
31.7.6.4 "arginit" typemap
The "arginit" typemap is used to set the initial value of a
@@ -5801,7 +5801,7 @@ applications. For example:
-
32.7.6.5 "default" typemap
+
31.7.6.5 "default" typemap
The "default" typemap is used to turn an argument into a
@@ -5843,7 +5843,7 @@ default argument wrapping.
-
32.7.6.6 "check" typemap
+
31.7.6.6 "check" typemap
The "check" typemap is used to supply value checking code
@@ -5867,7 +5867,7 @@ arguments have been converted. For example:
-
32.7.6.7 "argout" typemap
+
31.7.6.7 "argout" typemap
The "argout" typemap is used to return values from arguments.
@@ -6025,7 +6025,7 @@ some function like SWIG_Ruby_AppendOutput.
-
32.7.6.8 "freearg" typemap
+
31.7.6.8 "freearg" typemap
The "freearg" typemap is used to cleanup argument data. It is
@@ -6061,7 +6061,7 @@ abort prematurely.
-
32.7.6.9 "newfree" typemap
+
31.7.6.9 "newfree" typemap
The "newfree" typemap is used in conjunction with the %newobject
@@ -6092,7 +6092,7 @@ ownership and %newobject for further details.
-
32.7.6.10 "memberin" typemap
+
31.7.6.10 "memberin" typemap
The "memberin" typemap is used to copy data from an
@@ -6125,7 +6125,7 @@ other objects.
-
32.7.6.11 "varin" typemap
+
31.7.6.11 "varin" typemap
The "varin" typemap is used to convert objects in the target
@@ -6136,7 +6136,7 @@ This is implementation specific.
-
32.7.6.12 "varout" typemap
+
31.7.6.12 "varout" typemap
The "varout" typemap is used to convert a C/C++ object to an
@@ -6147,7 +6147,7 @@ This is implementation specific.
-
32.7.6.13 "throws" typemap
+
31.7.6.13 "throws" typemap
The "throws" typemap is only used when SWIG parses a C++
@@ -6206,7 +6206,7 @@ handling with %exception section.
-
32.7.6.14 directorin typemap
+
31.7.6.14 directorin typemap
Converts C++ objects in director
@@ -6460,7 +6460,7 @@ referring to the class itself.
-
32.7.6.15 directorout typemap
+
31.7.6.15 directorout typemap
Converts Ruby objects in director
@@ -6720,7 +6720,7 @@ exception.
-
32.7.6.16 directorargout typemap
+
31.7.6.16 directorargout typemap
Output argument processing in director
@@ -6960,7 +6960,7 @@ referring to the instance of the class itself
-
32.7.6.17 ret typemap
+
31.7.6.17 ret typemap
Cleanup of function return values
@@ -6970,7 +6970,7 @@ referring to the instance of the class itself
-
32.7.6.18 globalin typemap
+
31.7.6.18 globalin typemap
Setting of C global variables
@@ -6980,7 +6980,7 @@ referring to the instance of the class itself
-
32.7.7 Typemap variables
+
31.7.7 Typemap variables
@@ -7090,7 +7090,7 @@ being created.
-
32.7.8 Useful Functions
+
31.7.8 Useful Functions
When you write a typemap, you usually have to work directly
@@ -7114,7 +7114,7 @@ across multiple languages.
-
32.7.8.1 C Datatypes to Ruby Objects
+
31.7.8.1 C Datatypes to Ruby Objects
@@ -7170,7 +7170,7 @@ SWIG_From_float(float)
-
32.7.8.2 Ruby Objects to C Datatypes
+
31.7.8.2 Ruby Objects to C Datatypes
Here, while the Ruby versions return the value directly, the SWIG
@@ -7259,7 +7259,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input
-
The Ruby language doesn't support multiple inheritance, but
@@ -9802,7 +9802,7 @@ Features") for more details).
-
32.10 Memory Management
+
31.10 Memory Management
One of the most common issues in generating SWIG bindings for
@@ -9849,7 +9849,7 @@ understanding of how the underlying library manages memory.
-
32.10.1 Mark and Sweep Garbage Collector
+
31.10.1 Mark and Sweep Garbage Collector
Ruby uses a mark and sweep garbage collector. When the garbage
@@ -9897,7 +9897,7 @@ this memory.
-
32.10.2 Object Ownership
+
31.10.2 Object Ownership
As described above, memory management depends on clearly
@@ -10124,7 +10124,7 @@ classes is:
-
32.10.3 Object Tracking
+
31.10.3 Object Tracking
The remaining parts of this section will use the class library
@@ -10338,7 +10338,7 @@ methods.
-
32.10.4 Mark Functions
+
31.10.4 Mark Functions
With a bit more testing, we see that our class library still
@@ -10456,7 +10456,7 @@ test suite.
-
32.10.5 Free Functions
+
31.10.5 Free Functions
By default, SWIG creates a "free" function that is called when
@@ -10611,7 +10611,7 @@ been freed, and thus raises a runtime exception.
-
32.10.6 Embedded Ruby and the C++ Stack
+
31.10.6 Embedded Ruby and the C++ Stack
As has been said, the Ruby GC runs and marks objects before
diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html
index b36395cab..e837a5b17 100644
--- a/Doc/Manual/Tcl.html
+++ b/Doc/Manual/Tcl.html
@@ -6,7 +6,7 @@
-
33 SWIG and Tcl
+
32 SWIG and Tcl
@@ -82,7 +82,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but
this is no longer supported.
-
33.1 Preliminaries
+
32.1 Preliminaries
@@ -108,7 +108,7 @@ build a Tcl extension module. To finish building the module, you
need to compile this file and link it with the rest of your program.
-
33.1.1 Getting the right header files
+
32.1.1 Getting the right header files
@@ -126,7 +126,7 @@ this is the case, you should probably make a symbolic link so that tcl.h
-
33.1.2 Compiling a dynamic module
+
32.1.2 Compiling a dynamic module
@@ -161,7 +161,7 @@ The name of the module is specified using the %module directive or the
-module command line option.
-
33.1.3 Static linking
+
32.1.3 Static linking
@@ -227,7 +227,7 @@ minimal in most situations (and quite frankly not worth the extra
hassle in the opinion of this author).
-
33.1.4 Using your module
+
32.1.4 Using your module
@@ -355,7 +355,7 @@ to the default system configuration (this requires root access and you will need
the man pages).
-
33.1.5 Compilation of C++ extensions
+
32.1.5 Compilation of C++ extensions
@@ -438,7 +438,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
-
33.1.6 Compiling for 64-bit platforms
+
32.1.6 Compiling for 64-bit platforms
@@ -465,7 +465,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
-
33.1.7 Setting a package prefix
+
32.1.7 Setting a package prefix
@@ -484,7 +484,7 @@ option will append the prefix to the name when creating a command and
call it "Foo_bar".
-
33.1.8 Using namespaces
+
32.1.8 Using namespaces
@@ -506,7 +506,7 @@ When the -namespace option is used, objects in the module
are always accessed with the namespace name such as Foo::bar.
-
33.2 Building Tcl/Tk Extensions under Windows 95/NT
+
32.2 Building Tcl/Tk Extensions under Windows 95/NT
@@ -517,7 +517,7 @@ covers the process of using SWIG with Microsoft Visual C++.
although the procedure may be similar with other compilers.
-
33.2.1 Running SWIG from Developer Studio
+
32.2.1 Running SWIG from Developer Studio
@@ -575,7 +575,7 @@ MSDOS > tclsh80
%
-
33.2.2 Using NMAKE
+
32.2.2 Using NMAKE
@@ -638,7 +638,7 @@ to get you started. With a little practice, you'll be making lots of
Tcl extensions.
-
33.3 A tour of basic C/C++ wrapping
+
32.3 A tour of basic C/C++ wrapping
@@ -649,7 +649,7 @@ classes. This section briefly covers the essential aspects of this
wrapping.
-
33.3.1 Modules
+
32.3.1 Modules
@@ -683,7 +683,7 @@ To fix this, supply an extra argument to load like this:
-
@@ -872,7 +872,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l
conversion. This allows the global statement to be omitted.
-
33.3.5 Pointers
+
32.3.5 Pointers
@@ -968,7 +968,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
None if the conversion can't be performed.
-
33.3.6 Structures
+
32.3.6 Structures
@@ -1250,7 +1250,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the
memory management section that appears shortly.
-
33.3.7 C++ classes
+
32.3.7 C++ classes
@@ -1317,7 +1317,7 @@ In Tcl, the static member is accessed as follows:
-
33.3.8 C++ inheritance
+
32.3.8 C++ inheritance
@@ -1366,7 +1366,7 @@ For instance:
It is safe to use multiple inheritance with SWIG.
-
33.3.9 Pointers, references, values, and arrays
+
32.3.9 Pointers, references, values, and arrays
@@ -1420,7 +1420,7 @@ to hold the result and a pointer is returned (Tcl will release this memory
when the return value is garbage collected).
-
33.3.10 C++ overloaded functions
+
32.3.10 C++ overloaded functions
@@ -1543,7 +1543,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
-
33.3.11 C++ operators
+
32.3.11 C++ operators
@@ -1645,7 +1645,7 @@ There are ways to make this operator appear as part of the class using the %
Keep reading.
-
33.3.12 C++ namespaces
+
32.3.12 C++ namespaces
@@ -1709,7 +1709,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
@@ -2433,7 +2433,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex
See the chapter on "Customization Features" for more examples.
-
33.7 Typemaps
+
32.7 Typemaps
@@ -2450,7 +2450,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Tcl interface.
-
33.7.1 What is a typemap?
+
32.7.1 What is a typemap?
@@ -2567,7 +2567,7 @@ parameter is omitted):
-
33.7.2 Tcl typemaps
+
32.7.2 Tcl typemaps
@@ -2705,7 +2705,7 @@ Initialize an argument to a value before any conversions occur.
Examples of these methods will appear shortly.
-
33.7.3 Typemap variables
+
32.7.3 Typemap variables
@@ -2776,7 +2776,7 @@ properly assigned.
The Tcl name of the wrapper function being created.
-
33.7.4 Converting a Tcl list to a char **
+
32.7.4 Converting a Tcl list to a char **
@@ -2838,7 +2838,7 @@ argv[2] = Larry
3
-
33.7.5 Returning values in arguments
+
32.7.5 Returning values in arguments
@@ -2880,7 +2880,7 @@ result, a Tcl function using these typemaps will work like this :
%
-
33.7.6 Useful functions
+
32.7.6 Useful functions
@@ -2957,7 +2957,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
-
33.7.7 Standard typemaps
+
32.7.7 Standard typemaps
@@ -3041,7 +3041,7 @@ work)
-
33.7.8 Pointer handling
+
32.7.8 Pointer handling
@@ -3117,7 +3117,7 @@ For example:
-
33.8 Turning a SWIG module into a Tcl Package.
+
32.8 Turning a SWIG module into a Tcl Package.
@@ -3189,7 +3189,7 @@ As a final note, most SWIG examples do not yet use the
to use the load command instead.
-
33.9 Building new kinds of Tcl interfaces (in Tcl)
+
32.9 Building new kinds of Tcl interfaces (in Tcl)
@@ -3288,7 +3288,7 @@ danger of blowing something up (although it is easily accomplished
with an out of bounds array access).
-
33.9.1 Proxy classes
+
32.9.1 Proxy classes
From d0ae20ec39f9b5f59aa9b1dfa5ff9cd7d1f1a5e3 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 8 Sep 2008 20:09:41 +0000
Subject: [PATCH 046/508] set the references right
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10824 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/C.html | 50 +++++++++++++++++++++++------------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/Doc/Manual/C.html b/Doc/Manual/C.html
index 80146298f..85ea10aea 100644
--- a/Doc/Manual/C.html
+++ b/Doc/Manual/C.html
@@ -9,24 +9,24 @@
@@ -42,7 +42,7 @@ This chapter describes SWIG's support for creating ANSI C wrappers. This module
-
36.1 Overview
+
36.1 Overview
@@ -60,10 +60,10 @@ With wrapper interfaces generated by SWIG, it is easy to use the functionality o
Flattening C++ language constructs into a set of C-style functions obviously comes with many limitations and inconveniences. All data and functions become global. Manipulating objects requires explicit calls to special functions. We are losing the high level abstraction and have to work around it.
-
36.2 Preliminaries
+
36.2 Preliminaries
-
36.2.1 Running SWIG
+
36.2.1 Running SWIG
@@ -108,7 +108,7 @@ This will generate an example_wrap.c file or, in the latter case, e
The wrap file contains the wrapper functions, which perform the main functionality of SWIG: it translates the input arguments from C to C++, makes calls to the original functions and marshalls C++ output back to C data. The proxy header file contains the interface we can use in C application code. The additional .c file contains calls to the wrapper functions, allowing us to preserve names of the original functions.
-
36.2.2 Command line options
+
36.2.2 Command line options
@@ -131,12 +131,12 @@ swig -c -help
-noexcept
-
generate wrappers with no support of exception handling; see Exceptions chapter for more details
+
generate wrappers with no support of exception handling; see Exceptions chapter for more details
-
36.2.3 Compiling a dynamic module
+
36.2.3 Compiling a dynamic module
@@ -163,7 +163,7 @@ $ g++ -shared example_wrap.o -o libexample.so
Now the shared library module is ready to use. Note that the name of the generated module is important: is should be prefixed with lib on Unix, and have the specific extension, like .dll for Windows or .so for Unix systems.
-
36.2.4 Using the generated module
+
36.2.4 Using the generated module
@@ -178,14 +178,14 @@ $ gcc runme.c example_proxy.c -L. -lexample -o runme
This will compile the application code (runme.c), along with the proxy code and link it against the generated shared module. Following the -L option is the path to the directory containing the shared module. The output executable is ready to use. The last thing to do is to supply to the operating system the information of location of our module. This is system dependant, for instance Unix systems look for shared modules in certain directories, like /usr/lib, and additionally we can set the environment variable LD_LIBRARY_PATH (Unix) or PATH (Windows) for other directories.
-
36.3 Basic C wrapping
+
36.3 Basic C wrapping
Wrapping C functions and variables is obviously performed in a straightforward way. There is no need to perform type conversions, and all language constructs can be preserved in their original form. However, SWIG allows you to enchance the code with some additional elements, for instance using check typemap or %extend directive.
-
36.3.1 Functions
+
36.3.1 Functions
@@ -259,7 +259,7 @@ int _wrap_gcd(int arg1, int arg2) {
This time calling gcd with negative value argument will trigger an error message. This can save you time writing all the constraint checking code by hand.
The main reason of having the C module in SWIG is to be able to access C++ from C. In this chapter we will take a look at the rules of wrapping elements of the C++ language.
NOTE! This release changes the hash input slighly, so you will
+ probably find that you will not get any hits against your existing
+@@ -87,7 +87,7 @@
+
+
+
+ For the bleeding edge, you can fetch ccache via CVS or
+ rsync. To fetch via cvs use the following command:
diff --git a/CCache/debian/patches/14_hardlink_doc.diff b/CCache/debian/patches/14_hardlink_doc.diff
new file mode 100644
index 000000000..bd9e25ba6
--- /dev/null
+++ b/CCache/debian/patches/14_hardlink_doc.diff
@@ -0,0 +1,48 @@
+Index: ccache.1
+===================================================================
+RCS file: /cvsroot/ccache/ccache.1,v
+retrieving revision 1.26
+diff -u -r1.26 ccache.1
+--- ccache.1 24 Nov 2005 21:10:08 -0000 1.26
++++ ccache.1 21 Jul 2007 21:03:32 -0000
+@@ -330,7 +330,7 @@
+ .IP o
+ Use the same \fBCCACHE_DIR\fP environment variable setting
+ .IP o
+-Set the \fBCCACHE_NOLINK\fP environment variable
++Unset the \fBCCACHE_HARDLINK\fP environment variable
+ .IP o
+ Make sure everyone sets the CCACHE_UMASK environment variable
+ to 002, this ensures that cached files are accessible to everyone in
+Index: ccache.yo
+===================================================================
+RCS file: /cvsroot/ccache/ccache.yo,v
+retrieving revision 1.27
+diff -u -r1.27 ccache.yo
+--- ccache.yo 24 Nov 2005 21:54:09 -0000 1.27
++++ ccache.yo 21 Jul 2007 21:03:32 -0000
+@@ -289,7 +289,7 @@
+
+ itemize(
+ it() Use the same bf(CCACHE_DIR) environment variable setting
+- it() Set the bf(CCACHE_NOLINK) environment variable
++ it() Unset the bf(CCACHE_HARDLINK) environment variable
+ it() Make sure everyone sets the CCACHE_UMASK environment variable
+ to 002, this ensures that cached files are accessible to everyone in
+ the group.
+Index: web/ccache-man.html
+===================================================================
+RCS file: /cvsroot/ccache/web/ccache-man.html,v
+retrieving revision 1.25
+diff -u -r1.25 ccache-man.html
+--- web/ccache-man.html 13 Sep 2004 10:38:17 -0000 1.25
++++ web/ccache-man.html 21 Jul 2007 21:03:32 -0000
+@@ -256,7 +256,7 @@
+ following conditions need to be met:
+
+
Use the same CCACHE_DIR environment variable setting
+-
Set the CCACHE_NOLINK environment variable
++
Unset the CCACHE_HARDLINK environment variable
+
Make sure everyone sets the CCACHE_UMASK environment variable
+ to 002, this ensures that cached files are accessible to everyone in
+ the group.
diff --git a/CCache/debian/patches/CREDITS b/CCache/debian/patches/CREDITS
new file mode 100644
index 000000000..c4e323b7b
--- /dev/null
+++ b/CCache/debian/patches/CREDITS
@@ -0,0 +1,47 @@
+01_no_home.diff:
+ Francois Marier
+ Made especially for the Debian package.
+
+02_ccache_compressed.diff:
+ Lars Gustäbel
+ http://www.gustaebel.de/lars/ccache/ (downloaded on 2007-05-20)
+
+03_long_options.diff:
+ Francois Marier
+ Made especially for the Debian package.
+
+04_ignore_profile.diff:
+ Ted Percival
+ http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=20;filename=ccache-profile.patch;att=1;bug=215849
+
+05_nfs_fix.diff:
+ John Coiner
+ http://lists.samba.org/archive/ccache/2007q1/000265.html
+
+06_md.diff:
+ Andrea Bittau
+ http://darkircop.org/ccache/ccache-2.4-md.patch (downloaded on 2007-06-30)
+
+07_cachedirtag.diff:
+ Karl Chen
+ http://lists.samba.org/archive/ccache/2008q1/000316.html (downloaded on 2008-02-02)
+
+08_manpage_hyphens.diff:
+ Francois Marier
+ Made especially for the Debian package.
+
+09_respect_ldflags.diff:
+ Lisa Seelye
+ http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-util/ccache/files/ccache-2.4-respectflags.patch?rev=1.1&view=markup
+
+10_lru_cleanup.diff:
+ RW
+ http://lists.samba.org/archive/ccache/2008q2/000339.html (downloaded on 2008-04-11)
+
+11_utimes.diff:
+ Robin H. Johnson
+ http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-util/ccache/files/ccache-2.4-utimes.patch?rev=1.1&view=markup
+
+12_cachesize_permissions.diff:
+ Francois Marier
+ Made especially for the Debian package to fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=332527
diff --git a/CCache/debian/rules b/CCache/debian/rules
new file mode 100644
index 000000000..c5b538b78
--- /dev/null
+++ b/CCache/debian/rules
@@ -0,0 +1,141 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
+ confflags += --build $(DEB_HOST_GNU_TYPE)
+else
+ confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
+endif
+
+ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -g
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+ INSTALL_PROGRAM += -s
+endif
+
+config.status: configure
+ dh_testdir
+
+ # Apply Debian specific patches
+ cp $(CURDIR)/ccache.c $(CURDIR)/ccache.c.unpatched
+ cp $(CURDIR)/util.c $(CURDIR)/util.c.unpatched
+ cp $(CURDIR)/ccache.1 $(CURDIR)/ccache.1.unpatched
+ cp $(CURDIR)/ccache.h $(CURDIR)/ccache.h.unpatched
+ cp $(CURDIR)/ccache.yo $(CURDIR)/ccache.yo.unpatched
+ cp $(CURDIR)/config.h.in $(CURDIR)/config.h.in.unpatched
+ cp $(CURDIR)/configure $(CURDIR)/configure.unpatched
+ cp $(CURDIR)/configure.in $(CURDIR)/configure.in.unpatched
+ cp $(CURDIR)/Makefile.in $(CURDIR)/Makefile.in.unpatched
+ if test ! -f patch-stamp; then \
+ for patch in $(CURDIR)/debian/patches/*.diff ;\
+ do \
+ echo APPLYING PATCH\: $${patch##*/};\
+ patch -p0 < $$patch ;\
+ done ;\
+ touch patch-stamp ;\
+ fi
+ chmod +x $(CURDIR)/manage-cache.sh
+
+ ./configure $(confflags) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info
+
+build: build-stamp
+
+build-stamp: config.status
+ dh_testdir
+
+ $(MAKE)
+
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+
+ # Unapply patches
+ -test -r $(CURDIR)/ccache.c.unpatched && mv $(CURDIR)/ccache.c.unpatched $(CURDIR)/ccache.c
+ -test -r $(CURDIR)/util.c.unpatched && mv $(CURDIR)/util.c.unpatched $(CURDIR)/util.c
+ -test -r $(CURDIR)/ccache.1.unpatched && mv $(CURDIR)/ccache.1.unpatched $(CURDIR)/ccache.1
+ -test -r $(CURDIR)/ccache.h.unpatched && mv $(CURDIR)/ccache.h.unpatched $(CURDIR)/ccache.h
+ -test -r $(CURDIR)/ccache.yo.unpatched && mv $(CURDIR)/ccache.yo.unpatched $(CURDIR)/ccache.yo
+ -test -r $(CURDIR)/config.h.in.unpatched && mv $(CURDIR)/config.h.in.unpatched $(CURDIR)/config.h.in
+ -test -r $(CURDIR)/configure.unpatched && mv $(CURDIR)/configure.unpatched $(CURDIR)/configure
+ -test -r $(CURDIR)/configure.in.unpatched && mv $(CURDIR)/configure.in.unpatched $(CURDIR)/configure.in
+ -test -r $(CURDIR)/Makefile.in.unpatched && mv $(CURDIR)/Makefile.in.unpatched $(CURDIR)/Makefile.in
+ -rm -f $(CURDIR)/manage-cache.sh
+ -rm -f patch-stamp
+
+ [ ! -f Makefile ] || $(MAKE) distclean
+
+ dh_clean
+
+ # Update config.sub and config.guess
+ -test -r /usr/share/misc/config.sub && \
+ cp -f /usr/share/misc/config.sub config.sub
+ -test -r /usr/share/misc/config.guess && \
+ cp -f /usr/share/misc/config.guess config.guess
+
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/ccache.
+ $(MAKE) install prefix=$(CURDIR)/debian/ccache/usr
+
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-gcc
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-g++
+ set -e; for ver in 2.95 3.0 3.2 3.3 3.4 4.0 4.1 4.2 4.3; do \
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-gcc-$$ver; \
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/gcc-$$ver; \
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-g++-$$ver; \
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/g++-$$ver; \
+ done
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/cc
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/c++
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/gcc
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/g++
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-c++
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-cc
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-g++
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-gcc
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installdocs
+ dh_installexamples
+ dh_installmenu
+ dh_installcron
+ dh_installman
+ dh_installinfo
+ dh_installchangelogs
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
diff --git a/CCache/debian/update-ccache b/CCache/debian/update-ccache
new file mode 100644
index 000000000..0ef97a140
--- /dev/null
+++ b/CCache/debian/update-ccache
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Update compiler links to ccache (in /usr/local/bin)
+#
+# The idea is that /usr/local/bin is ahead of /usr/bin in your PATH, so adding
+# the link /usr/local/bin/cc -> /usr/bin/ccache means that it is run instead of
+# /usr/bin/cc
+#
+# Written by: Behan Webster
+#
+
+DIRECTORY=/usr/local/bin
+CCACHE=/usr/bin/ccache
+CCDIR=/usr/lib/ccache
+
+usage() {
+ echo "Usage: `basename $0` [--directory ] [--remove]"
+ exit 0
+}
+
+while [ $# -gt 0 ] ; do
+ case "$1" in
+ -d*|--d*|--directory) DIRECTORY=$2; shift; shift;;
+ -h*|--h*|--help) usage;;
+ -r*|--r*|--remove) REMOVE=1; shift;;
+ -t*|--t*|--test) TEST=echo; shift;;
+ esac
+done
+
+for FILE in `cd $CCDIR; ls` ; do
+ LINK=$DIRECTORY/$FILE
+ if [ -z "$REMOVE" ] ; then
+ # Add link
+ $TEST ln -fs $CCACHE $LINK
+ else
+ # Remove link
+ if [ -L "$LINK" ] ; then
+ $TEST rm -f $LINK
+ fi
+ fi
+done
+
+# vim: sw=4 ts=4
diff --git a/CCache/debian/watch b/CCache/debian/watch
new file mode 100644
index 000000000..a72959e50
--- /dev/null
+++ b/CCache/debian/watch
@@ -0,0 +1,2 @@
+version=2
+http://samba.org/ftp/ccache/ccache-(.*)\.tar\.gz
diff --git a/CCache/execute.c b/CCache/execute.c
new file mode 100644
index 000000000..165b91e66
--- /dev/null
+++ b/CCache/execute.c
@@ -0,0 +1,286 @@
+/*
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "ccache.h"
+
+#ifdef _WIN32
+char *argvtos(char **argv)
+{
+ int i, len;
+ char *ptr, *str;
+
+ for (i = 0, len = 0; argv[i]; i++) {
+ len += strlen(argv[i]) + 3;
+ }
+
+ str = ptr = (char *)malloc(len + 1);
+ if (str == NULL)
+ return NULL;
+
+ for (i = 0; argv[i]; i++) {
+ len = strlen(argv[i]);
+ *ptr++ = '"';
+ memcpy(ptr, argv[i], len);
+ ptr += len;
+ *ptr++ = '"';
+ *ptr++ = ' ';
+ }
+ *ptr = 0;
+
+ return str;
+}
+#endif
+
+/*
+ execute a compiler backend, capturing all output to the given paths
+ the full path to the compiler to run is in argv[0]
+*/
+int execute(char **argv,
+ const char *path_stdout,
+ const char *path_stderr)
+{
+#ifdef _WIN32
+
+#if 1
+ PROCESS_INFORMATION pinfo;
+ STARTUPINFO sinfo;
+ BOOL ret;
+ DWORD exitcode;
+ char *args;
+ HANDLE fd_out, fd_err;
+ SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
+
+ /* TODO: needs moving after possible exit() below, but before stdout is redirected */
+ if (ccache_verbose) {
+ display_execute_args(argv);
+ }
+
+ fd_out = CreateFile(path_stdout, GENERIC_WRITE, 0, &sa, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ if (fd_out == INVALID_HANDLE_VALUE) {
+ return STATUS_NOCACHE;
+ }
+
+ fd_err = CreateFile(path_stderr, GENERIC_WRITE, 0, &sa, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ if (fd_err == INVALID_HANDLE_VALUE) {
+ return STATUS_NOCACHE;
+ }
+
+ ZeroMemory(&pinfo, sizeof(PROCESS_INFORMATION));
+ ZeroMemory(&sinfo, sizeof(STARTUPINFO));
+
+ sinfo.cb = sizeof(STARTUPINFO);
+ sinfo.hStdError = fd_err;
+ sinfo.hStdOutput = fd_out;
+ sinfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
+ sinfo.dwFlags |= STARTF_USESTDHANDLES;
+
+ args = argvtos(argv);
+
+ ret = CreateProcessA(argv[0], args, NULL, NULL, TRUE, 0, NULL, NULL,
+ &sinfo, &pinfo);
+
+ free(args);
+ CloseHandle(fd_out);
+ CloseHandle(fd_err);
+
+ if (ret == 0)
+ return -1;
+
+ WaitForSingleObject(pinfo.hProcess, INFINITE);
+ GetExitCodeProcess(pinfo.hProcess, &exitcode);
+ CloseHandle(pinfo.hProcess);
+ CloseHandle(pinfo.hThread);
+
+ return exitcode;
+#else /* possibly slightly faster */
+ /* needs fixing to quote commandline options to handle spaces in CCACHE_DIR etc */
+ int status = -2;
+ int fd, std_od = -1, std_ed = -1;
+
+ /* TODO: needs moving after possible exit() below, but before stdout is redirected */
+ if (ccache_verbose) {
+ display_execute_args(argv);
+ }
+
+ unlink(path_stdout);
+ std_od = _dup(1);
+ fd = _open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
+ if (fd == -1) {
+ exit(STATUS_NOCACHE);
+ }
+ _dup2(fd, 1);
+ _close(fd);
+
+ unlink(path_stderr);
+ fd = _open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
+ std_ed = _dup(2);
+ if (fd == -1) {
+ exit(STATUS_NOCACHE);
+ }
+ _dup2(fd, 2);
+ _close(fd);
+
+ /* Spawn process (_exec* familly doesn't return) */
+ status = _spawnv(_P_WAIT, argv[0], (const char **)argv);
+
+ /* Restore descriptors */
+ if (std_od != -1) _dup2(std_od, 1);
+ if (std_ed != -1) _dup2(std_ed, 2);
+ _flushall();
+
+ return (status>0);
+
+#endif
+
+#else
+ pid_t pid;
+ int status;
+
+ pid = fork();
+ if (pid == -1) fatal("Failed to fork");
+
+ if (pid == 0) {
+ int fd;
+
+ /* TODO: needs moving after possible exit() below, but before stdout is redirected */
+ if (ccache_verbose) {
+ display_execute_args(argv);
+ }
+
+ unlink(path_stdout);
+ fd = open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
+ if (fd == -1) {
+ exit(STATUS_NOCACHE);
+ }
+ dup2(fd, 1);
+ close(fd);
+
+ unlink(path_stderr);
+ fd = open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
+ if (fd == -1) {
+ exit(STATUS_NOCACHE);
+ }
+ dup2(fd, 2);
+ close(fd);
+
+ exit(execv(argv[0], argv));
+ }
+
+ if (waitpid(pid, &status, 0) != pid) {
+ fatal("waitpid failed");
+ }
+
+ if (WEXITSTATUS(status) == 0 && WIFSIGNALED(status)) {
+ return -1;
+ }
+
+ return WEXITSTATUS(status);
+#endif
+}
+
+
+/*
+ find an executable by name in $PATH. Exclude any that are links to exclude_name
+*/
+char *find_executable(const char *name, const char *exclude_name)
+{
+#if _WIN32
+ (void)exclude_name;
+ DWORD ret;
+ char namebuf[MAX_PATH];
+
+ ret = SearchPathA(getenv("CCACHE_PATH"), name, ".exe",
+ sizeof(namebuf), namebuf, NULL);
+ if (ret != 0) {
+ return x_strdup(namebuf);
+ }
+
+ return NULL;
+#else
+ char *path;
+ char *tok;
+ struct stat st1, st2;
+
+ if (*name == '/') {
+ return x_strdup(name);
+ }
+
+ path = getenv("CCACHE_PATH");
+ if (!path) {
+ path = getenv("PATH");
+ }
+ if (!path) {
+ cc_log("no PATH variable!?\n");
+ stats_update(STATS_ENVIRONMMENT);
+ return NULL;
+ }
+
+ path = x_strdup(path);
+
+ /* search the path looking for the first compiler of the right name
+ that isn't us */
+ for (tok=strtok(path,":"); tok; tok = strtok(NULL, ":")) {
+ char *fname;
+ x_asprintf(&fname, "%s/%s", tok, name);
+ /* look for a normal executable file */
+ if (access(fname, X_OK) == 0 &&
+ lstat(fname, &st1) == 0 &&
+ stat(fname, &st2) == 0 &&
+ S_ISREG(st2.st_mode)) {
+ /* if its a symlink then ensure it doesn't
+ point at something called exclude_name */
+ if (S_ISLNK(st1.st_mode)) {
+ char *buf = x_realpath(fname);
+ if (buf) {
+ char *p = str_basename(buf);
+ if (strcmp(p, exclude_name) == 0) {
+ /* its a link to "ccache" ! */
+ free(p);
+ free(buf);
+ continue;
+ }
+ free(buf);
+ free(p);
+ }
+ }
+
+ /* found it! */
+ free(path);
+ return fname;
+ }
+ free(fname);
+ }
+
+ return NULL;
+#endif
+}
+
+void display_execute_args(char **argv)
+{
+ if (argv) {
+ printf("ccache executing: ");
+ while (*argv) {
+ printf("%s ", *argv);
+ ++argv;
+ }
+ printf("\n");
+ fflush(stdout);
+ }
+}
diff --git a/CCache/hash.c b/CCache/hash.c
new file mode 100644
index 000000000..d0ce8a6ba
--- /dev/null
+++ b/CCache/hash.c
@@ -0,0 +1,80 @@
+/*
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+/*
+ simple front-end functions to mdfour code
+*/
+
+#include "ccache.h"
+
+static struct mdfour md;
+
+void hash_buffer(const char *s, int len)
+{
+ mdfour_update(&md, (unsigned char *)s, len);
+}
+
+void hash_start(void)
+{
+ mdfour_begin(&md);
+}
+
+void hash_string(const char *s)
+{
+ hash_buffer(s, strlen(s));
+}
+
+void hash_int(int x)
+{
+ hash_buffer((char *)&x, sizeof(x));
+}
+
+/* add contents of a file to the hash */
+void hash_file(const char *fname)
+{
+ char buf[1024];
+ int fd, n;
+
+ fd = open(fname, O_RDONLY|O_BINARY);
+ if (fd == -1) {
+ cc_log("Failed to open %s\n", fname);
+ fatal("hash_file");
+ }
+
+ while ((n = read(fd, buf, sizeof(buf))) > 0) {
+ hash_buffer(buf, n);
+ }
+ close(fd);
+}
+
+/* return the hash result as a static string */
+char *hash_result(void)
+{
+ unsigned char sum[16];
+ static char ret[53];
+ int i;
+
+ hash_buffer(NULL, 0);
+ mdfour_result(&md, sum);
+
+ for (i=0;i<16;i++) {
+ sprintf(&ret[i*2], "%02x", (unsigned)sum[i]);
+ }
+ sprintf(&ret[i*2], "-%u", (unsigned)md.totalN);
+
+ return ret;
+}
diff --git a/CCache/install-sh b/CCache/install-sh
new file mode 100755
index 000000000..58719246f
--- /dev/null
+++ b/CCache/install-sh
@@ -0,0 +1,238 @@
+#! /bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+#
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ true
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ else
+ instcmd=mkdir
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ true
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ true
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ true
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/CCache/mdfour.c b/CCache/mdfour.c
new file mode 100644
index 000000000..b098e0215
--- /dev/null
+++ b/CCache/mdfour.c
@@ -0,0 +1,284 @@
+/*
+ a implementation of MD4 designed for use in the SMB authentication protocol
+ Copyright (C) Andrew Tridgell 1997-1998.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "ccache.h"
+
+/* NOTE: This code makes no attempt to be fast!
+
+ It assumes that a int is at least 32 bits long
+*/
+
+static struct mdfour *m;
+
+#define MASK32 (0xffffffff)
+
+#define F(X,Y,Z) ((((X)&(Y)) | ((~(X))&(Z))))
+#define G(X,Y,Z) ((((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z))))
+#define H(X,Y,Z) (((X)^(Y)^(Z)))
+#define lshift(x,s) (((((x)<<(s))&MASK32) | (((x)>>(32-(s)))&MASK32)))
+
+#define ROUND1(a,b,c,d,k,s) a = lshift((a + F(b,c,d) + M[k])&MASK32, s)
+#define ROUND2(a,b,c,d,k,s) a = lshift((a + G(b,c,d) + M[k] + 0x5A827999)&MASK32,s)
+#define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c,d) + M[k] + 0x6ED9EBA1)&MASK32,s)
+
+/* this applies md4 to 64 byte chunks */
+static void mdfour64(uint32 *M)
+{
+ uint32 AA, BB, CC, DD;
+ uint32 A,B,C,D;
+
+ A = m->A; B = m->B; C = m->C; D = m->D;
+ AA = A; BB = B; CC = C; DD = D;
+
+ ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7);
+ ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19);
+ ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7);
+ ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19);
+ ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7);
+ ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19);
+ ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7);
+ ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19);
+
+
+ ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5);
+ ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13);
+ ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5);
+ ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13);
+ ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5);
+ ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13);
+ ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5);
+ ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13);
+
+ ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9);
+ ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15);
+ ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9);
+ ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15);
+ ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9);
+ ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15);
+ ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9);
+ ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15);
+
+ A += AA; B += BB;
+ C += CC; D += DD;
+
+ A &= MASK32; B &= MASK32;
+ C &= MASK32; D &= MASK32;
+
+ m->A = A; m->B = B; m->C = C; m->D = D;
+}
+
+static void copy64(uint32 *M, const unsigned char *in)
+{
+ int i;
+
+ for (i=0;i<16;i++)
+ M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) |
+ (in[i*4+1]<<8) | (in[i*4+0]<<0);
+}
+
+static void copy4(unsigned char *out,uint32 x)
+{
+ out[0] = x&0xFF;
+ out[1] = (x>>8)&0xFF;
+ out[2] = (x>>16)&0xFF;
+ out[3] = (x>>24)&0xFF;
+}
+
+void mdfour_begin(struct mdfour *md)
+{
+ md->A = 0x67452301;
+ md->B = 0xefcdab89;
+ md->C = 0x98badcfe;
+ md->D = 0x10325476;
+ md->totalN = 0;
+ md->tail_len = 0;
+}
+
+
+static void mdfour_tail(const unsigned char *in, int n)
+{
+ unsigned char buf[128];
+ uint32 M[16];
+ uint32 b;
+
+ m->totalN += n;
+
+ b = m->totalN * 8;
+
+ memset(buf, 0, 128);
+ if (n) memcpy(buf, in, n);
+ buf[n] = 0x80;
+
+ if (n <= 55) {
+ copy4(buf+56, b);
+ copy64(M, buf);
+ mdfour64(M);
+ } else {
+ copy4(buf+120, b);
+ copy64(M, buf);
+ mdfour64(M);
+ copy64(M, buf+64);
+ mdfour64(M);
+ }
+}
+
+void mdfour_update(struct mdfour *md, const unsigned char *in, int n)
+{
+ uint32 M[16];
+
+ m = md;
+
+ if (in == NULL) {
+ mdfour_tail(md->tail, md->tail_len);
+ return;
+ }
+
+ if (md->tail_len) {
+ int len = 64 - md->tail_len;
+ if (len > n) len = n;
+ memcpy(md->tail+md->tail_len, in, len);
+ md->tail_len += len;
+ n -= len;
+ in += len;
+ if (md->tail_len == 64) {
+ copy64(M, md->tail);
+ mdfour64(M);
+ m->totalN += 64;
+ md->tail_len = 0;
+ }
+ }
+
+ while (n >= 64) {
+ copy64(M, in);
+ mdfour64(M);
+ in += 64;
+ n -= 64;
+ m->totalN += 64;
+ }
+
+ if (n) {
+ memcpy(md->tail, in, n);
+ md->tail_len = n;
+ }
+}
+
+
+void mdfour_result(struct mdfour *md, unsigned char *out)
+{
+ m = md;
+
+ copy4(out, m->A);
+ copy4(out+4, m->B);
+ copy4(out+8, m->C);
+ copy4(out+12, m->D);
+}
+
+
+void mdfour(unsigned char *out, const unsigned char *in, int n)
+{
+ struct mdfour md;
+ mdfour_begin(&md);
+ mdfour_update(&md, in, n);
+ mdfour_update(&md, NULL, 0);
+ mdfour_result(&md, out);
+}
+
+#ifdef TEST_MDFOUR
+static void file_checksum1(char *fname)
+{
+ int fd, i;
+ struct mdfour md;
+ unsigned char buf[1024], sum[16];
+ unsigned chunk;
+
+ fd = open(fname,O_RDONLY|O_BINARY);
+ if (fd == -1) {
+ perror("fname");
+ exit(1);
+ }
+
+ chunk = 1 + random() % (sizeof(buf) - 1);
+
+ mdfour_begin(&md);
+
+ while (1) {
+ int n = read(fd, buf, chunk);
+ if (n >= 0) {
+ mdfour_update(&md, buf, n);
+ }
+ if (n < chunk) break;
+ }
+
+ close(fd);
+
+ mdfour_update(&md, NULL, 0);
+
+ mdfour_result(&md, sum);
+
+ for (i=0;i<16;i++)
+ printf("%02x", sum[i]);
+ printf("\n");
+}
+
+#if 0
+#include "../md4.h"
+
+static void file_checksum2(char *fname)
+{
+ int fd, i;
+ MDstruct md;
+ unsigned char buf[64], sum[16];
+
+ fd = open(fname,O_RDONLY|O_BINARY);
+ if (fd == -1) {
+ perror("fname");
+ exit(1);
+ }
+
+ MDbegin(&md);
+
+ while (1) {
+ int n = read(fd, buf, sizeof(buf));
+ if (n <= 0) break;
+ MDupdate(&md, buf, n*8);
+ }
+
+ if (!md.done) {
+ MDupdate(&md, buf, 0);
+ }
+
+ close(fd);
+
+ memcpy(sum, md.buffer, 16);
+
+ for (i=0;i<16;i++)
+ printf("%02x", sum[i]);
+ printf("\n");
+}
+#endif
+
+ int main(int argc, char *argv[])
+{
+ file_checksum1(argv[1]);
+#if 0
+ file_checksum2(argv[1]);
+#endif
+ return 0;
+}
+#endif
diff --git a/CCache/mdfour.h b/CCache/mdfour.h
new file mode 100644
index 000000000..92ef2f831
--- /dev/null
+++ b/CCache/mdfour.h
@@ -0,0 +1,36 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ a implementation of MD4 designed for use in the SMB authentication protocol
+ Copyright (C) Andrew Tridgell 1997-1998.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+struct mdfour {
+ uint32 A, B, C, D;
+ uint32 totalN;
+ unsigned char tail[64];
+ unsigned tail_len;
+};
+
+void mdfour_begin(struct mdfour *md);
+void mdfour_update(struct mdfour *md, const unsigned char *in, int n);
+void mdfour_result(struct mdfour *md, unsigned char *out);
+void mdfour(unsigned char *out, const unsigned char *in, int n);
+
+
+
+
diff --git a/CCache/packaging/README b/CCache/packaging/README
new file mode 100644
index 000000000..fadc342c4
--- /dev/null
+++ b/CCache/packaging/README
@@ -0,0 +1,5 @@
+These packaging files are contributd by users of ccache. I do not
+maintain them, and they may well need updating before you use them.
+
+I don't distribute binary packages of ccache myself, but if you wish
+to add ccache to a distribution then that's OK
diff --git a/CCache/packaging/ccache.spec b/CCache/packaging/ccache.spec
new file mode 100644
index 000000000..0972121d7
--- /dev/null
+++ b/CCache/packaging/ccache.spec
@@ -0,0 +1,37 @@
+Summary: Compiler Cache
+Name: ccache
+Version: 2.3
+Release: 1
+Group: Development/Languages
+License: GPL
+URL: http://ccache.samba.org/
+Source: ccache-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+
+%description
+ccache caches gcc output files
+
+%prep
+%setup -q
+
+%build
+%configure
+make
+
+install -d -m 0755 $RPM_BUILD_ROOT%{_bindir}
+install -m 0755 ccache $RPM_BUILD_ROOT%{_bindir}
+install -d -m 0755 $RPM_BUILD_ROOT%{_mandir}/man1
+install -m 0644 ccache.1 $RPM_BUILD_ROOT%{_mandir}/man1
+
+%files
+%defattr(-,root,root)
+%doc README
+%{_mandir}/man1/ccache.1*
+%{_bindir}/ccache
+
+%clean
+[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
+
+%changelog
+* Mon Apr 01 2002 Peter Jones
+- Created the package
diff --git a/CCache/snprintf.c b/CCache/snprintf.c
new file mode 100644
index 000000000..32187c1a5
--- /dev/null
+++ b/CCache/snprintf.c
@@ -0,0 +1,962 @@
+/*
+ * Copyright Patrick Powell 1995
+ * This code is based on code written by Patrick Powell (papowell@astart.com)
+ * It may be used for any purpose as long as this notice remains intact
+ * on all source code distributions
+ */
+
+/**************************************************************
+ * Original:
+ * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
+ * A bombproof version of doprnt (dopr) included.
+ * Sigh. This sort of thing is always nasty do deal with. Note that
+ * the version here does not include floating point...
+ *
+ * snprintf() is used instead of sprintf() as it does limit checks
+ * for string length. This covers a nasty loophole.
+ *
+ * The other functions are there to prevent NULL pointers from
+ * causing nast effects.
+ *
+ * More Recently:
+ * Brandon Long 9/15/96 for mutt 0.43
+ * This was ugly. It is still ugly. I opted out of floating point
+ * numbers, but the formatter understands just about everything
+ * from the normal C string format, at least as far as I can tell from
+ * the Solaris 2.5 printf(3S) man page.
+ *
+ * Brandon Long 10/22/97 for mutt 0.87.1
+ * Ok, added some minimal floating point support, which means this
+ * probably requires libm on most operating systems. Don't yet
+ * support the exponent (e,E) and sigfig (g,G). Also, fmtint()
+ * was pretty badly broken, it just wasn't being exercised in ways
+ * which showed it, so that's been fixed. Also, formated the code
+ * to mutt conventions, and removed dead code left over from the
+ * original. Also, there is now a builtin-test, just compile with:
+ * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
+ * and run snprintf for results.
+ *
+ * Thomas Roessler 01/27/98 for mutt 0.89i
+ * The PGP code was using unsigned hexadecimal formats.
+ * Unfortunately, unsigned formats simply didn't work.
+ *
+ * Michael Elkins 03/05/98 for mutt 0.90.8
+ * The original code assumed that both snprintf() and vsnprintf() were
+ * missing. Some systems only have snprintf() but not vsnprintf(), so
+ * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
+ *
+ * Andrew Tridgell (tridge@samba.org) Oct 1998
+ * fixed handling of %.0f
+ * added test for HAVE_LONG_DOUBLE
+ *
+ * tridge@samba.org, idra@samba.org, April 2001
+ * got rid of fcvt code (twas buggy and made testing harder)
+ * added C99 semantics
+ *
+ **************************************************************/
+
+#ifndef NO_CONFIG_H /* for some tests */
+#include "config.h"
+#endif
+
+#ifdef HAVE_STRING_H
+#include
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include
+#endif
+#ifdef HAVE_CTYPE_H
+#include
+#endif
+#include
+#include
+#ifdef HAVE_STDLIB_H
+#include
+#endif
+
+#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF)
+/* only include stdio.h if we are not re-defining snprintf or vsnprintf */
+#include
+ /* make the compiler happy with an empty file */
+ void dummy_snprintf(void) {}
+#else
+
+#ifdef HAVE_LONG_DOUBLE
+#define LDOUBLE long double
+#else
+#define LDOUBLE double
+#endif
+
+#ifdef HAVE_LONG_LONG
+#define LLONG long long
+#else
+#define LLONG long
+#endif
+
+static size_t dopr(char *buffer, size_t maxlen, const char *format,
+ va_list args);
+static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
+ char *value, int flags, int min, int max);
+static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
+ long value, int base, int min, int max, int flags);
+static void fmtfp(char *buffer, size_t *currlen, size_t maxlen,
+ LDOUBLE fvalue, int min, int max, int flags);
+static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
+
+/*
+ * dopr(): poor man's version of doprintf
+ */
+
+/* format read states */
+#define DP_S_DEFAULT 0
+#define DP_S_FLAGS 1
+#define DP_S_MIN 2
+#define DP_S_DOT 3
+#define DP_S_MAX 4
+#define DP_S_MOD 5
+#define DP_S_CONV 6
+#define DP_S_DONE 7
+
+/* format flags - Bits */
+#define DP_F_MINUS (1 << 0)
+#define DP_F_PLUS (1 << 1)
+#define DP_F_SPACE (1 << 2)
+#define DP_F_NUM (1 << 3)
+#define DP_F_ZERO (1 << 4)
+#define DP_F_UP (1 << 5)
+#define DP_F_UNSIGNED (1 << 6)
+
+/* Conversion Flags */
+#define DP_C_SHORT 1
+#define DP_C_LONG 2
+#define DP_C_LDOUBLE 3
+#define DP_C_LLONG 4
+
+#define char_to_int(p) ((p)- '0')
+#ifndef MAX
+#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
+#endif
+
+static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args)
+{
+ char ch;
+ LLONG value;
+ LDOUBLE fvalue;
+ char *strvalue;
+ int min;
+ int max;
+ int state;
+ int flags;
+ int cflags;
+ size_t currlen;
+
+ state = DP_S_DEFAULT;
+ currlen = flags = cflags = min = 0;
+ max = -1;
+ ch = *format++;
+
+ while (state != DP_S_DONE) {
+ if (ch == '\0')
+ state = DP_S_DONE;
+
+ switch(state) {
+ case DP_S_DEFAULT:
+ if (ch == '%')
+ state = DP_S_FLAGS;
+ else
+ dopr_outch (buffer, &currlen, maxlen, ch);
+ ch = *format++;
+ break;
+ case DP_S_FLAGS:
+ switch (ch) {
+ case '-':
+ flags |= DP_F_MINUS;
+ ch = *format++;
+ break;
+ case '+':
+ flags |= DP_F_PLUS;
+ ch = *format++;
+ break;
+ case ' ':
+ flags |= DP_F_SPACE;
+ ch = *format++;
+ break;
+ case '#':
+ flags |= DP_F_NUM;
+ ch = *format++;
+ break;
+ case '0':
+ flags |= DP_F_ZERO;
+ ch = *format++;
+ break;
+ default:
+ state = DP_S_MIN;
+ break;
+ }
+ break;
+ case DP_S_MIN:
+ if (isdigit((unsigned char)ch)) {
+ min = 10*min + char_to_int (ch);
+ ch = *format++;
+ } else if (ch == '*') {
+ min = va_arg (args, int);
+ ch = *format++;
+ state = DP_S_DOT;
+ } else {
+ state = DP_S_DOT;
+ }
+ break;
+ case DP_S_DOT:
+ if (ch == '.') {
+ state = DP_S_MAX;
+ ch = *format++;
+ } else {
+ state = DP_S_MOD;
+ }
+ break;
+ case DP_S_MAX:
+ if (isdigit((unsigned char)ch)) {
+ if (max < 0)
+ max = 0;
+ max = 10*max + char_to_int (ch);
+ ch = *format++;
+ } else if (ch == '*') {
+ max = va_arg (args, int);
+ ch = *format++;
+ state = DP_S_MOD;
+ } else {
+ state = DP_S_MOD;
+ }
+ break;
+ case DP_S_MOD:
+ switch (ch) {
+ case 'h':
+ cflags = DP_C_SHORT;
+ ch = *format++;
+ break;
+ case 'l':
+ cflags = DP_C_LONG;
+ ch = *format++;
+ if (ch == 'l') { /* It's a long long */
+ cflags = DP_C_LLONG;
+ ch = *format++;
+ }
+ break;
+ case 'L':
+ cflags = DP_C_LDOUBLE;
+ ch = *format++;
+ break;
+ default:
+ break;
+ }
+ state = DP_S_CONV;
+ break;
+ case DP_S_CONV:
+ switch (ch) {
+ case 'd':
+ case 'i':
+ if (cflags == DP_C_SHORT)
+ value = va_arg (args, int);
+ else if (cflags == DP_C_LONG)
+ value = va_arg (args, long int);
+ else if (cflags == DP_C_LLONG)
+ value = va_arg (args, LLONG);
+ else
+ value = va_arg (args, int);
+ fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
+ break;
+ case 'o':
+ flags |= DP_F_UNSIGNED;
+ if (cflags == DP_C_SHORT)
+ value = va_arg (args, unsigned int);
+ else if (cflags == DP_C_LONG)
+ value = (long)va_arg (args, unsigned long int);
+ else if (cflags == DP_C_LLONG)
+ value = (long)va_arg (args, unsigned LLONG);
+ else
+ value = (long)va_arg (args, unsigned int);
+ fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
+ break;
+ case 'u':
+ flags |= DP_F_UNSIGNED;
+ if (cflags == DP_C_SHORT)
+ value = va_arg (args, unsigned int);
+ else if (cflags == DP_C_LONG)
+ value = (long)va_arg (args, unsigned long int);
+ else if (cflags == DP_C_LLONG)
+ value = (LLONG)va_arg (args, unsigned LLONG);
+ else
+ value = (long)va_arg (args, unsigned int);
+ fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
+ break;
+ case 'X':
+ flags |= DP_F_UP;
+ case 'x':
+ flags |= DP_F_UNSIGNED;
+ if (cflags == DP_C_SHORT)
+ value = va_arg (args, unsigned int);
+ else if (cflags == DP_C_LONG)
+ value = (long)va_arg (args, unsigned long int);
+ else if (cflags == DP_C_LLONG)
+ value = (LLONG)va_arg (args, unsigned LLONG);
+ else
+ value = (long)va_arg (args, unsigned int);
+ fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
+ break;
+ case 'f':
+ if (cflags == DP_C_LDOUBLE)
+ fvalue = va_arg (args, LDOUBLE);
+ else
+ fvalue = va_arg (args, double);
+ /* um, floating point? */
+ fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
+ break;
+ case 'E':
+ flags |= DP_F_UP;
+ case 'e':
+ if (cflags == DP_C_LDOUBLE)
+ fvalue = va_arg (args, LDOUBLE);
+ else
+ fvalue = va_arg (args, double);
+ break;
+ case 'G':
+ flags |= DP_F_UP;
+ case 'g':
+ if (cflags == DP_C_LDOUBLE)
+ fvalue = va_arg (args, LDOUBLE);
+ else
+ fvalue = va_arg (args, double);
+ break;
+ case 'c':
+ dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
+ break;
+ case 's':
+ strvalue = va_arg (args, char *);
+ if (!strvalue) strvalue = "(NULL)";
+ if (max == -1) {
+ max = strlen(strvalue);
+ }
+ if (min > 0 && max >= 0 && min > max) max = min;
+ fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
+ break;
+ case 'p':
+ strvalue = (char *)va_arg(args, void *);
+ fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags);
+ break;
+ case 'n':
+ if (cflags == DP_C_SHORT) {
+ short int *num;
+ num = va_arg (args, short int *);
+ *num = currlen;
+ } else if (cflags == DP_C_LONG) {
+ long int *num;
+ num = va_arg (args, long int *);
+ *num = (long int)currlen;
+ } else if (cflags == DP_C_LLONG) {
+ LLONG *num;
+ num = va_arg (args, LLONG *);
+ *num = (LLONG)currlen;
+ } else {
+ int *num;
+ num = va_arg (args, int *);
+ *num = currlen;
+ }
+ break;
+ case '%':
+ dopr_outch (buffer, &currlen, maxlen, ch);
+ break;
+ case 'w':
+ /* not supported yet, treat as next char */
+ ch = *format++;
+ break;
+ default:
+ /* Unknown, skip */
+ break;
+ }
+ ch = *format++;
+ state = DP_S_DEFAULT;
+ flags = cflags = min = 0;
+ max = -1;
+ break;
+ case DP_S_DONE:
+ break;
+ default:
+ /* hmm? */
+ break; /* some picky compilers need this */
+ }
+ }
+ if (maxlen != 0) {
+ if (currlen < maxlen - 1)
+ buffer[currlen] = '\0';
+ else if (maxlen > 0)
+ buffer[maxlen - 1] = '\0';
+ }
+
+ return currlen;
+}
+
+static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
+ char *value, int flags, int min, int max)
+{
+ int padlen, strln; /* amount to pad */
+ int cnt = 0;
+
+#ifdef DEBUG_SNPRINTF
+ printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value);
+#endif
+ if (value == 0) {
+ value = "";
+ }
+
+ for (strln = 0; value[strln]; ++strln); /* strlen */
+ padlen = min - strln;
+ if (padlen < 0)
+ padlen = 0;
+ if (flags & DP_F_MINUS)
+ padlen = -padlen; /* Left Justify */
+
+ while ((padlen > 0) && (cnt < max)) {
+ dopr_outch (buffer, currlen, maxlen, ' ');
+ --padlen;
+ ++cnt;
+ }
+ while (*value && (cnt < max)) {
+ dopr_outch (buffer, currlen, maxlen, *value++);
+ ++cnt;
+ }
+ while ((padlen < 0) && (cnt < max)) {
+ dopr_outch (buffer, currlen, maxlen, ' ');
+ ++padlen;
+ ++cnt;
+ }
+}
+
+/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
+
+static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
+ long value, int base, int min, int max, int flags)
+{
+ int signvalue = 0;
+ unsigned long uvalue;
+ char convert[20];
+ int place = 0;
+ int spadlen = 0; /* amount to space pad */
+ int zpadlen = 0; /* amount to zero pad */
+ int caps = 0;
+
+ if (max < 0)
+ max = 0;
+
+ uvalue = value;
+
+ if(!(flags & DP_F_UNSIGNED)) {
+ if( value < 0 ) {
+ signvalue = '-';
+ uvalue = -value;
+ } else {
+ if (flags & DP_F_PLUS) /* Do a sign (+/i) */
+ signvalue = '+';
+ else if (flags & DP_F_SPACE)
+ signvalue = ' ';
+ }
+ }
+
+ if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
+
+ do {
+ convert[place++] =
+ (caps? "0123456789ABCDEF":"0123456789abcdef")
+ [uvalue % (unsigned)base ];
+ uvalue = (uvalue / (unsigned)base );
+ } while(uvalue && (place < 20));
+ if (place == 20) place--;
+ convert[place] = 0;
+
+ zpadlen = max - place;
+ spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
+ if (zpadlen < 0) zpadlen = 0;
+ if (spadlen < 0) spadlen = 0;
+ if (flags & DP_F_ZERO) {
+ zpadlen = MAX(zpadlen, spadlen);
+ spadlen = 0;
+ }
+ if (flags & DP_F_MINUS)
+ spadlen = -spadlen; /* Left Justifty */
+
+#ifdef DEBUG_SNPRINTF
+ printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
+ zpadlen, spadlen, min, max, place);
+#endif
+
+ /* Spaces */
+ while (spadlen > 0) {
+ dopr_outch (buffer, currlen, maxlen, ' ');
+ --spadlen;
+ }
+
+ /* Sign */
+ if (signvalue)
+ dopr_outch (buffer, currlen, maxlen, signvalue);
+
+ /* Zeros */
+ if (zpadlen > 0) {
+ while (zpadlen > 0) {
+ dopr_outch (buffer, currlen, maxlen, '0');
+ --zpadlen;
+ }
+ }
+
+ /* Digits */
+ while (place > 0)
+ dopr_outch (buffer, currlen, maxlen, convert[--place]);
+
+ /* Left Justified spaces */
+ while (spadlen < 0) {
+ dopr_outch (buffer, currlen, maxlen, ' ');
+ ++spadlen;
+ }
+}
+
+static LDOUBLE abs_val(LDOUBLE value)
+{
+ LDOUBLE result = value;
+
+ if (value < 0)
+ result = -value;
+
+ return result;
+}
+
+static LDOUBLE POW10(int exp)
+{
+ LDOUBLE result = 1;
+
+ while (exp) {
+ result *= 10;
+ exp--;
+ }
+
+ return result;
+}
+
+static LLONG ROUND(LDOUBLE value)
+{
+ LLONG intpart;
+
+ intpart = (LLONG)value;
+ value = value - intpart;
+ if (value >= 0.5) intpart++;
+
+ return intpart;
+}
+
+/* a replacement for modf that doesn't need the math library. Should
+ be portable, but slow */
+static double my_modf(double x0, double *iptr)
+{
+ int i;
+ long l;
+ double x = x0;
+ double f = 1.0;
+
+ for (i=0;i<100;i++) {
+ l = (long)x;
+ if (l <= (x+1) && l >= (x-1)) break;
+ x *= 0.1;
+ f *= 10.0;
+ }
+
+ if (i == 100) {
+ /* yikes! the number is beyond what we can handle. What do we do? */
+ (*iptr) = 0;
+ return 0;
+ }
+
+ if (i != 0) {
+ double i2;
+ double ret;
+
+ ret = my_modf(x0-l*f, &i2);
+ (*iptr) = l*f + i2;
+ return ret;
+ }
+
+ (*iptr) = l;
+ return x - (*iptr);
+}
+
+
+static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
+ LDOUBLE fvalue, int min, int max, int flags)
+{
+ int signvalue = 0;
+ double ufvalue;
+ char iconvert[311];
+ char fconvert[311];
+ int iplace = 0;
+ int fplace = 0;
+ int padlen = 0; /* amount to pad */
+ int zpadlen = 0;
+ int caps = 0;
+ int index;
+ double intpart;
+ double fracpart;
+ double temp;
+
+ /*
+ * AIX manpage says the default is 0, but Solaris says the default
+ * is 6, and sprintf on AIX defaults to 6
+ */
+ if (max < 0)
+ max = 6;
+
+ ufvalue = abs_val (fvalue);
+
+ if (fvalue < 0) {
+ signvalue = '-';
+ } else {
+ if (flags & DP_F_PLUS) { /* Do a sign (+/i) */
+ signvalue = '+';
+ } else {
+ if (flags & DP_F_SPACE)
+ signvalue = ' ';
+ }
+ }
+
+#if 0
+ if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
+#endif
+
+#if 0
+ if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */
+#endif
+
+ /*
+ * Sorry, we only support 16 digits past the decimal because of our
+ * conversion method
+ */
+ if (max > 16)
+ max = 16;
+
+ /* We "cheat" by converting the fractional part to integer by
+ * multiplying by a factor of 10
+ */
+
+ temp = ufvalue;
+ my_modf(temp, &intpart);
+
+ fracpart = ROUND((POW10(max)) * (ufvalue - intpart));
+
+ if (fracpart >= POW10(max)) {
+ intpart++;
+ fracpart -= POW10(max);
+ }
+
+
+ /* Convert integer part */
+ do {
+ temp = intpart;
+ my_modf(intpart*0.1, &intpart);
+ temp = temp*0.1;
+ index = (int) ((temp -intpart +0.05)* 10.0);
+ /* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */
+ /* printf ("%llf, %f, %x\n", temp, intpart, index); */
+ iconvert[iplace++] =
+ (caps? "0123456789ABCDEF":"0123456789abcdef")[index];
+ } while (intpart && (iplace < 311));
+ if (iplace == 311) iplace--;
+ iconvert[iplace] = 0;
+
+ /* Convert fractional part */
+ if (fracpart)
+ {
+ do {
+ temp = fracpart;
+ my_modf(fracpart*0.1, &fracpart);
+ temp = temp*0.1;
+ index = (int) ((temp -fracpart +0.05)* 10.0);
+ /* index = (int) ((((temp/10) -fracpart) +0.05) *10); */
+ /* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */
+ fconvert[fplace++] =
+ (caps? "0123456789ABCDEF":"0123456789abcdef")[index];
+ } while(fracpart && (fplace < 311));
+ if (fplace == 311) fplace--;
+ }
+ fconvert[fplace] = 0;
+
+ /* -1 for decimal point, another -1 if we are printing a sign */
+ padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
+ zpadlen = max - fplace;
+ if (zpadlen < 0) zpadlen = 0;
+ if (padlen < 0)
+ padlen = 0;
+ if (flags & DP_F_MINUS)
+ padlen = -padlen; /* Left Justifty */
+
+ if ((flags & DP_F_ZERO) && (padlen > 0)) {
+ if (signvalue) {
+ dopr_outch (buffer, currlen, maxlen, signvalue);
+ --padlen;
+ signvalue = 0;
+ }
+ while (padlen > 0) {
+ dopr_outch (buffer, currlen, maxlen, '0');
+ --padlen;
+ }
+ }
+ while (padlen > 0) {
+ dopr_outch (buffer, currlen, maxlen, ' ');
+ --padlen;
+ }
+ if (signvalue)
+ dopr_outch (buffer, currlen, maxlen, signvalue);
+
+ while (iplace > 0)
+ dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
+
+#ifdef DEBUG_SNPRINTF
+ printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen);
+#endif
+
+ /*
+ * Decimal point. This should probably use locale to find the correct
+ * char to print out.
+ */
+ if (max > 0) {
+ dopr_outch (buffer, currlen, maxlen, '.');
+
+ while (fplace > 0)
+ dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
+ }
+
+ while (zpadlen > 0) {
+ dopr_outch (buffer, currlen, maxlen, '0');
+ --zpadlen;
+ }
+
+ while (padlen < 0) {
+ dopr_outch (buffer, currlen, maxlen, ' ');
+ ++padlen;
+ }
+}
+
+static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
+{
+ if (*currlen < maxlen) {
+ buffer[(*currlen)] = c;
+ }
+ (*currlen)++;
+}
+
+/* yes this really must be a ||. Don't muck with this (tridge) */
+#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+ int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
+{
+ return dopr(str, count, fmt, args);
+}
+#endif
+
+/* yes this really must be a ||. Don't muck wiith this (tridge)
+ *
+ * The logic for these two is that we need our own definition if the
+ * OS *either* has no definition of *sprintf, or if it does have one
+ * that doesn't work properly according to the autoconf test. Perhaps
+ * these should really be smb_snprintf to avoid conflicts with buggy
+ * linkers? -- mbp
+ */
+#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_SNPRINTF)
+ int snprintf(char *str,size_t count,const char *fmt,...)
+{
+ size_t ret;
+ va_list ap;
+
+ va_start(ap, fmt);
+ ret = vsnprintf(str, count, fmt, ap);
+ va_end(ap);
+ return ret;
+}
+#endif
+
+#endif
+
+#ifndef HAVE_VASPRINTF
+ int vasprintf(char **ptr, const char *format, va_list ap)
+{
+ int ret;
+
+ ret = vsnprintf(0, 0, format, ap);
+ if (ret <= 0) return ret;
+
+ (*ptr) = (char *)malloc(ret+1);
+ if (!*ptr) return -1;
+ ret = vsnprintf(*ptr, ret+1, format, ap);
+
+ return ret;
+}
+#endif
+
+
+#ifndef HAVE_ASPRINTF
+ int asprintf(char **ptr, const char *format, ...)
+{
+ va_list ap;
+ int ret;
+
+ *ptr = 0;
+ va_start(ap, format);
+ ret = vasprintf(ptr, format, ap);
+ va_end(ap);
+
+ return ret;
+}
+#endif
+
+#ifndef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
+ void vsyslog (int facility_priority, char *format, va_list arglist)
+{
+ char *msg = 0;
+ vasprintf(&msg, format, arglist);
+ if (!msg)
+ return;
+ syslog(facility_priority, "%s", msg);
+ free(msg);
+}
+#endif /* HAVE_SYSLOG */
+#endif /* HAVE_VSYSLOG */
+
+#ifdef TEST_SNPRINTF
+
+ int sprintf(char *str,const char *fmt,...);
+
+ int main (void)
+{
+ char buf1[1024];
+ char buf2[1024];
+ char *fp_fmt[] = {
+ "%1.1f",
+ "%-1.5f",
+ "%1.5f",
+ "%123.9f",
+ "%10.5f",
+ "% 10.5f",
+ "%+22.9f",
+ "%+4.9f",
+ "%01.3f",
+ "%4f",
+ "%3.1f",
+ "%3.2f",
+ "%.0f",
+ "%f",
+ "-16.16f",
+ 0
+ };
+ double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
+ 0.9996, 1.996, 4.136, 0};
+ char *int_fmt[] = {
+ "%-1.5d",
+ "%1.5d",
+ "%123.9d",
+ "%5.5d",
+ "%10.5d",
+ "% 10.5d",
+ "%+22.33d",
+ "%01.3d",
+ "%4d",
+ "%d",
+ 0
+ };
+ long int_nums[] = { -1, 134, 91340, 341, 0203, 0};
+ char *str_fmt[] = {
+ "10.5s",
+ "5.10s",
+ "10.1s",
+ "0.10s",
+ "10.0s",
+ "1.10s",
+ "%s",
+ "%.1s",
+ "%.10s",
+ "%10s",
+ 0
+ };
+ char *str_vals[] = {"hello", "a", "", "a longer string", 0};
+ int x, y;
+ int fail = 0;
+ int num = 0;
+
+ printf ("Testing snprintf format codes against system sprintf...\n");
+
+ for (x = 0; fp_fmt[x] ; x++) {
+ for (y = 0; fp_nums[y] != 0 ; y++) {
+ int l1 = snprintf(0, 0, fp_fmt[x], fp_nums[y]);
+ int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]);
+ sprintf (buf2, fp_fmt[x], fp_nums[y]);
+ if (strcmp (buf1, buf2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n",
+ fp_fmt[x], buf1, buf2);
+ fail++;
+ }
+ if (l1 != l2) {
+ printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, fp_fmt[x]);
+ fail++;
+ }
+ num++;
+ }
+ }
+
+ for (x = 0; int_fmt[x] ; x++) {
+ for (y = 0; int_nums[y] != 0 ; y++) {
+ int l1 = snprintf(0, 0, int_fmt[x], int_nums[y]);
+ int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]);
+ sprintf (buf2, int_fmt[x], int_nums[y]);
+ if (strcmp (buf1, buf2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n",
+ int_fmt[x], buf1, buf2);
+ fail++;
+ }
+ if (l1 != l2) {
+ printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, int_fmt[x]);
+ fail++;
+ }
+ num++;
+ }
+ }
+
+ for (x = 0; str_fmt[x] ; x++) {
+ for (y = 0; str_vals[y] != 0 ; y++) {
+ int l1 = snprintf(0, 0, str_fmt[x], str_vals[y]);
+ int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]);
+ sprintf (buf2, str_fmt[x], str_vals[y]);
+ if (strcmp (buf1, buf2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n",
+ str_fmt[x], buf1, buf2);
+ fail++;
+ }
+ if (l1 != l2) {
+ printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, str_fmt[x]);
+ fail++;
+ }
+ num++;
+ }
+ }
+
+ printf ("%d tests failed out of %d.\n", fail, num);
+
+ printf("seeing how many digits we support\n");
+ {
+ double v0 = 0.12345678901234567890123456789012345678901;
+ for (x=0; x<100; x++) {
+ snprintf(buf1, sizeof(buf1), "%1.1f", v0*pow(10, x));
+ sprintf(buf2, "%1.1f", v0*pow(10, x));
+ if (strcmp(buf1, buf2)) {
+ printf("we seem to support %d digits\n", x-1);
+ break;
+ }
+ }
+ }
+
+ return 0;
+}
+#endif /* SNPRINTF_TEST */
diff --git a/CCache/stats.c b/CCache/stats.c
new file mode 100644
index 000000000..92bc4a835
--- /dev/null
+++ b/CCache/stats.c
@@ -0,0 +1,361 @@
+/*
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+/*
+ routines to handle the stats files
+
+ the stats file is stored one per cache subdirectory to make this more
+ scalable
+ */
+
+#include "ccache.h"
+
+extern char *stats_file;
+extern char *cache_dir;
+
+#define STATS_VERSION 1
+
+#define FLAG_NOZERO 1 /* don't zero with the -z option */
+#define FLAG_ALWAYS 2 /* always show, even if zero */
+
+static struct {
+ enum stats stat;
+ char *message;
+ void (*fn)(unsigned );
+ unsigned flags;
+} stats_info[] = {
+ { STATS_CACHED, "cache hit ", NULL, FLAG_ALWAYS },
+ { STATS_TOCACHE, "cache miss ", NULL, FLAG_ALWAYS },
+ { STATS_LINK, "called for link ", NULL, 0 },
+ { STATS_MULTIPLE, "multiple source files ", NULL, 0 },
+ { STATS_STDOUT, "compiler produced stdout ", NULL, 0 },
+ { STATS_STATUS, "compile failed ", NULL, 0 },
+ { STATS_ERROR, "ccache internal error ", NULL, 0 },
+ { STATS_PREPROCESSOR, "preprocessor error ", NULL, 0 },
+ { STATS_COMPILER, "couldn't find the compiler ", NULL, 0 },
+ { STATS_MISSING, "cache file missing ", NULL, 0 },
+ { STATS_ARGS, "bad compiler arguments ", NULL, 0 },
+ { STATS_NOTC, "not a C/C++ file ", NULL, 0 },
+ { STATS_CONFTEST, "autoconf compile/link ", NULL, 0 },
+ { STATS_UNSUPPORTED, "unsupported compiler option ", NULL, 0 },
+ { STATS_OUTSTDOUT, "output to stdout ", NULL, 0 },
+ { STATS_DEVICE, "output to a non-regular file ", NULL, 0 },
+ { STATS_NOINPUT, "no input file ", NULL, 0 },
+ { STATS_ENVIRONMMENT, "error due to bad env variable ", NULL, 0 },
+ { STATS_NUMFILES, "files in cache ", NULL, FLAG_NOZERO|FLAG_ALWAYS },
+ { STATS_TOTALSIZE, "cache size ", display_size , FLAG_NOZERO|FLAG_ALWAYS },
+ { STATS_MAXFILES, "max files ", NULL, FLAG_NOZERO },
+ { STATS_MAXSIZE, "max cache size ", display_size, FLAG_NOZERO },
+ { STATS_NONE, NULL, NULL, 0 }
+};
+
+/* parse a stats file from a buffer - adding to the counters */
+static void parse_stats(unsigned counters[STATS_END], char *buf)
+{
+ int i;
+ char *p, *p2;
+
+ p = buf;
+ for (i=0;i= (int)sizeof(buf)-1) fatal("stats too long?!");
+ }
+ len += snprintf(buf+len, sizeof(buf)-(len+1), "\n");
+ if (len >= (int)sizeof(buf)-1) fatal("stats too long?!");
+
+ lseek(fd, 0, SEEK_SET);
+ if (write(fd, buf, len) == -1) fatal("could not write stats");
+}
+
+
+/* fill in some default stats values */
+static void stats_default(unsigned counters[STATS_END])
+{
+ counters[STATS_MAXSIZE] += DEFAULT_MAXSIZE / 16;
+}
+
+/* read in the stats from one dir and add to the counters */
+static void stats_read_fd(int fd, unsigned counters[STATS_END])
+{
+ char buf[1024];
+ int len;
+ len = read(fd, buf, sizeof(buf)-1);
+ if (len <= 0) {
+ stats_default(counters);
+ return;
+ }
+ buf[len] = 0;
+ parse_stats(counters, buf);
+}
+
+/* update the stats counter for this compile */
+static void stats_update_size(enum stats stat, size_t size, size_t numfiles)
+{
+ int fd;
+ unsigned counters[STATS_END];
+ int need_cleanup = 0;
+
+ if (getenv("CCACHE_NOSTATS")) return;
+
+ if (!stats_file) {
+ if (!cache_dir) return;
+ x_asprintf(&stats_file, "%s/stats", cache_dir);
+ }
+
+ /* open safely to try to prevent symlink races */
+ fd = safe_open(stats_file);
+
+ /* still can't get it? don't bother ... */
+ if (fd == -1) return;
+
+ memset(counters, 0, sizeof(counters));
+
+ if (lock_fd(fd) != 0) return;
+
+ /* read in the old stats */
+ stats_read_fd(fd, counters);
+
+ /* update them */
+ counters[stat]++;
+
+ /* on a cache miss we up the file count and size */
+ if (stat == STATS_TOCACHE) {
+ counters[STATS_NUMFILES] += numfiles;
+ counters[STATS_TOTALSIZE] += size;
+ }
+
+ /* and write them out */
+ write_stats(fd, counters);
+ close(fd);
+
+ /* we might need to cleanup if the cache has now got too big */
+ if (counters[STATS_MAXFILES] != 0 &&
+ counters[STATS_NUMFILES] > counters[STATS_MAXFILES]) {
+ need_cleanup = 1;
+ }
+ if (counters[STATS_MAXSIZE] != 0 &&
+ counters[STATS_TOTALSIZE] > counters[STATS_MAXSIZE]) {
+ need_cleanup = 1;
+ }
+
+ if (need_cleanup) {
+ char *p = dirname(stats_file);
+ cleanup_dir(p, counters[STATS_MAXFILES], counters[STATS_MAXSIZE]);
+ free(p);
+ }
+}
+
+/* record a cache miss */
+void stats_tocache(size_t size, size_t numfiles)
+{
+ /* convert size to kilobytes */
+ size = size / 1024;
+
+ stats_update_size(STATS_TOCACHE, size, numfiles);
+}
+
+/* update a normal stat */
+void stats_update(enum stats stat)
+{
+ stats_update_size(stat, 0, 0);
+}
+
+/* read in the stats from one dir and add to the counters */
+void stats_read(const char *stats_file, unsigned counters[STATS_END])
+{
+ int fd;
+
+ fd = open(stats_file, O_RDONLY|O_BINARY);
+ if (fd == -1) {
+ stats_default(counters);
+ return;
+ }
+ lock_fd(fd);
+ stats_read_fd(fd, counters);
+ close(fd);
+}
+
+/* sum and display the total stats for all cache dirs */
+void stats_summary(void)
+{
+ int dir, i;
+ unsigned counters[STATS_END];
+
+ memset(counters, 0, sizeof(counters));
+
+ /* add up the stats in each directory */
+ for (dir=-1;dir<=0xF;dir++) {
+ char *fname;
+
+ if (dir == -1) {
+ x_asprintf(&fname, "%s/stats", cache_dir);
+ } else {
+ x_asprintf(&fname, "%s/%1x/stats", cache_dir, dir);
+ }
+
+ stats_read(fname, counters);
+ free(fname);
+
+ /* oh what a nasty hack ... */
+ if (dir == -1) {
+ counters[STATS_MAXSIZE] = 0;
+ }
+
+ }
+
+ printf("cache directory %s\n", cache_dir);
+
+ /* and display them */
+ for (i=0;stats_info[i].message;i++) {
+ enum stats stat = stats_info[i].stat;
+
+ if (counters[stat] == 0 &&
+ !(stats_info[i].flags & FLAG_ALWAYS)) {
+ continue;
+ }
+
+ printf("%s ", stats_info[i].message);
+ if (stats_info[i].fn) {
+ stats_info[i].fn(counters[stat]);
+ printf("\n");
+ } else {
+ printf("%8u\n", counters[stat]);
+ }
+ }
+}
+
+/* zero all the stats structures */
+void stats_zero(void)
+{
+ int dir, fd;
+ unsigned i;
+ char *fname;
+ unsigned counters[STATS_END];
+
+ x_asprintf(&fname, "%s/stats", cache_dir);
+ unlink(fname);
+ free(fname);
+
+ for (dir=0;dir<=0xF;dir++) {
+ x_asprintf(&fname, "%s/%1x/stats", cache_dir, dir);
+ fd = safe_open(fname);
+ if (fd == -1) {
+ free(fname);
+ continue;
+ }
+ memset(counters, 0, sizeof(counters));
+ lock_fd(fd);
+ stats_read_fd(fd, counters);
+ for (i=0;stats_info[i].message;i++) {
+ if (!(stats_info[i].flags & FLAG_NOZERO)) {
+ counters[stats_info[i].stat] = 0;
+ }
+ }
+ write_stats(fd, counters);
+ close(fd);
+ free(fname);
+ }
+}
+
+
+/* set the per directory limits */
+int stats_set_limits(long maxfiles, long maxsize)
+{
+ int dir;
+ unsigned counters[STATS_END];
+
+ if (maxfiles != -1) {
+ maxfiles /= 16;
+ }
+ if (maxsize != -1) {
+ maxsize /= 16;
+ }
+
+ if (create_dir(cache_dir) != 0) {
+ return 1;
+ }
+
+ /* set the limits in each directory */
+ for (dir=0;dir<=0xF;dir++) {
+ char *fname, *cdir;
+ int fd;
+
+ x_asprintf(&cdir, "%s/%1x", cache_dir, dir);
+ if (create_dir(cdir) != 0) {
+ return 1;
+ }
+ x_asprintf(&fname, "%s/stats", cdir);
+ free(cdir);
+
+ memset(counters, 0, sizeof(counters));
+ fd = safe_open(fname);
+ if (fd != -1) {
+ lock_fd(fd);
+ stats_read_fd(fd, counters);
+ if (maxfiles != -1) {
+ counters[STATS_MAXFILES] = maxfiles;
+ }
+ if (maxsize != -1) {
+ counters[STATS_MAXSIZE] = maxsize;
+ }
+ write_stats(fd, counters);
+ close(fd);
+ }
+ free(fname);
+ }
+
+ return 0;
+}
+
+/* set the per directory sizes */
+void stats_set_sizes(const char *dir, size_t num_files, size_t total_size)
+{
+ int fd;
+ unsigned counters[STATS_END];
+ char *stats_file;
+
+ create_dir(dir);
+ x_asprintf(&stats_file, "%s/stats", dir);
+
+ memset(counters, 0, sizeof(counters));
+
+ fd = safe_open(stats_file);
+ if (fd != -1) {
+ lock_fd(fd);
+ stats_read_fd(fd, counters);
+ counters[STATS_NUMFILES] = num_files;
+ counters[STATS_TOTALSIZE] = total_size;
+ write_stats(fd, counters);
+ close(fd);
+ }
+
+ free(stats_file);
+}
diff --git a/CCache/test.sh b/CCache/test.sh
new file mode 100755
index 000000000..9581c85e3
--- /dev/null
+++ b/CCache/test.sh
@@ -0,0 +1,452 @@
+#!/bin/sh
+
+# a simple test suite for ccache
+# tridge@samba.org
+
+if test -n "$CC"; then
+ COMPILER="$CC"
+else
+ COMPILER=cc
+fi
+
+if test -n "$SWIG"; then
+ SWIG="$SWIG"
+else
+ SWIG=swig
+fi
+
+CCACHE=../ccache-swig
+TESTDIR=test.$$
+
+test_failed() {
+ reason="$1"
+ echo $1
+ $CCACHE -s
+ cd ..
+ rm -rf $TESTDIR
+ echo TEST FAILED
+ exit 1
+}
+
+randcode() {
+ outfile="$1"
+ nlines=$2
+ i=0;
+ (
+ while [ $i -lt $nlines ]; do
+ echo "int foo$nlines$i(int x) { return x; }"
+ i=`expr $i + 1`
+ done
+ ) >> "$outfile"
+}
+
+genswigcode() {
+ outfile="$1"
+ nlines=$2
+ i=0;
+ (
+ echo "%module swigtest$2;"
+ while [ $i -lt $nlines ]; do
+ echo "int foo$nlines$i(int x);"
+ echo "struct Bar$nlines$i { int y; };"
+ i=`expr $i + 1`
+ done
+ ) >> "$outfile"
+}
+
+
+getstat() {
+ stat="$1"
+ value=`$CCACHE -s | grep "$stat" | cut -c34-40`
+ echo $value
+}
+
+checkstat() {
+ stat="$1"
+ expected_value="$2"
+ value=`getstat "$stat"`
+# echo "exp: $expected_value got: $value $testname"
+ if [ "$expected_value" != "$value" ]; then
+ test_failed "SUITE: $testsuite TEST: $testname - Expected $stat to be $expected_value got $value"
+ fi
+}
+
+
+basetests() {
+ echo "starting testsuite $testsuite"
+ rm -rf "$CCACHE_DIR"
+ checkstat 'cache hit' 0
+ checkstat 'cache miss' 0
+
+ j=1
+ rm -f *.c
+ while [ $j -lt 32 ]; do
+ randcode test$j.c $j
+ j=`expr $j + 1`
+ done
+
+ testname="BASIC"
+ $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 0
+ checkstat 'cache miss' 1
+
+ testname="BASIC2"
+ $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 1
+ checkstat 'cache miss' 1
+
+ testname="debug"
+ $CCACHE_COMPILE -c test1.c -g
+ checkstat 'cache hit' 1
+ checkstat 'cache miss' 2
+
+ testname="debug2"
+ $CCACHE_COMPILE -c test1.c -g
+ checkstat 'cache hit' 2
+ checkstat 'cache miss' 2
+
+ testname="output"
+ $CCACHE_COMPILE -c test1.c -o foo.o
+ checkstat 'cache hit' 3
+ checkstat 'cache miss' 2
+
+ testname="link"
+ $CCACHE_COMPILE test1.c -o test 2> /dev/null
+ checkstat 'called for link' 1
+
+ testname="multiple"
+ $CCACHE_COMPILE -c test1.c test2.c
+ checkstat 'multiple source files' 1
+
+ testname="find"
+ $CCACHE blahblah -c test1.c 2> /dev/null
+ checkstat "couldn't find the compiler" 1
+
+ testname="bad"
+ $CCACHE_COMPILE -c test1.c -I 2> /dev/null
+ checkstat 'bad compiler arguments' 1
+
+ testname="c/c++"
+ ln -f test1.c test1.ccc
+ $CCACHE_COMPILE -c test1.ccc 2> /dev/null
+ checkstat 'not a C/C++ file' 1
+
+ testname="unsupported"
+ $CCACHE_COMPILE -M foo -c test1.c > /dev/null 2>&1
+ checkstat 'unsupported compiler option' 1
+
+ testname="stdout"
+ $CCACHE echo foo -c test1.c > /dev/null
+ checkstat 'compiler produced stdout' 1
+
+ testname="non-regular"
+ mkdir testd
+ $CCACHE_COMPILE -o testd -c test1.c > /dev/null 2>&1
+ rmdir testd
+ checkstat 'output to a non-regular file' 1
+
+ testname="no-input"
+ $CCACHE_COMPILE -c -O2 2> /dev/null
+ checkstat 'no input file' 1
+
+
+ testname="CCACHE_DISABLE"
+ CCACHE_DISABLE=1 $CCACHE_COMPILE -c test1.c 2> /dev/null
+ checkstat 'cache hit' 3
+ $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 4
+
+ testname="CCACHE_CPP2"
+ CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O
+ checkstat 'cache hit' 4
+ checkstat 'cache miss' 3
+
+ CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O
+ checkstat 'cache hit' 5
+ checkstat 'cache miss' 3
+
+ testname="CCACHE_NOSTATS"
+ CCACHE_NOSTATS=1 $CCACHE_COMPILE -c test1.c -O -O
+ checkstat 'cache hit' 5
+ checkstat 'cache miss' 3
+
+ testname="CCACHE_RECACHE"
+ CCACHE_RECACHE=1 $CCACHE_COMPILE -c test1.c -O -O
+ checkstat 'cache hit' 5
+ checkstat 'cache miss' 4
+
+ # strictly speaking should be 6 - RECACHE causes a double counting!
+ checkstat 'files in cache' 8
+ $CCACHE -c > /dev/null
+ checkstat 'files in cache' 6
+
+
+ testname="CCACHE_HASHDIR"
+ CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O
+ checkstat 'cache hit' 5
+ checkstat 'cache miss' 5
+
+ CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O
+ checkstat 'cache hit' 6
+ checkstat 'cache miss' 5
+
+ checkstat 'files in cache' 8
+
+ testname="comments"
+ echo '/* a silly comment */' > test1-comment.c
+ cat test1.c >> test1-comment.c
+ $CCACHE_COMPILE -c test1-comment.c
+ rm -f test1-comment*
+ checkstat 'cache hit' 6
+ checkstat 'cache miss' 6
+
+ testname="CCACHE_UNIFY"
+ CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 6
+ checkstat 'cache miss' 7
+ mv test1.c test1-saved.c
+ echo '/* another comment */' > test1.c
+ cat test1-saved.c >> test1.c
+ CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c
+ mv test1-saved.c test1.c
+ checkstat 'cache hit' 7
+ checkstat 'cache miss' 7
+
+ testname="cache-size"
+ for f in *.c; do
+ $CCACHE_COMPILE -c $f
+ done
+ checkstat 'cache hit' 8
+ checkstat 'cache miss' 37
+ checkstat 'files in cache' 72
+ $CCACHE -F 48 -c > /dev/null
+ if [ `getstat 'files in cache'` -gt 48 ]; then
+ test_failed '-F test failed'
+ fi
+
+ testname="cpp call"
+ $CCACHE_COMPILE -c test1.c -E > test1.i
+ checkstat 'cache hit' 8
+ checkstat 'cache miss' 37
+
+ testname="direct .i compile"
+ $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 8
+ checkstat 'cache miss' 38
+
+ $CCACHE_COMPILE -c test1.i
+ checkstat 'cache hit' 9
+ checkstat 'cache miss' 38
+
+ $CCACHE_COMPILE -c test1.i
+ checkstat 'cache hit' 10
+ checkstat 'cache miss' 38
+
+ # removed these tests as some compilers (including newer versions of gcc)
+ # determine which language to use based on .ii/.i extension, and C++ may
+ # not be installed
+# testname="direct .ii file"
+# mv test1.i test1.ii
+# $CCACHE_COMPILE -c test1.ii
+# checkstat 'cache hit' 10
+# checkstat 'cache miss' 39
+
+# $CCACHE_COMPILE -c test1.ii
+# checkstat 'cache hit' 11
+# checkstat 'cache miss' 39
+
+ testname="stripc" # This test might not be portable
+ CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 10
+ checkstat 'cache miss' 39
+
+ CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 11
+ checkstat 'cache miss' 39
+
+ testname="zero-stats"
+ $CCACHE -z > /dev/null
+ checkstat 'cache hit' 0
+ checkstat 'cache miss' 0
+
+ testname="clear"
+ $CCACHE -C > /dev/null
+ checkstat 'files in cache' 0
+
+
+ rm -f test1.c
+}
+
+swigtests() {
+ echo "starting swig testsuite $testsuite"
+ rm -rf "$CCACHE_DIR"
+ checkstat 'cache hit' 0
+ checkstat 'cache miss' 0
+
+ j=1
+ rm -f *.i
+ genswigcode testswig1.i 1
+
+ testname="BASIC"
+ $CCACHE_COMPILE -java testswig1.i
+ checkstat 'cache hit' 0
+ checkstat 'cache miss' 1
+
+ checkstat 'files in cache' 6
+
+ testname="BASIC2"
+ $CCACHE_COMPILE -java testswig1.i
+ checkstat 'cache hit' 1
+ checkstat 'cache miss' 1
+
+ testname="output"
+ $CCACHE_COMPILE -java testswig1.i -o foo_wrap.c
+ checkstat 'cache hit' 1
+ checkstat 'cache miss' 2
+
+ testname="bad"
+ $CCACHE_COMPILE -java testswig1.i -I 2> /dev/null
+ checkstat 'bad compiler arguments' 1
+
+ testname="stdout"
+ $CCACHE_COMPILE -v -java testswig1.i > /dev/null
+ checkstat 'compiler produced stdout' 1
+
+ testname="non-regular"
+ mkdir testd
+ $CCACHE_COMPILE -o testd -java testswig1.i > /dev/null 2>&1
+ rmdir testd
+ checkstat 'output to a non-regular file' 1
+
+ testname="no-input"
+ $CCACHE_COMPILE -java 2> /dev/null
+ checkstat 'no input file' 1
+
+
+ testname="CCACHE_DISABLE"
+ CCACHE_DISABLE=1 $CCACHE_COMPILE -java testswig1.i 2> /dev/null
+ checkstat 'cache hit' 1
+ $CCACHE_COMPILE -java testswig1.i
+ checkstat 'cache hit' 2
+
+ testname="CCACHE_CPP2"
+ CCACHE_CPP2=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 2
+ checkstat 'cache miss' 3
+
+ CCACHE_CPP2=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 3
+ checkstat 'cache miss' 3
+
+ testname="CCACHE_NOSTATS"
+ CCACHE_NOSTATS=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 3
+ checkstat 'cache miss' 3
+
+ testname="CCACHE_RECACHE"
+ CCACHE_RECACHE=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 3
+ checkstat 'cache miss' 4
+
+ # strictly speaking should be 3x6=18 instead of 4x6=24 - RECACHE causes a double counting!
+ checkstat 'files in cache' 24
+ $CCACHE -c > /dev/null
+ checkstat 'files in cache' 18
+
+
+ testname="CCACHE_HASHDIR"
+ CCACHE_HASHDIR=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 3
+ checkstat 'cache miss' 5
+
+ CCACHE_HASHDIR=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 4
+ checkstat 'cache miss' 5
+
+ checkstat 'files in cache' 24
+
+ testname="cpp call"
+ $CCACHE_COMPILE -java -E testswig1.i > testswig1-preproc.i
+ checkstat 'cache hit' 4
+ checkstat 'cache miss' 5
+
+ testname="direct .i compile"
+ $CCACHE_COMPILE -java testswig1.i
+ checkstat 'cache hit' 5
+ checkstat 'cache miss' 5
+
+ # No cache hit due to different input file name, -nopreprocess should not be given twice to SWIG
+ $CCACHE_COMPILE -java -nopreprocess testswig1-preproc.i
+ checkstat 'cache hit' 5
+ checkstat 'cache miss' 6
+
+ $CCACHE_COMPILE -java -nopreprocess testswig1-preproc.i
+ checkstat 'cache hit' 6
+ checkstat 'cache miss' 6
+
+ testname="stripc"
+ CCACHE_STRIPC=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 7
+ checkstat 'cache miss' 6
+
+ CCACHE_STRIPC=1 $CCACHE_COMPILE -java -O -O -O testswig1.i
+ checkstat 'cache hit' 7
+ checkstat 'cache miss' 7
+
+ rm -f testswig1-preproc.i
+ rm -f testswig1.i
+}
+
+######
+# main program
+rm -rf $TESTDIR
+mkdir $TESTDIR
+cd $TESTDIR || exit 1
+CCACHE_DIR="ccache dir" # with space in directory name (like Windows default)
+mkdir "$CCACHE_DIR"
+export CCACHE_DIR
+
+testsuite="base"
+CCACHE_COMPILE="$CCACHE $COMPILER"
+basetests
+CCACHE_COMPILE="$CCACHE $SWIG"
+swigtests
+
+if test -z "$NOSOFTLINKSTEST"; then
+ testsuite="link"
+ ln -s $CCACHE $COMPILER
+ CCACHE_COMPILE="./$COMPILER"
+ basetests
+ rm "./$COMPILER"
+ ln -s $CCACHE $SWIG
+ CCACHE_COMPILE="./$SWIG"
+ swigtests
+ rm "./$SWIG"
+else
+ echo "skipping testsuite link"
+fi
+
+testsuite="hardlink"
+CCACHE_COMPILE="env CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 $CCACHE $COMPILER"
+basetests
+CCACHE_COMPILE="env CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 $CCACHE $SWIG"
+swigtests
+
+testsuite="cpp2"
+CCACHE_COMPILE="env CCACHE_CPP2=1 $CCACHE $COMPILER"
+basetests
+CCACHE_COMPILE="env CCACHE_CPP2=1 $CCACHE $SWIG"
+swigtests
+
+testsuite="nlevels4"
+CCACHE_COMPILE="env CCACHE_NLEVELS=4 $CCACHE $COMPILER"
+basetests
+
+testsuite="nlevels1"
+CCACHE_COMPILE="env CCACHE_NLEVELS=1 $CCACHE $COMPILER"
+basetests
+
+cd ..
+rm -rf $TESTDIR
+echo test done - OK
+exit 0
diff --git a/CCache/unify.c b/CCache/unify.c
new file mode 100644
index 000000000..a93d48a02
--- /dev/null
+++ b/CCache/unify.c
@@ -0,0 +1,307 @@
+/*
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+/*
+ C/C++ unifier
+
+ the idea is that changes that don't affect the resulting C code
+ should not change the hash. This is achieved by folding white-space
+ and other non-semantic fluff in the input into a single unified format.
+
+ This unifier was design to match the output of the unifier in
+ compilercache, which is flex based. The major difference is that
+ this unifier is much faster (about 2x) and more forgiving of
+ syntactic errors. Continuing on syntactic errors is important to
+ cope with C/C++ extensions in the local compiler (for example,
+ inline assembly systems).
+*/
+
+#include "ccache.h"
+
+static char *s_tokens[] = {
+ "...", ">>=", "<<=", "+=", "-=", "*=", "/=", "%=", "&=", "^=",
+ "|=", ">>", "<<", "++", "--", "->", "&&", "||", "<=", ">=",
+ "==", "!=", ";", "{", "<%", "}", "%>", ",", ":", "=",
+ "(", ")", "[", "<:", "]", ":>", ".", "&", "!", "~",
+ "-", "+", "*", "/", "%", "<", ">", "^", "|", "?",
+ 0
+};
+
+#define C_ALPHA 1
+#define C_SPACE 2
+#define C_TOKEN 4
+#define C_QUOTE 8
+#define C_DIGIT 16
+#define C_HEX 32
+#define C_FLOAT 64
+#define C_SIGN 128
+
+static struct {
+ unsigned char type;
+ unsigned char num_toks;
+ char *toks[7];
+} tokens[256];
+
+/* build up the table used by the unifier */
+static void build_table(void)
+{
+ unsigned char c;
+ int i;
+ static int done;
+
+ if (done) return;
+ done = 1;
+
+ memset(tokens, 0, sizeof(tokens));
+ for (c=0;c<128;c++) {
+ if (isalpha(c) || c == '_') tokens[c].type |= C_ALPHA;
+ if (isdigit(c)) tokens[c].type |= C_DIGIT;
+ if (isspace(c)) tokens[c].type |= C_SPACE;
+ if (isxdigit(c)) tokens[c].type |= C_HEX;
+ }
+ tokens['\''].type |= C_QUOTE;
+ tokens['"'].type |= C_QUOTE;
+ tokens['l'].type |= C_FLOAT;
+ tokens['L'].type |= C_FLOAT;
+ tokens['f'].type |= C_FLOAT;
+ tokens['F'].type |= C_FLOAT;
+ tokens['U'].type |= C_FLOAT;
+ tokens['u'].type |= C_FLOAT;
+
+ tokens['-'].type |= C_SIGN;
+ tokens['+'].type |= C_SIGN;
+
+ for (i=0;s_tokens[i];i++) {
+ c = s_tokens[i][0];
+ tokens[c].type |= C_TOKEN;
+ tokens[c].toks[tokens[c].num_toks] = s_tokens[i];
+ tokens[c].num_toks++;
+ }
+}
+
+/* buffer up characters before hashing them */
+static void pushchar(unsigned char c)
+{
+ static unsigned char buf[64];
+ static int len;
+
+ if (c == 0) {
+ if (len > 0) {
+ hash_buffer((char *)buf, len);
+ len = 0;
+ }
+ hash_buffer(NULL, 0);
+ return;
+ }
+
+ buf[len++] = c;
+ if (len == 64) {
+ hash_buffer((char *)buf, len);
+ len = 0;
+ }
+}
+
+/* hash some C/C++ code after unifying */
+static void unify(unsigned char *p, size_t size)
+{
+ size_t ofs;
+ unsigned char q;
+ int i;
+
+ build_table();
+
+ for (ofs=0; ofs 2 && p[ofs+1] == ' ' && isdigit(p[ofs+2])) {
+ do {
+ ofs++;
+ } while (ofs < size && p[ofs] != '\n');
+ ofs++;
+ } else {
+ do {
+ pushchar(p[ofs]);
+ ofs++;
+ } while (ofs < size && p[ofs] != '\n');
+ pushchar('\n');
+ ofs++;
+ }
+ continue;
+ }
+
+ if (tokens[p[ofs]].type & C_ALPHA) {
+ do {
+ pushchar(p[ofs]);
+ ofs++;
+ } while (ofs < size &&
+ (tokens[p[ofs]].type & (C_ALPHA|C_DIGIT)));
+ pushchar('\n');
+ continue;
+ }
+
+ if (tokens[p[ofs]].type & C_DIGIT) {
+ do {
+ pushchar(p[ofs]);
+ ofs++;
+ } while (ofs < size &&
+ ((tokens[p[ofs]].type & C_DIGIT) || p[ofs] == '.'));
+ if (ofs < size && (p[ofs] == 'x' || p[ofs] == 'X')) {
+ do {
+ pushchar(p[ofs]);
+ ofs++;
+ } while (ofs < size && (tokens[p[ofs]].type & C_HEX));
+ }
+ if (ofs < size && (p[ofs] == 'E' || p[ofs] == 'e')) {
+ pushchar(p[ofs]);
+ ofs++;
+ while (ofs < size &&
+ (tokens[p[ofs]].type & (C_DIGIT|C_SIGN))) {
+ pushchar(p[ofs]);
+ ofs++;
+ }
+ }
+ while (ofs < size && (tokens[p[ofs]].type & C_FLOAT)) {
+ pushchar(p[ofs]);
+ ofs++;
+ }
+ pushchar('\n');
+ continue;
+ }
+
+ if (tokens[p[ofs]].type & C_SPACE) {
+ do {
+ ofs++;
+ } while (ofs < size && (tokens[p[ofs]].type & C_SPACE));
+ continue;
+ }
+
+ if (tokens[p[ofs]].type & C_QUOTE) {
+ q = p[ofs];
+ pushchar(p[ofs]);
+ do {
+ ofs++;
+ while (ofs < size-1 && p[ofs] == '\\') {
+ pushchar(p[ofs]);
+ pushchar(p[ofs+1]);
+ ofs+=2;
+ }
+ pushchar(p[ofs]);
+ } while (ofs < size && p[ofs] != q);
+ pushchar('\n');
+ ofs++;
+ continue;
+ }
+
+ if (tokens[p[ofs]].type & C_TOKEN) {
+ q = p[ofs];
+ for (i=0;i= ofs+len && memcmp(&p[ofs], s, len) == 0) {
+ int j;
+ for (j=0;s[j];j++) {
+ pushchar(s[j]);
+ ofs++;
+ }
+ pushchar('\n');
+ break;
+ }
+ }
+ if (i < tokens[q].num_toks) {
+ continue;
+ }
+ }
+
+ pushchar(p[ofs]);
+ pushchar('\n');
+ ofs++;
+ }
+ pushchar(0);
+}
+
+
+/* hash a file that consists of preprocessor output, but remove any line
+ number information from the hash
+*/
+int unify_hash(const char *fname)
+{
+#ifdef _WIN32
+ HANDLE file;
+ HANDLE section;
+ DWORD filesize_low;
+ char *map;
+ int ret = -1;
+
+ file = CreateFileA(fname, GENERIC_READ, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, 0, NULL);
+ if (file != INVALID_HANDLE_VALUE) {
+ filesize_low = GetFileSize(file, NULL);
+ if (!(filesize_low == INVALID_FILE_SIZE && GetLastError() != NO_ERROR)) {
+ section = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, NULL);
+ CloseHandle(file);
+ if (section != NULL) {
+ map = MapViewOfFile(section, FILE_MAP_READ, 0, 0, 0);
+ CloseHandle(section);
+ if (map != NULL)
+ ret = 0;
+ }
+ }
+ }
+
+ if (ret == -1) {
+ cc_log("Failed to open preprocessor output %s\n", fname);
+ stats_update(STATS_PREPROCESSOR);
+ return -1;
+ }
+
+ /* pass it through the unifier */
+ unify((unsigned char *)map, filesize_low);
+
+ UnmapViewOfFile(map);
+
+ return 0;
+#else
+ int fd;
+ struct stat st;
+ char *map;
+
+ fd = open(fname, O_RDONLY|O_BINARY);
+ if (fd == -1 || fstat(fd, &st) != 0) {
+ cc_log("Failed to open preprocessor output %s\n", fname);
+ stats_update(STATS_PREPROCESSOR);
+ return -1;
+ }
+
+ /* we use mmap() to make it easy to handle arbitrarily long
+ lines in preprocessor output. I have seen lines of over
+ 100k in length, so this is well worth it */
+ map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (map == (char *)-1) {
+ cc_log("Failed to mmap %s\n", fname);
+ stats_update(STATS_PREPROCESSOR);
+ return -1;
+ }
+ close(fd);
+
+ /* pass it through the unifier */
+ unify((unsigned char *)map, st.st_size);
+
+ munmap(map, st.st_size);
+
+ return 0;
+#endif
+}
+
diff --git a/CCache/util.c b/CCache/util.c
new file mode 100644
index 000000000..bba232492
--- /dev/null
+++ b/CCache/util.c
@@ -0,0 +1,884 @@
+/*
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "ccache.h"
+
+static FILE *logfile;
+
+/* log a message to the CCACHE_LOGFILE location */
+void cc_log(const char *format, ...)
+{
+ va_list ap;
+ extern char *cache_logfile;
+
+ if (!cache_logfile) return;
+
+ if (!logfile) logfile = fopen(cache_logfile, "a");
+ if (!logfile) return;
+
+ va_start(ap, format);
+ vfprintf(logfile, format, ap);
+ va_end(ap);
+ fflush(logfile);
+}
+
+/* something went badly wrong! */
+void fatal(const char *msg)
+{
+ cc_log("FATAL: %s\n", msg);
+ exit(1);
+}
+
+int safe_rename(const char* oldpath, const char* newpath)
+{
+ /* safe_rename is for creating entries in the cache.
+
+ Works like rename(), but it never overwrites an existing
+ cache entry. This avoids corruption on NFS. */
+#ifndef _WIN32
+ int status = link(oldpath, newpath);
+ if( status == 0 || errno == EEXIST )
+#else
+ int status = CreateHardLinkA(newpath, oldpath, NULL) ? 0 : -1;
+ if( status == 0 || GetLastError() == ERROR_ALREADY_EXISTS )
+#endif
+ {
+ return unlink( oldpath );
+ }
+ else
+ {
+ return -1;
+ }
+}
+
+#ifndef ENABLE_ZLIB
+/* copy all data from one file descriptor to another */
+void copy_fd(int fd_in, int fd_out)
+{
+ char buf[10240];
+ int n;
+
+ while ((n = read(fd_in, buf, sizeof(buf))) > 0) {
+ if (write(fd_out, buf, n) != n) {
+ fatal("Failed to copy fd");
+ }
+ }
+}
+
+#ifndef HAVE_MKSTEMP
+/* cheap and nasty mkstemp replacement */
+static int mkstemp(char *template)
+{
+ mktemp(template);
+ return open(template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600);
+}
+#endif
+
+/* move a file using rename */
+int move_file(const char *src, const char *dest) {
+ return safe_rename(src, dest);
+}
+
+/* copy a file - used when hard links don't work
+ the copy is done via a temporary file and atomic rename
+*/
+static int copy_file(const char *src, const char *dest)
+{
+ int fd1, fd2;
+ char buf[10240];
+ int n;
+ char *tmp_name;
+ mode_t mask;
+
+ x_asprintf(&tmp_name, "%s.XXXXXX", dest);
+
+ fd1 = open(src, O_RDONLY|O_BINARY);
+ if (fd1 == -1) {
+ free(tmp_name);
+ return -1;
+ }
+
+ fd2 = mkstemp(tmp_name);
+ if (fd2 == -1) {
+ close(fd1);
+ free(tmp_name);
+ return -1;
+ }
+
+ while ((n = read(fd1, buf, sizeof(buf))) > 0) {
+ if (write(fd2, buf, n) != n) {
+ close(fd2);
+ close(fd1);
+ unlink(tmp_name);
+ free(tmp_name);
+ return -1;
+ }
+ }
+
+ close(fd1);
+
+ /* get perms right on the tmp file */
+#ifndef _WIN32
+ mask = umask(0);
+ fchmod(fd2, 0666 & ~mask);
+ umask(mask);
+#else
+ (void)mask;
+#endif
+
+ /* the close can fail on NFS if out of space */
+ if (close(fd2) == -1) {
+ unlink(tmp_name);
+ free(tmp_name);
+ return -1;
+ }
+
+ unlink(dest);
+
+ if (rename(tmp_name, dest) == -1) {
+ unlink(tmp_name);
+ free(tmp_name);
+ return -1;
+ }
+
+ free(tmp_name);
+
+ return 0;
+}
+
+/* copy a file to the cache */
+static int copy_file_to_cache(const char *src, const char *dest) {
+ return copy_file(src, dest);
+}
+
+/* copy a file from the cache */
+static int copy_file_from_cache(const char *src, const char *dest) {
+ return copy_file(src, dest);
+}
+
+#else /* ENABLE_ZLIB */
+
+/* copy all data from one file descriptor to another
+ possibly decompressing it
+*/
+void copy_fd(int fd_in, int fd_out) {
+ char buf[10240];
+ int n;
+ gzFile gz_in;
+
+ gz_in = gzdopen(dup(fd_in), "rb");
+
+ if (!gz_in) {
+ fatal("Failed to copy fd");
+ }
+
+ while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) {
+ if (write(fd_out, buf, n) != n) {
+ fatal("Failed to copy fd");
+ }
+ }
+}
+
+static int _copy_file(const char *src, const char *dest, int mode) {
+ int fd_in, fd_out;
+ gzFile gz_in, gz_out = NULL;
+ char buf[10240];
+ int n, ret;
+ char *tmp_name;
+ mode_t mask;
+ struct stat st;
+
+ x_asprintf(&tmp_name, "%s.XXXXXX", dest);
+
+ if (getenv("CCACHE_NOCOMPRESS")) {
+ mode = COPY_UNCOMPRESSED;
+ }
+
+ /* open source file */
+ fd_in = open(src, O_RDONLY);
+ if (fd_in == -1) {
+ return -1;
+ }
+
+ gz_in = gzdopen(fd_in, "rb");
+ if (!gz_in) {
+ close(fd_in);
+ return -1;
+ }
+
+ /* open destination file */
+ fd_out = mkstemp(tmp_name);
+ if (fd_out == -1) {
+ gzclose(gz_in);
+ free(tmp_name);
+ return -1;
+ }
+
+ if (mode == COPY_TO_CACHE) {
+ /* The gzip file format occupies at least 20 bytes. So
+ it will always occupy an entire filesystem block,
+ even for empty files.
+ Since most stderr files will be empty, we turn off
+ compression in this case to save space.
+ */
+ if (fstat(fd_in, &st) != 0) {
+ gzclose(gz_in);
+ close(fd_out);
+ free(tmp_name);
+ return -1;
+ }
+ if (file_size(&st) == 0) {
+ mode = COPY_UNCOMPRESSED;
+ }
+ }
+
+ if (mode == COPY_TO_CACHE) {
+ gz_out = gzdopen(dup(fd_out), "wb");
+ if (!gz_out) {
+ gzclose(gz_in);
+ close(fd_out);
+ free(tmp_name);
+ return -1;
+ }
+ }
+
+ while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) {
+ if (mode == COPY_TO_CACHE) {
+ ret = gzwrite(gz_out, buf, n);
+ } else {
+ ret = write(fd_out, buf, n);
+ }
+ if (ret != n) {
+ gzclose(gz_in);
+ if (gz_out) {
+ gzclose(gz_out);
+ }
+ close(fd_out);
+ unlink(tmp_name);
+ free(tmp_name);
+ return -1;
+ }
+ }
+
+ gzclose(gz_in);
+ if (gz_out) {
+ gzclose(gz_out);
+ }
+
+ /* get perms right on the tmp file */
+ mask = umask(0);
+ fchmod(fd_out, 0666 & ~mask);
+ umask(mask);
+
+ /* the close can fail on NFS if out of space */
+ if (close(fd_out) == -1) {
+ unlink(tmp_name);
+ free(tmp_name);
+ return -1;
+ }
+
+ unlink(dest);
+
+ if (rename(tmp_name, dest) == -1) {
+ unlink(tmp_name);
+ free(tmp_name);
+ return -1;
+ }
+
+ free(tmp_name);
+
+ return 0;
+}
+
+/* move a file to the cache, compressing it */
+int move_file(const char *src, const char *dest) {
+ int ret;
+
+ ret = _copy_file(src, dest, COPY_TO_CACHE);
+ if (ret != -1) unlink(src);
+ return ret;
+}
+
+/* copy a file to the cache, compressing it */
+static int copy_file_to_cache(const char *src, const char *dest) {
+ return _copy_file(src, dest, COPY_TO_CACHE);
+}
+
+/* copy a file from the cache, decompressing it */
+static int copy_file_from_cache(const char *src, const char *dest) {
+ return _copy_file(src, dest, COPY_FROM_CACHE);
+}
+#endif /* ENABLE_ZLIB */
+
+/* test if a file is zlib compressed */
+int test_if_compressed(const char *filename) {
+ FILE *f;
+
+ f = fopen(filename, "rb");
+ if (!f) {
+ return 0;
+ }
+
+ /* test if file starts with 1F8B, which is zlib's
+ * magic number */
+ if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) {
+ fclose(f);
+ return 0;
+ }
+
+ fclose(f);
+ return 1;
+}
+
+/* copy file to the cache with error checking taking into account compression and hard linking if desired */
+int commit_to_cache(const char *src, const char *dest, int hardlink)
+{
+ int ret = -1;
+ struct stat st;
+ if (stat(src, &st) == 0) {
+ unlink(dest);
+ if (hardlink) {
+#ifdef _WIN32
+ ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1;
+#else
+ ret = link(src, dest);
+#endif
+ }
+ if (ret == -1) {
+ ret = copy_file_to_cache(src, dest);
+ if (ret == -1) {
+ cc_log("failed to commit %s -> %s (%s)\n", src, dest, strerror(errno));
+ stats_update(STATS_ERROR);
+ }
+ }
+ } else {
+ cc_log("failed to put %s in the cache (%s)\n", src, strerror(errno));
+ stats_update(STATS_ERROR);
+ }
+ return ret;
+}
+
+/* copy file out of the cache with error checking taking into account compression and hard linking if desired */
+int retrieve_from_cache(const char *src, const char *dest, int hardlink)
+{
+ int ret = 0;
+
+ x_utimes(src);
+
+ if (strcmp(dest, "/dev/null") == 0) {
+ ret = 0;
+ } else {
+ unlink(dest);
+ /* only make a hardlink if the cache file is uncompressed */
+ if (hardlink && test_if_compressed(src) == 0) {
+#ifdef _WIN32
+ ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1;
+#else
+ ret = link(src, dest);
+#endif
+ } else {
+ ret = copy_file_from_cache(src, dest);
+ }
+ }
+
+ /* the cached file might have been deleted by some external process */
+ if (ret == -1 && errno == ENOENT) {
+ cc_log("hashfile missing for %s\n", dest);
+ stats_update(STATS_MISSING);
+ return -1;
+ }
+
+ if (ret == -1) {
+ ret = copy_file_from_cache(src, dest);
+ if (ret == -1) {
+ cc_log("failed to retrieve %s -> %s (%s)\n", src, dest, strerror(errno));
+ stats_update(STATS_ERROR);
+ return -1;
+ }
+ }
+ return ret;
+}
+
+/* make sure a directory exists */
+int create_dir(const char *dir)
+{
+ struct stat st;
+ if (stat(dir, &st) == 0) {
+ if (S_ISDIR(st.st_mode)) {
+ return 0;
+ }
+ errno = ENOTDIR;
+ return 1;
+ }
+#ifdef _WIN32
+ if (mkdir(dir) != 0 && errno != EEXIST) {
+ return 1;
+ }
+#else
+ if (mkdir(dir, 0777) != 0 && errno != EEXIST) {
+ return 1;
+ }
+#endif
+ return 0;
+}
+
+char const CACHEDIR_TAG[] =
+ "Signature: 8a477f597d28d172789f06886806bc55\n"
+ "# This file is a cache directory tag created by ccache.\n"
+ "# For information about cache directory tags, see:\n"
+ "# http://www.brynosaurus.com/cachedir/\n";
+
+int create_cachedirtag(const char *dir)
+{
+ char *filename;
+ struct stat st;
+ FILE *f;
+ x_asprintf(&filename, "%s/CACHEDIR.TAG", dir);
+ if (stat(filename, &st) == 0) {
+ if (S_ISREG(st.st_mode)) {
+ goto success;
+ }
+ errno = EEXIST;
+ goto error;
+ }
+ f = fopen(filename, "w");
+ if (!f) goto error;
+ if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) {
+ goto error;
+ }
+ if (fclose(f)) goto error;
+success:
+ free(filename);
+ return 0;
+error:
+ free(filename);
+ return 1;
+}
+
+/*
+ this is like asprintf() but dies if the malloc fails
+ note that we use vsnprintf in a rather poor way to make this more portable
+*/
+void x_asprintf(char **ptr, const char *format, ...)
+{
+ va_list ap;
+
+ *ptr = NULL;
+ va_start(ap, format);
+ if (vasprintf(ptr, format, ap) == -1) {
+ fatal("out of memory in x_asprintf");
+ }
+ va_end(ap);
+
+ if (!ptr) fatal("out of memory in x_asprintf");
+}
+
+/*
+ this is like strdup() but dies if the malloc fails
+*/
+char *x_strdup(const char *s)
+{
+ char *ret;
+ ret = strdup(s);
+ if (!ret) {
+ fatal("out of memory in strdup\n");
+ }
+ return ret;
+}
+
+/*
+ this is like malloc() but dies if the malloc fails
+*/
+void *x_malloc(size_t size)
+{
+ void *ret;
+ ret = malloc(size);
+ if (!ret) {
+ fatal("out of memory in malloc\n");
+ }
+ return ret;
+}
+
+/*
+ this is like realloc() but dies if the malloc fails
+*/
+void *x_realloc(void *ptr, size_t size)
+{
+ void *p2;
+#if 1
+ /* Avoid invalid read in memcpy below */
+ p2 = realloc(ptr, size);
+ if (!p2) {
+ fatal("out of memory in x_realloc");
+ }
+#else
+ if (!ptr) return x_malloc(size);
+ p2 = malloc(size);
+ if (!p2) {
+ fatal("out of memory in x_realloc");
+ }
+ if (ptr) {
+ /* Note invalid read as the memcpy reads beyond the memory allocated by ptr */
+ memcpy(p2, ptr, size);
+ free(ptr);
+ }
+#endif
+ return p2;
+}
+
+
+/*
+ revsusive directory traversal - used for cleanup
+ fn() is called on all files/dirs in the tree
+ */
+void traverse(const char *dir, void (*fn)(const char *, struct stat *))
+{
+ DIR *d;
+ struct dirent *de;
+
+ d = opendir(dir);
+ if (!d) return;
+
+ while ((de = readdir(d))) {
+ char *fname;
+ struct stat st;
+
+ if (strcmp(de->d_name,".") == 0) continue;
+ if (strcmp(de->d_name,"..") == 0) continue;
+
+ if (strlen(de->d_name) == 0) continue;
+
+ x_asprintf(&fname, "%s/%s", dir, de->d_name);
+#ifdef _WIN32
+ if (stat(fname, &st))
+#else
+ if (lstat(fname, &st))
+#endif
+ {
+ if (errno != ENOENT) {
+ perror(fname);
+ }
+ free(fname);
+ continue;
+ }
+
+ if (S_ISDIR(st.st_mode)) {
+ traverse(fname, fn);
+ }
+
+ fn(fname, &st);
+ free(fname);
+ }
+
+ closedir(d);
+}
+
+
+/* return the base name of a file - caller frees */
+char *str_basename(const char *s)
+{
+ char *p = strrchr(s, '/');
+ if (p) {
+ s = (p+1);
+ }
+
+#ifdef _WIN32
+ p = strrchr(s, '\\');
+
+ if (p) {
+ s = (p+1);
+ }
+#endif
+
+ return x_strdup(s);
+}
+
+/* return the dir name of a file - caller frees */
+char *dirname(char *s)
+{
+ char *p;
+ s = x_strdup(s);
+ p = strrchr(s, '/');
+#ifdef _WIN32
+ p = strrchr(s, '\\');
+#endif
+ if (p) {
+ *p = 0;
+ }
+ return s;
+}
+
+/*
+ http://www.ecst.csuchico.edu/~beej/guide/ipc/flock.html
+ http://cvs.php.net/viewvc.cgi/php-src/win32/flock.c?revision=1.2&view=markup
+ Should return 0 for success, >0 otherwise
+ */
+int lock_fd(int fd)
+{
+#ifdef _WIN32
+# if 1
+ return _locking(fd, _LK_NBLCK, 1);
+# else
+ HANDLE fl = (HANDLE)_get_osfhandle(fd);
+ OVERLAPPED o;
+ memset(&o, 0, sizeof(o));
+ return (LockFileEx(fl, LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &o))
+ ? 0 : GetLastError();
+# endif
+#else
+ struct flock fl;
+ int ret;
+
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 1;
+ fl.l_pid = 0;
+
+ /* not sure why we would be getting a signal here,
+ but one user claimed it is possible */
+ do {
+ ret = fcntl(fd, F_SETLKW, &fl);
+ } while (ret == -1 && errno == EINTR);
+ return ret;
+#endif
+}
+
+/* return size on disk of a file */
+size_t file_size(struct stat *st)
+{
+#ifdef _WIN32
+ return (st->st_size + 1023) & ~1023;
+#else
+ size_t size = st->st_blocks * 512;
+ if ((size_t)st->st_size > size) {
+ /* probably a broken stat() call ... */
+ size = (st->st_size + 1023) & ~1023;
+ }
+ return size;
+#endif
+}
+
+
+/* a safe open/create for read-write */
+int safe_open(const char *fname)
+{
+ int fd = open(fname, O_RDWR|O_BINARY);
+ if (fd == -1 && errno == ENOENT) {
+ fd = open(fname, O_RDWR|O_CREAT|O_EXCL|O_BINARY, 0666);
+ if (fd == -1 && errno == EEXIST) {
+ fd = open(fname, O_RDWR|O_BINARY);
+ }
+ }
+ return fd;
+}
+
+/* display a kilobyte unsigned value in M, k or G */
+void display_size(unsigned v)
+{
+ if (v > 1024*1024) {
+ printf("%8.1f Gbytes", v/((double)(1024*1024)));
+ } else if (v > 1024) {
+ printf("%8.1f Mbytes", v/((double)(1024)));
+ } else {
+ printf("%8u Kbytes", v);
+ }
+}
+
+/* return a value in multiples of 1024 give a string that can end
+ in K, M or G
+*/
+size_t value_units(const char *s)
+{
+ char m;
+ double v = atof(s);
+ m = s[strlen(s)-1];
+ switch (m) {
+ case 'G':
+ case 'g':
+ default:
+ v *= 1024*1024;
+ break;
+ case 'M':
+ case 'm':
+ v *= 1024;
+ break;
+ case 'K':
+ case 'k':
+ v *= 1;
+ break;
+ }
+ return (size_t)v;
+}
+
+
+/*
+ a sane realpath() function, trying to cope with stupid path limits and
+ a broken API
+*/
+char *x_realpath(const char *path)
+{
+#ifdef _WIN32
+ char namebuf[MAX_PATH];
+ DWORD ret;
+
+ ret = GetFullPathNameA(path, sizeof(namebuf), namebuf, NULL);
+ if (ret == 0 || ret >= sizeof(namebuf)) {
+ return NULL;
+ }
+
+ return x_strdup(namebuf);
+#else
+ int maxlen;
+ char *ret, *p;
+#ifdef PATH_MAX
+ maxlen = PATH_MAX;
+#elif defined(MAXPATHLEN)
+ maxlen = MAXPATHLEN;
+#elif defined(_PC_PATH_MAX)
+ maxlen = pathconf(path, _PC_PATH_MAX);
+#endif
+ if (maxlen < 4096) maxlen = 4096;
+
+ ret = x_malloc(maxlen);
+
+#if HAVE_REALPATH
+ p = realpath(path, ret);
+#else
+ /* yes, there are such systems. This replacement relies on
+ the fact that when we call x_realpath we only care about symlinks */
+ {
+ int len = readlink(path, ret, maxlen-1);
+ if (len == -1) {
+ free(ret);
+ return NULL;
+ }
+ ret[len] = 0;
+ p = ret;
+ }
+#endif
+ if (p) {
+ p = x_strdup(p);
+ free(ret);
+ return p;
+ }
+ free(ret);
+ return NULL;
+#endif
+}
+
+/* a getcwd that will returns an allocated buffer */
+char *gnu_getcwd(void)
+{
+ unsigned size = 128;
+
+ while (1) {
+ char *buffer = (char *)x_malloc(size);
+ if (getcwd(buffer, size) == buffer) {
+ return buffer;
+ }
+ free(buffer);
+ if (errno != ERANGE) {
+ return 0;
+ }
+ size *= 2;
+ }
+}
+
+/* create an empty file */
+int create_empty_file(const char *fname)
+{
+ int fd;
+
+ fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
+ if (fd == -1) {
+ return -1;
+ }
+ close(fd);
+ return 0;
+}
+
+/*
+ return current users home directory or die
+*/
+const char *get_home_directory(void)
+{
+#ifdef _WIN32
+ static char home_path[MAX_PATH] = {0};
+ HRESULT ret;
+
+ /* we already have the path */
+ if (home_path[0] != 0) {
+ return home_path;
+ }
+
+ /* get the path to "Application Data" folder */
+ ret = SHGetFolderPathA(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, home_path);
+ if (SUCCEEDED(ret)) {
+ return home_path;
+ }
+
+ fprintf(stderr, "ccache: Unable to determine home directory\n");
+ return NULL;
+#else
+ const char *p = getenv("HOME");
+ if (p) {
+ return p;
+ }
+#ifdef HAVE_GETPWUID
+ {
+ struct passwd *pwd = getpwuid(getuid());
+ if (pwd) {
+ return pwd->pw_dir;
+ }
+ }
+#endif
+ fatal("Unable to determine home directory");
+ return NULL;
+#endif
+}
+
+int x_utimes(const char *filename)
+{
+#ifdef HAVE_UTIMES
+ return utimes(filename, NULL);
+#else
+ return utime(filename, NULL);
+#endif
+}
+
+#ifdef _WIN32
+/* perror for Win32 API calls, using GetLastError() instead of errno */
+void perror_win32(LPTSTR pszFunction)
+{
+ LPTSTR pszMessage;
+ DWORD dwLastError = GetLastError();
+
+ FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ dwLastError,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR)&pszMessage,
+ 0, NULL );
+
+ fprintf(stderr, "%s: %s\n", pszFunction, pszMessage);
+ LocalFree(pszMessage);
+}
+#endif
diff --git a/CCache/web/index.html b/CCache/web/index.html
new file mode 100644
index 000000000..4af839135
--- /dev/null
+++ b/CCache/web/index.html
@@ -0,0 +1,158 @@
+
+
+
+ccache
+
+
+
ccache
+
+ccache is a compiler cache. It acts as a caching pre-processor to
+C/C++ compilers, using the -E compiler switch and a hash to detect
+when a compilation can be satisfied from cache. This often results in
+a 5 to 10 times speedup in common compilations.
+
+The idea came from Erik Thiele wrote the original compilercache program
+as a bourne shell script. ccache is a re-implementation of Erik's idea
+in C with more features and better performance.
+
+
Latest release
+
+The latest release is ccache 2.4.
+
+
+
Added CCACHE_READONLY option
+
Added CCACHE_TEMPDIR option
+
fixed handling of hard-linked compilers on AIX
+
added O_BINARY support, to try and support win32 compiles
+
show cache directory in stats output
+
fixed handling of HOME environment variable
+
+
+See the manual page for details
+on the new options.
NOTE! This release changes the hash input slighly, so you will
+probably find that you will not get any hits against your existing
+cache when you upgrade.
+
+
Why bother?
+
+Why bother with a compiler cache? If you ever run "make clean; make"
+then you can probably benefit from ccache. It is very common for
+developers to do a clean build of a project for a whole host of
+reasons, and this throws away all the information from your previous
+compiles.
+
+By using ccache you can get exactly the same effect as "make clean;
+make" but much faster. It also helps a lot when doing RPM builds,
+as RPM can make doing incremental builds tricky.
+
+I put the effort into writing ccache for 2 reasons. The first is the
+Samba build farm
+(http://build.samba.org/)
+which constantly does clean builds of Samba on about 30 machines after each
+CVS commit. On some of those machines the build took over an hour. By
+using ccache we get the same effect as clean builds but about 6 times
+faster.
+
+The second reason is the autobuild system I used to run for
+Quantum. That system builds our whole Linux based OS from scratch
+after every CVS commit to catch compilation problems quickly. Using
+ccache those builds are much faster.
+
+
Is it safe?
+
+Yes. The most important aspect of a compiler cache is to always
+produce exactly the same output that the real compiler would
+produce. The includes providing exactly the same object files and
+exactly the same compiler warnings that would be produced if you use
+the real compiler. The only way you should be able to tell that you
+are using ccache is the speed.
+
+I have coded ccache very carefully to try to provide these guarantees.
+
+
+
+Here are some results for compiling Samba on my Linux laptop. I have
+also included the results of using Erik's compilercache program
+(version 1.0.10) for comparison.
+
+
+
ccache
compilercache
+
normal
13m 4s
13m 4s
+
uncached
13m 15s
15m 41s
+
cached
2m 45s
4m 26s
+
+
+
How to use it
+
+You can use ccache in two ways. The first is just to prefix your
+compile commands with "ccache". For example, you could change the
+"CC=gcc" line in your Makefile to be "CC=ccache gcc".
+
+Alternatively, you can create symbolic links from your compilers name
+to ccache. This allows you to use ccache without any changes to your
+build system.
+
+
A mailing
+list is available for discussion of ccache.
+
+
+
+
+Andrew Tridgell
+bugs@ccache.samba.org
+
+
+
+
diff --git a/CHANGES b/CHANGES
index 782849c6f..d9426512b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,488 @@ SWIG (Simplified Wrapper and Interface Generator)
See CHANGES.current for current version.
+Version 1.3.39 (21 March 2009)
+==============================
+
+2009-03-19: bhy
+ [Python] Fix the memory leak related to Python 3 unicode and C char* conversion,
+ which can be shown in the following example before this fix:
+
+ from li_cstring import *
+ i=0
+ while True:
+ i += 1
+ n = str(i)*10
+ test3(n)
+
+ This fix affected SWIG_AsCharPtrAndSize() so you cannot call this function with
+ a null alloc and non-null cptr argument in Python 3, otherwise a runtime error
+ will be raised.
+
+2009-03-18: wsfulton
+ [C#] std::vector wrapper improvements for .NET 2 and also providing the
+ necessary machinery to use the std::vector wrappers with more advanced features such
+ as LINQ - the C# proxy class now derives from IEnumerable<>. The default is now to
+ generate code requiring .NET 2 as a minimum, although the C# code can be compiled
+ for .NET 1 by defining the SWIG_DOTNET_1 C# preprocessor constant. See the
+ std_vector.i file for more details.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2009-03-12: wsfulton
+ [Ruby] Fix #2676738 SWIG generated symbol name clashes.
+
+2009-03-01: bhy
+ [Python] Some fixes for Python 3.0.1 and higher support. In 3.0.1, the C API function
+ PyObject_Compare is removed, so PyObject_RichCompareBool is used for replacement.
+ Struct initilization of SwigPyObject and SwigPyObject_as_number changed to reflect
+ the drop of tp_compare and nb_long.
+
+2009-03-01: bhy
+ [Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the
+ case that module already imported at other place.
+
+2009-02-28: bhy
+ [Python] Fix SF#2637352. Move struct declaration of SWIG_module in pyinit.swg before
+ the method calls, since some C compiler don't allow declaration in middle of function
+ body.
+
+2009-02-21: wsfulton
+ [Allegrocl] Fix seg fault wrapping some constant variable (%constant) types.
+
+2009-02-20: wsfulton
+ [CFFI] Fix seg faults when for %extend and using statements.
+
+2009-02-20: wsfulton
+ Fix SF #2605955: -co option which broke in 1.3.37.
+
+2009-02-20: wsfulton
+ New %insert("begin") section added. Also can be used as %begin. This is a new
+ code section reserved entirely for users and the code within the section is generated
+ at the top of the C/C++ wrapper file and so provides a means to put custom code
+ into the wrapper file before anything else that SWIG generates.
+
+2009-02-17: wsfulton
+ 'make clean-test-suite' will now run clean on ALL languages. Previously it only
+ ran the correctly configured languages. This way it is now possible to clean up
+ properly after running 'make partialcheck-test-suite'.
+
+2009-02-14: wsfulton
+ Extend attribute library support for structs/classes and the accessor functions use
+ pass/return by value semantics. Two new macros are available and usage is identical
+ to %attribute. These are %attributeval for structs/classes and %attributestring for
+ string classes, like std::string. See attribute.swg for more details.
+
+2009-02-13: wsfulton
+ Add support for %extend and memberin typemaps. Previously the memberin typemaps were
+ ignored for member variables within a %extend block.
+
+2009-02-12: wsfulton
+ Remove unnecessary temporary variable when wrapping return values that are references.
+ Example of generated code for wrapping:
+
+ struct XYZ {
+ std::string& refReturn();
+ };
+
+ used to be:
+
+ std::string *result = 0 ;
+ ...
+ {
+ std::string &_result_ref = (arg1)->refReturn();
+ result = (std::string *) &_result_ref;
+ }
+
+ Now it is:
+
+ std::string *result = 0 ;
+ ...
+ result = (std::string *) &(arg1)->refReturn();
+
+2009-02-08: bhy
+ Change the SIZE mapped by %pybuffer_mutable_binary and %pybuffer_binary in pybuffer.i from
+ the length of the buffer to the number of items in the buffer.
+
+2009-02-08: wsfulton
+ Fix %feature not working for conversion operators, reported by Matt Sprague, for example:
+ %feature("cs:methodmodifiers") operator bool "protected";
+
+2009-02-07: wsfulton
+ [MzScheme] Apply #2081967 configure changes for examples to build with recent PLT versions.
+ Also fixes Makefile errors building SWIG executable when mzscheme package is installed
+ (version 3.72 approx and later).
+
+2009-02-04: talby
+ [Perl] Fix SF#2564192 reported by David Kolovratnk.
+ SWIG_AsCharPtrAndSize() now handles "get" magic.
+
+Version 1.3.38 (31 January 2009)
+================================
+
+2009-01-31: bhy
+ [Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend
+ and %pythonappend have correct indentation.
+
+2009-01-31: bhy
+ [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list
+ of static member function in generated proxy code should not have the
+ 'self' parameter.
+
+2009-01-29: wsfulton
+ Fix regression introduced in 1.3.37 where the default output directory
+ for target language specific files (in the absence of -outdir) was no
+ longer the same directory as the generated c/c++ file.
+
+2009-01-28: wsfulton
+ [Java, C#] Fix proxy class not being used when the global scope operator
+ was used for parameters passed by value. Reported by David Piepgrass.
+
+2009-01-15: wsfulton
+ [Perl] Fix seg fault when running with -v option, reported by John Ky.
+
+Version 1.3.37 (13 January 2009)
+================================
+
+2009-01-13: mgossage
+ [Lua] Added contract support for requiring that unsigned numbers are >=0
+ Rewrote much of Examples/Lua/embed3.
+ Added a lot to the Lua documentation.
+
+2009-01-13: wsfulton
+ Fix compilation error when using directors on protected virtual overloaded
+ methods reported by Sam Hendley.
+
+2009-01-12: drjoe
+ [R] Fixed handling of integer arrays
+
+2009-01-10: drjoe
+ [R] Fix integer handling in r to deal correctly with signed
+ and unsigned issues
+
+2009-01-10: wsfulton
+ Patch #1992756 from Colin McDonald - %contract not working for classes
+ in namespace
+
+2009-01-05: olly
+ Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source
+ code and remove documentation of them.
+
+2008-12-30: wsfulton
+ Bug #2430756. All the languages now define a macro in the generated C/C++
+ wrapper file indicating which language is being wrapped. The macro name is the
+ same as those defined when SWIG is run, eg SWIGJAVA, SWIGOCTAVE, SWIGCSHARP etc
+ and are listed in the "Conditional Compilation" section in the documentation.
+
+2008-12-23: wsfulton
+ [Java] Fix #2153773 - %nojavaexception was clearing the exception feature
+ instead of disabling it. Clearing checked Java exceptions also didn't work.
+ The new %clearjavaexception can be used for clearing the exception feature.
+
+2008-12-22: wsfulton
+ Fix #2432801 - Make SwigValueWrapper exception safe for when copy constructors
+ throw exceptions.
+
+2008-12-21: wsfulton
+ Apply patch #2440046 which fixes possible seg faults for member and global
+ variable char arrays when the strings are larger than the string array size.
+
+2008-12-20: wsfulton
+ The ccache compiler cache has been adapted to work with SWIG and
+ named ccache-swig. It now works with C/C++ compilers as well as SWIG
+ and can result in impressive speedups when used to recompile unchanged
+ code with either a C/C++ compiler or SWIG. Documentation is in CCache.html
+ or the installed ccache-swig man page.
+
+2008-12-12: wsfulton
+ Apply patch from Kalyanov Dmitry which fixes parsing of nested structs
+ containing comments.
+
+2008-12-12: wsfulton
+ Fix error message in some nested struct and %inline parsing error situations
+ such as unterminated strings and comments.
+
+2008-12-07: olly
+ [PHP] Fix warnings when compiling generated wrapper with GCC 4.3.
+
+2008-12-06: wsfulton
+ [PHP] Deprecate %pragma(php4). Please use %pragma(php) instead.
+ The following two warnings have been renamed:
+ WARN_PHP4_MULTIPLE_INHERITANCE -> WARN_PHP_MULTIPLE_INHERITANCE
+ WARN_PHP4_UNKNOWN_PRAGMA -> WARN_PHP_UNKNOWN_PRAGMA
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2008-12-04: bhy
+ [Python] Applied patch SF#2158938: all the SWIG symbol names started with Py
+ are changed, since they are inappropriate and discouraged in Python
+ documentation (from http://www.python.org/doc/2.5.2/api/includes.html):
+
+ "All user visible names defined by Python.h (except those defined by
+ the included standard headers) have one of the prefixes "Py" or "_Py".
+ Names beginning with "_Py" are for internal use by the Python implementation
+ and should not be used by extension writers. Structure member names do
+ not have a reserved prefix.
+
+ Important: user code should never define names that begin with "Py" or "_Py".
+ This confuses the reader, and jeopardizes the portability of the user
+ code to future Python versions, which may define additional names beginning
+ with one of these prefixes."
+
+ Here is a brief list of what changed:
+
+ PySwig* -> SwigPy*
+ PyObject_ptr -> SwigPtr_PyObject
+ PyObject_var -> SwigVar_PyObject
+ PySequence_Base, PySequence_Cont, PySequence_Ref ->
+ SwigPySequence_Base, SwigPySequence_Cont, SwigPySequence_Ref
+ PyMap* -> SwigPyMap*
+
+ We provided a pyname_compat.i for backward compatibility. Users whose code having
+ these symbols and do not want to change it could simply include this file
+ at front of your code. A better solution is to run the converting tool on
+ your code, which has been put in SWIG's SVN trunk (Tools/pyname_patch.py) and
+ you can download it here:
+ https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2008-12-02: wsfulton
+ [Python] Apply patch #2143727 from Serge Monkewitz to fix importing base classes
+ when the package option is specified in %module and that module is %import'ed.
+
+2008-11-28: wsfulton
+ [UTL] Fix #2080497. Some incorrect acceptance of types in the STL, eg a double * element
+ passed into a vector constructor would be accepted, but the ensuing behaviour
+ was undefined. Now the type conversion correctly raises an exception.
+
+2008-11-24: wsfulton
+ Add -outcurrentdir option. This sets the default output directory to the current
+ directory instead of the path specified by the input file. This option enables
+ behaviour similar to c/c++ compilers. Note that this controls the output directory,
+ but only in the absence of the -o and/or -outdir options.
+
+2008-11-23: wsfulton
+ [ruby] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in
+ ruby 1.9.
+
+2008-11-23: wsfulton
+ Apply patch #2319790 from Johan Hake to fix shared_ptr usage in std::tr1 namespace.
+
+2008-11-21: wsfulton
+ The use of the include path to find the input file is now deprecated.
+ This makes the behaviour of SWIG the same as C/C++ compilers in preparation
+ for use with ccache.
+
+2008-11-16: wsfulton
+ Fix -nopreprocess option to:
+ - correctly report file names in warning and error messages.
+ - use the original input filename that created the preprocessed output when
+ determining the C++ wrapper file name (in the absence of -o). Previously
+ the name of the input file containing the preprocessed output was used.
+
+2008-11-11: wsfulton
+ [Java] Add patch #2152691 from MATSUURA Takanori which fixes compiles using the
+ Intel compiler
+
+2008-11-01: wsfulton
+ Add patch #2128249 from Anatoly Techtonik which corrects the C/C++ proxy
+ class being reported for Python docstrings when %rename is used.
+
+2008-11-01: wsfulton
+ Add the strip encoder patch from Anatoly Techtonik #2130016. This enables an
+ easy way to rename symbols by stripping a commonly used prefix in all the
+ function/struct names. It works in the same way as the other encoders, such as
+ title, lower, command etc outlined in CHANGES file dated 12/30/2005. Example
+ below will rename wxAnotherWidget to AnotherWidget and wxDoSomething to
+ DoSomething:
+
+ %rename("%(strip:[wx])s") "";
+
+ struct wxAnotherWidget {
+ void wxDoSomething();
+ };
+
+2008-09-26: mutandiz
+ [allegrocl]
+ Lots of test-suite work.
+ - Fix ordering of wrapper output and %{ %} header output.
+ - Fix declarations of local vars in C wrappers.
+ - Fix declaration of defined constants in C wrappers.
+ - Fix declaration of EnumValues in C wrappers.
+ - add some const typemaps to allegrocl.swg
+ - add rename for operator bool() overloads.
+
+2008-09-25: olly
+ [PHP5] Fill in typemaps for SWIGTYPE and void * (SF#2095186).
+
+2008-09-22: mutandiz (Mikel Bancroft)
+ [allegrocl]
+ - Support wrapping of types whose definitions are not seen by
+ SWIG. They are treated as forward-referenced classes and if a
+ definition is not seen are treated as (* :void).
+ - Don't wrap the contents of unnamed namespaces.
+ - More code cleanup. Removed some extraneous warnings.
+ - start work on having the allegrocl mod pass the cpp test-suite.
+
+2008-09-19: olly
+ [PHP5] Add typemaps for long long and unsigned long long.
+
+2008-09-18: wsfulton
+ [C#] Added C# array typemaps provided by Antti Karanta.
+ The arrays provide a way to use MarshalAs(UnmanagedType.LPArray)
+ and pinning the array using 'fixed'. See arrays_csharp.i library file
+ for details.
+
+2008-09-18: wsfulton
+ Document the optional module attribute in the %import directive,
+ see Modules.html. Add a warning for Python wrappers when the
+ module name for an imported base class is missing, requiring the
+ module attribute to be added to %import, eg
+
+ %import(module="FooModule") foo.h
+
+2008-09-18: olly
+ [PHP5] Change the default input typemap for char * to turn PHP
+ Null into C NULL (previously it was converted to an empty string).
+ The new behaviour is consistent with how the corresponding output
+ typemap works (SF#2025719).
+
+ If you want to keep the old behaviour, add the following typemap
+ to your interface file (PHP's convert_to_string_ex() function does
+ the converting from PHP Null to an empty string):
+
+ %typemap(in) char * {
+ convert_to_string_ex($input);
+ $1 = Z_STRVAL_PP($input);
+ }
+
+2008-09-18: olly
+ [PHP5] Fix extra code added to proxy class constructors in the case
+ where the only constructor takes no arguments.
+
+2008-09-18: olly
+ [PHP5] Fix wrapping of a renamed enumerated value of an enum class
+ member (SF#2095273).
+
+2008-09-17: mutandiz (Mikel Bancroft)
+ [allegrocl]
+ - Fix how forward reference typedefs are handled, so as not to conflict
+ with other legit typedefs.
+ - Don't (for now) perform an ffitype typemap lookup when trying to
+ when calling compose_foreign_type(). This is actually a useful thing
+ to do in certain cases, the test cases for which I can't currently
+ locate :/. It's breaking some wrapping behavior that is more commonly
+ seen, however. I'll readd in a more appropriate way when I can
+ recreate the needed test case, or a user complains (which means
+ they probably have a test case).
+ - document the -isolate command-line arg in the 'swig -help' output.
+ It was in the html docs, but not there.
+ - small amount of code cleanup, removed some unused code.
+ - some minor aesthetic changes.
+
+2008-09-12: bhy
+ [Python] Python 3.0 support branch merged into SWIG trunk. Thanks to
+ Google Summer of Code 2008 for supporting this project! By default
+ SWIG will generate interface files compatible with both Python 2.x
+ and 3.0. And there's also some Python 3 new features that can be
+ enabled by passing a "-py3" command line option to SWIG. These
+ features are:
+
+ - Function annotation support
+ Also, the parameter list of proxy function will be generated,
+ even without the "-py3" option. However, the parameter list
+ will fallback to *args if the function (or method) is overloaded.
+ - Buffer interface support
+ - Abstract base class support
+
+ For details of Python 3 support and these features, please see the
+ "Python 3 Support" section in the "SWIG and Python" chapter of the SWIG
+ documentation.
+
+ The "-apply" command line option and support of generating codes
+ using apply() is removed. Since this is only required by very old
+ Python.
+
+ This merge also patched SWIG's parser to solve a bug. By this patch,
+ SWIG features able to be correctly applied on C++ conversion operator,
+ such like this:
+
+ %feature("shadow") *::operator bool %{ ... %}
+
+2008-09-02: richardb
+ [Python] Commit patch #2089149: Director exception handling mangles
+ returned exception. Exceptions raised by Python code in directors
+ are now passed through to the caller without change. Also, remove
+ the ": " prefix which used to be added to other director exceptions
+ (eg, those due to incorrect return types).
+
+2008-09-02: wsfulton
+ [Python] Commit patch #1988296 GCItem multiple module linking issue when using
+ directors.
+
+2008-09-02: wsfulton
+ [C#] Support for 'using' and 'fixed' blocks in the 'csin' typemap is now
+ possible through the use of the pre attribute and the new terminator attribute, eg
+
+ %typemap(csin,
+ pre=" using (CDate temp$csinput = new CDate($csinput)) {",
+ terminator=" } // terminate temp$csinput using block",
+ ) const CDate &
+ "$csclassname.getCPtr(temp$csinput)"
+
+ See CSharp.html for more info.
+
+2008-09-01: wsfulton
+ [CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into
+ no-eval context in DEFCENUM
+
+2008-08-02: wuzzeb
+ [Chicken,Allegro] Commit Patch 2019314
+ Fixes a build error in chicken, and several build errors and other errors
+ in Allegro CL
+
+2008-07-19: wsfulton
+ Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson.
+
+2008-07-17: wsfulton
+ Fix SF #2019156 Configuring with --without-octave or --without-alllang
+ did not disable octave.
+
+2008-07-14: wsfulton
+ [Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly
+ marshalled to C#/Java null in director methods.
+
+2008-07-04: olly
+ [PHP] For std_vector.i and std_map.i, rename empty() to is_empty()
+ since "empty" is a PHP reserved word. Based on patch from Mark Klein
+ in SF#1943417.
+
+2008-07-04: olly
+ [PHP] The deprecated command line option "-make" has been removed.
+ Searches on Google codesearch suggest that nobody is using it now
+ anyway.
+
+2008-07-04: olly
+ [PHP] The SWIG cdata.i library module is now supported.
+
+2008-07-03: olly
+ [PHP] The deprecated command line option "-phpfull" has been
+ removed. We recommend building your extension as a dynamically
+ loadable module.
+
+2008-07-02: olly
+ [PHP4] Support for PHP4 has been removed. The PHP developers are
+ no longer making new PHP4 releases, and won't even be providing
+ patches for critical security issues after 2008-08-08.
+
+2008-07-02: olly
+ [Python] Import the C extension differently for Python 2.6 and
+ later so that an implicit relative import doesn't produce a
+ deprecation warning for 2.6 and a failure for 2.7 and later.
+ Patch from Richard Boulton in SF#2008229, plus follow-up patches
+ from Richard and Haoyu Bai.
+
Version 1.3.36 (24 June 2008)
=============================
@@ -477,7 +959,7 @@ Version 1.3.34 (27 February 2008)
};
Version 1.3.33 (November 23, 2007)
-=================================
+==================================
11/21/2007: mikel
[allegrocl] omit private slot type info in the classes/types
@@ -1409,7 +1891,7 @@ Version 1.3.31 (November 20, 2006)
[lua] update to typemap for object by value, to make it c89 compliant
Version 1.3.30 (November 13, 2006)
-=================================
+==================================
11/12/2006: wsfulton
[java] Remove DetachCurrentThread patch from 08/11/2006 - it causes segfaults
@@ -5732,7 +6214,7 @@ Version 1.3.24 (December 14, 2004)
compile with no errors, java shows some problems.
Version 1.3.23 (November 11, 2004)
-=================================
+==================================
11/05/2004: wsfulton
Patch #982753 from Fabrice Salvaire: Adds dependencies generation for
@@ -7983,7 +8465,8 @@ Version 1.3.22 (September 4, 2004)
exception instead.
Version 1.3.21 (January 11, 2004)
-==================================
+=================================
+
01/10/2004: cheetah (William Fulton)
The output format for both warnings and errors can be selected for
integration with your favourite IDE/editor. Editors and IDEs can usually
@@ -9757,6 +10240,7 @@ Version 1.3.20 (December 17, 2003)
Version 1.3.19 (March 28, 2003)
===============================
+
03/28/2003: beazley
Variety of minor bug fixes to the 1.3.18 release including:
@@ -10343,6 +10827,7 @@ Version 1.3.18 (March 23, 2003)
Version 1.3.17 (November 22, 2002)
==================================
+
11/19/2002: beazley
Fixed [ 613922 ] preprocessor errors with HAVE_LONG_LONG.
@@ -10698,6 +11183,7 @@ Version 1.3.16 (October 14, 2002)
Version 1.3.15 (September 9, 2002)
==================================
+
09/09/2002: beazley
Fixed nasty runtime type checking bug with subtypes and inheritance
and templates.
@@ -12390,6 +12876,7 @@ Version 1.3.14 (August 12, 2002)
Version 1.3.13 (June 17, 2002)
==============================
+
06/16/2002: beazley
Fixed a bug with __FILE__ expansion in the preprocessor. On Windows,
the backslash (\) is now converted to (\\) in the string literal
@@ -15521,6 +16008,7 @@ Version 1.3.10 (December 10, 2001)
Version 1.3.9 (September 25, 2001)
==================================
+
9/25/2001: beazley
Fixed parsing problem with type declarations like
'char ** const'. SWIG parsed this correctly, but the
@@ -15533,6 +16021,7 @@ Version 1.3.9 (September 25, 2001)
Version 1.3.8 (September 23, 2001)
==================================
+
9/23/2001: beazley
Included improved distutils setup.py file in the Tools
directory (look for the setup.py.tmpl file). Contributed by
@@ -16905,7 +17394,7 @@ Version 1.3 Alpha 5
and function bodies. Preprocessor bug.
Version 1.3 Alpha 4 (September 4, 2000)
-======================================
+=======================================
9/3/00 : ttn
Added instructions for maintainers in Examples/README on how
@@ -17991,6 +18480,7 @@ Version 1.3 Alpha 1 (February 11, 2000)
Version 1.1 Patch 5 (February 5, 1998)
======================================
+
2/4/98 : Fixed a bug in the configure script when different package
locations are specified (--with-tclincl, etc...).
@@ -18243,6 +18733,7 @@ Version 1.1 Patch 3 (November 24, 1997)
Version 1.1 Patch 2 (September 4, 1997)
=======================================
+
9/4/97 : Fixed problem with handling of virtual functions that
was introduced by some changes in the C++ module.
@@ -19378,7 +19869,7 @@ This release should fix most, if not all, of those problems.
it generated alot of unnecessary code).
Version 1.1 Beta3 (January 9, 1997)
-====================================
+===================================
Note : A *huge* number of changes related to ongoing modifications.
@@ -19501,6 +19992,7 @@ Version 1.1 Beta1 (October 30, 1996)
Version 1.0 Final (August 31, 1996)
===================================
+
1. Fixed minor bug in C++ module
2. Fixed minor bug in pointer type-checker when using
@@ -19584,7 +20076,7 @@ number of immediate problems :
3. A few minor fixes were made in the Makefile
Version 1.0 Beta 3 (June 14, 1996)
-===================================
+==================================
There are lots of changes in this release :
@@ -19674,6 +20166,7 @@ let me know.
Version 1.0 Beta 2 (April 26, 1996)
===================================
+
This release is identical to Beta1 except a few minor bugs are
fixed and the SWIG library has been updated to work with Tcl 7.5/Tk 4.1.
A tcl7.5 examples directory is now included.
@@ -19688,6 +20181,7 @@ A tcl7.5 examples directory is now included.
Version 1.0 Beta 1 (April 10, 1996).
=====================================
+
This is the first "semi-official" release of SWIG. It has a
number of substantial improvements over the Alpha release. These
notes are in no particular order--hope I remembered everything....
diff --git a/CHANGES.current b/CHANGES.current
index ef3fcca54..fcf35a6b5 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -1,3 +1,18 @@
-Version 1.3.36 (in progress)
-=============================
+Version 1.3.40 (in progress)
+============================
+2009-04-09: wsfulton
+ Fix #2746858 - C macro expression using floating point numbers
+
+2009-03-30: olly
+ [PHP] The default out typemap for char[ANY] now returns the string up to a
+ zero byte, or the end of the array if there is no zero byte. This
+ is the same as Python does, and seems more generally useful than
+ the previous behaviour of returning the whole contents of the array
+ including any zero bytes. If you want the old behaviour, you can provide
+ your own typemap to do this:
+
+ %typemap(out) char [ANY]
+ %{
+ RETVAL_STRINGL($1, $1_dim0, 1);
+ %}
diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html
old mode 100755
new mode 100644
index 8981f52b5..cc950db7c
--- a/Doc/Manual/Allegrocl.html
+++ b/Doc/Manual/Allegrocl.html
@@ -8,7 +8,7 @@
-
16 SWIG and Allegro Common Lisp
+
17 SWIG and Allegro Common Lisp
@@ -135,10 +135,10 @@ be unhappy to see some enterprising folk use this work to add
to it.
-
16.1 Basics
+
17.1 Basics
-
16.1.1 Running Swig
+
17.1.1 Running Swig
@@ -360,7 +360,7 @@ need to link in the Allegro shared library. The library you create from
the C++ wrapper will be what you then load into Allegro CL.
-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 an additional optional attribute called 'cshin'. It should contain the parameter type and name whenever a constructor helper function is generated due to the 'pre' or 'post' attributes. Note that 'pre', 'post' and 'cshin' attributes are not used for marshalling the property set. Please see the Date marshalling example and Date marshalling of properties example for further understanding.
+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 constructor helper function 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# using or fixed block is started.
+Note that 'pre', 'post', 'terminator' and 'cshin' attributes are not used for marshalling the property set.
+Please see the Date marshalling example and Date marshalling of properties example for further understanding of these "csin" applicable attributes.
@@ -397,7 +408,275 @@ Windows users can also get the examples working using a
Cygwin or MinGW environment for automatic configuration of the example makefiles.
Any one of the three C# compilers (Portable.NET, Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path.
-
17.3 C# Exceptions
+
18.3 C# Arrays
+
+
+
+There are various ways to pass arrays from C# to C/C++.
+The default wrapping treats arrays as pointers and as such simple type wrapper classes are generated,
+eg SWIGTYPE_p_int when wrapping the C type int [] or int *.
+This gives a rather restricted use of the underlying unmanaged code and the most practical way to use arrays is to enhance or customise
+with one of the following three approaches; namely the SWIG C arrays library, P/Invoke default array marshalling or
+pinned arrays.
+
+
+
18.3.1 The SWIG C arrays library
+
+
+
+The C arrays library keeps all the array memory in the unmanaged layer.
+The library is available to all language modules and is documented in the carrays.i library section.
+Please refer to this section for details, but for convenience, the C# usage for the two examples outlined there is shown below.
+
+
+
+For the %array_functions example, the equivalent usage would be:
+
+
+
+
+SWIGTYPE_p_double a = example.new_doubleArray(10); // Create an array
+for (int i=0; i<10; i++)
+ example.doubleArray_setitem(a,i,2*i); // Set a value
+example.print_array(a); // Pass to C
+example.delete_doubleArray(a); // Destroy array
+
+
+
+
+and for the %array_class example, the equivalent usage would be:
+
+
+
+
+doubleArray c = new doubleArray(10); // Create double[10]
+for (int i=0; i<10; i++)
+ c.setitem(i, 2*i); // Assign values
+example.print_array(c.cast()); // Pass to C
+
+
+
+
+
18.3.2 Managed arrays using P/Invoke default array marshalling
+
+
+
+In the P/Invoke default marshalling scheme, one needs to designate whether the invoked function will treat a managed
+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
+is passed to the native function.
+
+
+
+The reason for allocating a separate buffer is to leave the CLR free to relocate the managed array object
+during garbage collection. If the overhead caused by the copying is causing a significant performance penalty, consider pinning the managed array and
+passing a direct reference as described in the next section.
+
+The P/Invoke default marshalling is supported by the arrays_csharp.i library via the INPUT, OUTPUT and INOUT typemaps.
+Let's look at some example usage. Consider the following C function:
+
+
+
+void myArrayCopy(int *sourceArray, int *targetArray, int nitems);
+
+
+
+
+We can now instruct SWIG to use the default marshalling typemaps by
+
+
+
+
+%include "arrays_csharp.i"
+
+%apply int INPUT[] {int *sourceArray}
+%apply int OUTPUT[] {int *targetArray}
+
+
+
+
+As a result, we get the following method in the module class:
+
+If we look beneath the surface at the corresponding intermediary class code, we see
+that SWIG has generated code that uses attributes
+(from the System.Runtime.InteropServices namespace) to tell the CLR to use default
+marshalling for the arrays:
+
+As an example of passing an inout array (i.e. the target function will both read from and
+write to the array), consider this C function that swaps a given number of elements
+in the given arrays:
+
+
+
+
+void myArraySwap(int *array1, int *array2, int nitems);
+
+
+
+
+Now, we can instruct SWIG to wrap this by
+
+
+
+
+%include "arrays_csharp.i"
+
+%apply int INOUT[] {int *array1}
+%apply int INOUT[] {int *array2}
+
+
+
+
+This results in the module class method
+
+
+
+
+ public static void myArraySwap(int[] array1, int[] array2, int nitems) {
+ examplePINVOKE.myArraySwap(array1, array2, nitems);
+ }
+
+
+
+
+and intermediate class method
+
+
+
+
+ [DllImport("example", EntryPoint="CSharp_myArraySwap")]
+ public static extern void myArraySwap([In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg1,
+ [In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2, int jarg3);
+
+
+
+
+
18.3.3 Managed arrays using pinning
+
+
+
+It is also possible to pin a given array in memory (i.e. fix its location in memory), obtain a
+direct pointer to it, and then pass this pointer to the wrapped C/C++ function. This approach
+involves no copying, but it makes the work of the garbage collector harder as
+the managed array object can not be relocated before the fix on the array is released. You should avoid
+fixing arrays in memory in cases where the control may re-enter the managed side via a callback and/or
+another thread may produce enough garbage to trigger garbage collection.
+
+
+
+For more information, see the fixed statement in the C# language reference.
+
+
+
+
+Now let's look at an example using pinning, thus avoiding the CLR making copies
+of the arrays passed as parameters. The arrays_csharp.i library file again provides the required support via the FIXED typemaps.
+Let's use the same function from the previous section:
+
+
+
+
+void myArrayCopy(int *sourceArray, int *targetArray, int nitems);
+
+
+
+
+We now need to declare the module class method unsafe, as we are using pointers:
+
+On the method signature level the only difference to the version using P/Invoke default
+marshalling is the "unsafe" quantifier, which is required because we are handling pointers.
+
+
+
+Also the intermediate class method looks a little different from the default marshalling
+example - the method is expecting an IntPtr as the parameter type.
+
@@ -494,7 +773,7 @@ set so should only be used when a C# exception is not created.
-
17.3.1 C# exception example using "check" typemap
+
18.4.1 C# exception example using "check" typemap
@@ -676,7 +955,7 @@ method and C# code does not handle pending exceptions via the canthrow attribute
Actually it will issue this warning for any function beginning with SWIG_CSharpSetPendingException.
-
17.3.2 C# exception example using %exception
+
18.4.2 C# exception example using %exception
@@ -741,7 +1020,7 @@ The managed code generated does check for the pending exception as mentioned ear
-
17.3.3 C# exception example using exception specifications
+
18.4.3 C# exception example using exception specifications
@@ -798,7 +1077,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) {
Multiple catch handlers are generated should there be more than one exception specifications declared.
-
17.3.4 Custom C# ApplicationException example
+
18.4.4 Custom C# ApplicationException example
@@ -932,7 +1211,7 @@ try {
-
17.4 C# Directors
+
18.5 C# Directors
@@ -945,7 +1224,7 @@ The following sections provide information on the C# director implementation and
However, the Java directors section should also be read in order to gain more insight into directors.
@@ -1300,7 +1579,7 @@ However, a call from C# to CSharpDefaults.DefaultMethod() will of cours
should pass the call on to CSharpDefaults.DefaultMethod(int)using the C++ default value, as shown above.
-
17.5 C# Typemap examples
+
18.6 C# Typemap examples
This section includes a few examples of typemaps. For more examples, you
@@ -1308,7 +1587,7 @@ might look at the files "csharp.swg" and "typemaps.i" in
the SWIG library.
-
17.5.1 Memory management when returning references to member variables
+
18.6.1 Memory management when returning references to member variables
@@ -1432,7 +1711,7 @@ public class Bike : IDisposable {
Note the addReference call.
-
17.5.2 Memory management for objects passed to the C++ layer
+
18.6.2 Memory management for objects passed to the C++ layer
@@ -1551,7 +1830,7 @@ The 'cscode' typemap simply adds in the specified code into the C# proxy class.
-
17.5.3 Date marshalling using the csin typemap and associated attributes
+
18.6.3 Date marshalling using the csin typemap and associated attributes
@@ -1567,6 +1846,7 @@ Let's assume the code being wrapped is as follows:
class CDate {
public:
+ CDate();
CDate(int year, int month, int day);
int getYear();
int getMonth();
@@ -1649,8 +1929,8 @@ The typemaps to achieve this are shown below.
%typemap(cstype) const CDate& "System.DateTime"
%typemap(csin,
- pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);")
- const CDate &
+ pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);"
+ ) const CDate &
"$csclassname.getCPtr(temp$csinput)"
%typemap(cstype) CDate& "out System.DateTime"
@@ -1658,7 +1938,8 @@ The typemaps to achieve this are shown below.
pre=" CDate temp$csinput = new CDate();",
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
- cshin="out $csinput") CDate &
+ cshin="out $csinput"
+ ) CDate &
"$csclassname.getCPtr(temp$csinput)"
@@ -1763,7 +2044,8 @@ will be possible with the following CDate * typemaps
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
- cshin="ref $csinput") CDate *
+ cshin="ref $csinput"
+ ) CDate *
"$csclassname.getCPtr(temp$csinput)"
@@ -1788,7 +2070,51 @@ public class example {
-
17.5.4 A date example demonstrating marshalling of C# properties
+
+The following typemap is the same as the previous but demonstrates how a using block can be used for the temporary variable.
+The only change to the previous typemap is the introduction of the 'terminator' attribute to terminate the using block.
+The subtractYears method is nearly identical to the above addYears method.
+
+
+
+
+%typemap(csin,
+ pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ terminator=" } // terminate temp$csinput using block",
+ cshin="ref $csinput"
+ ) CDate *
+ "$csclassname.getCPtr(temp$csinput)"
+
+void subtractYears(CDate *pDate, int years) {
+ *pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay());
+}
+
+
+
+
+The resulting generated code shows the termination of the using block:
+
+
+
+
+public class example {
+ public static void subtractYears(ref System.DateTime pDate, int years) {
+ using (CDate temppDate = new CDate(pDate.Year, pDate.Month, pDate.Day)) {
+ try {
+ examplePINVOKE.subtractYears(CDate.getCPtr(temppDate), years);
+ } finally {
+ pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(), 0, 0, 0);
+ }
+ } // terminate temppDate using block
+ }
+ ...
+}
+
+
+
+
18.6.4 A date example demonstrating marshalling of C# properties
@@ -1827,7 +2153,8 @@ The typemap type required is thus CDate *. Given that the previous sect
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
- cshin="ref $csinput") CDate *
+ cshin="ref $csinput"
+ ) CDate *
"$csclassname.getCPtr(temp$csinput)"
%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{
@@ -1888,7 +2215,7 @@ Some points to note:
-
17.5.5 Turning wrapped classes into partial classes
+
18.6.5 Turning wrapped classes into partial classes
@@ -1988,7 +2315,7 @@ demonstrating that the class contains methods calling both unmanaged code -
The following example is an alternative approach to adding managed code to the generated proxy class.
-
17.5.6 Extending proxy classes with additional C# code
+
18.6.6 Extending proxy classes with additional C# code
@@ -230,7 +230,7 @@
for info on how to apply the %feature.
-
18.2.4 Functions
+
19.2.4 Functions
@@ -249,7 +249,7 @@
parameters). The return values can then be accessed with (call-with-values).
-
18.2.5 Exceptions
+
19.2.5 Exceptions
The SWIG chicken module has support for exceptions thrown from
@@ -291,7 +291,7 @@
-
18.3 TinyCLOS
+
19.3 TinyCLOS
@@ -334,7 +334,7 @@
-
18.4 Linkage
+
19.4 Linkage
@@ -355,7 +355,7 @@
-
18.4.1 Static binary or shared library linked at compile time
+
19.4.1 Static binary or shared library linked at compile time
We can easily use csc to build a static binary.
@@ -396,7 +396,7 @@ in which case the test script does not need to be linked with example.so. The t
be run with csi.
-
18.4.2 Building chicken extension libraries
+
19.4.2 Building chicken extension libraries
Building a shared library like in the above section only works if the library
@@ -454,7 +454,7 @@ distributed and used by anyone, even if SWIG is not installed.
See the Examples/chicken/egg directory in the SWIG source for an example that builds
two eggs, one using the first method and one using the second method.
-
18.4.3 Linking multiple SWIG modules with TinyCLOS
+
19.4.3 Linking multiple SWIG modules with TinyCLOS
Linking together multiple modules that share type information using the %import
@@ -478,7 +478,7 @@ with (declare (uses ...)).
To create an extension library or an egg, just create a module_load.scm file that (declare (uses ...))
all the modules.
-
18.5 Typemaps
+
19.5 Typemaps
@@ -487,7 +487,7 @@ all the modules.
Lib/chicken/chicken.swg.
-
18.6 Pointers
+
19.6 Pointers
@@ -520,7 +520,7 @@ all the modules.
type. flags is either zero or SWIG_POINTER_DISOWN (see below).
-
18.6.1 Garbage collection
+
19.6.1 Garbage collection
If the owner flag passed to SWIG_NewPointerObj is 1, NewPointerObj will add a
@@ -551,7 +551,7 @@ all the modules.
18.7.1 TinyCLOS problems with Chicken version <= 1.92
+
19.7.1 TinyCLOS problems with Chicken version <= 1.92
In Chicken versions equal to or below 1.92, TinyCLOS has a limitation such that generic methods do not properly work on methods
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index c3197b9dc..c135b7c6f 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -162,7 +162,7 @@
diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html
index e9d70e39a..ec73e5460 100644
--- a/Doc/Manual/Customization.html
+++ b/Doc/Manual/Customization.html
@@ -1019,6 +1019,20 @@ but this will:
+
+SWIG provides macros for disabling and clearing features. Many of these can be found in the swig.swg library file.
+The typical pattern is to define three macros; one to define the feature itself, one to disable the feature and one to clear the feature.
+The three macros below show this for the "except" feature:
+
@@ -89,7 +89,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.
-
34.2 Prerequisites
+
35.2 Prerequisites
@@ -119,7 +119,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of
wrapper code are driven by C++ datatypes.
-
34.3 The Big Picture
+
35.3 The Big Picture
@@ -156,7 +156,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.
-
34.4 Execution Model
+
35.4 Execution Model
@@ -201,7 +201,7 @@ latter stage of compilation.
The next few sections briefly describe some of these stages.
-
34.4.1 Preprocessing
+
35.4.1 Preprocessing
@@ -232,10 +232,11 @@ of swig.swg looks like this:
...
/* Code insertion directives such as %wrapper %{ ... %} */
-#define %init %insert("init")
-#define %wrapper %insert("wrapper")
-#define %header %insert("header")
+#define %begin %insert("begin")
#define %runtime %insert("runtime")
+#define %header %insert("header")
+#define %wrapper %insert("wrapper")
+#define %init %insert("init")
/* Access control directives */
@@ -281,7 +282,7 @@ been expanded as well as everything else that goes into the low-level
construction of the wrapper code.
-
34.4.2 Parsing
+
35.4.2 Parsing
@@ -382,7 +383,7 @@ returning a foo and taking types a and b as
arguments).
-
34.4.3 Parse Trees
+
35.4.3 Parse Trees
@@ -448,7 +449,8 @@ of the output.
The contents of each parse tree node consist of a collection of attribute/value
pairs. Internally, the nodes are simply represented by hash tables. A display of
-the entire parse-tree structure can be obtained using swig -dump_tree.
+the entire parse-tree structure can be obtained using swig -debug-top <n>, where n is
+the stage being processed.
There are a number of other parse tree display options, for example, swig -debug-module <n> will
avoid displaying system parse information and only display the parse tree pertaining to the user's module at
stage n of processing.
@@ -636,7 +638,7 @@ $ swig -c++ -python -debug-module 4 example.i
-
34.4.4 Attribute namespaces
+
35.4.4 Attribute namespaces
@@ -655,7 +657,7 @@ that matches the name of the target language. For example, python:fooperl:foo.
@@ -802,7 +804,7 @@ For example, the exception code above is simply
stored without any modifications.
-
34.4.7 Code Generation
+
35.4.7 Code Generation
@@ -924,7 +926,7 @@ public :
The role of these functions is described shortly.
-
34.4.8 SWIG and XML
+
35.4.8 SWIG and XML
@@ -937,7 +939,7 @@ internal data structures, it may be useful to keep XML in the back of
your mind as a model.
-
34.5 Primitive Data Structures
+
35.5 Primitive Data Structures
@@ -983,7 +985,7 @@ typedef Hash Typetab;
-
34.5.1 Strings
+
35.5.1 Strings
@@ -1124,7 +1126,7 @@ Returns the number of replacements made (if any).
-
34.5.2 Hashes
+
35.5.2 Hashes
@@ -1201,7 +1203,7 @@ Returns the list of hash table keys.
-
34.5.3 Lists
+
35.5.3 Lists
@@ -1290,7 +1292,7 @@ If t is not a standard object, it is assumed to be a char *
and is used to create a String object.
-
34.5.4 Common operations
+
35.5.4 Common operations
The following operations are applicable to all datatypes.
@@ -1345,7 +1347,7 @@ objects and report errors.
Gets the line number associated with x.
-
34.5.5 Iterating over Lists and Hashes
+
35.5.5 Iterating over Lists and Hashes
To iterate over the elements of a list or a hash table, the following functions are used:
@@ -1390,7 +1392,7 @@ for (j = First(j); j.item; j= Next(j)) {
-
34.5.6 I/O
+
35.5.6 I/O
Special I/O functions are used for all internal I/O. These operations
@@ -1526,7 +1528,7 @@ Similarly, the preprocessor and parser all operate on string-files.
-
34.6 Navigating and manipulating parse trees
+
35.6 Navigating and manipulating parse trees
Parse trees are built as collections of hash tables. Each node is a hash table in which
@@ -1660,7 +1662,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u
the parent so that sibling nodes are unaffected.
-
34.7 Working with attributes
+
35.7 Working with attributes
@@ -1777,7 +1779,7 @@ the attribute is optional. Swig_restore() must always be called after
function.
-
34.8 Type system
+
35.8 Type system
@@ -1786,7 +1788,7 @@ pointers, references, and pointers to members. A detailed discussion of
type theory is impossible here. However, let's cover the highlights.
-
34.8.1 String encoding of types
+
35.8.1 String encoding of types
@@ -1887,7 +1889,7 @@ make the final type, the two parts are just joined together using
string concatenation.
-
34.8.2 Type construction
+
35.8.2 Type construction
@@ -2056,7 +2058,7 @@ Returns the prefix of a type. For example, if ty is
ty is unmodified.
-
34.8.3 Type tests
+
35.8.3 Type tests
@@ -2143,7 +2145,7 @@ Checks if ty is a varargs type.
Checks if ty is a templatized type.
-
34.8.4 Typedef and inheritance
+
35.8.4 Typedef and inheritance
@@ -2245,7 +2247,7 @@ Fully reduces ty according to typedef rules. Resulting datatype
will consist only of primitive typenames.
-
@@ -2344,7 +2346,7 @@ SWIG, but is most commonly associated with type-descriptor objects
that appear in wrappers (e.g., SWIGTYPE_p_double).
-
34.9 Parameters
+
35.9 Parameters
@@ -2443,7 +2445,7 @@ included. Used to emit prototypes.
Returns the number of required (non-optional) arguments in p.
-
34.10 Writing a Language Module
+
35.10 Writing a Language Module
@@ -2458,7 +2460,7 @@ describes the creation of a minimal Python module. You should be able to extra
this to other languages.
-
34.10.1 Execution model
+
35.10.1 Execution model
@@ -2468,7 +2470,7 @@ the parsing of command line options, all aspects of code generation are controll
different methods of the Language that must be defined by your module.
-
34.10.2 Starting out
+
35.10.2 Starting out
@@ -2576,7 +2578,7 @@ that activates your module. For example, swig -python foo.i. The
messages from your new module should appear.
-
34.10.3 Command line options
+
35.10.3 Command line options
@@ -2635,7 +2637,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit
unrecognized command line option error.
-
34.10.4 Configuration and preprocessing
+
35.10.4 Configuration and preprocessing
@@ -2684,7 +2686,7 @@ an implementation file python.cxx and a configuration file
python.swg.
-
34.10.5 Entry point to code generation
+
35.10.5 Entry point to code generation
@@ -2742,7 +2744,7 @@ int Python::top(Node *n) {
-
@@ -3038,7 +3040,7 @@ but without the typemaps, there is still work to do.
-
34.10.8 Configuration files
+
35.10.8 Configuration files
@@ -3113,7 +3115,7 @@ entirely upcased.
At the end of the new section is the place to put the aforementioned
-nickname kludges (should they be needed). See Perl5 and Php4 for
+nickname kludges (should they be needed). See Perl5 for
examples of what to do. [If this is still unclear after you've read
the code, ping me and I'll expand on this further. --ttn]
@@ -3188,7 +3190,7 @@ politely displays the ignoring language message.
-
34.10.9 Runtime support
+
35.10.9 Runtime support
@@ -3197,7 +3199,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g.
the SWIG files that implement those functions.
-
34.10.10 Standard library files
+
35.10.10 Standard library files
@@ -3216,7 +3218,7 @@ The following are the minimum that are usually supported:
Please copy these and modify for any new language.
-
34.10.11 Examples and test cases
+
35.10.11 Examples and test cases
@@ -3245,7 +3247,7 @@ during this process, see the section on configuration
files.
-
34.10.12 Documentation
+
35.10.12 Documentation
@@ -3277,7 +3279,7 @@ Some topics that you'll want to be sure to address include:
if available.
-
34.10.13 Prerequisites for adding a new language module to the SWIG distribution
+
35.10.13 Prerequisites for adding a new language module to the SWIG distribution
@@ -3334,7 +3336,7 @@ should be added should there be an area not already covered by
the existing tests.
-
34.10.14 Coding style guidelines
+
35.10.14 Coding style guidelines
@@ -3358,13 +3360,13 @@ 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.
This section details guile-specific support in SWIG.
-
19.1 Meaning of "Module"
+
20.1 Meaning of "Module"
@@ -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".
-
19.2 Using the SCM or GH Guile API
+
20.2 Using the SCM or GH Guile API
The guile module can currently export wrapper files that use the guile GH interface or the
@@ -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.
-
19.3 Linkage
+
20.3 Linkage
@@ -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 linkage.
-
19.3.1 Simple Linkage
+
20.3.1 Simple Linkage
@@ -206,7 +206,7 @@ placed between the define-module form and the
SWIG_init via a preprocessor define to avoid symbol
clashes. For this case, however, passive linkage is available.
-
19.3.2 Passive Linkage
+
20.3.2 Passive Linkage
Passive linkage is just like simple linkage, but it generates an
@@ -216,7 +216,7 @@ package name (see below).
You should use passive linkage rather than simple linkage when you
are using multiple modules.
-
19.3.3 Native Guile Module Linkage
+
20.3.3 Native Guile Module Linkage
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:
-
19.3.4 Old Auto-Loading Guile Module Linkage
+
20.3.4 Old Auto-Loading Guile Module Linkage
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.
-
19.3.5 Hobbit4D Linkage
+
20.3.5 Hobbit4D Linkage
@@ -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.
-
19.4 Underscore Folding
+
20.4 Underscore Folding
@@ -320,7 +320,7 @@ complained so far.
%rename to specify the Guile name of the wrapped
functions and variables (see CHANGES).
-
19.5 Typemaps
+
20.5 Typemaps
@@ -412,7 +412,7 @@ constant will appear as a scheme variable. See
Features and the %feature directive
for info on how to apply the %feature.
-
19.6 Representation of pointers as smobs
+
20.6 Representation of pointers as smobs
@@ -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 wrong-type-arg exception is raised.
-
19.6.1 GH Smobs
+
20.6.1 GH Smobs
@@ -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.
-
19.6.2 SCM Smobs
+
20.6.2 SCM Smobs
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.
-
19.6.3 Garbage Collection
+
20.6.3 Garbage Collection
Garbage collection is a feature of the new SCM interface, and it is automatically included
@@ -491,7 +491,7 @@ is exactly like described in
Object ownership and %newobject in the SWIG manual. All typemaps use an $owner var, and
the guile module replaces $owner with 0 or 1 depending on feature:new.
-
19.7 Exception Handling
+
20.7 Exception Handling
@@ -517,7 +517,7 @@ mapping:
The default when not specified here is to use "swig-error".
See Lib/exception.i for details.
-
19.8 Procedure documentation
+
20.8 Procedure documentation
If invoked with the command-line option -procdoc
@@ -553,7 +553,7 @@ like this:
typemap argument doc. See Lib/guile/typemaps.i for
details.
-
19.9 Procedures with setters
+
20.9 Procedures with setters
For global variables, SWIG creates a single wrapper procedure
@@ -581,7 +581,7 @@ struct members, the procedures (struct-member-get
pointer) and (struct-member-set pointer
value) are not generated.
-
19.10 GOOPS Proxy Classes
+
20.10 GOOPS Proxy Classes
SWIG can also generate classes and generic functions for use with
@@ -730,7 +730,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th
%import "foo.h" before the %inline block.
-
19.10.1 Naming Issues
+
20.10.1 Naming Issues
As you can see in the example above, there are potential naming conflicts. The default exported
@@ -769,7 +769,7 @@ guile-modules. For example,
TODO: Renaming class name prefixes?
-
19.10.2 Linking
+
20.10.2 Linking
The guile-modules generated above all need to be linked together. GOOPS support requires
diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html
index 491204d1d..099454cf0 100644
--- a/Doc/Manual/Introduction.html
+++ b/Doc/Manual/Introduction.html
@@ -414,7 +414,8 @@ SWIG_LINK_LIBRARIES(example ${PYTHON_LIBRARIES})
The above example will generate native build files such as makefiles, nmake files and Visual Studio projects
-which will invoke SWIG and compile the generated C++ files into _example.so (UNIX) or _example.dll (Windows).
+which will invoke SWIG and compile the generated C++ files into _example.so (UNIX) or _example.pyd (Windows).
+For other target languages on Windows a dll, instead of a .pyd file, is usually generated.
@@ -154,7 +154,7 @@ It covers most SWIG features, but certain low-level details are covered in less
-
20.1 Overview
+
21.1 Overview
@@ -189,7 +189,7 @@ Various customisation tips and techniques using SWIG directives are covered.
The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.
-
20.2 Preliminaries
+
21.2 Preliminaries
@@ -205,7 +205,7 @@ Run make -k check from the SWIG root directory after installing SWIG on
The Java module requires your system to support shared libraries and dynamic loading.
This is the commonly used method to load JNI code so your system will more than likely support this.
-
20.2.1 Running SWIG
+
21.2.1 Running SWIG
@@ -258,7 +258,7 @@ The following sections have further practical examples and details on how you mi
compiling and using the generated files.
-
20.2.2 Additional Commandline Options
+
21.2.2 Additional Commandline Options
@@ -295,7 +295,7 @@ swig -java -help
Their use will become clearer by the time you have finished reading this section on SWIG and Java.
-
20.2.3 Getting the right header files
+
21.2.3 Getting the right header files
@@ -310,7 +310,7 @@ They are usually in directories like this:
The exact location may vary on your machine, but the above locations are typical.
-
20.2.4 Compiling a dynamic module
+
21.2.4 Compiling a dynamic module
@@ -346,16 +346,16 @@ The name of the shared library output file is important.
If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information).
The name of the module is specified using the %module directive or -module command line option.
-
20.2.5 Using your module
+
21.2.5 Using your module
To load your shared native library module in Java, simply use Java's System.loadLibrary method in a Java class:
-// main.java
+// runme.java
-public class main {
+public class runme {
static {
System.loadLibrary("example");
}
@@ -372,7 +372,7 @@ Compile all the Java files and run:
$ javac *.java
-$ java main
+$ java runme
24
$
@@ -381,7 +381,7 @@ $
If it doesn't work have a look at the following section which discusses problems loading the shared library.
-
20.2.6 Dynamic linking problems
+
21.2.6 Dynamic linking problems
@@ -394,12 +394,12 @@ You may get an exception similar to this:
-$ java main
+$ java runme
Exception in thread "main" java.lang.UnsatisfiedLinkError: no example in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1312)
at java.lang.Runtime.loadLibrary0(Runtime.java:749)
at java.lang.System.loadLibrary(System.java:820)
- at main.<clinit>(main.java:5)
+ at runme.<clinit>(runme.java:5)
@@ -426,7 +426,7 @@ The following exception is indicative of this:
-$ java main
+$ java runme
Exception in thread "main" java.lang.UnsatisfiedLinkError: libexample.so: undefined
symbol: fact
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
@@ -434,7 +434,7 @@ symbol: fact
at java.lang.ClassLoader.loadLibrary(ClassLoader.java, Compiled Code)
at java.lang.Runtime.loadLibrary0(Runtime.java, Compiled Code)
at java.lang.System.loadLibrary(System.java, Compiled Code)
- at main.<clinit>(main.java:5)
+ at runme.<clinit>(runme.java:5)
$
@@ -455,7 +455,7 @@ The following section also contains some C++ specific linking problems and solut
-
20.2.7 Compilation problems and compiling with C++
+
21.2.7 Compilation problems and compiling with C++
@@ -508,7 +508,7 @@ Finally make sure the version of JDK header files matches the version of Java th
-
20.2.8 Building on Windows
+
21.2.8 Building on Windows
@@ -517,7 +517,7 @@ You will want to produce a DLL that can be loaded by the Java Virtual Machine.
This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers.
In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.
-
20.2.8.1 Running SWIG from Visual Studio
+
21.2.8.1 Running SWIG from Visual Studio
@@ -556,7 +556,7 @@ To run the native code in the DLL (example.dll), make sure that it is in your pa
If the library fails to load have a look at Dynamic linking problems.
-
20.2.8.2 Using NMAKE
+
21.2.8.2 Using NMAKE
@@ -615,7 +615,7 @@ Of course you may want to make changes for it to work for C++ by adding in the -
-
20.3 A tour of basic C/C++ wrapping
+
21.3 A tour of basic C/C++ wrapping
@@ -625,7 +625,7 @@ variables are wrapped with JavaBean type getters and setters and so forth.
This section briefly covers the essential aspects of this wrapping.
-
20.3.1 Modules, packages and generated Java classes
+
21.3.1 Modules, packages and generated Java classes
@@ -659,7 +659,7 @@ swig -java -package com.bloggs.swig -outdir com/bloggs/swig example.i
SWIG won't create the directory, so make sure it exists beforehand.
-
@@ -920,7 +920,7 @@ Or if you decide this practice isn't so bad and your own class implements ex
-
20.3.5 Enumerations
+
21.3.5 Enumerations
@@ -934,7 +934,7 @@ The final two approaches use simple integers for each enum item.
Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.
-
20.3.5.1 Anonymous enums
+
21.3.5.1 Anonymous enums
@@ -997,7 +997,7 @@ As in the case of constants, you can access them through either the module class
-
20.3.5.2 Typesafe enums
+
21.3.5.2 Typesafe enums
@@ -1090,7 +1090,7 @@ When upgrading to JDK 1.5 or later, proper Java enums could be used instead, wit
The following section details proper Java enum generation.
@@ -1191,7 +1191,7 @@ Note that unlike typesafe enums, this approach requires users to mostly use diff
Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.
-
20.3.5.5 Simple enums
+
21.3.5.5 Simple enums
@@ -1210,7 +1210,7 @@ SWIG-1.3.21 and earlier versions wrapped all enums using this approach.
The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.
-
20.3.6 Pointers
+
21.3.6 Pointers
@@ -1298,7 +1298,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
a NULL pointer if the conversion can't be performed.
-
20.3.7 Structures
+
21.3.7 Structures
@@ -1466,7 +1466,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a
-
20.3.8 C++ classes
+
21.3.8 C++ classes
@@ -1529,7 +1529,7 @@ int bar = Spam.getBar();
-
20.3.9 C++ inheritance
+
21.3.9 C++ inheritance
@@ -1590,7 +1590,7 @@ Note that Java does not support multiple inheritance so any multiple inheritance
A warning is given when multiple inheritance is detected and only the first base class is used.
-
20.3.10 Pointers, references, arrays and pass by value
+
21.3.10 Pointers, references, arrays and pass by value
@@ -1645,7 +1645,7 @@ to hold the result and a pointer is returned (Java will release this memory
when the returned object's finalizer is run by the garbage collector).
-
20.3.10.1 Null pointers
+
21.3.10.1 Null pointers
@@ -1669,7 +1669,7 @@ For spam1 and spam4 above the Java null gets translat
The converse also occurs, that is, NULL pointers are translated into null Java objects when returned from a C/C++ function.
20.4 Further details on the generated Java classes
+
21.4 Further details on the generated Java classes
@@ -2035,7 +2035,7 @@ Finally enum classes are covered.
First, the crucial intermediary JNI class is considered.
-
20.4.1 The intermediary JNI class
+
21.4.1 The intermediary JNI class
@@ -2155,7 +2155,7 @@ If name is the same as modulename then the module class name g
from modulename to modulenameModule.
-
20.4.1.1 The intermediary JNI class pragmas
+
21.4.1.1 The intermediary JNI class pragmas
@@ -2234,7 +2234,7 @@ For example, let's change the intermediary JNI class access to public.
All the methods in the intermediary JNI class will then be callable outside of the package as the method modifiers are public by default.
-
20.4.2 The Java module class
+
21.4.2 The Java module class
@@ -2265,7 +2265,7 @@ example.egg(new Foo());
The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a Foo can be passed to the egg function, whereas any long can be passed to the egg function in the intermediary JNI class.
20.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling
+
21.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling
@@ -2857,7 +2857,11 @@ and therefore there is no possibility of premature garbage collection. In practi
The premature garbage collection prevention parameter for proxy classes is generated by default whenever proxy classes are passed by value, reference or with a pointer.
-The additional parameters do impose a slight performance overhead and the parameter generation can be suppressed globally with the -nopgcpp commandline option.
+The implementation for this extra parameter generation requires the "jtype" typemap to contain long and the "jstype" typemap to contain the name of a proxy class.
+
+
+
+The additional parameter does impose a slight performance overhead and the parameter generation can be suppressed globally with the -nopgcpp commandline option.
More selective suppression is possible with the 'nopgcpp' attribute in the "jtype" Java typemap.
The attribute is a flag and so should be set to "1" to enable the suppression, or it can be omitted or set to "0" to disable.
For example:
@@ -2871,7 +2875,7 @@ For example:
Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.
-
20.4.3.5 Single threaded applications and thread safety
+
21.4.3.5 Single threaded applications and thread safety
@@ -3046,7 +3050,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... }
-
20.4.5 Enum classes
+
21.4.5 Enum classes
@@ -3055,7 +3059,7 @@ The Enumerations section discussed these but omitted
The following sub-sections detail the various types of enum classes that can be generated.
-
20.4.5.1 Typesafe enum classes
+
21.4.5.1 Typesafe enum classes
@@ -3139,7 +3143,7 @@ The swigValue method is used for marshalling in the other direction.
The toString method is overridden so that the enum name is available.
-
20.4.5.2 Proper Java enum classes
+
21.4.5.2 Proper Java enum classes
@@ -3217,7 +3221,7 @@ These needn't be generated if the enum being wrapped does not have any initializ
Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this.
-
20.4.5.3 Type unsafe enum classes
+
21.4.5.3 Type unsafe enum classes
@@ -3248,7 +3252,7 @@ public final class Beverage {
-
20.5 Cross language polymorphism using directors
+
21.5 Cross language polymorphism using directors
@@ -3270,7 +3274,7 @@ The upshot is that C++ classes can be extended in Java and from C++ these extens
Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.
-
20.5.1 Enabling directors
+
21.5.1 Enabling directors
@@ -3341,7 +3345,7 @@ public:
-
20.5.2 Director classes
+
21.5.2 Director classes
@@ -3368,7 +3372,7 @@ If the correct implementation is in Java, the Java API is used to call the metho
-
20.5.3 Overhead and code bloat
+
21.5.3 Overhead and code bloat
@@ -3386,7 +3390,7 @@ This situation can be optimized by selectively enabling director methods (using
@@ -3471,7 +3475,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern
-
20.6 Accessing protected members
+
21.6 Accessing protected members
@@ -3567,7 +3571,7 @@ class MyProtectedBase extends ProtectedBase
-
20.7 Common customization features
+
21.7 Common customization features
@@ -3579,7 +3583,7 @@ be awkward. This section describes some common SWIG features that are used
to improve the interface to existing C/C++ code.
-
20.7.1 C/C++ helper functions
+
21.7.1 C/C++ helper functions
@@ -3645,7 +3649,7 @@ hard to implement. It is possible to improve on this using Java code, typemaps,
customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.
-
20.7.2 Class extension with %extend
+
21.7.2 Class extension with %extend
@@ -3708,7 +3712,7 @@ Vector(2,3,4)
in any way---the extensions only show up in the Java interface.
-
20.7.3 Exception handling with %exception and %javaexception
+
21.7.3 Exception handling with %exception and %javaexception
@@ -3756,7 +3760,7 @@ will produce a familiar looking Java exception:
Exception in thread "main" java.lang.OutOfMemoryError: Not enough memory
at exampleJNI.malloc(Native Method)
at example.malloc(example.java:16)
- at main.main(main.java:112)
+ at runme.main(runme.java:112)
@@ -3816,7 +3820,9 @@ public:
In the example above, java.lang.Exception is a checked exception class and so ought to be declared in the throws clause of getitem.
Classes can be specified for adding to the throws clause using %javaexception(classes) instead of %exception,
where classes is a string containing one or more comma separated Java classes.
-The %nojavaexception feature is the equivalent to %noexception and clears previously declared exception handlers.
+The %clearjavaexception feature is the equivalent to %clearexception and clears previously declared exception handlers.
+The %nojavaexception feature is the equivalent to %noexception and disables the exception handler.
+See Clearing features for the difference on disabling and clearing features.
@@ -3901,7 +3907,7 @@ strings and arrays. This chapter discusses the common techniques for
solving these problems.
-
20.8.1 Input and output parameters using primitive pointers and references
+
21.8.1 Input and output parameters using primitive pointers and references
@@ -4075,7 +4081,7 @@ void foo(Bar *OUTPUT);
will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.
-
20.8.2 Simple pointers
+
21.8.2 Simple pointers
@@ -4141,7 +4147,7 @@ System.out.println("3 + 4 = " + result);
See the SWIG Library chapter for further details.
-
20.8.3 Wrapping C arrays with Java arrays
+
21.8.3 Wrapping C arrays with Java arrays
@@ -4208,7 +4214,7 @@ Please be aware that the typemaps in this library are not efficient as all the e
There is an alternative approach using the SWIG array library and this is covered in the next section.
-
20.8.4 Unbounded C Arrays
+
21.8.4 Unbounded C Arrays
@@ -4353,7 +4359,7 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
-
20.8.5 Overriding new and delete to allocate from Java heap
+
21.8.5 Overriding new and delete to allocate from Java heap
@@ -4470,7 +4476,7 @@ model and use these functions in place of malloc and free in your own
code.
-
20.9 Java typemaps
+
21.9 Java typemaps
@@ -4491,7 +4497,7 @@ Before proceeding, it should be stressed that typemaps are not a required
part of using SWIG---the default wrapping behavior is enough in most cases.
Typemaps are only used if you want to change some aspect of the generated code.
-
20.9.1 Default primitive type mappings
+
21.9.1 Default primitive type mappings
@@ -4643,7 +4649,7 @@ However, the mappings allow the full range of values for each C type from Java.
-
20.9.2 Default typemaps for non-primitive types
+
21.9.2 Default typemaps for non-primitive types
@@ -4658,7 +4664,7 @@ So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit
The Java type is either the proxy class or type wrapper class.
-
20.9.3 Sixty four bit JVMs
+
21.9.3 Sixty four bit JVMs
@@ -4671,7 +4677,7 @@ Unfortunately it won't of course hold true for JNI code.
-
20.9.4 What is a typemap?
+
21.9.4 What is a typemap?
@@ -4794,7 +4800,7 @@ int c = example.count('e',"Hello World");
-
20.9.5 Typemaps for mapping C/C++ types to Java types
+
21.9.5 Typemaps for mapping C/C++ types to Java types
@@ -5054,7 +5060,7 @@ These are listed below:
-
20.9.6 Java typemap attributes
+
21.9.6 Java typemap attributes
@@ -5100,7 +5106,7 @@ The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes.
Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action.
-
20.9.7 Java special variables
+
21.9.7 Java special variables
@@ -5243,7 +5249,7 @@ This special variable expands to the intermediary class name. Usually this is th
unless the jniclassname attribute is specified in the %module directive.
-
20.9.8 Typemaps for both C and C++ compilation
+
21.9.8 Typemaps for both C and C++ compilation
@@ -5280,7 +5286,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps
-
20.9.9 Java code typemaps
+
21.9.9 Java code typemaps
@@ -5476,7 +5482,7 @@ For the typemap to be used in all type wrapper classes, all the different types
Again this is the same that is in "java.swg", barring the method modifier for getCPtr.
-
20.9.10 Director specific typemaps
+
21.9.10 Director specific typemaps
@@ -5701,7 +5707,7 @@ The basic strategy here is to provide a default package typemap for the majority
-
20.10 Typemap Examples
+
21.10 Typemap Examples
@@ -5711,7 +5717,7 @@ the SWIG library.
-
20.10.1 Simpler Java enums for enums without initializers
+
21.10.1 Simpler Java enums for enums without initializers
@@ -5790,7 +5796,7 @@ This would be done by using the original versions of these typemaps in "enums.sw
-
20.10.2 Handling C++ exception specifications as Java exceptions
+
21.10.2 Handling C++ exception specifications as Java exceptions
@@ -5915,7 +5921,7 @@ We could alternatively have used %rename to rename what() into
-
20.10.3 NaN Exception - exception handling for a particular type
+
21.10.3 NaN Exception - exception handling for a particular type
@@ -6070,7 +6076,7 @@ If we were a martyr to the JNI cause, we could replace the succinct code within
If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.
-
20.10.4 Converting Java String arrays to char **
+
21.10.4 Converting Java String arrays to char **
@@ -6164,9 +6170,9 @@ When this module is compiled, our wrapped C functions can be used by the followi
-// File main.java
+// File runme.java
-public class main {
+public class runme {
static {
try {
@@ -6192,7 +6198,7 @@ When compiled and run we get:
-$ java main
+$ java runme
argv[0] = Cat
argv[1] = Dog
argv[2] = Cow
@@ -6214,7 +6220,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify
what Java types to use.
-
20.10.5 Expanding a Java object to multiple arguments
+
21.10.5 Expanding a Java object to multiple arguments
@@ -6383,9 +6389,9 @@ The following Java program demonstrates this:
-// File: main.java
+// File: runme.java
-public class main {
+public class runme {
static {
try {
@@ -6410,11 +6416,11 @@ When compiled and run we get:
-$ java main
+$ java runme
1 12.0 340.0
-
20.10.7 Adding Java downcasts to polymorphic return types
+
21.10.7 Adding Java downcasts to polymorphic return types
@@ -6470,7 +6476,7 @@ We get:
Ambulance started
java.lang.ClassCastException
- at main.main(main.java:16)
+ at runme.main(runme.java:16)
@@ -6620,7 +6626,7 @@ SWIG usually generates code which constructs the proxy classes using Java code a
Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.
-
20.10.8 Adding an equals method to the Java classes
+
21.10.8 Adding an equals method to the Java classes
20.10.9 Void pointers and a common Java base class
+
21.10.9 Void pointers and a common Java base class
@@ -6723,7 +6729,7 @@ This example contains some useful functionality which you may want in your code.
It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer.
-
20.10.10 Struct pointer to pointer
+
21.10.10 Struct pointer to pointer
@@ -6903,7 +6909,7 @@ The C functional interface has been completely morphed into an object-oriented i
the Butler class would behave much like any pure Java class and feel more natural to Java users.
-
20.10.11 Memory management when returning references to member variables
+
21.10.11 Memory management when returning references to member variables
@@ -7026,7 +7032,7 @@ public class Bike {
Note the addReference call.
-
20.10.12 Memory management for objects passed to the C++ layer
+
21.10.12 Memory management for objects passed to the C++ layer
@@ -7142,7 +7148,7 @@ The 'javacode' typemap simply adds in the specified code into the Java proxy cla
-
20.10.13 Date marshalling using the javain typemap and associated attributes
+
21.10.13 Date marshalling using the javain typemap and associated attributes
@@ -7319,7 +7325,7 @@ A few things to note:
-
20.11 Living with Java Directors
+
21.11 Living with Java Directors
@@ -7500,10 +7506,10 @@ public abstract class UserVisibleFoo extends Foo {
-
20.12 Odds and ends
+
21.12 Odds and ends
-
20.12.1 JavaDoc comments
+
21.12.1 JavaDoc comments
@@ -7559,7 +7565,7 @@ public class Barmy {
-
20.12.2 Functional interface without proxy classes
+
21.12.2 Functional interface without proxy classes
@@ -7620,7 +7626,7 @@ All destructors have to be called manually for example the delete_Foo(foo)
-
20.12.3 Using your own JNI functions
+
21.12.3 Using your own JNI functions
@@ -7670,7 +7676,7 @@ This directive is only really useful if you want to mix your own hand crafted JN
-
20.12.4 Performance concerns and hints
+
21.12.4 Performance concerns and hints
@@ -7691,7 +7697,7 @@ However, you will have to be careful about memory management and make sure that
This method normally calls the C++ destructor or free() for C code.
-
20.12.5 Debugging
+
21.12.5 Debugging
@@ -7713,7 +7719,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh
@@ -316,7 +316,7 @@ In this example, the function int_to_uint() would be used to cast type
Note: When working with simple pointers, typemaps can often be used to provide more seamless operation.
-
@@ -77,7 +77,7 @@ swig -cffi -module module-namefile-name
files and the various things which you can do with them.
-
21.2.1 Additional Commandline Options
+
22.2.1 Additional Commandline Options
@@ -118,7 +118,7 @@ swig -cffi -help
-
21.2.2 Generating CFFI bindings
+
22.2.2 Generating CFFI bindings
As we mentioned earlier the ideal way to use SWIG is to use interface
@@ -392,7 +392,7 @@ The feature intern_function ensures that all C names are
-
21.2.3 Generating CFFI bindings for C++ code
+
22.2.3 Generating CFFI bindings for C++ code
This feature to SWIG (for CFFI) is very new and still far from
@@ -568,7 +568,7 @@ If you have any questions, suggestions, patches, etc., related to CFFI
module feel free to contact us on the SWIG mailing list, and
also please add a "[CFFI]" tag in the subject line.
-
21.2.4 Inserting user code into generated files
+
22.2.4 Inserting user code into generated files
@@ -583,7 +583,7 @@ using the SWIG %insert(section) %{ ...code... %} directive:
Note that the block %{ ... %} is effectively a shortcut for
-%insert("runtime") %{ ... %}.
+%insert("header") %{ ... %}.
-
21.3 CLISP
+
22.3 CLISP
@@ -638,7 +638,7 @@ swig -clisp -module module-namefile-name
interface file for the CLISP module. The CLISP module tries to
produce code which is both human readable and easily modifyable.
-
21.3.1 Additional Commandline Options
+
22.3.1 Additional Commandline Options
@@ -671,7 +671,7 @@ and global variables will be created otherwise only definitions for
-
Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). Its also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org
-
22.1 Preliminaries
+
23.1 Preliminaries
The current SWIG implementation is designed to work with Lua 5.0.x and Lua 5.1.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. ((Currently SWIG generated code has only been tested on Windows with MingW, though given the nature of Lua, is should not have problems on other OS's)). It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms).
-
22.2 Running SWIG
+
23.2 Running SWIG
@@ -90,7 +105,7 @@ This creates a C/C++ source file example_wrap.c or example_wrap.cxx
The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrappered module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module.
@@ -205,7 +220,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib
-
22.2.3 Using your module
+
23.2.3 Using your module
@@ -223,19 +238,19 @@ $ ./my_lua
>
-
22.3 A tour of basic C/C++ wrapping
+
23.3 A tour of basic C/C++ wrapping
By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.
-
22.3.1 Modules
+
23.3.1 Modules
The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.
-
22.3.2 Functions
+
23.3.2 Functions
@@ -273,7 +288,7 @@ It is also possible to rename the module with an assignment.
24
-
22.3.3 Global variables
+
23.3.3 Global variables
@@ -347,7 +362,7 @@ nil
3.142
-
22.3.4 Constants and enums
+
23.3.4 Constants and enums
@@ -370,7 +385,7 @@ example.SUNDAY=0
Constants are not guaranteed to remain constant in Lua. The name of the constant could be accidentally reassigned to refer to some other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.
-
22.3.5 Pointers
+
23.3.5 Pointers
@@ -408,7 +423,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor
nil
-
22.3.6 Structures
+
23.3.6 Structures
@@ -494,7 +509,7 @@ Because the pointer points inside the structure, you can modify the contents and
> x.a = 3 -- Modifies the same structure
-
22.3.7 C++ classes
+
23.3.7 C++ classes
@@ -555,7 +570,7 @@ It is not (currently) possible to access static members of an instance:
-- does NOT work
-
22.3.8 C++ inheritance
+
23.3.8 C++ inheritance
@@ -580,7 +595,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas
It is safe to use multiple inheritance with SWIG.
-
22.3.9 Pointers, references, values, and arrays
+
23.3.9 Pointers, references, values, and arrays
@@ -611,7 +626,7 @@ Foo spam7();
then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.
-
22.3.10 C++ overloaded functions
+
23.3.10 C++ overloaded functions
@@ -697,7 +712,7 @@ Please refer to the "SWIG and C++" chapter for more information about overloadin
Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.
-
22.3.11 C++ operators
+
23.3.11 C++ operators
@@ -809,7 +824,7 @@ It is also possible to overload the operator[], but currently this cann
};
-
22.3.12 Class extension with %extend
+
23.3.12 Class extension with %extend
@@ -864,7 +879,7 @@ true
Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).
-
22.3.13 C++ templates
+
23.3.13 C++ templates
@@ -899,7 +914,7 @@ In Lua:
Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.
-
22.3.14 C++ Smart Pointers
+
23.3.14 C++ Smart Pointers
@@ -951,7 +966,7 @@ If you ever need to access the underlying pointer returned by operator->(
> f = p:__deref__() -- Returns underlying Foo *
-
22.3.15 C++ Exceptions
+
23.3.15 C++ Exceptions
@@ -1003,8 +1018,9 @@ stack traceback:
-SWIG is able to throw numeric types, enums, chars, char*'s and std::string's without problem.
-However its not so simple for to throw objects.
+SWIG is able to throw numeric types, enums, chars, char*'s and std::string's without problem. It has also written typemaps for std::exception and its derived classes, which convert the exception into and error string.
+
+However its not so simple for to throw other types of objects.
Thrown objects are not valid outside the 'catch' block. Therefore they cannot be
returned to the interpreter.
The obvious ways to overcome this would be to either return a copy of the object, or so convert the object to a string and
@@ -1038,10 +1054,6 @@ To get a more useful behaviour out of SWIG you must either: provide a way to con
throw objects which can be copied.
-SWIG has typemaps for std::exception and its children already written, so a function which throws any of these will
-automatically have its exception converted into an error string.
-
-
If you have your own class which you want output as a string you will need to add a typemap something like this:
@@ -1098,7 +1110,271 @@ add exception specification to functions or globally (respectively).
-
22.3.16 Writing your own custom wrappers
+
23.4 Typemaps
+
+
+
This section explains what typemaps are and the usage of them. The default wrappering behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrappering. This section will be explaining how to use typemaps to best effect
+
+
23.4.1 What is a typemap?
+
+
+
A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:
+
+
%module example
+
+%typemap(in) int {
+ $1 = (int) lua_tonumber(L,$input);
+ printf("Received an integer : %d\n",$1);
+}
+%inline %{
+extern int fact(int n);
+%}
+
+
+
Note: you shouldn't use this typemap, as SWIG already has a typemap for this task. This is purely for example.
+
+
Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variable prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input is the index on the Lua stack for the value to be used.
+
+
When this example is compiled into a Lua module, it operates as follows:
There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.
+
+
However for more complex functions which use input/output parameters or arrays, you will need to make use of <typemaps.i>, which contains typemaps for these situations. For example, consider these functions:
+
+
void add(int x, int y, int *result) {
+ *result = x + y;
+}
+
+int sub(int *x1, int *y1) {
+ return *x1-*y1;
+}
+
+void swap(int *sx, int *sy) {
+ int t=*sx;
+ *sx=*sy;
+ *sy=t;
+}
+
+
+
It is clear to the programmer, that 'result' is an output parameter, 'x1' and 'y1' are input parameters and 'sx' and 'sy' are input/output parameters. However is not apparent to SWIG, so SWIG must to informed about which kind they are, so it can wrapper accordingly.
+
+
One means would be to rename the argument name to help SWIG, eg void add(int x, int y, int *OUTPUT), however it is easier to use the %apply to achieve the same result, as shown below.
+
+
%include <typemaps.i>
+%apply int* OUTPUT {int *result}; // int *result is output
+%apply int* INPUT {int *x1, int *y1}; // int *x1 and int *y1 are input
+%apply int* INOUT {int *sx, int *sy}; // int *sx and int *sy are input and output
+
+void add(int x, int y, int *result);
+int sub(int *x1, int *y1);
+void swap(int *sx, int *sy);
+
Notice, that 'result' is not required in the arguments to call the function, as it an output parameter only. For 'sx' and 'sy' they must be passed in (as they are input), but the original value is not modified (Lua does not have a pass by reference feature). The modified results are then returned as two return values. All INPUT/OUTPUT/INOUT arguments will behave in a similar manner.
+
+
Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a const int& as an input parameter (since that it obviously input).
+
+
23.4.3 Typemaps and arrays
+
+
+
Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor
+does SWIG have any indication of how large an array should be. However with the proper guidance SWIG can easily wrapper
+arrays for convenient usage.
+
+
Given the functions:
+
extern void sort_int(int* arr, int len);
+extern void sort_double(double* arr, int len);
+
+
+
There are basically two ways that SWIG can deal with this. The first way, uses the <carrays.i> library
+to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but its a bit tedious.
+More details can be found in the carrays.i documention.
+
+
The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %appy in the correct manner.
+
+
The wrapper file below, shows both the use of carrays as well as the use of the typemap to wrap arrays.
+
+
// using the C-array
+%include <carrays.i>
+// this declares a batch of function for manipulating C integer arrays
+%array_functions(int,int)
+
+extern void sort_int(int* arr, int len); // the function to wrap
+
+// using typemaps
+%include <typemaps.i>
+%apply (double *INOUT,int) {(double* arr,int len)};
+
+extern void sort_double(double* arr, int len); // the function to wrap
+
+
+
Once wrappered, the functions can both be called, though with different ease of use:
+
+
require "example"
+ARRAY_SIZE=10
+
+-- passing a C array to the sort_int()
+arr=example.new_int(ARRAY_SIZE) -- create the array
+for i=0,ARRAY_SIZE-1 do -- index 0..9 (just like C)
+ example.int_setitem(arr,i,math.random(1000))
+end
+example.sort_int(arr,ARRAY_SIZE) -- call the function
+example.delete_int(arr) -- must delete the allocated memory
+
+-- use a typemap to call with a Lua-table
+-- one item of note: the typemap creates a copy, rather than edit-in-place
+t={} -- a Lua table
+for i=1,ARRAY_SIZE do -- index 1..10 (Lua style)
+ t[i]=math.random(1000)/10
+end
+t=example.sort_double(t) -- replace t with the result
+
+
+
Obviously the first version could be made less tedious by writing a Lua function to perform the conversion from a table
+to a C-array. The %luacode directive is good for this. See SWIG\Examples\lua\arrays for an example of this.
+
+
Warning: in C indexes start at ZERO, in Lua indexes start at ONE. SWIG expects C-arrays to be filled for 0..N-1
+and Lua tables to be 1..N, (the indexing follows the norm for the language). In the typemap when it converts the table to an array it quietly changes the indexing accordingly. Take note of this behaviour if you have a C function which returns indexes.
+
+
Note: SWIG also can support arrays of pointers in a similar manner.
+
+
23.4.4 Typemaps and pointer-pointer functions
+
+
+
Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:
+
+
struct iMath; // some structure
+int Create_Math(iMath** pptr); // its creator (assume it mallocs)
+
+
+
Which would be used with the following C code:
+
+
iMath* ptr;
+int ok;
+ok=Create_Math(&ptr);
+// do things with ptr
+//...
+free(ptr); // dispose of iMath
+
+
+
SWIG has a ready written typemap to deal with such a kind of function in <typemaps.i>. It provides the correct wrappering as well as setting the flag to inform Lua that the object in question should be garbage collected. Therefore the code is simply:
+
+
%include <typemaps.i>
+%apply SWIGTYPE** OUTPUT{iMath **pptr }; // tell SWIG its an output
+
+struct iMath; // some structure
+int Create_Math(iMath** pptr); // its creator (assume it mallocs)
+
+
+
The usage is as follows:
+
+
ok,ptr=Create_Math() -- ptr is a iMath* which is returned with the int (ok)
+ptr=nil -- the iMath* will be GC'ed as normal
+
+
+
23.5 Writing typemaps
+
+
+
This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "Typemaps" chapter.
+
+
Before proceeding, it should be stressed that writing typemaps is rarely needed unless you want to change some aspect of the wrappering, or to achieve an effect which in not available with the default bindings.
+
+
Before proceeding, you should read the previous section on using typemaps, as well as read the ready written typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you a idea to base your worn on).
+
+
23.5.1 Typemaps you can write
+
+
+
There are many different types of typemap that can be written, the full list can be found in the "Typemaps" chapter. However the following are the most commonly used ones.
+
+
+
in this is for input arguments to functions
+
out this is for return types from functions
+
argout this is for a function argument which is actually returning something
+
typecheck this is used to determine which overloaded function should be called
+(the syntax for the typecheck is different from the typemap, see typemaps for details).
+
+
+
23.5.2 SWIG's Lua-C API
+
+
+
This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.
+
+
int SWIG_ConvertPtr(lua_State* L,int index,void** ptr,swig_type_info *type,int flags);
+
+
+This is the standard function used for converting a Lua userdata to a void*. It takes the value at the given index in the Lua state and converts it to a userdata. It will then provide the neccesary type checks, confirming that the pointer is compatible with the type given in 'type'. Then finally setting '*ptr' to the pointer.
+If flags is set to SWIG_POINTER_DISOWN, this is will clear any ownership flag set on the object.
+The returns a value which can be checked with the macro SWIG_IsOK()
+
+This is the opposite of SWIG_ConvertPtr, as it pushes a new userdata which wrappers the pointer 'ptr' of type 'type'.
+The parameter 'own' specifies if the object is owned be Lua and if it is 1 then Lua will GC the object when the userdata is disposed of.
+
+This function is a version of SWIG_ConvertPtr(), except that it will either work, or it will trigger a lua_error() with a text error message. This function is rarely used, and may be deprecated in the future.
+
+
+
SWIG_fail
+
+
+This macro, when called within the context of a SWIG wrappered function, will jump to the error handler code. This will call any cleanup code (freeing any temp variables) and then triggers a lua_error.
+A common use for this code is:
+if (!SWIG_IsOK(SWIG_ConvertPtr( .....)){
+ lua_pushstring(L,"something bad happened");
+ SWIG_fail;
+}
+This macro, when called within the context of a SWIG wrappered function, will display the error message and jump to the error handler code. The error message is of the form
+
+"Error in func_name (arg argnum), expected 'type' got 'whatever the type was'"
+
+Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
+
+
23.6 Customization of your Bindings
+
+
+
+This section covers adding of some small extra bits to your module to add the last finishing touches.
+
+
+
+
+
23.6.1 Writing your own custom wrappers
@@ -1117,7 +1393,7 @@ int native_function(lua_State*L) // my native code
The %native directive in the above example, tells SWIG that there is a function int native_function(lua_State*L); which is to be added into the module under the name 'my_func'. SWIG will not add any wrappering for this function, beyond adding it into the function table. How you write your code is entirely up to you.
-
22.3.17 Adding additional Lua code
+
23.6.2 Adding additional Lua code
@@ -1155,7 +1431,7 @@ Good uses for this feature is adding of new code, or writing helper functions to
See Examples/lua/arrays for an example of this code.
-
22.4 Details on the Lua binding
+
23.7 Details on the Lua binding
@@ -1166,7 +1442,7 @@ See Examples/lua/arrays for an example of this code.
-
22.4.1 Binding global data into the module.
+
23.7.1 Binding global data into the module.
@@ -1226,7 +1502,7 @@ end
That way when you call 'a=example.Foo', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code 'example.Foo=10', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.
-
22.4.2 Userdata and Metatables
+
23.7.2 Userdata and Metatables
@@ -1306,7 +1582,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrappered classes/s
Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.
-
22.4.3 Memory management
+
23.7.3 Memory management
diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
index 1923c2c48..4c907791b 100644
--- a/Doc/Manual/Makefile
+++ b/Doc/Manual/Makefile
@@ -18,15 +18,19 @@ HTMLDOC_OPTIONS = "--book --toclevels 4 --no-numbered --toctitle \"Table of Cont
all: maketoc check generate
-maketoc:
+maketoc: CCache.html
python maketoc.py
+CCache.html: ../../CCache/ccache.yo
+ yodl2html -o CCache.html ../../CCache/ccache.yo
+
# Use htmltidy to warn about some HTML errors. Note that it is not used to clean/tidy the HTML,
# it is just used as a primitive HTML checker.
+# CCache.html is generated by yodl2html and has a few insignificant problems, so we don't put it through tidy
check:
tidy -errors --gnu-emacs yes -quiet index.html
tidy -errors --gnu-emacs yes -quiet Sections.html
- all=`sed '/^#/d' chapters`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done;
+ all=`sed '/^#/d' chapters | grep -v CCache.html`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done;
generate: swightml.book swigpdf.book
htmldoc --batch swightml.book || true
@@ -45,11 +49,14 @@ swightml.book:
echo "Sections.html" >> swightml.book
cat chapters >> swightml.book
-clean:
+clean: clean-baks
rm -f swightml.book
rm -f swigpdf.book
+ rm -f CCache.html
rm -f SWIGDocumentation.html
rm -f SWIGDocumentation.pdf
+
+clean-baks:
rm -f *.bak
test:
diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html
index ff70fc143..c4e485202 100644
--- a/Doc/Manual/Modula3.html
+++ b/Doc/Manual/Modula3.html
@@ -5,7 +5,7 @@
@@ -90,7 +90,7 @@ So the introduction got a bit longer than it should ... ;-)
-
23.1.1 Why not scripting ?
+
24.1.1 Why not scripting ?
@@ -126,7 +126,7 @@ are not advantages of the language itself
but can be provided by function libraries.
-
23.1.2 Why Modula-3 ?
+
24.1.2 Why Modula-3 ?
@@ -166,7 +166,7 @@ it's statically typed, too.
-
23.1.3 Why C / C++ ?
+
24.1.3 Why C / C++ ?
@@ -179,7 +179,7 @@ Even more fortunately even non-C libraries may provide C header files.
This is where SWIG becomes helpful.
-
23.1.4 Why SWIG ?
+
24.1.4 Why SWIG ?
@@ -252,10 +252,10 @@ integrate Modula-3 code into a C / C++ project.
-
23.2 Conception
+
24.2 Conception
-
23.2.1 Interfaces to C libraries
+
24.2.1 Interfaces to C libraries
@@ -404,7 +404,7 @@ and the principal type must be renamed (%typemap).
-
23.2.2 Interfaces to C++ libraries
+
24.2.2 Interfaces to C++ libraries
@@ -505,10 +505,10 @@ There is no C++ library I wrote a SWIG interface for,
so I'm not sure if this is possible or sensible, yet.
-
23.3 Preliminaries
+
24.3 Preliminaries
-
23.3.1 Compilers
+
24.3.1 Compilers
@@ -522,7 +522,7 @@ For testing examples I use Critical Mass cm3.
-
23.3.2 Additional Commandline Options
+
24.3.2 Additional Commandline Options
@@ -599,10 +599,10 @@ Instead generate templates for some basic typemaps.
-
23.4 Modula-3 typemaps
+
24.4 Modula-3 typemaps
-
23.4.1 Inputs and outputs
+
24.4.1 Inputs and outputs
@@ -818,7 +818,7 @@ consist of the following parts:
-
23.4.2 Subranges, Enumerations, Sets
+
24.4.2 Subranges, Enumerations, Sets
@@ -860,8 +860,8 @@ that split the task up into converting
the C bit patterns (integer or bit set)
into Modula-3 bit patterns (integer or bit set)
and change the type as requested.
-See the corresponding
-example.
+See the corresponding example in the
+Examples/modula3/enum/example.i file.
This is quite messy and not satisfying.
So the best what you can currently do is
to rewrite constant definitions manually.
@@ -870,20 +870,20 @@ that I'd like to automate.
-
23.4.3 Objects
+
24.4.3 Objects
Declarations of C++ classes are mapped to OBJECT types
while it is tried to retain the access hierarchy
"public - protected - private" using partial revelation.
-Though the
-implementation
+Though the example in
+Examples/modula3/class/example.i
is not really useful, yet.
-
23.4.4 Imports
+
24.4.4 Imports
@@ -918,7 +918,7 @@ IMPORT M3toC;
-
23.4.5 Exceptions
+
24.4.5 Exceptions
@@ -942,7 +942,7 @@ you should declare
%typemap("m3wrapinconv:throws") blah * %{OSError.E%}.
-
23.4.6 Example
+
24.4.6 Example
@@ -989,10 +989,10 @@ where almost everything is generated by a typemap:
-
23.5 More hints to the generator
+
24.5 More hints to the generator
-
23.5.1 Features
+
24.5.1 Features
@@ -1029,7 +1029,7 @@ where almost everything is generated by a typemap:
-
23.5.2 Pragmas
+
24.5.2 Pragmas
@@ -1052,7 +1052,7 @@ where almost everything is generated by a typemap:
-
23.6 Remarks
+
24.6 Remarks
diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html
index 8971324fb..5ac66dc2e 100644
--- a/Doc/Manual/Modules.html
+++ b/Doc/Manual/Modules.html
@@ -50,41 +50,90 @@ scripting language runtime as you would do for the single module case.
A bit more complex is the case in which modules need to share information.
-For example, when one module extends the class of the another by deriving from
+For example, when one module extends the class of another by deriving from
it:
-%module base
-
-%inline %{
+// File: base.h
class base {
public:
- int foo(void);
+ int foo();
};
-%}
+// File: derived_module.i
+%module derived_module
+
+%import "base_module.i"
%inline %{
class derived : public base {
public:
- int bar(void);
+ int bar();
};
%}
-
To create the wrapper properly, module derived needs to know the
-base class and that it's interface is covered in another module. The
-line %import "base.i" lets SWIG know exactly that. The common mistake here is
-to %import the .h file instead of the .i, which sadly won't do the trick. Another issue
-to take care of is that multiple dependent wrappers should not be linked/loaded
+
To create the wrapper properly, module derived_module needs to know about the
+base class and that its interface is covered in another module. The
+line %import "base_module.i" lets SWIG know exactly that. Oftentimes
+the .h file is passed to %import instead of the .i,
+which unfortunately doesn't work for all language modules. For example, Python requires the
+name of module that the base class exists in so that the proxy classes can fully inherit the
+base class's methods. Typically you will get a warning when the module name is missing, eg:
+
+
+
+derived_module.i:8: Warning(401): Base class 'base' ignored - unknown module name for base. Either import
+the appropriate module interface file or specify the name of the module in the %import directive.
+
+
+
+It is sometimes desirable to import the header file rather than the interface file and overcome
+the above warning.
+For example in the case of the imported interface being quite large, it may be desirable to
+simplify matters and just import a small header file of dependent types.
+This can be done by specifying the optional module attribute in the %import directive.
+The derived_module.i file shown above could be replaced with the following:
+
+
+// File: derived_module.i
+%module derived_module
+
+%import(module="base_module") "base.h"
+
+%inline %{
+class derived : public base {
+public:
+ int bar();
+};
+
+
+
+Note that "base_module" is the module name and is the same as that specified in %module
+in base_module.i as well as the %import in derived_module.i.
+
+
+
+Another issue
+to beware of is that multiple dependent wrappers should not be linked/loaded
in parallel from multiple threads as SWIG provides no locking - for more on that
-issue, read on.
@@ -80,7 +80,7 @@ If you're not familiar with the Objective Caml language, you can visit
The Ocaml Website.
-
25.1 Preliminaries
+
26.1 Preliminaries
@@ -99,7 +99,7 @@ file Examples/Makefile illustrate how to compile and link SWIG modules that
will be loaded dynamically. This has only been tested on Linux so far.
-
25.1.1 Running SWIG
+
26.1.1 Running SWIG
@@ -122,7 +122,7 @@ you will compile the file example_wrap.c with ocamlc or
the resulting .ml and .mli files as well, and do the final link with -custom
(not needed for native link).
-
25.1.2 Compiling the code
+
26.1.2 Compiling the code
@@ -158,7 +158,7 @@ the user more freedom with respect to custom typing.
-
25.1.3 The camlp4 module
+
26.1.3 The camlp4 module
@@ -234,7 +234,7 @@ let b = C_string (getenv "PATH")
-
25.1.4 Using your module
+
26.1.4 Using your module
@@ -248,7 +248,7 @@ When linking any ocaml bytecode with your module, use the -custom
option is not needed when you build native code.
-
25.1.5 Compilation problems and compiling with C++
+
26.1.5 Compilation problems and compiling with C++
@@ -259,7 +259,7 @@ liberal with pointer types may not compile under the C++ compiler.
Most code meant to be compiled as C++ will not have problems.
-
25.2 The low-level Ocaml/C interface
+
26.2 The low-level Ocaml/C interface
@@ -360,7 +360,7 @@ is that you must append them to the return list with swig_result = caml_list_a
signature for a function that uses value in this way.
-
25.2.1 The generated module
+
26.2.1 The generated module
@@ -394,7 +394,7 @@ it describes the output SWIG will generate for class definitions.
-
25.2.2 Enums
+
26.2.2 Enums
@@ -457,7 +457,7 @@ val x : Enum_test.c_obj = C_enum `a
-
25.2.2.1 Enum typing in Ocaml
+
26.2.2.1 Enum typing in Ocaml
@@ -470,10 +470,10 @@ functions imported from different modules. You must convert values to master
values using the swig_val function before sharing them with another module.
-
25.2.3 Arrays
+
26.2.3 Arrays
-
25.2.3.1 Simple types of bounded arrays
+
26.2.3.1 Simple types of bounded arrays
@@ -494,7 +494,7 @@ arrays of simple types with known bounds in your code, but this only works
for arrays whose bounds are completely specified.
-
25.2.3.2 Complex and unbounded arrays
+
26.2.3.2 Complex and unbounded arrays
@@ -507,7 +507,7 @@ SWIG can't predict which of these methods will be used in the array,
so you have to specify it for yourself in the form of a typemap.
-
25.2.3.3 Using an object
+
26.2.3.3 Using an object
@@ -521,7 +521,7 @@ Consider writing an object when the ending condition of your array is complex,
such as using a required sentinel, etc.
-
25.2.3.4 Example typemap for a function taking float * and int
+
26.2.3.4 Example typemap for a function taking float * and int
@@ -572,7 +572,7 @@ void printfloats( float *tab, int len );
-
25.2.4 C++ Classes
+
26.2.4 C++ Classes
@@ -615,7 +615,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the
returned value for the same object.
@@ -770,10 +770,10 @@ Assuming you have a working installation of QT, you will see a window
containing the string "hi" in a button.
-
25.2.5 Director Classes
+
26.2.5 Director Classes
-
25.2.5.1 Director Introduction
+
26.2.5.1 Director Introduction
@@ -800,7 +800,7 @@ class foo {
};
-
25.2.5.2 Overriding Methods in Ocaml
+
26.2.5.2 Overriding Methods in Ocaml
@@ -828,7 +828,7 @@ In this example, I'll examine the objective caml code involved in providing
an overloaded class. This example is contained in Examples/ocaml/shapes.
-
25.2.5.3 Director Usage Example
+
26.2.5.3 Director Usage Example
@@ -887,7 +887,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the
program in C++.
-
25.2.5.4 Creating director objects
+
26.2.5.4 Creating director objects
@@ -928,7 +928,7 @@ object from causing a core dump, as long as the object is destroyed
properly.
-
25.2.5.5 Typemaps for directors, directorin, directorout, directorargout
+
26.2.5.5 Typemaps for directors, directorin, directorout, directorargout
@@ -939,7 +939,7 @@ well as a function return value in the same way you provide function arguments,
and to receive arguments the same way you normally receive function returns.
-
25.2.5.6 directorin typemap
+
26.2.5.6 directorin typemap
@@ -950,7 +950,7 @@ code receives when you are called. In general, a simple directorin typ
can use the same body as a simple out typemap.
-
25.2.5.7 directorout typemap
+
26.2.5.7 directorout typemap
@@ -961,7 +961,7 @@ for the same type, except when there are special requirements for object
ownership, etc.
-
25.2.5.8 directorargout typemap
+
26.2.5.8 directorargout typemap
@@ -978,7 +978,7 @@ In the event that you don't specify all of the necessary values, integral
values will read zero, and struct or object returns have undefined results.
The current SWIG implemention is based on Octave 2.9.12. Support for other versions (in particular the recent 3.0) has not been tested, nor has support for any OS other than Linux.
-
26.2 Running SWIG
+
27.2 Running SWIG
@@ -89,7 +89,7 @@ This creates a C/C++ source file example_wrap.cxx. The generated C++ so
The swig command line has a number of options you can use, like to redirect it's output. Use swig --help to learn about these.
@@ -318,7 +318,7 @@ octave:2> f=example.fopen("not there","r");
error: value on right hand side of assignment is undefined
error: evaluating assignment expression near line 2, column 2
-
26.3.6 Structures and C++ classes
+
27.3.6 Structures and C++ classes
@@ -453,7 +453,7 @@ ans = 1
Depending on the ownership setting of a swig_ref, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.
-
26.3.7 C++ inheritance
+
27.3.7 C++ inheritance
@@ -462,7 +462,7 @@ This information contains the full class hierarchy. When an indexing operation (
the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the swig_ref.
-
26.3.8 C++ overloaded functions
+
27.3.8 C++ overloaded functions
@@ -472,7 +472,7 @@ The dispatch function selects which overload to call (if any) based on the passe
typecheck typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.
-
26.3.9 C++ operators
+
27.3.9 C++ operators
@@ -572,7 +572,7 @@ On the C++ side, the default mappings are as follows:
%rename(__brace) *::operator[];
-
C++ smart pointers are fully supported as in other modules.
-
26.3.13 Directors (calling Octave from C++ code)
+
27.3.13 Directors (calling Octave from C++ code)
@@ -766,14 +766,14 @@ c-side routine called
octave-side routine called
-
26.3.14 Threads
+
27.3.14 Threads
The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.
-
26.3.15 Memory management
+
27.3.15 Memory management
@@ -807,14 +807,14 @@ The %newobject directive may be used to control this behavior for pointers retur
In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/subclass()'ing).
-
26.3.16 STL support
+
27.3.16 STL support
This is some skeleton support for various STL containers.
@@ -87,7 +87,7 @@ later. Earlier versions are problematic and SWIG generated extensions
may not compile or run correctly.
-
27.1 Overview
+
28.1 Overview
@@ -108,7 +108,7 @@ described. Advanced customization features, typemaps, and other
options are found near the end of the chapter.
-
27.2 Preliminaries
+
28.2 Preliminaries
@@ -133,7 +133,7 @@ To build the module, you will need to compile the file
example_wrap.c and link it with the rest of your program.
-
27.2.1 Getting the right header files
+
28.2.1 Getting the right header files
@@ -165,7 +165,7 @@ loaded, an easy way to find out is to run Perl itself.
-
27.2.2 Compiling a dynamic module
+
28.2.2 Compiling a dynamic module
@@ -198,7 +198,7 @@ the target should be named `example.so',
`example.sl', or the appropriate dynamic module name on your system.
-
27.2.3 Building a dynamic module with MakeMaker
+
28.2.3 Building a dynamic module with MakeMaker
@@ -232,7 +232,7 @@ the preferred approach to compilation. More information about MakeMaker can be
found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen,
and Randal Schwartz.
-
27.2.4 Building a static version of Perl
+
28.2.4 Building a static version of Perl
@@ -301,7 +301,7 @@ added to it. Depending on your machine, you may need to link with
additional libraries such as -lsocket, -lnsl, -ldl, etc.
-
27.2.5 Using the module
+
28.2.5 Using the module
@@ -456,7 +456,7 @@ system configuration (this requires root access and you will need to
read the man pages).
-
27.2.6 Compilation problems and compiling with C++
+
28.2.6 Compilation problems and compiling with C++
@@ -599,7 +599,7 @@ have to find the macro that conflicts and add an #undef into the .i file. Pleas
any conflicting macros you find to swig-user mailing list.
-
27.2.7 Compiling for 64-bit platforms
+
28.2.7 Compiling for 64-bit platforms
@@ -626,7 +626,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
-
27.3 Building Perl Extensions under Windows
+
28.3 Building Perl Extensions under Windows
@@ -637,7 +637,7 @@ section assumes you are using SWIG with Microsoft Visual C++
although the procedure may be similar with other compilers.
-
27.3.1 Running SWIG from Developer Studio
+
28.3.1 Running SWIG from Developer Studio
@@ -700,7 +700,7 @@ print "$a\n";
-
27.3.2 Using other compilers
+
28.3.2 Using other compilers
@@ -708,7 +708,7 @@ SWIG is known to work with Cygwin and may work with other compilers on Windows.
For general hints and suggestions refer to the Windows chapter.
-
27.4 The low-level interface
+
28.4 The low-level interface
@@ -718,7 +718,7 @@ can be used to control your application. However, it is also used to
construct more user-friendly proxy classes as described in the next section.
-
27.4.1 Functions
+
28.4.1 Functions
@@ -741,7 +741,7 @@ use example;
$a = &example::fact(2);
-
27.4.2 Global variables
+
28.4.2 Global variables
@@ -811,7 +811,7 @@ extern char *path; // Declared later in the input
-
27.4.3 Constants
+
28.4.3 Constants
@@ -838,7 +838,7 @@ $example::FOO = 2; # Error
-
27.4.4 Pointers
+
28.4.4 Pointers
@@ -947,7 +947,7 @@ as XS and xsubpp. Given the advancement of the SWIG typesystem and the
SWIG and XS, this is no longer supported.
@@ -1146,7 +1146,7 @@ provides direct access to C++ objects. A higher level interface using Perl prox
can be built using these low-level accessors. This is described shortly.
-
27.4.7 C++ classes and type-checking
+
28.4.7 C++ classes and type-checking
@@ -1182,7 +1182,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece
multiple inheritance is used).
-
27.4.8 C++ overloaded functions
+
28.4.8 C++ overloaded functions
@@ -1226,7 +1226,7 @@ example::Spam_foo_d($s,3.14);
Please refer to the "SWIG Basics" chapter for more information.
-
27.4.9 Operators
+
28.4.9 Operators
@@ -1253,7 +1253,7 @@ The following C++ operators are currently supported by the Perl module:
operator or
-
27.4.10 Modules and packages
+
28.4.10 Modules and packages
@@ -1348,7 +1348,7 @@ print Foo::fact(4),"\n"; # Call a function in package FooBar
-->
-
27.5 Input and output parameters
+
28.5 Input and output parameters
@@ -1567,7 +1567,7 @@ print "$c\n";
Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).
-
27.6 Exception handling
+
28.6 Exception handling
@@ -1732,7 +1732,7 @@ This is still supported, but it is deprecated. The newer %exception di
functionality, but it has additional capabilities that make it more powerful.
-
27.7 Remapping datatypes with typemaps
+
28.7 Remapping datatypes with typemaps
@@ -1749,7 +1749,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Perl interface.
@@ -2345,7 +2345,7 @@ the "in" typemap in the previous section would be used to convert an
to copy the converted array into a C data structure.
-
27.8.5 Turning Perl references into C pointers
+
28.8.5 Turning Perl references into C pointers
@@ -2410,7 +2410,7 @@ print "$c\n";
-
27.8.6 Pointer handling
+
28.8.6 Pointer handling
@@ -2489,7 +2489,7 @@ For example:
-
27.9 Proxy classes
+
28.9 Proxy classes
@@ -2505,7 +2505,7 @@ to the underlying code. This section describes the implementation
details of the proxy interface.
-
27.9.1 Preliminaries
+
28.9.1 Preliminaries
@@ -2527,7 +2527,7 @@ SWIG creates a collection of high-level Perl wrappers. In your scripts, you wil
high level wrappers. The wrappers, in turn, interact with the low-level procedural module.
-
27.9.2 Structure and class wrappers
+
28.9.2 Structure and class wrappers
@@ -2653,7 +2653,7 @@ $v->DESTROY();
-
27.9.3 Object Ownership
+
28.9.3 Object Ownership
@@ -2740,7 +2740,7 @@ counting, garbage collection, or advanced features one might find in
sophisticated languages.
Basic PHP interface
@@ -43,21 +42,24 @@
Caution: This chapter (and module!) is still under construction
+
+SWIG supports generating wrappers for PHP5. Support for PHP4 has been removed
+as of SWIG 1.3.37. The PHP developers are no longer making new PHP4 releases,
+and won't even be patching critical security issues after 2008-08-08, so it
+doesn't make much sense for SWIG to continue to support PHP4 at this point.
+If you need to continue to use PHP4, stick with SWIG 1.3.36.
+
+
In this chapter, we discuss SWIG's support of PHP. The PHP module
-was extensively rewritten in release 1.3.26, and although it is
-significantly more functional, it still does not implement all the
+was extensively rewritten in release 1.3.26, and support for generating
+OO wrappers for PHP5 was added in 1.3.30. The PHP module works fairly
+well, but currently does not implement all the
features available in some of the other languages.
-The examples and test cases have been developed with PHP4. Release
-1.3.30 added support for generating PHP5 class wrappers for C++
-libraries.
-
-
-
-In order to use this module, you will need to have a copy of the PHP4 or PHP5
+In order to use this module, you will need to have a copy of the PHP5
include files to compile the SWIG generated files. If you installed
PHP from a binary package, you may need to install a "php-dev" or "php-devel"
package for these to be installed. You can find out where these files are
@@ -67,7 +69,7 @@ your extension into php directly, you will need the complete PHP source tree
available.
-
28.1 Generating PHP Extensions
+
29.1 Generating PHP Extensions
@@ -88,7 +90,7 @@ you wish to statically link the extension into the php interpreter.
The third file,
example.php can be included by PHP scripts. It attempts to
dynamically load the extension and contains extra php code specified
-in the interface file. If wrapping C++ code for PHP5, it will
+in the interface file. If wrapping C++ code with PHP classes, it will
also contain PHP5 class wrappers.
The usual (and recommended) way is to build the extension as a separate
-dynamically loaded module. You can then specify that this be loaded
+dynamically loaded module (which is supported by all modern operating
+systems). You can then specify that this be loaded
automatically in php.ini or load it explicitly for any script which
needs it.
@@ -110,17 +113,16 @@ It is also possible to rebuild PHP from source so that your module is
statically linked into the php executable/library. This is a lot more
work, and also requires a full rebuild of PHP to update your module,
and it doesn't play nicely with package system. We don't recommend
-this approach, but if you really want to do this, the -phpfull
-command line argument to swig may be of use - see below for details.
+this approach, or provide explicit support for it.
-
28.1.1 Building a loadable extension
+
29.1.1 Building a loadable extension
To build your module as a dynamically loadable extension, use compilation
commands like these (if you aren't using GCC, the commands will be different,
-and there may be so variation between platforms - these commands should at
+and there may be some variation between platforms - these commands should at
least work for Linux though):
@@ -129,135 +131,7 @@ least work for Linux though):
gcc -shared example_wrap.o -o example.so
-
-There is a deprecated -make command line argument to swig which will
-generate an additional file makefile which can usually build the
-extension (at least on some UNIX platforms), but the Makefile generated isn't
-very flexible, and the commands required are trivial so it is simpler to just
-add them to your Makefile or other build system directly. We recommend that
-you don't use -make and it's likely to be removed at some point.
-
-
-
28.1.2 Building extensions into PHP
-
-
-
-Note that we don't recommend this approach - it's cleaner and simpler to
-use dynamically loadable modules, which are supported by all modern OSes.
-Support for this may be discontinued entirely in the future.
-
-
-
-It is possible to rebuild PHP itself with your module statically linked
-in. To do this, you can use the -phpfull command line option to
-swig. Using this option will generate three additional files. The first
-extra file, config.m4 contains the m4 and shell code needed to
-enable the extension as part of the PHP build process. The second
-extra file, Makefile.in contains the information needed to
-build the final Makefile after substitutions. The third and final
-extra file, CREDITS should contain the credits for the
-extension.
-
-
-
-To build with phpize, after you have run swig you will need to run the
-'phpize' command (installed as part of php) in the same
-directory. This re-creates the php build environment in that
-directory. It also creates a configure file which includes the shell
-code from the config.m4 that was generated by SWIG, this configure
-script will accept a command line argument to enable the extension to
-be run (by default the command line argument is --enable-modulename,
-however you can edit the config.m4 file before running phpize to
-accept --with-modulename. You can also add extra tests in config.m4 to
-check that a correct library version is installed or correct header
-files are included, etc, but you must edit this file before running
-phpize.) You can also get SWIG to generate simple extra tests for
-libraries and header files for you.
-
-
-
- swig -php -phpfull
-
-
-
-If you depend on source files not generated by SWIG, before generating
-the configure file, you may need to edit the Makefile.in
-file. This contains the names of the source files to compile (just the
-wrapper file by default) and any additional libraries needed to be
-linked in. If there are extra C files to compile, you will need to add
-them to the Makefile.in, or add the names of libraries if they are
-needed. In simple cases SWIG is pretty good at generating a complete
-Makefile.in and config.m4 which need no further editing.
-
-
-
-You then run the configure script with the command line argument needed
-to enable the extension. Then run make, which builds the extension.
-The extension object file will be left in the modules sub directory, you can
-move it to wherever it is convenient to call from your php script.
-
-
-
-When using -phpfull, swig also accepts the following
-additional optional arguments:
-
-
-
-withincs "<incs>" Adds include files to the config.m4 file.
-
-withlibs "<libs>" Links with the specified libraries.
-
-withc "<files>" Compiles and links the additional specified C files.
-
-withcxx "<files>" Compiles and links the additional specified C++ files.
-
-
-
-After running swig with the -phpfull switch, you will be left with a shockingly
-similar set of files to the previous build process. However you will then need
-to move these files to a subdirectory within the php source tree, this subdirectory you will need to create under the ext directory, with the name of the extension (e.g. mkdir php-4.0.6/ext/modulename).
-
-
-
-After moving the files into this directory, you will need to run the 'buildall'
-script in the php source directory. This rebuilds the configure script
-and includes the extra command line arguments from the module you have added.
-
-
-
-Before running the generated configure file, you may need to edit the
-Makefile.in. This contains the names of the source files to compile (
-just the wrapper file by default) and any additional libraries needed to
-link in. If there are extra C files to compile you will need to add them
-to the Makefile, or add the names of libraries if they are needed.
-In most cases Makefile.in will be complete, especially if you
-make use of -withlibs and -withincs
-
-Will include in the config.m4 and Makefile.in search for
-libxapian.a or libxapian.so and search for
-libomquery.a or libomquery.so as well as a
-search for om.h.
-
-
-
-You then need to run the configure command and pass the necessary command
-line arguments to enable your module (by default this is --enable-modulename,
-but this can be changed by editing the config.m4 file in the modules directory
-before running the buildall script. In addition, extra tests can be added to
-the config.m4 file to ensure the correct libraries and header files are
-installed.)
-
-
-
-Once configure has completed, you can run make to build php. If this all
-compiles correctly, you should end up with a php executable/library
-which contains your new module. You can test it with a php script which
-does not have the 'dl' command as used above.
-
-
-
28.1.3 Using PHP Extensions
+
29.1.2 Using PHP Extensions
@@ -288,7 +162,7 @@ attempts to do the dl() call for you:
include("example.php");
-
28.2 Basic PHP interface
+
29.2 Basic PHP interface
@@ -298,7 +172,7 @@ possible for names of symbols in one extension module to clash with
other symbols unless care is taken to %rename them.
-
28.2.1 Constants
+
29.2.1 Constants
@@ -423,7 +297,7 @@ both point to the same value, without the case test taking place. (
Apologies, this paragraph needs rewriting to make some sense. )
-
28.2.2 Global Variables
+
29.2.2 Global Variables
@@ -472,7 +346,7 @@ undefined.
At this time SWIG does not support custom accessor methods.
-
28.2.3 Functions
+
29.2.3 Functions
@@ -525,7 +399,7 @@ print $s; # The value of $s was not changed.
-->
-
28.2.4 Overloading
+
29.2.4 Overloading
@@ -539,7 +413,7 @@ Overloaded Functions and Methods.
-
28.2.5 Pointers and References
+
29.2.5 Pointers and References
@@ -713,24 +587,13 @@ PHP in a number of ways: by using unset on an existing
variable, or assigning NULL to a variable.
-
28.2.6 Structures and C++ classes
+
29.2.6 Structures and C++ classes
-SWIG defaults to wrapping C++ structs and classes with PHP classes. This
-requires SWIG to generate different code for PHP4 and PHP5, so you must
-specify which you want using -php4 or -php5 (currently
--php generates PHP4 class wrappers for compatibility with
-SWIG 1.3.29 and earlier, but this may change in the future).
-
-
-
-PHP4 classes are implemented entirely using the Zend C API so
-no additional php code is generated. For PHP5, a PHP wrapper
+SWIG defaults to wrapping C++ structs and classes with PHP classes
+unless "-noproxy" is specified. For PHP5, a PHP wrapper
class is generated which calls a set of flat functions wrapping the C++ class.
-In many cases the PHP4 and PHP5 wrappers will behave the same way,
-but the PHP5 ones make use of better PHP5's better OO functionality
-where appropriate.
@@ -754,7 +617,7 @@ struct Complex {
-Would be used in the following way from either PHP4 or PHP5:
+Would be used in the following way from PHP5:
@@ -783,7 +646,7 @@ Would be used in the following way from either PHP4 or PHP5:
Member variables and methods are accessed using the -> operator.
-
@@ -850,13 +713,13 @@ the programmer can either reassign the variable or call
unset($v)
-
28.2.6.3 Static Member Variables
+
29.2.6.3 Static Member Variables
-Static member variables are not supported in PHP4, and it does not
-appear to be possible to intercept accesses to static member variables
-in PHP5. Therefore, static member variables are
+Static member variables in C++ are not wrapped as such in PHP
+as it does not appear to be possible to intercept accesses to such variables.
+Therefore, static member variables are
wrapped using a class function with the same name, which
returns the current value of the class variable. For example
@@ -893,7 +756,7 @@ Ko::threats(10);
echo "There has now been " . Ko::threats() . " threats\n";
-
28.2.6.4 Static Member Functions
+
29.2.6.4 Static Member Functions
@@ -915,12 +778,12 @@ Ko::threats();
-
28.2.7 PHP Pragmas, Startup and Shutdown code
+
29.2.7 PHP Pragmas, Startup and Shutdown code
Note: Currently pragmas for PHP need to be specified using
-%pragma(php4) but also apply for PHP5! This is just a historical
+%pragma(php) but also apply for PHP5! This is just a historical
oddity because SWIG's PHP support predates PHP5.
@@ -932,7 +795,7 @@ object.
%module example
-%pragma(php4) code="
+%pragma(php) code="
# This code is inserted into example.php
echo \"example.php execution\\n\";
"
@@ -954,7 +817,7 @@ the example.php file.
%module example
-%pragma(php4) code="
+%pragma(php) code="
include \"include.php\";
"
%pragma(php) include="include.php" // equivalent.
@@ -968,7 +831,7 @@ phpinfo() function.
%module example;
-%pragma(php4) phpinfo="
+%pragma(php) phpinfo="
zend_printf("An example of PHP support through SWIG\n");
php_info_print_table_start();
php_info_print_table_header(2, \"Directive\", \"Value\");
diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html
index 3e39d4062..a47d07865 100644
--- a/Doc/Manual/Pike.html
+++ b/Doc/Manual/Pike.html
@@ -6,7 +6,7 @@
-
29 SWIG and Pike
+
30 SWIG and Pike
@@ -46,10 +46,10 @@ least, make sure you read the "SWIG Basics"
chapter.
-
29.1 Preliminaries
+
30.1 Preliminaries
-
29.1.1 Running SWIG
+
30.1.1 Running SWIG
@@ -94,7 +94,7 @@ can use the -o option:
$ swig -pike -o pseudonym.c example.i
-
29.1.2 Getting the right header files
+
30.1.2 Getting the right header files
@@ -114,7 +114,7 @@ You're looking for files with the names global.h, program.h
and so on.
@@ -143,7 +143,7 @@ concerned), SWIG's %module directive doesn't really have any
significance.
-
29.2.2 Functions
+
30.2.2 Functions
@@ -168,7 +168,7 @@ exactly as you'd expect it to:
(1) Result: 24
-
29.2.3 Global variables
+
30.2.3 Global variables
@@ -197,7 +197,7 @@ will result in two functions, Foo_get() and Foo_set():
(3) Result: 3.141590
-
29.2.4 Constants and enumerated types
+
30.2.4 Constants and enumerated types
@@ -205,7 +205,7 @@ Enumerated types in C/C++ declarations are wrapped as Pike constants,
not as Pike enums.
-
29.2.5 Constructors and Destructors
+
30.2.5 Constructors and Destructors
@@ -213,7 +213,7 @@ Constructors are wrapped as create() methods, and destructors are
wrapped as destroy() methods, for Pike classes.
-
29.2.6 Static Members
+
30.2.6 Static Members
diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html
index a454c8124..5afa59243 100644
--- a/Doc/Manual/Preprocessor.html
+++ b/Doc/Manual/Preprocessor.html
@@ -81,7 +81,7 @@ Such information generally includes type declarations (e.g., typedef) a
C++ classes that might be used as base-classes for class declarations in the interface.
The use of %import is also important when SWIG is used to generate
extensions as a collection of related modules. This is an advanced topic and is described
-in a later chapter.
+in later in the Working with Modules chapter.
@@ -107,7 +107,10 @@ SWIGWIN Defined when running SWIG under Windows
SWIG_VERSION Hexadecimal number containing SWIG version,
such as 0x010311 (corresponding to SWIG-1.3.11).
+SWIGALLEGROCL Defined when using Allegro CL
+SWIGCFFI Defined when using CFFI
SWIGCHICKEN Defined when using CHICKEN
+SWIGCLISP Defined when using CLISP
SWIGCSHARP Defined when using C#
SWIGGUILE Defined when using Guile
SWIGJAVA Defined when using Java
@@ -115,17 +118,15 @@ SWIGLUA Defined when using Lua
SWIGMODULA3 Defined when using Modula-3
SWIGMZSCHEME Defined when using Mzscheme
SWIGOCAML Defined when using Ocaml
+SWIGOCTAVE Defined when using Octave
SWIGPERL Defined when using Perl
-SWIGPERL5 Defined when using Perl5
SWIGPHP Defined when using PHP
-SWIGPHP4 Defined when using PHP4
-SWIGPHP5 Defined when using PHP5
SWIGPIKE Defined when using Pike
SWIGPYTHON Defined when using Python
+SWIGR Defined when using R
SWIGRUBY Defined when using Ruby
SWIGSEXP Defined when using S-expressions
SWIGTCL Defined when using Tcl
-SWIGTCL8 Defined when using Tcl8.0
SWIGXML Defined when using XML
This chapter describes SWIG's support of Python. SWIG is compatible
-with most recent Python versions including Python 2.2 as well as older
-versions dating back to Python 1.5.2. For the best results, consider using Python
-2.0 or newer.
+with most recent Python versions including Python 3.0 and Python 2.6,
+as well as older versions dating back to Python 2.0. For the best results,
+consider using Python 2.3 or newer.
@@ -125,7 +131,7 @@ very least, make sure you read the "SWIG
Basics" chapter.
-
30.1 Overview
+
31.1 Overview
@@ -152,10 +158,10 @@ described followed by a discussion of low-level implementation
details.
-
30.2 Preliminaries
+
31.2 Preliminaries
-
30.2.1 Running SWIG
+
31.2.1 Running SWIG
@@ -253,7 +259,7 @@ The following sections have further practical examples and details on
how you might go about compiling and using the generated files.
-
30.2.2 Using distutils
+
31.2.2 Using distutils
@@ -345,7 +351,7 @@ This same approach works on all platforms if the appropriate compiler is install
can even build extensions to the standard Windows Python using MingGW)
-
30.2.3 Hand compiling a dynamic module
+
31.2.3 Hand compiling a dynamic module
@@ -393,7 +399,7 @@ module actually consists of two files; socket.py and
-
30.2.4 Static linking
+
31.2.4 Static linking
@@ -472,7 +478,7 @@ If using static linking, you might want to rely on a different approach
(perhaps using distutils).
-
30.2.5 Using your module
+
31.2.5 Using your module
@@ -629,7 +635,7 @@ system configuration (this requires root access and you will need to
read the man pages).
-
30.2.6 Compilation of C++ extensions
+
31.2.6 Compilation of C++ extensions
@@ -728,7 +734,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
-
30.2.7 Compiling for 64-bit platforms
+
31.2.7 Compiling for 64-bit platforms
@@ -765,7 +771,7 @@ and -m64 allow you to choose the desired binary format for your python
extension.
-
30.2.8 Building Python Extensions under Windows
+
31.2.8 Building Python Extensions under Windows
@@ -874,7 +880,7 @@ SWIG Wiki.
-
30.3 A tour of basic C/C++ wrapping
+
31.3 A tour of basic C/C++ wrapping
@@ -883,7 +889,7 @@ to your C/C++ code. Functions are wrapped as functions, classes are wrapped as
This section briefly covers the essential aspects of this wrapping.
-
30.3.1 Modules
+
31.3.1 Modules
@@ -896,7 +902,7 @@ module name, make sure you don't use the same name as a built-in
Python command or standard module name.
-
30.3.2 Functions
+
31.3.2 Functions
@@ -920,7 +926,7 @@ like you think it does:
>>>
-
30.3.3 Global variables
+
31.3.3 Global variables
@@ -1058,7 +1064,7 @@ that starts with a leading underscore. SWIG does not create cvar
if there are no global variables in a module.
-
30.3.4 Constants and enums
+
31.3.4 Constants and enums
@@ -1098,7 +1104,7 @@ other object. Unfortunately, there is no easy way for SWIG to
generate code that prevents this. You will just have to be careful.
-
30.3.5 Pointers
+
31.3.5 Pointers
@@ -1239,7 +1245,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
None if the conversion can't be performed.
-
30.3.6 Structures
+
31.3.6 Structures
@@ -1428,7 +1434,7 @@ everything works just like you would expect. For example:
-
30.3.7 C++ classes
+
31.3.7 C++ classes
@@ -1517,7 +1523,7 @@ they are accessed through cvar like this:
-
30.3.8 C++ inheritance
+
31.3.8 C++ inheritance
@@ -1572,7 +1578,7 @@ then the function spam() accepts Foo * or a pointer to any cla
It is safe to use multiple inheritance with SWIG.
-
30.3.9 Pointers, references, values, and arrays
+
31.3.9 Pointers, references, values, and arrays
@@ -1633,7 +1639,7 @@ treated as a returning value, and it will follow the same
allocation/deallocation process.
-
30.3.10 C++ overloaded functions
+
31.3.10 C++ overloaded functions
@@ -1756,7 +1762,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
-
30.3.11 C++ operators
+
31.3.11 C++ operators
@@ -1845,7 +1851,7 @@ Also, be aware that certain operators don't map cleanly to Python. For instance
overloaded assignment operators don't map to Python semantics and will be ignored.
-
30.3.12 C++ namespaces
+
31.3.12 C++ namespaces
@@ -1912,7 +1918,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
-
30.3.13 C++ templates
+
31.3.13 C++ templates
@@ -1966,7 +1972,7 @@ Some more complicated
examples will appear later.
-
30.3.14 C++ Smart Pointers
+
31.3.14 C++ Smart Pointers
@@ -2051,7 +2057,7 @@ simply use the __deref__() method. For example:
-
30.3.15 C++ Reference Counted Objects (ref/unref)
+
31.3.15 C++ Reference Counted Objects (ref/unref)
@@ -2213,7 +2219,7 @@ python releases the proxy instance.
-
30.4 Further details on the Python class interface
+
31.4 Further details on the Python class interface
@@ -2226,7 +2232,7 @@ of low-level details were omitted. This section provides a brief overview
of how the proxy classes work.
-
30.4.1 Proxy classes
+
31.4.1 Proxy classes
@@ -2315,7 +2321,7 @@ you can attach new Python methods to the class and you can even inherit from it
by Python built-in types until Python 2.2).
-
30.4.2 Memory management
+
31.4.2 Memory management
@@ -2507,7 +2513,7 @@ It is also possible to deal with situations like this using
typemaps--an advanced topic discussed later.
-
30.4.3 Python 2.2 and classic classes
+
31.4.3 Python 2.2 and classic classes
@@ -2544,7 +2550,7 @@ class itself. In Python-2.1 and earlier, they have to be accessed as a global
function or through an instance (see the earlier section).
-
30.5 Cross language polymorphism
+
31.5 Cross language polymorphism
@@ -2578,7 +2584,7 @@ proxy classes, director classes, and C wrapper functions takes care of
all the cross-language method routing transparently.
-
30.5.1 Enabling directors
+
31.5.1 Enabling directors
@@ -2671,7 +2677,7 @@ class MyFoo(mymodule.Foo):
-
30.5.2 Director classes
+
31.5.2 Director classes
@@ -2753,7 +2759,7 @@ so there is no need for the extra overhead involved with routing the
calls through Python.
-
30.5.3 Ownership and object destruction
+
31.5.3 Ownership and object destruction
@@ -2820,7 +2826,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard
references to the Foo objects remain in Python.
-
30.5.4 Exception unrolling
+
31.5.4 Exception unrolling
@@ -2879,7 +2885,7 @@ Swig::DirectorMethodException is thrown, Python will register the
exception as soon as the C wrapper function returns.
-
30.5.5 Overhead and code bloat
+
31.5.5 Overhead and code bloat
@@ -2913,7 +2919,7 @@ directive) for only those methods that are likely to be extended in
Python.
-
30.5.6 Typemaps
+
31.5.6 Typemaps
@@ -2927,7 +2933,7 @@ need to be supported.
-
30.5.7 Miscellaneous
+
31.5.7 Miscellaneous
@@ -2974,7 +2980,7 @@ methods that return const references.
-
30.6 Common customization features
+
31.6 Common customization features
@@ -2987,7 +2993,7 @@ This section describes some common SWIG features that are used to
improve your the interface to an extension module.
-
30.6.1 C/C++ helper functions
+
31.6.1 C/C++ helper functions
@@ -3068,7 +3074,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps,
customization features as covered in later sections.
-
30.6.2 Adding additional Python code
+
31.6.2 Adding additional Python code
@@ -3217,7 +3223,7 @@ public:
-
30.6.3 Class extension with %extend
+
31.6.3 Class extension with %extend
@@ -3306,7 +3312,7 @@ Vector(12,14,16)
in any way---the extensions only show up in the Python interface.
-
30.6.4 Exception handling with %exception
+
31.6.4 Exception handling with %exception
@@ -3432,7 +3438,7 @@ The language-independent exception.i library file can also be used
to raise exceptions. See the SWIG Library chapter.
-
30.7 Tips and techniques
+
31.7 Tips and techniques
@@ -3442,7 +3448,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques
solving these problems.
-
30.7.1 Input and output parameters
+
31.7.1 Input and output parameters
@@ -3655,7 +3661,7 @@ void foo(Bar *OUTPUT);
may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.
-
30.7.2 Simple pointers
+
31.7.2 Simple pointers
@@ -3724,7 +3730,7 @@ If you replace %pointer_functions() by %pointer_class(type,name)SWIG Library chapter for further details.
-
30.7.3 Unbounded C Arrays
+
31.7.3 Unbounded C Arrays
@@ -3786,7 +3792,7 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
-
30.7.4 String handling
+
31.7.4 String handling
@@ -3855,16 +3861,16 @@ If you need to return binary data, you might use the
also be used to extra binary data from arbitrary pointers.
-
30.7.5 Arrays
+
31.7.5 Arrays
-
30.7.6 String arrays
+
31.7.6 String arrays
-
30.7.7 STL wrappers
+
31.7.7 STL wrappers
-
30.8 Typemaps
+
31.8 Typemaps
@@ -3881,7 +3887,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Python interface or if you want to elevate your guru status.
-
30.8.1 What is a typemap?
+
31.8.1 What is a typemap?
@@ -3997,7 +4003,7 @@ parameter is omitted):
-
30.8.2 Python typemaps
+
31.8.2 Python typemaps
@@ -4038,7 +4044,7 @@ a look at the SWIG library version 1.3.20 or so.
-
30.8.3 Typemap variables
+
31.8.3 Typemap variables
@@ -4109,7 +4115,7 @@ properly assigned.
The Python name of the wrapper function being created.
-
30.8.4 Useful Python Functions
+
31.8.4 Useful Python Functions
@@ -4237,7 +4243,7 @@ write me
-
30.9 Typemap Examples
+
31.9 Typemap Examples
@@ -4246,7 +4252,7 @@ might look at the files "python.swg" and "typemaps.i" in
the SWIG library.
-
30.9.1 Converting Python list to a char **
+
31.9.1 Converting Python list to a char **
@@ -4326,7 +4332,7 @@ memory allocation is used to allocate memory for the array, the
the C function.
-
30.9.2 Expanding a Python object into multiple arguments
+
31.9.2 Expanding a Python object into multiple arguments
@@ -4405,7 +4411,7 @@ to supply the argument count. This is automatically set by the typemap code. F
-
30.9.3 Using typemaps to return arguments
+
31.9.3 Using typemaps to return arguments
@@ -4494,7 +4500,7 @@ function can now be used as follows:
>>>
-
30.9.4 Mapping Python tuples into small arrays
+
31.9.4 Mapping Python tuples into small arrays
@@ -4543,7 +4549,7 @@ array, such an approach would not be recommended for huge arrays, but
for small structures, this approach works fine.
-
30.9.5 Mapping sequences to C arrays
+
31.9.5 Mapping sequences to C arrays
@@ -4632,7 +4638,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) {
-
30.9.6 Pointer handling
+
31.9.6 Pointer handling
@@ -4729,7 +4735,7 @@ class object (if applicable).
-
30.10 Docstring Features
+
31.10 Docstring Features
@@ -4757,7 +4763,7 @@ of your users much simpler.
-
30.10.1 Module docstring
+
31.10.1 Module docstring
@@ -4791,7 +4797,7 @@ layout of controls on a panel, etc. to be loaded from an XML file."
-
30.10.2 %feature("autodoc")
+
31.10.2 %feature("autodoc")
@@ -4818,7 +4824,7 @@ names, default values if any, and return type if any. There are also
three options for autodoc controlled by the value given to the
feature, described below.
-
@@ -4923,13 +4929,13 @@ with more than one line.
-
30.11 Python Packages
+
31.11 Python Packages
Using the package option of the %module directive
allows you to specify what Python package that the module will be
-living in when installed.
+living in when installed.
@@ -4950,6 +4956,256 @@ and also in base class declarations, etc. if the package name is
different than its own.
+
31.12 Python 3 Support
+
+
+
+SWIG is able to support Python 3.0. The wrapper code generated by
+SWIG can be compiled with both Python 2.x or 3.0. Further more, by
+passing the -py3 command line option to SWIG, wrapper code
+with some Python 3 specific features can be generated (see below
+subsections for details of these features). The -py3 option also
+disables some incompatible features for Python 3, such as
+-classic.
+
+
+There is a list of known-to-be-broken features in Python 3:
+
+
+
No more support for FILE* typemaps, because PyFile_AsFile has been dropped
+ in Python 3.
+
The -apply command line option is removed and generating
+ code using apply() is no longer supported.
+
+
+
+The following are Python 3.0 new features that are currently supported by
+SWIG.
+
+
+
31.12.1 Function annotation
+
+
+
+The -py3 option will enable function annotation support. When used
+SWIG is able to generate proxy method definitions like this:
+
+Also, even if without passing SWIG the -py3 option, the parameter list
+still could be generated:
+
+
+
+ def foo(self, bar = 0): ...
+
+
+
+But for overloaded function or method, the parameter list would fallback to
+*args or self, *args, and **kwargs may be append
+depend on whether you enabled the keyword argument. This fallback is due to
+all overloaded functions share the same function in SWIG generated proxy class.
+
+
+
+For detailed usage of function annotation, see PEP 3107.
+
+
+
31.12.2 Buffer interface
+
+
+
+Buffer protocols were revised in Python 3. SWIG also gains a series of
+new typemaps to support buffer interfaces. These typemap macros are
+defined in pybuffer.i, which must be included in order to use them.
+By using these typemaps, your wrapped function will be able to
+accept any Python object that exposes a suitable buffer interface.
+
+
+
+For example, the get_path() function puts the path string
+into the memory pointed to by its argument:
+
+
+
+void get_path(char *s);
+
+
+
+Then you can write a typemap like this: (the following example is
+applied to both Python 3.0 and 2.6, since the bytearray type
+is backported to 2.6.
+
+And then on the Python side the wrapped get_path could be used in this
+way:
+
+
+
+>>> p = bytearray(10)
+>>> get_path(p)
+>>> print(p)
+bytearray(b'/Foo/Bar/\x00')
+
+
+
+The macros defined in pybuffer.i are similar to those in
+cstring.i:
+
+
+
+%pybuffer_mutable_binary(parm, size_parm)
+
+
+
+
+
+The macro can be used to generate a typemap which maps a buffer of an
+object to a pointer provided by parm and a size argument
+provided by size_parm. For example:
+
+Both %pybuffer_mutable_binary and %pybuffer_mutable_string
+require the provided buffer to be mutable, eg. they can accept a
+bytearray type but can't accept an immutable byte
+type.
+
+
+
+
+
+%pybuffer_binary(parm, size_parm)
+
+
+
+
+
+This macro maps an object's buffer to a pointer parm and a
+size size_parm. It is similar to
+%pybuffer_mutable_binary, except the
+%pybuffer_binary an accept both mutable and immutable
+buffers. As a result, the wrapped function should not modify the buffer.
+
+
+
+
+
+%pybuffer_string(parm)
+
+
+
+
+
+This macro maps an object's buffer as a string pointer parm.
+It is similar to %pybuffer_mutable_string but the buffer
+could be both mutable and immutable. And your function should not
+modify the buffer.
+
+
+
+
+
+
31.12.3 Abstract base classes
+
+
+
+By including pyabc.i and using the -py3 command
+line option when calling SWIG, the proxy classes of the STL containers
+will automatically gain an appropriate abstract base class. For
+example, the following SWIG interface:
+
+will generate a Python proxy class Mapii inheriting from
+collections.MutableMap and a proxy class IntList
+inheriting from collections.MutableSequence.
+
+
+
+pyabc.i also provides a macro %pythonabc that could be
+used to define an abstract base class for your own C++ class:
+
+
+
+%pythonabc(MySet, collections.MutableSet);
+
+
+
+For details of abstract base class, please see PEP 3119.
+
@@ -33,7 +33,7 @@ compile and run an R interface to QuantLib running on Mandriva Linux
with gcc. The R bindings also work on Microsoft Windows using Visual C++.
-
33.1 Bugs
+
34.1 Bugs
@@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:
C Array wrappings
-
33.2 Using R and SWIG
+
34.2 Using R and SWIG
@@ -99,7 +99,7 @@ Without it, inheritance of wrapped objects may fail.
These two files can be loaded in any order
-
33.3 Precompiling large R files
+
34.3 Precompiling large R files
In cases where the R file is large, one make save a lot of loading
@@ -117,7 +117,7 @@ will save a large amount of loading time.
-
33.4 General policy
+
34.4 General policy
@@ -126,7 +126,7 @@ wrapping over the underlying functions and rely on the R type system
to provide R syntax.
-
33.5 Language conventions
+
34.5 Language conventions
@@ -135,7 +135,7 @@ and [ are overloaded to allow for R syntax (one based indices and
slices)
-
33.6 C++ classes
+
34.6 C++ classes
@@ -147,7 +147,7 @@ keep track of the pointer object which removes the necessity for a lot
of the proxy class baggage you see in other languages.
SWIG 1.3 is known to work with Ruby versions 1.6 and later.
@@ -190,7 +190,7 @@ of Ruby.
-
31.1.1 Running SWIG
+
32.1.1 Running SWIG
To build a Ruby module, run SWIG using the -ruby
@@ -244,7 +244,7 @@ to compile this file and link it with the rest of your program.
-
31.1.2 Getting the right header files
+
32.1.2 Getting the right header files
In order to compile the wrapper code, the compiler needs the ruby.h
@@ -288,7 +288,7 @@ installed, you can run Ruby to find out. For example:
-
31.1.3 Compiling a dynamic module
+
32.1.3 Compiling a dynamic module
Ruby extension modules are typically compiled into shared
@@ -443,7 +443,7 @@ manual pages for your compiler and linker to determine the correct set
of options. You might also check the SWIG Wiki
for additional information.
-
31.1.4 Using your module
+
32.1.4 Using your module
Ruby module names must be capitalized,
@@ -498,7 +498,7 @@ begins with:
-
31.1.5 Static linking
+
32.1.5 Static linking
An alternative approach to dynamic linking is to rebuild the
@@ -519,7 +519,7 @@ finally rebuilding Ruby.
-
31.1.6 Compilation of C++ extensions
+
32.1.6 Compilation of C++ extensions
On most machines, C++ extension modules should be linked
@@ -571,7 +571,7 @@ extension, e.g.
-
31.2 Building Ruby Extensions under Windows 95/NT
+
32.2 Building Ruby Extensions under Windows 95/NT
Building a SWIG extension to Ruby under Windows 95/NT is
@@ -610,7 +610,7 @@ files.
-
31.2.1 Running SWIG from Developer Studio
+
32.2.1 Running SWIG from Developer Studio
If you are developing your application within Microsoft
@@ -752,7 +752,7 @@ directory, then run the Ruby script from the DOS/Command prompt:
-
31.3 The Ruby-to-C/C++ Mapping
+
32.3 The Ruby-to-C/C++ Mapping
This section describes the basics of how SWIG maps C or C++
@@ -762,7 +762,7 @@ declarations in your SWIG interface files to Ruby constructs.
There are three ways to raise exceptions from C++ code to
@@ -4621,7 +4621,7 @@ the built-in Ruby exception types.
-
31.6.4 Exception classes
+
32.6.4 Exception classes
Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass
@@ -4679,7 +4679,7 @@ providing for a more natural integration between C++ code and Ruby code.
-
31.7 Typemaps
+
32.7 Typemaps
This section describes how you can modify SWIG's default
@@ -4702,7 +4702,7 @@ of the primitive C-Ruby interface.
-
31.7.1 What is a typemap?
+
32.7.1 What is a typemap?
A typemap is nothing more than a code generation rule that is
@@ -4964,7 +4964,7 @@ to be used as follows (notice how the length parameter is omitted):
-
31.7.2 Typemap scope
+
32.7.2 Typemap scope
Once defined, a typemap remains in effect for all of the
@@ -5012,7 +5012,7 @@ where the class itself is defined. For example:
-
31.7.3 Copying a typemap
+
32.7.3 Copying a typemap
A typemap is copied by using assignment. For example:
@@ -5114,7 +5114,7 @@ rules as for
-
31.7.4 Deleting a typemap
+
32.7.4 Deleting a typemap
A typemap can be deleted by simply defining no code. For
@@ -5166,7 +5166,7 @@ typemaps immediately after the clear operation.
-
31.7.5 Placement of typemaps
+
32.7.5 Placement of typemaps
Typemap declarations can be declared in the global scope,
@@ -5250,7 +5250,7 @@ string
-
31.7.6 Ruby typemaps
+
32.7.6 Ruby typemaps
The following list details all of the typemap methods that
@@ -5260,7 +5260,7 @@ can be used by the Ruby module:
-
31.7.6.1 "in" typemap
+
32.7.6.1 "in" typemap
Converts Ruby objects to input
@@ -5503,7 +5503,7 @@ arguments to be specified. For example:
-
31.7.6.2 "typecheck" typemap
+
32.7.6.2 "typecheck" typemap
The "typecheck" typemap is used to support overloaded
@@ -5544,7 +5544,7 @@ on "Typemaps and Overloading."
-
31.7.6.3 "out" typemap
+
32.7.6.3 "out" typemap
Converts return value of a C function
@@ -5776,7 +5776,7 @@ version of the C datatype matched by the typemap.
-
31.7.6.4 "arginit" typemap
+
32.7.6.4 "arginit" typemap
The "arginit" typemap is used to set the initial value of a
@@ -5801,7 +5801,7 @@ applications. For example:
-
31.7.6.5 "default" typemap
+
32.7.6.5 "default" typemap
The "default" typemap is used to turn an argument into a
@@ -5843,7 +5843,7 @@ default argument wrapping.
-
31.7.6.6 "check" typemap
+
32.7.6.6 "check" typemap
The "check" typemap is used to supply value checking code
@@ -5867,7 +5867,7 @@ arguments have been converted. For example:
-
31.7.6.7 "argout" typemap
+
32.7.6.7 "argout" typemap
The "argout" typemap is used to return values from arguments.
@@ -6025,7 +6025,7 @@ some function like SWIG_Ruby_AppendOutput.
-
31.7.6.8 "freearg" typemap
+
32.7.6.8 "freearg" typemap
The "freearg" typemap is used to cleanup argument data. It is
@@ -6061,7 +6061,7 @@ abort prematurely.
-
31.7.6.9 "newfree" typemap
+
32.7.6.9 "newfree" typemap
The "newfree" typemap is used in conjunction with the %newobject
@@ -6092,7 +6092,7 @@ ownership and %newobject for further details.
-
31.7.6.10 "memberin" typemap
+
32.7.6.10 "memberin" typemap
The "memberin" typemap is used to copy data from an
@@ -6125,7 +6125,7 @@ other objects.
-
31.7.6.11 "varin" typemap
+
32.7.6.11 "varin" typemap
The "varin" typemap is used to convert objects in the target
@@ -6136,7 +6136,7 @@ This is implementation specific.
-
31.7.6.12 "varout" typemap
+
32.7.6.12 "varout" typemap
The "varout" typemap is used to convert a C/C++ object to an
@@ -6147,7 +6147,7 @@ This is implementation specific.
-
31.7.6.13 "throws" typemap
+
32.7.6.13 "throws" typemap
The "throws" typemap is only used when SWIG parses a C++
@@ -6206,7 +6206,7 @@ handling with %exception section.
-
31.7.6.14 directorin typemap
+
32.7.6.14 directorin typemap
Converts C++ objects in director
@@ -6460,7 +6460,7 @@ referring to the class itself.
-
31.7.6.15 directorout typemap
+
32.7.6.15 directorout typemap
Converts Ruby objects in director
@@ -6720,7 +6720,7 @@ exception.
-
31.7.6.16 directorargout typemap
+
32.7.6.16 directorargout typemap
Output argument processing in director
@@ -6960,7 +6960,7 @@ referring to the instance of the class itself
-
31.7.6.17 ret typemap
+
32.7.6.17 ret typemap
Cleanup of function return values
@@ -6970,7 +6970,7 @@ referring to the instance of the class itself
-
31.7.6.18 globalin typemap
+
32.7.6.18 globalin typemap
Setting of C global variables
@@ -6980,7 +6980,7 @@ referring to the instance of the class itself
-
31.7.7 Typemap variables
+
32.7.7 Typemap variables
@@ -7090,7 +7090,7 @@ being created.
-
31.7.8 Useful Functions
+
32.7.8 Useful Functions
When you write a typemap, you usually have to work directly
@@ -7114,7 +7114,7 @@ across multiple languages.
-
31.7.8.1 C Datatypes to Ruby Objects
+
32.7.8.1 C Datatypes to Ruby Objects
@@ -7170,7 +7170,7 @@ SWIG_From_float(float)
-
31.7.8.2 Ruby Objects to C Datatypes
+
32.7.8.2 Ruby Objects to C Datatypes
Here, while the Ruby versions return the value directly, the SWIG
@@ -7259,7 +7259,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input
-
The Ruby language doesn't support multiple inheritance, but
@@ -9802,7 +9802,7 @@ Features") for more details).
-
31.10 Memory Management
+
32.10 Memory Management
One of the most common issues in generating SWIG bindings for
@@ -9849,7 +9849,7 @@ understanding of how the underlying library manages memory.
-
31.10.1 Mark and Sweep Garbage Collector
+
32.10.1 Mark and Sweep Garbage Collector
Ruby uses a mark and sweep garbage collector. When the garbage
@@ -9897,7 +9897,7 @@ this memory.
-
31.10.2 Object Ownership
+
32.10.2 Object Ownership
As described above, memory management depends on clearly
@@ -10124,7 +10124,7 @@ classes is:
-
31.10.3 Object Tracking
+
32.10.3 Object Tracking
The remaining parts of this section will use the class library
@@ -10338,7 +10338,7 @@ methods.
-
31.10.4 Mark Functions
+
32.10.4 Mark Functions
With a bit more testing, we see that our class library still
@@ -10456,7 +10456,7 @@ test suite.
-
31.10.5 Free Functions
+
32.10.5 Free Functions
By default, SWIG creates a "free" function that is called when
@@ -10567,7 +10567,7 @@ existing Ruby object to the destroyed C++ object and raise an exception.
-
%module example
%{ #include "example.h" %}
/* Specify that ownership is transferred to the zoo when calling add_animal */ %apply SWIGTYPE *DISOWN { Animal* animal };
/* Track objects */ %trackobjects;
/* Specify the mark function */ %freefunc Zoo "free_Zoo";
/* Loop over each animal */ int count = zoo->get_num_animals();
for(int i = 0; i < count; ++i) { /* Get an animal */ Animal* animal = zoo->get_animal(i);
/* Unlink the Ruby object from the C++ object */ SWIG_RubyUnlinkObjects(animal);
/* Now remove the tracking for this animal */ SWIG_RubyRemoveTracking(animal); }
/* Now call SWIG_RubyRemoveTracking for the zoo */ SWIG_RubyRemoveTracking(ptr);
/* Now free the zoo which will free the animals it contains */ delete zoo; } %}
@@ -10611,7 +10611,7 @@ been freed, and thus raises a runtime exception.
-
31.10.6 Embedded Ruby and the C++ Stack
+
32.10.6 Embedded Ruby and the C++ Stack
As has been said, the Ruby GC runs and marks objects before
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index c22d81c07..d52f0441c 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -53,7 +53,7 @@
Other things to note about structure wrapping
@@ -120,8 +120,7 @@ can be obtained by typing swig -help or swig
-mzscheme Generate Mzscheme wrappers
-ocaml Generate Ocaml wrappers
-perl Generate Perl wrappers
--php4 Generate PHP4 wrappers
--php5 Generate PHP5 wrappers
+-php Generate PHP wrappers
-pike Generate Pike wrappers
-python Generate Python wrappers
-r Generate R (aka GNU S) wrappers
@@ -140,6 +139,7 @@ can be obtained by typing swig -help or swig
-lfile Include a SWIG library file.
-module name Set the name of the SWIG module
-o outfile Name of output file
+-outcurrentdir Set default output dir to current dir instead of input file's path
-outdir dir Set language specific files output directory
-swiglib Show location of SWIG library
-version Show SWIG version number
@@ -224,7 +224,7 @@ The C/C++ output file created by SWIG often
contains everything that is needed to construct a extension module
for the target scripting language. SWIG is not a stub compiler nor is it
usually necessary to edit the output file (and if you look at the output,
-you probably won't want to). To build the final extension module, the
+you probably won't want to). To build the final extension module, the
SWIG output file is compiled and linked with the rest of your C/C++
program to create a shared library.
@@ -232,7 +232,7 @@ program to create a shared library.
Many target languages will also generate proxy class files in the
target language. The default output directory for these language
-specific files is the same directory as the generated C/C++ file. This can
+specific files is the same directory as the generated C/C++ file. This
can be modified using the -outdir option. For example:
+If the -outcurrentdir option is used (without -o)
+then SWIG behaves like a typical C/C++
+compiler and the default output directory is then the current directory. Without
+this option the default output directory is the path to the input file.
+If -o and
+-outcurrentdir are used together, -outcurrentdir is effectively ignored
+as the output directory for the language files is the same directory as the
+generated C/C++ file if not overidden with -outdir.
+
+
5.1.3 Comments
@@ -2219,13 +2230,13 @@ void Foo_w_set(FOO *f, WORD value) {
-Compatibility Note: SWIG-1.3.11 and earlier releases transformed all non-primitive member datatypes
-to pointers. Starting in SWIG-1.3.12, this transformation only occurs if a datatype is known to be a structure,
-class, or union. This is unlikely to break existing code. However, if you need to tell SWIG that an undeclared
+Compatibility Note: SWIG-1.3.11 and earlier releases transformed all non-primitive member datatypes
+to pointers. Starting in SWIG-1.3.12, this transformation only occurs if a datatype is known to be a structure,
+class, or union. This is unlikely to break existing code. However, if you need to tell SWIG that an undeclared
datatype is really a struct, simply use a forward struct declaration such as "struct Foo;".
-
5.5.5 C constructors and destructors
+
5.5.5 C constructors and destructors
@@ -2282,7 +2293,7 @@ struct Bar { // Default constructor generated.
Since ignoring the implicit or default destructors most of the times
produce memory leaks, SWIG will always try to generate them. If
needed, however, you can selectively disable the generation of the
-default/implicit destructor by using %nodefaultdtor
+default/implicit destructor by using %nodefaultdtor
@@ -2726,11 +2737,16 @@ the module upon loading.
Code is inserted into the appropriate code section by using one
-of the following code insertion directives:
+of the code insertion directives listed below. The order of the sections in
+the wrapper file is as shown:
+%begin %{
+ ... code in begin section ...
+%}
+
%runtime %{
... code in runtime section ...
%}
@@ -2751,10 +2767,12 @@ of the following code insertion directives:
The bare %{ ... %} directive is a shortcut that is the same as
-%header %{ ... %}.
+%header %{ ... %}.
+The %begin section is effectively empty as it just contains the SWIG banner by default.
+This section is provided as a way for users to insert code at the top of the wrapper file before any other code is generated.
Everything in a code insertion block is copied verbatim into the output file and is
not parsed by SWIG. Most SWIG input files have at least one such block to include header
files and support C code. Additional code blocks may be placed anywhere in a
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index 5406f44ea..789efc129 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -6,7 +6,7 @@
SWIG-1.3 Development Documentation
-Last update : SWIG-1.3.37 (in progress)
+Last update : SWIG-1.3.40 (in progress)
@@ -82,7 +82,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but
this is no longer supported.
-
32.1 Preliminaries
+
33.1 Preliminaries
@@ -108,7 +108,7 @@ build a Tcl extension module. To finish building the module, you
need to compile this file and link it with the rest of your program.
-
32.1.1 Getting the right header files
+
33.1.1 Getting the right header files
@@ -126,7 +126,7 @@ this is the case, you should probably make a symbolic link so that tcl.h
-
32.1.2 Compiling a dynamic module
+
33.1.2 Compiling a dynamic module
@@ -161,7 +161,7 @@ The name of the module is specified using the %module directive or the
-module command line option.
-
32.1.3 Static linking
+
33.1.3 Static linking
@@ -227,7 +227,7 @@ minimal in most situations (and quite frankly not worth the extra
hassle in the opinion of this author).
-
32.1.4 Using your module
+
33.1.4 Using your module
@@ -355,7 +355,7 @@ to the default system configuration (this requires root access and you will need
the man pages).
-
32.1.5 Compilation of C++ extensions
+
33.1.5 Compilation of C++ extensions
@@ -438,7 +438,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
-
32.1.6 Compiling for 64-bit platforms
+
33.1.6 Compiling for 64-bit platforms
@@ -465,7 +465,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
-
32.1.7 Setting a package prefix
+
33.1.7 Setting a package prefix
@@ -484,7 +484,7 @@ option will append the prefix to the name when creating a command and
call it "Foo_bar".
-
32.1.8 Using namespaces
+
33.1.8 Using namespaces
@@ -506,7 +506,7 @@ When the -namespace option is used, objects in the module
are always accessed with the namespace name such as Foo::bar.
-
32.2 Building Tcl/Tk Extensions under Windows 95/NT
+
33.2 Building Tcl/Tk Extensions under Windows 95/NT
@@ -517,7 +517,7 @@ covers the process of using SWIG with Microsoft Visual C++.
although the procedure may be similar with other compilers.
-
32.2.1 Running SWIG from Developer Studio
+
33.2.1 Running SWIG from Developer Studio
@@ -575,7 +575,7 @@ MSDOS > tclsh80
%
-
32.2.2 Using NMAKE
+
33.2.2 Using NMAKE
@@ -638,7 +638,7 @@ to get you started. With a little practice, you'll be making lots of
Tcl extensions.
-
32.3 A tour of basic C/C++ wrapping
+
33.3 A tour of basic C/C++ wrapping
@@ -649,7 +649,7 @@ classes. This section briefly covers the essential aspects of this
wrapping.
-
32.3.1 Modules
+
33.3.1 Modules
@@ -683,7 +683,7 @@ To fix this, supply an extra argument to load like this:
@@ -872,7 +872,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l
conversion. This allows the global statement to be omitted.
-
32.3.5 Pointers
+
33.3.5 Pointers
@@ -968,7 +968,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
None if the conversion can't be performed.
-
32.3.6 Structures
+
33.3.6 Structures
@@ -1250,7 +1250,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the
memory management section that appears shortly.
-
32.3.7 C++ classes
+
33.3.7 C++ classes
@@ -1317,7 +1317,7 @@ In Tcl, the static member is accessed as follows:
-
32.3.8 C++ inheritance
+
33.3.8 C++ inheritance
@@ -1366,7 +1366,7 @@ For instance:
It is safe to use multiple inheritance with SWIG.
-
32.3.9 Pointers, references, values, and arrays
+
33.3.9 Pointers, references, values, and arrays
@@ -1420,7 +1420,7 @@ to hold the result and a pointer is returned (Tcl will release this memory
when the return value is garbage collected).
-
32.3.10 C++ overloaded functions
+
33.3.10 C++ overloaded functions
@@ -1543,7 +1543,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
-
32.3.11 C++ operators
+
33.3.11 C++ operators
@@ -1645,7 +1645,7 @@ There are ways to make this operator appear as part of the class using the %
Keep reading.
-
32.3.12 C++ namespaces
+
33.3.12 C++ namespaces
@@ -1709,7 +1709,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
@@ -2433,7 +2433,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex
See the chapter on "Customization Features" for more examples.
-
32.7 Typemaps
+
33.7 Typemaps
@@ -2450,7 +2450,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Tcl interface.
-
32.7.1 What is a typemap?
+
33.7.1 What is a typemap?
@@ -2567,7 +2567,7 @@ parameter is omitted):
-
32.7.2 Tcl typemaps
+
33.7.2 Tcl typemaps
@@ -2705,7 +2705,7 @@ Initialize an argument to a value before any conversions occur.
Examples of these methods will appear shortly.
-
32.7.3 Typemap variables
+
33.7.3 Typemap variables
@@ -2776,7 +2776,7 @@ properly assigned.
The Tcl name of the wrapper function being created.
-
32.7.4 Converting a Tcl list to a char **
+
33.7.4 Converting a Tcl list to a char **
@@ -2838,7 +2838,7 @@ argv[2] = Larry
3
-
32.7.5 Returning values in arguments
+
33.7.5 Returning values in arguments
@@ -2880,7 +2880,7 @@ result, a Tcl function using these typemaps will work like this :
%
-
32.7.6 Useful functions
+
33.7.6 Useful functions
@@ -2957,7 +2957,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
-
32.7.7 Standard typemaps
+
33.7.7 Standard typemaps
@@ -3041,7 +3041,7 @@ work)
-
32.7.8 Pointer handling
+
33.7.8 Pointer handling
@@ -3117,7 +3117,7 @@ For example:
-
32.8 Turning a SWIG module into a Tcl Package.
+
33.8 Turning a SWIG module into a Tcl Package.
@@ -3189,7 +3189,7 @@ As a final note, most SWIG examples do not yet use the
to use the load command instead.
-
32.9 Building new kinds of Tcl interfaces (in Tcl)
+
33.9 Building new kinds of Tcl interfaces (in Tcl)
@@ -3288,7 +3288,7 @@ danger of blowing something up (although it is easily accomplished
with an out of bounds array access).
Where to go for more information?
@@ -3899,7 +3900,66 @@ sure that the typemaps sharing information have exactly the same types and names
-
10.15 Where to go for more information?
+
10.15 C++ "this" pointer
+
+
+
+All the rules discussed for Typemaps apply to C++ as well as C.
+However in addition C++ passes an extra parameter into every
+non-static class method -- the this pointer. Occasionally it can be
+useful to apply a typemap to this pointer (for example to check
+and make sure this is non-null before deferencing).
+Actually, C also has an the equivalent of the this pointer which is used
+when accessing variables in a C struct.
+
+
+In order to customise the this pointer handling, target a variable named self in your typemaps.
+self is the name SWIG uses to refer to the extra parameter in wrapped functions.
+
+In the above case, the $1 variable is expanded into the argument
+name that SWIG is using as the this pointer.
+
+SWIG will then insert the check code before the actual C++ class method
+is called, and will raise an exception rather than crash
+the Java virtual machine.
+
+The generated code will look something like:
+
+Note that if you have a parameter named self then it
+will also match the typemap. One work around is to create an interface file that wraps
+the method, but give the argument a name other than self.
+
+
+
10.16 Where to go for more information?
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 0b3cb37e9..95af1ec6b 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -558,7 +558,7 @@ example.i(4): Syntax error in input.
-
870. Warning for classname: Base baseclass ignored. Multiple inheritance is not supported in Php4. (Php).
+
870. Warning for classname: Base baseclass ignored. Multiple inheritance is not supported in PHP.
871. Unrecognized pragma pragma. (Php).
diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html
index 8a718ffad..bc8c8fa51 100644
--- a/Doc/Manual/Windows.html
+++ b/Doc/Manual/Windows.html
@@ -281,7 +281,7 @@ Execute the steps in the order shown and don't use spaces in path names. In fact
- Copy the followig to the MSYS install folder (C:\msys\1.0 is default):
+ Copy the following to the MSYS install folder (C:\msys\1.0 is default):
-Click here to see a Java program that calls the C++ functions from Java.
+Click here to see a Java program that calls the C++ functions from Java.
Key points
diff --git a/Examples/java/class/main.java b/Examples/java/class/runme.java
similarity index 99%
rename from Examples/java/class/main.java
rename to Examples/java/class/runme.java
index 8ef35db6d..e1ea0d71c 100644
--- a/Examples/java/class/main.java
+++ b/Examples/java/class/runme.java
@@ -1,7 +1,7 @@
// This example illustrates how C++ classes can be used from Java using SWIG.
// The Java class gets mapped onto the C++ class and behaves as if it is a Java class.
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/java/constants/index.html b/Examples/java/constants/index.html
index 8367d0571..9f1e95a03 100644
--- a/Examples/java/constants/index.html
+++ b/Examples/java/constants/index.html
@@ -20,7 +20,7 @@ to see a SWIG interface with some constant declarations in it.
Click here for the section on constants in the SWIG and Java documentation.
-Click here to see a Java program that prints out the values
+Click here to see a Java program that prints out the values
of the constants contained in the above file.
Key points
diff --git a/Examples/java/constants/main.java b/Examples/java/constants/runme.java
similarity index 98%
rename from Examples/java/constants/main.java
rename to Examples/java/constants/runme.java
index 7130c3d70..2c67d86aa 100644
--- a/Examples/java/constants/main.java
+++ b/Examples/java/constants/runme.java
@@ -1,6 +1,6 @@
import java.lang.reflect.*;
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/java/enum/index.html b/Examples/java/enum/index.html
index 52c06c5d1..20daf2691 100644
--- a/Examples/java/enum/index.html
+++ b/Examples/java/enum/index.html
@@ -21,7 +21,7 @@ See the documentation for the other approaches for wrapping enums.
diff --git a/Examples/java/enum/main.java b/Examples/java/enum/runme.java
similarity index 98%
rename from Examples/java/enum/main.java
rename to Examples/java/enum/runme.java
index 8646e0087..56e49af91 100644
--- a/Examples/java/enum/main.java
+++ b/Examples/java/enum/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/java/extend/main.java b/Examples/java/extend/runme.java
similarity index 99%
rename from Examples/java/extend/main.java
rename to Examples/java/extend/runme.java
index ee3a94ed0..629bb14a6 100644
--- a/Examples/java/extend/main.java
+++ b/Examples/java/extend/runme.java
@@ -17,7 +17,7 @@ class CEO extends Manager {
}
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/java/funcptr/index.html b/Examples/java/funcptr/index.html
index 0ad2be1cf..56d3baa18 100644
--- a/Examples/java/funcptr/index.html
+++ b/Examples/java/funcptr/index.html
@@ -66,7 +66,7 @@ Here are some files that illustrate this with a simple example:
diff --git a/Examples/java/funcptr/main.java b/Examples/java/funcptr/runme.java
similarity index 98%
rename from Examples/java/funcptr/main.java
rename to Examples/java/funcptr/runme.java
index cf81f92b4..cd34c1b65 100644
--- a/Examples/java/funcptr/main.java
+++ b/Examples/java/funcptr/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/java/index.html b/Examples/java/index.html
index d98f9a393..007e14dbc 100644
--- a/Examples/java/index.html
+++ b/Examples/java/index.html
@@ -30,7 +30,7 @@ certain C declarations are turned into constants.
Running the examples
Please see the Windows page in the main manual for information on using the examples on Windows.
-On Unix most of the examples work by making the Makefile before executing the program main.java. The Makefile will output the swig generated JNI c code as well as the Java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the Java files using javac.
+On Unix most of the examples work by making the Makefile before executing the program runme.java. The Makefile will output the swig generated JNI c code as well as the Java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the Java files using javac.
Ensure that the dynamic link library file is in the appropriate path before executing the Java program. For example in Unix, libexample.so must be in the LD_LIBRARY_PATH.
@@ -39,7 +39,7 @@ A Unix example:
$ make
$ export LD_LIBRARY_PATH=. #ksh
-$ java main
+$ java runme
diff --git a/Examples/java/multimap/main.java b/Examples/java/multimap/runme.java
similarity index 97%
rename from Examples/java/multimap/main.java
rename to Examples/java/multimap/runme.java
index 331ac6b89..738330e77 100644
--- a/Examples/java/multimap/main.java
+++ b/Examples/java/multimap/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/java/native/index.html b/Examples/java/native/index.html
index 7ecf129ce..1ca51c1e9 100644
--- a/Examples/java/native/index.html
+++ b/Examples/java/native/index.html
@@ -18,7 +18,7 @@ This example compares wrapping a c global function using the manual way and the
example.i. Interface file comparing code wrapped by SWIG and wrapped manually.
-
main.java. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions.
+
runme.java. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions.
Notes
diff --git a/Examples/java/native/main.java b/Examples/java/native/runme.java
similarity index 96%
rename from Examples/java/native/main.java
rename to Examples/java/native/runme.java
index f4760bb3d..e9a18b21a 100644
--- a/Examples/java/native/main.java
+++ b/Examples/java/native/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/java/pointer/index.html b/Examples/java/pointer/index.html
index c30d549e6..e20fe3328 100644
--- a/Examples/java/pointer/index.html
+++ b/Examples/java/pointer/index.html
@@ -144,7 +144,7 @@ extraction.
diff --git a/Examples/java/pointer/main.java b/Examples/java/pointer/runme.java
similarity index 98%
rename from Examples/java/pointer/main.java
rename to Examples/java/pointer/runme.java
index e96e02eaa..f32f980f9 100644
--- a/Examples/java/pointer/main.java
+++ b/Examples/java/pointer/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/java/reference/index.html b/Examples/java/reference/index.html
index 64b129cbb..33c80c50f 100644
--- a/Examples/java/reference/index.html
+++ b/Examples/java/reference/index.html
@@ -121,7 +121,7 @@ Click here to see a SWIG interface file with these addit
Sample Java program
-Click here to see a Java program that manipulates some C++ references.
+Click here to see a Java program that manipulates some C++ references.
Notes:
diff --git a/Examples/java/reference/main.java b/Examples/java/reference/runme.java
similarity index 99%
rename from Examples/java/reference/main.java
rename to Examples/java/reference/runme.java
index 4fd354761..6a2d9bf70 100644
--- a/Examples/java/reference/main.java
+++ b/Examples/java/reference/runme.java
@@ -1,6 +1,6 @@
// This example illustrates the manipulation of C++ references in Java.
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/java/simple/index.html b/Examples/java/simple/index.html
index a363327fe..9729e6dd8 100644
--- a/Examples/java/simple/index.html
+++ b/Examples/java/simple/index.html
@@ -65,15 +65,15 @@ to create the extension libexample.so (unix).
Using the extension
-Click here to see a program that calls our C functions from Java.
+Click here to see a program that calls our C functions from Java.
-Compile the java files example.java and main.java
-to create the class files example.class and main.class before running main in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example:
+Compile the java files example.java and runme.java
+to create the class files example.class and runme.class before running runme in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example:
export LD_LIBRARY_PATH=. #ksh
javac *.java
-java main
+java runme
diff --git a/Examples/java/simple/main.java b/Examples/java/simple/runme.java
similarity index 97%
rename from Examples/java/simple/main.java
rename to Examples/java/simple/runme.java
index 6d224a4dc..92880e8f9 100644
--- a/Examples/java/simple/main.java
+++ b/Examples/java/simple/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/java/template/index.html b/Examples/java/template/index.html
index 1aebd4c2a..f4408e568 100644
--- a/Examples/java/template/index.html
+++ b/Examples/java/template/index.html
@@ -85,7 +85,7 @@ Note that SWIG parses the templated function max and templated class A sample Java program
-Click here to see a Java program that calls the C++ functions from Java.
+Click here to see a Java program that calls the C++ functions from Java.
Notes
Use templated classes just like you would any other SWIG generated Java class. Use the classnames specified by the %template directive.
diff --git a/Examples/java/template/main.java b/Examples/java/template/runme.java
similarity index 98%
rename from Examples/java/template/main.java
rename to Examples/java/template/runme.java
index 9129fcf2a..5d1097bba 100644
--- a/Examples/java/template/main.java
+++ b/Examples/java/template/runme.java
@@ -1,6 +1,6 @@
// This example illustrates how C++ templates can be used from Java.
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/java/typemap/index.html b/Examples/java/typemap/index.html
index 486aa8e79..5dd591941 100644
--- a/Examples/java/typemap/index.html
+++ b/Examples/java/typemap/index.html
@@ -16,7 +16,7 @@ This example shows how typemaps can be used to modify the default behaviour of t
diff --git a/Examples/java/typemap/main.java b/Examples/java/typemap/runme.java
similarity index 96%
rename from Examples/java/typemap/main.java
rename to Examples/java/typemap/runme.java
index bd9a4e1b6..fcbcc3067 100644
--- a/Examples/java/typemap/main.java
+++ b/Examples/java/typemap/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/java/variables/index.html b/Examples/java/variables/index.html
index 05aaa2d6e..07b19d4e7 100644
--- a/Examples/java/variables/index.html
+++ b/Examples/java/variables/index.html
@@ -38,7 +38,7 @@ example.set_foo(12.3);
-Click here to see the example program that updates and prints
+Click here to see the example program that updates and prints
out the values of the variables using this technique.
Key points
diff --git a/Examples/java/variables/main.java b/Examples/java/variables/runme.java
similarity index 99%
rename from Examples/java/variables/main.java
rename to Examples/java/variables/runme.java
index 92745db99..361a30fa6 100644
--- a/Examples/java/variables/main.java
+++ b/Examples/java/variables/runme.java
@@ -2,7 +2,7 @@
import java.lang.reflect.*;
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/lua/embed3/embed3.cpp b/Examples/lua/embed3/embed3.cpp
index c2424f9af..e5e0e0a7d 100644
--- a/Examples/lua/embed3/embed3.cpp
+++ b/Examples/lua/embed3/embed3.cpp
@@ -26,7 +26,12 @@ extern "C" {
#include
#include
}
-
+
+/* The SWIG external runtime is generated by using.
+swig -lua -externalruntime swigluarun.h
+It contains useful function used by SWIG in its wrappering
+SWIG_TypeQuery() SWIG_NewPointerObj()
+*/
#include "swigluarun.h" // the SWIG external runtime
/* the SWIG wrappered library */
diff --git a/Examples/perl5/class/example.dsp b/Examples/perl5/class/example.dsp
index bbdedc094..b5ccd1928 100644
--- a/Examples/perl5/class/example.dsp
+++ b/Examples/perl5/class/example.dsp
@@ -126,7 +126,7 @@ InputName=example
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -141,7 +141,7 @@ InputName=example
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/import/bar.dsp b/Examples/perl5/import/bar.dsp
index 682c21757..64786b8f6 100644
--- a/Examples/perl5/import/bar.dsp
+++ b/Examples/perl5/import/bar.dsp
@@ -118,7 +118,7 @@ InputName=bar
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=bar
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/import/base.dsp b/Examples/perl5/import/base.dsp
index 7a0ea8027..920891cbf 100644
--- a/Examples/perl5/import/base.dsp
+++ b/Examples/perl5/import/base.dsp
@@ -118,7 +118,7 @@ InputName=base
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=base
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/import/foo.dsp b/Examples/perl5/import/foo.dsp
index 755560165..d519a5316 100644
--- a/Examples/perl5/import/foo.dsp
+++ b/Examples/perl5/import/foo.dsp
@@ -118,7 +118,7 @@ InputName=foo
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=foo
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/import/spam.dsp b/Examples/perl5/import/spam.dsp
index ed41de36b..e5c8046eb 100644
--- a/Examples/perl5/import/spam.dsp
+++ b/Examples/perl5/import/spam.dsp
@@ -118,7 +118,7 @@ InputName=spam
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=spam
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/multimap/example.dsp b/Examples/perl5/multimap/example.dsp
index 2d295763b..be8a0070e 100644
--- a/Examples/perl5/multimap/example.dsp
+++ b/Examples/perl5/multimap/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -perl5 $(InputPath)
+ ..\..\..\swig.exe -perl5 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -perl5 $(InputPath)
+ ..\..\..\swig.exe -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/simple/example.dsp b/Examples/perl5/simple/example.dsp
index 2d295763b..be8a0070e 100644
--- a/Examples/perl5/simple/example.dsp
+++ b/Examples/perl5/simple/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -perl5 $(InputPath)
+ ..\..\..\swig.exe -perl5 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -perl5 $(InputPath)
+ ..\..\..\swig.exe -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/php4/check.list b/Examples/php/check.list
similarity index 100%
rename from Examples/php4/check.list
rename to Examples/php/check.list
diff --git a/Examples/php4/enum/Makefile b/Examples/php/class/Makefile
similarity index 71%
rename from Examples/php4/enum/Makefile
rename to Examples/php/class/Makefile
index 39c4d2f23..252a72660 100644
--- a/Examples/php4/enum/Makefile
+++ b/Examples/php/class/Makefile
@@ -9,16 +9,16 @@ SWIGOPT = -noproxy
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/class/example.cxx b/Examples/php/class/example.cxx
similarity index 100%
rename from Examples/php4/class/example.cxx
rename to Examples/php/class/example.cxx
diff --git a/Examples/php4/class/example.h b/Examples/php/class/example.h
similarity index 100%
rename from Examples/php4/class/example.h
rename to Examples/php/class/example.h
diff --git a/Examples/php4/class/example.i b/Examples/php/class/example.i
similarity index 100%
rename from Examples/php4/class/example.i
rename to Examples/php/class/example.i
diff --git a/Examples/php4/class/runme.php4 b/Examples/php/class/runme.php
similarity index 100%
rename from Examples/php4/class/runme.php4
rename to Examples/php/class/runme.php
diff --git a/Examples/php4/constants/Makefile b/Examples/php/constants/Makefile
similarity index 70%
rename from Examples/php4/constants/Makefile
rename to Examples/php/constants/Makefile
index aed110eb2..23e2675d7 100644
--- a/Examples/php4/constants/Makefile
+++ b/Examples/php/constants/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/constants/example.i b/Examples/php/constants/example.i
similarity index 100%
rename from Examples/php4/constants/example.i
rename to Examples/php/constants/example.i
diff --git a/Examples/php4/constants/runme.php4 b/Examples/php/constants/runme.php
similarity index 100%
rename from Examples/php4/constants/runme.php4
rename to Examples/php/constants/runme.php
diff --git a/Examples/php4/simple/Makefile b/Examples/php/cpointer/Makefile
similarity index 71%
rename from Examples/php4/simple/Makefile
rename to Examples/php/cpointer/Makefile
index caeec2d73..0862ce5ec 100644
--- a/Examples/php4/simple/Makefile
+++ b/Examples/php/cpointer/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/cpointer/example.c b/Examples/php/cpointer/example.c
similarity index 100%
rename from Examples/php4/cpointer/example.c
rename to Examples/php/cpointer/example.c
diff --git a/Examples/php4/cpointer/example.i b/Examples/php/cpointer/example.i
similarity index 100%
rename from Examples/php4/cpointer/example.i
rename to Examples/php/cpointer/example.i
diff --git a/Examples/php4/cpointer/runme.php4 b/Examples/php/cpointer/runme.php
similarity index 100%
rename from Examples/php4/cpointer/runme.php4
rename to Examples/php/cpointer/runme.php
diff --git a/Examples/php4/proxy/Makefile b/Examples/php/disown/Makefile
similarity index 70%
rename from Examples/php4/proxy/Makefile
rename to Examples/php/disown/Makefile
index ef3acc773..1bc0beaab 100644
--- a/Examples/php4/proxy/Makefile
+++ b/Examples/php/disown/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/disown/example.cxx b/Examples/php/disown/example.cxx
similarity index 100%
rename from Examples/php4/disown/example.cxx
rename to Examples/php/disown/example.cxx
diff --git a/Examples/php4/disown/example.h b/Examples/php/disown/example.h
similarity index 100%
rename from Examples/php4/disown/example.h
rename to Examples/php/disown/example.h
diff --git a/Examples/php4/disown/example.i b/Examples/php/disown/example.i
similarity index 100%
rename from Examples/php4/disown/example.i
rename to Examples/php/disown/example.i
diff --git a/Examples/php4/disown/runme.php4 b/Examples/php/disown/runme.php
similarity index 100%
rename from Examples/php4/disown/runme.php4
rename to Examples/php/disown/runme.php
diff --git a/Examples/php4/reference/Makefile b/Examples/php/enum/Makefile
similarity index 71%
rename from Examples/php4/reference/Makefile
rename to Examples/php/enum/Makefile
index 39c4d2f23..252a72660 100644
--- a/Examples/php4/reference/Makefile
+++ b/Examples/php/enum/Makefile
@@ -9,16 +9,16 @@ SWIGOPT = -noproxy
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/enum/example.cxx b/Examples/php/enum/example.cxx
similarity index 100%
rename from Examples/php4/enum/example.cxx
rename to Examples/php/enum/example.cxx
diff --git a/Examples/php4/enum/example.h b/Examples/php/enum/example.h
similarity index 100%
rename from Examples/php4/enum/example.h
rename to Examples/php/enum/example.h
diff --git a/Examples/php4/enum/example.i b/Examples/php/enum/example.i
similarity index 100%
rename from Examples/php4/enum/example.i
rename to Examples/php/enum/example.i
diff --git a/Examples/php4/enum/runme.php4 b/Examples/php/enum/runme.php
similarity index 100%
rename from Examples/php4/enum/runme.php4
rename to Examples/php/enum/runme.php
diff --git a/Examples/php4/cpointer/Makefile b/Examples/php/funcptr/Makefile
similarity index 71%
rename from Examples/php4/cpointer/Makefile
rename to Examples/php/funcptr/Makefile
index caeec2d73..0862ce5ec 100644
--- a/Examples/php4/cpointer/Makefile
+++ b/Examples/php/funcptr/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/funcptr/example.c b/Examples/php/funcptr/example.c
similarity index 100%
rename from Examples/php4/funcptr/example.c
rename to Examples/php/funcptr/example.c
diff --git a/Examples/php4/funcptr/example.h b/Examples/php/funcptr/example.h
similarity index 100%
rename from Examples/php4/funcptr/example.h
rename to Examples/php/funcptr/example.h
diff --git a/Examples/php4/funcptr/example.i b/Examples/php/funcptr/example.i
similarity index 100%
rename from Examples/php4/funcptr/example.i
rename to Examples/php/funcptr/example.i
diff --git a/Examples/php4/funcptr/runme.php4 b/Examples/php/funcptr/runme.php
similarity index 100%
rename from Examples/php4/funcptr/runme.php4
rename to Examples/php/funcptr/runme.php
diff --git a/Examples/php4/overloading/Makefile b/Examples/php/overloading/Makefile
similarity index 70%
rename from Examples/php4/overloading/Makefile
rename to Examples/php/overloading/Makefile
index ef3acc773..1bc0beaab 100644
--- a/Examples/php4/overloading/Makefile
+++ b/Examples/php/overloading/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/overloading/example.cxx b/Examples/php/overloading/example.cxx
similarity index 78%
rename from Examples/php4/overloading/example.cxx
rename to Examples/php/overloading/example.cxx
index fc7aff195..2f684f05c 100644
--- a/Examples/php4/overloading/example.cxx
+++ b/Examples/php/overloading/example.cxx
@@ -34,22 +34,22 @@ double Square::perimeter(void) {
return 4*width;
}
-char *overloaded(int i) {
+const char *overloaded(int i) {
return "Overloaded with int";
}
-char *overloaded(double d) {
+const char *overloaded(double d) {
return "Overloaded with double";
}
-char *overloaded(const char * str) {
+const char *overloaded(const char * str) {
return "Overloaded with char *";
}
-char *overloaded( const Circle& ) {
+const char *overloaded( const Circle& ) {
return "Overloaded with Circle";
}
-char *overloaded( const Shape& ) {
+const char *overloaded( const Shape& ) {
return "Overloaded with Shape";
}
diff --git a/Examples/php4/overloading/example.h b/Examples/php/overloading/example.h
similarity index 77%
rename from Examples/php4/overloading/example.h
rename to Examples/php/overloading/example.h
index 39ccc1cb1..01d71dd70 100644
--- a/Examples/php4/overloading/example.h
+++ b/Examples/php/overloading/example.h
@@ -38,9 +38,9 @@ public:
virtual double perimeter(void);
};
-char *overloaded( int i );
-char *overloaded( double d );
-char *overloaded( const char * str );
-char *overloaded( const Circle& );
-char *overloaded( const Shape& );
+const char *overloaded( int i );
+const char *overloaded( double d );
+const char *overloaded( const char * str );
+const char *overloaded( const Circle& );
+const char *overloaded( const Shape& );
diff --git a/Examples/php4/overloading/example.i b/Examples/php/overloading/example.i
similarity index 100%
rename from Examples/php4/overloading/example.i
rename to Examples/php/overloading/example.i
diff --git a/Examples/php4/overloading/runme.php4 b/Examples/php/overloading/runme.php
similarity index 100%
rename from Examples/php4/overloading/runme.php4
rename to Examples/php/overloading/runme.php
diff --git a/Examples/php4/funcptr/Makefile b/Examples/php/pointer/Makefile
similarity index 71%
rename from Examples/php4/funcptr/Makefile
rename to Examples/php/pointer/Makefile
index caeec2d73..0862ce5ec 100644
--- a/Examples/php4/funcptr/Makefile
+++ b/Examples/php/pointer/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/pointer/example.c b/Examples/php/pointer/example.c
similarity index 100%
rename from Examples/php4/pointer/example.c
rename to Examples/php/pointer/example.c
diff --git a/Examples/php4/pointer/example.i b/Examples/php/pointer/example.i
similarity index 100%
rename from Examples/php4/pointer/example.i
rename to Examples/php/pointer/example.i
diff --git a/Examples/php4/pointer/runme.php4 b/Examples/php/pointer/runme.php
similarity index 100%
rename from Examples/php4/pointer/runme.php4
rename to Examples/php/pointer/runme.php
diff --git a/Examples/php4/pragmas/Makefile b/Examples/php/pragmas/Makefile
similarity index 70%
rename from Examples/php4/pragmas/Makefile
rename to Examples/php/pragmas/Makefile
index aed110eb2..23e2675d7 100644
--- a/Examples/php4/pragmas/Makefile
+++ b/Examples/php/pragmas/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/pragmas/example.i b/Examples/php/pragmas/example.i
similarity index 70%
rename from Examples/php4/pragmas/example.i
rename to Examples/php/pragmas/example.i
index 289d4ec99..c7e8bf303 100644
--- a/Examples/php4/pragmas/example.i
+++ b/Examples/php/pragmas/example.i
@@ -21,11 +21,11 @@
zend_printf("This was %%rshutdown\n");
}
-%pragma(php4) include="include.php";
+%pragma(php) include="include.php";
-%pragma(php4) code="
+%pragma(php) code="
# This code is inserted into example.php
-echo \"this was php4 code\\n\";
+echo \"this was php code\\n\";
"
-%pragma(php4) phpinfo="php_info_print_table_start();"
+%pragma(php) phpinfo="php_info_print_table_start();"
diff --git a/Examples/php4/pragmas/include.php b/Examples/php/pragmas/include.php
similarity index 100%
rename from Examples/php4/pragmas/include.php
rename to Examples/php/pragmas/include.php
diff --git a/Examples/php4/pragmas/runme.php4 b/Examples/php/pragmas/runme.php
similarity index 100%
rename from Examples/php4/pragmas/runme.php4
rename to Examples/php/pragmas/runme.php
diff --git a/Examples/php4/sync/Makefile b/Examples/php/proxy/Makefile
similarity index 70%
rename from Examples/php4/sync/Makefile
rename to Examples/php/proxy/Makefile
index ef3acc773..1bc0beaab 100644
--- a/Examples/php4/sync/Makefile
+++ b/Examples/php/proxy/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/proxy/example.cxx b/Examples/php/proxy/example.cxx
similarity index 100%
rename from Examples/php4/proxy/example.cxx
rename to Examples/php/proxy/example.cxx
diff --git a/Examples/php4/proxy/example.h b/Examples/php/proxy/example.h
similarity index 100%
rename from Examples/php4/proxy/example.h
rename to Examples/php/proxy/example.h
diff --git a/Examples/php4/proxy/example.i b/Examples/php/proxy/example.i
similarity index 100%
rename from Examples/php4/proxy/example.i
rename to Examples/php/proxy/example.i
diff --git a/Examples/php4/proxy/runme.php4 b/Examples/php/proxy/runme.php
similarity index 100%
rename from Examples/php4/proxy/runme.php4
rename to Examples/php/proxy/runme.php
diff --git a/Examples/php4/class/Makefile b/Examples/php/reference/Makefile
similarity index 71%
rename from Examples/php4/class/Makefile
rename to Examples/php/reference/Makefile
index 39c4d2f23..252a72660 100644
--- a/Examples/php4/class/Makefile
+++ b/Examples/php/reference/Makefile
@@ -9,16 +9,16 @@ SWIGOPT = -noproxy
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/reference/example.cxx b/Examples/php/reference/example.cxx
similarity index 100%
rename from Examples/php4/reference/example.cxx
rename to Examples/php/reference/example.cxx
diff --git a/Examples/php4/reference/example.h b/Examples/php/reference/example.h
similarity index 100%
rename from Examples/php4/reference/example.h
rename to Examples/php/reference/example.h
diff --git a/Examples/php4/reference/example.i b/Examples/php/reference/example.i
similarity index 100%
rename from Examples/php4/reference/example.i
rename to Examples/php/reference/example.i
diff --git a/Examples/php4/reference/runme-proxy.php4 b/Examples/php/reference/runme-proxy.php4
similarity index 100%
rename from Examples/php4/reference/runme-proxy.php4
rename to Examples/php/reference/runme-proxy.php4
diff --git a/Examples/php4/reference/runme.php4 b/Examples/php/reference/runme.php
similarity index 100%
rename from Examples/php4/reference/runme.php4
rename to Examples/php/reference/runme.php
diff --git a/Examples/php4/pointer/Makefile b/Examples/php/simple/Makefile
similarity index 71%
rename from Examples/php4/pointer/Makefile
rename to Examples/php/simple/Makefile
index caeec2d73..0862ce5ec 100644
--- a/Examples/php4/pointer/Makefile
+++ b/Examples/php/simple/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/simple/example.c b/Examples/php/simple/example.c
similarity index 100%
rename from Examples/php4/simple/example.c
rename to Examples/php/simple/example.c
diff --git a/Examples/php4/simple/example.i b/Examples/php/simple/example.i
similarity index 100%
rename from Examples/php4/simple/example.i
rename to Examples/php/simple/example.i
diff --git a/Examples/php4/simple/runme.php4 b/Examples/php/simple/runme.php
similarity index 100%
rename from Examples/php4/simple/runme.php4
rename to Examples/php/simple/runme.php
diff --git a/Examples/php4/disown/Makefile b/Examples/php/sync/Makefile
similarity index 70%
rename from Examples/php4/disown/Makefile
rename to Examples/php/sync/Makefile
index ef3acc773..1bc0beaab 100644
--- a/Examples/php4/disown/Makefile
+++ b/Examples/php/sync/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/sync/example.cxx b/Examples/php/sync/example.cxx
similarity index 91%
rename from Examples/php4/sync/example.cxx
rename to Examples/php/sync/example.cxx
index 47378924b..31ed2021b 100644
--- a/Examples/php4/sync/example.cxx
+++ b/Examples/php/sync/example.cxx
@@ -2,7 +2,7 @@
#include
int x = 42;
-char *s = "Test";
+char *s = (char *)"Test";
void Sync::printer(void) {
diff --git a/Examples/php4/sync/example.h b/Examples/php/sync/example.h
similarity index 100%
rename from Examples/php4/sync/example.h
rename to Examples/php/sync/example.h
diff --git a/Examples/php4/sync/example.i b/Examples/php/sync/example.i
similarity index 100%
rename from Examples/php4/sync/example.i
rename to Examples/php/sync/example.i
diff --git a/Examples/php4/sync/runme.php4 b/Examples/php/sync/runme.php
similarity index 100%
rename from Examples/php4/sync/runme.php4
rename to Examples/php/sync/runme.php
diff --git a/Examples/php4/value/Makefile b/Examples/php/value/Makefile
similarity index 71%
rename from Examples/php4/value/Makefile
rename to Examples/php/value/Makefile
index cc383ea3f..9e69d00a4 100644
--- a/Examples/php4/value/Makefile
+++ b/Examples/php/value/Makefile
@@ -9,16 +9,16 @@ SWIGOPT = -noproxy
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/value/example.c b/Examples/php/value/example.c
similarity index 100%
rename from Examples/php4/value/example.c
rename to Examples/php/value/example.c
diff --git a/Examples/php4/value/example.h b/Examples/php/value/example.h
similarity index 100%
rename from Examples/php4/value/example.h
rename to Examples/php/value/example.h
diff --git a/Examples/php4/value/example.i b/Examples/php/value/example.i
similarity index 100%
rename from Examples/php4/value/example.i
rename to Examples/php/value/example.i
diff --git a/Examples/php4/value/runme.php4 b/Examples/php/value/runme.php
similarity index 100%
rename from Examples/php4/value/runme.php4
rename to Examples/php/value/runme.php
diff --git a/Examples/php/variables/Makefile b/Examples/php/variables/Makefile
new file mode 100644
index 000000000..0862ce5ec
--- /dev/null
+++ b/Examples/php/variables/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/variables/example.c b/Examples/php/variables/example.c
similarity index 100%
rename from Examples/php4/variables/example.c
rename to Examples/php/variables/example.c
diff --git a/Examples/php4/variables/example.h b/Examples/php/variables/example.h
similarity index 100%
rename from Examples/php4/variables/example.h
rename to Examples/php/variables/example.h
diff --git a/Examples/php4/variables/example.i b/Examples/php/variables/example.i
similarity index 100%
rename from Examples/php4/variables/example.i
rename to Examples/php/variables/example.i
diff --git a/Examples/php4/variables/runme.php4 b/Examples/php/variables/runme.php
similarity index 100%
rename from Examples/php4/variables/runme.php4
rename to Examples/php/variables/runme.php
diff --git a/Examples/php4/variables/runme.php4.old b/Examples/php/variables/runme.php4.old
similarity index 100%
rename from Examples/php4/variables/runme.php4.old
rename to Examples/php/variables/runme.php4.old
diff --git a/Examples/php4/reference/BUILD-proxy.sh b/Examples/php4/reference/BUILD-proxy.sh
deleted file mode 100755
index b1c8c71a4..000000000
--- a/Examples/php4/reference/BUILD-proxy.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#! /bin/sh -e
-
-${SWIG:=swig} -php4 -make -c++ -withcxx example.cxx example.i
-make
-php -d extension_dir=. runme-proxy.php4
diff --git a/Examples/php4/variables/Makefile b/Examples/php4/variables/Makefile
deleted file mode 100644
index caeec2d73..000000000
--- a/Examples/php4/variables/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-all::
- $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
-
-static::
- $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
-
-clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
- rm -f $(TARGET).php
-
-check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
diff --git a/Examples/pike/class/Makefile b/Examples/pike/class/Makefile
old mode 100755
new mode 100644
diff --git a/Examples/pike/class/example.cxx b/Examples/pike/class/example.cxx
old mode 100755
new mode 100644
diff --git a/Examples/pike/class/example.h b/Examples/pike/class/example.h
old mode 100755
new mode 100644
diff --git a/Examples/pike/class/example.i b/Examples/pike/class/example.i
old mode 100755
new mode 100644
diff --git a/Examples/pike/constants/Makefile b/Examples/pike/constants/Makefile
old mode 100755
new mode 100644
diff --git a/Examples/pike/constants/example.i b/Examples/pike/constants/example.i
old mode 100755
new mode 100644
diff --git a/Examples/pike/overload/example.cxx b/Examples/pike/overload/example.cxx
old mode 100755
new mode 100644
diff --git a/Examples/pike/overload/example.h b/Examples/pike/overload/example.h
old mode 100755
new mode 100644
diff --git a/Examples/pike/template/Makefile b/Examples/pike/template/Makefile
old mode 100755
new mode 100644
diff --git a/Examples/pike/template/example.h b/Examples/pike/template/example.h
old mode 100755
new mode 100644
diff --git a/Examples/pike/template/example.i b/Examples/pike/template/example.i
old mode 100755
new mode 100644
diff --git a/Examples/python/callback/Makefile b/Examples/python/callback/Makefile
index ad36d7d7e..a29276e58 100644
--- a/Examples/python/callback/Makefile
+++ b/Examples/python/callback/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/class/Makefile b/Examples/python/class/Makefile
index f331b8203..74625b992 100644
--- a/Examples/python/class/Makefile
+++ b/Examples/python/class/Makefile
@@ -18,3 +18,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/class/example.dsp b/Examples/python/class/example.dsp
index dccba46b0..fd7bf8c06 100644
--- a/Examples/python/class/example.dsp
+++ b/Examples/python/class/example.dsp
@@ -126,7 +126,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@@ -141,7 +141,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/class/example.i b/Examples/python/class/example.i
index 0bf3285ca..75700b305 100644
--- a/Examples/python/class/example.i
+++ b/Examples/python/class/example.i
@@ -5,10 +5,6 @@
#include "example.h"
%}
-%typemap(in) double {
- /* hello */
-}
-
/* Let's just grab the original header file here */
%include "example.h"
diff --git a/Examples/python/constants/Makefile b/Examples/python/constants/Makefile
index 01d0f943a..1420b4e0b 100644
--- a/Examples/python/constants/Makefile
+++ b/Examples/python/constants/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/contract/Makefile b/Examples/python/contract/Makefile
index c7b476995..77fe94b1a 100644
--- a/Examples/python/contract/Makefile
+++ b/Examples/python/contract/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/contract/example.dsp b/Examples/python/contract/example.dsp
index 7a32f4dc1..32845e0e8 100644
--- a/Examples/python/contract/example.dsp
+++ b/Examples/python/contract/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -python $(InputPath)
+ ..\..\..\swig.exe -python $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -python $(InputPath)
+ ..\..\..\swig.exe -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/docstrings/Makefile b/Examples/python/docstrings/Makefile
index 74ab112a1..f25450cac 100644
--- a/Examples/python/docstrings/Makefile
+++ b/Examples/python/docstrings/Makefile
@@ -21,3 +21,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/enum/Makefile b/Examples/python/enum/Makefile
index f331b8203..74625b992 100644
--- a/Examples/python/enum/Makefile
+++ b/Examples/python/enum/Makefile
@@ -18,3 +18,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/exception/Makefile b/Examples/python/exception/Makefile
index 17c4f30b7..7dbdde944 100644
--- a/Examples/python/exception/Makefile
+++ b/Examples/python/exception/Makefile
@@ -18,3 +18,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/exceptproxy/Makefile b/Examples/python/exceptproxy/Makefile
index a4f334311..ba5c79827 100644
--- a/Examples/python/exceptproxy/Makefile
+++ b/Examples/python/exceptproxy/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/extend/Makefile b/Examples/python/extend/Makefile
index ad36d7d7e..a29276e58 100644
--- a/Examples/python/extend/Makefile
+++ b/Examples/python/extend/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/funcptr/Makefile b/Examples/python/funcptr/Makefile
index 4a1e1bb71..0f4a1e077 100644
--- a/Examples/python/funcptr/Makefile
+++ b/Examples/python/funcptr/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/funcptr2/Makefile b/Examples/python/funcptr2/Makefile
index 4a1e1bb71..0f4a1e077 100644
--- a/Examples/python/funcptr2/Makefile
+++ b/Examples/python/funcptr2/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/functor/Makefile b/Examples/python/functor/Makefile
index c45536529..fe389757a 100644
--- a/Examples/python/functor/Makefile
+++ b/Examples/python/functor/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/import/Makefile b/Examples/python/import/Makefile
index e00e81864..74d4f88cf 100644
--- a/Examples/python/import/Makefile
+++ b/Examples/python/import/Makefile
@@ -19,3 +19,4 @@ clean::
@rm -f foo.py bar.py spam.py base.py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/import/bar.dsp b/Examples/python/import/bar.dsp
index edb45811b..17b05cc39 100644
--- a/Examples/python/import/bar.dsp
+++ b/Examples/python/import/bar.dsp
@@ -118,7 +118,7 @@ InputName=bar
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=bar
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/import/base.dsp b/Examples/python/import/base.dsp
index 0ddb65157..2bc9736d1 100644
--- a/Examples/python/import/base.dsp
+++ b/Examples/python/import/base.dsp
@@ -118,7 +118,7 @@ InputName=base
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=base
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/import/foo.dsp b/Examples/python/import/foo.dsp
index 86e11699f..9a92c4b85 100644
--- a/Examples/python/import/foo.dsp
+++ b/Examples/python/import/foo.dsp
@@ -118,7 +118,7 @@ InputName=foo
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=foo
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/import/spam.dsp b/Examples/python/import/spam.dsp
index 7245f7a7c..0a6595bfe 100644
--- a/Examples/python/import/spam.dsp
+++ b/Examples/python/import/spam.dsp
@@ -118,7 +118,7 @@ InputName=spam
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=spam
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/import_template/Makefile b/Examples/python/import_template/Makefile
index fa49f3145..ee47e994d 100644
--- a/Examples/python/import_template/Makefile
+++ b/Examples/python/import_template/Makefile
@@ -19,3 +19,4 @@ clean::
@rm -f foo.py bar.py spam.py base.py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/libffi/Makefile b/Examples/python/libffi/Makefile
index 8c7edfa65..fafb7de09 100644
--- a/Examples/python/libffi/Makefile
+++ b/Examples/python/libffi/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/multimap/Makefile b/Examples/python/multimap/Makefile
index 4a1e1bb71..0f4a1e077 100644
--- a/Examples/python/multimap/Makefile
+++ b/Examples/python/multimap/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/multimap/example.dsp b/Examples/python/multimap/example.dsp
index 7a32f4dc1..32845e0e8 100644
--- a/Examples/python/multimap/example.dsp
+++ b/Examples/python/multimap/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -python $(InputPath)
+ ..\..\..\swig.exe -python $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -python $(InputPath)
+ ..\..\..\swig.exe -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i
index 163d7cc8e..f1c4d9990 100644
--- a/Examples/python/multimap/example.i
+++ b/Examples/python/multimap/example.i
@@ -27,11 +27,24 @@ extern int gcd(int x, int y);
$2 = (char **) malloc(($1+1)*sizeof(char *));
for (i = 0; i < $1; i++) {
PyObject *s = PyList_GetItem($input,i);
- if (!PyString_Check(s)) {
+%#if PY_VERSION_HEX >= 0x03000000
+ if (!PyUnicode_Check(s))
+%#else
+ if (!PyString_Check(s))
+%#endif
+ {
free($2);
SWIG_exception(SWIG_ValueError, "List items must be strings");
}
+%#if PY_VERSION_HEX >= 0x03000000
+ {
+ int l;
+ $2[i] = PyUnicode_AsStringAndSize(s, &l);
+ }
+%#else
$2[i] = PyString_AsString(s);
+%#endif
+
}
$2[i] = 0;
}
@@ -39,12 +52,21 @@ extern int gcd(int x, int y);
extern int gcdmain(int argc, char *argv[]);
%typemap(in) (char *bytes, int len) {
+
+%#if PY_VERSION_HEX >= 0x03000000
+ if (!PyUnicode_Check($input)) {
+ PyErr_SetString(PyExc_ValueError,"Expected a string");
+ return NULL;
+ }
+ $1 = PyUnicode_AsStringAndSize($input, &$2);
+%#else
if (!PyString_Check($input)) {
PyErr_SetString(PyExc_ValueError,"Expected a string");
return NULL;
}
$1 = PyString_AsString($input);
$2 = PyString_Size($input);
+%#endif
}
extern int count(char *bytes, int len, char c);
@@ -56,9 +78,15 @@ extern int count(char *bytes, int len, char c);
so that we don't violate it's mutability */
%typemap(in) (char *str, int len) {
+%#if PY_VERSION_HEX >= 0x03000000
+ $2 = PyUnicode_GetSize($input);
+ $1 = (char *) malloc($2+1);
+ memmove($1,PyUnicode_AsString($input),$2);
+%#else
$2 = PyString_Size($input);
$1 = (char *) malloc($2+1);
memmove($1,PyString_AsString($input),$2);
+%#endif
}
/* Return the mutated string as a new object. The t_output_helper
@@ -67,7 +95,11 @@ extern int count(char *bytes, int len, char c);
%typemap(argout) (char *str, int len) {
PyObject *o;
+%#if PY_VERSION_HEX >= 0x03000000
+ o = PyUnicode_FromStringAndSize($1,$2);
+%#else
o = PyString_FromStringAndSize($1,$2);
+%#endif
$result = t_output_helper($result,o);
free($1);
}
diff --git a/Examples/python/operator/Makefile b/Examples/python/operator/Makefile
index c45536529..fe389757a 100644
--- a/Examples/python/operator/Makefile
+++ b/Examples/python/operator/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/pointer/Makefile b/Examples/python/pointer/Makefile
index 4a1e1bb71..0f4a1e077 100644
--- a/Examples/python/pointer/Makefile
+++ b/Examples/python/pointer/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/reference/Makefile b/Examples/python/reference/Makefile
index f331b8203..74625b992 100644
--- a/Examples/python/reference/Makefile
+++ b/Examples/python/reference/Makefile
@@ -18,3 +18,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/simple/Makefile b/Examples/python/simple/Makefile
index 4a1e1bb71..0f4a1e077 100644
--- a/Examples/python/simple/Makefile
+++ b/Examples/python/simple/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/simple/example.dsp b/Examples/python/simple/example.dsp
index 7a32f4dc1..32845e0e8 100644
--- a/Examples/python/simple/example.dsp
+++ b/Examples/python/simple/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -python $(InputPath)
+ ..\..\..\swig.exe -python $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -python $(InputPath)
+ ..\..\..\swig.exe -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/smartptr/Makefile b/Examples/python/smartptr/Makefile
index 58d139643..f73802a6b 100644
--- a/Examples/python/smartptr/Makefile
+++ b/Examples/python/smartptr/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/std_map/Makefile b/Examples/python/std_map/Makefile
index 2d4c1b4a3..5d13da764 100644
--- a/Examples/python/std_map/Makefile
+++ b/Examples/python/std_map/Makefile
@@ -22,3 +22,4 @@ run:
python runme.py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/std_map/example.i b/Examples/python/std_map/example.i
index 36354a882..6a7af7108 100644
--- a/Examples/python/std_map/example.i
+++ b/Examples/python/std_map/example.i
@@ -23,5 +23,5 @@ namespace std {
%template(halfi) half_map;
-%template() std::pair;
-%template(pymap) std::map;
+%template() std::pair;
+%template(pymap) std::map;
diff --git a/Examples/python/std_vector/Makefile b/Examples/python/std_vector/Makefile
index a4f334311..ba5c79827 100644
--- a/Examples/python/std_vector/Makefile
+++ b/Examples/python/std_vector/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/swigrun/Makefile b/Examples/python/swigrun/Makefile
index 53bf701c9..2142be5bb 100644
--- a/Examples/python/swigrun/Makefile
+++ b/Examples/python/swigrun/Makefile
@@ -22,3 +22,4 @@ clean::
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/template/Makefile b/Examples/python/template/Makefile
index a4f334311..ba5c79827 100644
--- a/Examples/python/template/Makefile
+++ b/Examples/python/template/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/varargs/Makefile b/Examples/python/varargs/Makefile
index 01d0f943a..1420b4e0b 100644
--- a/Examples/python/varargs/Makefile
+++ b/Examples/python/varargs/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/variables/Makefile b/Examples/python/variables/Makefile
index 4a1e1bb71..0f4a1e077 100644
--- a/Examples/python/variables/Makefile
+++ b/Examples/python/variables/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/weave/Makefile b/Examples/python/weave/Makefile
index 822779bd1..88f95c095 100644
--- a/Examples/python/weave/Makefile
+++ b/Examples/python/weave/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/r/class/example.dsp b/Examples/r/class/example.dsp
index 682b156fb..b831989cc 100644
--- a/Examples/r/class/example.dsp
+++ b/Examples/r/class/example.dsp
@@ -126,7 +126,7 @@ InputName=example
echo R_INCLUDE: %R_INCLUDE%
echo R_LIB: %R_LIB%
echo on
- ..\..\..\swig -c++ -r -o example_wrap.cpp $(InputPath)
+ ..\..\..\swig.exe -c++ -r -o example_wrap.cpp $(InputPath)
# End Custom Build
@@ -141,7 +141,7 @@ InputName=example
echo R_INCLUDE: %R_INCLUDE%
echo R_LIB: %R_LIB%
echo on
- ..\..\..\swig -c++ -r -o example_wrap.cpp $(InputPath)
+ ..\..\..\swig.exe -c++ -r -o example_wrap.cpp $(InputPath)
# End Custom Build
diff --git a/Examples/r/simple/example.dsp b/Examples/r/simple/example.dsp
index aaa5ef8e0..356815d19 100644
--- a/Examples/r/simple/example.dsp
+++ b/Examples/r/simple/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo R_INCLUDE: %R_INCLUDE%
echo R_LIB: %R_LIB%
echo on
- ..\..\..\swig -r $(InputPath)
+ ..\..\..\swig.exe -r $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo R_INCLUDE: %R_INCLUDE%
echo R_LIB: %R_LIB%
echo on
- ..\..\..\swig -r $(InputPath)
+ ..\..\..\swig.exe -r $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/class/example.dsp b/Examples/ruby/class/example.dsp
index 9a26322ec..2adab787a 100644
--- a/Examples/ruby/class/example.dsp
+++ b/Examples/ruby/class/example.dsp
@@ -128,7 +128,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -143,7 +143,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/free_function/example.dsp b/Examples/ruby/free_function/example.dsp
index 9a26322ec..2adab787a 100644
--- a/Examples/ruby/free_function/example.dsp
+++ b/Examples/ruby/free_function/example.dsp
@@ -128,7 +128,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -143,7 +143,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/free_function/example.i b/Examples/ruby/free_function/example.i
index 5ab29bd58..a446b3f99 100644
--- a/Examples/ruby/free_function/example.i
+++ b/Examples/ruby/free_function/example.i
@@ -20,7 +20,7 @@
static void free_Zoo(void* ptr) {
Zoo* zoo = (Zoo*) ptr;
- /* Loop over each object and call SWIG_RemoveMapping */
+ /* Loop over each object and call SWIG_RubyRemoveTracking */
int count = zoo->get_num_animals();
for(int i = 0; i < count; ++i) {
@@ -32,7 +32,7 @@
SWIG_RubyRemoveTracking(animal);
}
- /* Now call SWIG_RemoveMapping for the zoo */
+ /* Now call SWIG_RubyRemoveTracking for the zoo */
SWIG_RubyRemoveTracking(ptr);
/* Now free the zoo which will free the animals it contains */
diff --git a/Examples/ruby/hashargs/Makefile b/Examples/ruby/hashargs/Makefile
old mode 100755
new mode 100644
diff --git a/Examples/ruby/hashargs/example.i b/Examples/ruby/hashargs/example.i
old mode 100755
new mode 100644
diff --git a/Examples/ruby/import/bar.dsp b/Examples/ruby/import/bar.dsp
index dd09ca021..29d9abf2f 100644
--- a/Examples/ruby/import/bar.dsp
+++ b/Examples/ruby/import/bar.dsp
@@ -120,7 +120,7 @@ InputName=bar
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -135,7 +135,7 @@ InputName=bar
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/import/base.dsp b/Examples/ruby/import/base.dsp
index 2bd4fa243..174afef3e 100644
--- a/Examples/ruby/import/base.dsp
+++ b/Examples/ruby/import/base.dsp
@@ -120,7 +120,7 @@ InputName=base
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -135,7 +135,7 @@ InputName=base
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/import/foo.dsp b/Examples/ruby/import/foo.dsp
index 2a764bbd7..7f4754915 100644
--- a/Examples/ruby/import/foo.dsp
+++ b/Examples/ruby/import/foo.dsp
@@ -120,7 +120,7 @@ InputName=foo
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -135,7 +135,7 @@ InputName=foo
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/import/spam.dsp b/Examples/ruby/import/spam.dsp
index d2d7158bb..72729f290 100644
--- a/Examples/ruby/import/spam.dsp
+++ b/Examples/ruby/import/spam.dsp
@@ -120,7 +120,7 @@ InputName=spam
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -135,7 +135,7 @@ InputName=spam
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/mark_function/example.dsp b/Examples/ruby/mark_function/example.dsp
index 9a26322ec..2adab787a 100644
--- a/Examples/ruby/mark_function/example.dsp
+++ b/Examples/ruby/mark_function/example.dsp
@@ -128,7 +128,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -143,7 +143,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/multimap/example.dsp b/Examples/ruby/multimap/example.dsp
index ccb99d44d..4888299f5 100644
--- a/Examples/ruby/multimap/example.dsp
+++ b/Examples/ruby/multimap/example.dsp
@@ -124,7 +124,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -ruby $(InputPath)
+ ..\..\..\swig.exe -ruby $(InputPath)
# End Custom Build
@@ -139,7 +139,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -ruby $(InputPath)
+ ..\..\..\swig.exe -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/simple/example.dsp b/Examples/ruby/simple/example.dsp
index ccb99d44d..4888299f5 100644
--- a/Examples/ruby/simple/example.dsp
+++ b/Examples/ruby/simple/example.dsp
@@ -124,7 +124,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -ruby $(InputPath)
+ ..\..\..\swig.exe -ruby $(InputPath)
# End Custom Build
@@ -139,7 +139,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -ruby $(InputPath)
+ ..\..\..\swig.exe -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/std_vector/runme.rb b/Examples/ruby/std_vector/runme.rb
index 1529d38c6..851190536 100644
--- a/Examples/ruby/std_vector/runme.rb
+++ b/Examples/ruby/std_vector/runme.rb
@@ -9,7 +9,7 @@ puts Example::average([1,2,3,4])
# ... or a wrapped std::vector
v = Example::IntVector.new(4)
-0.upto(v.length-1) { |i| v[i] = i+1 }
+0.upto(v.size-1) { |i| v[i] = i+1 }
puts Example::average(v)
@@ -17,7 +17,7 @@ puts Example::average(v)
# Call it with a Ruby array...
w = Example::half([1.0, 1.5, 2.0, 2.5, 3.0])
-0.upto(w.length-1) { |i| print w[i],"; " }
+0.upto(w.size-1) { |i| print w[i],"; " }
puts
# ... or a wrapped std::vector
@@ -25,12 +25,12 @@ puts
v = Example::DoubleVector.new
[1,2,3,4].each { |i| v.push(i) }
w = Example::half(v)
-0.upto(w.length-1) { |i| print w[i],"; " }
+0.upto(w.size-1) { |i| print w[i],"; " }
puts
# now halve a wrapped std::vector in place
Example::halve_in_place(v)
-0.upto(v.length-1) { |i| print v[i],"; " }
+0.upto(v.size-1) { |i| print v[i],"; " }
puts
diff --git a/Examples/tcl/class/example.dsp b/Examples/tcl/class/example.dsp
index bf6149407..0ff54829f 100644
--- a/Examples/tcl/class/example.dsp
+++ b/Examples/tcl/class/example.dsp
@@ -126,7 +126,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -141,7 +141,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/contract/example.dsp b/Examples/tcl/contract/example.dsp
index 296cb313b..c1568f2c5 100644
--- a/Examples/tcl/contract/example.dsp
+++ b/Examples/tcl/contract/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/import/bar.dsp b/Examples/tcl/import/bar.dsp
index 35b4e608b..d22b6a6fa 100644
--- a/Examples/tcl/import/bar.dsp
+++ b/Examples/tcl/import/bar.dsp
@@ -118,7 +118,7 @@ InputName=bar
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=bar
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/import/base.dsp b/Examples/tcl/import/base.dsp
index 74870ccb0..b27bbfdb6 100644
--- a/Examples/tcl/import/base.dsp
+++ b/Examples/tcl/import/base.dsp
@@ -118,7 +118,7 @@ InputName=base
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=base
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/import/foo.dsp b/Examples/tcl/import/foo.dsp
index ac7f09f06..4d3765bd7 100644
--- a/Examples/tcl/import/foo.dsp
+++ b/Examples/tcl/import/foo.dsp
@@ -118,7 +118,7 @@ InputName=foo
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=foo
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/import/spam.dsp b/Examples/tcl/import/spam.dsp
index db9ade0a3..5674c4373 100644
--- a/Examples/tcl/import/spam.dsp
+++ b/Examples/tcl/import/spam.dsp
@@ -118,7 +118,7 @@ InputName=spam
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=spam
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/multimap/example.dsp b/Examples/tcl/multimap/example.dsp
index 296cb313b..c1568f2c5 100644
--- a/Examples/tcl/multimap/example.dsp
+++ b/Examples/tcl/multimap/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/simple/example.dsp b/Examples/tcl/simple/example.dsp
index 296cb313b..c1568f2c5 100644
--- a/Examples/tcl/simple/example.dsp
+++ b/Examples/tcl/simple/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/test-suite/abstract_virtual.i b/Examples/test-suite/abstract_virtual.i
index e2d8054bb..2e4d105b1 100644
--- a/Examples/test-suite/abstract_virtual.i
+++ b/Examples/test-suite/abstract_virtual.i
@@ -2,10 +2,10 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP4_MULTIPLE_INHERITANCE) D; /* C#, Java, Php4 multiple inheritance */
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP4_MULTIPLE_INHERITANCE) E; /* C#, Java, Php4 multiple inheritance */
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */
%inline %{
#if defined(_MSC_VER)
diff --git a/Examples/test-suite/allegrocl/Makefile.in b/Examples/test-suite/allegrocl/Makefile.in
index 394d2d524..df7193389 100644
--- a/Examples/test-suite/allegrocl/Makefile.in
+++ b/Examples/test-suite/allegrocl/Makefile.in
@@ -9,116 +9,75 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
+
+# these cpp tests generate warnings/errors when compiling
+# the wrapper .cxx file.
+CPP_TEST_BROKEN_CXX =
+# the error is wrap:action code generated by swig. \
+# error: can't convert [std::string] 'b' to 'bool' \
+# might just need a bool overload op for std::string. \
+ global_vars \
+# same as w/ global_vars but with more errors in cxx file \
+ naturalvar \
+
# these cpp tests aren't working. Fix 'em
# need to further separate these into tests requiring
# std libraries, or the $ldestructor problem.
CPP_TEST_BROKEN_ACL = \
- array_member \
- char_strings \
- class_ignore \
- constant_pointers \
contract \
+ allprotected \
+# 'throws' typemap entries. \
cplusplus_throw \
- cpp_basic \
- cpp_enum \
- cpp_typedef \
- default_constructor \
+# 'throws' typemap entries. \
default_args \
+# missing typemaps. suspect module support needed \
dynamic_cast \
- enum_thorough \
extend_variable \
- global_vars \
- import_nomodule \
- kind \
- li_carrays \
+# cdata.i support needed \
li_cdata \
- li_windows \
- namespace_class \
- namespace_spaces \
- naturalvar \
+# warning generated. otherwise all good. \
operator_overload \
- overload_simple \
- register_par \
+# std_common.i support \
sizet \
- smart_pointer_extend \
- smart_pointer_namespace \
- template \
- template_classes \
+# std_vector.i support. \
template_default \
- template_default_inherit \
- template_enum \
- template_explicit \
- template_extend_overload \
- template_ns \
- template_ns4 \
- template_ns_enum \
- template_rename \
- template_retvalue \
- template_static \
- template_tbase_template \
- template_typedef \
- template_typedef_cplx \
- template_typedef_cplx2 \
- template_typedef_cplx3 \
- template_typedef_cplx4 \
- template_typedef_cplx5 \
- template_typedef_ns \
- template_typedef_rec \
- threads \
- typedef_array_member \
- typedef_sizet \
+# *** line 31. can't copy typemap?? \
typemap_namespace \
- union_scope \
- using_pointers \
- valuewrapper_opaque \
- varargs \
- virtual_poly \
- voidtest \
- wrapmacro
# these aren't working due to longlong support. (low hanging fruit)
CPP_TEST_BROKEN_LONGLONG = \
arrays_dimensionless \
arrays_global \
arrays_global_twodim \
- li_stdint \
li_typemaps \
+ li_windows \
long_long_apply \
- mixed_types \
primitive_ref \
reference_global_vars \
template_default_arg
# These are currently unsupported.
CPP_TEST_CASES_ACL_UNSUPPORTED = \
+# contract support \
aggregate \
+# directors support \
+ apply_signed_char \
+# contract support \
contract \
- director_abstract \
- director_basic \
- director_constructor \
- director_detect \
- director_default \
- director_enum \
director_exception \
- director_frob \
- director_finalizer \
- director_nested \
director_protected \
- director_redefined \
- director_unroll \
- director_using \
- director_wombat \
exception_order \
+# 'throws' typemap support \
extern_throws \
- throw_exception
+ throw_exception \
+ using_pointers \
C_TEST_CASES_ACL_BROKEN = \
- arrays \
- enums \
- extern_declaration \
- immutable \
- integers \
+# 'cdate.i' module support \
li_cdata \
+# adding an existing type defnition... \
+ typedef_struct \
+# swigrun.swg support. \
typemap_subst
C_TEST_BROKEN_LONGLONG = \
@@ -128,12 +87,10 @@ C_TEST_BROKEN_LONGLONG = \
# std lib support hasn't been done yet.
SKIP_CPP_STD_CASES = Yes
-C_TEST_CASES =
-
-CPP_TEST_CASES =
-
include $(srcdir)/../common.mk
+# SWIGOPT += -debug-module 4
+
# Rules for the different types of tests
%.cpptest:
$(setup)
@@ -157,9 +114,8 @@ run_testcase = \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
-# Clean: (does nothing, we dont generate extra allegrocl code)
%.clean:
-
+ @rm -f $*.cl
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile allegrocl_clean
diff --git a/Examples/test-suite/allowexcept.i b/Examples/test-suite/allowexcept.i
index 14b19b33d..37b01cd75 100644
--- a/Examples/test-suite/allowexcept.i
+++ b/Examples/test-suite/allowexcept.i
@@ -26,14 +26,26 @@ UVW Bar::static_member_variable;
struct XYZ {
};
+// The operator& trick doesn't work for SWIG/PHP because the generated code
+// takes the address of the variable in the code in the "vinit" section.
+#ifdef SWIGPHP
%{
struct XYZ {
void foo() {}
private:
XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method
- XYZ* operator&(); // prevent dereferencing used in normally generated get method
};
%}
+#else
+%{
+struct XYZ {
+ void foo() {}
+private:
+ XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method
+ XYZ* operator&(); // prevent dereferencing used in normally generated get method
+};
+%}
+#endif
#if defined(SWIGUTL)
%exception {
/*
diff --git a/Examples/test-suite/python/argcargvtest.i b/Examples/test-suite/argcargvtest.i
similarity index 100%
rename from Examples/test-suite/python/argcargvtest.i
rename to Examples/test-suite/argcargvtest.i
diff --git a/Examples/test-suite/c/Makefile.in b/Examples/test-suite/c/Makefile.in
index 1108ff337..45a4ff915 100644
--- a/Examples/test-suite/c/Makefile.in
+++ b/Examples/test-suite/c/Makefile.in
@@ -21,6 +21,8 @@ CPP_TEST_CASES = cast_operator \
include $(srcdir)/../common.mk
+INTERFACEDIR = ../../
+
# Rules for the different types of tests
%.cpptest:
$(setup)
diff --git a/Examples/test-suite/python/callback.i b/Examples/test-suite/callback.i
similarity index 100%
rename from Examples/test-suite/python/callback.i
rename to Examples/test-suite/callback.i
diff --git a/Examples/test-suite/char_strings.i b/Examples/test-suite/char_strings.i
index b06eba773..12e4b5aa2 100644
--- a/Examples/test-suite/char_strings.i
+++ b/Examples/test-suite/char_strings.i
@@ -9,6 +9,12 @@ below.
%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) global_char_array1; // Unable to set variable of type char[]
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory.
+#ifdef SWIG_ALLEGRO_CL
+%{
+#include
+%}
+#endif
+
%{
#define OTHERLAND_MSG "Little message from the safe world."
#define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible."
diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in
index ef6d7056c..764518880 100644
--- a/Examples/test-suite/chicken/Makefile.in
+++ b/Examples/test-suite/chicken/Makefile.in
@@ -19,7 +19,7 @@ SKIP_CPP_STD_CASES = Yes
CPP_TEST_CASES += li_std_string
-EXTRA_TEST_CASES += ext_test.externaltest
+EXTRA_TEST_CASES += chicken_ext_test.externaltest
include $(srcdir)/../common.mk
diff --git a/Examples/test-suite/chicken/ext_test_runme.ss b/Examples/test-suite/chicken/chicken_ext_test_runme.ss
similarity index 57%
rename from Examples/test-suite/chicken/ext_test_runme.ss
rename to Examples/test-suite/chicken/chicken_ext_test_runme.ss
index ea3eaa487..65fa4e085 100644
--- a/Examples/test-suite/chicken/ext_test_runme.ss
+++ b/Examples/test-suite/chicken/chicken_ext_test_runme.ss
@@ -1,4 +1,4 @@
-(load "ext_test.so")
+(load "chicken_ext_test.so")
(define a (test-create))
diff --git a/Examples/test-suite/chicken/ext_test.i b/Examples/test-suite/chicken_ext_test.i
similarity index 94%
rename from Examples/test-suite/chicken/ext_test.i
rename to Examples/test-suite/chicken_ext_test.i
index e8f5930df..b4f726cc7 100644
--- a/Examples/test-suite/chicken/ext_test.i
+++ b/Examples/test-suite/chicken_ext_test.i
@@ -1,4 +1,4 @@
-%module ext_test
+%module chicken_ext_test
/* just use the imports_a.h header... for this test we only need a class */
%{
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 0a3a0858a..afcb87159 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -59,11 +59,12 @@ CXXSRCS =
CSRCS =
TARGETPREFIX =
TARGETSUFFIX =
-SWIGOPT = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE) -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) -DSWIG_NOEXTRA_QUALIFICATION
-INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE) -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
+SWIGOPT = -outcurrentdir -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
+INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
LIBS = -L.
LIBPREFIX = lib
ACTION = check
+INTERFACEDIR = ../
#
# Please keep test cases in alphabetical order.
@@ -76,8 +77,9 @@ CPP_TEST_BROKEN += \
cpp_broken \
exception_partial_info \
extend_variable \
+ li_std_vector_ptr \
namespace_union \
- nested_comment \
+ nested_struct \
overload_complicated \
template_default_pointer \
template_expr
@@ -164,6 +166,7 @@ CPP_TEST_CASES += \
director_overload \
director_primitives \
director_protected \
+ director_protected_overloaded \
director_redefined \
director_thread \
director_unroll \
@@ -191,6 +194,7 @@ CPP_TEST_CASES += \
fragments \
friends \
fvirtual \
+ global_namespace \
global_ns_arg \
global_vars \
grouping \
@@ -202,6 +206,7 @@ CPP_TEST_CASES += \
inherit_target_language \
inherit_void_arg \
inline_initializer \
+ insert_directive \
keyword_rename \
kind \
langobj \
@@ -233,10 +238,12 @@ CPP_TEST_CASES += \
namespace_typemap \
namespace_virtual_method \
naturalvar \
+ nested_comment \
newobject1 \
null_pointer \
operator_overload \
operator_overload_break \
+ operbool \
ordering \
overload_copy \
overload_extend \
@@ -259,6 +266,7 @@ CPP_TEST_CASES += \
rename3 \
rename4 \
rename_scope \
+ rename_strip_encoder \
restrict_cplusplus \
return_const_value \
return_value_scope \
@@ -403,6 +411,7 @@ CPP_STD_TEST_CASES += \
template_typedef_fnc \
template_type_namespace \
template_opaque
+# li_std_list
ifndef SKIP_CPP_STD_CASES
@@ -439,11 +448,13 @@ C_TEST_CASES += \
overload_extendc \
preproc \
ret_by_value \
+ simple_array \
sizeof_pointer \
sneaky1 \
struct_rename \
typedef_struct \
typemap_subst \
+ union_parameter \
unions
@@ -489,14 +500,14 @@ swig_and_compile_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
- TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \
+ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)_cpp
swig_and_compile_c = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CSRCS="$(CSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
- TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \
+ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)
swig_and_compile_multi_cpp = \
@@ -504,7 +515,7 @@ swig_and_compile_multi_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
- TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \
+ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
done
@@ -516,7 +527,7 @@ swig_and_compile_external = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS) $*_external.cxx" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
- TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \
+ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)_cpp
swig_and_compile_runtime = \
diff --git a/Examples/test-suite/python/complextest.i b/Examples/test-suite/complextest.i
similarity index 100%
rename from Examples/test-suite/python/complextest.i
rename to Examples/test-suite/complextest.i
diff --git a/Examples/test-suite/contract.i b/Examples/test-suite/contract.i
index 6ee0a353c..b979ef19e 100644
--- a/Examples/test-suite/contract.i
+++ b/Examples/test-suite/contract.i
@@ -3,7 +3,7 @@
%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP4_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, Php4 multiple inheritance */
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, PHP multiple inheritance */
#ifdef SWIGCSHARP
%ignore B::bar; // otherwise get a warning: `C.bar' no suitable methods found to override
@@ -201,3 +201,33 @@ struct E {
};
%}
+
+// Namespace
+
+%{
+namespace myNames {
+
+class myClass
+{
+ public:
+ myClass(int i) {}
+};
+
+}
+%}
+
+namespace myNames {
+
+%contract myClass::myClass( int i ) {
+require:
+ i > 0;
+}
+
+class myClass
+{
+ public:
+ myClass(int i) {}
+};
+
+}
+
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index 5fd576ed8..5fb547f3f 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -21,12 +21,17 @@ CPP_TEST_CASES = \
enum_thorough_typesafe \
exception_partial_info
-CUSTOM_TEST_CASES = intermediary_classname
+CUSTOM_TEST_CASES = \
+ csharp_lib_arrays \
+ intermediary_classname
include $(srcdir)/../common.mk
# Overridden variables here
SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL)
+INTERFACEDIR = ../../
+
+CSHARPFLAGSSPECIAL =
# Rules for the different types of tests
%.cpptest:
@@ -47,6 +52,8 @@ SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL)
# Rules for custom tests
intermediary_classname.customtest:
$(MAKE) intermediary_classname.cpptest SWIGOPTSPECIAL="-dllimport intermediary_classname"
+csharp_lib_arrays.customtest:
+ $(MAKE) csharp_lib_arrays.cpptest CSHARPFLAGSSPECIAL="-unsafe"
# Makes a directory for the testcase if it does not exist
setup = \
@@ -65,14 +72,14 @@ setup = \
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
- CSHARPFLAGS='-nologo -out:$*_runme.exe' \
+ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` \
$*$(CSHARPPATHSEPARATOR)*.cs' csharp_compile && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; ) \
else ( \
cd $* && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
- CSHARPFLAGS='-nologo -t:module -out:$*.netmodule' \
+ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
CSHARPSRCS='*.cs' csharp_compile; ); \
fi;
diff --git a/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs b/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs
new file mode 100644
index 000000000..9f3ea6b88
--- /dev/null
+++ b/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs
@@ -0,0 +1,70 @@
+using System;
+using csharp_lib_arraysNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ {
+ int[] source = { 1, 2, 3, 4, 5 };
+ int[] target = new int[ source.Length ];
+
+ csharp_lib_arrays.myArrayCopy( source, target, target.Length );
+ CompareArrays(source, target);
+ }
+
+ {
+ int[] source = { 1, 2, 3, 4, 5 };
+ int[] target = new int[ source.Length ];
+
+ csharp_lib_arrays.myArrayCopyUsingFixedArrays( source, target, target.Length );
+ CompareArrays(source, target);
+ }
+
+ {
+ int[] source = { 1, 2, 3, 4, 5 };
+ int[] target = new int[] { 6, 7, 8, 9, 10 };
+
+ csharp_lib_arrays.myArraySwap( source, target, target.Length );
+
+ for (int i=0; i myEnumerator = dv.GetEnumerator();
+ while ( myEnumerator.MoveNext() ) {
+ if (myEnumerator.Current != 77.7)
+ throw new Exception("Repeat (2) test failed");
+ }
+ }
+#endif
}
{
@@ -516,6 +533,13 @@ public class li_std_vector_runme {
li_std_vector.halve_in_place(dvec);
}
+ // Dispose()
+ {
+ using (StructVector vs = new StructVector() { new Struct(0.0), new Struct(11.1) } )
+ using (DoubleVector vd = new DoubleVector() { 0.0, 11.1 } ) {
+ }
+ }
+
// More wrapped methods
{
RealVector v0 = li_std_vector.vecreal(new RealVector());
diff --git a/Examples/test-suite/csharp_lib_arrays.i b/Examples/test-suite/csharp_lib_arrays.i
new file mode 100644
index 000000000..d07d43737
--- /dev/null
+++ b/Examples/test-suite/csharp_lib_arrays.i
@@ -0,0 +1,61 @@
+%module csharp_lib_arrays
+
+%include "arrays_csharp.i"
+
+%apply int INPUT[] { int* sourceArray }
+%apply int OUTPUT[] { int* targetArray }
+
+%apply int INOUT[] { int* array1 }
+%apply int INOUT[] { int* array2 }
+
+%inline %{
+/* copy the contents of the first array to the second */
+void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) {
+ int i;
+ for ( i = 0; i < nitems; i++ ) {
+ targetArray[ i ] = sourceArray[ i ];
+ }
+}
+
+/* swap the contents of the two arrays */
+void myArraySwap( int* array1, int* array2, int nitems ) {
+ int i, temp;
+ for ( i = 0; i < nitems; i++ ) {
+ temp = array1[ i ];
+ array1[ i ] = array2[ i ];
+ array2[ i ] = temp;
+ }
+}
+%}
+
+
+%clear int* sourceArray;
+%clear int* targetArray;
+
+%clear int* array1;
+%clear int* array2;
+
+
+// Below replicates the above array handling but this time using the pinned (fixed) array typemaps
+%csmethodmodifiers myArrayCopyUsingFixedArrays "public unsafe";
+%csmethodmodifiers myArraySwapUsingFixedArrays "public unsafe";
+
+%apply int FIXED[] { int* sourceArray }
+%apply int FIXED[] { int* targetArray }
+
+%inline %{
+void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) {
+ myArrayCopy(sourceArray, targetArray, nitems);
+}
+%}
+
+%apply int FIXED[] { int* array1 }
+%apply int FIXED[] { int* array2 }
+
+%inline %{
+void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) {
+ myArraySwap(array1, array2, nitems);
+}
+%}
+
+
diff --git a/Examples/test-suite/csharp_prepost.i b/Examples/test-suite/csharp_prepost.i
index 9c2cedc83..0c35c1833 100644
--- a/Examples/test-suite/csharp_prepost.i
+++ b/Examples/test-suite/csharp_prepost.i
@@ -1,6 +1,6 @@
%module csharp_prepost
-// Test the pre, post and cshin attributes for csin typemaps
+// Test the pre, post, terminate and cshin attributes for csin typemaps
%include "std_vector.i"
@@ -88,3 +88,102 @@ public:
};
%}
+
+
+// test Date marshalling with pre post and terminate typemap attributes (Documented in CSharp.html)
+%typemap(cstype) const CDate& "System.DateTime"
+%typemap(csin,
+ pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);"
+ ) const CDate &
+ "$csclassname.getCPtr(temp$csinput)"
+
+%typemap(cstype) CDate& "out System.DateTime"
+%typemap(csin,
+ pre=" CDate temp$csinput = new CDate();",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ cshin="out $csinput"
+ ) CDate &
+ "$csclassname.getCPtr(temp$csinput)"
+
+
+%inline %{
+class CDate {
+public:
+ CDate();
+ CDate(int year, int month, int day);
+ int getYear();
+ int getMonth();
+ int getDay();
+private:
+ int m_year;
+ int m_month;
+ int m_day;
+};
+struct Action {
+ int doSomething(const CDate &dateIn, CDate &dateOut);
+ Action(const CDate &dateIn, CDate& dateOut);
+};
+%}
+
+%{
+Action::Action(const CDate &dateIn, CDate& dateOut) {dateOut = dateIn;}
+int Action::doSomething(const CDate &dateIn, CDate &dateOut) { dateOut = dateIn; return 0; }
+CDate::CDate() : m_year(0), m_month(0), m_day(0) {}
+CDate::CDate(int year, int month, int day) : m_year(year), m_month(month), m_day(day) {}
+int CDate::getYear() { return m_year; }
+int CDate::getMonth() { return m_month; }
+int CDate::getDay() { return m_day; }
+%}
+
+%typemap(cstype, out="System.DateTime") CDate * "ref System.DateTime"
+
+%typemap(csin,
+ pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ cshin="ref $csinput"
+ ) CDate *
+ "$csclassname.getCPtr(temp$csinput)"
+
+%inline %{
+void addYears(CDate *pDate, int years) {
+ *pDate = CDate(pDate->getYear() + years, pDate->getMonth(), pDate->getDay());
+}
+%}
+
+%typemap(csin,
+ pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ terminator=" } // terminate temp$csinput using block",
+ cshin="ref $csinput"
+ ) CDate *
+ "$csclassname.getCPtr(temp$csinput)"
+
+%inline %{
+void subtractYears(CDate *pDate, int years) {
+ *pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay());
+}
+%}
+
+%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{
+ /* csvarin typemap code */
+ set {
+ CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);
+ $imcall;$excode
+ } %}
+
+%typemap(csvarout, excode=SWIGEXCODE2) CDate * %{
+ /* csvarout typemap code */
+ get {
+ IntPtr cPtr = $imcall;
+ CDate tempDate = (cPtr == IntPtr.Zero) ? null : new CDate(cPtr, $owner);$excode
+ return new System.DateTime(tempDate.getYear(), tempDate.getMonth(), tempDate.getDay(),
+ 0, 0, 0);
+ } %}
+
+%inline %{
+CDate ImportantDate = CDate(1999, 12, 31);
+%}
+
diff --git a/Examples/test-suite/default_constructor.i b/Examples/test-suite/default_constructor.i
index 71600e55a..ff22c7834 100644
--- a/Examples/test-suite/default_constructor.i
+++ b/Examples/test-suite/default_constructor.i
@@ -5,11 +5,11 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP4_MULTIPLE_INHERITANCE) EB; /* C#, Java, Php4 multiple inheritance */
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP4_MULTIPLE_INHERITANCE) AD; /* C#, Java, Php4 multiple inheritance */
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */
diff --git a/Examples/test-suite/director_basic.i b/Examples/test-suite/director_basic.i
index 986a1706f..12cb0db65 100644
--- a/Examples/test-suite/director_basic.i
+++ b/Examples/test-suite/director_basic.i
@@ -112,12 +112,14 @@ public:
return vmethod(b);
}
-
static MyClass *get_self(MyClass *c)
{
return c;
}
-
+
+ static Bar * call_pmethod(MyClass *myclass, Bar *b) {
+ return myclass->pmethod(b);
+ }
};
template
diff --git a/Examples/test-suite/director_classic.i b/Examples/test-suite/director_classic.i
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/director_ignore.i b/Examples/test-suite/director_ignore.i
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/python/director_profile.i b/Examples/test-suite/director_profile.i
similarity index 100%
rename from Examples/test-suite/python/director_profile.i
rename to Examples/test-suite/director_profile.i
diff --git a/Examples/test-suite/director_protected_overloaded.i b/Examples/test-suite/director_protected_overloaded.i
new file mode 100644
index 000000000..a9f786fc7
--- /dev/null
+++ b/Examples/test-suite/director_protected_overloaded.i
@@ -0,0 +1,21 @@
+%module(directors="1",dirprot="1") director_protected_overloaded
+
+%director IDataObserver;
+%director DerivedDataObserver;
+
+// protected overloaded methods
+%inline %{
+ class IDataObserver
+ {
+ public:
+ virtual ~IDataObserver(){}
+
+ protected:
+ virtual void notoverloaded() = 0;
+ virtual void isoverloaded() = 0;
+ virtual void isoverloaded(int i) = 0;
+ virtual void isoverloaded(int i, double d) = 0;
+ };
+ class DerivedDataObserver : public IDataObserver {
+ };
+%}
diff --git a/Examples/test-suite/python/director_stl.i b/Examples/test-suite/director_stl.i
similarity index 100%
rename from Examples/test-suite/python/director_stl.i
rename to Examples/test-suite/director_stl.i
diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i
index 4f4e55cfe..2732eb907 100644
--- a/Examples/test-suite/director_thread.i
+++ b/Examples/test-suite/director_thread.i
@@ -13,6 +13,7 @@
#include
#else
#include
+#include
#include
#endif
@@ -27,6 +28,8 @@ extern "C" {
void* working(void* t);
pthread_t thread;
#endif
+ static int thread_terminate = 0;
+
}
%}
@@ -51,6 +54,15 @@ extern "C" {
virtual ~Foo() {
}
+ void stop() {
+ thread_terminate = 1;
+ %#ifdef _WIN32
+ /*TODO(bhy) what to do for win32? */
+ %#else
+ pthread_join(thread, NULL);
+ %#endif
+ }
+
void run() {
%#ifdef _WIN32
_beginthreadex(NULL,0,working,this,0,&thread_id);
@@ -75,10 +87,15 @@ extern "C" {
#endif
{
Foo* f = static_cast(t);
- while (1) {
+ while ( ! thread_terminate ) {
MilliSecondSleep(50);
f->do_foo();
}
+#ifdef _WIN32
+ /* TODO(bhy) what's the corresponding of pthread_exit in win32? */
+#else
+ pthread_exit(0);
+#endif
return 0;
}
}
diff --git a/Examples/test-suite/evil_diamond.i b/Examples/test-suite/evil_diamond.i
index 33353e32e..7b2e9152f 100644
--- a/Examples/test-suite/evil_diamond.i
+++ b/Examples/test-suite/evil_diamond.i
@@ -6,7 +6,7 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP4_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
%inline %{
diff --git a/Examples/test-suite/evil_diamond_ns.i b/Examples/test-suite/evil_diamond_ns.i
index 78a764ccc..515044007 100644
--- a/Examples/test-suite/evil_diamond_ns.i
+++ b/Examples/test-suite/evil_diamond_ns.i
@@ -6,7 +6,7 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP4_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
%inline %{
namespace Blah {
diff --git a/Examples/test-suite/evil_diamond_prop.i b/Examples/test-suite/evil_diamond_prop.i
index e9fc24f4d..804ea66b4 100644
--- a/Examples/test-suite/evil_diamond_prop.i
+++ b/Examples/test-suite/evil_diamond_prop.i
@@ -6,7 +6,7 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP4_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
%inline %{
diff --git a/Examples/test-suite/features.i b/Examples/test-suite/features.i
index 2db51ae6b..2ccbe725a 100644
--- a/Examples/test-suite/features.i
+++ b/Examples/test-suite/features.i
@@ -162,3 +162,20 @@ namespace Space {
}
%}
+// Test 8 conversion operators
+%rename(opbool) operator bool;
+%rename(opuint) operator unsigned int;
+
+%exception ConversionOperators::ConversionOperators() "$action /* ConversionOperators::ConversionOperators() */";
+%exception ConversionOperators::~ConversionOperators() "$action /* ConversionOperators::~ConversionOperators() */";
+%exception ConversionOperators::operator bool "$action /* ConversionOperators::operator bool */";
+%exception ConversionOperators::operator unsigned int "$action /* ConversionOperators::unsigned int*/";
+
+%inline %{
+ class ConversionOperators {
+ public:
+ operator bool() { return false; }
+ operator unsigned int() { return 0; }
+ };
+%}
+
diff --git a/Examples/test-suite/global_namespace.i b/Examples/test-suite/global_namespace.i
new file mode 100644
index 000000000..02139f6c4
--- /dev/null
+++ b/Examples/test-suite/global_namespace.i
@@ -0,0 +1,60 @@
+%module global_namespace
+
+// classes
+%inline %{
+class Klass1 {};
+class Klass2 {};
+class Klass3 {};
+class Klass4 {};
+class Klass5 {};
+class Klass6 {};
+class Klass7 {};
+
+struct KlassMethods {
+ static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, Klass7*& pr) {}
+ static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*& pr) {}
+};
+%}
+
+%inline %{
+namespace Space {
+class XYZ1 {};
+class XYZ2 {};
+class XYZ3 {};
+class XYZ4 {};
+class XYZ5 {};
+class XYZ6 {};
+class XYZ7 {};
+}
+
+struct XYZMethods {
+ static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, Space::XYZ7*& pr) {}
+ static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*& pr) {}
+};
+%}
+
+//enums
+%inline %{
+enum AnEnum1 { anenum1 };
+enum AnEnum2 { anenum2 };
+enum AnEnum3 { anenum3 };
+
+struct AnEnumMethods {
+ static void methodA(::AnEnum1 v, const ::AnEnum2 cv, const ::AnEnum3 &cr) {}
+ static void methodB( AnEnum1 v, const AnEnum2 cv, const AnEnum3 &cr) {}
+};
+%}
+
+%inline %{
+namespace Space {
+enum TheEnum1 { theenum1 };
+enum TheEnum2 { theenum2 };
+enum TheEnum3 { theenum3 };
+
+struct TheEnumMethods {
+ static void methodA(::Space::TheEnum1 v, const ::Space::TheEnum2 cv, const ::Space::TheEnum3 &cr) {}
+ static void methodB( Space::TheEnum1 v, const Space::TheEnum2 cv, const Space::TheEnum3 &cr) {}
+};
+}
+%}
+
diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in
index 97f30e3b2..25d40674d 100644
--- a/Examples/test-suite/guile/Makefile.in
+++ b/Examples/test-suite/guile/Makefile.in
@@ -36,7 +36,7 @@ swig_and_compile_multi_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $$SWIGOPT" NOLINK=true \
- TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \
+ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
SWIGOPT=" -noruntime "; \
done
diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in
index 04de236db..eb53f020e 100644
--- a/Examples/test-suite/guilescm/Makefile.in
+++ b/Examples/test-suite/guilescm/Makefile.in
@@ -2,7 +2,7 @@
# Makefile for guile test-suite (with SCM API)
#######################################################################
-EXTRA_TEST_CASES += ext_test.externaltest
+EXTRA_TEST_CASES += guilescm_ext_test.externaltest
include ../guile/Makefile
@@ -31,7 +31,7 @@ swig_and_compile_multi_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $$SWIGOPT" NOLINK=true \
- TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \
+ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
done
diff --git a/Examples/test-suite/guilescm/ext_test_runme.scm b/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm
similarity index 82%
rename from Examples/test-suite/guilescm/ext_test_runme.scm
rename to Examples/test-suite/guilescm/guilescm_ext_test_runme.scm
index 67add849e..ff3df064b 100644
--- a/Examples/test-suite/guilescm/ext_test_runme.scm
+++ b/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm
@@ -1,4 +1,4 @@
-(dynamic-call "scm_init_ext_test_module" (dynamic-link "./libext_test.so"))
+(dynamic-call "scm_init_guilescm_ext_test_module" (dynamic-link "./libguilescm_ext_test.so"))
; This is a test for SF Bug 1573892
; If IsPointer is called before TypeQuery, the test-is-pointer will fail
diff --git a/Examples/test-suite/guilescm/ext_test.i b/Examples/test-suite/guilescm_ext_test.i
similarity index 93%
rename from Examples/test-suite/guilescm/ext_test.i
rename to Examples/test-suite/guilescm_ext_test.i
index 8b117bb5a..fd5655d4f 100644
--- a/Examples/test-suite/guilescm/ext_test.i
+++ b/Examples/test-suite/guilescm_ext_test.i
@@ -1,4 +1,4 @@
-%module ext_test
+%module guilescm_ext_test
/* just use the imports_a.h header... for this test we only need a class */
%{
diff --git a/Examples/test-suite/python/iadd.h b/Examples/test-suite/iadd.i
similarity index 79%
rename from Examples/test-suite/python/iadd.h
rename to Examples/test-suite/iadd.i
index 367eda26f..514bd3e4f 100644
--- a/Examples/test-suite/python/iadd.h
+++ b/Examples/test-suite/iadd.i
@@ -1,3 +1,12 @@
+%module iadd
+
+%include attribute.i
+class Foo;
+%attribute_ref(test::Foo, test::A& , AsA);
+%attribute_ref(test::Foo, long, AsLong);
+
+
+%inline %{
struct B {
int x;
B(const int x) : x(x) {}
@@ -45,3 +54,5 @@ private:
long *_n;
};
}
+
+%}
diff --git a/Examples/test-suite/ignore_template_constructor.i b/Examples/test-suite/ignore_template_constructor.i
index 5225d5183..ffd541986 100644
--- a/Examples/test-suite/ignore_template_constructor.i
+++ b/Examples/test-suite/ignore_template_constructor.i
@@ -37,3 +37,9 @@ public:
#endif
%template(VectFlow) std::vector;
+
+%inline %{
+std::vector inandout(std::vector v) {
+ return v;
+}
+%}
diff --git a/Examples/test-suite/octave/implicittest.i b/Examples/test-suite/implicittest.i
similarity index 100%
rename from Examples/test-suite/octave/implicittest.i
rename to Examples/test-suite/implicittest.i
diff --git a/Examples/test-suite/import_nomodule.i b/Examples/test-suite/import_nomodule.i
index 5d5115360..a1ba9ad7a 100644
--- a/Examples/test-suite/import_nomodule.i
+++ b/Examples/test-suite/import_nomodule.i
@@ -3,6 +3,9 @@
#include "import_nomodule.h"
%}
+// For Python
+%warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Bar; // Base class 'Foo' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %import directive.
+
%import "import_nomodule.h"
#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP)
diff --git a/Examples/test-suite/imports_b.i b/Examples/test-suite/imports_b.i
index afc573a39..81e84cddd 100644
--- a/Examples/test-suite/imports_b.i
+++ b/Examples/test-suite/imports_b.i
@@ -34,9 +34,14 @@
*/
#if 0
-%import "imports_a.i"
+ %import "imports_a.i"
#else
-%import(module="imports_a") "imports_a.h"
+# if 0
+ // Test Warning 401 (Python only)
+ %import "imports_a.h"
+# else
+ %import(module="imports_a") "imports_a.h"
+# endif
#endif
%include "imports_b.h"
diff --git a/Examples/test-suite/python/inout.i b/Examples/test-suite/inout.i
similarity index 100%
rename from Examples/test-suite/python/inout.i
rename to Examples/test-suite/inout.i
diff --git a/Examples/test-suite/python/inplaceadd.i b/Examples/test-suite/inplaceadd.i
similarity index 100%
rename from Examples/test-suite/python/inplaceadd.i
rename to Examples/test-suite/inplaceadd.i
diff --git a/Examples/test-suite/python/input.i b/Examples/test-suite/input.i
similarity index 100%
rename from Examples/test-suite/python/input.i
rename to Examples/test-suite/input.i
diff --git a/Examples/test-suite/insert_directive.i b/Examples/test-suite/insert_directive.i
new file mode 100644
index 000000000..8ad966a99
--- /dev/null
+++ b/Examples/test-suite/insert_directive.i
@@ -0,0 +1,38 @@
+%module insert_directive
+
+// check %insert and the order of each insert section is correct
+
+%begin %{
+// %inserted code %begin
+int inserted_begin(int i) { return i; }
+%}
+
+%runtime %{
+// %inserted code %runtime
+int inserted_runtime(int i) { return inserted_begin(i); }
+%}
+
+%{
+// %inserted code %header
+int inserted_header1(int i) { return inserted_runtime(i); }
+%}
+
+%header %{
+// %inserted code %header
+int inserted_header2(int i) { return inserted_header1(i); }
+%}
+
+%{
+// %inserted code %header
+int inserted_header3(int i) { return inserted_header2(i); }
+%}
+
+%wrapper %{
+// %inserted code %wrapper
+int inserted_wrapper(int i) { return inserted_header3(i); }
+%}
+
+%init %{
+// %inserted code %init
+int inserted_init_value = inserted_wrapper(0);
+%}
diff --git a/Examples/test-suite/intermediary_classname.i b/Examples/test-suite/intermediary_classname.i
index 0f90f9cdd..94858a5fb 100644
--- a/Examples/test-suite/intermediary_classname.i
+++ b/Examples/test-suite/intermediary_classname.i
@@ -18,6 +18,7 @@
"new $javaclassname($jniinput, false)/*javadirectorin*/"
%typemap(out, throws="IllegalAccessException/*out Base&*/") Base& {
// XYZ& typemap out
+ $result = 0; // remove unused variable warning
}
%inline %{
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index ace8dee86..03c10d498 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -32,11 +32,13 @@ CPP_TEST_CASES = \
java_throws \
java_typemaps_proxy \
java_typemaps_typewrapper
+# li_boost_intrusive_ptr
include $(srcdir)/../common.mk
# Overridden variables here
SWIGOPT += -package $*
+INTERFACEDIR = ../../
# Rules for the different types of tests
%.cpptest:
@@ -72,7 +74,7 @@ run_testcase = \
(cd $* && $(COMPILETOOL) $(JAVAC) -classpath . *.java) && \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
- env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*\_runme;) \
+ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme;) \
fi;
# Clean: remove testcase directories
diff --git a/Examples/test-suite/java/allprotected_runme.java b/Examples/test-suite/java/allprotected_runme.java
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/java/director_basic_runme.java b/Examples/test-suite/java/director_basic_runme.java
index eafe20bec..16a46aa35 100644
--- a/Examples/test-suite/java/director_basic_runme.java
+++ b/Examples/test-suite/java/director_basic_runme.java
@@ -14,28 +14,43 @@ public class director_basic_runme {
public static void main(String argv[]) {
- director_basic_MyFoo a = new director_basic_MyFoo();
+ director_basic_MyFoo a = new director_basic_MyFoo();
- if (!a.ping().equals("director_basic_MyFoo::ping()")) {
- throw new RuntimeException ( "a.ping()" );
- }
+ if (!a.ping().equals("director_basic_MyFoo::ping()")) {
+ throw new RuntimeException ( "a.ping()" );
+ }
- if (!a.pong().equals("Foo::pong();director_basic_MyFoo::ping()")) {
- throw new RuntimeException ( "a.pong()" );
- }
+ if (!a.pong().equals("Foo::pong();director_basic_MyFoo::ping()")) {
+ throw new RuntimeException ( "a.pong()" );
+ }
- Foo b = new Foo();
+ Foo b = new Foo();
- if (!b.ping().equals("Foo::ping()")) {
- throw new RuntimeException ( "b.ping()" );
- }
+ if (!b.ping().equals("Foo::ping()")) {
+ throw new RuntimeException ( "b.ping()" );
+ }
- if (!b.pong().equals("Foo::pong();Foo::ping()")) {
- throw new RuntimeException ( "b.pong()" );
- }
+ if (!b.pong().equals("Foo::pong();Foo::ping()")) {
+ throw new RuntimeException ( "b.pong()" );
+ }
- A1 a1 = new A1(1, false);
- a1.delete();
+ A1 a1 = new A1(1, false);
+ a1.delete();
+
+ {
+ MyOverriddenClass my = new MyOverriddenClass();
+
+ my.expectNull = true;
+ if (MyClass.call_pmethod(my, null) != null)
+ throw new RuntimeException("null pointer marshalling problem");
+
+ Bar myBar = new Bar();
+ my.expectNull = false;
+ Bar myNewBar = MyClass.call_pmethod(my, myBar);
+ if (myNewBar == null)
+ throw new RuntimeException("non-null pointer marshalling problem");
+ myNewBar.setX(10);
+ }
}
}
@@ -45,3 +60,13 @@ class director_basic_MyFoo extends Foo {
}
}
+class MyOverriddenClass extends MyClass {
+ public boolean expectNull = false;
+ public boolean nonNullReceived = false;
+ public Bar pmethod(Bar b) {
+ if ( expectNull && (b != null) )
+ throw new RuntimeException("null not received as expected");
+ return b;
+ }
+}
+
diff --git a/Examples/test-suite/java/director_classic_runme.java b/Examples/test-suite/java/director_classic_runme.java
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/java/director_ignore_runme.java b/Examples/test-suite/java/director_ignore_runme.java
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/java/global_namespace_runme.java b/Examples/test-suite/java/global_namespace_runme.java
new file mode 100644
index 000000000..faab7d4ba
--- /dev/null
+++ b/Examples/test-suite/java/global_namespace_runme.java
@@ -0,0 +1,25 @@
+import global_namespace.*;
+
+public class global_namespace_runme {
+
+ static {
+ try {
+ System.loadLibrary("global_namespace");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ KlassMethods.methodA(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
+ KlassMethods.methodB(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
+
+ XYZMethods.methodA(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
+ XYZMethods.methodB(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
+
+ TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3);
+ TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3);
+ }
+}
diff --git a/Examples/test-suite/java/java_throws_runme.java b/Examples/test-suite/java/java_throws_runme.java
index 3538aa6d4..6a73ea563 100644
--- a/Examples/test-suite/java/java_throws_runme.java
+++ b/Examples/test-suite/java/java_throws_runme.java
@@ -94,5 +94,20 @@ public class java_throws_runme {
if (!pass)
throw new RuntimeException("Test 7 failed");
+
+ // Test %nojavaexception
+ NoExceptTest net = new NoExceptTest();
+
+ pass = false;
+ try {
+ net.exceptionPlease();
+ pass = true;
+ }
+ catch (MyException e) {}
+
+ if (!pass)
+ throw new RuntimeException("Test 8 failed");
+
+ net.noExceptionPlease();
}
}
diff --git a/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java
new file mode 100644
index 000000000..f40c28e9e
--- /dev/null
+++ b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java
@@ -0,0 +1,701 @@
+import li_boost_intrusive_ptr.*;
+
+public class li_boost_intrusive_ptr_runme {
+ static {
+ try {
+ System.loadLibrary("li_boost_intrusive_ptr");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ // Debugging flag
+ public final static boolean debug = false;
+
+ public static void main(String argv[])
+ {
+ if (debug)
+ System.out.println("Started");
+
+ li_boost_intrusive_ptr.setDebug_shared(debug);
+
+ // Change loop count to run for a long time to monitor memory
+ final int loopCount = 5000; //5000;
+ for (int i=0; iFindClass("java_throws/MyException");
+ if (excep)
+ jenv->ThrowNew(excep, "exception message");
+ return $null;
+}
+%}
+
+%nojavaexception *::noExceptionPlease();
+%nojavaexception NoExceptTest::NoExceptTest();
+
+// Need to handle the checked exception in NoExceptTest.delete()
+%typemap(javafinalize) SWIGTYPE %{
+ protected void finalize() {
+ try {
+ delete();
+ } catch (MyException e) {
+ throw new RuntimeException(e);
+ }
+ }
+%}
+
+%inline %{
+struct NoExceptTest {
+ unsigned int noExceptionPlease() { return 123; }
+ unsigned int exceptionPlease() { return 456; }
+ ~NoExceptTest() {}
+};
+%}
+
+// Turn global exceptions off (for the implicit destructors/constructors)
+%nojavaexception;
+
diff --git a/Examples/test-suite/li_attribute.i b/Examples/test-suite/li_attribute.i
index 5b4379ebf..4f9497afb 100644
--- a/Examples/test-suite/li_attribute.i
+++ b/Examples/test-suite/li_attribute.i
@@ -93,9 +93,11 @@ struct MyFoo; // %attribute2 does not work with templates
%template(Param_i) Param;
+// class/struct attribute with get/set methods using return/pass by reference
%attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo);
%inline %{
struct MyFoo {
+ MyFoo() : x(-1) {}
int x;
};
class MyClass {
@@ -106,3 +108,32 @@ struct MyFoo; // %attribute2 does not work with templates
};
%}
+
+// class/struct attribute with get/set methods using return/pass by value
+%attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo);
+%attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo);
+%inline %{
+ class MyClassVal {
+ MyFoo foo;
+ public:
+ MyFoo GetFoo() { return foo; }
+ void SetFoo(MyFoo other) { foo = other; }
+ };
+%}
+
+
+// string attribute with get/set methods using return/pass by value
+%include
+%attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString);
+%attributestring(MyStringyClass, std::string, ReadOnlyString, GetString);
+%inline %{
+ class MyStringyClass {
+ std::string str;
+ public:
+ MyStringyClass(const std::string &val) : str(val) {}
+ std::string GetString() { return str; }
+ void SetString(std::string other) { str = other; }
+ };
+%}
+
+
diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i
new file mode 100644
index 000000000..7c37e6843
--- /dev/null
+++ b/Examples/test-suite/li_boost_intrusive_ptr.i
@@ -0,0 +1,494 @@
+// This tests intrusive_ptr is working okay. It also checks that there are no memory leaks in the
+// class that intrusive_ptr is pointing via a counting mechanism in the constructors and destructor of Klass.
+// In order to test that there are no leaks of the intrusive_ptr class itself (as it is created on the heap)
+// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
+// like 'top'. There is a wrapper for intrusive_ptr in intrusive_ptr_wrapper.h which enables one to
+// count the instances of intrusive_ptr. Uncomment the INTRUSIVE_PTR_WRAPPER macro to turn this on.
+//
+// Also note the debug_shared flag which can be set from the target language.
+
+%module li_boost_intrusive_ptr
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
+
+%inline %{
+#include "boost/shared_ptr.hpp"
+#include "boost/intrusive_ptr.hpp"
+#include
+
+// Uncomment macro below to turn on intrusive_ptr memory leak checking as described above
+//#define INTRUSIVE_PTR_WRAPPER
+
+#ifdef INTRUSIVE_PTR_WRAPPER
+# include "intrusive_ptr_wrapper.h"
+# include "shared_ptr_wrapper.h"
+#endif
+%}
+
+%{
+#ifndef INTRUSIVE_PTR_WRAPPER
+# define SwigBoost boost
+#endif
+%}
+
+%include "std_string.i"
+#ifndef INTRUSIVE_PTR_WRAPPER
+# define SWIG_INTRUSIVE_PTR_NAMESPACE SwigBoost
+# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
+#endif
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON)
+#define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED
+#endif
+
+#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
+
+%include
+SWIG_INTRUSIVE_PTR(Klass, Space::Klass)
+SWIG_INTRUSIVE_PTR_NO_WRAP(KlassWithoutRefCount, Space::KlassWithoutRefCount)
+SWIG_INTRUSIVE_PTR_DERIVED(KlassDerived, Space::KlassWithoutRefCount, Space::KlassDerived)
+SWIG_INTRUSIVE_PTR_DERIVED(KlassDerivedDerived, Space::KlassDerived, Space::KlassDerivedDerived)
+
+//For the use_count shared_ptr functions
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{
+ $1 = $input ? *($&1_ltype)&$input : &tempnull;
+%}
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass.getCPtr($javainput)"
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & ($*1_ltype tempnull) %{
+ $1 = $input ? *($&1_ltype)&$input : &tempnull;
+%}
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived.getCPtr($javainput)"
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & ($*1_ltype tempnull) %{
+ $1 = $input ? *($&1_ltype)&$input : &tempnull;
+%}
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived.getCPtr($javainput)"
+
+#endif
+
+// TODO:
+// const intrusive_ptr
+// std::vector
+// Add in generic %extend for the Upcast function for derived classes
+// Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method
+
+%exception {
+ if (debug_shared) {
+ cout << "++++++" << endl << flush;
+ cout << "calling $name" << endl << flush;
+ }
+ $action
+ if (debug_shared) {
+ cout << "------" << endl << flush;
+ }
+}
+
+%ignore IgnoredRefCountingBase;
+%ignore *::operator=;
+%ignore intrusive_ptr_add_ref;
+%ignore intrusive_ptr_release;
+%newobject pointerownertest();
+%newobject smartpointerpointerownertest();
+
+%inline %{
+#include
+using namespace std;
+
+static bool debug_shared = false;
+
+namespace Space {
+
+struct Klass {
+ Klass() : value("EMPTY"), count(0) { if (debug_shared) cout << "Klass() [" << value << "]" << endl << flush; increment(); }
+
+ Klass(const std::string &val) : value(val), count(0) { if (debug_shared) cout << "Klass(string) [" << value << "]" << endl << flush; increment(); }
+
+ virtual ~Klass() { if (debug_shared) cout << "~Klass() [" << value << "]" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return value; }
+ void append(const std::string &s) { value += s; }
+ Klass(const Klass &other) : value(other.value), count(0) { if (debug_shared) cout << "Klass(const Klass&) [" << value << "]" << endl << flush; increment(); }
+
+ Klass &operator=(const Klass &other) { value = other.value; return *this; }
+
+ void addref(void) const { ++count; }
+ void release(void) const { if (--count == 0) delete this; }
+ int use_count(void) const { return count; }
+ static long getTotal_count() { return total_count; }
+
+private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx Klass::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+ std::string value;
+ int array[1024];
+ mutable boost::detail::atomic_count count;
+};
+
+struct KlassWithoutRefCount {
+ KlassWithoutRefCount() : value("EMPTY") { if (debug_shared) cout << "KlassWithoutRefCount() [" << value << "]" << endl << flush; increment(); }
+
+ KlassWithoutRefCount(const std::string &val) : value(val) { if (debug_shared) cout << "KlassWithoutRefCount(string) [" << value << "]" << endl << flush; increment(); }
+
+ virtual ~KlassWithoutRefCount() { if (debug_shared) cout << "~KlassWithoutRefCount() [" << value << "]" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return value; }
+ void append(const std::string &s) { value += s; }
+ KlassWithoutRefCount(const KlassWithoutRefCount &other) : value(other.value) { if (debug_shared) cout << "KlassWithoutRefCount(const KlassWithoutRefCount&) [" << value << "]" << endl << flush; increment(); }
+ std::string getSpecialValueFromUnwrappableClass() { return "this class cannot be wrapped by intrusive_ptrs but we can still use it"; }
+ KlassWithoutRefCount &operator=(const KlassWithoutRefCount &other) { value = other.value; return *this; }
+ static long getTotal_count() { return total_count; }
+
+private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassWithoutRefCount::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassWithoutRefCount::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+ std::string value;
+ int array[1024];
+};
+
+struct IgnoredRefCountingBase {
+ IgnoredRefCountingBase() : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase()" << endl << flush; increment(); }
+
+ IgnoredRefCountingBase(const IgnoredRefCountingBase &other) : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase(const IgnoredRefCountingBase&)" << endl << flush; increment(); }
+
+ IgnoredRefCountingBase &operator=(const IgnoredRefCountingBase& other) {
+ return *this;
+ }
+
+ virtual ~IgnoredRefCountingBase() { if (debug_shared) cout << "~IgnoredRefCountingBase()" << endl << flush; decrement(); }
+
+ void addref(void) const { ++count; }
+ void release(void) const { if (--count == 0) delete this; }
+ int use_count(void) const { return count; }
+ static long getTotal_count() { return total_count; }
+
+ private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx IgnoredRefCountingBase::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx IgnoredRefCountingBase::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+ double d;
+ double e;
+ mutable boost::detail::atomic_count count;
+};
+
+long getTotal_IgnoredRefCountingBase_count() {
+ return IgnoredRefCountingBase::getTotal_count();
+}
+
+// For most compilers, this use of multiple inheritance results in different derived and base class
+// pointer values ... for some more challenging tests :)
+struct KlassDerived : IgnoredRefCountingBase, KlassWithoutRefCount {
+ KlassDerived() : KlassWithoutRefCount() { if (debug_shared) cout << "KlassDerived()" << endl << flush; increment(); }
+ KlassDerived(const std::string &val) : KlassWithoutRefCount(val) { if (debug_shared) cout << "KlassDerived(string) [" << val << "]" << endl << flush; increment(); }
+ KlassDerived(const KlassDerived &other) : KlassWithoutRefCount(other) { if (debug_shared) cout << "KlassDerived(const KlassDerived&))" << endl << flush; increment(); }
+ virtual ~KlassDerived() { if (debug_shared) cout << "~KlassDerived()" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-Derived"; }
+ int use_count(void) const { return IgnoredRefCountingBase::use_count(); }
+ static long getTotal_count() { return total_count; }
+
+ private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerived::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerived::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+};
+struct KlassDerivedDerived : KlassDerived {
+ KlassDerivedDerived() : KlassDerived() { if (debug_shared) cout << "KlassDerivedDerived()" << endl << flush; increment(); }
+ KlassDerivedDerived(const std::string &val) : KlassDerived(val) { if (debug_shared) cout << "KlassDerivedDerived(string) [" << val << "]" << endl << flush; increment(); }
+ KlassDerivedDerived(const KlassDerived &other) : KlassDerived(other) { if (debug_shared) cout << "KlassDerivedDerived(const KlassDerivedDerived&))" << endl << flush; increment(); }
+ virtual ~KlassDerivedDerived() { if (debug_shared) cout << "~KlassDerivedDerived()" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-DerivedDerived"; }
+ static long getTotal_count() { return total_count; }
+
+ private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerivedDerived::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerivedDerived::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+};
+KlassDerived* derivedpointertest(KlassDerived* kd) {
+ if (kd)
+ kd->append(" derivedpointertest");
+ return kd;
+}
+KlassDerived derivedvaluetest(KlassDerived kd) {
+ kd.append(" derivedvaluetest");
+ return kd;
+}
+KlassDerived& derivedreftest(KlassDerived& kd) {
+ kd.append(" derivedreftest");
+ return kd;
+}
+SwigBoost::intrusive_ptr derivedsmartptrtest(SwigBoost::intrusive_ptr kd) {
+ if (kd)
+ kd->append(" derivedsmartptrtest");
+ return kd;
+}
+SwigBoost::intrusive_ptr* derivedsmartptrpointertest(SwigBoost::intrusive_ptr* kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrpointertest");
+ return kd;
+}
+SwigBoost::intrusive_ptr* derivedsmartptrreftest(SwigBoost::intrusive_ptr* kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrreftest");
+ return kd;
+}
+SwigBoost::intrusive_ptr*& derivedsmartptrpointerreftest(SwigBoost::intrusive_ptr*& kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrpointerreftest");
+ return kd;
+}
+
+SwigBoost::intrusive_ptr factorycreate() {
+ return SwigBoost::intrusive_ptr(new Klass("factorycreate"));
+}
+// smart pointer
+SwigBoost::intrusive_ptr smartpointertest(SwigBoost::intrusive_ptr k) {
+ if (k)
+ k->append(" smartpointertest");
+ return SwigBoost::intrusive_ptr(k);
+}
+SwigBoost::intrusive_ptr* smartpointerpointertest(SwigBoost::intrusive_ptr* k) {
+ if (k && *k)
+ (*k)->append(" smartpointerpointertest");
+ return k;
+}
+SwigBoost::intrusive_ptr& smartpointerreftest(SwigBoost::intrusive_ptr& k) {
+ if (k)
+ k->append(" smartpointerreftest");
+ return k;
+}
+SwigBoost::intrusive_ptr*& smartpointerpointerreftest(SwigBoost::intrusive_ptr*& k) {
+ if (k && *k)
+ (*k)->append(" smartpointerpointerreftest");
+ return k;
+}
+// const
+SwigBoost::intrusive_ptr constsmartpointertest(SwigBoost::intrusive_ptr k) {
+ return SwigBoost::intrusive_ptr(k);
+}
+SwigBoost::intrusive_ptr* constsmartpointerpointertest(SwigBoost::intrusive_ptr* k) {
+ return k;
+}
+SwigBoost::intrusive_ptr& constsmartpointerreftest(SwigBoost::intrusive_ptr& k) {
+ return k;
+}
+// plain pointer
+Klass valuetest(Klass k) {
+ k.append(" valuetest");
+ return k;
+}
+Klass *pointertest(Klass *k) {
+ if (k)
+ k->append(" pointertest");
+ return k;
+}
+Klass& reftest(Klass& k) {
+ k.append(" reftest");
+ return k;
+}
+Klass*& pointerreftest(Klass*& k) {
+ k->append(" pointerreftest");
+ return k;
+}
+// null
+std::string nullsmartpointerpointertest(SwigBoost::intrusive_ptr* k) {
+ if (k && *k)
+ return "not null";
+ else if (!k)
+ return "null smartpointer pointer";
+ else if (!*k)
+ return "null pointer";
+ else
+ return "also not null";
+}
+// $owner
+Klass *pointerownertest() {
+ return new Klass("pointerownertest");
+}
+SwigBoost::intrusive_ptr* smartpointerpointerownertest() {
+ return new SwigBoost::intrusive_ptr(new Klass("smartpointerpointerownertest"));
+}
+
+const SwigBoost::intrusive_ptr& ref_1() {
+ static SwigBoost::intrusive_ptr sptr;
+ return sptr;
+}
+
+// overloading tests
+std::string overload_rawbyval(int i) { return "int"; }
+std::string overload_rawbyval(Klass k) { return "rawbyval"; }
+
+std::string overload_rawbyref(int i) { return "int"; }
+std::string overload_rawbyref(Klass &k) { return "rawbyref"; }
+
+std::string overload_rawbyptr(int i) { return "int"; }
+std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; }
+
+std::string overload_rawbyptrref(int i) { return "int"; }
+std::string overload_rawbyptrref(Klass *&k) { return "rawbyptrref"; }
+
+
+
+std::string overload_smartbyval(int i) { return "int"; }
+std::string overload_smartbyval(SwigBoost::intrusive_ptr k) { return "smartbyval"; }
+
+std::string overload_smartbyref(int i) { return "int"; }
+std::string overload_smartbyref(SwigBoost::intrusive_ptr &k) { return "smartbyref"; }
+
+std::string overload_smartbyptr(int i) { return "int"; }
+std::string overload_smartbyptr(SwigBoost::intrusive_ptr *k) { return "smartbyptr"; }
+
+std::string overload_smartbyptrref(int i) { return "int"; }
+std::string overload_smartbyptrref(SwigBoost::intrusive_ptr *&k) { return "smartbyptrref"; }
+
+} // namespace Space
+
+%}
+%{
+ boost::detail::atomic_count Space::Klass::total_count(0);
+ boost::detail::atomic_count Space::KlassWithoutRefCount::total_count(0);
+ boost::detail::atomic_count Space::IgnoredRefCountingBase::total_count(0);
+ boost::detail::atomic_count Space::KlassDerived::total_count(0);
+ boost::detail::atomic_count Space::KlassDerivedDerived::total_count(0);
+%}
+
+// Member variables
+
+%inline %{
+struct MemberVariables {
+ MemberVariables() : SmartMemberPointer(new SwigBoost::intrusive_ptr()), SmartMemberReference(*(new SwigBoost::intrusive_ptr())), MemberPointer(0), MemberReference(MemberValue) {}
+ virtual ~MemberVariables() {
+ delete SmartMemberPointer;
+ delete &SmartMemberReference;
+ }
+ SwigBoost::intrusive_ptr SmartMemberValue;
+ SwigBoost::intrusive_ptr * SmartMemberPointer;
+ SwigBoost::intrusive_ptr & SmartMemberReference;
+ Space::Klass MemberValue;
+ Space::Klass * MemberPointer;
+ Space::Klass & MemberReference;
+};
+
+// Global variables
+SwigBoost::intrusive_ptr GlobalSmartValue;
+Space::Klass GlobalValue;
+Space::Klass * GlobalPointer = 0;
+Space::Klass & GlobalReference = GlobalValue;
+
+%}
+
+#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
+
+// Note: %template after the intrusive_ptr typemaps
+SWIG_INTRUSIVE_PTR(BaseIntDouble, Base)
+// Note: cannot use Base in the macro below because of the comma in the type,
+// so we use a typedef instead. Alternatively use %arg(Base). %arg is defined in swigmacros.swg.
+SWIG_INTRUSIVE_PTR_DERIVED(PairIntDouble, BaseIntDouble_t, Pair)
+
+#endif
+
+// Templates
+%inline %{
+template struct Base {
+ Space::Klass klassBase;
+ T1 baseVal1;
+ T2 baseVal2;
+ Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {}
+ virtual std::string getValue() const { return "Base<>"; };
+ mutable int count;
+ void addref(void) const { count++; }
+ void release(void) const { if (--count == 0) delete this; }
+ int use_count(void) const { return count; }
+};
+typedef Base BaseIntDouble_t;
+%}
+
+%template(BaseIntDouble) Base;
+
+%inline %{
+template struct Pair : Base {
+ Space::Klass klassPair;
+ T1 val1;
+ T2 val2;
+ Pair(T1 t1, T2 t2) : Base(t1, t2), val1(t1), val2(t2) {}
+ virtual std::string getValue() const { return "Pair<>"; };
+};
+
+Pair pair_id2(Pair p) { return p; }
+SwigBoost::intrusive_ptr< Pair > pair_id1(SwigBoost::intrusive_ptr< Pair > p) { return p; }
+
+template void intrusive_ptr_add_ref(const T* r) { r->addref(); }
+
+template void intrusive_ptr_release(const T* r) { r->release(); }
+
+long use_count(const SwigBoost::shared_ptr& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr& sptr) {
+ return sptr.use_count();
+}
+%}
+
+%template(PairIntDouble) Pair;
+
+// For counting the instances of intrusive_ptr (all of which are created on the heap)
+// intrusive_ptr_wrapper_count() gives overall count
+%inline %{
+namespace SwigBoost {
+ const int NOT_COUNTING = -123456;
+ int intrusive_ptr_wrapper_count() {
+ #ifdef INTRUSIVE_PTR_WRAPPER
+ return SwigBoost::IntrusivePtrWrapper::getTotalCount();
+ #else
+ return NOT_COUNTING;
+ #endif
+ }
+ #ifdef INTRUSIVE_PTR_WRAPPER
+ template<> std::string show_message(boost::intrusive_ptr*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "Klass: " + (*t)->getValue();
+ else
+ return "Klass: NULL";
+ }
+ template<> std::string show_message(boost::intrusive_ptr*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "Klass: " + (*t)->getValue();
+ else
+ return "Klass: NULL";
+ }
+ template<> std::string show_message(boost::intrusive_ptr*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "KlassDerived: " + (*t)->getValue();
+ else
+ return "KlassDerived: NULL";
+ }
+ template<> std::string show_message(boost::intrusive_ptr*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "KlassDerived: " + (*t)->getValue();
+ else
+ return "KlassDerived: NULL";
+ }
+ #endif
+}
+%}
+
diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i
index a6225410b..f992a3c08 100644
--- a/Examples/test-suite/li_boost_shared_ptr.i
+++ b/Examples/test-suite/li_boost_shared_ptr.i
@@ -43,6 +43,14 @@
%include
SWIG_SHARED_PTR(Klass, Space::Klass)
SWIG_SHARED_PTR_DERIVED(KlassDerived, Space::Klass, Space::KlassDerived)
+SWIG_SHARED_PTR_DERIVED(Klass2ndDerived, Space::Klass, Space::Klass2ndDerived)
+SWIG_SHARED_PTR_DERIVED(Klass3rdDerived, Space::Klass2ndDerived, Space::Klass3rdDerived)
+
+// TEMP for python
+%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >) {
+ *newmemory = SWIG_CAST_NEW_MEMORY;
+ return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > *)$from);
+}
#endif
@@ -101,7 +109,13 @@ private:
};
SwigExamples::CriticalSection Space::Klass::critical_section;
-struct IgnoredMultipleInheritBase { virtual ~IgnoredMultipleInheritBase() {} double d; double e;};
+struct IgnoredMultipleInheritBase {
+ IgnoredMultipleInheritBase() : d(0.0), e(0.0) {}
+ virtual ~IgnoredMultipleInheritBase() {}
+ double d;
+ double e;
+ virtual void AVirtualMethod() {}
+};
// For most compilers, this use of multiple inheritance results in different derived and base class
// pointer values ... for some more challenging tests :)
@@ -142,7 +156,21 @@ SwigBoost::shared_ptr*& derivedsmartptrpointerreftest(SwigBoost::s
return kd;
}
+// 3 classes in inheritance chain test
+struct Klass2ndDerived : Klass {
+ Klass2ndDerived() : Klass() {}
+ Klass2ndDerived(const std::string &val) : Klass(val) {}
+};
+struct Klass3rdDerived : IgnoredMultipleInheritBase, Klass2ndDerived {
+ Klass3rdDerived() : Klass2ndDerived() {}
+ Klass3rdDerived(const std::string &val) : Klass2ndDerived(val) {}
+ virtual ~Klass3rdDerived() {}
+ virtual std::string getValue() const { return Klass2ndDerived::getValue() + "-3rdDerived"; }
+};
+std::string test3rdupcast( SwigBoost::shared_ptr< Klass > k) {
+ return k->getValue();
+}
@@ -217,8 +245,14 @@ SwigBoost::shared_ptr* smartpointerpointerownertest() {
return new SwigBoost::shared_ptr(new Klass("smartpointerpointerownertest"));
}
-// Provide overloads for Klass and KlassDerived as some language modules, eg Python, create an extra reference in
+// Provide overloads for Klass and derived classes as some language modules, eg Python, create an extra reference in
// the marshalling if an upcast to a base class is required.
+long use_count(const SwigBoost::shared_ptr& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr& sptr) {
+ return sptr.use_count();
+}
long use_count(const SwigBoost::shared_ptr& sptr) {
return sptr.use_count();
}
diff --git a/Examples/test-suite/li_cstring.i b/Examples/test-suite/li_cstring.i
index fd92ac7d3..28e8049e8 100644
--- a/Examples/test-suite/li_cstring.i
+++ b/Examples/test-suite/li_cstring.i
@@ -4,7 +4,7 @@
#ifndef SWIG_CSTRING_UNIMPL
-%cstring_input_binary(char *in, int n);
+%cstring_input_binary(char *str_in, int n);
%cstring_bounded_output(char *out1, 512);
%cstring_chunk_output(char *out2, 64);
%cstring_bounded_mutable(char *out3, 512);
@@ -22,13 +22,13 @@
%inline %{
-int count(char *in, int n, char c) {
+int count(char *str_in, int n, char c) {
int r = 0;
while (n > 0) {
- if (*in == c) {
+ if (*str_in == c) {
r++;
}
- in++;
+ str_in++;
--n;
}
return r;
diff --git a/Examples/test-suite/li_cwstring.i b/Examples/test-suite/li_cwstring.i
index dc9a1c4b9..769dcce12 100644
--- a/Examples/test-suite/li_cwstring.i
+++ b/Examples/test-suite/li_cwstring.i
@@ -4,7 +4,7 @@
#ifndef SWIG_CWSTRING_UNIMPL
-%cwstring_input_binary(wchar_t *in, int n);
+%cwstring_input_binary(wchar_t *str_in, int n);
%cwstring_bounded_output(wchar_t *out1, 512);
%cwstring_chunk_output(wchar_t *out2, 64);
%cwstring_bounded_mutable(wchar_t *out3, 512);
@@ -22,13 +22,13 @@
%inline %{
-int count(wchar_t *in, int n, wchar_t c) {
+int count(wchar_t *str_in, int n, wchar_t c) {
int r = 0;
while (n > 0) {
- if (*in == c) {
+ if (*str_in == c) {
r++;
}
- in++;
+ str_in++;
--n;
}
return r;
diff --git a/Examples/test-suite/python/li_std_carray.i b/Examples/test-suite/li_std_carray.i
similarity index 100%
rename from Examples/test-suite/python/li_std_carray.i
rename to Examples/test-suite/li_std_carray.i
diff --git a/Examples/test-suite/ruby/li_std_functors.i b/Examples/test-suite/li_std_functors.i
similarity index 100%
rename from Examples/test-suite/ruby/li_std_functors.i
rename to Examples/test-suite/li_std_functors.i
diff --git a/Examples/test-suite/perl5/li_std_list.i b/Examples/test-suite/li_std_list.i
similarity index 100%
rename from Examples/test-suite/perl5/li_std_list.i
rename to Examples/test-suite/li_std_list.i
diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i
index edcb05641..27c1b1a70 100644
--- a/Examples/test-suite/li_std_map.i
+++ b/Examples/test-suite/li_std_map.i
@@ -10,7 +10,7 @@
*
* For example:
* swig::LANGUAGE_OBJ is GC_VALUE in Ruby
- * swig::LANGUAGE_OBJ is PyObject_ptr in python
+ * swig::LANGUAGE_OBJ is SwigPtr_PyObject in python
*
*
*/
@@ -47,8 +47,15 @@ namespace std
%template(pairiiAc) pair >;
+#ifdef SWIGRUBY
%template() pair< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >;
%template(LanguageMap) map< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >;
+#endif
+
+#ifdef SWIGPYTHON
+ %template() pair;
+ %template(pymap) map;
+#endif
}
diff --git a/Examples/test-suite/octave/li_std_pair.i b/Examples/test-suite/li_std_pair_extra.i
similarity index 99%
rename from Examples/test-suite/octave/li_std_pair.i
rename to Examples/test-suite/li_std_pair_extra.i
index 886bf1a4b..4e3b3a571 100644
--- a/Examples/test-suite/octave/li_std_pair.i
+++ b/Examples/test-suite/li_std_pair_extra.i
@@ -1,4 +1,4 @@
-%module li_std_pair
+%module li_std_pair_extra
//
// activate the automatic comparison methods generation (==,!=,...)
diff --git a/Examples/test-suite/ruby/li_std_pair_lang_object.i b/Examples/test-suite/li_std_pair_lang_object.i
similarity index 100%
rename from Examples/test-suite/ruby/li_std_pair_lang_object.i
rename to Examples/test-suite/li_std_pair_lang_object.i
diff --git a/Examples/test-suite/ruby/li_std_queue.i b/Examples/test-suite/li_std_queue.i
similarity index 100%
rename from Examples/test-suite/ruby/li_std_queue.i
rename to Examples/test-suite/li_std_queue.i
diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i
index c2cdc2ebe..8c335b24c 100644
--- a/Examples/test-suite/li_std_set.i
+++ b/Examples/test-suite/li_std_set.i
@@ -10,7 +10,7 @@
*
* For example:
* swig::LANGUAGE_OBJ is GC_VALUE in Ruby
- * swig::LANGUAGE_OBJ is PyObject_ptr in python
+ * swig::LANGUAGE_OBJ is SwigPtr_PyObject in python
*
*
*/
@@ -31,4 +31,10 @@
+#if defined(SWIGRUBY)
%template(LanguageSet) std::set;
+#endif
+
+#if defined(SWIGPYTHON)
+%template(pyset) std::set;
+#endif
diff --git a/Examples/test-suite/ruby/li_std_stack.i b/Examples/test-suite/li_std_stack.i
similarity index 100%
rename from Examples/test-suite/ruby/li_std_stack.i
rename to Examples/test-suite/li_std_stack.i
diff --git a/Examples/test-suite/python/li_std_string.i b/Examples/test-suite/li_std_string_extra.i
similarity index 93%
rename from Examples/test-suite/python/li_std_string.i
rename to Examples/test-suite/li_std_string_extra.i
index 822d713c4..aa758532a 100644
--- a/Examples/test-suite/python/li_std_string.i
+++ b/Examples/test-suite/li_std_string_extra.i
@@ -1,4 +1,4 @@
-%module li_std_string
+%module li_std_string_extra
%naturalvar A;
@@ -51,5 +51,5 @@ std::basic_string,std::allocator > test_value_
%}
-%include ../li_std_string.i
+%include "li_std_string.i"
diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i
index 587ea2217..c6e2ea9ad 100644
--- a/Examples/test-suite/li_std_vector.i
+++ b/Examples/test-suite/li_std_vector.i
@@ -85,8 +85,10 @@ SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, const int *)
%template(StructureConstPtrVector) std::vector;
#endif
+#if !defined(SWIGR)
%template(IntPtrVector) std::vector;
%template(IntConstPtrVector) std::vector;
+#endif
%template(StructVector) std::vector;
%template(StructPtrVector) std::vector;
%template(StructConstPtrVector) std::vector;
diff --git a/Examples/test-suite/python/li_std_vector.i b/Examples/test-suite/li_std_vector_extra.i
similarity index 85%
rename from Examples/test-suite/python/li_std_vector.i
rename to Examples/test-suite/li_std_vector_extra.i
index 06dafce59..9c2497f7c 100644
--- a/Examples/test-suite/python/li_std_vector.i
+++ b/Examples/test-suite/li_std_vector_extra.i
@@ -1,4 +1,4 @@
-%module li_std_vector
+%module li_std_vector_extra
%warnfilter(509) overloaded1;
%warnfilter(509) overloaded2;
@@ -123,11 +123,17 @@ std::vector vecStr(std::vector v) {
%pointer_class(int,PtrInt)
%array_functions(int,ArrInt)
+%inline %{
+ int *makeIntPtr(int v) { return new int(v); }
+ double *makeDoublePtr(double v) { return new double(v); }
+ int extractInt(int *p) { return *p; }
+%}
-%template(pyvector) std::vector;
+%template(pyvector) std::vector;
namespace std {
- %template(ConstIntVector) vector;
+ %template(ConstShortVector) vector;
+// %template(ConstIntVector) vector; // interferes with vector... see new testcase li_std_vector_ptr
}
%inline %{
diff --git a/Examples/test-suite/li_std_vector_ptr.i b/Examples/test-suite/li_std_vector_ptr.i
new file mode 100644
index 000000000..688cbdd54
--- /dev/null
+++ b/Examples/test-suite/li_std_vector_ptr.i
@@ -0,0 +1,29 @@
+%module li_std_vector_ptr
+
+%include "std_vector.i"
+
+%template(IntPtrVector) std::vector;
+
+%inline %{
+#include
+using namespace std;
+int* makeIntPtr(int v) {
+ return new int(v);
+}
+double* makeDoublePtr(double v) {
+ return new double(v);
+}
+
+#if 1
+int** makeIntPtrPtr(int* v) {
+ return new int*(v);
+}
+#endif
+
+void displayVector(std::vector vpi) {
+ cout << "displayVector..." << endl;
+ for (int i=0; i;
-
%inline {
/* silently rename the parameter names in csharp/java */
#ifdef SWIGR
double foo(double inparam, double out) { return 1.0; }
#else
- double foo(double in, double out) { return 1.0; }
+ double foo(double abstract, double out) { return 1.0; }
#endif
double bar(double native, bool boolean) { return 1.0; }
}
diff --git a/Examples/test-suite/namespace_typemap.i b/Examples/test-suite/namespace_typemap.i
index e4e0af905..984b93a6f 100644
--- a/Examples/test-suite/namespace_typemap.i
+++ b/Examples/test-suite/namespace_typemap.i
@@ -75,7 +75,7 @@ namespace test {
class string_class;
#ifdef SWIGPYTHON
%typemap(in) string_class * {
- $1 = new string_class(PyString_AsString($input));
+ $1 = new string_class(SWIG_Python_str_AsChar($input));
}
%typemap(freearg) string_class * {
delete $1;
diff --git a/Examples/test-suite/nested_comment.i b/Examples/test-suite/nested_comment.i
index 16f1b7af2..ea365a6fe 100644
--- a/Examples/test-suite/nested_comment.i
+++ b/Examples/test-suite/nested_comment.i
@@ -18,24 +18,17 @@ in rlgc models */
char *name;
} n ;
} s2;
-
%}
-// bug #491476
+// comment in nested struct
%inline %{
-struct {
-struct {
-int a;
-} a, b;
-} a;
-
-%}
-
-// bug #909387
-%inline %{
-struct foo {
- struct happy; // no warning
- struct sad { int x; }; // warning
- happy *good(); // produces good code
- sad *bad(); // produces bad code
+struct a
+{
+ struct {
+ /*struct*/
+ struct {
+ int b;
+ } c;
+ } d;
};
+%}
diff --git a/Examples/test-suite/nested_structs.i b/Examples/test-suite/nested_structs.i
new file mode 100644
index 000000000..4b13ff69d
--- /dev/null
+++ b/Examples/test-suite/nested_structs.i
@@ -0,0 +1,22 @@
+%module nested_structs
+
+// bug #491476
+%inline %{
+struct {
+struct {
+int a;
+} a, b;
+} a;
+
+%}
+
+// bug #909387
+%inline %{
+struct foo {
+ struct happy; // no warning
+ struct sad { int x; }; // warning
+ happy *good(); // produces good code
+ sad *bad(); // produces bad code
+};
+%}
+
diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in
index 6f0b65489..0e6235f94 100644
--- a/Examples/test-suite/ocaml/Makefile.in
+++ b/Examples/test-suite/ocaml/Makefile.in
@@ -16,7 +16,7 @@ run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \
-f $(top_srcdir)/Examples/test-suite/$*.list ] ; then ( \
$(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
- $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& ./runme) ; \
+ $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./runme) ; \
elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
$(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \
diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in
index 534da55c4..b12cf500a 100644
--- a/Examples/test-suite/octave/Makefile.in
+++ b/Examples/test-suite/octave/Makefile.in
@@ -10,7 +10,9 @@ top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CPP_TEST_CASES += \
- cell_deref
+ li_std_pair_extra \
+ li_std_string_extra \
+ octave_cell_deref
CPP_TEST_BROKEN += \
implicittest \
diff --git a/Examples/test-suite/octave/li_attribute_runme.m b/Examples/test-suite/octave/li_attribute_runme.m
index c66e27c5b..548e733ed 100644
--- a/Examples/test-suite/octave/li_attribute_runme.m
+++ b/Examples/test-suite/octave/li_attribute_runme.m
@@ -10,7 +10,6 @@ if (aa.a != 3)
error("aa.a = %i",aa.a)
endif
-
if (aa.b != 2)
error(aa.b)
endif
@@ -19,8 +18,6 @@ if (aa.b != 5)
error
endif
-
-
if (aa.d != aa.b)
error
endif
@@ -39,14 +36,13 @@ if (pi.value != 3)
error
endif
-
b = li_attribute.B(aa);
if (b.a.c != 3)
error
endif
-
+# class/struct attribute with get/set methods using return/pass by reference
myFoo = li_attribute.MyFoo();
myFoo.x = 8;
myClass = li_attribute.MyClass();
@@ -55,3 +51,35 @@ if (myClass.Foo.x != 8)
error
endif
+# class/struct attribute with get/set methods using return/pass by value
+myClassVal = li_attribute.MyClassVal();
+if (myClassVal.ReadWriteFoo.x != -1)
+ error
+endif
+if (myClassVal.ReadOnlyFoo.x != -1)
+ error
+endif
+myClassVal.ReadWriteFoo = myFoo;
+if (myClassVal.ReadWriteFoo.x != 8)
+ error
+endif
+if (myClassVal.ReadOnlyFoo.x != 8)
+ error
+endif
+
+# string attribute with get/set methods using return/pass by value
+myStringyClass = li_attribute.MyStringyClass("initial string");
+if (myStringyClass.ReadWriteString != "initial string")
+ error
+endif
+if (myStringyClass.ReadOnlyString != "initial string")
+ error
+endif
+myStringyClass.ReadWriteString = "changed string";
+if (myStringyClass.ReadWriteString != "changed string")
+ error
+endif
+if (myStringyClass.ReadOnlyString != "changed string")
+ error
+endif
+
diff --git a/Examples/test-suite/octave/li_std_pair_extra_runme.m b/Examples/test-suite/octave/li_std_pair_extra_runme.m
new file mode 100644
index 000000000..0f9e9a23d
--- /dev/null
+++ b/Examples/test-suite/octave/li_std_pair_extra_runme.m
@@ -0,0 +1,69 @@
+li_std_pair_extra
+
+p = {1,2};
+p1 = li_std_pair_extra.p_inout(p);
+assert(all(cell2mat(p1)==[2,1]));
+p2 = li_std_pair_extra.p_inoutd(p1);
+assert(all(cell2mat(p2)==[1,2]));
+
+d1 = li_std_pair_extra.d_inout(2);
+assert(d1==4);
+
+[i,d2] = li_std_pair_extra.d_inout2(2);
+assert(all([i,d2]==[1,4]));
+
+[i,p] = li_std_pair_extra.p_inout2(p);
+assert(i==1&&all([cell2mat(p)]==[2,1]));
+[p3,p4] = li_std_pair_extra.p_inout3(p1,p1);
+assert(all(cell2mat(p3)==[2,1]));
+assert(all(cell2mat(p4)==[2,1]));
+
+psi = li_std_pair_extra.SIPair("hello",1);
+assert(psi=={"hello",1});
+pci = li_std_pair_extra.CIPair(complex(1,2),1);
+assert(pci.first==complex(1,2)&&pci.second==1);
+
+
+psi = li_std_pair_extra.SIPair("hi",1);
+assert(psi.first=="hi"&&psi.second==1);
+
+psii = li_std_pair_extra.SIIPair(psi,1);
+assert(psii.first.first=="hi");
+assert(psii.first.second==1);
+assert(psii.second==1);
+
+a = li_std_pair_extra.A();
+b = li_std_pair_extra.B();
+
+pab = li_std_pair_extra.ABPair(a,b);
+
+pab.first = a;
+pab.first.val = 2;
+
+assert(pab.first.val == 2);
+
+pci = li_std_pair_extra.CIntPair(1,0);
+assert(pci.first==1&&pci.second==0);
+
+a = li_std_pair_extra.A(5);
+p1 = li_std_pair_extra.pairP1(1,a);
+p2 = li_std_pair_extra.pairP2(a,1);
+p3 = li_std_pair_extra.pairP3(a,a);
+
+assert(a.val == li_std_pair_extra.p_identa(p1){2}.val);
+
+p = li_std_pair_extra.IntPair(1,10);
+assert(p.first==1&&p.second==10);
+p.first = 1;
+assert(p.first==1);
+
+p = li_std_pair_extra.paircA1(1,a);
+assert(p.first==1);
+assert(swig_this(p.second)==swig_this(a));
+
+p = li_std_pair_extra.paircA2(1,a);
+assert(p.first==1);
+assert(swig_this(p.second)==swig_this(a));
+#pp = li_std_pair_extra.pairiiA(1,p); # conversion pb re const of pairA1/A2
+pp = li_std_pair_extra.pairiiA(1,{1,A()});
+
diff --git a/Examples/test-suite/octave/li_std_pair_runme.m b/Examples/test-suite/octave/li_std_pair_runme.m
deleted file mode 100644
index 83e9fe5b5..000000000
--- a/Examples/test-suite/octave/li_std_pair_runme.m
+++ /dev/null
@@ -1,69 +0,0 @@
-li_std_pair
-
-p = {1,2};
-p1 = li_std_pair.p_inout(p);
-assert(all(cell2mat(p1)==[2,1]));
-p2 = li_std_pair.p_inoutd(p1);
-assert(all(cell2mat(p2)==[1,2]));
-
-d1 = li_std_pair.d_inout(2);
-assert(d1==4);
-
-[i,d2] = li_std_pair.d_inout2(2);
-assert(all([i,d2]==[1,4]));
-
-[i,p] = li_std_pair.p_inout2(p);
-assert(i==1&&all([cell2mat(p)]==[2,1]));
-[p3,p4] = li_std_pair.p_inout3(p1,p1);
-assert(all(cell2mat(p3)==[2,1]));
-assert(all(cell2mat(p4)==[2,1]));
-
-psi = li_std_pair.SIPair("hello",1);
-assert(psi=={"hello",1});
-pci = li_std_pair.CIPair(complex(1,2),1);
-assert(pci.first==complex(1,2)&&pci.second==1);
-
-
-psi = li_std_pair.SIPair("hi",1);
-assert(psi.first=="hi"&&psi.second==1);
-
-psii = li_std_pair.SIIPair(psi,1);
-assert(psii.first.first=="hi");
-assert(psii.first.second==1);
-assert(psii.second==1);
-
-a = li_std_pair.A();
-b = li_std_pair.B();
-
-pab = li_std_pair.ABPair(a,b);
-
-pab.first = a;
-pab.first.val = 2;
-
-assert(pab.first.val == 2);
-
-pci = li_std_pair.CIntPair(1,0);
-assert(pci.first==1&&pci.second==0);
-
-a = li_std_pair.A(5);
-p1 = li_std_pair.pairP1(1,a);
-p2 = li_std_pair.pairP2(a,1);
-p3 = li_std_pair.pairP3(a,a);
-
-assert(a.val == li_std_pair.p_identa(p1){2}.val);
-
-p = li_std_pair.IntPair(1,10);
-assert(p.first==1&&p.second==10);
-p.first = 1;
-assert(p.first==1);
-
-p = li_std_pair.paircA1(1,a);
-assert(p.first==1);
-assert(swig_this(p.second)==swig_this(a));
-
-p = li_std_pair.paircA2(1,a);
-assert(p.first==1);
-assert(swig_this(p.second)==swig_this(a));
-#pp = li_std_pair.pairiiA(1,p); # conversion pb re const of pairA1/A2
-pp = li_std_pair.pairiiA(1,{1,A()});
-
diff --git a/Examples/test-suite/octave/li_std_string.i b/Examples/test-suite/octave/li_std_string.i
deleted file mode 100644
index 822d713c4..000000000
--- a/Examples/test-suite/octave/li_std_string.i
+++ /dev/null
@@ -1,55 +0,0 @@
-%module li_std_string
-
-%naturalvar A;
-
-
-%include
-%include
-
-
-%inline %{
-
-struct A : std::string
-{
- A(const std::string& s) : std::string(s)
- {
- }
-};
-
-struct B
-{
- B(const std::string& s) : cname(0), name(s), a(s)
- {
- }
-
- char *cname;
- std::string name;
- A a;
-
-};
-
-
-const char* test_ccvalue(const char* x) {
- return x;
-}
-
-char* test_cvalue(char* x) {
- return x;
-}
-
-std::basic_string test_value_basic1(std::basic_string x) {
- return x;
-}
-
-std::basic_string > test_value_basic2(std::basic_string > x) {
- return x;
-}
-
-std::basic_string,std::allocator > test_value_basic3(std::basic_string,std::allocator > x) {
- return x;
-}
-
-%}
-
-%include ../li_std_string.i
-
diff --git a/Examples/test-suite/octave/li_std_string_extra_runme.m b/Examples/test-suite/octave/li_std_string_extra_runme.m
new file mode 100644
index 000000000..8d506af8a
--- /dev/null
+++ b/Examples/test-suite/octave/li_std_string_extra_runme.m
@@ -0,0 +1,162 @@
+li_std_string_extra
+
+x="hello";
+
+
+
+if (li_std_string_extra.test_ccvalue(x) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_cvalue(x) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_value(x) != x)
+ error("bad string mapping: %s, %s", x, li_std_string_extra.test_value(x))
+endif
+
+if (li_std_string_extra.test_const_reference(x) != x)
+ error("bad string mapping")
+endif
+
+
+s = li_std_string_extra.string("he");
+#s += "ll"
+#s.append("ll")
+s = s + "llo";
+
+if (s != x)
+ error("bad string mapping: %s, %s", s, x);
+endif
+
+#if (s(1:4) != x(1:4))
+# error("bad string mapping")
+#endif
+
+if (li_std_string_extra.test_value(s) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_const_reference(s) != x)
+ error("bad string mapping")
+endif
+
+a = li_std_string_extra.A(s);
+
+if (li_std_string_extra.test_value(a) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_const_reference(a) != x)
+ error("bad string mapping")
+endif
+
+b = li_std_string_extra.string(" world");
+
+s = a + b;
+if (a + b != "hello world")
+ error("bad string mapping: %s", a + b)
+endif
+
+if (a + " world" != "hello world")
+ error("bad string mapping")
+endif
+
+#if ("hello" + b != "hello world")
+# error("bad string mapping")
+#endif
+
+c = (li_std_string_extra.string("hello") + b);
+if (c.find_last_of("l") != 9)
+ error("bad string mapping")
+endif
+
+s = "hello world";
+
+b = li_std_string_extra.B("hi");
+
+b.name = li_std_string_extra.string("hello");
+if (b.name != "hello")
+ error("bad string mapping")
+endif
+
+
+b.a = li_std_string_extra.A("hello");
+if (b.a != "hello")
+ error("bad string mapping")
+endif
+
+
+if (li_std_string_extra.test_value_basic1(x) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_value_basic2(x) != x)
+ error("bad string mapping")
+endif
+
+
+if (li_std_string_extra.test_value_basic3(x) != x)
+ error("bad string mapping")
+endif
+
+# Global variables
+s = "initial string";
+if (li_std_string_extra.cvar.GlobalString2 != "global string 2")
+ error("GlobalString2 test 1")
+endif
+li_std_string_extra.cvar.GlobalString2 = s;
+if (li_std_string_extra.cvar.GlobalString2 != s)
+ error("GlobalString2 test 2")
+endif
+if (li_std_string_extra.cvar.ConstGlobalString != "const global string")
+ error("ConstGlobalString test")
+endif
+
+# Member variables
+myStructure = li_std_string_extra.Structure();
+if (myStructure.MemberString2 != "member string 2")
+ error("MemberString2 test 1")
+endif
+myStructure.MemberString2 = s;
+if (myStructure.MemberString2 != s)
+ error("MemberString2 test 2")
+endif
+if (myStructure.ConstMemberString != "const member string")
+ error("ConstMemberString test")
+endif
+
+if (li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2")
+ error("StaticMemberString2 test 1")
+endif
+li_std_string_extra.cvar.Structure_StaticMemberString2 = s;
+if (li_std_string_extra.cvar.Structure_StaticMemberString2 != s)
+ error("StaticMemberString2 test 2")
+endif
+if (li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string")
+ error("ConstStaticMemberString test")
+endif
+
+
+if (li_std_string_extra.test_reference_input("hello") != "hello")
+ error
+endif
+s = li_std_string_extra.test_reference_inout("hello");
+if (s != "hellohello")
+ error
+endif
+
+
+if (li_std_string_extra.stdstring_empty() != "")
+ error
+endif
+
+
+if (li_std_string_extra.c_empty() != "")
+ error
+endif
+
+#if (li_std_string_extra.c_null() != None)
+# error
+#endif
diff --git a/Examples/test-suite/octave/li_std_string_runme.m b/Examples/test-suite/octave/li_std_string_runme.m
deleted file mode 100644
index fa0e260e0..000000000
--- a/Examples/test-suite/octave/li_std_string_runme.m
+++ /dev/null
@@ -1,162 +0,0 @@
-li_std_string
-
-x="hello";
-
-
-
-if (li_std_string.test_ccvalue(x) != x)
- error("bad string mapping")
-endif
-
-if (li_std_string.test_cvalue(x) != x)
- error("bad string mapping")
-endif
-
-if (li_std_string.test_value(x) != x)
- error("bad string mapping: %s, %s", x, li_std_string.test_value(x))
-endif
-
-if (li_std_string.test_const_reference(x) != x)
- error("bad string mapping")
-endif
-
-
-s = li_std_string.string("he");
-#s += "ll"
-#s.append('o')
-s = s + "llo";
-
-if (s != x)
- error("bad string mapping: %s, %s", s, x);
-endif
-
-if (s[1:4] != x[1:4])
- error("bad string mapping")
-endif
-
-if (li_std_string.test_value(s) != x)
- error("bad string mapping")
-endif
-
-if (li_std_string.test_const_reference(s) != x)
- error("bad string mapping")
-endif
-
-a = li_std_string.A(s);
-
-if (li_std_string.test_value(a) != x)
- error("bad string mapping")
-endif
-
-if (li_std_string.test_const_reference(a) != x)
- error("bad string mapping")
-endif
-
-b = li_std_string.string(" world");
-
-s = a + b;
-if (a + b != "hello world")
- error("bad string mapping: %s", a + b)
-endif
-
-if (a + " world" != "hello world")
- error("bad string mapping")
-endif
-
-if ("hello" + b != "hello world")
- error("bad string mapping")
-endif
-
-c = ("hello" + b)
-if (c.find_last_of("l") != 9)
- error("bad string mapping")
-endif
-
-s = "hello world";
-
-b = li_std_string.B("hi");
-
-b.name = li_std_string.string("hello");
-if (b.name != "hello")
- error("bad string mapping")
-endif
-
-
-b.a = li_std_string.A("hello");
-if (b.a != "hello")
- error("bad string mapping")
-endif
-
-
-if (li_std_string.test_value_basic1(x) != x)
- error("bad string mapping")
-endif
-
-if (li_std_string.test_value_basic2(x) != x)
- error("bad string mapping")
-endif
-
-
-if (li_std_string.test_value_basic3(x) != x)
- error("bad string mapping")
-endif
-
-# Global variables
-s = "initial string";
-if (li_std_string.cvar.GlobalString2 != "global string 2")
- error("GlobalString2 test 1")
-endif
-li_std_string.cvar.GlobalString2 = s;
-if (li_std_string.cvar.GlobalString2 != s)
- error("GlobalString2 test 2")
-endif
-if (li_std_string.cvar.ConstGlobalString != "const global string")
- error("ConstGlobalString test")
-endif
-
-# Member variables
-myStructure = li_std_string.Structure();
-if (myStructure.MemberString2 != "member string 2")
- error("MemberString2 test 1")
-endif
-myStructure.MemberString2 = s;
-if (myStructure.MemberString2 != s)
- error("MemberString2 test 2")
-endif
-if (myStructure.ConstMemberString != "const member string")
- error("ConstMemberString test")
-endif
-
-if (li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2")
- error("StaticMemberString2 test 1")
-endif
-li_std_string.cvar.Structure_StaticMemberString2 = s;
-if (li_std_string.cvar.Structure_StaticMemberString2 != s)
- error("StaticMemberString2 test 2")
-endif
-if (li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string")
- error("ConstStaticMemberString test")
-endif
-
-
-if (li_std_string.test_reference_input("hello") != "hello")
- error
-endif
-s = li_std_string.test_reference_inout("hello");
-if (s != "hellohello")
- error
-endif
-
-
-if (li_std_string.stdstring_empty() != "")
- error
-endif
-
-
-if (li_std_string.c_empty() != "")
- error
-endif
-
-if (li_std_string.c_null() != None)
- error
-endif
diff --git a/Examples/test-suite/octave/cell_deref_runme.m b/Examples/test-suite/octave/octave_cell_deref_runme.m
similarity index 85%
rename from Examples/test-suite/octave/cell_deref_runme.m
rename to Examples/test-suite/octave/octave_cell_deref_runme.m
index 1c370fe85..5a98c0a3b 100644
--- a/Examples/test-suite/octave/cell_deref_runme.m
+++ b/Examples/test-suite/octave/octave_cell_deref_runme.m
@@ -1,4 +1,4 @@
-cell_deref;
+octave_cell_deref;
assert(func("hello"));
assert(func({"hello"}));
diff --git a/Examples/test-suite/octave/cell_deref.i b/Examples/test-suite/octave_cell_deref.i
similarity index 86%
rename from Examples/test-suite/octave/cell_deref.i
rename to Examples/test-suite/octave_cell_deref.i
index fddcd80ec..2e92ec4de 100644
--- a/Examples/test-suite/octave/cell_deref.i
+++ b/Examples/test-suite/octave_cell_deref.i
@@ -1,4 +1,4 @@
-%module cell_deref
+%module octave_cell_deref
%inline {
bool func(const char* s) {
diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i
index b2748f9b4..b62bf5179 100644
--- a/Examples/test-suite/operator_overload.i
+++ b/Examples/test-suite/operator_overload.i
@@ -71,6 +71,12 @@ see bottom for a set of possible tests
%rename(OrOperator) operator ||;
#endif
+#ifdef SWIG_ALLEGRO_CL
+%{
+#include
+%}
+#endif
+
%rename(IntCast) operator int();
%rename(DoubleCast) operator double();
diff --git a/Examples/test-suite/operbool.i b/Examples/test-suite/operbool.i
new file mode 100644
index 000000000..793c0174e
--- /dev/null
+++ b/Examples/test-suite/operbool.i
@@ -0,0 +1,12 @@
+%module operbool
+
+%rename(operbool) operator bool();
+
+%inline %{
+ class Test {
+ public:
+ operator bool() {
+ return false;
+ }
+ };
+%}
diff --git a/Examples/test-suite/packageoption.h b/Examples/test-suite/packageoption.h
index a7ef499aa..82f29d1c7 100644
--- a/Examples/test-suite/packageoption.h
+++ b/Examples/test-suite/packageoption.h
@@ -1,5 +1,6 @@
-class A
-{
- public:
- int testInt() { return 2;}
+struct Base {
+ virtual int vmethod() { return 1; }
+ int basemethod() { return 1; }
+ virtual ~Base() {}
};
+
diff --git a/Examples/test-suite/packageoption.list b/Examples/test-suite/packageoption.list
index 4bdabeccf..da125c2a3 100644
--- a/Examples/test-suite/packageoption.list
+++ b/Examples/test-suite/packageoption.list
@@ -1,2 +1,3 @@
packageoption_a
packageoption_b
+packageoption_c
diff --git a/Examples/test-suite/packageoption_a.i b/Examples/test-suite/packageoption_a.i
index e95091b0d..b28278282 100644
--- a/Examples/test-suite/packageoption_a.i
+++ b/Examples/test-suite/packageoption_a.i
@@ -1,4 +1,4 @@
-%module(package="C") "packageoption_a";
+%module(package="CommonPackage") "packageoption_a";
%inline %{
class A
@@ -6,5 +6,11 @@ class A
public:
int testInt() { return 2;}
};
-
%}
+
+%{
+#include "packageoption.h"
+%}
+
+%include "packageoption.h"
+
diff --git a/Examples/test-suite/packageoption_b.i b/Examples/test-suite/packageoption_b.i
index 466853cc0..40a44be14 100644
--- a/Examples/test-suite/packageoption_b.i
+++ b/Examples/test-suite/packageoption_b.i
@@ -1,4 +1,4 @@
-%module(package="C") "packageoption_b";
+%module(package="CommonPackage") "packageoption_b";
%inline %{
class B
diff --git a/Examples/test-suite/packageoption_c.i b/Examples/test-suite/packageoption_c.i
new file mode 100644
index 000000000..f43e47002
--- /dev/null
+++ b/Examples/test-suite/packageoption_c.i
@@ -0,0 +1,13 @@
+%module(package="PackageC") "packageoption_c";
+
+%import "packageoption_a.i"
+
+%inline %{
+#include "packageoption.h"
+
+struct Derived : Base {
+ virtual int vmethod() { return 2; }
+ virtual ~Derived() {}
+};
+
+%}
diff --git a/Examples/test-suite/perl5/char_strings_runme.pl b/Examples/test-suite/perl5/char_strings_runme.pl
index 51c227bb9..c4573737e 100644
--- a/Examples/test-suite/perl5/char_strings_runme.pl
+++ b/Examples/test-suite/perl5/char_strings_runme.pl
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More tests => 5;
BEGIN { use_ok('char_strings') }
require_ok('char_strings');
@@ -10,3 +10,6 @@ is(char_strings::CharPingPong($val1), "100", 'cstr1');
my $val2 = "greetings";
is(char_strings::CharPingPong($val2), "greetings", 'cstr2');
+# SF#2564192
+"this is a test" =~ /(\w+)$/;
+is(char_strings::CharPingPong($1), "test", "handles Magical");
diff --git a/Examples/test-suite/perl5/li_typemaps_runme.pl b/Examples/test-suite/perl5/li_typemaps_runme.pl
index c149284ae..c182cdbb1 100644
--- a/Examples/test-suite/perl5/li_typemaps_runme.pl
+++ b/Examples/test-suite/perl5/li_typemaps_runme.pl
@@ -37,24 +37,29 @@ batch('ulong', 0, 1, 12, 0xffffffff);
batch('uchar', 0, 1, 12, 0xff);
batch('schar', -0x80, 0, 1, 12, 0x7f);
-# IEEE 754 machine, please!
-batch('float',
- -(2 - 2 ** -23) * 2 ** 127,
- -1, -2 ** -149, 0, 2 ** -149, 1,
- (2 - 2 ** -23) * 2 ** 127,
- 'nan');
-{ local $TODO = "shouldn't some Inf <=> float work?";
- # I'm going to guess that it could work reasonably as
- # NV Inf => float Inf
- # float Inf => NV NaN
- # but this needs some thought.
- batch('float', 'inf');
+{
+ use Math::BigInt qw();
+ # the pack dance is to get plain old NVs out of the
+ # Math::BigInt objects.
+ my $inf = unpack 'd', pack 'd', Math::BigInt->binf();
+ my $nan = unpack 'd', pack 'd', Math::BigInt->bnan();
+ batch('float',
+ -(2 - 2 ** -23) * 2 ** 127,
+ -1, -2 ** -149, 0, 2 ** -149, 1,
+ (2 - 2 ** -23) * 2 ** 127,
+ $nan);
+ { local $TODO = "float typemaps don't pass infinity";
+ # it seems as though SWIG is unwilling to pass infinity around
+ # because that value always fails bounds checking. I think that
+ # is a bug.
+ batch('float', $inf);
+ }
+ batch('double',
+ -(2 - 2 ** -53) ** 1023,
+ -1, -2 ** -1074, 0, 2 ** 1074,
+ (2 - 2 ** -53) ** 1023,
+ $nan, $inf);
}
-batch('double',
- -(2 - 2 ** -53) ** 1023,
- -1, -2 ** -1074, 0, 2 ** 1074,
- (2 - 2 ** -53) ** 1023,
- 'nan', 'inf');
batch('longlong', -1, 0, 1, 12);
batch('ulonglong', 0, 1, 12);
SKIP: {
diff --git a/Examples/test-suite/perl5/packageoption_runme.pl b/Examples/test-suite/perl5/packageoption_runme.pl
index debea78e1..d94a7a1fd 100644
--- a/Examples/test-suite/perl5/packageoption_runme.pl
+++ b/Examples/test-suite/perl5/packageoption_runme.pl
@@ -14,11 +14,11 @@ sub ok_not ($;$) {
ok($test, $name);
}
-my $a = C::A->new();
+my $a = CommonPackage::A->new();
-isa_ok($a, 'C::A');
+isa_ok($a, 'CommonPackage::A');
-my $b = C::B->new();
+my $b = CommonPackage::B->new();
-isa_ok($b, 'C::B');
+isa_ok($b, 'CommonPackage::B');
diff --git a/Examples/test-suite/php4/Makefile.in b/Examples/test-suite/php/Makefile.in
similarity index 69%
rename from Examples/test-suite/php4/Makefile.in
rename to Examples/test-suite/php/Makefile.in
index 2e14ef9a2..b8aeaaa11 100644
--- a/Examples/test-suite/php4/Makefile.in
+++ b/Examples/test-suite/php/Makefile.in
@@ -1,13 +1,16 @@
#######################################################################
-# Makefile for php4 test-suite
+# Makefile for php test-suite
#######################################################################
-LANGUAGE = php4
-SCRIPTSUFFIX = _runme.php4
+LANGUAGE = php
+SCRIPTSUFFIX = _runme.php
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
+#CPP_TEST_CASES += \
+# php_namewarn_rename \
+
include $(srcdir)/../common.mk
# Overridden variables here
@@ -22,19 +25,19 @@ makectests:
@bash -ec 'for test in $(C_TEST_CASES) ; do $($(MAKE)) clean && $(MAKE) $${test}.cpptest; done'
runcpptests:
- @bash -ec 'for test in $(CPP_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi ; done'
+ @bash -ec 'for test in $(CPP_TEST_CASES) ; do if [ -f $${test}_runme.php ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi ; done'
runctests:
- @bash -ec 'for test in $(C_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi; done'
+ @bash -ec 'for test in $(C_TEST_CASES) ; do if [ -f $${test}_runme.php ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi; done'
runtests: runcpptests runctests
-# write out tests without a _runme.php4
+# write out tests without a _runme.php
missingcpptests:
- @bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done'
+ @bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done'
missingctests:
- @bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done'
+ @bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done'
missingtests: missingcpptests missingctests
@@ -55,10 +58,10 @@ missingtests: missingcpptests missingctests
+$(run_testcase)
# Runs the testcase. A testcase is only run if
-# a file is found which has _runme.php4 appended after the testcase name.
+# a file is found which has _runme.php appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php4_run;) \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php_run;) \
fi;
# Clean: remove the generated .php file
@@ -66,4 +69,4 @@ run_testcase = \
@rm -f $*.php;
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php4_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php_clean
diff --git a/Examples/test-suite/php4/abstract_inherit_ok_runme.php4 b/Examples/test-suite/php/abstract_inherit_ok_runme.php
similarity index 88%
rename from Examples/test-suite/php4/abstract_inherit_ok_runme.php4
rename to Examples/test-suite/php/abstract_inherit_ok_runme.php
index 1182e4cec..c2d86499b 100644
--- a/Examples/test-suite/php4/abstract_inherit_ok_runme.php4
+++ b/Examples/test-suite/php/abstract_inherit_ok_runme.php
@@ -1,6 +1,6 @@
diff --git a/Examples/test-suite/php4/arrays_global_twodim_runme.php4 b/Examples/test-suite/php/arrays_global_twodim_runme.php
similarity index 97%
rename from Examples/test-suite/php4/arrays_global_twodim_runme.php4
rename to Examples/test-suite/php/arrays_global_twodim_runme.php
index 352ad2568..d9b62de0d 100644
--- a/Examples/test-suite/php4/arrays_global_twodim_runme.php4
+++ b/Examples/test-suite/php/arrays_global_twodim_runme.php
@@ -1,7 +1,7 @@
/dev/null 2>&1
+
+
# Runs the testcase. A testcase is only run if
-# a file is found which has _runme.py appended after the testcase name.
+# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
+
+run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
+
+py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
+py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
+
+ifeq (,$(PY3))
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
- env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
+ $(run_python);)\
fi;
+else
+run_testcase = \
+ if [ -f $(py2_runme) ]; then ( \
+ $(MAKE) -f $(srcdir)/Makefile $(py3_runme) && \
+ $(run_python);) \
+ elif [ -f $(py3_runme) ]; then ( \
+ $(run_python);) \
+ fi;
+endif
# Clean: remove the generated .py file
%.clean:
@rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
@rm -f $*.py;
+ @#We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
+ @if [ -f $(py2_runme) ]; then (rm -f $(py3_runme) $(py3_runme).bak;) fi;
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean
@@ -101,14 +153,15 @@ cvsignore:
@echo clientdata_prop_b.py
@echo imports_a.py
@echo imports_b.py
- @echo mod_a.py mod_b.py
+ @echo mod_a.py mod_b.py
@echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
@echo template_typedef_import.py
+hugemod_runme = hugemod$(SCRIPTPREFIX)
hugemod:
- perl hugemod.pl
+ perl hugemod.pl $(hugemod_runme)
$(MAKE) hugemod_a.cpptest
$(MAKE) hugemod_b.cpptest
- time $(PYTHON) hugemod_runme.py
- time $(PYTHON) hugemod_runme.py
+ sh -c "time $(PYTHON) $(hugemod_runme)"
+ sh -c "time $(PYTHON) $(hugemod_runme)"
diff --git a/Examples/test-suite/python/README b/Examples/test-suite/python/README
index b86ec5289..71db759b5 100644
--- a/Examples/test-suite/python/README
+++ b/Examples/test-suite/python/README
@@ -1,4 +1,8 @@
See ../README for common README file.
-Any testcases which have _runme.py appended after the testcase name will be detected and run.
+Any testcases which have _runme.py (or _runme3.py for Python 3) appended after the testcase name will be detected and run.
+If you intend to write a testcase for both Python 2.x and 3.x, do *not* directly put the _runme3.py in this directory. Just write Python 2.x's _runme.py testcase and it will be automatically converted to Python 3 code during test.
+
+You can run make with PY3=y to run test case with Python 3.x, eg.
+ $ make voidtest.cpptest PY3=y
diff --git a/Examples/test-suite/python/contract_runme.py b/Examples/test-suite/python/contract_runme.py
index 9ded5bb5b..905bf1196 100644
--- a/Examples/test-suite/python/contract_runme.py
+++ b/Examples/test-suite/python/contract_runme.py
@@ -133,3 +133,11 @@ try:
except:
pass
+#Namespace
+my = contract.myClass(1)
+try:
+ my = contract.myClass(0)
+ print "Failed! constructor preassertion"
+except:
+ pass
+
diff --git a/Examples/test-suite/python/cpp_namespace_runme.py b/Examples/test-suite/python/cpp_namespace_runme.py
index 3108b4f47..a454774f5 100644
--- a/Examples/test-suite/python/cpp_namespace_runme.py
+++ b/Examples/test-suite/python/cpp_namespace_runme.py
@@ -3,20 +3,20 @@ import cpp_namespace
n = cpp_namespace.fact(4)
if n != 24:
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
if cpp_namespace.cvar.Foo != 42:
- raise "Bad variable value!"
+ raise RuntimeError("Bad variable value!")
t = cpp_namespace.Test()
if t.method() != "Test::method":
- raise "Bad method return value!"
+ raise RuntimeError("Bad method return value!")
if cpp_namespace.do_method(t) != "Test::method":
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
if cpp_namespace.do_method2(t) != "Test::method":
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
cpp_namespace.weird("hello", 4)
@@ -28,18 +28,18 @@ t4 = cpp_namespace.Test4()
t5 = cpp_namespace.Test5()
if cpp_namespace.foo3(42) != 42:
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t2,40) != "Test2::method":
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t3,40) != "Test3::method":
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t4,40) != "Test4::method":
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t5,40) != "Test5::method":
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py
new file mode 100644
index 000000000..ef8623359
--- /dev/null
+++ b/Examples/test-suite/python/cpp_static_runme.py
@@ -0,0 +1,7 @@
+#!/usr/bin/evn python
+from cpp_static import *
+StaticFunctionTest.static_func()
+StaticFunctionTest.static_func_2(1)
+StaticFunctionTest.static_func_3(1,2)
+StaticMemberTest.static_int = 10
+assert StaticMemberTest.static_int == 10
diff --git a/Examples/test-suite/python/director_classic_runme.py b/Examples/test-suite/python/director_classic_runme.py
index 878905679..7e18a9a61 100644
--- a/Examples/test-suite/python/director_classic_runme.py
+++ b/Examples/test-suite/python/director_classic_runme.py
@@ -1,56 +1,56 @@
from director_classic import *
class TargetLangPerson(Person):
- def __init__(self):
- Person.__init__(self)
- def id(self):
- identifier = "TargetLangPerson"
- return identifier
+ def __init__(self):
+ Person.__init__(self)
+ def id(self):
+ identifier = "TargetLangPerson"
+ return identifier
class TargetLangChild(Child):
- def __init__(self):
- Child.__init__(self)
- def id(self):
- identifier = "TargetLangChild"
- return identifier
+ def __init__(self):
+ Child.__init__(self)
+ def id(self):
+ identifier = "TargetLangChild"
+ return identifier
class TargetLangGrandChild(GrandChild):
- def __init__(self):
- GrandChild.__init__(self)
- def id(self):
- identifier = "TargetLangGrandChild"
- return identifier
+ def __init__(self):
+ GrandChild.__init__(self)
+ def id(self):
+ identifier = "TargetLangGrandChild"
+ return identifier
# Semis - don't override id() in target language
class TargetLangSemiPerson(Person):
- def __init__(self):
- Person.__init__(self)
+ def __init__(self):
+ Person.__init__(self)
# No id() override
class TargetLangSemiChild(Child):
- def __init__(self):
- Child.__init__(self)
+ def __init__(self):
+ Child.__init__(self)
# No id() override
class TargetLangSemiGrandChild(GrandChild):
- def __init__(self):
- GrandChild.__init__(self)
+ def __init__(self):
+ GrandChild.__init__(self)
# No id() override
# Orphans - don't override id() in C++
class TargetLangOrphanPerson(OrphanPerson):
- def __init__(self):
- OrphanPerson.__init__(self)
- def id(self):
- identifier = "TargetLangOrphanPerson"
- return identifier
+ def __init__(self):
+ OrphanPerson.__init__(self)
+ def id(self):
+ identifier = "TargetLangOrphanPerson"
+ return identifier
class TargetLangOrphanChild(OrphanChild):
- def __init__(self):
- Child.__init__(self)
- def id(self):
- identifier = "TargetLangOrphanChild"
- return identifier
+ def __init__(self):
+ Child.__init__(self)
+ def id(self):
+ identifier = "TargetLangOrphanChild"
+ return identifier
def check(person, expected):
@@ -61,7 +61,7 @@ def check(person, expected):
if (debug):
print(ret)
if (ret != expected):
- raise ("Failed. Received: " + ret + " Expected: " + expected)
+ raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected)
# Polymorphic call from C++
caller = Caller()
@@ -70,7 +70,7 @@ def check(person, expected):
if (debug):
print(ret)
if (ret != expected):
- raise ("Failed. Received: " + ret + " Expected: " + expected)
+ raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected)
# Polymorphic call of object created in target language and passed to C++ and back again
baseclass = caller.baseClass()
@@ -78,7 +78,7 @@ def check(person, expected):
if (debug):
print(ret)
if (ret != expected):
- raise ("Failed. Received: " + ret + " Expected: " + expected)
+ raise RuntimeError("Failed. Received: " + str(ret)+ " Expected: " + expected)
caller.resetCallback()
if (debug):
diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py
index 7c9e69250..ef7a044f1 100644
--- a/Examples/test-suite/python/director_exception_runme.py
+++ b/Examples/test-suite/python/director_exception_runme.py
@@ -1,5 +1,8 @@
from director_exception import *
-from exceptions import *
+
+class MyException(Exception):
+ def __init__(self, a, b):
+ self.msg = a + b
class MyFoo(Foo):
def ping(self):
@@ -7,39 +10,62 @@ class MyFoo(Foo):
class MyFoo2(Foo):
def ping(self):
- return true
+ return True
pass # error: should return a string
-ok = 0
+class MyFoo3(Foo):
+ def ping(self):
+ raise MyException("foo", "bar")
+# Check that the NotImplementedError raised by MyFoo.ping() is returned by
+# MyFoo.pong().
+ok = 0
a = MyFoo()
b = launder(a)
-
try:
b.pong()
except NotImplementedError, e:
- ok = 1
+ if str(e) == "MyFoo::ping() EXCEPTION":
+ ok = 1
+ else:
+ print "Unexpected error message: %s" % str(e)
except:
pass
-
if not ok:
raise RuntimeError
-ok = 0
+# Check that the director returns the appropriate TypeError if the return type
+# is wrong.
+ok = 0
a = MyFoo2()
b = launder(a)
-
try:
b.pong()
-except:
- ok = 1
-
-
+except TypeError, e:
+ if str(e) == "Swig director type mismatch in output value of type 'std::string'":
+ ok = 1
+ else:
+ print "Unexpected error message: %s" % str(e)
if not ok:
raise RuntimeError
+# Check that the director can return an exception which requires two arguments
+# to the constructor, without mangling it.
+ok = 0
+a = MyFoo3()
+b = launder(a)
+try:
+ b.pong()
+except MyException, e:
+ if e.msg == 'foobar':
+ ok = 1
+ else:
+ print "Unexpected error message: %s" % str(e)
+if not ok:
+ raise RuntimeError
+
try:
raise Exception2()
except Exception2:
diff --git a/Examples/test-suite/python/director_thread_runme.py b/Examples/test-suite/python/director_thread_runme.py
index e66817e17..15a12ab80 100644
--- a/Examples/test-suite/python/director_thread_runme.py
+++ b/Examples/test-suite/python/director_thread_runme.py
@@ -14,3 +14,5 @@ d.run()
if d.val >= 0:
print d.val
raise RuntimeError
+
+d.stop()
diff --git a/Examples/test-suite/python/file_test_runme.py b/Examples/test-suite/python/file_test_runme.py
index 64154c619..de4e2669e 100644
--- a/Examples/test-suite/python/file_test_runme.py
+++ b/Examples/test-suite/python/file_test_runme.py
@@ -1,7 +1,8 @@
import sys
import file_test
-file_test.nfile(sys.stdout)
+if sys.version_info < (3,0):
+ file_test.nfile(sys.stdout)
cstdout = file_test.GetStdOut()
diff --git a/Examples/test-suite/python/hugemod.pl b/Examples/test-suite/python/hugemod.pl
index 15c4ce41b..5420926e4 100644
--- a/Examples/test-suite/python/hugemod.pl
+++ b/Examples/test-suite/python/hugemod.pl
@@ -2,8 +2,12 @@
use strict;
+my $modsize = 399; #adjust it so you can have a smaller or bigger hugemod
+
+my $runme = shift @ARGV;
+
open HEADER, ">hugemod.h" or die "error";
-open TEST, ">hugemod_runme.py" or die "error";
+open TEST, ">$runme" or die "error";
open I1, ">hugemod_a.i" or die "error";
open I2, ">hugemod_b.i" or die "error";
@@ -21,7 +25,7 @@ print I2 "\%inline \%{\n";
my $i;
-for ($i = 0; $i < 6000; $i++) {
+for ($i = 0; $i < $modsize; $i++) {
my $t = $i * 4;
print HEADER "class type$i { public: int a; };\n";
print I2 "class dtype$i : public type$i { public: int b; };\n";
diff --git a/Examples/test-suite/python/iadd.i b/Examples/test-suite/python/iadd.i
deleted file mode 100644
index 76604c027..000000000
--- a/Examples/test-suite/python/iadd.i
+++ /dev/null
@@ -1,12 +0,0 @@
-%module iadd
-
-%include attribute.i
-%{
-#include "iadd.h"
-%}
-class Foo;
-%attribute_ref(test::Foo, test::A& , AsA);
-%attribute_ref(test::Foo, long, AsLong);
-
-
-%include "iadd.h"
diff --git a/Examples/test-suite/python/implicittest.i b/Examples/test-suite/python/implicittest.i
deleted file mode 100644
index 91205aafa..000000000
--- a/Examples/test-suite/python/implicittest.i
+++ /dev/null
@@ -1,68 +0,0 @@
-%module(naturalvar="1") implicittest
-
-%implicitconv;
-
-%inline
-{
- struct B { };
-}
-
-%inline
-{
- struct A
- {
- int ii;
- A(int i) { ii = 1; }
- A(double d) { ii = 2; }
- A(const B& b) { ii = 3; }
- explicit A(char *s) { ii = 4; }
-
- int get() const { return ii; }
-
- };
-
- int get(const A& a) { return a.ii; }
-
- template
- struct A_T
- {
- int ii;
- A_T(int i) { ii = 1; }
- A_T(double d) { ii = 2; }
- A_T(const B& b) { ii = 3; }
- explicit A_T(char *s) { ii = 4; }
-
- int get() const { return ii; }
-
- };
-}
-
-%inline
-{
- struct Foo
- {
- int ii;
- Foo(){ ii = 0;}
- Foo(int){ ii = 1;}
- Foo(double){ ii = 2;}
- explicit Foo(char *s){ii = 3;}
- Foo(const Foo& f){ ii = f.ii;}
-
- };
-
- struct Bar
- {
- int ii;
- Foo f;
- Bar() {ii = -1;}
- Bar(const Foo& ff){ ii = ff.ii;}
- };
-
-
- int get_b(const Bar&b) { return b.ii; }
-
- Foo foo;
-
-}
-
-%template(A_int) A_T;
diff --git a/Examples/test-suite/python/li_attribute_runme.py b/Examples/test-suite/python/li_attribute_runme.py
index 5eeec299b..db40b9b2a 100644
--- a/Examples/test-suite/python/li_attribute_runme.py
+++ b/Examples/test-suite/python/li_attribute_runme.py
@@ -1,3 +1,5 @@
+# Ported to C# li_attribute_runme.cs
+
import li_attribute
aa = li_attribute.A(1,2,3)
@@ -9,7 +11,6 @@ if aa.a != 3:
print aa.a
raise RuntimeError
-
if aa.b != 2:
print aa.b
raise RuntimeError
@@ -17,8 +18,6 @@ aa.b = 5
if aa.b != 5:
raise RuntimeError
-
-
if aa.d != aa.b:
raise RuntimeError
@@ -36,17 +35,40 @@ pi.value=3
if pi.value != 3:
raise RuntimeError
-
b = li_attribute.B(aa)
if b.a.c != 3:
raise RuntimeError
-
-myFoo = li_attribute.MyFoo
+# class/struct attribute with get/set methods using return/pass by reference
+myFoo = li_attribute.MyFoo()
myFoo.x = 8
-myClass = li_attribute.MyClass
+myClass = li_attribute.MyClass()
myClass.Foo = myFoo
if myClass.Foo.x != 8:
raise RuntimeError
+# class/struct attribute with get/set methods using return/pass by value
+myClassVal = li_attribute.MyClassVal()
+if myClassVal.ReadWriteFoo.x != -1:
+ raise RuntimeError
+if myClassVal.ReadOnlyFoo.x != -1:
+ raise RuntimeError
+myClassVal.ReadWriteFoo = myFoo
+if myClassVal.ReadWriteFoo.x != 8:
+ raise RuntimeError
+if myClassVal.ReadOnlyFoo.x != 8:
+ raise RuntimeError
+
+# string attribute with get/set methods using return/pass by value
+myStringyClass = li_attribute.MyStringyClass("initial string")
+if myStringyClass.ReadWriteString != "initial string":
+ raise RuntimeError
+if myStringyClass.ReadOnlyString != "initial string":
+ raise RuntimeError
+myStringyClass.ReadWriteString = "changed string"
+if myStringyClass.ReadWriteString != "changed string":
+ raise RuntimeError
+if myStringyClass.ReadOnlyString != "changed string":
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/li_boost_shared_ptr_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_runme.py
index 5f6cbd211..f967def14 100644
--- a/Examples/test-suite/python/li_boost_shared_ptr_runme.py
+++ b/Examples/test-suite/python/li_boost_shared_ptr_runme.py
@@ -304,6 +304,15 @@ class li_boost_shared_ptr_runme:
self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr")
self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref")
+ # 3rd derived class
+ k = li_boost_shared_ptr.Klass3rdDerived("me oh my")
+ val = k.getValue()
+ self.verifyValue("me oh my-3rdDerived", val)
+ self.verifyCount(1, k)
+ val = li_boost_shared_ptr.test3rdupcast(k)
+ self.verifyValue("me oh my-3rdDerived", val)
+ self.verifyCount(1, k)
+
# //////////////////////////////// Member variables ////////////////////////////////////////
# smart pointer by value
m = li_boost_shared_ptr.MemberVariables()
diff --git a/Examples/test-suite/python/li_std_map.i b/Examples/test-suite/python/li_std_map.i
deleted file mode 100644
index a8ba4f2e2..000000000
--- a/Examples/test-suite/python/li_std_map.i
+++ /dev/null
@@ -1,58 +0,0 @@
-%module("templatereduce") li_std_map
-
-%include std_pair.i
-%include std_map.i
-%include std_multimap.i
-
-%inline %{
-struct A{
- int val;
-
- A(int v = 0): val(v)
- {
- }
-
-};
-%}
-
-namespace std
-{
- %template(pairii) pair;
- %template(pairAA) pair;
- %template(pairA) pair;
- %template(mapA) map;
- %template(mmapA) multimap;
-
- %template(paircA1) pair;
- %template(paircA2) pair;
- %template(pairiiA) pair >;
- %template(pairiiAc) pair >;
-
-
- %template() pair;
- %template(pymap) map;
-
-}
-
-
-
-%inline
-{
-std::pair
-p_identa(std::pair p) {
- return p;
-}
-
-std::map m_identa(const std::map& v)
-{
- return v;
-}
-
-}
-
-
-
-namespace std
-{
-%template(mapii) map;
-}
diff --git a/Examples/test-suite/python/li_std_pair.i b/Examples/test-suite/python/li_std_pair.i
deleted file mode 100644
index 886bf1a4b..000000000
--- a/Examples/test-suite/python/li_std_pair.i
+++ /dev/null
@@ -1,210 +0,0 @@
-%module li_std_pair
-
-//
-// activate the automatic comparison methods generation (==,!=,...)
-//
-
-%{
-#include // for std::swap
-%}
-
-
-%include std_pair.i
-%include std_string.i
-%include std_complex.i
-
-%inline
-%{
- struct A
- {
- int val;
-
- A(int v = 0): val(v)
- {
- }
-
- };
- struct B
- {
- };
-%}
-
-%std_comp_methods(std::pair);
-
-namespace std {
- %template(CIntPair) pair;
- %template() pair;
- %template(ShortPair) pair;
-
- %template(IntPair) pair;
- %extend pair
- {
- %template(pair) pair;
- }
-
-
-
- %template(SIPair) pair;
- %template(CIPair) pair, int>;
- %template(SIIPair) pair, int>;
- %template(AIntPair) pair;
-
- %template(CCIntPair) pair >;
-
- %template(ABPair) pair;
- %template(IntAPair) pair;
-
- %template(pairP1) pair;
- %template(pairP2) pair;
- %template(pairP3) pair;
- %template(pairP4) pair;
- %template(pairP5) pair;
- %template(pairP6) pair;
-
-}
-%std_comp_methods(std::pair, int>);
-
-%apply std::pair *INOUT {std::pair *INOUT2};
-
-%inline %{
-
-/* Test the "out" typemap for pair */
-std::pair makeIntPair(int a, int b) {
- return std::make_pair(a, b);
-}
-
-/**
- * There is no "out" typemap for a pointer to a pair, so
- * this should return a wrapped instance of a std::pair
- * instead of the native "array" type for the target language.
- */
-std::pair * makeIntPairPtr(int a, int b) {
- static std::pair p = std::make_pair(a, b);
- return &p;
-}
-
-/**
- * There is no "out" typemap for a non-const reference to a pair, so
- * this should return a wrapped instance of a std::pair instead of
- * the native "array" type for the target language.
- */
-std::pair& makeIntPairRef(int a, int b) {
- static std::pair p = std::make_pair(a, b);
- return p;
-}
-
-/**
- * There is no "out" typemap for a const reference to a pair, so
- * this should return a wrapped instance of a std::pair
- * instead of the native "array" type for the target language.
- */
-const std::pair & makeIntPairConstRef(int a, int b) {
- static std::pair p = std::make_pair(a, b);
- return p;
-}
-
-/* Test the "in" typemap for pair */
-int product1(std::pair p) {
- return p.first*p.second;
-}
-
-/* Test the "in" typemap for const pair& */
-int product2(const std::pair& p) {
- return p.first*p.second;
-}
-
-std::pair
- p_ident(std::pair p, const std::pair& q) {
- return p;
-}
-
-
-std::pair
-p_identa(const std::pair& p) {
- return p;
-}
-
-void
-d_inout(double *INOUT) {
- *INOUT += *INOUT;
-}
-
-void
-d_inout(int *INOUT) {
- *INOUT += *INOUT;
-}
-
-int
-d_inout2(double *INOUT) {
- *INOUT += *INOUT;
- return 1;
-}
-
-void
-p_inout(std::pair *INOUT) {
- std::swap(INOUT->first, INOUT->second);
-}
-
-int
-p_inout2(std::pair *INOUT) {
- std::swap(INOUT->first, INOUT->second);
- return 1;
-}
-
-void
- p_inout3(std::pair *INOUT, std::pair *INOUT2) {
- std::swap(*INOUT, *INOUT2);
-}
-
-void
-p_inoutd(std::pair *INOUT) {
- std::swap(INOUT->first, INOUT->second);
-}
-
-std::string
- s_ident(const std::string& s) {
- return s;
-}
-
-#if 0
-std::pair
- p_ident(std::pair p, const std::pair& q) {
- return p;
-}
-
-/* Test the "in" typemap for const pair* */
-std::pair
- p_ident(std::pair p, const std::pair& q) {
- return q;
-}
-
-/* Test the "in" typemap for const pair* */
-std::pair
- p_ident(std::pair p, const std::pair& q) {
- return p;
-}
-
-
-std::pair
- p_ident(std::pair p, const std::pair& q) {
- return p;
-}
-
-std::pair
- p_ident(std::pair p, const std::pair& q) {
- return p;
-}
-
-
-
-#endif
-%}
-
-
-namespace std
-{
- %template(paircA1) pair;
- %template(paircA2) pair;
- %template(pairiiA) pair >;
-}
-
diff --git a/Examples/test-suite/python/li_std_pair_extra_runme.py b/Examples/test-suite/python/li_std_pair_extra_runme.py
new file mode 100644
index 000000000..dc6e31b76
--- /dev/null
+++ b/Examples/test-suite/python/li_std_pair_extra_runme.py
@@ -0,0 +1,59 @@
+import li_std_pair_extra
+
+p = (1,2)
+p1 = li_std_pair_extra.p_inout(p)
+p2 = li_std_pair_extra.p_inoutd(p1)
+
+d1 = li_std_pair_extra.d_inout(2)
+
+i,d2 = li_std_pair_extra.d_inout2(2)
+
+i,p = li_std_pair_extra.p_inout2(p)
+p3,p4 = li_std_pair_extra.p_inout3(p1,p1)
+
+psi = li_std_pair_extra.SIPair("hello",1)
+pci = li_std_pair_extra.CIPair(1,1)
+
+
+#psi.first = "hi"
+
+
+psi = li_std_pair_extra.SIPair("hi",1)
+if psi != ("hi",1):
+ raise RuntimeError
+
+psii = li_std_pair_extra.SIIPair(psi,1)
+
+a = li_std_pair_extra.A()
+b = li_std_pair_extra.B()
+
+pab = li_std_pair_extra.ABPair(a,b);
+
+pab.first = a
+pab.first.val = 2
+
+if pab.first.val != 2:
+ raise RuntimeError
+
+
+pci = li_std_pair_extra.CIntPair(1,0)
+
+a = li_std_pair_extra.A(5)
+p1 = li_std_pair_extra.pairP1(1,a.this)
+p2 = li_std_pair_extra.pairP2(a,1)
+p3 = li_std_pair_extra.pairP3(a,a)
+
+
+if a.val != li_std_pair_extra.p_identa(p1.this)[1].val:
+ raise RuntimeError
+
+p = li_std_pair_extra.IntPair(1,10)
+p.first = 1
+
+p = li_std_pair_extra.paircA1(1,a)
+p.first
+p.second
+
+p = li_std_pair_extra.paircA2(1,a)
+pp = li_std_pair_extra.pairiiA(1,p)
+
diff --git a/Examples/test-suite/python/li_std_pair_runme.py b/Examples/test-suite/python/li_std_pair_runme.py
deleted file mode 100644
index b301f0d24..000000000
--- a/Examples/test-suite/python/li_std_pair_runme.py
+++ /dev/null
@@ -1,59 +0,0 @@
-import li_std_pair
-
-p = (1,2)
-p1 = li_std_pair.p_inout(p)
-p2 = li_std_pair.p_inoutd(p1)
-
-d1 = li_std_pair.d_inout(2)
-
-i,d2 = li_std_pair.d_inout2(2)
-
-i,p = li_std_pair.p_inout2(p)
-p3,p4 = li_std_pair.p_inout3(p1,p1)
-
-psi = li_std_pair.SIPair("hello",1)
-pci = li_std_pair.CIPair(1,1)
-
-
-#psi.first = "hi"
-
-
-psi = li_std_pair.SIPair("hi",1)
-if psi != ("hi",1):
- raise RuntimeError
-
-psii = li_std_pair.SIIPair(psi,1)
-
-a = li_std_pair.A()
-b = li_std_pair.B()
-
-pab = li_std_pair.ABPair(a,b);
-
-pab.first = a
-pab.first.val = 2
-
-if pab.first.val != 2:
- raise RuntimeError
-
-
-pci = li_std_pair.CIntPair(1,0)
-
-a = li_std_pair.A(5)
-p1 = li_std_pair.pairP1(1,a.this)
-p2 = li_std_pair.pairP2(a,1)
-p3 = li_std_pair.pairP3(a,a)
-
-
-if a.val != li_std_pair.p_identa(p1.this)[1].val:
- raise RuntimeError
-
-p = li_std_pair.IntPair(1,10)
-p.first = 1
-
-p = li_std_pair.paircA1(1,a)
-p.first
-p.second
-
-p = li_std_pair.paircA2(1,a)
-pp = li_std_pair.pairiiA(1,p)
-
diff --git a/Examples/test-suite/python/li_std_set.i b/Examples/test-suite/python/li_std_set.i
deleted file mode 100644
index f0fddb058..000000000
--- a/Examples/test-suite/python/li_std_set.i
+++ /dev/null
@@ -1,17 +0,0 @@
-%module li_std_set
-
-%include
-%include
-%include
-%include
-
-%template(set_string) std::set;
-%template(set_int) std::multiset;
-
-
-%template(v_int) std::vector;
-
-
-
-
-%template(pyset) std::set;
diff --git a/Examples/test-suite/python/li_std_stream.i b/Examples/test-suite/python/li_std_stream.i
deleted file mode 100644
index 0a999ddbf..000000000
--- a/Examples/test-suite/python/li_std_stream.i
+++ /dev/null
@@ -1,59 +0,0 @@
-%module li_std_stream
-
-%inline %{
- struct A;
-%}
-
-%include
-%include
-
-
-
-%callback(1) A::bar;
-
-%inline %{
-
- struct B {
- virtual ~B()
- {
- }
-
- };
-
- struct A : B
- {
- void __add__(int a)
- {
- }
-
- void __add__(double a)
- {
- }
-
- static int bar(int a){
- return a;
- }
-
- static int foo(int a, int (*pf)(int a))
- {
- return pf(a);
- }
-
-
- std::ostream& __rlshift__(std::ostream& out)
- {
- out << "A class";
- return out;
- }
- };
-%}
-
-%extend std::basic_ostream{
- std::basic_ostream&
- operator<<(const A& a)
- {
- *self << "A class";
- return *self;
- }
-}
-
diff --git a/Examples/test-suite/python/li_std_string_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py
similarity index 54%
rename from Examples/test-suite/python/li_std_string_runme.py
rename to Examples/test-suite/python/li_std_string_extra_runme.py
index c0dae1e25..cef5921b0 100644
--- a/Examples/test-suite/python/li_std_string_runme.py
+++ b/Examples/test-suite/python/li_std_string_extra_runme.py
@@ -1,24 +1,24 @@
-import li_std_string
+import li_std_string_extra
x="hello"
-if li_std_string.test_ccvalue(x) != x:
+if li_std_string_extra.test_ccvalue(x) != x:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_cvalue(x) != x:
+if li_std_string_extra.test_cvalue(x) != x:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_value(x) != x:
- print x, li_std_string.test_value(x)
+if li_std_string_extra.test_value(x) != x:
+ print x, li_std_string_extra.test_value(x)
raise RuntimeError, "bad string mapping"
-if li_std_string.test_const_reference(x) != x:
+if li_std_string_extra.test_const_reference(x) != x:
raise RuntimeError, "bad string mapping"
-s = li_std_string.string("he")
+s = li_std_string_extra.string("he")
#s += "ll"
#s.append('o')
s = s + "llo"
@@ -30,21 +30,21 @@ if s != x:
if s[1:4] != x[1:4]:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_value(s) != x:
+if li_std_string_extra.test_value(s) != x:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_const_reference(s) != x:
+if li_std_string_extra.test_const_reference(s) != x:
raise RuntimeError, "bad string mapping"
-a = li_std_string.A(s)
+a = li_std_string_extra.A(s)
-if li_std_string.test_value(a) != x:
+if li_std_string_extra.test_value(a) != x:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_const_reference(a) != x:
+if li_std_string_extra.test_const_reference(a) != x:
raise RuntimeError, "bad string mapping"
-b = li_std_string.string(" world")
+b = li_std_string_extra.string(" world")
s = a + b
if a + b != "hello world":
@@ -63,40 +63,40 @@ if c.find_last_of("l") != 9:
s = "hello world"
-b = li_std_string.B("hi")
+b = li_std_string_extra.B("hi")
-b.name = li_std_string.string("hello")
+b.name = li_std_string_extra.string("hello")
if b.name != "hello":
raise RuntimeError, "bad string mapping"
-b.a = li_std_string.A("hello")
+b.a = li_std_string_extra.A("hello")
if b.a != "hello":
raise RuntimeError, "bad string mapping"
-if li_std_string.test_value_basic1(x) != x:
+if li_std_string_extra.test_value_basic1(x) != x:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_value_basic2(x) != x:
+if li_std_string_extra.test_value_basic2(x) != x:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_value_basic3(x) != x:
+if li_std_string_extra.test_value_basic3(x) != x:
raise RuntimeError, "bad string mapping"
# Global variables
s = "initial string"
-if li_std_string.cvar.GlobalString2 != "global string 2":
+if li_std_string_extra.cvar.GlobalString2 != "global string 2":
raise RuntimeError, "GlobalString2 test 1"
-li_std_string.cvar.GlobalString2 = s
-if li_std_string.cvar.GlobalString2 != s:
+li_std_string_extra.cvar.GlobalString2 = s
+if li_std_string_extra.cvar.GlobalString2 != s:
raise RuntimeError, "GlobalString2 test 2"
-if li_std_string.cvar.ConstGlobalString != "const global string":
+if li_std_string_extra.cvar.ConstGlobalString != "const global string":
raise RuntimeError, "ConstGlobalString test"
# Member variables
-myStructure = li_std_string.Structure()
+myStructure = li_std_string_extra.Structure()
if myStructure.MemberString2 != "member string 2":
raise RuntimeError, "MemberString2 test 1"
myStructure.MemberString2 = s
@@ -105,28 +105,28 @@ if myStructure.MemberString2 != s:
if myStructure.ConstMemberString != "const member string":
raise RuntimeError, "ConstMemberString test"
-if li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2":
+if li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2":
raise RuntimeError, "StaticMemberString2 test 1"
-li_std_string.cvar.Structure_StaticMemberString2 = s
-if li_std_string.cvar.Structure_StaticMemberString2 != s:
+li_std_string_extra.cvar.Structure_StaticMemberString2 = s
+if li_std_string_extra.cvar.Structure_StaticMemberString2 != s:
raise RuntimeError, "StaticMemberString2 test 2"
-if li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string":
+if li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string":
raise RuntimeError, "ConstStaticMemberString test"
-if li_std_string.test_reference_input("hello") != "hello":
+if li_std_string_extra.test_reference_input("hello") != "hello":
raise RuntimeError
-s = li_std_string.test_reference_inout("hello")
+s = li_std_string_extra.test_reference_inout("hello")
if s != "hellohello":
raise RuntimeError
-if li_std_string.stdstring_empty() != "":
+if li_std_string_extra.stdstring_empty() != "":
raise RuntimeError
-if li_std_string.c_empty() != "":
+if li_std_string_extra.c_empty() != "":
raise RuntimeError
-if li_std_string.c_null() != None:
+if li_std_string_extra.c_null() != None:
raise RuntimeError
diff --git a/Examples/test-suite/python/li_std_vector_runme.py b/Examples/test-suite/python/li_std_vector_extra_runme.py
similarity index 84%
rename from Examples/test-suite/python/li_std_vector_runme.py
rename to Examples/test-suite/python/li_std_vector_extra_runme.py
index a0d96d4aa..776eacfb3 100644
--- a/Examples/test-suite/python/li_std_vector_runme.py
+++ b/Examples/test-suite/python/li_std_vector_extra_runme.py
@@ -1,4 +1,4 @@
-from li_std_vector import *
+from li_std_vector_extra import *
iv = IntVector(4)
for i in range(0,4):
@@ -133,3 +133,24 @@ if overloaded3(None) != "vector *":
if overloaded3(100) != "int":
raise RuntimeError
+
+# vector pointer checks
+ip = makeIntPtr(11)
+dp = makeDoublePtr(33.3)
+error = 0
+try:
+ vi = IntPtrVector((ip, dp)) # check vector does not accept double * element
+ error = 1
+except:
+ pass
+
+if error:
+ raise RuntimeError
+
+vi = IntPtrVector((ip, makeIntPtr(22)))
+if extractInt(vi[0]) != 11:
+ raise RuntimeError
+
+if extractInt(vi[1]) != 22:
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/li_std_vector_ptr_runme.py b/Examples/test-suite/python/li_std_vector_ptr_runme.py
new file mode 100644
index 000000000..c5f72fde4
--- /dev/null
+++ b/Examples/test-suite/python/li_std_vector_ptr_runme.py
@@ -0,0 +1,8 @@
+from li_std_vector_ptr import *
+
+ip1 = makeIntPtr(11)
+ip2 = makeIntPtr(22)
+
+vi = IntPtrVector((ip1, ip2))
+displayVector(vi)
+
diff --git a/Examples/test-suite/python/li_std_wstring.i b/Examples/test-suite/python/li_std_wstring.i
deleted file mode 100644
index c809e11ec..000000000
--- a/Examples/test-suite/python/li_std_wstring.i
+++ /dev/null
@@ -1,89 +0,0 @@
-%module li_std_wstring
-%include
-%include
-
-
-%inline %{
-
-struct A : std::wstring
-{
- A(const std::wstring& s) : std::wstring(s)
- {
- }
-};
-
-struct B
-{
- B(const std::wstring& s) : cname(0), name(s), a(s)
- {
- }
-
- char *cname;
- std::wstring name;
- A a;
-
-};
-
-
-wchar_t test_wcvalue(wchar_t x) {
- return x;
-}
-
-const wchar_t* test_ccvalue(const wchar_t* x) {
- return x;
-}
-
-wchar_t* test_cvalue(wchar_t* x) {
- return x;
-}
-
-
-std::wstring test_value(std::wstring x) {
- return x;
-}
-
-const std::wstring& test_const_reference(const std::wstring &x) {
- return x;
-}
-
-void test_pointer(std::wstring *x) {
-}
-
-std::wstring *test_pointer_out() {
- static std::wstring x = L"x";
- return &x;
-}
-
-void test_const_pointer(const std::wstring *x) {
-}
-
-const std::wstring *test_const_pointer_out() {
- static std::wstring x = L"x";
- return &x;
-}
-
-void test_reference(std::wstring &x) {
-}
-
-std::wstring& test_reference_out() {
- static std::wstring x = L"x";
- return x;
-}
-
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
-void test_throw() throw(std::wstring){
- static std::wstring x = L"x";
-
- throw x;
-}
-
-#if defined(_MSC_VER)
- #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
-%}
-
-
diff --git a/Examples/test-suite/python/operbool_runme.py b/Examples/test-suite/python/operbool_runme.py
new file mode 100644
index 000000000..4218b5dd4
--- /dev/null
+++ b/Examples/test-suite/python/operbool_runme.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+import operbool
+assert not operbool.Test()
+
diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py
new file mode 100644
index 000000000..e34777558
--- /dev/null
+++ b/Examples/test-suite/python/python_abstractbase_runme3.py
@@ -0,0 +1,8 @@
+from python_abstractbase import *
+from collections import *
+assert issubclass(Mapii, MutableMapping)
+assert issubclass(Multimapii, MutableMapping)
+assert issubclass(IntSet, MutableSet)
+assert issubclass(IntMultiset, MutableSet)
+assert issubclass(IntVector, MutableSequence)
+assert issubclass(IntList, MutableSequence)
diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py
new file mode 100644
index 000000000..c8e6b2640
--- /dev/null
+++ b/Examples/test-suite/python/python_append_runme.py
@@ -0,0 +1,4 @@
+from python_append import *
+t=Test()
+t.func()
+t.static_func()
diff --git a/Examples/test-suite/python/kwargs_runme.py b/Examples/test-suite/python/python_kwargs_runme.py
similarity index 97%
rename from Examples/test-suite/python/kwargs_runme.py
rename to Examples/test-suite/python/python_kwargs_runme.py
index 91812929d..fb6e191dd 100644
--- a/Examples/test-suite/python/kwargs_runme.py
+++ b/Examples/test-suite/python/python_kwargs_runme.py
@@ -1,4 +1,4 @@
-from kwargs import *
+from python_kwargs import *
class MyFoo(Foo):
def __init__(self, a , b = 0):
diff --git a/Examples/test-suite/python/nondynamic_runme.py b/Examples/test-suite/python/python_nondynamic_runme.py
similarity index 67%
rename from Examples/test-suite/python/nondynamic_runme.py
rename to Examples/test-suite/python/python_nondynamic_runme.py
index 18230616d..27755db9c 100644
--- a/Examples/test-suite/python/nondynamic_runme.py
+++ b/Examples/test-suite/python/python_nondynamic_runme.py
@@ -1,6 +1,6 @@
-import nondynamic
+import python_nondynamic
-aa = nondynamic.A()
+aa = python_nondynamic.A()
aa.a = 1
aa.b = 2
@@ -14,10 +14,10 @@ if not err:
raise RuntimeError, "A is not static"
-class B(nondynamic.A):
+class B(python_nondynamic.A):
c = 4
def __init__(self):
- nondynamic.A.__init__(self)
+ python_nondynamic.A.__init__(self)
pass
pass
@@ -35,5 +35,5 @@ if not err:
raise RuntimeError, "B is not static"
-cc = nondynamic.C()
+cc = python_nondynamic.C()
cc.d = 3
diff --git a/Examples/test-suite/python/overload_simple_cast_runme.py b/Examples/test-suite/python/python_overload_simple_cast_runme.py
similarity index 98%
rename from Examples/test-suite/python/overload_simple_cast_runme.py
rename to Examples/test-suite/python/python_overload_simple_cast_runme.py
index 87e6e5d43..1b3a5482c 100644
--- a/Examples/test-suite/python/overload_simple_cast_runme.py
+++ b/Examples/test-suite/python/python_overload_simple_cast_runme.py
@@ -1,4 +1,4 @@
-from overload_simple_cast import *
+from python_overload_simple_cast import *
class Ai:
def __init__(self,x):
diff --git a/Examples/test-suite/python/python_pybuf_runme3.py b/Examples/test-suite/python/python_pybuf_runme3.py
new file mode 100644
index 000000000..152aecdc0
--- /dev/null
+++ b/Examples/test-suite/python/python_pybuf_runme3.py
@@ -0,0 +1,42 @@
+#run:
+# python python_pybuf_runme3.py benchmark
+#for the benchmark, other wise the test case will be run
+import python_pybuf
+import sys
+if len(sys.argv)>=2 and sys.argv[1]=="benchmark":
+ #run the benchmark
+ import time
+ k=1000000 #number of times to excute the functions
+
+ t=time.time()
+ a = bytearray(b'hello world')
+ for i in range(k):
+ pybuf.title1(a)
+ print("Time used by bytearray:",time.time()-t)
+
+ t=time.time()
+ b = 'hello world'
+ for i in range(k):
+ pybuf.title2(b)
+ print("Time used by string:",time.time()-t)
+else:
+ #run the test case
+ buf1 = bytearray(10)
+ buf2 = bytearray(50)
+
+ pybuf.func1(buf1)
+ assert buf1 == b'a'*10
+
+ pybuf.func2(buf2)
+ assert buf2.startswith(b"Hello world!\x00")
+
+ count = pybuf.func3(buf2)
+ assert count==10 #number of alpha and number in 'Hello world!'
+
+ length = pybuf.func4(buf2)
+ assert length==12
+
+ buf3 = bytearray(b"hello")
+ pybuf.title1(buf3)
+ assert buf3==b'Hello'
+
diff --git a/Examples/test-suite/python/rename_strip_encoder_runme.py b/Examples/test-suite/python/rename_strip_encoder_runme.py
new file mode 100644
index 000000000..64be611d6
--- /dev/null
+++ b/Examples/test-suite/python/rename_strip_encoder_runme.py
@@ -0,0 +1,6 @@
+from rename_strip_encoder import *
+
+s = SomeWidget()
+a = AnotherWidget()
+a.DoSomething()
+
diff --git a/Examples/test-suite/python/std_containers.i b/Examples/test-suite/python/std_containers.i
deleted file mode 100644
index a1d39e7ab..000000000
--- a/Examples/test-suite/python/std_containers.i
+++ /dev/null
@@ -1,199 +0,0 @@
-%module std_containers
-
-%{
-#include
-%}
-%include std_vector.i
-%include std_string.i
-%include std_deque.i
-%include std_list.i
-%include std_set.i
-%include std_multiset.i
-%include std_pair.i
-%include std_map.i
-%include std_multimap.i
-%include std_complex.i
-
-%template() std::vector;
-%template() std::pair;
-%template() std::pair;
-
-%template() std::vector< std::vector > ;
-%template(ccube) std::vector< std::vector< std::vector > >;
-
-%inline
-{
- typedef
- std::vector > >
- ccube;
-
- ccube cident(const ccube& c)
- {
- return c;
- }
-
- struct C
- {
- };
-}
-
-
-%template(map_si) std::map;
-%template(pair_iC) std::pair;
-%template(map_iC) std::map;
-%template(mmap_si) std::multimap;
-%template(set_i) std::set;
-%template(multiset_i) std::multiset;
-%template(list_i) std::list;
-%template(deque_i) std::deque;
-
-%template(vector_b) std::vector;
-%template(vector_i) std::vector;
-%template(vector_c) std::vector