From 9e9f5d84b3c37b415ba5fbf9deeec636657ceedd Mon Sep 17 00:00:00 2001
From: John Lenz
+>>> a = add(3,4) >>> print a 7 @@ -153,7 +153,7 @@ void getwinsize(int winid, int *width, int *height); In this case, the function returns multiple values, allowing it to be used like this: -+>>> w,h = genwinsize(wid) >>> print w 400 @@ -234,7 +234,7 @@ extern double add(double *INPUT, double *INPUT); When the function is used in the scripting language interpreter, it will work like this: -+@@ -297,7 +297,7 @@ extern int foo(double a, double b, double *OUTPUT); The function will return two values like this: -result = add(3,4)+iresult, dresult = foo(3.5, 2)@@ -347,7 +347,7 @@ extern void negate(double *INOUT);Now within a script, you can simply call the function normally :
-+diff --git a/SWIG/Doc/Manual/Contract.html b/SWIG/Doc/Manual/Contract.html index 6f8a5bf66..fc341fe23 100644 --- a/SWIG/Doc/Manual/Contract.html +++ b/SWIG/Doc/Manual/Contract.html @@ -82,7 +82,7 @@ Once a contract has been specified, it modifies the behavior of the resulting module. For example: -a = negate(3); # a = -3 after calling this+>>> example.sqrt(2) 1.4142135623730951 diff --git a/SWIG/Doc/Manual/Customization.html b/SWIG/Doc/Manual/Customization.html index 610df295c..46bcd9a13 100644 --- a/SWIG/Doc/Manual/Customization.html +++ b/SWIG/Doc/Manual/Customization.html @@ -425,7 +425,7 @@ As arguments, SWIG_exception() takes an error type code (an integer) and an error message string. The currently supported error types are : -+SWIG_MemoryError SWIG_IOError SWIG_RuntimeError diff --git a/SWIG/Doc/Manual/Extending.html b/SWIG/Doc/Manual/Extending.html index 92660c029..acd5cd4a8 100644 --- a/SWIG/Doc/Manual/Extending.html +++ b/SWIG/Doc/Manual/Extending.html @@ -291,7 +291,7 @@ The current C++ parser handles a subset of C++. Most incompatibilities with C a subtle aspects of how SWIG parses declarations. Specifically, SWIG expects all C/C++ declarations to follow this general form: -+storage type declarator initializer;@@ -395,7 +395,7 @@ The parse tree structure and tag names of an interface can be displayed using- +$ swig -c++ -python -dump_tags example.i . top (example.i:1) @@ -453,7 +453,7 @@ pairs. Internally, the nodes are simply represented by hash tables. A display the parse-tree structure can be obtained using swig -dump_tree. For example: -+$ swig -c++ -python -dump_tree example.i ... @@ -683,7 +683,7 @@ void foo(Bar *b); Now, running SWIG: -+$ swig -dump_tree example.i ... @@ -733,7 +733,7 @@ void foo(Bar *b); When you run SWIG on this you now get: -+$ ./swig example.i example.i:6. Overloaded declaration ignored. foo_d(double ) @@ -777,7 +777,7 @@ given prototype. When a feature is added, it shows up as an attribute in the < You can see this when running with the -dump_tree option. For example: -++++ cdecl ---------------------------------------- | sym:name - "getitem" @@ -828,7 +828,7 @@ When the parser constructs a node for the member bar, it creates a raw attributes: -+nodeType : cdecl name : bar @@ -844,7 +844,7 @@ sym:name : bar To produce wrapper code, this "cdecl" node undergoes a number of transformations. First, the node is recognized as a function declaration. This adjusts some of the type information--specifically, the declarator is joined with the base datatype to produce this: -+nodeType : cdecl name : bar @@ -862,7 +862,7 @@ member function. This produces a transformation to a low-level accessor function like this: -+nodeType : cdecl name : bar @@ -1795,7 +1795,7 @@ Internally, types are represented as strings that are constructed in a very precise manner. Here are some examples: -+C datatype SWIG encoding (strings) ----------------------------- -------------------------- @@ -1819,7 +1819,7 @@ a "pointer to a function(int,double) that returns int". The following operator encodings are used in type strings: -+Operator Meaning ------------------- ------------------------------- @@ -1846,7 +1846,7 @@ is expected. For instance, here is an extremely perverted example: -+`p.a(10).p.f(int,p.f(int).int)` foo(int, int (*x)(int));@@ -1856,7 +1856,7 @@ an extremely perverted example: This corresponds to the immediately obvious C declaration: -+(*(*foo(int,int (*)(int)))[10])(int,int (*)(int));@@ -2139,7 +2139,7 @@ typedef int Size; produces two trees like this: -+int p.Integer ^ ^ ^ ^ @@ -2169,7 +2169,7 @@ resolving types, the process starts in the leaf nodes and moves up the tree towards the root. Here are a few examples that show how it works: -+Original type After typedef_resolve() ------------------------ ----------------------- @@ -2185,7 +2185,7 @@ For complicated types, the process can be quite involved. Here is the reduction of a function pointer: -+p.f(Integer, p.IntegerPtr, Size).Integer : Start p.f(Integer, p.IntegerPtr, Size).int @@ -2318,7 +2318,7 @@ functions and templates. Parameter list are represented as a list of nodes with the following attributes: -+"type" - Parameter type (required) "name" - Parameter name (optional) @@ -2332,7 +2332,7 @@ Typically parameters are denoted in the source by using a typename of code like this: -+Parm *parms; Parm *p; @@ -2510,7 +2510,7 @@ Next, at the top level of the SWIG distribution, re-run the autogen.sh to regenerate the various build files: -+$ sh autogen.sh@@ -2520,7 +2520,7 @@ $ sh autogen.sh Next re-run configure to regenerate all of the Makefiles: -+$ ./configure@@ -2530,7 +2530,7 @@ $ ./configure Finally, rebuild SWIG with your module added: -+$ make@@ -2974,7 +2974,7 @@ A declaration is parsed as "storage T D" where storage is a storage class, T is and D is a declarator. -+"name" - Declarator name "type" - Base type T @@ -2995,7 +2995,7 @@ and D is a declarator. C++ constructor declaration. -+"name" - Name of constructor "parms" - Parameters @@ -3014,7 +3014,7 @@ C++ constructor declaration. C++ destructor declaration. -+"name" - Name of destructor "code" - Function body code (if any) @@ -3032,7 +3032,7 @@ C++ destructor declaration. C++ access change. -+"kind" - public, protected, private@@ -3047,7 +3047,7 @@ C++ access change. Constant created by %constant or #define. -+"name" - Name of constant. "type" - Base type. @@ -3065,7 +3065,7 @@ Constant created by %constant or #define. C++ class definition or C structure definition. -+"name" - Name of the class. "kind" - Class kind ("struct", "union", "class") @@ -3087,7 +3087,7 @@ C++ class definition or C structure definition. Enumeration. -+"name" - Name of the enum (if supplied). "storage" - Storage class (if any) @@ -3105,7 +3105,7 @@ Enumeration. Enumeration value. -+"name" - Name of the enum value. "type" - Type (integer or char) @@ -3122,7 +3122,7 @@ Enumeration value. C++ namespace. -+"name" - Name of the namespace. "symtab" - Symbol table for enclosed scope. @@ -3140,7 +3140,7 @@ C++ namespace. C++ using directive. -+"name" - Name of the object being referred to. "uname" - Qualified name actually given to using. @@ -3158,7 +3158,7 @@ C++ using directive. A forward C++ class declaration. -+"name" - Name of the class. "kind" - Class kind ("union", "struct", "class") @@ -3175,7 +3175,7 @@ Code insertion directive. For example, %{ ... %} or %insert(section). -+"code" - Inserted code "section" - Section name ("header", "wrapper", etc.) @@ -3190,7 +3190,7 @@ Code insertion directive. For example, %{ ... %} or Top of the parse tree. -+"module" - Module name@@ -3204,7 +3204,7 @@ Top of the parse tree. %extend directive. -+"name" - Module name "symtab" - Symbol table of enclosed scope. @@ -3219,7 +3219,7 @@ Top of the parse tree. %apply pattern { patternlist }. -+"pattern" - Source pattern. "symtab" - Symbol table of enclosed scope. @@ -3234,7 +3234,7 @@ Top of the parse tree. %clear patternlist; -+"firstChild" - Patterns to clear@@ -3248,7 +3248,7 @@ Top of the parse tree. %include directive. -+"name" - Filename "firstChild" - Children @@ -3263,7 +3263,7 @@ Top of the parse tree. %import directive. -+"name" - Filename "firstChild" - Children @@ -3279,7 +3279,7 @@ Top of the parse tree. %module directive. -+"name" - Name of the module@@ -3294,7 +3294,7 @@ Top of the parse tree. %typemap directive. -+"method" - Typemap method name. "code" - Typemap code. @@ -3311,7 +3311,7 @@ Top of the parse tree. %typemap directive with copy. -+"method" - Typemap method name. "pattern" - Typemap source pattern. @@ -3328,7 +3328,7 @@ Top of the parse tree. %typemap pattern. Used with %apply, %clear, %typemap. -+"pattern" - Typemap pattern (a parameter list) "parms" - Typemap parameters. @@ -3343,7 +3343,7 @@ Top of the parse tree. %types directive. -+"parms" - List of parameter types.@@ -3358,7 +3358,7 @@ Top of the parse tree. extern "X" { ... } declaration. -+"name" - Name "C", "Fortran", etc.diff --git a/SWIG/Doc/Manual/Introduction.html b/SWIG/Doc/Manual/Introduction.html index 15c411150..890e5ccaa 100644 --- a/SWIG/Doc/Manual/Introduction.html +++ b/SWIG/Doc/Manual/Introduction.html @@ -203,7 +203,7 @@ SWIG is invoked using the swig command. We can use this to build a Tcl module (under Linux) as follows : -+unix > swig -tcl example.i unix > gcc -c -fpic example.c example_wrap.c -I/usr/local/include unix > gcc -shared example.o example_wrap.o -o example.so @@ -237,7 +237,7 @@ Now, let's turn these functions into a Perl5 module. Without making any changes type the following (shown for Solaris): -+unix > swig -perl5 example.i unix > gcc -c example.c example_wrap.c \ -I/usr/local/lib/perl5/sun4-solaris/5.003/CORE @@ -262,7 +262,7 @@ unix > Finally, let's build a module for Python (shown for Irix). -+unix > swig -python example.i unix > gcc -c -fpic example.c example_wrap.c -I/usr/local/include/python2.0 unix > gcc -shared example.o example_wrap.o -o _example.so @@ -289,7 +289,7 @@ it. For example, you could also build a Perl5 module by just running SWIG on the C header file and specifying a module name as follows -+unix > swig -perl5 -module example example.h unix > gcc -c example.c example_wrap.c \ -I/usr/local/lib/perl5/sun4-solaris/5.003/CORE diff --git a/SWIG/Doc/Manual/Library.html b/SWIG/Doc/Manual/Library.html index ccf51e8f6..c6331f8d8 100644 --- a/SWIG/Doc/Manual/Library.html +++ b/SWIG/Doc/Manual/Library.html @@ -182,7 +182,7 @@ void add(int x, int y, int *result); Now, in Python: -+>>> import example >>> c = example.new_intp() # Create an "int" for storing result @@ -262,7 +262,7 @@ void add(int x, int y, int *result); Now, in Python (using proxy classes) -+>>> import example >>> c = example.intp() # Create an "int" for storing result @@ -626,7 +626,7 @@ Here is a simple example that illustrates the use of these macros: Now, in a script: -+>>> from example import * >>> a = malloc_int() @@ -698,7 +698,7 @@ Here is a short example: Python example: -+>>> a = intArray(10) >>> for i in range(0,10): @@ -949,7 +949,7 @@ void get_path(char *path); In the target language: -+>>> get_path() /home/beazley/packages/Foo/Bar @@ -992,7 +992,7 @@ void get_packet(char *packet); In the target language: -+>>> get_packet() '\xa9Y:\xf6\xd7\xe1\x87\xdbH;y\x97\x7f"\xd3\x99\x14V\xec\x06\xea\xa2\x88' @@ -1035,7 +1035,7 @@ void make_upper(char *ustr); In the target language: -+>>> make_upper("hello world") 'HELLO WORLD' @@ -1087,7 +1087,7 @@ void attach_header(char *hstr); In the target language: -+>>> make_upper("hello world") 'HELLO WORLD' @@ -1138,7 +1138,7 @@ void get_path(char *path, int maxpath); In the target language: -+>>> get_path(1024) '/home/beazley/Packages/Foo/Bar' @@ -1184,7 +1184,7 @@ void get_data(char *data, int *maxdata); In the target language: -+>>> get_data(1024) 'x627388912' @@ -1241,7 +1241,7 @@ void foo(char **s); In the target language: -+>>> foo() 'Hello world\n' @@ -1291,7 +1291,7 @@ void foo(char **s, int *slen); In the target language: -+>>> foo() '\xa9Y:\xf6\xd7\xe1\x87\xdbH;y\x97\x7f"\xd3\x99\x14V\xec\x06\xea\xa2\x88' @@ -1377,7 +1377,7 @@ void bar(const std::string &x); In the target language: -+x = foo(); # Returns a string object bar("Hello World"); # Pass string as std::string @@ -1522,7 +1522,7 @@ namespace std { Now, to illustrate the behavior in the scripting interpreter, consider this Python example: -+>>> from example import * >>> iv = IntVector(4) # Create an vector<int> diff --git a/SWIG/Doc/Manual/Preface.html b/SWIG/Doc/Manual/Preface.html index 5478ceb96..7c95ad5ef 100644 --- a/SWIG/Doc/Manual/Preface.html +++ b/SWIG/Doc/Manual/Preface.html @@ -83,7 +83,7 @@ of SWIG-1.3 scare you---it is much more stable (and capable) than SWIG-1.1p5. The official location of SWIG related material is -+ @@ -96,7 +96,7 @@ implementation tricks. You can also subscribe to the SWIG mailing list by visiting the page -+ @@ -110,7 +110,7 @@ CVS access to the latest version of SWIG is also available. More information about this can be obtained at: -+ diff --git a/SWIG/Doc/Manual/SWIG.html b/SWIG/Doc/Manual/SWIG.html index 953e6fc39..725d2fc51 100644 --- a/SWIG/Doc/Manual/SWIG.html +++ b/SWIG/Doc/Manual/SWIG.html @@ -96,7 +96,7 @@ To run SWIG, use the swig command with one or more of the following options and a filename like this: -+swig [ options ] filename -chicken Generate CHICKEN wrappers @@ -203,7 +203,7 @@ language (C, C++, etc.). Therefore, you have to use the file if you want something different than the default. For example: -+@@ -224,13 +224,13 @@ specific files is the same directory as the generated C/C++ file. This can can be modified using the -outdir option. For example: -$ swig -c++ -python -o example_wrap.cpp example.i+$ swig -c++ -python -outdir pyfiles -o cppfiles/example_wrap.cpp example.iIf the directories cppfiles and pyfiles exist, the following will be generated:
-+@@ -414,7 +414,7 @@ declarations are accessible as scripting language functions, variables, and constants respectively. For example, in Tcl: -cppfiles/example_wrap.cpp pyfiles/example.py+% sin 3 5.2335956 % strcmp Dave Mike @@ -430,7 +430,7 @@ constants respectively. For example, in Tcl: Or in Python: -+>>> example.sin(3) 5.2335956 >>> example.strcmp('Dave','Mike') @@ -871,7 +871,7 @@ representation that contains the actual value of the pointer and a type-tag. Thus, the SWIG representation of the above pointers (in Tcl), might look like this: -+_10081012_p_int _1008e124_ppp_double _f8ac_pp_char @@ -979,7 +979,7 @@ as a pointer, so it doesn't really matter what it is. If you wrapped this module into Python, you can use the functions just like you expect : -+# Copy a file def filecopy(source,target): f1 = fopen(source,"r") @@ -1115,7 +1115,7 @@ For example: In this case, you might run SWIG as follows: -+$ swig -I/usr/include -includeall example.i@@ -1334,7 +1334,7 @@ it as a function from the target scripting language (it does not work like a variable). For example, in Python you will have to write: -+>>> set_foo("Hello World")@@ -1374,7 +1374,7 @@ getting the value. However, the default behavior does not release the a possible memory leak). In fact, you may get a warning message such as this when wrapping such a variable: -+example.i:20. Typemap warning. Setting const char * variable may leak memory@@ -1710,7 +1710,7 @@ In this case, SWIG generates wrapper code where the default arguments are optional in the target language. For example, this function could be used in Tcl as follows : -+% plot -3.4 7.5 # Use default value % plot -3.4 7.5 10 # set color to 10 instead @@ -1751,7 +1751,7 @@ When you first wrap something like this into an extension module, you may find the function to be impossible to use. For instance, in Python: -+>>> def add(x,y): ... return x+y ... @@ -1785,7 +1785,7 @@ In this case, add, sub, and mul become function point constants in the target scripting language. This allows you to use them as follows: -+>>> binary_op(3,4,add) 7 @@ -1800,7 +1800,7 @@ Unfortunately, by declaring the callback functions as constants, they are no lon as functions. For example: -+>>> add(3,4) Traceback (most recent call last): @@ -1835,7 +1835,7 @@ by the function name). The callback mode remains in effect until it is explicit disabled using