From 3243cbaad43fcc53a8a2fa1c96863b008365a466 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 10 Jun 2011 19:33:40 +0000 Subject: [PATCH 001/147] Numerous autodoc fixes for Python git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12735 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 9 + Doc/Manual/Python.html | 112 +++++++++++-- Examples/test-suite/autodoc.i | 142 ++++++++++------ Examples/test-suite/python/autodoc_runme.py | 176 ++++++++++++++++++++ Lib/python/pydocs.swg | 30 ++-- Lib/python/pythonkw.swg | 3 +- Source/Modules/python.cxx | 160 +++++++++--------- 7 files changed, 471 insertions(+), 161 deletions(-) create mode 100644 Examples/test-suite/python/autodoc_runme.py diff --git a/CHANGES.current b/CHANGES.current index 3fab761b8..269c71bf7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,15 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-06-10: wsfulton + [Python] Few subtle bugfixes in autodoc documentation generation, + - Unnamed argument names fix for autodoc levels > 0. + - Display of template types fixed for autodoc levels > 1. + - Fix SF #3310528 - display of typedef structs for autodoc levels > 1. + - Add missing type for self for autodoc levels 1 and 3. + - autodoc levels 2 and 3 documented. + - Minor tweaks to autodoc style to conform with PEP8. + 2011-05-30: olly [PHP] Fix handling of directors when -prefix is used. diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 07f9e87d7..165fa94cb 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -98,6 +98,8 @@
  • %feature("docstring") @@ -5114,14 +5116,15 @@ introspection, then life is good once more. which when attached to a node in the parse tree will cause a docstring to be generated that includes the name of the function, parameter 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. +four levels for autodoc controlled by the value given to the +feature, %feature("autodoc", "level"). +The four values for level are covered in the following sub-sections.

    33.10.2.1 %feature("autodoc", "0")

    -When the "0" option is given then the types of the parameters will +When level "0" is used then the types of the parameters will not be included in the autodoc string. For example, given this function prototype:

    @@ -5150,14 +5153,15 @@ def function_name(*args, **kwargs):

    -When the "1" option is used then the parameter types will be +When level "1" is used then the parameter types will be used in the autodoc string. In addition, an attempt is made to simplify the type name such that it makes more sense to the Python -user. Pointer, reference and const info is removed, -%rename's are evaluated, etc. (This is not always -successful, but works most of the time. See the next section for what -to do when it doesn't.) Given the example above, then turning on the -parameter types with the "1" option will result in Python code like +user. Pointer, reference and const info is removed if the associated type +is has an associated Python type (%rename's are thus shown correctly). +This works most of the time, otherwise a C/C++ type will be used. +See the next section for the "docstring" feature for tweaking the docstrings to your liking. +Given the example above, then turning on the +parameter types with level "1" will result in Python code like this:

    @@ -5170,8 +5174,92 @@ def function_name(*args, **kwargs): +

    33.10.2.3 %feature("autodoc", "2")

    -

    33.10.2.3 %feature("autodoc", "docstring")

    + +

    +Level "2" results in the function prototype as per level "0". In addition, a line of +documentation is generated for each parameter. Using the previous example, the generated +code will be: +

    + +
    +
    +def function_name(*args, **kwargs):
    +    """
    +    function_name(x, y, foo=None, bar=None) -> bool
    +
    +    Parameters:
    +        x: int
    +        y: int
    +        foo: Foo *
    +        bar: Bar *
    +
    +    """
    +    ...
    +
    +
    + +

    +Note that the documentation for each parameter is sourced from the "doc" typemap which by default shows the +C/C++ type rather than the simplified Python type name described earlier for level "1". +Typemaps can of course change the output for any particular type, for example the int x parameter: +

    + +
    +
    +%feature("autodoc", "2");
    +%typemap("doc") int x "$1_name (C++ type: $1_type) -- Input $1_name dimension"
    +bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);
    +
    +
    + +

    +resulting in +

    + +
    +
    +def function_name(*args, **kwargs):
    +  """
    +    function_name(x, y, foo=None, bar=None) -> bool
    +
    +    Parameters:
    +        x (C++ type: int) -- Input x dimension
    +        y: int
    +        foo: Foo *
    +        bar: Bar *
    +
    +    """
    +
    +
    + +

    33.10.2.4 %feature("autodoc", "3")

    + + +

    +Level "3" results in the function prototype as per level "1" but also contains the same additional line of documentation for each parameter as per level "2". Using our earlier example again, the generated code will be: +

    + +
    +
    +def function_name(*args, **kwargs):
    +    """
    +    function_name(int x, int y, Foo foo=None, Bar bar=None) -> bool
    +
    +    Parameters:
    +        x: int
    +        y: int
    +        foo: Foo *
    +        bar: Bar *
    +
    +    """
    +    ...
    +
    +
    + + +

    33.10.2.5 %feature("autodoc", "docstring")

    @@ -5285,7 +5373,7 @@ SWIG is able to generate proxy method definitions like this:

    -  def foo(self, bar : "int" = 0) -> "void" : ...
    +  def foo(self, bar : "int"=0) -> "void" : ...
     

    @@ -5294,7 +5382,7 @@ still could be generated:

    -  def foo(self, bar = 0): ...
    +  def foo(self, bar=0): ...
     

    diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index c363e4384..23aa3f0b7 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -1,9 +1,9 @@ -%module(docstring="hello") python_autodoc +%module(docstring="hello") autodoc %feature("autodoc"); -// especial typemap and its docs -%typemap(in) (int c, int d) "$1 =0; $2 = 0;"; +// special typemap and its docs +%typemap(in) (int c, int d) "$1 = 0; $2 = 0;"; %typemap(doc,name="hello",type="Tuple") (int c, int d) "hello: int tuple[2]"; // testing for different documentation levels @@ -12,7 +12,22 @@ %feature("autodoc","2") A::func2; // extended %feature("autodoc","3") A::func3; // extended + types -%feature("autodoc","just a string") A::func; // names +%feature("autodoc","0") A::func0default; // names +%feature("autodoc","1") A::func1default; // names + types +%feature("autodoc","2") A::func2default; // extended +%feature("autodoc","3") A::func3default; // extended + types + +%feature("autodoc","0") A::func0static; // names +%feature("autodoc","1") A::func1static; // names + types +%feature("autodoc","2") A::func2static; // extended +%feature("autodoc","3") A::func3static; // extended + types + +%feature("autodoc","0") A::variable_a; // names +%feature("autodoc","1") A::variable_b; // names + types +%feature("autodoc","2") A::variable_c; // extended +%feature("autodoc","3") A::variable_d; // extended + types + +%feature("autodoc","just a string") A::funk; // names %inline { @@ -20,36 +35,29 @@ hi, hello }; - struct A - { - A(int a, short b, Hola h) - { - } + struct A { + A(int a, short b, Hola h) {} + int funk(int a) { return a; } - int func(int a) - { - return a; - } + int func0(short, int c, int d) { return c; } + int func1(short, int c, int d) { return c; } + int func2(short, int c, int d) { return c; } + int func3(short, int c, int d) { return c; } - int func0(int c, int d) - { - return c; - } - - int func1(int c, int d) - { - return c; - } + int func0default(A *e, short, int c, int d, double f = 2) { return 0; } + int func1default(A *e, short, int c, int d, double f = 2) { return 0; } + int func2default(A *e, short, int c, int d, double f = 2) { return 0; } + int func3default(A *e, short, int c, int d, double f = 2) { return 0; } - int func2(A* c, double d = 2) - { - return 2; - } + static int func0static(A *e, short, int c, int d, double f = 2) { return 0; } + static int func1static(A *e, short, int c, int d, double f = 2) { return 0; } + static int func2static(A *e, short, int c, int d, double f = 2) { return 0; } + static int func3static(A *e, short, int c, int d, double f = 2) { return 0; } - int func3(A* c, double d = 2) - { - return 2; - } + int variable_a; + int variable_b; + int variable_c; + int variable_d; }; } @@ -62,34 +70,66 @@ %typemap(doc) int a "a: special comment for parameter a"; %typemap(doc) int b "b: another special comment for parameter b"; -%callback(1) func_cb; +%feature("autodoc","0") C::C(int a, int b, Hola h); // names +%feature("autodoc","1") D::D(int a, int b, Hola h); // names + types +%feature("autodoc","2") E::E(int a, int b, Hola h); // extended +%feature("autodoc","3") F::F(int a, int b, Hola h); // extended + types %inline { - struct B - { - B(int a, int b, Hola h) - { - } - - - int func(int c, int d) - { - return c; - } - + struct B { + B(int a, int b, Hola h) {} + int funk(int c, int d) { return c; } }; - int func(int c, int d) { - return c; - } + struct C { + C(int a, int b, Hola h) {} + }; + struct D { + D(int a, int b, Hola h) {} + }; + struct E { + E(int a, int b, Hola h) {} + }; + struct F { + F(int a, int b, Hola h) {} + }; - int funcio(int *INOUT) { + int funk(A *e, short, int c, int d) { return c; } + int funkdefaults(A *e, short, int c, int d, double f = 2) { return c; } +} + +%include +%inline %{ + int func_input(int *INPUT) { return 1; } - - int func_cb(int c, int d) { - return c; + int func_output(int *OUTPUT) { + *OUTPUT = 2; + return 1; } - + int func_inout(int *INOUT) { + *INOUT += 1; + return 1; + } +%} + +%callback(1) func_cb; + +%inline { + int func_cb(int c, int d) { return c; } } + +// Bug 3310528 +%feature("autodoc","1") banana; // names + types +%inline %{ +typedef struct tagS { + int a; + char b; +} S; + +typedef int Integer; + +void banana(S *a, const struct tagS *b, int c, Integer d) {} +%} + diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py new file mode 100644 index 000000000..c65ebba24 --- /dev/null +++ b/Examples/test-suite/python/autodoc_runme.py @@ -0,0 +1,176 @@ +from autodoc import * + +def check(got, expected): + if expected != got: + raise RuntimeError("\n" + "Expected: [" + expected + "]\n" + "Got : [" + got + "]") + +check(A.__doc__, "Proxy of C++ A class") +check(A.funk.__doc__, "just a string") +check(A.func0.__doc__, "func0(self, arg2, hello) -> int") +check(A.func1.__doc__, "func1(A self, short arg2, Tuple hello) -> int") +check(A.func2.__doc__, "\n" +" func2(self, arg2, hello) -> int\n" +"\n" +" Parameters:\n" +" arg2: short\n" +" hello: int tuple[2]\n" +"\n" +" " +) +check(A.func3.__doc__, "\n" +" func3(A self, short arg2, Tuple hello) -> int\n" +"\n" +" Parameters:\n" +" arg2: short\n" +" hello: int tuple[2]\n" +"\n" +" " +) + +check(A.func0default.__doc__, "\n" +" func0default(self, e, arg3, hello, f=2) -> int\n" +" func0default(self, e, arg3, hello) -> int\n" +" " +) +check(A.func1default.__doc__, "\n" +" func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n" +" func1default(A self, A e, short arg3, Tuple hello) -> int\n" +" " +) +check(A.func2default.__doc__, "\n" +" func2default(self, e, arg3, hello, f=2) -> int\n" +"\n" +" Parameters:\n" +" e: A *\n" +" arg3: short\n" +" hello: int tuple[2]\n" +" f: double\n" +"\n" +" func2default(self, e, arg3, hello) -> int\n" +"\n" +" Parameters:\n" +" e: A *\n" +" arg3: short\n" +" hello: int tuple[2]\n" +"\n" +" " +) +check(A.func3default.__doc__, "\n" +" func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n" +"\n" +" Parameters:\n" +" e: A *\n" +" arg3: short\n" +" hello: int tuple[2]\n" +" f: double\n" +"\n" +" func3default(A self, A e, short arg3, Tuple hello) -> int\n" +"\n" +" Parameters:\n" +" e: A *\n" +" arg3: short\n" +" hello: int tuple[2]\n" +"\n" +" " +) + +check(A.func0static.__doc__, "\n" +" func0static(e, arg2, hello, f=2) -> int\n" +" func0static(e, arg2, hello) -> int\n" +" " +) +check(A.func1static.__doc__, "\n" +" func1static(A e, short arg2, Tuple hello, double f=2) -> int\n" +" func1static(A e, short arg2, Tuple hello) -> int\n" +" " +) +check(A.func2static.__doc__, "\n" +" func2static(e, arg2, hello, f=2) -> int\n" +"\n" +" Parameters:\n" +" e: A *\n" +" arg2: short\n" +" hello: int tuple[2]\n" +" f: double\n" +"\n" +" func2static(e, arg2, hello) -> int\n" +"\n" +" Parameters:\n" +" e: A *\n" +" arg2: short\n" +" hello: int tuple[2]\n" +"\n" +" " +) +check(A.func3static.__doc__, "\n" +" func3static(A e, short arg2, Tuple hello, double f=2) -> int\n" +"\n" +" Parameters:\n" +" e: A *\n" +" arg2: short\n" +" hello: int tuple[2]\n" +" f: double\n" +"\n" +" func3static(A e, short arg2, Tuple hello) -> int\n" +"\n" +" Parameters:\n" +" e: A *\n" +" arg2: short\n" +" hello: int tuple[2]\n" +"\n" +" " +) + +check(A.variable_a.__doc__, "A_variable_a_get(self) -> int") +check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int") +check(A.variable_c.__doc__, "\n" +"A_variable_c_get(self) -> int\n" +"\n" +"Parameters:\n" +" self: A *\n" +"\n" +) +check(A.variable_d.__doc__, "\n" +"A_variable_d_get(A self) -> int\n" +"\n" +"Parameters:\n" +" self: A *\n" +"\n" +) + +check(B.__doc__, "Proxy of C++ B class") +check(C.__init__.__doc__, "__init__(self, a, b, h) -> C") +check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D") +check(E.__init__.__doc__, "\n" +" __init__(self, a, b, h) -> E\n" +"\n" +" Parameters:\n" +" a: special comment for parameter a\n" +" b: another special comment for parameter b\n" +" h: enum Hola\n" +"\n" +" " +) +check(F.__init__.__doc__, "\n" +" __init__(F self, int a, int b, Hola h) -> F\n" +"\n" +" Parameters:\n" +" a: special comment for parameter a\n" +" b: another special comment for parameter b\n" +" h: enum Hola\n" +"\n" +" " +) + +check(B.funk.__doc__, "funk(B self, int c, int d) -> int") +check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int") +check(funkdefaults.__doc__, "\n" +" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n" +" funkdefaults(A e, short arg2, int c, int d) -> int\n" +" " +) + +check(func_input.__doc__, "func_input(int * INPUT) -> int") +check(func_output.__doc__, "func_output() -> int") +check(func_inout.__doc__, "func_inout(int * INOUT) -> int") +check(banana.__doc__, "banana(S a, S b, int c, Integer d)") diff --git a/Lib/python/pydocs.swg b/Lib/python/pydocs.swg index 862339da7..f4ab9db23 100644 --- a/Lib/python/pydocs.swg +++ b/Lib/python/pydocs.swg @@ -1,18 +1,22 @@ -// basic doc for primitive types.... +// Documentation for use with the autodoc feature. #ifdef SWIG_DOC_DOXYGEN_STYLE -%typemap(doc) SWIGTYPE "@param $1_name $1_type value"; -%typemap(doc) SWIGTYPE * "@param $1_name $1_type value"; -%typemap(doc) const SWIGTYPE & "@param $1_name $1_type value"; -%typemap(doc) enum SWIGTYPE "@param $1_name enum $1_type value"; -#else -%typemap(doc) SWIGTYPE "$1_name: $1_type value"; -%typemap(doc) SWIGTYPE * "$1_name: $1_type value"; -%typemap(doc) const SWIGTYPE & "$1_name: $1_type value"; -%typemap(doc) enum SWIGTYPE "$1_name: enum $1_type value"; +%typemap(doc) SWIGTYPE "@param $1_name $1_type"; +%typemap(doc) SWIGTYPE * "@param $1_name $1_type"; +%typemap(doc) const SWIGTYPE & "@param $1_name $1_type"; +%typemap(doc) enum SWIGTYPE "@param $1_name enum $1_type"; -%typemap(doc) SWIGTYPE *INOUT "$1_name: $1_type input/ouput value"; -%typemap(doc) SWIGTYPE *INPUT "$1_name: $1_type input value"; -%typemap(doc) SWIGTYPE *OUTPUT "$1_name: $1_type output value"; +%typemap(doc) SWIGTYPE *INOUT, SWIGTYPE &INOUT "@param $1_name $1_type (input/output)"; +%typemap(doc) SWIGTYPE *INPUT, SWIGTYPE &INPUT "@param $1_name $1_type (input)"; +%typemap(doc) SWIGTYPE *OUTPUT, SWIGTYPE &OUTPUT "@param $1_name $1_type (output)"; +#else +%typemap(doc) SWIGTYPE "$1_name: $1_type"; +%typemap(doc) SWIGTYPE * "$1_name: $1_type"; +%typemap(doc) const SWIGTYPE & "$1_name: $1_type"; +%typemap(doc) enum SWIGTYPE "$1_name: enum $1_type"; + +%typemap(doc) SWIGTYPE *INOUT, SWIGTYPE &INOUT "$1_name: $1_type (input/output)"; +%typemap(doc) SWIGTYPE *INPUT, SWIGTYPE &INPUT "$1_name: $1_type (input)"; +%typemap(doc) SWIGTYPE *OUTPUT, SWIGTYPE &OUTPUT "$1_name: $1_type (output)"; #endif diff --git a/Lib/python/pythonkw.swg b/Lib/python/pythonkw.swg index 2dd4f2f49..8ad0ef11b 100644 --- a/Lib/python/pythonkw.swg +++ b/Lib/python/pythonkw.swg @@ -3,7 +3,7 @@ */ #define PYTHONKW(x) %keywordwarn("'" `x` "' is a python keyword, renaming to '_" `x` "'", rename="_%s") `x` -#define PYTHONBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in python") "::"`x` +#define PYTHONBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in python") `x` /* @@ -105,7 +105,6 @@ PYTHONBN(setattr); PYTHONBN(slice); PYTHONBN(sorted); PYTHONBN(staticmethod); -PYTHONBN(staticmethod); PYTHONBN(str); PYTHONBN(sum); PYTHONBN(super); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 00f6ebfff..737ecc555 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1122,9 +1122,9 @@ public: initial++; c++; } - if (*c && !isspace(*c)) + if (*c && !isspace(*c)) { break; - else { + } else { initial = 0; } } @@ -1267,35 +1267,29 @@ public: } /* ----------------------------------------------------------------------------- - * makeParameterName() - * Note: the generated name should consist with that in kwnames[] + * addMissingParameterNames() + * For functions that have not had nameless parameters set in the Language class. * * Inputs: - * n - Node - * p - parameter node - * arg_num - parameter argument number - * Return: - * arg - a unique parameter name + * plist - entire parameter list + * arg_offset - argument number for first parameter + * Side effects: + * The "lname" attribute in each parameter in plist will be contain a parameter name * ----------------------------------------------------------------------------- */ - String *makeParameterName(ParmList *plist, Parm *p, int arg_num) { - String *arg = 0; - String *pn = Swig_name_make(p, 0, Getattr(p, "name"), 0, 0); - // Use C parameter name unless it is a duplicate or an empty parameter name - int count = 0; - if (SwigType_isvarargs(Getattr(p, "type"))) { - return NewString("*args"); + void addMissingParameterNames(ParmList *plist, int arg_offset) { + Parm *p = plist; + int i = arg_offset; + while (p) { + if (!Getattr(p, "lname")) { + String *pname = Swig_cparm_name(p, i); + Delete(pname); + } + i++; + p = nextSibling(p); } - while (plist) { - if ((Cmp(pn, Getattr(plist, "name")) == 0)) - count++; - plist = nextSibling(plist); - } - arg = (!pn || !Len(pn) || (count > 1)) ? NewStringf("arg%d", arg_num) : Copy(pn); - return arg; } - /* ------------------------------------------------------------ * make_autodocParmList() * Generate the documentation for the function parameters @@ -1305,25 +1299,21 @@ public: String *make_autodocParmList(Node *n, bool showTypes, bool calling = false, bool func_annotation = false) { - String *doc = NewString(""); - String *pdocs = Copy(Getattr(n, "feature:pdocs")); + String *pdocs = 0; ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p; Parm *pnext; - Node *lookup; int lines = 0; - int arg_num = 0; - const int maxwidth = 50; + int start_arg_num = is_wrapping_class() ? 1 : 0; + const int maxwidth = 80; if (calling) func_annotation = false; - if (pdocs) - Append(pdocs, "\n"); - + addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms Swig_typemap_attach_parms("in", plist, 0); Swig_typemap_attach_parms("doc", plist, 0); @@ -1354,18 +1344,15 @@ public: value = Getattr(p, "tmap:doc:value"); } + // Note: the generated name should be consistent with that in kwnames[] name = name ? name : Getattr(p, "name"); + name = name ? name : Getattr(p, "lname"); + type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); - name = makeParameterName(plist, p, arg_num); - // Reset it for convinient in further use. (mainly for makeParameterName()) - // Since the plist is created by CopyParmList, - // we can hope that the set would have no side effect - Setattr(p, "name", name); - - arg_num++; - + if (SwigType_isvarargs(type)) + break; if (Len(doc)) { // add a comma to the previous one if any @@ -1378,39 +1365,35 @@ public: } } - type = SwigType_base(type); - lookup = Swig_symbol_clookup(type, 0); - if (lookup) - type = Getattr(lookup, "sym:name"); - // Do the param type too? + Node *nn = classLookup(Getattr(p, "type")); + String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); if (showTypes) - Printf(doc, "%s ", type); - + Printf(doc, "%s ", type_str); Append(doc, name); if (pdoc) { if (!pdocs) - pdocs = NewString("Parameters:\n"); - Printf(pdocs, " %s\n", pdoc); + pdocs = NewString("\nParameters:\n"); + Printf(pdocs, " %s\n", pdoc); } - // Write the function annoation + // Write the function annotation if (func_annotation) - Printf(doc, " : '%s'", type); + Printf(doc, " : '%s'", type_str); // Write default value if (value && !calling) { String *pv = pyvalue(value, Getattr(p, "type")); - if (pv) + if (pv) { value = pv; - else { - lookup = Swig_symbol_clookup(value, 0); - if (lookup) { + } else { + Node *lookup = Swig_symbol_clookup(value, 0); + if (lookup) value = Getattr(lookup, "sym:name"); - } } - Printf(doc, " = %s", value); + Printf(doc, "=%s", value); } + Delete(type_str); } if (pdocs) Setattr(n, "feature:pdocs", pdocs); @@ -1430,7 +1413,7 @@ public: String *make_autodoc(Node *n, autodoc_t ad_type) { int extended = 0; - // If the function is overloaded then this funciton is called + // If the function is overloaded then this function is called // for the last one. Rewind to the first so the docstrings are // in order. while (Getattr(n, "sym:previousSibling")) @@ -1468,15 +1451,14 @@ public: if (!skipAuto) { String *symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); + String *type_str = NULL; if (type) { - if (Strcmp(type, "void") == 0) - type = NULL; - else { - type = SwigType_base(type); - Node *lookup = Swig_symbol_clookup(type, 0); - if (lookup) - type = Getattr(lookup, "sym:name"); + if (Strcmp(type, "void") == 0) { + type_str = NULL; + } else { + Node *nn = classLookup(type); + type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); } } @@ -1497,40 +1479,50 @@ public: case AUTODOC_CTOR: if (Strcmp(class_name, symname) == 0) { String *paramList = make_autodocParmList(n, showTypes); + Printf(doc, "__init__("); + if (showTypes) + Printf(doc, "%s ", getClassName()); if (Len(paramList)) - Printf(doc, "__init__(self, %s) -> %s", paramList, class_name); + Printf(doc, "self, %s) -> %s", paramList, class_name); else - Printf(doc, "__init__(self) -> %s", class_name); + Printf(doc, "self) -> %s", class_name); } else Printf(doc, "%s(%s) -> %s", symname, make_autodocParmList(n, showTypes), class_name); break; case AUTODOC_DTOR: - Append(doc, "__del__(self)"); + if (showTypes) + Printf(doc, "__del__(%s self)", getClassName()); + else + Printf(doc, "__del__(self)"); break; case AUTODOC_STATICFUNC: Printf(doc, "%s(%s)", symname, make_autodocParmList(n, showTypes)); - if (type) - Printf(doc, " -> %s", type); + if (type_str) + Printf(doc, " -> %s", type_str); break; case AUTODOC_FUNC: Printf(doc, "%s(%s)", symname, make_autodocParmList(n, showTypes)); - if (type) - Printf(doc, " -> %s", type); + if (type_str) + Printf(doc, " -> %s", type_str); break; case AUTODOC_METHOD: String *paramList = make_autodocParmList(n, showTypes); + Printf(doc, "%s(", symname); + if (showTypes) + Printf(doc, "%s ", class_name); if (Len(paramList)) - Printf(doc, "%s(self, %s)", symname, paramList); + Printf(doc, "self, %s)", paramList); else - Printf(doc, "%s(self)", symname); - if (type) - Printf(doc, " -> %s", type); + Printf(doc, "self)"); + if (type_str) + Printf(doc, " -> %s", type_str); break; } + Delete(type_str); } if (extended) { String *pdocs = Getattr(n, "feature:pdocs"); @@ -1935,7 +1927,7 @@ public: /* Create a shadow for this function (if enabled and not in a member function) */ if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) { - emitFunctionShadowHelper(n, f_shadow_stubs, symname, 0); + emitFunctionShadowHelper(n, in_class ? f_shadow_stubs : f_shadow, symname, 0); } DelWrapper(f); Delete(dispatch); @@ -3914,7 +3906,7 @@ public: // Can't use checkAttribute(n, "access", "public") because // "access" attr isn't set on %extend methods if (!checkAttribute(n, "access", "private") && strncmp(Char(symname), "operator ", 9) && !Getattr(class_members, symname)) { - String *fullname = Swig_name_member(NULL, class_name, symname); + String *fullname = Swig_name_member(NSPACE_TODO, class_name, symname); String *wname = Swig_name_wrapper(fullname); Setattr(class_members, symname, n); int argcount = Getattr(n, "python:argcount") ? atoi(Char(Getattr(n, "python:argcount"))) : 2; @@ -3940,12 +3932,13 @@ public: if (!Getattr(n, "sym:nextSibling")) { if (shadow && !builtin) { int fproxy = fastproxy; + String *fullname = Swig_name_member(NSPACE_TODO, class_name, symname); if (Strcmp(symname, "__repr__") == 0) { have_repr = 1; } if (Getattr(n, "feature:shadow")) { String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4); - String *pyaction = NewStringf("%s.%s", module, Swig_name_member(NSPACE_TODO, class_name, symname)); + String *pyaction = NewStringf("%s.%s", module, fullname); Replaceall(pycode, "$action", pyaction); Delete(pyaction); Printv(f_shadow, pycode, "\n", NIL); @@ -3958,7 +3951,7 @@ public: if (!have_addtofunc(n)) { if (!fastproxy || olddefs) { Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); - Printv(f_shadow, " return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL); + Printv(f_shadow, " return ", funcCall(fullname, callParms), "\n", NIL); } } else { Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); @@ -3971,11 +3964,11 @@ public: } if (have_pythonappend(n)) { fproxy = 0; - Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL); + Printv(f_shadow, tab8, "val = ", funcCall(fullname, callParms), "\n", NIL); Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { - Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL); + Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n\n", NIL); } } } @@ -3988,6 +3981,7 @@ public: } Append(shadow_list, symname); } + Delete(fullname); } } return SWIG_OK; @@ -4012,7 +4006,7 @@ public: if (builtin && in_class) { if ((GetFlagAttr(n, "feature:extend") || checkAttribute(n, "access", "public")) && !Getattr(class_members, symname)) { - String *fullname = Swig_name_member(NULL, class_name, symname); + String *fullname = Swig_name_member(NSPACE_TODO, class_name, symname); String *wname = Swig_name_wrapper(fullname); Setattr(class_members, symname, n); int funpack = modernargs && fastunpack && !Getattr(n, "sym:overloaded"); From a4f8ed4fc9a5f1e8ccacf39919b7ac48a89f407c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 10 Jun 2011 20:26:07 +0000 Subject: [PATCH 002/147] Fix last checkin for renamed parameters git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12736 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/python.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 737ecc555..aab40ca94 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1347,6 +1347,7 @@ public: // Note: the generated name should be consistent with that in kwnames[] name = name ? name : Getattr(p, "name"); name = name ? name : Getattr(p, "lname"); + name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); @@ -1394,6 +1395,7 @@ public: Printf(doc, "=%s", value); } Delete(type_str); + Delete(name); } if (pdocs) Setattr(n, "feature:pdocs", pdocs); @@ -2198,7 +2200,7 @@ public: String *tmp = 0; String *name = pn; if (!Getattr(p, "hidden")) { - name = tmp = Swig_name_make(p, 0, pn, 0, 0); + name = tmp = Swig_name_make(p, 0, pn, 0, 0); // rename parameter if a keyword } Printf(kwargs, "(char *) \"%s\",", name); if (tmp) From 665b70e887e4058ce822670275aa3a0cb085b8e2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 10 Jun 2011 22:48:32 +0000 Subject: [PATCH 003/147] Change test to fail rather than print a message git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12737 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/typename_runme.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/python/typename_runme.py b/Examples/test-suite/python/typename_runme.py index 59a0f1f76..10c7bff1b 100644 --- a/Examples/test-suite/python/typename_runme.py +++ b/Examples/test-suite/python/typename_runme.py @@ -5,8 +5,8 @@ b = typename.Bar() x = typename.twoFoo(f) if not isinstance(x,types.FloatType): - print "Wrong return type!" + raise RuntimeError,"Wrong return type (FloatType) !" y = typename.twoBar(b) if not isinstance(y,types.IntType): - print "Wrong return type!" + raise RuntimeError,"Wrong return type (IntType)!" From 3cb76bb45ec9cc6e5be0aae7dc5b7d61ca6a1220 Mon Sep 17 00:00:00 2001 From: Stefan Zager Date: Sat, 11 Jun 2011 05:49:49 +0000 Subject: [PATCH 004/147] Slight tweak to output typemap for int git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12738 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pyprimtypes.swg | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg index a11e87409..aa5ddaf62 100644 --- a/Lib/python/pyprimtypes.swg +++ b/Lib/python/pyprimtypes.swg @@ -25,6 +25,16 @@ SWIG_AsVal_dec(bool)(PyObject *obj, bool *val) } } +/* int */ + +%fragment(SWIG_From_frag(int),"header") { +SWIGINTERNINLINE PyObject* + SWIG_From_dec(int)(int value) +{ + return PyInt_FromLong((long) value); +} +} + /* long */ %fragment(SWIG_From_frag(long),"header") { From 58e74e8675499dba4791429b379ca1aef207467a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 13 Jun 2011 17:38:08 +0000 Subject: [PATCH 005/147] Rename python_kwargs testcase to kwargs_feature. Add kwargs_feature to Ruby and fix Ruby warnings when using kwargs feature. Add %kwargs macro for Ruby git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12739 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/{python_kwargs.i => kwargs_feature.i} | 2 +- Examples/test-suite/python/Makefile.in | 2 +- ...{python_kwargs_runme.py => kwargs_feature_runme.py} | 2 +- Examples/test-suite/ruby/Makefile.in | 1 + Lib/ruby/rubyuserdir.swg | 10 ++++++++++ Source/Modules/ruby.cxx | 2 +- 6 files changed, 15 insertions(+), 4 deletions(-) rename Examples/test-suite/{python_kwargs.i => kwargs_feature.i} (98%) rename Examples/test-suite/python/{python_kwargs_runme.py => kwargs_feature_runme.py} (96%) diff --git a/Examples/test-suite/python_kwargs.i b/Examples/test-suite/kwargs_feature.i similarity index 98% rename from Examples/test-suite/python_kwargs.i rename to Examples/test-suite/kwargs_feature.i index 28089bbf1..87153109a 100644 --- a/Examples/test-suite/python_kwargs.i +++ b/Examples/test-suite/kwargs_feature.i @@ -1,4 +1,4 @@ -%module python_kwargs +%module kwargs_feature %nocopyctor; %kwargs; diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 7eb700124..185ca2298 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -41,6 +41,7 @@ CPP_TEST_CASES += \ inout \ inplaceadd \ input \ + kwargs_feature \ li_cstring \ li_cwstring \ li_factory \ @@ -58,7 +59,6 @@ CPP_TEST_CASES += \ primitive_types \ python_abstractbase \ python_append \ - python_kwargs \ python_nondynamic \ python_overload_simple_cast \ python_richcompare \ diff --git a/Examples/test-suite/python/python_kwargs_runme.py b/Examples/test-suite/python/kwargs_feature_runme.py similarity index 96% rename from Examples/test-suite/python/python_kwargs_runme.py rename to Examples/test-suite/python/kwargs_feature_runme.py index fb6e191dd..5539e211d 100644 --- a/Examples/test-suite/python/python_kwargs_runme.py +++ b/Examples/test-suite/python/kwargs_feature_runme.py @@ -1,4 +1,4 @@ -from python_kwargs import * +from kwargs_feature import * class MyFoo(Foo): def __init__(self, a , b = 0): diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 27996616e..e157e72ca 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -10,6 +10,7 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES = \ + kwargs_feature \ li_cdata \ li_cstring \ li_factory \ diff --git a/Lib/ruby/rubyuserdir.swg b/Lib/ruby/rubyuserdir.swg index 2f67c9ec6..638433c2d 100644 --- a/Lib/ruby/rubyuserdir.swg +++ b/Lib/ruby/rubyuserdir.swg @@ -8,3 +8,13 @@ #define %nooutput %feature("outputs","0") #define %initstack %feature("initstack", "1") #define %ignorestack %feature("initstack", "0") + +/* ------------------------------------------------------------------------- */ +/* + Enable keywords paramaters +*/ + +#define %kwargs %feature("kwargs") +#define %nokwargs %feature("kwargs", "0") +#define %clearkwargs %feature("kwargs", "") + diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index dfb199b6e..d2ce97592 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1477,7 +1477,7 @@ public: /* Finish argument marshalling */ Printf(kwargs, " NULL }"); if (allow_kwargs) { - Printv(f->locals, tab4, "char *kwnames[] = ", kwargs, ";\n", NIL); + Printv(f->locals, tab4, "const char *kwnames[] = ", kwargs, ";\n", NIL); } /* Trailing varargs */ From 72ffdb930dcbbe0ae2a1cf7164a7ca4b632b1fee Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 13 Jun 2011 20:46:20 +0000 Subject: [PATCH 006/147] Repeat autodoc fixes for Octave and Ruby as done previously for Python git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12740 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 + Source/Modules/octave.cxx | 113 +++++++++++----- Source/Modules/python.cxx | 12 +- Source/Modules/ruby.cxx | 263 +++++++++++++++++++++++--------------- 4 files changed, 252 insertions(+), 139 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 269c71bf7..b47de9b69 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-06-13: wsfulton + [Ruby, Octave] SF #3310528 Autodoc fixes similar to those described below for Python. + 2011-06-10: wsfulton [Python] Few subtle bugfixes in autodoc documentation generation, - Unnamed argument names fix for autodoc levels > 0. diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 11fbc46fd..c22d90195 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -383,20 +383,54 @@ public: return conv ? "SWIG_POINTER_IMPLICIT_CONV" : "0"; } + /* ----------------------------------------------------------------------------- + * addMissingParameterNames() + * For functions that have not had nameless parameters set in the Language class. + * + * Inputs: + * plist - entire parameter list + * arg_offset - argument number for first parameter + * Side effects: + * The "lname" attribute in each parameter in plist will be contain a parameter name + * ----------------------------------------------------------------------------- */ + + void addMissingParameterNames(ParmList *plist, int arg_offset) { + Parm *p = plist; + int i = arg_offset; + while (p) { + if (!Getattr(p, "lname")) { + String *pname = Swig_cparm_name(p, i); + Delete(pname); + } + i++; + p = nextSibling(p); + } + } + void make_autodocParmList(Node *n, String *decl_str, String *args_str) { - String *pdocs = Copy(Getattr(n, "feature:pdocs")); + String *pdocs = 0; ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p; Parm *pnext; - Node *lookup; + int start_arg_num = is_wrapping_class() ? 1 : 0; - if (pdocs) - Append(pdocs, "\n"); + addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms Swig_typemap_attach_parms("in", plist, 0); Swig_typemap_attach_parms("doc", plist, 0); for (p = plist; p; p = pnext) { + + String *tm = Getattr(p, "tmap:in"); + if (tm) { + pnext = Getattr(p, "tmap:in:next"); + if (checkAttribute(p, "tmap:in:numinputs", "0")) { + continue; + } + } else { + pnext = nextSibling(p); + } + String *name = 0; String *type = 0; String *value = 0; @@ -407,60 +441,81 @@ public: value = Getattr(p, "tmap:doc:value"); } + // Note: the generated name should be consistent with that in kwnames[] name = name ? name : Getattr(p, "name"); + name = name ? name : Getattr(p, "lname"); + name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword + type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); + if (SwigType_isvarargs(type)) + break; + String *tex_name = NewString(""); if (name) Printf(tex_name, "@var{%s}", name); else Printf(tex_name, "@var{?}"); - String *tm = Getattr(p, "tmap:in"); - if (tm) { - pnext = Getattr(p, "tmap:in:next"); - } else { - pnext = nextSibling(p); - } - if (Len(decl_str)) Append(decl_str, ", "); Append(decl_str, tex_name); if (value) { - if (Strcmp(value, "NULL") == 0) - value = NewString("nil"); - else if (Strcmp(value, "true") == 0 || Strcmp(value, "TRUE") == 0) - value = NewString("true"); - else if (Strcmp(value, "false") == 0 || Strcmp(value, "FALSE") == 0) - value = NewString("false"); - else { - lookup = Swig_symbol_clookup(value, 0); + String *new_value = convertValue(value, Getattr(p, "type")); + if (new_value) { + value = new_value; + } else { + Node *lookup = Swig_symbol_clookup(value, 0); if (lookup) value = Getattr(lookup, "sym:name"); } Printf(decl_str, " = %s", value); } - if (type) { - String *type_str = NewString(""); - type = SwigType_base(type); - lookup = Swig_symbol_clookup(type, 0); - if (lookup) - type = Getattr(lookup, "sym:name"); - Printf(type_str, "%s is of type %s. ", tex_name, type); - Append(args_str, type_str); - Delete(type_str); - } + Node *nn = classLookup(Getattr(p, "type")); + String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); + Printf(args_str, "%s is of type %s. ", tex_name, type_str); + Delete(type_str); Delete(tex_name); + Delete(name); } if (pdocs) Setattr(n, "feature:pdocs", pdocs); Delete(plist); } + /* ------------------------------------------------------------ + * convertValue() + * Check if string v can be an Octave value literal, + * (eg. number or string), or translate it to an Octave literal. + * ------------------------------------------------------------ */ + String *convertValue(String *v, SwigType *t) { + if (v && Len(v) > 0) { + char fc = (Char(v))[0]; + if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) { + /* number or string (or maybe NULL pointer) */ + if (SwigType_ispointer(t) && Strcmp(v, "0") == 0) + return NewString("None"); + else + return v; + } + if (Strcmp(v, "NULL") == 0) + return SwigType_ispointer(t) ? NewString("nil") : NewString("0"); + else if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) + return NewString("true"); + else if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) + return NewString("false"); + if (Strcmp(v, "true") == 0 || Strcmp(v, "FALSE") == 0) + return NewString("true"); + if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) + return NewString("false"); + } + return 0; + } + virtual int functionWrapper(Node *n) { Wrapper *f = NewWrapper(); Parm *p; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index aab40ca94..e1dad5259 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1384,9 +1384,9 @@ public: // Write default value if (value && !calling) { - String *pv = pyvalue(value, Getattr(p, "type")); - if (pv) { - value = pv; + String *new_value = convertValue(value, Getattr(p, "type")); + if (new_value) { + value = new_value; } else { Node *lookup = Swig_symbol_clookup(value, 0); if (lookup) @@ -1542,11 +1542,11 @@ public: } /* ------------------------------------------------------------ - * pyvalue() + * convertValue() * Check if string v can be a Python value literal, * (eg. number or string), or translate it to a Python literal. * ------------------------------------------------------------ */ - String *pyvalue(String *v, SwigType *t) { + String *convertValue(String *v, SwigType *t) { if (v && Len(v) > 0) { char fc = (Char(v))[0]; if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) { @@ -1589,7 +1589,7 @@ public: } String *type = Getattr(p, "type"); String *value = Getattr(p, "value"); - if (!pyvalue(value, type)) + if (!convertValue(value, type)) return false; } return true; diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index d2ce97592..1ad1241ee 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -296,6 +296,30 @@ private: return doc; } + /* ----------------------------------------------------------------------------- + * addMissingParameterNames() + * For functions that have not had nameless parameters set in the Language class. + * + * Inputs: + * plist - entire parameter list + * arg_offset - argument number for first parameter + * Side effects: + * The "lname" attribute in each parameter in plist will be contain a parameter name + * ----------------------------------------------------------------------------- */ + + void addMissingParameterNames(ParmList *plist, int arg_offset) { + Parm *p = plist; + int i = arg_offset; + while (p) { + if (!Getattr(p, "lname")) { + String *pname = Swig_cparm_name(p, i); + Delete(pname); + } + i++; + p = nextSibling(p); + } + } + /* ------------------------------------------------------------ * make_autodocParmList() * Generate the documentation for the function parameters @@ -303,22 +327,36 @@ private: String *make_autodocParmList(Node *n, bool showTypes) { String *doc = NewString(""); - String *pdocs = Copy(Getattr(n, "feature:pdocs")); + String *pdocs = 0; ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p; Parm *pnext; - Node *lookup; int lines = 0; - const int maxwidth = 50; - - if (pdocs) - Append(pdocs, ".\n"); + int start_arg_num = is_wrapping_class() ? 1 : 0; + const int maxwidth = 80; + addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms Swig_typemap_attach_parms("in", plist, 0); Swig_typemap_attach_parms("doc", plist, 0); + if (Strcmp(ParmList_protostr(plist), "void") == 0) { + //No parameters actually + return doc; + } + for (p = plist; p; p = pnext) { + + String *tm = Getattr(p, "tmap:in"); + if (tm) { + pnext = Getattr(p, "tmap:in:next"); + if (checkAttribute(p, "tmap:in:numinputs", "0")) { + continue; + } + } else { + pnext = nextSibling(p); + } + String *name = 0; String *type = 0; String *value = 0; @@ -329,21 +367,16 @@ private: value = Getattr(p, "tmap:doc:value"); } + // Note: the generated name should be consistent with that in kwnames[] name = name ? name : Getattr(p, "name"); + name = name ? name : Getattr(p, "lname"); + name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword + type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); - - String *tm = Getattr(p, "tmap:in"); - if (tm) { - pnext = Getattr(p, "tmap:in:next"); - } else { - pnext = nextSibling(p); - } - - // Skip ignored input attributes - if (checkAttribute(p, "tmap:in:numinputs", "0")) - continue; + if (SwigType_isvarargs(type)) + break; // Skip the 'self' parameter which in ruby is implicit if ( Cmp(name, "self") == 0 ) @@ -362,40 +395,33 @@ private: lines += 1; } } - // Do the param type too? - if (showTypes) { - type = SwigType_base(type); - lookup = Swig_symbol_clookup(type, 0); - if (lookup) - type = Getattr(lookup, "sym:name"); - Printf(doc, "%s ", type); - } - if (name) { - Append(doc, name); - if (pdoc) { - if (!pdocs) - pdocs = NewString("Parameters:\n"); - Printf(pdocs, " %s.\n", pdoc); - } - } else { - Append(doc, "?"); + // Do the param type too? + Node *nn = classLookup(Getattr(p, "type")); + String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); + if (showTypes) + Printf(doc, "%s ", type_str); + + Append(doc, name); + if (pdoc) { + if (!pdocs) + pdocs = NewString("Parameters:\n"); + Printf(pdocs, " %s.\n", pdoc); } if (value) { - if (Strcmp(value, "NULL") == 0) - value = NewString("nil"); - else if (Strcmp(value, "true") == 0 || Strcmp(value, "TRUE") == 0) - value = NewString("true"); - else if (Strcmp(value, "false") == 0 || Strcmp(value, "FALSE") == 0) - value = NewString("false"); - else { - lookup = Swig_symbol_clookup(value, 0); + String *new_value = convertValue(value, Getattr(p, "type")); + if (new_value) { + value = new_value; + } else { + Node *lookup = Swig_symbol_clookup(value, 0); if (lookup) value = Getattr(lookup, "sym:name"); } Printf(doc, "=%s", value); } + Delete(type_str); + Delete(name); } if (pdocs) Setattr(n, "feature:pdocs", pdocs); @@ -425,55 +451,53 @@ private: String* super_names = NewString(""); String* class_name = Getattr(pn, "sym:name") ; - if ( !class_name ) class_name = NewString(""); - else - { - class_name = Copy(class_name); - List *baselist = Getattr(pn, "bases"); - if (baselist && Len(baselist)) { - Iterator base = First(baselist); - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - - int count = 0; - for ( ;base.item; ++count) { - if ( count ) Append(super_names, ", "); - String *basename = Getattr(base.item, "sym:name"); + if ( !class_name ) { + class_name = NewString(""); + } else { + class_name = Copy(class_name); + List *baselist = Getattr(pn, "bases"); + if (baselist && Len(baselist)) { + Iterator base = First(baselist); + while (base.item && GetFlag(base.item, "feature:ignore")) { + base = Next(base); + } - String* basenamestr = NewString(basename); - Node* parent = parentNode(base.item); - while (parent) - { - String *parent_name = Copy( Getattr(parent, "sym:name") ); - if ( !parent_name ) { - Node* mod = Getattr(parent, "module"); - if ( mod ) - parent_name = Copy( Getattr(mod, "name") ); - if ( parent_name ) - { - (Char(parent_name))[0] = (char)toupper((Char(parent_name))[0]); - } - } - if ( parent_name ) - { - Insert(basenamestr, 0, "::"); - Insert(basenamestr, 0, parent_name); - Delete(parent_name); - } - parent = parentNode(parent); - } + int count = 0; + for ( ;base.item; ++count) { + if ( count ) Append(super_names, ", "); + String *basename = Getattr(base.item, "sym:name"); - Append(super_names, basenamestr ); - Delete(basenamestr); - base = Next(base); + String* basenamestr = NewString(basename); + Node* parent = parentNode(base.item); + while (parent) + { + String *parent_name = Copy( Getattr(parent, "sym:name") ); + if ( !parent_name ) { + Node* mod = Getattr(parent, "module"); + if ( mod ) + parent_name = Copy( Getattr(mod, "name") ); + if ( parent_name ) + (Char(parent_name))[0] = (char)toupper((Char(parent_name))[0]); + } + if ( parent_name ) { + Insert(basenamestr, 0, "::"); + Insert(basenamestr, 0, parent_name); + Delete(parent_name); + } + parent = parentNode(parent); } + + Append(super_names, basenamestr ); + Delete(basenamestr); + base = Next(base); } } + } String* full_name; if ( module ) { full_name = NewString(module); - if (class_name && Len(class_name) > 0) Append(full_name, "::"); + if (class_name && Len(class_name) > 0) + Append(full_name, "::"); } else full_name = NewString(""); @@ -508,6 +532,7 @@ private: bool skipAuto = false; Node* on = n; for ( ; n; ++counter ) { + String *type_str = NULL; skipAuto = false; bool showTypes = false; String *autodoc = Getattr(n, "feature:autodoc"); @@ -537,17 +562,15 @@ private: SwigType *type = Getattr(n, "type"); if (type) { - if (Strcmp(type, "void") == 0) - type = NULL; - else { + if (Strcmp(type, "void") == 0) { + type_str = NULL; + } else { SwigType *qt = SwigType_typedef_resolve_all(type); - if (SwigType_isenum(qt)) - type = NewString("int"); - else { - type = SwigType_base(type); - Node *lookup = Swig_symbol_clookup(type, 0); - if (lookup) - type = Getattr(lookup, "sym:name"); + if (SwigType_isenum(qt)) { + type_str = NewString("int"); + } else { + Node *nn = classLookup(type); + type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); } } } @@ -582,7 +605,6 @@ private: } } - if (skipAuto) { if ( counter == 0 ) Printf(doc, " call-seq:\n"); switch( ad_type ) @@ -597,21 +619,21 @@ private: Printf(doc, " %s(%s)", symname, paramList); else Printf(doc, " %s", symname); - if (type) - Printf(doc, " -> %s", type); + if (type_str) + Printf(doc, " -> %s", type_str); break; } case AUTODOC_SETTER: { Printf(doc, " %s=(x)", symname); - if (type) Printf(doc, " -> %s", type); + if (type_str) + Printf(doc, " -> %s", type_str); break; } default: break; } - } - else { + } else { switch (ad_type) { case AUTODOC_CLASS: { @@ -627,7 +649,8 @@ private: } break; case AUTODOC_CTOR: - if (counter == 0) Printf(doc, " call-seq:\n"); + if (counter == 0) + Printf(doc, " call-seq:\n"); if (Strcmp(class_name, symname) == 0) { String *paramList = make_autodocParmList(n, showTypes); if (Len(paramList)) @@ -647,21 +670,23 @@ private: case AUTODOC_METHOD: case AUTODOC_GETTER: { - if (counter == 0) Printf(doc, " call-seq:\n"); + if (counter == 0) + Printf(doc, " call-seq:\n"); String *paramList = make_autodocParmList(n, showTypes); if (Len(paramList)) Printf(doc, " %s(%s)", symname, paramList); else Printf(doc, " %s", symname); - if (type) - Printf(doc, " -> %s", type); + if (type_str) + Printf(doc, " -> %s", type_str); break; } case AUTODOC_SETTER: { Printf(doc, " call-seq:\n"); Printf(doc, " %s=(x)", symname); - if (type) Printf(doc, " -> %s", type); + if (type_str) + Printf(doc, " -> %s", type_str); break; } } @@ -671,6 +696,7 @@ private: n = Getattr(n, "sym:nextSibling"); if (n) Append(doc, "\n"); + Delete(type_str); } Printf(doc, "\n\n"); @@ -748,6 +774,35 @@ private: return doc; } + /* ------------------------------------------------------------ + * convertValue() + * Check if string v can be a Ruby value literal, + * (eg. number or string), or translate it to a Ruby literal. + * ------------------------------------------------------------ */ + String *convertValue(String *v, SwigType *t) { + if (v && Len(v) > 0) { + char fc = (Char(v))[0]; + if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) { + /* number or string (or maybe NULL pointer) */ + if (SwigType_ispointer(t) && Strcmp(v, "0") == 0) + return NewString("None"); + else + return v; + } + if (Strcmp(v, "NULL") == 0) + return SwigType_ispointer(t) ? NewString("nil") : NewString("0"); + else if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) + return NewString("true"); + else if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) + return NewString("false"); + if (Strcmp(v, "true") == 0 || Strcmp(v, "FALSE") == 0) + return NewString("True"); + if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) + return NewString("False"); + } + return 0; + } + public: /* --------------------------------------------------------------------- From 8a6e006a7b6835fdd7c851f718d6fb39b352ffc6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 17 Jun 2011 06:41:53 +0000 Subject: [PATCH 007/147] Marshalling char[] and char[ANY] to Java byte[] is now a bit easier git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12742 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/java/java_lib_arrays_runme.java | 7 +++++++ Examples/test-suite/java_lib_arrays.i | 13 +++++++++++++ Lib/java/arrays_java.i | 12 +++++++----- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/java/java_lib_arrays_runme.java b/Examples/test-suite/java/java_lib_arrays_runme.java index 9ee36210a..09a175ebb 100644 --- a/Examples/test-suite/java/java_lib_arrays_runme.java +++ b/Examples/test-suite/java/java_lib_arrays_runme.java @@ -23,6 +23,7 @@ public class java_lib_arrays_runme { // Create arrays for all the array types that ArrayStruct can handle String array_c = "X"; + byte[] array_c_extra = {11, 22}; byte[] array_sc = {10, 20}; short[] array_uc = {101, 201}; short[] array_s = {1002, 2002}; @@ -105,6 +106,12 @@ public class java_lib_arrays_runme { as.setArray_struct(array_struct); check_struct_array(array_struct, as.getArray_struct()); + + // Extended element (for char[]) + ArrayStructExtra ase = new ArrayStructExtra(); + ase.setArray_c2(array_c_extra); + check_byte_array(array_c_extra, ase.getArray_c2()); + } // Functions to check that the array values were set correctly diff --git a/Examples/test-suite/java_lib_arrays.i b/Examples/test-suite/java_lib_arrays.i index 0551cd100..8f9b0fd65 100644 --- a/Examples/test-suite/java_lib_arrays.i +++ b/Examples/test-suite/java_lib_arrays.i @@ -8,6 +8,7 @@ JAVA_ARRAYSOFCLASSES(SimpleStruct) %apply ARRAYSOFENUMS[ANY] { finger[ANY] } +//%apply signed char[ANY] { char array_c2[ANY] } %include "arrays.i" @@ -54,3 +55,15 @@ typedef enum { Big, Little } toe; void toestest(toe *t, toe tt[], toe ttt[2]) {} %} + +JAVA_ARRAYS_IMPL(char, jbyte, Byte, Char) +JAVA_ARRAYS_TYPEMAPS(char, byte, jbyte, Char, "[B") +%typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */ + signed char[ANY], signed char[] + "" + +%inline %{ +struct ArrayStructExtra { + char array_c2[ARRAY_LEN]; +}; +%} diff --git a/Lib/java/arrays_java.i b/Lib/java/arrays_java.i index ddaf7408c..64b85a89a 100644 --- a/Lib/java/arrays_java.i +++ b/Lib/java/arrays_java.i @@ -147,19 +147,19 @@ JAVA_ARRAYS_IMPL(double, jdouble, Double, Double) /* double[] */ %typemap(jstype) CTYPE[ANY], CTYPE[] %{JTYPE[]%} %typemap(in) CTYPE[] (JNITYPE *jarr) -%{ if (!SWIG_JavaArrayIn##JFUNCNAME(jenv, &jarr, &$1, $input)) return $null; %} +%{ if (!SWIG_JavaArrayIn##JFUNCNAME(jenv, &jarr, (CTYPE **)&$1, $input)) return $null; %} %typemap(in) CTYPE[ANY] (JNITYPE *jarr) %{ if ($input && JCALL1(GetArrayLength, jenv, $input) != $1_size) { SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "incorrect array size"); return $null; } - if (!SWIG_JavaArrayIn##JFUNCNAME(jenv, &jarr, &$1, $input)) return $null; %} + if (!SWIG_JavaArrayIn##JFUNCNAME(jenv, &jarr, (CTYPE **)&$1, $input)) return $null; %} %typemap(argout) CTYPE[ANY], CTYPE[] -%{ SWIG_JavaArrayArgout##JFUNCNAME(jenv, jarr$argnum, $1, $input); %} +%{ SWIG_JavaArrayArgout##JFUNCNAME(jenv, jarr$argnum, (CTYPE *)$1, $input); %} %typemap(out) CTYPE[ANY] -%{$result = SWIG_JavaArrayOut##JFUNCNAME(jenv, $1, $1_dim0); %} +%{$result = SWIG_JavaArrayOut##JFUNCNAME(jenv, (CTYPE *)$1, $1_dim0); %} %typemap(out) CTYPE[] -%{$result = SWIG_JavaArrayOut##JFUNCNAME(jenv, $1, FillMeInAsSizeCannotBeDeterminedAutomatically); %} +%{$result = SWIG_JavaArrayOut##JFUNCNAME(jenv, (CTYPE *)$1, FillMeInAsSizeCannotBeDeterminedAutomatically); %} %typemap(freearg) CTYPE[ANY], CTYPE[] #ifdef __cplusplus %{ delete [] $1; %} @@ -172,6 +172,8 @@ JAVA_ARRAYS_IMPL(double, jdouble, Double, Double) /* double[] */ return $jnicall; } +%typemap(memberin) CTYPE[ANY], CTYPE[]; +%typemap(globalin) CTYPE[ANY], CTYPE[]; %enddef JAVA_ARRAYS_TYPEMAPS(bool, boolean, jboolean, Bool, "[Z") /* bool[ANY] */ From eb398f692d316b8e29911fa1db286765618066df Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 17 Jun 2011 06:50:19 +0000 Subject: [PATCH 008/147] Marshalling char[] and char[ANY] to Java byte[] is now a bit easier git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12743 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index b47de9b69..3b6691c65 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-06-17: wsfulton + [Java] SF #3312505 - slightly easier to wrap char[] or char[ANY] with a Java byte[] + using arrays_java.i. + 2011-06-13: wsfulton [Ruby, Octave] SF #3310528 Autodoc fixes similar to those described below for Python. From 88d540683e8168dbf224da296ba2d6ebe95804a8 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 18 Jun 2011 04:24:19 +0000 Subject: [PATCH 009/147] [Tcl] Fix variable declarations in middle of blocks which isn't permitted in C90 (issue probably introduced in 2.0.3 by patch #3224663). Reported by Paul Obermeier in SF#3288586. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12744 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Lib/tcl/tclinit.swg | 5 ++--- Lib/tcl/tclrun.swg | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 3b6691c65..848dd25dd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-06-18: olly + [Tcl] Fix variable declarations in middle of blocks which isn't + permitted in C90 (issue probably introduced in 2.0.3 by patch #3224663). + Reported by Paul Obermeier in SF#3288586. + 2011-06-17: wsfulton [Java] SF #3312505 - slightly easier to wrap char[] or char[ANY] with a Java byte[] using arrays_java.i. diff --git a/Lib/tcl/tclinit.swg b/Lib/tcl/tclinit.swg index 87e398d91..3140bdcdb 100644 --- a/Lib/tcl/tclinit.swg +++ b/Lib/tcl/tclinit.swg @@ -77,13 +77,12 @@ SWIG_Tcl_InstallMethodLookupTables(void) { swig_type_info *type = swig_module.type_initial[i]; if (type->clientdata) { swig_class* klass = (swig_class*) type->clientdata; + swig_method* meth; Tcl_InitHashTable(&(klass->hashtable), TCL_STRING_KEYS); - swig_method* meth = klass->methods; - while (meth && meth->name) { + for (meth = klass->methods; meth && meth->name; ++meth) { int newEntry; Tcl_HashEntry* hashentry = Tcl_CreateHashEntry(&(klass->hashtable), meth->name, &newEntry); Tcl_SetHashValue(hashentry, (ClientData)meth->method); - ++meth; } } } diff --git a/Lib/tcl/tclrun.swg b/Lib/tcl/tclrun.swg index 66bb4d201..c91a7e511 100644 --- a/Lib/tcl/tclrun.swg +++ b/Lib/tcl/tclrun.swg @@ -340,6 +340,7 @@ SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_ cls_stack_bi[cls_stack_top] = -1; cls = inst->classptr; while (1) { + Tcl_HashEntry* hashentry; bi = cls_stack_bi[cls_stack_top]; cls = cls_stack[cls_stack_top]; if (bi != -1) { @@ -364,7 +365,7 @@ SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_ } cls_stack_bi[cls_stack_top]++; - Tcl_HashEntry* hashentry = Tcl_FindHashEntry(&(cls->hashtable), method); + hashentry = Tcl_FindHashEntry(&(cls->hashtable), method); if (hashentry) { ClientData cd = Tcl_GetHashValue(hashentry); swig_wrapper method_wrapper = (swig_wrapper)cd; From f320ea1d4a83a58b3e0873824eaf693df62a9916 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 18 Jun 2011 04:33:00 +0000 Subject: [PATCH 010/147] Update supported Perl versions to more closely reflect reality. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12745 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Perl5.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 5aae51888..72fe78be8 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -82,9 +82,9 @@ This chapter describes SWIG's support of Perl5. Although the Perl5 module is one of the earliest SWIG modules, it has continued to evolve and has been improved greatly with the help of SWIG users. For the -best results, it is recommended that SWIG be used with Perl5.003 or -later. Earlier versions are problematic and SWIG generated extensions -may not compile or run correctly. +best results, it is recommended that SWIG be used with Perl 5.8 or +later. We're no longer testing regularly with older versions, but +Perl 5.6 seems to mostly work, while older versions don't.

    30.1 Overview

    From 4cf0f14cb9468d56636604de178150e8baa2e3c8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 20 Jun 2011 17:38:02 +0000 Subject: [PATCH 011/147] Add function comment git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12746 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index e6c6e5143..6ea1777b5 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -214,6 +214,7 @@ Hash *Swig_cparse_features(void) { return features_hash; } +/* Fully qualify any template parameters */ static String *feature_identifier_fix(String *s) { String *tp = SwigType_istemplate_templateprefix(s); if (tp) { From d38e6bdf43625b6bbe207a424b153b8d36f420ae Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 20 Jun 2011 17:46:38 +0000 Subject: [PATCH 012/147] Fix incorrect typemaps being used for a symbol within a templated type git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12747 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/typemap_template.i | 10 ++++++++-- Source/Swig/swig.h | 1 + Source/Swig/typemap.c | 4 ++-- Source/Swig/typeobj.c | 26 ++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 848dd25dd..e8f8f9a35 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-06-19: wsfulton + Fix incorrect typemaps being used for a symbol within a templated type, eg: + A::value_type would incorrectly use a typemap for type A. + 2011-06-18: olly [Tcl] Fix variable declarations in middle of blocks which isn't permitted in C90 (issue probably introduced in 2.0.3 by patch #3224663). diff --git a/Examples/test-suite/typemap_template.i b/Examples/test-suite/typemap_template.i index ad35371cc..7ef77c79d 100644 --- a/Examples/test-suite/typemap_template.i +++ b/Examples/test-suite/typemap_template.i @@ -2,8 +2,8 @@ /* Test bug in 1.3.40 where the presence of a generic/unspecialized typemap caused the incorrect specialized typemap to be used */ -%typemap(in) SWIGTYPE "/*_this_will_not_compile_SWIGTYPE_ \"$type\" */ " -%typemap(in) const SWIGTYPE & "/*_this_will_not_compile_const_SWIGTYPE_REF_\"$type\" */ " +%typemap(in) SWIGTYPE "_this_will_not_compile_SWIGTYPE_ \"$type\" " +%typemap(in) const SWIGTYPE & "_this_will_not_compile_const_SWIGTYPE_REF_\"$type\" " %typemap(in) const TemplateTest1 & {$1 = (TemplateTest1 *)0; /* in typemap generic for $type */} %typemap(in) const TemplateTest1< ZZ > & {$1 = (TemplateTest1 *)0; /* in typemap ZZ for $type */} @@ -12,6 +12,7 @@ %inline %{ template struct TemplateTest1 { void setT(const TemplateTest1& t) {} + typedef double Double; }; %} @@ -32,3 +33,8 @@ template struct TemplateTest1 { {} %} +%typemap(in) TemplateTest1 "_this_will_not_compile_TemplateTest_ \"$type\" " + +%inline %{ + void wasbug(TemplateTest1< int >::Double wbug) {} +%} diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index db6144ce6..c5b1a7ce3 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -166,6 +166,7 @@ extern "C" { extern String *SwigType_templateprefix(const SwigType *t); extern String *SwigType_templatesuffix(const SwigType *t); extern String *SwigType_istemplate_templateprefix(const SwigType *t); + extern String *SwigType_istemplate_only_templateprefix(const SwigType *t); extern String *SwigType_templateargs(const SwigType *t); extern String *SwigType_prefix(const SwigType *t); extern int SwigType_array_ndim(const SwigType *t); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index fe6a33641..412db3f93 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -728,8 +728,8 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type goto ret_result; { - /* Look for the type reduced to just the template prefix */ - SwigType *template_prefix = SwigType_istemplate_templateprefix(ctype); + /* Look for the type reduced to just the template prefix - for templated types without the template parameter list being specified */ + SwigType *template_prefix = SwigType_istemplate_only_templateprefix(ctype); if (template_prefix) { tm = get_typemap(ts, template_prefix); result = typemap_search_helper(debug_display, tm, tm_method, template_prefix, cqualifiedname, cname, &backup); diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index dd8d901e0..b8ecf6e6a 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -927,6 +927,32 @@ String *SwigType_istemplate_templateprefix(const SwigType *t) { return c ? NewStringWithSize(s, c - s) : 0; } +/* ----------------------------------------------------------------------------- + * SwigType_istemplate_only_templateprefix() + * + * Similar to SwigType_istemplate_templateprefix() but only returns the template + * prefix if the type is just the template and not a subtype/symbol within the template. + * Returns NULL if not a template or is a template with a symbol within the template. + * For example: + * + * Foo<(p.int)> => Foo + * Foo<(p.int)>::bar => NULL + * r.q(const).Foo<(p.int)> => r.q(const).Foo + * r.q(const).Foo<(p.int)>::bar => NULL + * Foo => NULL + * ----------------------------------------------------------------------------- */ + +String *SwigType_istemplate_only_templateprefix(const SwigType *t) { + int len = Len(t); + const char *s = Char(t); + if (len >= 4 && strcmp(s + len - 2, ")>") == 0) { + const char *c = strstr(s, "<("); + return c ? NewStringWithSize(s, c - s) : 0; + } else { + return 0; + } +} + /* ----------------------------------------------------------------------------- * SwigType_templateargs() * From b8dcf31539b3ad4f6b06c339e47ea91f1c9f99bd Mon Sep 17 00:00:00 2001 From: Mikel Bancroft Date: Tue, 21 Jun 2011 18:51:25 +0000 Subject: [PATCH 013/147] [allegrocl] Small set of bug fixes and typemap tweaks. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12748 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 11 ++++ Lib/allegrocl/allegrocl.swg | 7 +++ Lib/allegrocl/longlongs.i | 36 +++++++++---- Source/Modules/allegrocl.cxx | 97 ++++++++++++++++++++++++++++++------ 4 files changed, 125 insertions(+), 26 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index e8f8f9a35..09ac4a022 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,17 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-06-21: mutandiz + [allegrocl] + - various small tweaks and bug fixes. + - Avoid name conflicts between smart pointer wrappers and the wrappers for + the actual class. + - Fix default typemaps for C bindings, which were incorrectly attempting to + call non-existent destructors on user-defined types. + - New feature, feature:aclmixins, for adding superclass to the foreign class + wrappers. + - Improve longlong typemaps. + 2011-06-19: wsfulton Fix incorrect typemaps being used for a symbol within a templated type, eg: A::value_type would incorrectly use a typemap for type A. diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg index 87e030ce4..f08f87c3c 100644 --- a/Lib/allegrocl/allegrocl.swg +++ b/Lib/allegrocl/allegrocl.swg @@ -16,6 +16,7 @@ float, double, long double, char *, void *, enum SWIGTYPE "(cl::setq ACL_ffresult $body)"; %typemap(lout) void "$body"; +#ifdef __cplusplus %typemap(lout) SWIGTYPE[ANY], SWIGTYPE *, SWIGTYPE & %{ (cl:let* ((address $body) @@ -25,6 +26,12 @@ (cl:setq ACL_ffresult new-inst)) %} %typemap(lout) SWIGTYPE "(cl::let* ((address $body)\n (new-inst (cl::make-instance '$lclass :foreign-address address)))\n (cl::unless (cl::zerop address)\n (excl:schedule-finalization new-inst #'$ldestructor))\n (cl::setq ACL_ffresult new-inst))"; +#else +%typemap(lout) SWIGTYPE[ANY], SWIGTYPE *, SWIGTYPE &, SWIGTYPE +%{ (cl:let* ((address $body) + (new-inst (cl:make-instance '$lclass :foreign-address address))) + (cl:setq ACL_ffresult new-inst)) %} +#endif %typemap(lisptype) bool, const bool "cl:boolean"; %typemap(lisptype) char, const char "cl:character"; diff --git a/Lib/allegrocl/longlongs.i b/Lib/allegrocl/longlongs.i index 4aa54660b..a15adcdda 100644 --- a/Lib/allegrocl/longlongs.i +++ b/Lib/allegrocl/longlongs.i @@ -7,27 +7,43 @@ * functions have been defined. * ----------------------------------------------------------------------------- */ -%typemap(in) long long, unsigned long long "$1 = $input;"; -%typemap(out) long long, unsigned long long "$result = &$1;"; +#ifdef Acl64Bit +%typemap(ctype) long long, unsigned long long "$1_ltype"; +%typemap(out) long long, unsigned long long "$result = $1;"; +%typemap(ffitype) long long ":nat"; +%typemap(ffitype) unsigned long long ":unsigned-nat"; + +%typemap(lout) long long, unsigned long long " #+64bit (cl::setq ACL_ffresult $body)"; + +#else +%typemap(out) long long, unsigned long long "$result = &$1;"; %typemap(ffitype) long long "(:struct (l1 :long) (l2 :long))"; -%typemap(ffitype) unsigned long long "(:struct (l1 :unsigned-long) - (l2 :unsigned-long))"; + +%typemap(ffitype) unsigned long long "(:struct (l1 :unsigned-long) (l2 :unsigned-long))"; %typemap(lout) long long -" (make-instance #.(swig-insert-id \"longlong\" () :type :class) - :foreign-address $body)"; +" (cl::setq ACL_ffresult (make-instance '#.(swig-insert-id \"longlong\" () :type :class) + :foreign-address $body))"; + %typemap(lout) unsigned long long -" (make-instance #.(swig-insert-id \"ulonglong\" () :type :class) - :foreign-address $body)"; +" (cl:setq ACL_ffresult (make-instance '#.(swig-insert-id \"ulonglong\" () :type :class) + :foreign-address $body))"; + +#endif + +%typemap(in) long long, unsigned long long "$1 = $input;"; + %insert("lisphead") %{ +#-64bit (swig-def-foreign-class "longlong" (ff:foreign-pointer) - (:struct (:struct (l1 :long) (l2 :long)))) + (:struct (l1 :long) (l2 :long))) +#-64bit (swig-def-foreign-class "ulonglong" (ff:foreign-pointer) - (:struct (:struct (l1 :unsigned-long) (l2 :unsigned-long)))) + (:struct (l1 :unsigned-long) (l2 :unsigned-long))) %} diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index df0b3b3d1..70096a226 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -162,10 +162,27 @@ String *namespaced_name(Node *n, String *ns = current_namespace) { // "Namespace::Nested::Class2::Baz" -> "Baz" static String *strip_namespaces(String *str) { - char *result = Char(str); + SwigType *new_type = Copy(str); + SwigType *leading_type = SwigType_pop(new_type); + char *result = Char(leading_type); + + if(SwigType_istemplate(leading_type)) { + result = Char(SwigType_templateprefix(leading_type)); + } else { + if (!SwigType_issimple(leading_type)) + return NewString(str); + } + String *stripped_one; while ((stripped_one = Strstr(result, "::"))) result = Char(stripped_one) + 2; + + if(SwigType_istemplate(leading_type)) { + SwigType_push(new_type, NewStringf("%s%s%s", result, SwigType_templateargs(leading_type), + SwigType_templatesuffix(leading_type))); + return new_type; + } + return NewString(result); } @@ -644,8 +661,12 @@ void note_implicit_template_instantiation(SwigType *t) { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "culling namespace of '%s' from '%s'\n", t, SwigType_templateprefix(t)); #endif - String *implicit_ns = namespace_of(SwigType_templateprefix(t)); + SwigType *type = Copy(t); + SwigType *tok = SwigType_pop(type); + String *implicit_ns = SwigType_istemplate(tok) ? namespace_of(SwigType_templateprefix(tok)) : 0; add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace); + + Delete(type); } String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) { @@ -1099,6 +1120,7 @@ void emit_stub_class(Node *n) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_stub_class: ENTER... '%s'(%x)\n", Getattr(n, "sym:name"), n); + Swig_print_node(n); #endif @@ -1221,7 +1243,8 @@ void emit_full_class(Node *n) { Printf(supers, "ff:foreign-pointer"); } - Printf(supers, ")"); + // check for "feature:aclmixins" and add those as well. + Printf(supers, " %s)", Getattr(n,"feature:aclmixins")); // Walk children to generate type definition. String *slotdefs = NewString(" "); @@ -2026,7 +2049,7 @@ int emit_num_lin_arguments(ParmList *parms) { int nargs = 0; while (p) { - // Printf(stderr,"enla: '%s' lin='%x'\n", Getattr(p,"name"), Getattr(p,"tmap:lin")); + // Printf(stderr,"enla: '%s' lin='%x' numinputs='%s'\n", Getattr(p,"name"), Getattr(p,"tmap:lin"), Getattr(p,"tmap:lin:numinputs")); if (Getattr(p, "tmap:lin")) { nargs += GetInt(p, "tmap:lin:numinputs"); p = Getattr(p, "tmap:lin:next"); @@ -2197,15 +2220,23 @@ struct IDargs { return result; } - String *noname_str() { + String *noname_str(bool include_class = true) { String *result = NewString(""); Printf(result, " :type :%s", type); - if (klass) + if (klass && include_class) Printf(result, " :class \"%s\"", klass); if (arity) Printf(result, " :arity %s", arity); return result; } + + String *noname_no_others_str(bool include_class = true) { + String *result = NewString(""); + Printf(result, " :type :%s", type); + if (klass && include_class) + Printf(result, " :class \"%s\"", klass); + return result; + } }; IDargs *id_converter_arguments(Node *n) { IDargs *result = (IDargs *) GetVoid(n, "allegrocl:id-converter-args"); @@ -2241,8 +2272,9 @@ IDargs *id_converter_arguments(Node *n) { // :class if (Strstr(result->type, "member ")) { Replaceall(result->type, "member ", ""); - if (!result->klass) + if (!result->klass) { result->klass = Copy(Getattr(parent_node_skipping_extends(n), "sym:name")); + } } // :arity if (Getattr(n, "sym:overloaded")) { @@ -2329,8 +2361,16 @@ int ALLEGROCL::emit_dispatch_defun(Node *n) { #endif List *overloads = Swig_overload_rank(n, true); - String *id_args = id_converter_arguments(n)->no_others_quoted_str(); - Printf(f_clwrap, "(swig-dispatcher (%s :arities (", id_args); + // Printf(stderr,"\ndispatch node=%x\n\n", n); + // Swig_print_node(n); + + Node *overloaded_from = Getattr(n,"sym:overloaded"); + bool include_class = Getattr(overloaded_from, "allegrocl:dispatcher:include-class") ? true : false; + String *id_args = id_converter_arguments(n)->noname_no_others_str(include_class); + Printf(f_clwrap, "(swig-dispatcher (\"%s\" %s :arities (", Getattr(overloaded_from, "allegrocl:dispatcher:name"), id_args); + + Delattr(overloaded_from, "allegrocl:dispatcher:include-class"); + Delattr(overloaded_from, "allegrocl:dispatcher:name"); int last_arity = -1; for (Iterator i = First(overloads); i.item; i = Next(i)) { @@ -2359,16 +2399,24 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { Printf(stderr, "emit_defun: ENTER... "); #endif + // avoid name conflicts between smart pointer wrappers and the wrappers for the + // actual class. + bool smartmemberwrapper = (!Cmp(Getattr(n, "view"), "memberfunctionHandler") && + Getattr(n,"allocate:smartpointeraccess")); + #ifdef ALLEGROCL_DEBUG int auto_generated = Cmp(Getattr(n, "view"), "globalfunctionHandler"); Printf(stderr, "%s%sfunction %s%s%s\n", auto_generated ? "> " : "", Getattr(n, "sym:overloaded") ? "overloaded " : "", current_namespace, (current_namespace) > 0 ? "::" : "", Getattr(n, "sym:name")); Printf(stderr, " (view: %s)\n", Getattr(n, "view")); + Swig_print_node(n); #endif + String *funcname = Getattr(n, "allegrocl:old-sym:name"); - if (!funcname) + if (smartmemberwrapper || !funcname) funcname = Getattr(n, "sym:name"); + String *mangled_name = Getattr(n, "wrap:name"); ParmList *pl = parmlist_with_names(Getattr(n, "wrap:parms")); @@ -2388,10 +2436,16 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { int largnum = 0, argnum = 0, first = 1; // int varargs=0; if (Generate_Wrapper) { - String *extra_parms = id_converter_arguments(n)->noname_str(); - if (Getattr(n, "sym:overloaded")) + String *extra_parms = id_converter_arguments(n)->noname_str(smartmemberwrapper ? false : true); + Node *overloaded_from = Getattr(n,"sym:overloaded"); + if (overloaded_from) { + if(!GetFlag(overloaded_from,"allegrocl:dispatcher:name")) { + Setattr(overloaded_from,"allegrocl:dispatcher:name",funcname); + Setattr(overloaded_from,"allegrocl:dispatcher:include-class", smartmemberwrapper ? 0 : "1"); + // Printf(stderr, " set a:d:name='%s', a:d:i-c='%s'\n", Getattr(n,"allegrocl:dispatcher:name"), Getattr(n,"allegrocl:dispatcher:include-class")); + } Printf(fcl, "(swig-defmethod (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms); - else + } else Printf(fcl, "(swig-defun (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms); Delete(extra_parms); } @@ -2568,7 +2622,6 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { int ALLEGROCL::functionWrapper(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "functionWrapper %s\n", Getattr(n,"name")); - Swig_print_node(n); #endif @@ -2616,7 +2669,7 @@ int ALLEGROCL::functionWrapper(Node *n) { if (Getattr(n, "overload:ignore")) { // if we're the last overload, make sure to force the emit // of the rest of the overloads before we leave. - Printf(stderr, "ignored overload %s(%x)\n", name, Getattr(n, "sym:nextSibling")); + // Printf(stderr, "ignored overload %s(%x)\n", name, Getattr(n, "sym:nextSibling")); if (!Getattr(n, "sym:nextSibling")) { update_package_if_needed(n); emit_buffered_defuns(n); @@ -2639,6 +2692,12 @@ int ALLEGROCL::functionWrapper(Node *n) { Parm *p; for (i = 0, p = parms; i < num_arguments; i++) { +#ifdef ALLEGROCL_DEBUG + String *temp1 = Getattr(p,"tmap:in"); + String *temp2 = Getattr(p,"tmap:in:numinputs"); + Printf(stderr," parm %d: %s, tmap:in='%s', tmap:in:numinputs='%s'\n", i, Getattr(p,"name"), temp1 ? temp1 : "", temp2 ? temp2 : ""); +#endif + while (p && checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); } @@ -2677,6 +2736,10 @@ int ALLEGROCL::functionWrapper(Node *n) { } Printf(name_and_parms, ")"); +#ifdef ALLEGROCL_DEBUG + Printf(stderr, " arity = %d(%d)\n", emit_num_lin_arguments(parms), emit_num_lin_arguments(Getattr(n,"wrap:parms"))); +#endif + // Emit the function definition String *signature = SwigType_str(return_type, name_and_parms); Printf(f->def, "EXPORT %s {", signature); @@ -2918,6 +2981,7 @@ int ALLEGROCL::variableWrapper(Node *n) { int ALLEGROCL::memberfunctionHandler(Node *n) { #ifdef ALLEGROCL_DEBUG Printf(stderr, "memberfunctionHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name")); + Swig_print_node(n); #endif Setattr(n, "allegrocl:kind", "member function"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); @@ -3103,7 +3167,8 @@ int ALLEGROCL::cppClassHandler(Node *n) { SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type")); #ifdef ALLEGROCL_CLASS_DEBUG - Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType); + Printf(stderr, "looking at child '%x' of type '%s' '%d'\n", c, childType, SwigType_isfunction(childType)); + // Swig_print_node(c); #endif if (!SwigType_isfunction(childType)) Delete(compose_foreign_type(n, childType)); From 688ea245600c0154aab7269e9de484776b8badde Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 23 Jun 2011 16:04:42 +0000 Subject: [PATCH 014/147] [PHP] Fix director code to work when PHP is built with ZTS enabled, which is the standard configuration on Microsoft Windows. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12749 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/php/director.swg | 38 ++++++++++++++++++++++++-------------- Source/Modules/php.cxx | 37 +++++++++++++++++++++++++++++++++---- 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 09ac4a022..c152184f3 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-06-23: olly + [PHP] Fix director code to work when PHP is built with ZTS enabled, + which is the standard configuration on Microsoft Windows. + 2011-06-21: mutandiz [allegrocl] - various small tweaks and bug fixes. diff --git a/Lib/php/director.swg b/Lib/php/director.swg index 218a84e3a..90f6a74a2 100644 --- a/Lib/php/director.swg +++ b/Lib/php/director.swg @@ -102,11 +102,17 @@ namespace Swig { zval *swig_self; typedef std::map swig_ownership_map; mutable swig_ownership_map swig_owner; +#ifdef ZTS + // Store the ZTS context so it's available when C++ calls back to PHP. + void *** swig_zts_ctx; +#endif public: - Director(zval* self) : swig_self(self) { + Director(zval* self TSRMLS_DC) : swig_self(self) { + TSRMLS_SET_CTX(swig_zts_ctx); } bool swig_is_overridden_method(char *cname, char *lc_fname) { + TSRMLS_FETCH_FROM_CTX(swig_zts_ctx); zend_class_entry **ce; zend_function *mptr; int name_len = strlen(lc_fname); @@ -135,7 +141,7 @@ namespace Swig { protected: std::string swig_msg; public: - DirectorException(int code, const char *hdr, const char* msg) + DirectorException(int code, const char *hdr, const char* msg TSRMLS_DC) : swig_msg(hdr) { if (strlen(msg)) { @@ -146,9 +152,9 @@ namespace Swig { SWIG_ErrorMsg() = swig_msg.c_str(); } - static void raise(int code, const char *hdr, const char* msg) + static void raise(int code, const char *hdr, const char* msg TSRMLS_DC) { - throw DirectorException(code, hdr, msg); + throw DirectorException(code, hdr, msg TSRMLS_CC); } }; @@ -156,32 +162,36 @@ namespace Swig { class DirectorPureVirtualException : public Swig::DirectorException { public: - DirectorPureVirtualException(const char* msg) - : DirectorException(E_ERROR, "SWIG director pure virtual method called", msg) - { + DirectorPureVirtualException(const char* msg TSRMLS_DC) + : DirectorException(E_ERROR, "SWIG director pure virtual method called", msg TSRMLS_CC) + { } - static void raise(const char *msg) + static void raise(const char *msg TSRMLS_DC) { - throw DirectorPureVirtualException(msg); + throw DirectorPureVirtualException(msg TSRMLS_CC); } }; /* any php exception that occurs during a director method call */ class DirectorMethodException : public Swig::DirectorException { public: - DirectorMethodException(const char* msg = "") - : DirectorException(E_ERROR, "SWIG director method error", msg) - { + DirectorMethodException(const char* msg TSRMLS_DC) + : DirectorException(E_ERROR, "SWIG director method error", msg TSRMLS_CC) + { } - static void raise(const char *msg) + static void raise(const char *msg TSRMLS_DC) { - throw DirectorMethodException(msg); + throw DirectorMethodException(msg TSRMLS_CC); } }; } +// DirectorMethodException() is documented to be callable with no parameters +// so use a macro to insert TSRMLS_CC so any ZTS context gets passed. +#define DirectorMethodException() DirectorMethodException("" TSRMLS_CC) + #endif /* __cplusplus */ #endif diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index b4af248f5..f6b4d5436 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -182,6 +182,23 @@ static void SwigPHP_emit_resource_registrations() { } class PHP : public Language { + String *emit_action(Node *n) { + // Adjust wrap:action to add TSRMLS_CC. + String * action = Getattr(n, "wrap:action"); + if (action) { + char * p = Strstr(action, "Swig::DirectorPureVirtualException::raise(\""); + if (p) { + p += strlen("Swig::DirectorPureVirtualException::raise(\""); + p = strchr(p, '"'); + if (p) { + ++p; + Insert(action, p - Char(action), " TSRMLS_CC"); + } + } + } + return ::emit_action(n); + } + public: PHP() { director_language = 1; @@ -2237,8 +2254,8 @@ done: if (i) { Insert(args, 0, ", "); } - Printf(director_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s);\n}\n", ctype, sname, args); - Printf(director_prot_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s);\n}\n", ctype, sname, args); + Printf(director_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", ctype, sname, args); + Printf(director_prot_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", ctype, sname, args); Delete(args); wrapperType = directorconstructor; @@ -2359,8 +2376,13 @@ done: String *call; String *basetype = Getattr(parent, "classtype"); String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); + if (((const char *)Char(target))[Len(target) - 2] == '(') { + Insert(target, Len(target) - 1, "TSRMLS_D"); + } else { + Insert(target, Len(target) - 1, " TSRMLS_DC"); + } call = Swig_csuperclass_call(0, basetype, superparms); - Printf(w->def, "%s::%s: %s, Swig::Director(self) {", classname, target, call); + Printf(w->def, "%s::%s: %s, Swig::Director(self TSRMLS_CC) {", classname, target, call); Append(w->def, "}"); Delete(target); Wrapper_print(w, f_directors); @@ -2371,6 +2393,11 @@ done: /* constructor header */ { String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); + if (((const char *)Char(target))[Len(target) - 2] == '(') { + Insert(target, Len(target) - 1, "TSRMLS_D"); + } else { + Insert(target, Len(target) - 1, " TSRMLS_DC"); + } Printf(f_directors_h, " %s;\n", target); Delete(target); } @@ -2474,6 +2501,8 @@ done: Append(w->def, " {"); Append(declaration, ";\n"); + Printf(w->code, "TSRMLS_FETCH_FROM_CTX(swig_zts_ctx);\n"); + /* declare method return value * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). @@ -2494,7 +2523,7 @@ done: Printf(w->code, "%s;\n", super_call); Delete(super_call); } else { - Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname), + Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\" TSRMLS_CC);\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } } else { From e3b5627ab57bce9df8910adaa550270e38605cb2 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 24 Jun 2011 17:18:43 +0000 Subject: [PATCH 015/147] Remove example of odd behaviour of PHP constants which I can't reproduce. It seems highly likely it's been fixed in PHP now, as the example dates from PHP4 days. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12750 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Php.html | 54 --------------------------------------------- 1 file changed, 54 deletions(-) diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 797cb058e..6f00bef28 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -249,60 +249,6 @@ evaluates to true, rather than the value of the constant which would be false. This is a feature!

    -

    -The second 'feature' is that although constants are case sensitive (by -default), you cannot declare a constant twice with alternative -cases. E.g., -

    - -
    -
    -%module example
    -
    -#define TEST	Hello
    -#define Test	World
    -
    -
    - -

    -accessed from PHP, -

    - -
    -
    -include("example.php");
    -
    -echo TEST, Test;
    -
    -
    - -

    -will output "Hello Test" rather than "Hello World". This is because -internally, all constants are stored in a hash table by their lower -case name, so 'TEST' and 'Test' will map to the same hash element -('Test'). But, because we declared them case sensitive, the Zend -engine will test if the case matches with the case the constant was -declared with first. -

    - -

    -So, in the example above, the TEST constant was declared first, and -will be stored under the hash element 'test'. The 'Test' constant will -also map to the same hash element 'test', but will not overwrite -it. When called from the script, the TEST constant will again be -mapped to the hash element 'test' so the constant will be -retrieved. The case will then be checked, and will match up, so the -value ('Hello') will be returned. When 'Test' is evaluated, it will -also map to the same hash element 'test'. The same constant will be -retrieved, this time though the case check will fail as 'Test' != -'TEST'. So PHP will assume that Test is a undeclared constant, and as -explained above, will return it as a string set to the constant name -('Test'). Hence the script above will print 'Hello Test'. If they were -declared non-case sensitive, the output would be 'Hello Hello', as -both point to the same value, without the case test taking place. ( -Apologies, this paragraph needs rewriting to make some sense. ) -

    -

    31.2.2 Global Variables

    From e7d25dd2d766abd30ff65deb654119b38b2a7ffc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 24 Jun 2011 18:34:01 +0000 Subject: [PATCH 016/147] Remove unimplemented functions git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12751 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/swig.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index c5b1a7ce3..fcb79c142 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -179,9 +179,6 @@ extern "C" { extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t); extern SwigType *SwigType_alttype(const SwigType *t, int ltmap); - extern void SwigType_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl); - extern SwigType *SwigType_template_deftype(const SwigType *type, Symtab *tscope); - /* --- Type-system managment --- */ extern void SwigType_typesystem_init(void); extern int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name); From 7d584f5204fa0fe7a8c0a1bdb8ea2961f4b3e1e4 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 25 Jun 2011 12:48:08 +0000 Subject: [PATCH 017/147] Clarify the text about remaining PHP constant oddity. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12752 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Php.html | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 6f00bef28..2b728b9f9 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -180,9 +180,8 @@ other symbols unless care is taken to %rename them.

    31.2.1 Constants

    -

    -These work in much the same way as in C/C++, constants can be defined +These work in much the same way as in C/C++. Constants can be defined by using either the normal C pre-processor declarations, or the %constant SWIG directive. These will then be available from your PHP script as a PHP constant, (i.e. no dollar sign is needed to @@ -199,7 +198,7 @@ access them.) For example, with a swig interface file like this,

    -you can access the constants in your php script like this, +you can access the constants in your PHP script like this,

    @@ -213,9 +212,16 @@ echo "E = " . E . "\n";
     

    -There are two peculiarities with using constants in PHP. The first is that -if you try to use an undeclared constant, it will evaluate to a string -set to the constant's name. For example, +There's one peculiarity of how constants work in PHP which it is useful +to note (this is not specific to SWIG though) - if you try to use an undeclared +constant, PHP will issue a warning and then expand the constant to a string +version of the constant's name. The warning will often be missed though as +if you're using PHP in a webserver, it will probably end up in error.log or +similar. +

    + +

    +For example,

    @@ -243,10 +249,9 @@ if(EASY_TO_MISPEL) {
     

    -will issue a warning about the undeclared constant, but will then -evaluate it and turn it into a string ('EASY_TO_MISPEL'), which -evaluates to true, rather than the value of the constant which would -be false. This is a feature! +The mis-spelled constant will become the string 'EASY_TO_MISPEL', which +is treated as true by the if test, when the value of the intended constant +would be treated as false!

    31.2.2 Global Variables

    From 6f672800440eed188fc72564b08b5f7741d4e464 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 1 Jul 2011 20:34:38 +0000 Subject: [PATCH 018/147] Add setter tests to test case git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12753 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../java/template_default_class_parms_runme.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Examples/test-suite/java/template_default_class_parms_runme.java b/Examples/test-suite/java/template_default_class_parms_runme.java index 4c8010745..406915b82 100644 --- a/Examples/test-suite/java/template_default_class_parms_runme.java +++ b/Examples/test-suite/java/template_default_class_parms_runme.java @@ -17,8 +17,11 @@ public class template_default_class_parms_runme { { DefaultBar bar = new DefaultBar(20.0, new SomeType(), 10); double d = bar.getCType(); + bar.setCType(d); SomeType s = bar.getDType(); + bar.setDType(s); int i = bar.getEType(); + bar.setEType(i); d = bar.method(d, s, i); } { @@ -29,13 +32,17 @@ public class template_default_class_parms_runme { { BarAnotherTypeBool bar = new BarAnotherTypeBool(new AnotherType(), true, 10); AnotherType a = bar.getCType(); + bar.setCType(a); boolean b = bar.getDType(); + bar.setDType(b); int i = bar.getEType(); + bar.setEType(i); a = bar.method(a, b, i); } { FooAnotherType foo = new FooAnotherType(new AnotherType()); AnotherType a = foo.getTType(); + foo.setTType(a); a = foo.method(a); } } From 6c100423b8a714994eb96efd580ccdb5169d15d8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 1 Jul 2011 22:59:55 +0000 Subject: [PATCH 019/147] Fix some scope and symbol lookup problems when template default parameters are being used with typedef - add the fully expanded template into the c symbol table and scope table. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12754 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 14 +++ Examples/test-suite/common.mk | 1 + ...ate_default_class_parms_typedef_runme.java | 86 +++++++++++++++++++ Examples/test-suite/li_std_vector.i | 1 + .../test-suite/python/li_std_vector_runme.py | 4 + .../template_default_class_parms_typedef.i | 77 +++++++++++++++++ Source/Modules/typepass.cxx | 25 +++++- 7 files changed, 204 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/java/template_default_class_parms_typedef_runme.java create mode 100644 Examples/test-suite/python/li_std_vector_runme.py create mode 100644 Examples/test-suite/template_default_class_parms_typedef.i diff --git a/CHANGES.current b/CHANGES.current index c152184f3..14f4a5f4c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,20 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-07-01: wsfulton + Fix some scope and symbol lookup problems when template default parameters are being + used with typedef. For example: + + template struct Foo { + typedef XX X; + typedef TT T; + }; + template struct UsesFoo { + void x(typename Foo::T, typename Foo::X); + }; + + Also fixes use of std::vector::size_type for Python as reported by Aubrey Barnard. + 2011-06-23: olly [PHP] Fix director code to work when PHP is built with ZTS enabled, which is the standard configuration on Microsoft Windows. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 10bc24309..0f80230ea 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -341,6 +341,7 @@ CPP_TEST_CASES += \ template_default2 \ template_default_arg \ template_default_class_parms \ + template_default_class_parms_typedef \ template_default_inherit \ template_default_qualify \ template_default_vw \ diff --git a/Examples/test-suite/java/template_default_class_parms_typedef_runme.java b/Examples/test-suite/java/template_default_class_parms_typedef_runme.java new file mode 100644 index 000000000..2b57875b7 --- /dev/null +++ b/Examples/test-suite/java/template_default_class_parms_typedef_runme.java @@ -0,0 +1,86 @@ + + +import template_default_class_parms_typedef.*; + +public class template_default_class_parms_typedef_runme { + + static { + try { + System.loadLibrary("template_default_class_parms_typedef"); + } 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[]) { + { + DefaultBar bar = new DefaultBar(20.0, new SomeType(), 10); + double d = bar.getCType(); + bar.setCType(d); + SomeType s = bar.getDType(); + bar.setDType(s); + int i = bar.getEType(); + bar.setEType(i); + d = bar.method(d, s, i); + d = bar.method_1(d, s, i); + d = bar.method_2(d, s, i); + d = bar.method_3(d, s, i); + + bar = new DefaultBar(true, 20.0, new SomeType(), 10); + bar = new DefaultBar(true, true, 20.0, new SomeType(), 10); + bar = new DefaultBar(true, true, true, 20.0, new SomeType(), 10); + } + { + DefaultFoo foo = new DefaultFoo(new SomeType()); + SomeType s = foo.getTType(); + s = foo.method(s); + s = foo.method_A(s); + s = foo.method_B(s); + s = foo.method_C(s); + + foo = new DefaultFoo(new SomeType(), new SomeType()); + foo = new DefaultFoo(new SomeType(), new SomeType(), new SomeType()); + foo = new DefaultFoo(new SomeType(), new SomeType(), new SomeType(), new SomeType()); + } + { + BarAnotherTypeBool bar = new BarAnotherTypeBool(new AnotherType(), true, 10); + AnotherType a = bar.getCType(); + bar.setCType(a); + boolean b = bar.getDType(); + bar.setDType(b); + int i = bar.getEType(); + bar.setEType(i); + + a = bar.method(a, b, i); + a = bar.method_1(a, b, i); + a = bar.method_2(a, b, i); + a = bar.method_3(a, b, i); + + bar = new BarAnotherTypeBool(true, new AnotherType(), true, 10); + bar = new BarAnotherTypeBool(true, true, new AnotherType(), true, 10); + bar = new BarAnotherTypeBool(true, true, true, new AnotherType(), true, 10); + } + { + FooAnotherType foo = new FooAnotherType(new AnotherType()); + AnotherType a = foo.getTType(); + foo.setTType(a); + a = foo.method(a); + a = foo.method_A(a); + a = foo.method_B(a); + a = foo.method_C(a); + + foo = new FooAnotherType(new AnotherType(), new AnotherType()); + foo = new FooAnotherType(new AnotherType(), new AnotherType(), new AnotherType()); + foo = new FooAnotherType(new AnotherType(), new AnotherType(), new AnotherType(), new AnotherType()); + } + { + UsesBarDouble u = new UsesBarDouble(); + u.use_A(10.1, new SomeType(), 10); + u.use_B(10.1, new SomeType(), 10); + u.use_C(10.1, new SomeType(), 10); + u.use_D(10.1, new SomeType(), 10); + } + } +} + diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i index a58f97ff1..55e0f4f6d 100644 --- a/Examples/test-suite/li_std_vector.i +++ b/Examples/test-suite/li_std_vector.i @@ -27,6 +27,7 @@ namespace std { %inline %{ typedef float Real; +size_t typedef_test(std::vector::size_type s) { return s; } %} namespace std { diff --git a/Examples/test-suite/python/li_std_vector_runme.py b/Examples/test-suite/python/li_std_vector_runme.py new file mode 100644 index 000000000..68a6d0348 --- /dev/null +++ b/Examples/test-suite/python/li_std_vector_runme.py @@ -0,0 +1,4 @@ +from li_std_vector import * + +if typedef_test(101) != 101: + raise RuntimeError diff --git a/Examples/test-suite/template_default_class_parms_typedef.i b/Examples/test-suite/template_default_class_parms_typedef.i new file mode 100644 index 000000000..fb64659ba --- /dev/null +++ b/Examples/test-suite/template_default_class_parms_typedef.i @@ -0,0 +1,77 @@ +%module template_default_class_parms_typedef + +// Based on template_default_class_parms testcase but using typedefs in template + +%feature("python:nondynamic"); + +%inline %{ +namespace Space { + struct SomeType {}; + struct AnotherType {}; + template class Bar { + public: + typedef CC C; + typedef DD D; + typedef EE E; + C CType; + D DType; + E EType; + // Use typedef with no qualifiers + Bar(C c, D d, E e) {} + C method(C c, D d, E e) { return c; } + + // Use typedef with classname qualifiers + Bar(bool, Bar::C c, Bar::D d, Bar::E e) {} + Bar::C method_1(Bar::C c, Bar::D d, Bar::E e) { return c; } + + // Use typedef with classname and full template parameter qualifiers + Bar(bool, bool, Bar::C c, Bar::D d, Bar::E e) {} + Bar::C method_2(Bar::C c, Bar::D d, Bar::E e) { return c; } + + // Use typedef with namespace and classname and full template parameter qualifiers + Bar(bool, bool, bool, Space::Bar::C c, Space::Bar::D d, Space::Bar::E e) {} + Space::Bar::C method_3(Space::Bar::C c, Space::Bar::D d, Space::Bar::E e) { return c; } + }; + template class Foo { + public: + typedef TT T; + T TType; + + // Use typedef with no qualifiers + Foo(T t) {} + T method(T t) { return t; } + + // Use typedef with classname qualifiers + Foo(const T &, T t) {} + Foo::T method_A(Foo::T t) { return t; } + + // Use typedef with classname and full template parameter qualifiers + Foo(const Foo::T &, const Foo::T &, Foo::T t) {} + Foo::T method_B(Foo::T t) { return t; } + + // Use typedef with namespace and classname and full template parameter qualifiers + Foo(const Foo::T &, const Foo::T &, const Foo::T &, Foo::T t) {} + Foo::T method_C(Foo::T t) { return t; } + }; + template class ATemplate {}; + + template struct UsesBar { + void use_A(typename Bar::C, typename Bar::D, typename Bar::E) {} + void use_B(const typename Bar::C &, const typename Bar::D &, const typename Bar::E &) {} + void use_C(typename Space::Bar::C, typename Space::Bar::D, typename Space::Bar::E) {} + void use_D(const typename Space::Bar::C &, const typename Space::Bar::D &, const typename Space::Bar::E &) {} + }; +} +%} + +// Use defaults +%template(DefaultBar) Space::Bar; +%template(DefaultFoo) Space::Foo<>; + +// Don't use all defaults +%template(BarAnotherTypeBool) Space::Bar; +%template(FooAnotherType) Space::Foo; + +%template() Space::ATemplate<>; + +%template(UsesBarDouble) Space::UsesBar; diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index 74996207f..9baca9258 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -399,20 +399,27 @@ class TypePass:private Dispatcher { String *nname = 0; String *fname = 0; String *scopename = 0; + String *template_default_expanded = 0; normalize = NewList(); if (name) { if (SwigType_istemplate(name)) { - // We need to fully resolve the name to make templates work correctly */ + // We need to fully resolve the name and expand default template parameters to make templates work correctly */ Node *cn; - fname = SwigType_typedef_resolve_all(name); - if (Strcmp(fname, name) != 0 && (cn = Swig_symbol_clookup_local(fname, 0))) { + SwigType *resolved_name = SwigType_typedef_resolve_all(name); + SwigType *deftype_name = Swig_symbol_template_deftype(resolved_name, 0); + fname = Copy(resolved_name); + if (!Equal(resolved_name, deftype_name)) + template_default_expanded = Copy(deftype_name); + if (!Equal(fname, name) && (cn = Swig_symbol_clookup_local(fname, 0))) { if ((n == cn) || (Strcmp(nodeType(cn), "template") == 0) || (Getattr(cn, "feature:onlychildren") != 0) || (Getattr(n, "feature:onlychildren") != 0)) { Swig_symbol_cadd(fname, n); + if (template_default_expanded) + Swig_symbol_cadd(template_default_expanded, n); SwigType_typedef_class(fname); scopename = Copy(fname); } else { @@ -425,6 +432,8 @@ class TypePass:private Dispatcher { SwigType_typedef_class(fname); scopename = Copy(fname); } + Delete(deftype_name); + Delete(resolved_name); } else { if ((CPlusPlus) || (unnamed)) { SwigType_typedef_class(name); @@ -444,7 +453,7 @@ class TypePass:private Dispatcher { SwigType_typedef(unnamed, tdname); } - if (nsname) { + if (nsname && name) { nname = NewStringf("%s::%s", nsname, name); String *tdname = Getattr(n, "tdname"); if (tdname) { @@ -474,6 +483,13 @@ class TypePass:private Dispatcher { Delete(ts); Setattr(n, "module", module); + // When a fully qualified templated type with default parameters is used in the parsed code, + // the following additional symbols and scopes are needed for successful lookups + if (template_default_expanded) { + Swig_symbol_alias(template_default_expanded, Getattr(n, "symtab")); + SwigType_scope_alias(template_default_expanded, Getattr(n, "typescope")); + } + /* Normalize deferred types */ { normal_node *nn = new normal_node(); @@ -493,6 +509,7 @@ class TypePass:private Dispatcher { Setattr(n, "name", nname); Delete(nname); } + Delete(fname); return SWIG_OK; } From a9bf7737c1e6bbecfb989ec294837f28a24899c8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 1 Jul 2011 23:08:47 +0000 Subject: [PATCH 020/147] Format changes for -debug-typedef git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12755 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/typesys.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index f13c84a84..c2eb3ec07 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -393,7 +393,9 @@ void SwigType_print_scope(void) { Hash *ttab; Iterator i, j; + Printf(stdout, "SCOPES start =======================================\n"); for (i = First(scopes); i.key; i = Next(i)) { + Printf(stdout, "-------------------------------------------------------------\n"); ttab = Getattr(i.item, "typetab"); Printf(stdout, "Type scope '%s' (%x)\n", i.key, i.item); @@ -406,11 +408,11 @@ void SwigType_print_scope(void) { } } } - Printf(stdout, "-------------------------------------------------------------\n"); for (j = First(ttab); j.key; j = Next(j)) { Printf(stdout, "%40s -> %s\n", j.key, j.item); } } + Printf(stdout, "SCOPES finish =======================================\n"); } static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix) { From 0df6937fbfc6c81e32c0266ab5e870e5be27262b Mon Sep 17 00:00:00 2001 From: Stefan Zager Date: Thu, 14 Jul 2011 05:15:05 +0000 Subject: [PATCH 021/147] Bug 3324753: fix %rename for member variables under -builtin git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12756 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/python.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index e1dad5259..3024e299d 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2650,20 +2650,26 @@ public: /* If this is a builtin type, create a PyGetSetDef entry for this member variable. */ if (builtin_getter) { - Hash *h = Getattr(builtin_getset, name); + String *memname = Getattr(n, "membervariableHandler:sym:name"); + if (!memname) + memname = iname; + Hash *h = Getattr(builtin_getset, memname); if (!h) { h = NewHash(); - Setattr(builtin_getset, name, h); + Setattr(builtin_getset, memname, h); Delete(h); } Setattr(h, "getter", wrapper_name); Delattr(n, "memberget"); } if (builtin_setter) { - Hash *h = Getattr(builtin_getset, name); + String *memname = Getattr(n, "membervariableHandler:sym:name"); + if (!memname) + memname = iname; + Hash *h = Getattr(builtin_getset, memname); if (!h) { h = NewHash(); - Setattr(builtin_getset, name, h); + Setattr(builtin_getset, memname, h); Delete(h); } Setattr(h, "setter", wrapper_name); From e5659434571d07ea124c7b18ae1c87b0465e8760 Mon Sep 17 00:00:00 2001 From: Stefan Zager Date: Thu, 14 Jul 2011 05:17:27 +0000 Subject: [PATCH 022/147] Added comment for bug 3324753 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12757 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 14f4a5f4c..3b1ccfcb7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-07-13: szager + Fix for bug 3324753: %rename member variables with -builtin. + 2011-07-01: wsfulton Fix some scope and symbol lookup problems when template default parameters are being used with typedef. For example: From 62a88f3613af41d97c40dc928678c0d90ecba64f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 15 Jul 2011 06:57:25 +0000 Subject: [PATCH 023/147] Fix comment typoes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12758 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/lua.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index 26237f033..c38ffdae9 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -762,7 +762,7 @@ public: String *getName = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, iname)); String *setName = 0; // checking whether it can be set to or not appears to be a very error prone issue - // I refered to the Language::variableWrapper() to find this out + // I referred to the Language::variableWrapper() to find this out bool assignable=is_assignable(n) ? true : false; SwigType *type = Getattr(n, "type"); String *tm = Swig_typemap_lookup("globalin", n, iname, 0); @@ -890,7 +890,7 @@ public: real_classname = Getattr(n, "name"); mangled_classname = Swig_name_mangle(real_classname); - // not sure exactly how this workswhat this works, + // not sure exactly how this works, // but tcl has a static hashtable of all classes emitted and then only emits code for them once. // this fixes issues in test suites: template_default2 & template_specialization @@ -952,7 +952,7 @@ public: Delete(s_attr_tab); // Handle inheritance - // note: with the idea of class hireachied spread over multiple modules + // note: with the idea of class hierarchies spread over multiple modules // cf test-suite: imports.i // it is not possible to just add the pointers to the base classes to the code // (as sometimes these classes are not present) From e167400a2909c68eb08e86896f8834f39ee9f09b Mon Sep 17 00:00:00 2001 From: Stefan Zager Date: Fri, 15 Jul 2011 18:49:32 +0000 Subject: [PATCH 024/147] Fixed issue from swig-user 6/27/11. Support code in std_map.i needs all the template parameters that std::map takes, even the default ones (Compare, Allocator). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12759 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/python/std_map.i | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 3b1ccfcb7..dda3e410d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-07-13: szager + [python] Add all template parameters to map support code in std_map.i + 2011-07-13: szager Fix for bug 3324753: %rename member variables with -builtin. diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index fec816222..37d749790 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -5,19 +5,19 @@ %fragment("StdMapTraits","header",fragment="StdSequenceTraits") { namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::map *map) { - typedef typename std::map::value_type value_type; + assign(const SwigPySeq& swigpyseq, std::map *map) { + typedef typename std::map::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { map->insert(value_type(it->first, it->second)); } } - template - struct traits_asptr > { - typedef std::map map_type; + template + struct traits_asptr > { + typedef std::map map_type; static int asptr(PyObject *obj, map_type **val) { int res = SWIG_ERROR; SWIG_PYTHON_THREAD_BEGIN_BLOCK; @@ -27,7 +27,7 @@ /* In Python 3.x the ".items()" method returns a dict_items object */ items = PySequence_Fast(items, ".items() didn't return a sequence!"); %#endif - res = traits_asptr_stdseq, std::pair >::asptr(items, val); + res = traits_asptr_stdseq >::asptr(items, val); } else { map_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); @@ -38,9 +38,9 @@ } }; - template - struct traits_from > { - typedef std::map map_type; + template + struct traits_from > { + typedef std::map map_type; typedef typename map_type::const_iterator const_iterator; typedef typename map_type::size_type size_type; From ff6b144f30b8962096569f468d695391425bbb8f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 16 Jul 2011 14:43:04 +0000 Subject: [PATCH 025/147] Fix Python directorin typemap for PyObject * git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12760 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 ++++- Examples/test-suite/python/Makefile.in | 1 + Examples/test-suite/python_director.i | 18 ++++++++++++++++++ Lib/typemaps/swigobject.swg | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/python_director.i diff --git a/CHANGES.current b/CHANGES.current index dda3e410d..503553f33 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,11 +5,14 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-07-16: wsfulton + [python] Fix director typemap using PyObject *. + 2011-07-13: szager [python] Add all template parameters to map support code in std_map.i 2011-07-13: szager - Fix for bug 3324753: %rename member variables with -builtin. + [python] Fix for bug 3324753: %rename member variables with -builtin. 2011-07-01: wsfulton Fix some scope and symbol lookup problems when template default parameters are being diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 185ca2298..e5d92626e 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -59,6 +59,7 @@ CPP_TEST_CASES += \ primitive_types \ python_abstractbase \ python_append \ + python_director \ python_nondynamic \ python_overload_simple_cast \ python_richcompare \ diff --git a/Examples/test-suite/python_director.i b/Examples/test-suite/python_director.i new file mode 100644 index 000000000..c85113afa --- /dev/null +++ b/Examples/test-suite/python_director.i @@ -0,0 +1,18 @@ +%module(directors="1") python_director + +%feature("director"); +%inline %{ + class IFactoryFuncs { + public: + IFactoryFuncs() {} + virtual ~IFactoryFuncs() {} + + virtual PyObject * process(PyObject *pyobj) { + return pyobj; + } + + void process_again(const PyObject *& pyobj) { + } + }; +%} + diff --git a/Lib/typemaps/swigobject.swg b/Lib/typemaps/swigobject.swg index e89b63026..4a7965d96 100644 --- a/Lib/typemaps/swigobject.swg +++ b/Lib/typemaps/swigobject.swg @@ -30,7 +30,7 @@ #if defined(SWIG_DIRECTOR_TYPEMAPS) -%typemap(directorin) SWIG_Object "$input = $1_name"; +%typemap(directorin) SWIG_Object "$input = $1_name;"; %typemap(directorout) SWIG_Object "$result = $input;"; #endif /* SWIG_DIRECTOR_TYPEMAPS */ From 498367bc9ddb5f82299cf771facfac2b9f3341de Mon Sep 17 00:00:00 2001 From: Stefan Zager Date: Wed, 20 Jul 2011 15:20:24 +0000 Subject: [PATCH 026/147] From swig-user 7/6/11: fix closure for tp_call. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12761 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/python/builtin.swg | 9 +++++++++ Lib/python/pyopers.swg | 2 +- Source/Modules/python.cxx | 2 ++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 503553f33..f7bdb9dae 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-07-20 szager + [python] Fix closure for tp_call slot. + 2011-07-16: wsfulton [python] Fix director typemap using PyObject *. diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 97150dc5c..d8164777f 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -39,6 +39,8 @@ wrapper##_closure(PyObject *a, PyObject *b) { \ return result; \ } +typedef ternaryfunc ternarycallfunc; + #define SWIGPY_TERNARYFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ @@ -54,6 +56,12 @@ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ return result; \ } +#define SWIGPY_TERNARYCALLFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_closure(PyObject *callable_object, PyObject *args, PyObject *) { \ + return wrapper(callable_object, args); \ +} + #define SWIGPY_LENFUNC_CLOSURE(wrapper) \ SWIGINTERN Py_ssize_t \ wrapper##_closure(PyObject *a) { \ @@ -498,3 +506,4 @@ SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype) #ifdef __cplusplus } #endif + diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg index d84d740f4..ecbe7834e 100644 --- a/Lib/python/pyopers.swg +++ b/Lib/python/pyopers.swg @@ -123,7 +123,7 @@ %rename(__invert__) *::operator~; %feature("python:slot", "nb_invert", functype="unaryfunc") *::operator~; %rename(__call__) *::operator(); -%feature("python:slot", "tp_call", functype="ternaryfunc") *::operator(); +%feature("python:slot", "tp_call", functype="ternarycallfunc") *::operator(); #if defined(SWIGPYTHON_BUILTIN) %pybinoperator(__nonzero__, *::operator bool, inquiry, nb_nonzero); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3024e299d..43cfcaed9 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -190,6 +190,7 @@ static String *getClosure(String *functype, String *wrapper, int funpack = 0) { "getiterfunc", "SWIGPY_UNARYFUNC_CLOSURE", "binaryfunc", "SWIGPY_BINARYFUNC_CLOSURE", "ternaryfunc", "SWIGPY_TERNARYFUNC_CLOSURE", + "ternarycallfunc", "SWIGPY_TERNARYCALLFUNC_CLOSURE", "lenfunc", "SWIGPY_LENFUNC_CLOSURE", "ssizeargfunc", "SWIGPY_SSIZEARGFUNC_CLOSURE", "ssizessizeargfunc", "SWIGPY_SSIZESSIZEARGFUNC_CLOSURE", @@ -208,6 +209,7 @@ static String *getClosure(String *functype, String *wrapper, int funpack = 0) { "inquiry", "SWIGPY_INQUIRY_CLOSURE", "getiterfunc", "SWIGPY_UNARYFUNC_CLOSURE", "ternaryfunc", "SWIGPY_TERNARYFUNC_CLOSURE", + "ternarycallfunc", "SWIGPY_TERNARYCALLFUNC_CLOSURE", "lenfunc", "SWIGPY_LENFUNC_CLOSURE", "ssizeargfunc", "SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE", "ssizessizeargfunc", "SWIGPY_SSIZESSIZEARGFUNC_CLOSURE", From 40efa0705221b5556df98e0414d280ad4cfd8073 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 Jul 2011 06:27:10 +0000 Subject: [PATCH 027/147] Typemap correction for: (size_t LENGTH, const char *STRING) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12762 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/typemaps/strings.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/typemaps/strings.swg b/Lib/typemaps/strings.swg index d982a17a2..8c39b8322 100644 --- a/Lib/typemaps/strings.swg +++ b/Lib/typemaps/strings.swg @@ -448,7 +448,7 @@ /* Here len doesn't include the '0' terminator */ %typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (size_t LENGTH, Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), - (size_t LENGHT, const Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) + (size_t LENGTH, const Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) { res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); if (!SWIG_IsOK(res)) { From 931536594d9fda8151ef7c7a49d932ad5f45905d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 Jul 2011 19:30:17 +0000 Subject: [PATCH 028/147] Module name fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12763 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/template_typemaps.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/template_typemaps.i b/Examples/test-suite/template_typemaps.i index 92968e56f..b5fc1c9aa 100644 --- a/Examples/test-suite/template_typemaps.i +++ b/Examples/test-suite/template_typemaps.i @@ -1,4 +1,4 @@ -%module template_typemap +%module template_typemaps %typemap(in) Integer1 From 7d038d4bd7762fb931d3a2112788cddc952792a2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 Jul 2011 19:34:23 +0000 Subject: [PATCH 029/147] Fix scoping of forward class declarations nested within a class (for C++). Also fix %template and resolution of template parameters that are typedefs. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12764 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 27 +++++ Examples/test-suite/common.mk | 4 + .../template_typemaps_typedef2_runme.py | 37 ++++++ .../python/template_typemaps_typedef_runme.py | 37 ++++++ .../template_typedef_class_template.i | 57 +++++++++ .../test-suite/template_typemaps_typedef.i | 109 +++++++++++++++++ .../test-suite/template_typemaps_typedef2.i | 111 ++++++++++++++++++ Source/Modules/typepass.cxx | 10 +- Source/Swig/symbol.c | 3 + Source/Swig/typemap.c | 7 +- Source/Swig/typesys.c | 94 ++++++++------- 11 files changed, 442 insertions(+), 54 deletions(-) create mode 100644 Examples/test-suite/python/template_typemaps_typedef2_runme.py create mode 100644 Examples/test-suite/python/template_typemaps_typedef_runme.py create mode 100644 Examples/test-suite/template_typedef_class_template.i create mode 100644 Examples/test-suite/template_typemaps_typedef.i create mode 100644 Examples/test-suite/template_typemaps_typedef2.i diff --git a/CHANGES.current b/CHANGES.current index f7bdb9dae..d6bbc6ba5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,33 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-07-26: wsfulton + Fix scoping of forward class declarations nested within a class (for C++). Previously the symbol + was incorrectly put into the outer namespace, eg + + namespace std { + template struct map { + class iterator; + } + } + + iterator was scoped as std::iterator, but now it is correctly std::map::iterator; + + Also fixed is %template and template parameters that are a typedef when the template contains + default template parameters, eg: + + namespace Std { + template struct Map { + typedef Key key_type; + typedef T mapped_type; + } + } + tyepdef double DOUBLE; + %typemap(MM) Std::Map; + + All symbols within Map will be resolved correctly, eg key_type and mapped_type no matter if the + wrapped code uses Std::Map or std::Map or Std::Map + 2011-07-20 szager [python] Fix closure for tp_call slot. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 0f80230ea..6b0bdae78 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -383,6 +383,7 @@ CPP_TEST_CASES += \ template_tbase_template \ template_template_parameters \ template_typedef \ + template_typedef_class_template \ template_typedef_cplx \ template_typedef_cplx2 \ template_typedef_cplx3 \ @@ -392,6 +393,9 @@ CPP_TEST_CASES += \ template_typedef_ns \ template_typedef_ptr \ template_typedef_rec \ + template_typemaps \ + template_typemaps_typedef \ + template_typemaps_typedef2 \ template_using \ template_virtual \ template_whitespace \ diff --git a/Examples/test-suite/python/template_typemaps_typedef2_runme.py b/Examples/test-suite/python/template_typemaps_typedef2_runme.py new file mode 100644 index 000000000..8a66d27d0 --- /dev/null +++ b/Examples/test-suite/python/template_typemaps_typedef2_runme.py @@ -0,0 +1,37 @@ +from template_typemaps_typedef2 import * + +m1 = MultimapIntA() + +dummy_pair = m1.make_dummy_pair() +val = m1.typemap_test(dummy_pair).val +if val != 1234: + raise RuntimeError, "typemaps not working" + +m2 = MultimapAInt() + +# TODO: typemaps and specializations not quite working as expected. T needs expanding, but at least the right typemap is being picked up. +#dummy_pair = m2.make_dummy_pair() +#val = m2.typemap_test(dummy_pair) + +#print val +#if val != 4321: +# raise RuntimeError, "typemaps not working" + +if typedef_test1(dummy_pair).val != 1234: + raise RuntimeError, "typedef_test1 not working" + +if typedef_test2(dummy_pair).val != 1234: + raise RuntimeError, "typedef_test2 not working" + +if typedef_test3(dummy_pair).val != 1234: + raise RuntimeError, "typedef_test3 not working" + +if typedef_test4(dummy_pair).val != 1234: + raise RuntimeError, "typedef_test4 not working" + +if typedef_test5(dummy_pair).val != 1234: + raise RuntimeError, "typedef_test5 not working" + +if typedef_test6(dummy_pair).val != 1234: + raise RuntimeError, "typedef_test6 not working" + diff --git a/Examples/test-suite/python/template_typemaps_typedef_runme.py b/Examples/test-suite/python/template_typemaps_typedef_runme.py new file mode 100644 index 000000000..a4d6fd0a7 --- /dev/null +++ b/Examples/test-suite/python/template_typemaps_typedef_runme.py @@ -0,0 +1,37 @@ +from template_typemaps_typedef import * + +m1 = MultimapIntA() + +dummy_pair = m1.make_dummy_pair() +val = m1.typemap_test(dummy_pair).val +if val != 1234: + raise RuntimeError, "typemaps not working" + +m2 = MultimapAInt() + +# TODO: typemaps and specializations not quite working as expected. T needs expanding, but at least the right typemap is being picked up. +#dummy_pair = m2.make_dummy_pair() +#val = m2.typemap_test(dummy_pair) + +#print val +#if val != 4321: +# raise RuntimeError, "typemaps not working" + +if typedef_test1(dummy_pair).val != 1234: + raise RuntimeError, "typedef_test1 not working" + +if typedef_test2(dummy_pair).val != 1234: + raise RuntimeError, "typedef_test2 not working" + +if typedef_test3(dummy_pair).val != 1234: + raise RuntimeError, "typedef_test3 not working" + +if typedef_test4(dummy_pair).val != 1234: + raise RuntimeError, "typedef_test4 not working" + +if typedef_test5(dummy_pair).val != 1234: + raise RuntimeError, "typedef_test5 not working" + +if typedef_test6(dummy_pair).val != 1234: + raise RuntimeError, "typedef_test6 not working" + diff --git a/Examples/test-suite/template_typedef_class_template.i b/Examples/test-suite/template_typedef_class_template.i new file mode 100644 index 000000000..498f83ec5 --- /dev/null +++ b/Examples/test-suite/template_typedef_class_template.i @@ -0,0 +1,57 @@ +%module template_typedef_class_template + +%inline %{ +namespace Standard { + template struct Pair { + T first; + U second; + }; +} +%} + +// previously these typemaps were erroneously being used as iterator was not correctly scoped in Multimap +%typemap(out) Standard::Pair "_this_will_not_compile_iterator_" +%typemap(out) Standard::Pair "_this_will_not_compile_const_iterator_" + +%{ +namespace Standard { +template class Multimap { + public: + typedef Key key_type; + typedef T mapped_type; + + class iterator {}; + class const_iterator {}; + + // test usage of a typedef of a nested class in a template + Standard::Pair equal_range_1(const key_type& kt1) {} + Standard::Pair equal_range_2(const key_type& kt2) const {} + }; +} +%} + +namespace Standard { +template class Multimap { + public: + typedef Key key_type; + typedef T mapped_type; + + class iterator; + class const_iterator; + + // test usage of a typedef of a nested class in a template + Standard::Pair equal_range_1(const key_type& kt1) {} + Standard::Pair equal_range_2(const key_type& kt2) const {} + }; +} + +%inline %{ +struct A { + int val; + A(int v = 0): val(v) {} +}; +%} + +%template(PairA) Standard::Pair; +%template(MultimapA) Standard::Multimap; + diff --git a/Examples/test-suite/template_typemaps_typedef.i b/Examples/test-suite/template_typemaps_typedef.i new file mode 100644 index 000000000..5351f1785 --- /dev/null +++ b/Examples/test-suite/template_typemaps_typedef.i @@ -0,0 +1,109 @@ +%module template_typemaps_typedef +// Similar to template_typedef_class_template +// Testing typemaps of a typedef of a nested class in a template and where the template uses default parameters + +%inline %{ +namespace Standard { + template struct Pair { + T first; + U second; + }; +} +%} + +%{ +namespace Standard { +template class Multimap { + public: + typedef Key key_type; + typedef T mapped_type; + + class iterator { + public: + mapped_type mm; + iterator(mapped_type m = mapped_type()) : mm(m) {} + }; + + mapped_type typemap_test(Standard::Pair pp) { return pp.second.mm; } + Standard::Pair* make_dummy_pair() { return new Standard::Pair(); } + }; +} +%} + +namespace Standard { +template class Multimap { + public: + typedef Key key_type; + typedef T mapped_type; + + class iterator; + + %typemap(in) Standard::Pair "$1 = default_general< Key, T >();" + mapped_type typemap_test(Standard::Pair pii1); + Standard::Pair* make_dummy_pair(); + }; +} + +// specialization +namespace Standard { +template<> class Multimap { + public: + typedef Key key_type; + typedef T mapped_type; + + class iterator; + + // Note uses a different function to the non-specialized version + %typemap(in) Standard::Pair "$1 = default_A_int< A, int >();" + mapped_type typemap_test(Standard::Pair pii2); + Standard::Pair* make_dummy_pair(); + }; +} + +%inline %{ +struct A { + int val; + A(int v = 0): val(v) {} +}; +%} + +%{ +// For < int, A > +template Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_general() { + Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_value; + default_value.second.mm = A(1234); + return default_value; +} +// For < A, int > +template Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_A_int() { + Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_value; + default_value.second.mm = 4321; + return default_value; +} +%} + +%inline %{ +typedef A AA; +namespace Space { + typedef AA AB; +} +%} + +%template(PairIntA) Standard::Pair; +%template(MultimapIntA) Standard::Multimap; + +%template(PairAInt) Standard::Pair; +%template(MultimapAInt) Standard::Multimap; + +%inline %{ + +// Extend the test with some typedefs in the template parameters +Standard::Multimap< int, AA >::mapped_type typedef_test1(Standard::Pair< Standard::Multimap< int, AA >::iterator, Standard::Multimap< int, AA >::iterator > pp) { return pp.second.mm; } +Standard::Multimap< int, A >::mapped_type typedef_test2(Standard::Pair< Standard::Multimap< int, A >::iterator, Standard::Multimap< int, A >::iterator > pp) { return pp.second.mm; } +Standard::Multimap< int, AA, int >::mapped_type typedef_test3(Standard::Pair< Standard::Multimap< int, AA, int >::iterator, Standard::Multimap< int, AA, int >::iterator > pp) { return pp.second.mm; } +Standard::Multimap< int, A , int >::mapped_type typedef_test4(Standard::Pair< Standard::Multimap< int, A , int >::iterator, Standard::Multimap< int, A , int >::iterator > pp) { return pp.second.mm; } +using namespace Space; +Standard::Multimap< int, AB >::mapped_type typedef_test5(Standard::Pair< Standard::Multimap< int, AB >::iterator, Standard::Multimap< int, AB >::iterator > pp) { return pp.second.mm; } +Standard::Multimap< int, AB, int >::mapped_type typedef_test6(Standard::Pair< Standard::Multimap< int, AB, int >::iterator, Standard::Multimap< int, AB, int >::iterator > pp) { return pp.second.mm; } +%} + diff --git a/Examples/test-suite/template_typemaps_typedef2.i b/Examples/test-suite/template_typemaps_typedef2.i new file mode 100644 index 000000000..549f42373 --- /dev/null +++ b/Examples/test-suite/template_typemaps_typedef2.i @@ -0,0 +1,111 @@ +%module template_typemaps_typedef2 +// Identical to template_typemaps_typedef, except for %template + +// Similar to template_typedef_class_template +// Testing typemaps of a typedef of a nested class in a template and where the template uses default parameters + +%inline %{ +namespace Standard { + template struct Pair { + T first; + U second; + }; +} +%} + +%{ +namespace Standard { +template class Multimap { + public: + typedef Key key_type; + typedef T mapped_type; + + class iterator { + public: + mapped_type mm; + iterator(mapped_type m = mapped_type()) : mm(m) {} + }; + + mapped_type typemap_test(Standard::Pair pp) { return pp.second.mm; } + Standard::Pair* make_dummy_pair() { return new Standard::Pair(); } + }; +} +%} + +namespace Standard { +template class Multimap { + public: + typedef Key key_type; + typedef T mapped_type; + + class iterator; + + %typemap(in) Standard::Pair "$1 = default_general< Key, T >();" + mapped_type typemap_test(Standard::Pair pii1); + Standard::Pair* make_dummy_pair(); + }; +} + +// specialization +namespace Standard { +template<> class Multimap { + public: + typedef Key key_type; + typedef T mapped_type; + + class iterator; + + // Note uses a different function to the non-specialized version + %typemap(in) Standard::Pair "$1 = default_A_int< A, int >();" + mapped_type typemap_test(Standard::Pair pii2); + Standard::Pair* make_dummy_pair(); + }; +} + +%inline %{ +struct A { + int val; + A(int v = 0): val(v) {} +}; +%} + +%{ +// For < int, A > +template Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_general() { + Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_value; + default_value.second.mm = A(1234); + return default_value; +} +// For < A, int > +template Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_A_int() { + Standard::Pair< typename Standard::Multimap< Key, T >::iterator, typename Standard::Multimap< Key, T >::iterator > default_value; + default_value.second.mm = 4321; + return default_value; +} +%} + +%inline %{ +typedef A AA; +namespace Space { + typedef AA AB; +} +%} + +%template(PairIntA) Standard::Pair; +%template(MultimapIntA) Standard::Multimap; + +%template(PairAInt) Standard::Pair; +%template(MultimapAInt) Standard::Multimap; + +%inline %{ + +// Extend the test with some typedefs in the template parameters +Standard::Multimap< int, AA >::mapped_type typedef_test1(Standard::Pair< Standard::Multimap< int, AA >::iterator, Standard::Multimap< int, AA >::iterator > pp) { return pp.second.mm; } +Standard::Multimap< int, A >::mapped_type typedef_test2(Standard::Pair< Standard::Multimap< int, A >::iterator, Standard::Multimap< int, A >::iterator > pp) { return pp.second.mm; } +Standard::Multimap< int, AA, int >::mapped_type typedef_test3(Standard::Pair< Standard::Multimap< int, AA, int >::iterator, Standard::Multimap< int, AA, int >::iterator > pp) { return pp.second.mm; } +Standard::Multimap< int, A , int >::mapped_type typedef_test4(Standard::Pair< Standard::Multimap< int, A , int >::iterator, Standard::Multimap< int, A , int >::iterator > pp) { return pp.second.mm; } +using namespace Space; +Standard::Multimap< int, AB >::mapped_type typedef_test5(Standard::Pair< Standard::Multimap< int, AB >::iterator, Standard::Multimap< int, AB >::iterator > pp) { return pp.second.mm; } +Standard::Multimap< int, AB, int >::mapped_type typedef_test6(Standard::Pair< Standard::Multimap< int, AB, int >::iterator, Standard::Multimap< int, AB, int >::iterator > pp) { return pp.second.mm; } +%} + diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index 9baca9258..15768f203 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -539,18 +539,10 @@ class TypePass:private Dispatcher { virtual int classforwardDeclaration(Node *n) { - /* Temporary hack. Can't do inside a class because it breaks - C nested structure wrapping */ - + /* Can't do inside a C struct because it breaks C nested structure wrapping */ if ((!inclass) || (CPlusPlus)) { String *name = Getattr(n, "name"); - String *nname; SwigType_typedef_class(name); - if (nsname) { - nname = NewStringf("%s::%s", nsname, name); - Setattr(n, "name", nname); - } - } return SWIG_OK; } diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index 0dc47c48c..fd6644bb2 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -223,6 +223,9 @@ static void symbol_print_symbols(const char *symboltabletype) { while (it.key) { String *symname = it.key; Printf(stdout, " %s\n", symname); + /* + Printf(stdout, " %s - %p (%s)\n", symname, it.item, Getattr(it.item, "name")); + */ it = Next(it); } } diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 412db3f93..8f5d07158 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -91,9 +91,11 @@ static Hash *get_typemap(int tm_scope, const SwigType *type) { static void set_typemap(int tm_scope, const SwigType *type, Hash *tm) { SwigType *hashtype = 0; if (SwigType_istemplate(type)) { - String *ty = Swig_symbol_template_deftype(type, 0); + SwigType *rty = SwigType_typedef_resolve_all(type); + String *ty = Swig_symbol_template_deftype(rty, 0); String *tyq = Swig_symbol_type_qualify(ty, 0); hashtype = SwigType_remove_global_scope_prefix(tyq); + Delete(rty); Delete(tyq); Delete(ty); } else { @@ -2013,12 +2015,13 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper void Swig_typemap_debug() { int ts; + int nesting_level = 2; Printf(stdout, "---[ typemaps ]--------------------------------------------------------------\n"); ts = tm_scope; while (ts >= 0) { Printf(stdout, "::: scope %d\n\n", ts); - Printf(stdout, "%s\n", typemaps[ts]); + Swig_print(typemaps[ts], nesting_level); ts--; } Printf(stdout, "-----------------------------------------------------------------------------\n"); diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index c2eb3ec07..a6b23a225 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -425,8 +425,6 @@ static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix) { return 0; Setmark(s, 1); - /* Printf(stdout,"find_scope: %x(%s) '%s'\n", s, Getattr(s,"name"), nameprefix); */ - if (SwigType_istemplate(nameprefix)) { nnameprefix = SwigType_typedef_resolve_all(nameprefix); nameprefix = nnameprefix; @@ -542,6 +540,53 @@ static SwigType *_typedef_resolve(Typetab *s, String *base, int look_parent) { return type; } +/* ----------------------------------------------------------------------------- + * template_parameters_resolve() + * + * For use with templates only. The template parameters are resolved. If none + * of the parameters can be resolved, zero is returned. + * ----------------------------------------------------------------------------- */ + +static String *template_parameters_resolve(const String *base) { + List *tparms; + String *suffix; + String *type; + int i, sz; + int rep = 0; + type = SwigType_templateprefix(base); + suffix = SwigType_templatesuffix(base); + Append(type, "<("); + tparms = SwigType_parmlist(base); + sz = Len(tparms); + for (i = 0; i < sz; i++) { + SwigType *tpr; + SwigType *tp = Getitem(tparms, i); + if (!rep) { + tpr = SwigType_typedef_resolve(tp); + } else { + tpr = 0; + } + if (tpr) { + Append(type, tpr); + Delete(tpr); + rep = 1; + } else { + Append(type, tp); + } + if ((i + 1) < sz) + Append(type, ","); + } + Append(type, ")>"); + Append(type, suffix); + Delete(suffix); + Delete(tparms); + if (!rep) { + Delete(type); + type = 0; + } + return type; +} + static SwigType *typedef_resolve(Typetab *s, String *base) { return _typedef_resolve(s, base, 1); } @@ -562,12 +607,6 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) { String *nameprefix = 0; int newtype = 0; - /* - if (!noscope) { - noscope = NewStringEmpty(); - } - */ - resolved_scope = 0; #ifdef SWIG_TYPEDEF_RESOLVE_CACHE @@ -611,6 +650,9 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) { #endif if (nameprefix) { /* Name had a prefix on it. See if we can locate the proper scope for it */ + String *rnameprefix = template_parameters_resolve(nameprefix); + nameprefix = rnameprefix ? Copy(rnameprefix) : nameprefix; + Delete(rnameprefix); s = SwigType_find_scope(s, nameprefix); /* Couldn't locate a scope for the type. */ @@ -677,42 +719,8 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) { template arguments one by one to see if they can be resolved. */ if (!type && SwigType_istemplate(base)) { - List *tparms; - String *suffix; - int i, sz; - int rep = 0; - type = SwigType_templateprefix(base); newtype = 1; - suffix = SwigType_templatesuffix(base); - Append(type, "<("); - tparms = SwigType_parmlist(base); - sz = Len(tparms); - for (i = 0; i < sz; i++) { - SwigType *tpr; - SwigType *tp = Getitem(tparms, i); - if (!rep) { - tpr = SwigType_typedef_resolve(tp); - } else { - tpr = 0; - } - if (tpr) { - Append(type, tpr); - Delete(tpr); - rep = 1; - } else { - Append(type, tp); - } - if ((i + 1) < sz) - Append(type, ","); - } - Append(type, ")>"); - Append(type, suffix); - Delete(suffix); - Delete(tparms); - if (!rep) { - Delete(type); - type = 0; - } + type = template_parameters_resolve(base); } if (namebase) Delete(namebase); From 4511b1364670b8882ba9067949c8d5c6be4d197a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 28 Jul 2011 06:29:20 +0000 Subject: [PATCH 030/147] Add testcase for bug #3378145 which was fixed in r12764 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12765 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 + Examples/test-suite/common.mk | 1 + .../java/template_typedef_inherit_runme.java | 24 +++++++++ .../test-suite/template_typedef_inherit.i | 50 +++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 Examples/test-suite/java/template_typedef_inherit_runme.java create mode 100644 Examples/test-suite/template_typedef_inherit.i diff --git a/CHANGES.current b/CHANGES.current index d6bbc6ba5..11e0b5950 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -32,6 +32,8 @@ Version 2.0.5 (in progress) All symbols within Map will be resolved correctly, eg key_type and mapped_type no matter if the wrapped code uses Std::Map or std::Map or Std::Map + Also fixes bug #3378145 - regression introduced in 2.0.4 - %template using traits. + 2011-07-20 szager [python] Fix closure for tp_call slot. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 6b0bdae78..c007588ef 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -390,6 +390,7 @@ CPP_TEST_CASES += \ template_typedef_cplx4 \ template_typedef_cplx5 \ template_typedef_funcptr \ + template_typedef_inherit \ template_typedef_ns \ template_typedef_ptr \ template_typedef_rec \ diff --git a/Examples/test-suite/java/template_typedef_inherit_runme.java b/Examples/test-suite/java/template_typedef_inherit_runme.java new file mode 100644 index 000000000..72a72807a --- /dev/null +++ b/Examples/test-suite/java/template_typedef_inherit_runme.java @@ -0,0 +1,24 @@ + + +import template_typedef_inherit.*; + +public class template_typedef_inherit_runme { + + static { + try { + System.loadLibrary("template_typedef_inherit"); + } 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[]) { + DescriptionImplementationTypedCollectionInterfaceObject d = new DescriptionImplementationTypedCollectionInterfaceObject(); + d.add("a string"); + + StringPersistentCollection s = new StringPersistentCollection(); + s.add("a string"); + } +} + diff --git a/Examples/test-suite/template_typedef_inherit.i b/Examples/test-suite/template_typedef_inherit.i new file mode 100644 index 000000000..057d8afd5 --- /dev/null +++ b/Examples/test-suite/template_typedef_inherit.i @@ -0,0 +1,50 @@ +%module template_typedef_virtual + +// Bug 3378145 + +%include std_string.i + +%inline %{ +#include // for std::string + +typedef std::string String; + +namespace Type { + template class TypedInterfaceObject {}; + + template class TypedCollectionInterfaceObject : public TypedInterfaceObject { + public: + typedef T ImplementationType; + typedef typename ImplementationType::ElementType ImplementationElementType; + + /** Method add() appends an element to the collection */ + void add(const ImplementationElementType & elt) {} + }; + + template class PersistentCollection { + public: + typedef T ElementType; + + /** Method add() appends an element to the collection */ + inline virtual void add(const T & elt) {} + }; +} +%} + +%template(StringPersistentCollection) Type::PersistentCollection; + +%inline %{ + +namespace Type { + class DescriptionImplementation : public PersistentCollection { + public: + typedef PersistentCollection::ElementType ElementType; + DescriptionImplementation() {} + }; +} + +%} + +%template(DescriptionImplementationTypedInterfaceObject) Type::TypedInterfaceObject; +%template(DescriptionImplementationTypedCollectionInterfaceObject) Type::TypedCollectionInterfaceObject; + From 56c38059222be1a61d1f02f35ef136c0363e3909 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 28 Jul 2011 19:31:52 +0000 Subject: [PATCH 031/147] Add missing SF patch number git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12766 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 11e0b5950..3dcc96d49 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -41,7 +41,7 @@ Version 2.0.5 (in progress) [python] Fix director typemap using PyObject *. 2011-07-13: szager - [python] Add all template parameters to map support code in std_map.i + [python] SF patch #3365908 - Add all template parameters to map support code in std_map.i 2011-07-13: szager [python] Fix for bug 3324753: %rename member variables with -builtin. From 210266cd7004108b074fac9da4fc97d1df0adc53 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 29 Jul 2011 10:51:02 +0000 Subject: [PATCH 032/147] [PHP] Don't generate "return $r;" in cases where $r hasn't been set. This was basically harmless, except it generated a PHP E_NOTICE if the calling code had enabled them. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12767 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Source/Modules/php.cxx | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 3dcc96d49..d43a3cd30 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-07-29: olly + [PHP] Don't generate "return $r;" in cases where $r hasn't been set. + This was basically harmless, except it generated a PHP E_NOTICE if + the calling code had enabled them. + 2011-07-26: wsfulton Fix scoping of forward class declarations nested within a class (for C++). Previously the symbol was incorrectly put into the outer namespace, eg diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index f6b4d5436..20f9bcc78 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1773,7 +1773,11 @@ public: Printf(output, "\t\t}\n"); } } else { - Printf(output, "\t\treturn %s;\n", invoke); + if (non_void_return) { + Printf(output, "\t\treturn %s;\n", invoke); + } else if (Cmp(invoke, "$r") != 0) { + Printf(output, "\t\t%s;\n", invoke); + } } Printf(output, "\t}\n"); From 6747c6a13d402683b567d51f9a99ac2df65c47c0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 4 Aug 2011 06:21:16 +0000 Subject: [PATCH 033/147] Add section on void * pointers for C# git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12769 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 6691400b7..968d629c4 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -455,6 +455,24 @@ 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 Void pointers

    + + +

    +By default SWIG treats void * as any other pointer and hence marshalls it as a type wrapper class called SWIGTYPE_p_void. +If you want to marshall with the .NET System.IntPtr type instead, there is a simple set of named typemaps called +void *VOID_INT_PTR that can be used. +They can be applied like any other named typemaps: +

    + + +
    +
    +%apply void *VOID_INT_PTR { void * }
    +void * f(void *v);
    +
    +
    +

    18.3 C# Arrays

    From ff2d73586676de4782ab2f53ef0717fc91cf31cb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 4 Aug 2011 06:23:24 +0000 Subject: [PATCH 034/147] Section numbering update git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12770 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 43 ++++++++++++++++++++-------------------- Doc/Manual/Contents.html | 8 ++++++-- Doc/Manual/Go.html | 1 + Doc/Manual/Php.html | 1 + 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 968d629c4..c520ccfe4 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -11,6 +11,7 @@
    • Introduction
    • Differences to the Java module +
    • Void pointers
    • C# Arrays
      • The SWIG C arrays library @@ -473,7 +474,7 @@ void * f(void *v); -

        18.3 C# Arrays

        +

        18.4 C# Arrays

        @@ -485,7 +486,7 @@ with one of the following three approaches; namely the SWIG C arrays library, P/ pinned arrays.

        -

        18.3.1 The SWIG C arrays library

        +

        18.4.1 The SWIG C arrays library

        @@ -522,7 +523,7 @@ example.print_array(c.cast()); // Pass to C -

        18.3.2 Managed arrays using P/Invoke default array marshalling

        +

        18.4.2 Managed arrays using P/Invoke default array marshalling

        @@ -649,7 +650,7 @@ and intermediate class method -

        18.3.3 Managed arrays using pinning

        +

        18.4.3 Managed arrays using pinning

        @@ -744,7 +745,7 @@ public static extern void myArrayCopy(IntPtr jarg1, IntPtr jarg2, int jarg3); -

        18.4 C# Exceptions

        +

        18.5 C# Exceptions

        @@ -841,7 +842,7 @@ set so should only be used when a C# exception is not created.

        -

        18.4.1 C# exception example using "check" typemap

        +

        18.5.1 C# exception example using "check" typemap

        @@ -1023,7 +1024,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.4.2 C# exception example using %exception

        +

        18.5.2 C# exception example using %exception

        @@ -1088,7 +1089,7 @@ The managed code generated does check for the pending exception as mentioned ear -

        18.4.3 C# exception example using exception specifications

        +

        18.5.3 C# exception example using exception specifications

        @@ -1145,7 +1146,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) { Multiple catch handlers are generated should there be more than one exception specifications declared.

        -

        18.4.4 Custom C# ApplicationException example

        +

        18.5.4 Custom C# ApplicationException example

        @@ -1279,7 +1280,7 @@ try { -

        18.5 C# Directors

        +

        18.6 C# Directors

        @@ -1292,7 +1293,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.

        -

        18.5.1 Directors example

        +

        18.6.1 Directors example

        @@ -1413,7 +1414,7 @@ CSharpDerived - UIntMethod(123) -

        18.5.2 Directors implementation

        +

        18.6.2 Directors implementation

        @@ -1599,7 +1600,7 @@ void SwigDirector_Base::BaseBoolMethod(Base const &b, bool flag) { -

        18.5.3 Director caveats

        +

        18.6.3 Director caveats

        @@ -1647,7 +1648,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.6 C# Typemap examples

        +

        18.7 C# Typemap examples

        This section includes a few examples of typemaps. For more examples, you @@ -1655,7 +1656,7 @@ might look at the files "csharp.swg" and "typemaps.i" in the SWIG library. -

        18.6.1 Memory management when returning references to member variables

        +

        18.7.1 Memory management when returning references to member variables

        @@ -1779,7 +1780,7 @@ public class Bike : IDisposable { Note the addReference call.

        -

        18.6.2 Memory management for objects passed to the C++ layer

        +

        18.7.2 Memory management for objects passed to the C++ layer

        @@ -1898,7 +1899,7 @@ The 'cscode' typemap simply adds in the specified code into the C# proxy class. -

        18.6.3 Date marshalling using the csin typemap and associated attributes

        +

        18.7.3 Date marshalling using the csin typemap and associated attributes

        @@ -2184,7 +2185,7 @@ public class example { -

        18.6.4 A date example demonstrating marshalling of C# properties

        +

        18.7.4 A date example demonstrating marshalling of C# properties

        @@ -2285,7 +2286,7 @@ Some points to note:

      -

      18.6.5 Turning wrapped classes into partial classes

      +

      18.7.5 Turning wrapped classes into partial classes

      @@ -2385,7 +2386,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.6.6 Extending proxy classes with additional C# code

      +

      18.7.6 Extending proxy classes with additional C# code

      @@ -2424,7 +2425,7 @@ public class ExtendMe : IDisposable { -

      18.6.7 Underlying type for enums

      +

      18.7.7 Underlying type for enums

      diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index b53923c17..d662626a9 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -635,6 +635,7 @@

      @@ -1389,6 +1390,8 @@
    • %feature("docstring") @@ -1691,3 +1694,4 @@ + diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 8c072e00a..b927e8661 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -547,6 +547,7 @@ void f(char *output);

      21.3.10 Adding additional go code

      +

      Often the APIs generated by swig are not very natural in go, especially if there are output arguments. You can insert additional go wrapping code to add new APIs diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 2b728b9f9..ccc0f039c 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -180,6 +180,7 @@ other symbols unless care is taken to %rename them.

      31.2.1 Constants

      +

      These work in much the same way as in C/C++. Constants can be defined by using either the normal C pre-processor declarations, or the From e29d93ebd96adc057fe96bc96a7e7539e161002c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 4 Aug 2011 06:25:45 +0000 Subject: [PATCH 035/147] html fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12771 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 4 ++-- Doc/Manual/Contents.html | 2 +- Doc/Manual/Go.html | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index c520ccfe4..6ea2fb72c 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -11,7 +11,7 @@

      • Introduction
      • Differences to the Java module -
      • Void pointers +
      • Void pointers
      • C# Arrays
        • The SWIG C arrays library @@ -456,7 +456,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 Void pointers

          +

          18.3 Void pointers

          diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index d662626a9..e9c923a9e 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -635,7 +635,7 @@

          • Introduction
          • Differences to the Java module -
          • Void pointers +
          • Void pointers
          • C# Arrays
            • The SWIG C arrays library diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index b927e8661..5c3c1b4f2 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -503,7 +503,7 @@ argument.

              For example, suppose you were trying to wrap the modf() function in the C math library which splits x into integral and fractional parts (and -returns the integer part in one of its parameters):

              +returns the integer part in one of its parameters):

               double modf(double x, double *ip);
              @@ -536,7 +536,7 @@ some additional functions written in go that
               hide the ugly details.

              There are no char *OUTPUT typemaps. However you can -apply the signed char * typemaps instead:

              +apply the signed char * typemaps instead:

               %include <typemaps.i>
              
              From 44c202d048e645d66b0cd023345b95597f822f08 Mon Sep 17 00:00:00 2001
              From: William S Fulton 
              Date: Thu, 4 Aug 2011 19:45:19 +0000
              Subject: [PATCH 036/147] Add in $symname expansion for director methods
              
              git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12772 626c5289-ae23-0410-ae9c-e8d60b6d4f22
              ---
               CHANGES.current                         |  3 +++
               Examples/test-suite/special_variables.i | 18 +++++++++++++++++-
               Source/Modules/ocaml.cxx                |  2 ++
               Source/Modules/octave.cxx               |  2 ++
               Source/Modules/php.cxx                  |  2 ++
               Source/Modules/python.cxx               |  2 ++
               Source/Modules/ruby.cxx                 |  2 ++
               7 files changed, 30 insertions(+), 1 deletion(-)
              
              diff --git a/CHANGES.current b/CHANGES.current
              index d43a3cd30..13fb61b2c 100644
              --- a/CHANGES.current
              +++ b/CHANGES.current
              @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release.
               Version 2.0.5 (in progress)
               ===========================
               
              +2011-08-04: wsfulton
              +            Add in $symname expansion for director methods.
              +
               2011-07-29: olly
               	    [PHP] Don't generate "return $r;" in cases where $r hasn't been set.
               	    This was basically harmless, except it generated a PHP E_NOTICE if
              diff --git a/Examples/test-suite/special_variables.i b/Examples/test-suite/special_variables.i
              index e8853cec2..071365710 100644
              --- a/Examples/test-suite/special_variables.i
              +++ b/Examples/test-suite/special_variables.i
              @@ -1,4 +1,4 @@
              -%module special_variables
              +%module(directors="1") special_variables
               
               %include 
               
              @@ -88,3 +88,19 @@ namespace SpaceNamespace {
               
               %template(TemplateABC) SpaceNamespace::Template;
               
              +/////////////////////////////////// directors /////////////////////////////////
              +%{
              +void DirectorTest_director_testmethod(int i) {}
              +void DirectorTest_director_testmethodSwigExplicitDirectorTest(int i) {}
              +%}
              +%typemap(directorargout) int i {
              +  $symname(99);
              +}
              +%feature("director") DirectorTest;
              +%inline %{
              +void director_testmethod(int i) {}
              +struct DirectorTest {
              +  virtual void director_testmethod(int i) {}
              +  virtual ~DirectorTest() {}
              +};
              +%}
              diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
              index 1f7249348..676a5b7ae 100644
              --- a/Source/Modules/ocaml.cxx
              +++ b/Source/Modules/ocaml.cxx
              @@ -1387,6 +1387,7 @@ public:
                   String *name;
                   String *classname;
                   String *c_classname = Getattr(parent, "name");
              +    String *symname = Getattr(n, "sym:name");
                   String *declaration;
                   ParmList *l;
                   Wrapper *w;
              @@ -1691,6 +1692,7 @@ public:
                   /* emit the director method */
                   if (status == SWIG_OK) {
                     if (!Getattr(n, "defaultargs")) {
              +	Replaceall(w->code, "$symname", symname);
               	Wrapper_print(w, f_directors);
               	Printv(f_directors_h, declaration, NIL);
               	Printv(f_directors_h, inline_extra_method, NIL);
              diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
              index c22d90195..49d07a3a3 100644
              --- a/Source/Modules/octave.cxx
              +++ b/Source/Modules/octave.cxx
              @@ -1208,6 +1208,7 @@ public:
                   String *name;
                   String *classname;
                   String *c_classname = Getattr(parent, "name");
              +    String *symname = Getattr(n, "sym:name");
                   String *declaration;
                   ParmList *l;
                   Wrapper *w;
              @@ -1474,6 +1475,7 @@ public:
                   // emit the director method
                   if (status == SWIG_OK) {
                     if (!Getattr(n, "defaultargs")) {
              +	Replaceall(w->code, "$symname", symname);
               	Wrapper_print(w, f_directors);
               	Printv(f_directors_h, declaration, NIL);
               	Printv(f_directors_h, inline_extra_method, NIL);
              diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
              index 20f9bcc78..a428afedb 100644
              --- a/Source/Modules/php.cxx
              +++ b/Source/Modules/php.cxx
              @@ -2417,6 +2417,7 @@ done:
                   String *name;
                   String *classname;
                   String *c_classname = Getattr(parent, "name");
              +    String *symname = Getattr(n, "sym:name");
                   String *declaration;
                   ParmList *l;
                   Wrapper *w;
              @@ -2738,6 +2739,7 @@ done:
                   /* emit the director method */
                   if (status == SWIG_OK) {
                     if (!Getattr(n, "defaultargs")) {
              +	Replaceall(w->code, "$symname", symname);
               	Wrapper_print(w, f_directors);
               	Printv(f_directors_h, declaration, NIL);
               	Printv(f_directors_h, inline_extra_method, NIL);
              diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
              index 43cfcaed9..619e99e86 100644
              --- a/Source/Modules/python.cxx
              +++ b/Source/Modules/python.cxx
              @@ -4533,6 +4533,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
                 String *name;
                 String *classname;
                 String *c_classname = Getattr(parent, "name");
              +  String *symname = Getattr(n, "sym:name");
                 String *declaration;
                 ParmList *l;
                 Wrapper *w;
              @@ -4996,6 +4997,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
                 /* emit the director method */
                 if (status == SWIG_OK) {
                   if (!Getattr(n, "defaultargs")) {
              +      Replaceall(w->code, "$symname", symname);
                     Wrapper_print(w, f_directors);
                     Printv(f_directors_h, declaration, NIL);
                     Printv(f_directors_h, inline_extra_method, NIL);
              diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
              index 1ad1241ee..a12d93b68 100644
              --- a/Source/Modules/ruby.cxx
              +++ b/Source/Modules/ruby.cxx
              @@ -3028,6 +3028,7 @@ public:
                   String *name;
                   String *classname;
                   String *c_classname = Getattr(parent, "name");
              +    String *symname = Getattr(n, "sym:name");
                   String *declaration;
                   ParmList *l;
                   Wrapper *w;
              @@ -3388,6 +3389,7 @@ public:
                   /* emit the director method */
                   if (status == SWIG_OK) {
                     if (!Getattr(n, "defaultargs")) {
              +	Replaceall(w->code, "$symname", symname);
               	Wrapper_print(w, f_directors);
               	Printv(f_directors_h, declaration, NIL);
               	Printv(f_directors_h, inline_extra_method, NIL);
              
              From 91c4eeaa53019dd22cf3a1f790c007fe56248f6f Mon Sep 17 00:00:00 2001
              From: William S Fulton 
              Date: Fri, 5 Aug 2011 06:43:35 +0000
              Subject: [PATCH 037/147] Add in clarification of the memmove function's
               parameters in the cdata.i library
              
              git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12773 626c5289-ae23-0410-ae9c-e8d60b6d4f22
              ---
               Doc/Manual/Library.html | 8 ++++++--
               1 file changed, 6 insertions(+), 2 deletions(-)
              
              diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html
              index 02b8e53bd..dcec21c90 100644
              --- a/Doc/Manual/Library.html
              +++ b/Doc/Manual/Library.html
              @@ -682,8 +682,12 @@ pointer.
               
               

              Copies all of the string data in s into the memory pointed to by -ptr. The string may contain embedded NULL bytes. The length of -the string is implicitly determined in the underlying wrapper code. +ptr. The string may contain embedded NULL bytes. +This is actually a wrapper to the standard C library memmove function, which is +declared as +void memmove(void *ptr, const void *src, size_t n). +The src and length n parameters are +extracted from the language specific string s in the underlying wrapper code.

              From dae94579621dd1de80327f24195f056fae9b8b7d Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Mon, 8 Aug 2011 21:41:34 +0000 Subject: [PATCH 038/147] Octave patches for 3.4.0 compatibility, etc. (sf 3387394, thanks for Karl Wette) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12774 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 10 ++++++++++ Examples/octave/callback/Makefile | 1 + Examples/octave/class/Makefile | 1 + Examples/octave/constants/Makefile | 1 + Examples/octave/contract/Makefile | 1 + Examples/octave/enum/Makefile | 1 + Examples/octave/extend/Makefile | 1 + Examples/octave/funcptr/Makefile | 1 + Examples/octave/funcptr2/Makefile | 1 + Examples/octave/functor/Makefile | 1 + Examples/octave/operator/Makefile | 1 + Examples/octave/operator/example.i | 4 ++-- Examples/octave/operator/runme.m | 16 ++++++++-------- Examples/octave/pointer/Makefile | 1 + Examples/octave/reference/Makefile | 1 + Examples/octave/simple/Makefile | 1 + Examples/octave/template/Makefile | 1 + Examples/octave/variables/Makefile | 1 + Lib/octave/octrun.swg | 7 +++++++ configure.in | 13 +++++++------ 20 files changed, 49 insertions(+), 16 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 3b0a86ec4..28f1fa994 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -333,6 +333,7 @@ python_clean: # Make sure these locate your Octave installation OCTAVE_INCLUDE= $(DEFS) @OCTAVEEXT@ OCTAVE_LIB = +OCTAVE = @OCTAVE@ # Extra Octave specific dynamic linking options OCTAVE_DLNK = @OCTAVEDYNAMICLINKING@ @@ -358,6 +359,15 @@ octave_cpp: $(SRCS) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE) $(CXXSHARED) -g $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) +# ----------------------------------------------------------------- +# Running an Octave example +# ----------------------------------------------------------------- + +OCTSCRIPT = runme.m + +octave_run: $(OCTSCRIPT) + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVEPATH=$(srcdir):$$OCTAVEPATH $(OCTAVE) $(OCTSCRIPT) >/dev/null + # ----------------------------------------------------------------- # Cleaning the octave examples # ----------------------------------------------------------------- diff --git a/Examples/octave/callback/Makefile b/Examples/octave/callback/Makefile index 2bce9df5d..21fb21137 100644 --- a/Examples/octave/callback/Makefile +++ b/Examples/octave/callback/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/class/Makefile b/Examples/octave/class/Makefile index 2bce9df5d..21fb21137 100644 --- a/Examples/octave/class/Makefile +++ b/Examples/octave/class/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/constants/Makefile b/Examples/octave/constants/Makefile index 4d80c6f19..3156eae84 100644 --- a/Examples/octave/constants/Makefile +++ b/Examples/octave/constants/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/contract/Makefile b/Examples/octave/contract/Makefile index 627b0a977..464b74122 100644 --- a/Examples/octave/contract/Makefile +++ b/Examples/octave/contract/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/enum/Makefile b/Examples/octave/enum/Makefile index 2bce9df5d..21fb21137 100644 --- a/Examples/octave/enum/Makefile +++ b/Examples/octave/enum/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/extend/Makefile b/Examples/octave/extend/Makefile index 2bce9df5d..21fb21137 100644 --- a/Examples/octave/extend/Makefile +++ b/Examples/octave/extend/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/funcptr/Makefile b/Examples/octave/funcptr/Makefile index 627b0a977..464b74122 100644 --- a/Examples/octave/funcptr/Makefile +++ b/Examples/octave/funcptr/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/funcptr2/Makefile b/Examples/octave/funcptr2/Makefile index 627b0a977..464b74122 100644 --- a/Examples/octave/funcptr2/Makefile +++ b/Examples/octave/funcptr2/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/functor/Makefile b/Examples/octave/functor/Makefile index d910de530..8f6dfc73e 100644 --- a/Examples/octave/functor/Makefile +++ b/Examples/octave/functor/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/operator/Makefile b/Examples/octave/operator/Makefile index 6e625d538..de818a41a 100644 --- a/Examples/octave/operator/Makefile +++ b/Examples/octave/operator/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).m check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/operator/example.i b/Examples/octave/operator/example.i index d4bba5c53..ccb2029bc 100644 --- a/Examples/octave/operator/example.i +++ b/Examples/octave/operator/example.i @@ -10,13 +10,13 @@ /* An output method that turns a complex into a short string */ %extend ComplexVal { - char *__str() { + char *__str__() { static char temp[512]; sprintf(temp,"(%g,%g)", $self->re(), $self->im()); return temp; } - ComplexVal __paren(int j) { + ComplexVal __paren__(int j) { return ComplexVal($self->re()*j,$self->im()*j); } }; diff --git a/Examples/octave/operator/runme.m b/Examples/octave/operator/runme.m index e0f590694..2a4168660 100644 --- a/Examples/octave/operator/runme.m +++ b/Examples/octave/operator/runme.m @@ -4,21 +4,21 @@ example a = example.ComplexVal(2,3); b = example.ComplexVal(-5,10); -printf("a = %s\n",a); -printf("b = %s\n",b); +printf("a = %s\n",disp(a)); +printf("b = %s\n",disp(b)); c = a + b; -printf("c = %s\n",c); -printf("a*b = %s\n",a*b); -printf("a-c = %s\n",a-c); +printf("c = %s\n",disp(c)); +printf("a*b = %s\n",disp(a*b)); +printf("a-c = %s\n",disp(a-c)); e = example.ComplexVal(a-c); -printf("e = %s\n",e); +printf("e = %s\n",disp(e)); # Big expression f = ((a+b)*(c+b*e)) + (-a); -printf("f = %s\n",f); +printf("f = %s\n",disp(f)); # paren overloading -printf("a(3)= %s\n",a(3)); +printf("a(3)= %s\n",disp(a(3))); diff --git a/Examples/octave/pointer/Makefile b/Examples/octave/pointer/Makefile index 627b0a977..464b74122 100644 --- a/Examples/octave/pointer/Makefile +++ b/Examples/octave/pointer/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/reference/Makefile b/Examples/octave/reference/Makefile index 2bce9df5d..21fb21137 100644 --- a/Examples/octave/reference/Makefile +++ b/Examples/octave/reference/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/simple/Makefile b/Examples/octave/simple/Makefile index 627b0a977..464b74122 100644 --- a/Examples/octave/simple/Makefile +++ b/Examples/octave/simple/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/template/Makefile b/Examples/octave/template/Makefile index 3d7445a66..d64487430 100644 --- a/Examples/octave/template/Makefile +++ b/Examples/octave/template/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/variables/Makefile b/Examples/octave/variables/Makefile index 627b0a977..464b74122 100644 --- a/Examples/octave/variables/Makefile +++ b/Examples/octave/variables/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 49b032fc9..2c36bc043 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -399,6 +399,10 @@ namespace Swig { Swig::erase_rtdir(types[j].second.ptr); } + dim_vector dims(void) const { + return dim_vector(1,1); + } + octave_value as_value() { ++count; return Swig::swig_value_ref(this); @@ -928,6 +932,9 @@ namespace Swig { octave_base_value *empty_clone() const { return new octave_swig_ref(0); } + dim_vector dims(void) const + { return ptr->dims(); } + bool is_defined() const { return ptr->is_defined(); } diff --git a/configure.in b/configure.in index 1953e19ee..e960d1abc 100644 --- a/configure.in +++ b/configure.in @@ -923,19 +923,20 @@ fi AC_MSG_CHECKING(for Octave header files) if test -n "$OCTAVE"; then - OCTAVEDIR="/usr/include" + OCTAVECONFIG=[`echo $OCTAVEBIN | sed 's|octave\([^/]*\)$|octave-config\1|'`] + if test -r "$OCTAVECONFIG"; then + OCTAVEDIR=`$OCTAVECONFIG -p OCTINCLUDEDIR | sed 's|/octave$||'` + else + OCTAVEDIR="/usr/include" + fi if test "$OCTAVEDIR" != ""; then - dirs="$OCTAVEDIR" + dirs="$OCTAVEDIR/octave $OCTAVEDIR" OCTAVEEXT="" for i in $dirs; do if test -r $i/octave/oct.h; then OCTAVEEXT="$i" break; fi - if test -r $i/octave/octave/oct.h; then - OCTAVEEXT="$i/octave" - break; - fi done if test "$OCTAVEEXT" = "" ; then AC_MSG_RESULT(not found) From 95cd530c8f5976fa34253981e2d4482b0d7e532b Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Tue, 9 Aug 2011 17:30:51 +0000 Subject: [PATCH 039/147] add CHANGES.current entry for sf 3387394 patches git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12775 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 13fb61b2c..cda081fd0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-08-09: xavier98 + Fix bug 3387394; Octave patches for 3.4.0 compatibility, etc. (from Karl Wette) + 2011-08-04: wsfulton Add in $symname expansion for director methods. From d0081ebb82f0822453bb60bbe124fb4c17c6f200 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Aug 2011 00:36:12 +0000 Subject: [PATCH 040/147] %shared_ptr fixes when the type is a template using template parameters that are typedef'd to another type. Also fixed %shared_ptr when the template parameter has a default value. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12776 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + .../li_boost_shared_ptr_template_runme.java | 49 +++++++++ .../test-suite/li_boost_shared_ptr_template.i | 99 +++++++++++++++++++ .../li_boost_shared_ptr_template_runme.py | 28 ++++++ Source/Modules/typepass.cxx | 91 ++++++++++------- 5 files changed, 231 insertions(+), 37 deletions(-) create mode 100644 Examples/test-suite/java/li_boost_shared_ptr_template_runme.java create mode 100644 Examples/test-suite/li_boost_shared_ptr_template.i create mode 100644 Examples/test-suite/python/li_boost_shared_ptr_template_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index c007588ef..e86c0fb65 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -227,6 +227,7 @@ CPP_TEST_CASES += \ li_attribute \ li_boost_shared_ptr \ li_boost_shared_ptr_bits \ + li_boost_shared_ptr_template \ li_carrays \ li_cdata \ li_cpointer \ diff --git a/Examples/test-suite/java/li_boost_shared_ptr_template_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_template_runme.java new file mode 100644 index 000000000..35f517a53 --- /dev/null +++ b/Examples/test-suite/java/li_boost_shared_ptr_template_runme.java @@ -0,0 +1,49 @@ + + +import li_boost_shared_ptr_template.*; + +public class li_boost_shared_ptr_template_runme { + + static { + try { + System.loadLibrary("li_boost_shared_ptr_template"); + } 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[]) { + { + BaseINTEGER b = new BaseINTEGER(); + DerivedINTEGER d = new DerivedINTEGER(); + if (b.bar() != 1) + throw new RuntimeException("test 1"); + if (d.bar() != 2) + throw new RuntimeException("test 2"); + if (li_boost_shared_ptr_template.bar_getter(b) != 1) + throw new RuntimeException("test 3"); + if (li_boost_shared_ptr_template.bar_getter(d) != 2) + throw new RuntimeException("test 4"); + } + + { + BaseDefaultInt b = new BaseDefaultInt(); + DerivedDefaultInt d = new DerivedDefaultInt(); + DerivedDefaultInt2 d2 = new DerivedDefaultInt2(); + if (b.bar2() != 3) + throw new RuntimeException("test 5"); + if (d.bar2() != 4) + throw new RuntimeException("test 6"); + if (d2.bar2() != 4) + throw new RuntimeException("test 6"); + if (li_boost_shared_ptr_template.bar2_getter(b) != 3) + throw new RuntimeException("test 7"); + if (li_boost_shared_ptr_template.bar2_getter(d) != 4) + throw new RuntimeException("test 8"); + if (li_boost_shared_ptr_template.bar2_getter(d2) != 4) + throw new RuntimeException("test 8"); + } + } +} + diff --git a/Examples/test-suite/li_boost_shared_ptr_template.i b/Examples/test-suite/li_boost_shared_ptr_template.i new file mode 100644 index 000000000..62086c99d --- /dev/null +++ b/Examples/test-suite/li_boost_shared_ptr_template.i @@ -0,0 +1,99 @@ +%module li_boost_shared_ptr_template + +// First test- Bug 3333549 - using INTEGER typedef in %shared_ptr before typedef defined +%{ +#include + + typedef int INTEGER; + + template + class Base { + public: + virtual T bar() {return 1;} + }; + + template + class Derived : public Base { + public: + virtual T bar() {return 2;} + }; + + INTEGER bar_getter(Base& foo) { + return foo.bar(); + } + +%} + +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) +#define SHARED_PTR_WRAPPERS_IMPLEMENTED +#endif + +#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) + +%include +%shared_ptr(Base) +%shared_ptr(Derived) + +#endif + +typedef int INTEGER; + +template +class Base { + public: + virtual T bar() {return 1;} +}; + +template +class Derived : public Base { + public: + virtual T bar() {return 2;} +}; + +INTEGER bar_getter(Base& foo) { + return foo.bar(); +} + +%template(BaseINTEGER) Base; +%template(DerivedINTEGER) Derived; + + +// 2nd test - templates with default template parameters +#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) + +%shared_ptr(Space::BaseDefault) +%shared_ptr(Space::DerivedDefault) +%shared_ptr(Space::DerivedDefault2) + +#endif + +%inline %{ +namespace Space { +typedef int INT_TYPEDEF; +template +class BaseDefault { + public: + virtual T bar2() {return 3;} +}; + +template +class DerivedDefault : public BaseDefault { + public: + virtual T bar2() {return 4;} +}; +template +class DerivedDefault2 : public BaseDefault { + public: + virtual int bar2() {return 4;} +}; + +int bar2_getter(BaseDefault& foo) { + return foo.bar2(); +} +} +%} + +%template(BaseDefaultInt) Space::BaseDefault; +%template(DerivedDefaultInt) Space::DerivedDefault; +%template(DerivedDefaultInt2) Space::DerivedDefault2; + diff --git a/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py new file mode 100644 index 000000000..20e7a8060 --- /dev/null +++ b/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py @@ -0,0 +1,28 @@ +from li_boost_shared_ptr_template import * + +b = BaseINTEGER() +d = DerivedINTEGER() +if b.bar() != 1: + raise RuntimeError +if d.bar() != 2: + raise RuntimeError +if bar_getter(b) != 1: + raise RuntimeError +if bar_getter(d) != 2: + raise RuntimeError + +b = BaseDefaultInt() +d = DerivedDefaultInt() +d2 = DerivedDefaultInt2() +if b.bar2() != 3: + raise RuntimeError +if d.bar2() != 4: + raise RuntimeError +if d2.bar2() != 4: + raise RuntimeError +if bar2_getter(b) != 3: + raise RuntimeError +if bar2_getter(d) != 4: + raise RuntimeError +if bar2_getter(d2) != 4: + raise RuntimeError diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index 15768f203..575b8e6b2 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -227,51 +227,64 @@ class TypePass:private Dispatcher { for (i = 0; i < len; i++) { Node *n = Getitem(ilist, i); String *bname = Getattr(n, "name"); - Node *bclass = n; /* Getattr(n,"class"); */ + Node *bclass = n; Hash *scopes = Getattr(bclass, "typescope"); SwigType_inherit(clsname, bname, cast, 0); - String *smartptr = Getattr(first, "feature:smartptr"); - if (smartptr) { - SwigType *smart = 0; - SwigType *spt = Swig_cparse_type(smartptr); - if (spt) { - smart = SwigType_typedef_resolve_all(spt); - Delete(spt); - /* Record a (fake) inheritance relationship between smart pointer - and smart pointer to base class, so that smart pointer upcasts - are automatically generated. */ - SwigType *bsmart = Copy(smart); - SwigType *rclsname = SwigType_typedef_resolve_all(clsname); - SwigType *rbname = SwigType_typedef_resolve_all(bname); - Replaceall(bsmart, rclsname, rbname); - Delete(rclsname); - Delete(rbname); - String *smartnamestr = SwigType_namestr(smart); - String *bsmartnamestr = SwigType_namestr(bsmart); - /* construct casting code */ - String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr); - Delete(bsmartnamestr); - Delete(smartnamestr); - /* setup inheritance relationship between smart pointer templates */ - SwigType_inherit(smart, bsmart, 0, convcode); - if (!GetFlag(bclass, "feature:smartptr")) - Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name"))); - Delete(convcode); - Delete(bsmart); - Delete(smart); - } else { - Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname)); - } - } else { - if (GetFlag(bclass, "feature:smartptr")) - Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name"))); - } if (!importmode) { String *btype = Copy(bname); SwigType_add_pointer(btype); SwigType_remember(btype); Delete(btype); } + + String *smartptr = Getattr(first, "feature:smartptr"); + String *base_smartptr = Getattr(bclass, "feature:smartptr"); + if (smartptr) { + SwigType *spt = Swig_cparse_type(smartptr); + if (spt) { + if (base_smartptr) { + SwigType *base_spt = Swig_cparse_type(base_smartptr); + if (base_spt) { + /* Record a (fake) inheritance relationship between smart pointer + and smart pointer to base class, so that smart pointer upcasts + are automatically generated. */ + SwigType *smart = SwigType_typedef_resolve_all(spt); + SwigType *bsmart = SwigType_typedef_resolve_all(base_spt); + String *smartnamestr = SwigType_namestr(smart); + String *bsmartnamestr = SwigType_namestr(bsmart); + + /* Construct casting code */ + String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr); + + /* Setup inheritance relationship between smart pointers */ + SwigType_inherit(smart, bsmart, 0, convcode); + if (!importmode) { + String *btype = Copy(bsmart); + SwigType_add_pointer(btype); + SwigType_remember(btype); + Delete(btype); + } + Delete(convcode); + Delete(bsmartnamestr); + Delete(smartnamestr); + Delete(bsmart); + Delete(smart); + Delete(base_spt); + } else { + Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(base_smartptr), SwigType_namestr(bname)); + } + Delete(spt); + } else { + Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name"))); + } + } else { + Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname)); + } + } else { + if (base_smartptr) + Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name"))); + } + if (scopes) { SwigType_inherit_scope(scopes); } @@ -429,6 +442,10 @@ class TypePass:private Dispatcher { } } else { Swig_symbol_cadd(fname, n); + /* needed? + if (template_default_expanded) + Swig_symbol_cadd(template_default_expanded, n); + */ SwigType_typedef_class(fname); scopename = Copy(fname); } From a724cf58f7ac9962fd7762203fc98a0dc7ab8793 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Aug 2011 05:16:39 +0000 Subject: [PATCH 041/147] %shared_ptr fixes when the type is a template using template parameters that are typedef'd to another type. Also fixed %shared_ptr when the template parameter has a default value. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12777 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index cda081fd0..e9d47b54c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,12 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-08-12: wsfulton + SF bug # 3333549 - %shared_ptr fixes when the type is a template using template parameters + that are typedef'd to another type. + + Also fixed %shared_ptr when template parameters have default values. + 2011-08-09: xavier98 Fix bug 3387394; Octave patches for 3.4.0 compatibility, etc. (from Karl Wette) From 3099911397ea5946ab45add77842b77aa4137049 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 17 Aug 2011 21:52:52 +0000 Subject: [PATCH 042/147] some doc typo fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12778 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 4 ++-- Doc/Manual/Java.html | 2 +- Doc/Manual/SWIGPlus.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 6ea2fb72c..d3d68bd53 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -637,7 +637,7 @@ This results in the module class method

              -and intermediate class method +and intermediary class method

              @@ -732,7 +732,7 @@ marshalling is the "unsafe" quantifier, which is required because we are handlin

              -Also the intermediate class method looks a little different from the default marshalling +Also the intermediary class method looks a little different from the default marshalling example - the method is expecting an IntPtr as the parameter type.

              diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 2ae9f7b95..428528403 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -3461,7 +3461,7 @@ void callup(DirectorBase *director) {

              The following DirectorDerived Java class is derived from the Java proxy class DirectorBase and overrides upcall_method(). When C++ code invokes upcall_method(), the SWIG-generated C++ code redirects the call via JNI to the Java DirectorDerived subclass. -Naturally, the SWIG generated C++ code and the generated Java intermediate class marshal and convert arguments between C++ and Java when needed. +Naturally, the SWIG generated C++ code and the generated Java intermediary class marshal and convert arguments between C++ and Java when needed.

              diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index c8e5ee870..97c2e058a 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -3356,7 +3356,7 @@ public:

              In this case, the %extend directive is not needed, and -%template does the exactly same job, i.e., it adds two new +%template does exactly the same job, i.e., it adds two new methods to the Foo class.

              From 61124e61a75f08dad76c2283b0aa2fe68e790302 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Aug 2011 22:18:47 +0000 Subject: [PATCH 043/147] documentation - consistency in shadow/proxy terminology git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12779 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Python.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 165fa94cb..fa312c4f1 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -2153,7 +2153,7 @@ For example:

              where the code passed to the "ref" and "unref" features will be executed as needed whenever a new object is passed to python, or when -python tries to release the shadow object instance, respectively. +python tries to release the proxy object instance, respectively.

              From 932f47a84540ddb103239f3e10c662988b396232 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 22 Aug 2011 19:27:56 +0000 Subject: [PATCH 044/147] SF patch #3394339 from Torsten Landschoff - new option -nomoduleglobal to disable installing the module table into the global namespace. Require call also returns the module table instead of a string git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12780 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 ++++ Doc/Manual/Lua.html | 23 ++++++++++++++++++ Examples/test-suite/lua/Makefile.in | 12 +++++----- .../lua/lua_no_module_global_runme.lua | 24 +++++++++++++++++++ Examples/test-suite/lua_no_module_global.i | 5 ++++ Lib/lua/luarun.swg | 10 +++++++- Lib/lua/luaruntime.swg | 5 ++-- Source/Modules/lua.cxx | 14 +++++++++-- 8 files changed, 87 insertions(+), 11 deletions(-) create mode 100644 Examples/test-suite/lua/lua_no_module_global_runme.lua create mode 100644 Examples/test-suite/lua_no_module_global.i diff --git a/CHANGES.current b/CHANGES.current index e9d47b54c..33bb5b909 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-08-22: wsfulton + [Lua] SF patch #3394339 from Torsten Landschoff - new option -nomoduleglobal to disable installing + the module table into the global namespace. Require call also returns the module table instead + of a string. + 2011-08-12: wsfulton SF bug # 3333549 - %shared_ptr fixes when the type is a template using template parameters that are typedef'd to another type. diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 04f96f2f3..218a9a498 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -105,6 +105,29 @@ 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.

              + +

              25.2.1 Additional command line options

              + +

              +The following table list the additional commandline options available for the Lua module. They can also be seen by using: +

              + +
              +swig -lua -help 
              +
              + + + + + + + + + + + +
              Lua specific options
              -nomoduleglobalDo not register the module name as a global variable but return the module table from calls to require.
              +

              25.2.1 Compiling and Linking and Interpreter

              diff --git a/Examples/test-suite/lua/Makefile.in b/Examples/test-suite/lua/Makefile.in index 0ddc86a7d..d6a6554f4 100644 --- a/Examples/test-suite/lua/Makefile.in +++ b/Examples/test-suite/lua/Makefile.in @@ -11,12 +11,12 @@ top_builddir = @top_builddir@ # sorry, currently very few test cases work/have been written -#CPP_TEST_CASES += \ -# cnum +CPP_TEST_CASES += \ + lua_no_module_global \ -#C_TEST_CASES += \ -# file_test \ -# nondynamic + +C_TEST_CASES += \ + lua_no_module_global \ include $(srcdir)/../common.mk @@ -25,7 +25,7 @@ include $(srcdir)/../common.mk LIBS = -L. # Custom tests - tests with additional commandline options -# none! +lua_no_module_global.%: SWIGOPT += -nomoduleglobal # Rules for the different types of tests %.cpptest: diff --git a/Examples/test-suite/lua/lua_no_module_global_runme.lua b/Examples/test-suite/lua/lua_no_module_global_runme.lua new file mode 100644 index 000000000..9eb436c3f --- /dev/null +++ b/Examples/test-suite/lua/lua_no_module_global_runme.lua @@ -0,0 +1,24 @@ +-- require is only available in Lua 5.1 + +if string.sub(_VERSION,1,7)=='Lua 5.1' then + + -- Initially the package should not be loaded + assert(package.loaded["lua_no_module_global"] == nil) + + -- Load the module + the_module = require "lua_no_module_global" + + -- require should return the module table + assert(the_module.hi_mom ~= nil) + assert(the_module.hi_mom() == "hi mom!") + + -- But it should not end up in the global table _G, subject to + -- the -nomoduleglobal swig option. + assert(_G["lua_no_module_global"] == nil) + + -- According to the Lua 5.1 reference manual, require should also + -- store the module table into package.loaded["name"] + assert(package.loaded["lua_no_module_global"] == the_module) + assert(package.loaded["lua_no_module_global"].hi_mom() == "hi mom!") + +end diff --git a/Examples/test-suite/lua_no_module_global.i b/Examples/test-suite/lua_no_module_global.i new file mode 100644 index 000000000..7f71788f5 --- /dev/null +++ b/Examples/test-suite/lua_no_module_global.i @@ -0,0 +1,5 @@ +%module lua_no_module_global +%{ + const char *hi_mom() { return "hi mom!"; } +%} +const char *hi_mom(); diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 89b762637..1810e9895 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -237,7 +237,7 @@ SWIGINTERN int SWIG_Lua_module_set(lua_State* L) return 0; } -/* registering a module in lua */ +/* registering a module in lua. Pushes the module table on the stack. */ SWIGINTERN void SWIG_Lua_module_begin(lua_State* L,const char* name) { assert(lua_istable(L,-1)); /* just in case */ @@ -254,8 +254,16 @@ SWIGINTERN void SWIG_Lua_module_begin(lua_State* L,const char* name) lua_newtable(L); /* the .set table */ lua_rawset(L,-3); /* add .set into metatable */ lua_setmetatable(L,-2); /* sets meta table in module */ +#ifdef SWIG_LUA_MODULE_GLOBAL + /* If requested, install the module directly into the global namespace. */ lua_rawset(L,-3); /* add module into parent */ SWIG_Lua_get_table(L,name); /* get the table back out */ +#else + /* Do not install the module table as global name. The stack top has + the module table with the name below. We pop the top and replace + the name with it. */ + lua_replace(L,-2); +#endif } /* ending the register */ diff --git a/Lib/lua/luaruntime.swg b/Lib/lua/luaruntime.swg index 5823d4fcf..e28644510 100644 --- a/Lib/lua/luaruntime.swg +++ b/Lib/lua/luaruntime.swg @@ -59,8 +59,9 @@ SWIGEXPORT int SWIG_init(lua_State* L) /* invoke user-specific initialization */ SWIG_init_user(L); /* end module */ - lua_pop(L,1); /* tidy stack (remove module table)*/ - lua_pop(L,1); /* tidy stack (remove global table)*/ + /* Note: We do not clean up the stack here (Lua will do this for us). At this + point, we have the globals table and out module table on the stack. Returning + one value makes the module table the result of the require command. */ return 1; } diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index c38ffdae9..9b4bb6ee3 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -83,10 +83,11 @@ void display_mapping(DOH *d) { NEW LANGUAGE NOTE:END ************************************************/ static const char *usage = (char *) "\ Lua Options (available with -lua)\n\ - [no additional options]\n\ + -nomoduleglobal - Do not register the module name as a global variable \n\ + but return the module table from calls to require.\n\ \n"; - +static int nomoduleglobal = 0; /* NEW LANGUAGE NOTE:*********************************************** To add a new language, you need to derive your class from @@ -172,6 +173,9 @@ public: if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { // usage flags fputs(usage, stdout); + } else if (strcmp(argv[i], "-nomoduleglobal") == 0) { + nomoduleglobal = 1; + Swig_mark_arg(i); } } } @@ -263,6 +267,12 @@ public: Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGLUA\n"); + if (nomoduleglobal) { + Printf(f_runtime, "#define SWIG_LUA_NO_MODULE_GLOBAL\n"); + } else { + Printf(f_runtime, "#define SWIG_LUA_MODULE_GLOBAL\n"); + } + // if (NoInclude) { // Printf(f_runtime, "#define SWIG_NOINCLUDE\n"); // } From e82f320510ba4a0742ee4bb0de1cfd609122bad0 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 22 Aug 2011 20:04:06 +0000 Subject: [PATCH 045/147] Run gofmt on hand written Go code. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12781 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/go/extend/runme.go | 1 - Examples/test-suite/go/director_basic_runme.go | 1 - Examples/test-suite/go/overload_template_fast_runme.go | 1 - Examples/test-suite/go/overload_template_runme.go | 2 -- Examples/test-suite/go/template_default_arg_runme.go | 1 - Examples/test-suite/go/virtual_poly_runme.go | 1 - 6 files changed, 7 deletions(-) diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go index 796c5ce68..187f1ce08 100644 --- a/Examples/go/extend/runme.go +++ b/Examples/go/extend/runme.go @@ -24,7 +24,6 @@ func main() { fmt.Println("Just call her \"", e.GetTitle(), "\"") fmt.Println("----------------------") - // Create a new EmployeeList instance. This class does not // have a C++ director wrapper, but can be used freely with // other classes that do. diff --git a/Examples/test-suite/go/director_basic_runme.go b/Examples/test-suite/go/director_basic_runme.go index 1995452ce..0ce780bbd 100644 --- a/Examples/test-suite/go/director_basic_runme.go +++ b/Examples/test-suite/go/director_basic_runme.go @@ -107,7 +107,6 @@ func f3() { p2.Vmethod(bc) } - func main() { f1() f2() diff --git a/Examples/test-suite/go/overload_template_fast_runme.go b/Examples/test-suite/go/overload_template_fast_runme.go index 4ecf4157a..b80cb7dd4 100644 --- a/Examples/test-suite/go/overload_template_fast_runme.go +++ b/Examples/test-suite/go/overload_template_fast_runme.go @@ -143,7 +143,6 @@ func main() { panic("overload(const char *)") } - // everything put in a namespace if Nsoverload("hi") != 1000 { panic("nsoverload()") diff --git a/Examples/test-suite/go/overload_template_runme.go b/Examples/test-suite/go/overload_template_runme.go index 279e43de6..53e1def1b 100644 --- a/Examples/test-suite/go/overload_template_runme.go +++ b/Examples/test-suite/go/overload_template_runme.go @@ -100,7 +100,6 @@ func main() { panic("specialization(const char *, const char *)") } - // simple specialization Xyz() Xyz_int() @@ -144,7 +143,6 @@ func main() { panic("overload(const char *)") } - // everything put in a namespace if Nsoverload("hi") != 1000 { panic("nsoverload()") diff --git a/Examples/test-suite/go/template_default_arg_runme.go b/Examples/test-suite/go/template_default_arg_runme.go index 18412cd89..3d9346b05 100644 --- a/Examples/test-suite/go/template_default_arg_runme.go +++ b/Examples/test-suite/go/template_default_arg_runme.go @@ -49,7 +49,6 @@ func main() { xz := template_default_arg.NewX_Foo_Z_8() _ = xz.Meth(fz) - // Templated functions // plain function: int ott(Foo) diff --git a/Examples/test-suite/go/virtual_poly_runme.go b/Examples/test-suite/go/virtual_poly_runme.go index 7048ba8cf..487b371ba 100644 --- a/Examples/test-suite/go/virtual_poly_runme.go +++ b/Examples/test-suite/go/virtual_poly_runme.go @@ -29,7 +29,6 @@ func main() { panic(0) } - // 'narrowing' also works ddc := virtual_poly.NDoubleNarrow(d.Nnumber()) if d.Get() != ddc.Get() { From 86e1051a8b9fefc163e0ac3b40369df76912e797 Mon Sep 17 00:00:00 2001 From: Stefan Zager Date: Mon, 22 Aug 2011 23:33:17 +0000 Subject: [PATCH 046/147] Fixed memory leak with --builtin (bug 3385089) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12782 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/python/builtin.swg | 1 + 2 files changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 33bb5b909..35010d273 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-08-22: szager + [python] Fixed memory leak with --builtin option (bug 3385089). + 2011-08-22: wsfulton [Lua] SF patch #3394339 from Torsten Landschoff - new option -nomoduleglobal to disable installing the module table into the global namespace. Require call also returns the module table instead diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index d8164777f..1fc3fb05f 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -13,6 +13,7 @@ wrapper##_closure(PyObject *a) { \ PyObject *o = wrapper(a, NULL); \ Py_XDECREF(o); \ } \ + PyObject_Del(a); \ } #define SWIGPY_INQUIRY_CLOSURE(wrapper) \ From c794d08597e6f0c0b54cd70438f3374ccff43201 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 Aug 2011 19:29:10 +0000 Subject: [PATCH 047/147] Fix %newobject when used in conjunction with %feature(ref). The code from the ref feature was not always being generated for the function specified by %newobject. Documentation for ref and unref moved from Python to the C++ chapter. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12783 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 + Doc/Manual/Customization.html | 5 + Doc/Manual/Python.html | 144 +-------------- Doc/Manual/SWIGPlus.html | 174 +++++++++++++++++++ Examples/test-suite/python/refcount_runme.py | 33 +++- Examples/test-suite/refcount.i | 23 ++- Source/Swig/cwrap.c | 22 +-- Source/Swig/typemap.c | 16 +- 8 files changed, 262 insertions(+), 160 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 35010d273..b59952e27 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-08-23: wsfulton + Fix %newobject when used in conjunction with %feature("ref") as reported by Jan Becker. The + code from the "ref" feature was not always being generated for the function specified by %newobject. + Documentation for "ref" and "unref" moved from Python to the C++ chapter. + 2011-08-22: szager [python] Fixed memory leak with --builtin option (bug 3385089). diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 7f164ac57..b98fbfc88 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -704,6 +704,11 @@ depends on the target language on implementing the 'disown' mechanism properly.

              +

              +The use of %newobject is also integrated with reference counting and is covered in the +C++ reference counted objects section. +

              +

              Compatibility note: Previous versions of SWIG had a special %new directive. However, unlike %newobject, it only applied to the next declaration. For example: diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index fa312c4f1..78e1fbeed 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -38,7 +38,7 @@

            • C++ namespaces
            • C++ templates
            • C++ Smart Pointers -
            • C++ Reference Counted Objects (ref/unref) +
            • C++ reference counted objects
          • Further details on the Python class interface

            14.9.6 Language module specific (700-899)

            diff --git a/Examples/test-suite/errors/cpp_extend_destructors.i b/Examples/test-suite/errors/cpp_extend_destructors.i new file mode 100644 index 000000000..56b46f9c9 --- /dev/null +++ b/Examples/test-suite/errors/cpp_extend_destructors.i @@ -0,0 +1,104 @@ +%module xxx + +///////////////////////////// +%extend AStruct { + ~AStruct() {} +} +struct AStruct { + ~AStruct() {} +}; + +///////////////////////////// +struct BStruct { + ~BStruct() {} + ~BStruct() {} +}; + +///////////////////////////// +struct CStruct { +}; + +%extend CStruct { + ~NOT_CStruct() { + delete $self; + } +} + +%extend DStruct { + ~NOT_DStruct() { + delete $self; + } +} + +struct DStruct { +}; + +///////////////////////////// +struct EStruct { + ~EStruct() {} +}; + +%extend EStruct { + ~NOT_EStruct() { + delete $self; + } +} + +%extend FStruct { + ~NOT_FStruct() { + delete $self; + } +} + +struct FStruct { + ~FStruct() {} +}; + +///////////////////////////// +struct GStruct { +}; + +%extend GStruct { + ~GStruct() {} + ~NOT_GStruct() { + delete $self; + } +} + +%extend HStruct { + ~HStruct() {} + ~NOT_HStruct() { + delete $self; + } +} + +struct HStruct { +}; + +///////////////////////////// +struct IStruct { + ~IStruct() {} + ~NOT_IStruct() {} +}; + +struct JStruct { + ~JStruct() {} + ~NOT_JStruct() {} + ~JStruct() {} +}; + +///////////////////////////// +struct KStruct { + ~NOT_KStruct() {} +}; + +///////////////////////////// +template +struct LStruct { + ~LStruct() {} + ~NOT_LStruct() {} + ~LStruct() {} +}; +%template(LStructInt) LStruct; +%template(LStructShort) LStruct; + diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log index 9e4052bea..2779469ca 100644 --- a/Examples/test-suite/errors/expected.log +++ b/Examples/test-suite/errors/expected.log @@ -209,6 +209,27 @@ Doc/Manual/Typemaps.html for complete details. cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL". cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL". +:::::::::::::::::::::::::::::::: cpp_extend_destructors.i ::::::::::::::::::::::::::::::::::: +cpp_extend_destructors.i:8: Warning 302: Identifier '~AStruct' redefined by %extend (ignored), +cpp_extend_destructors.i:5: Warning 302: %extend definition of '~AStruct'. +cpp_extend_destructors.i:14: Warning 302: Identifier '~BStruct' redefined (ignored), +cpp_extend_destructors.i:13: Warning 302: previous definition of '~BStruct'. +cpp_extend_destructors.i:87: Warning 302: Identifier '~JStruct' redefined (ignored), +cpp_extend_destructors.i:85: Warning 302: previous definition of '~JStruct'. +cpp_extend_destructors.i:100: Warning 302: Identifier '~LStruct' redefined (ignored), +cpp_extend_destructors.i:98: Warning 302: previous definition of '~LStruct'. +cpp_extend_destructors.i:24: Warning 521: Illegal destructor name ~NOT_CStruct. Ignored. +cpp_extend_destructors.i:30: Warning 521: Illegal destructor name ~NOT_DStruct. Ignored. +cpp_extend_destructors.i:44: Warning 521: Illegal destructor name ~NOT_EStruct. Ignored. +cpp_extend_destructors.i:50: Warning 521: Illegal destructor name ~NOT_FStruct. Ignored. +cpp_extend_destructors.i:65: Warning 521: Illegal destructor name ~NOT_GStruct. Ignored. +cpp_extend_destructors.i:72: Warning 521: Illegal destructor name ~NOT_HStruct. Ignored. +cpp_extend_destructors.i:81: Warning 521: Illegal destructor name ~NOT_IStruct. Ignored. +cpp_extend_destructors.i:86: Warning 521: Illegal destructor name ~NOT_JStruct. Ignored. +cpp_extend_destructors.i:92: Warning 521: Illegal destructor name ~NOT_KStruct. Ignored. +cpp_extend_destructors.i:99: Warning 521: Illegal destructor name ~NOT_LStruct< int >. Ignored. +cpp_extend_destructors.i:99: Warning 521: Illegal destructor name ~NOT_LStruct< short >. Ignored. + :::::::::::::::::::::::::::::::: cpp_extend_redefine.i ::::::::::::::::::::::::::::::::::: cpp_extend_redefine.i:9: Warning 302: Identifier 'bar' redefined by %extend (ignored), cpp_extend_redefine.i:5: Warning 302: %extend definition of 'bar'. diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh index 009b581c1..44d58a344 100755 --- a/Examples/test-suite/errors/make.sh +++ b/Examples/test-suite/errors/make.sh @@ -63,6 +63,7 @@ swig_typemap_old # Files run in C++ mode CPPFILES=' cpp_bad_extern +cpp_extend_destructors cpp_extend_redefine cpp_extend_undefined cpp_inline_namespace diff --git a/Examples/test-suite/extend_constructor_destructor.i b/Examples/test-suite/extend_constructor_destructor.i index dbb47245d..08a9dc2bf 100644 --- a/Examples/test-suite/extend_constructor_destructor.i +++ b/Examples/test-suite/extend_constructor_destructor.i @@ -20,20 +20,21 @@ namespace Space { typedef struct { int ivar; } DStruct; + } typedef struct tagEStruct { int ivar; } EStruct; +namespace Space { + template + struct FFStruct { + int ivar; + }; +} %} -%extend Junk { -void thingy() {} -} -%inline %{ -struct Junk {}; -%} namespace Space { %extend tagAStruct { @@ -103,3 +104,22 @@ namespace Space { } } +namespace Space { +%extend FFStruct { + FFStruct(int ivar0) { + Space::FFStruct *s = new Space::FFStruct(); + s->ivar = ivar0; + global = ivar0; + return s; + } + ~FFStruct() { + global = -$self->ivar; + delete $self; + } +} + +} + +%template(FStruct) Space::FFStruct; +%template(GStruct) Space::FFStruct; + diff --git a/Examples/test-suite/java/extend_constructor_destructor_runme.java b/Examples/test-suite/java/extend_constructor_destructor_runme.java index 270bc17e1..de1515839 100644 --- a/Examples/test-suite/java/extend_constructor_destructor_runme.java +++ b/Examples/test-suite/java/extend_constructor_destructor_runme.java @@ -20,6 +20,12 @@ public class extend_constructor_destructor_runme { checkGlobal(30); DStruct d = new DStruct(40); checkGlobal(40); + EStruct e = new EStruct(50); + checkGlobal(50); + FStruct f = new FStruct(60); + checkGlobal(60); + GStruct g = new GStruct(70); + checkGlobal(70); a.delete(); checkGlobal(-10); @@ -29,6 +35,12 @@ public class extend_constructor_destructor_runme { checkGlobal(-30); d.delete(); checkGlobal(-40); + e.delete(); + checkGlobal(-50); + f.delete(); + checkGlobal(-60); + g.delete(); + checkGlobal(-70); } public static void checkGlobal(int val) { diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 9f1df25d2..1aae86fdd 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -195,6 +195,7 @@ #define WARN_LANG_PORTABILITY_FILENAME 518 #define WARN_LANG_TEMPLATE_METHOD_IGNORE 519 #define WARN_LANG_SMARTPTR_MISSING 520 +#define WARN_LANG_ILLEGAL_DESTRUCTOR 521 /* -- Reserved (600-799) -- */ diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx index 563680a10..81a732638 100644 --- a/Source/Modules/allocate.cxx +++ b/Source/Modules/allocate.cxx @@ -936,6 +936,9 @@ Allocate(): } else if (cplus_mode == PROTECTED) { Setattr(inclass, "allocate:default_base_destructor", "1"); } + } else { + Setattr(inclass, "allocate:has_destructor", "1"); + Setattr(inclass, "allocate:default_destructor", "1"); } return SWIG_OK; } diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 44a9d2edc..0fc214694 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2609,17 +2609,18 @@ int Language::constructorDeclaration(Node *n) { } } } else { - if (name && (!Equal(Swig_scopename_last(name), Swig_scopename_last(ClassName))) && !(Getattr(n, "template"))) { - bool illegal_method = true; + String *expected_name = ClassName; + if (name && (!Equal(Swig_scopename_last(name), Swig_scopename_last(expected_name))) && !(Getattr(n, "template"))) { + bool illegal_name = true; if (Extend) { // SWIG extension - allow typedef names as constructor name in %extend - an unnamed struct declared with a typedef can thus be given a 'constructor'. SwigType *name_resolved = SwigType_typedef_resolve_all(name); - SwigType *classname_resolved = SwigType_typedef_resolve_all(ClassName); - illegal_method = !Equal(name_resolved, classname_resolved); + SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name); + illegal_name = !Equal(name_resolved, expected_name_resolved); Delete(name_resolved); - Delete(classname_resolved); + Delete(expected_name_resolved); } - if (illegal_method) { + if (illegal_name) { Swig_warning(WARN_LANG_RETURN_TYPE, input_file, line_number, "Function %s must have a return type. Ignored.\n", SwigType_namestr(name)); Swig_restore(n); return SWIG_NOWRAP; @@ -2727,24 +2728,12 @@ int Language::destructorDeclaration(Node *n) { if (ImportMode) return SWIG_NOWRAP; - if (Extend) { - /* extend destructor can be safely ignored if there is already one */ - if (Getattr(CurrentClass, "has_destructor")) { - return SWIG_NOWRAP; - } - } - Swig_save("destructorDeclaration", n, "name", "sym:name", NIL); - char *c = GetChar(n, "name"); - if (c && (*c == '~')) - Setattr(n, "name", c + 1); - - c = GetChar(n, "sym:name"); - if (c && (*c == '~')) + char *c = GetChar(n, "sym:name"); + if (c && (*c == '~')) { Setattr(n, "sym:name", c + 1); - - /* Name adjustment for %name */ + } String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); @@ -2753,10 +2742,33 @@ int Language::destructorDeclaration(Node *n) { Setattr(n, "sym:name", ClassPrefix); } + String *expected_name = NewString(ClassName); + Replace(expected_name, "~", "", DOH_REPLACE_FIRST); + String *actual_name = NewString(name); + Replace(actual_name, "~", "", DOH_REPLACE_FIRST); + if (name && (!Equal(Swig_scopename_last(actual_name), Swig_scopename_last(expected_name))) && !(Getattr(n, "template"))) { + bool illegal_name = true; + if (Extend) { + // SWIG extension - allow typedef names as destructor name in %extend - an unnamed struct declared with a typedef can thus be given a 'destructor'. + SwigType *name_resolved = SwigType_typedef_resolve_all(actual_name); + SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name); + illegal_name = !Equal(name_resolved, expected_name_resolved); + Delete(name_resolved); + Delete(expected_name_resolved); + } + + if (illegal_name) { + Swig_warning(WARN_LANG_ILLEGAL_DESTRUCTOR, input_file, line_number, "Illegal destructor name %s. Ignored.\n", SwigType_namestr(name)); + Swig_restore(n); + Delete(expected_name); + return SWIG_NOWRAP; + } + } destructorHandler(n); Setattr(CurrentClass, "has_destructor", "1"); Swig_restore(n); + Delete(expected_name); return SWIG_OK; } From c03ae50a0f774fc2886f38c58aa54d937c3dfe6c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Sep 2011 19:00:49 +0000 Subject: [PATCH 061/147] Add boost_intrusive_ptr.i library contribution from #3401571. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12805 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index ab958c625..674d48517 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-09-14: wsfulton + [C#] Add boost_intrusive_ptr.i library contribution from patch #3401571. + 2011-09-13: wsfulton Add warnings for badly named destructors, eg: From b00aafcad064f164bba28e51c92162bada3723c7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Sep 2011 19:01:23 +0000 Subject: [PATCH 062/147] Add boost_intrusive_ptr.i library contribution from #3401571. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12806 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/boost_intrusive_ptr.i | 491 +++++++++++++++++++++++++++++++ 1 file changed, 491 insertions(+) create mode 100644 Lib/csharp/boost_intrusive_ptr.i diff --git a/Lib/csharp/boost_intrusive_ptr.i b/Lib/csharp/boost_intrusive_ptr.i new file mode 100644 index 000000000..66baf3e98 --- /dev/null +++ b/Lib/csharp/boost_intrusive_ptr.i @@ -0,0 +1,491 @@ +%include + +// Language specific macro implementing all the customisations for handling the smart pointer +%define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) + +// %naturalvar is as documented for member variables +%naturalvar TYPE; +%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; + +// destructor wrapper customisation +%feature("unref") TYPE "(void)arg1; delete smartarg1;" + +// Typemap customisations... + +%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + // plain value + argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; + if (!argp) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); + return $null; + } + $1 = *argp; +%} +%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{ + //plain value(out) + $1_ltype* resultp = new $1_ltype(($1_ltype &)$1); + intrusive_ptr_add_ref(resultp); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >()); +%} + +%typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + // plain pointer + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; + $1 = (TYPE *)(smartarg ? smartarg->get() : 0); +%} +%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{ + //plain pointer(out) + #if ($owner) + if ($1) { + intrusive_ptr_add_ref($1); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } + #else + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; + #endif +%} + +%typemap(in, canthrow=1) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + // plain reference + $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + if(!$1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0); + return $null; + } +%} +%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{ + //plain reference(out) + #if ($owner) + if ($1) { + intrusive_ptr_add_ref($1); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } + #else + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; + #endif +%} + +%typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + // plain pointer by reference + temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + $1 = &temp; +%} +%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{ + // plain pointer by reference(out) + #if ($owner) + if (*$1) { + intrusive_ptr_add_ref(*$1); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } + #else + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0); + #endif +%} + +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ + // intrusive_ptr by value + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; + if (smartarg) { + $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + } +%} +%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{ + if ($1) { + intrusive_ptr_add_ref(result.get()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(result.get(), SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } +%} + +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ + // shared_ptr by value + smartarg = *($&1_ltype*)&$input; + if (smartarg) $1 = *smartarg; +%} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ + *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; +%} + +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ + // intrusive_ptr by reference + if ( $input ) { + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; + temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + $1 = &temp; + } else { + $1 = &tempnull; + } +%} +%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ + delete &($1); + if ($self) { + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); + $1 = *temp; + } +%} +%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ + if (*$1) { + intrusive_ptr_add_ref($1->get()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } +%} + +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ + // intrusive_ptr by pointer + if ( $input ) { + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; + temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + $1 = &temp; + } else { + $1 = &tempnull; + } +%} +%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ + delete $1; + if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); +%} +%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ + if ($1 && *$1) { + intrusive_ptr_add_ref($1->get()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } + if ($owner) delete $1; +%} + +%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ + // intrusive_ptr by pointer reference + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; + if ($input) { + temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + } + tempp = &temp; + $1 = &tempp; +%} +%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ + if ($self) $1 = *$input; +%} +%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ + if (*$1 && **$1) { + intrusive_ptr_add_ref((*$1)->get()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >()); + } else { + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + } +%} + +// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug +%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} +%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} + + +%typemap (ctype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "void *" +%typemap (imtype, out="IntPtr") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "HandleRef" +%typemap (cstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)" +%typemap(csin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, + SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)" + +%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } + + +%typemap(csout, excode=SWIGEXCODE) CONST TYPE { + $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) CONST TYPE & { + $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) CONST TYPE * { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { + IntPtr cPtr = $imcall; + $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode + return ret; + } + +// Base proxy classes +%typemap(csbody) TYPE %{ + private HandleRef swigCPtr; + private bool swigCMemOwnBase; + + public $csclassname(IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwnBase = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + internal static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +// Derived proxy classes +%typemap(csbody_derived) TYPE %{ + private HandleRef swigCPtr; + private bool swigCMemOwnDerived; + + public $csclassname(IntPtr cPtr, bool cMemoryOwn) + : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { + + swigCMemOwnDerived = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + internal static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { + lock(this) { + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwnBase) { + swigCMemOwnBase = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + GC.SuppressFinalize(this); + } + } + +%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { + lock(this) { + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwnDerived) { + swigCMemOwnDerived = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + GC.SuppressFinalize(this); + base.Dispose(); + } + } + +// CONST version needed ???? also for C# +%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "HandleRef" +%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "HandleRef" + + +%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; +%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; +%enddef + + +///////////////////////////////////////////////////////////////////// + + +%include + +%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) + +%naturalvar TYPE; +%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; + +// destructor mods +%feature("unref") TYPE "(void)arg1; delete smartarg1;" + + +// plain value +%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{ + argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; + if (!argp) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); + return $null; + } + $1 = *argp; %} +%typemap(out) CONST TYPE +%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} + +// plain pointer +%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; + $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; +%} + +// plain reference +%typemap(in, canthrow=1) CONST TYPE & %{ + $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + if (!$1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0); + return $null; + } %} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE & +%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} + +// plain pointer by reference +%typemap(in) TYPE *CONST& ($*1_ltype temp = 0) +%{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + $1 = &temp; %} +%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& +%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} + +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ + // shared_ptr by value + smartarg = *($&1_ltype*)&$input; + if (smartarg) $1 = *smartarg; +%} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ + *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; +%} + +// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug +%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} +%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} + + +%typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *" +%typemap (imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *" +%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE)" +%typemap (csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE).getCPtr($csinput)" +%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + IntPtr cPtr = $imcall; + return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true); + } + +%typemap(csout, excode=SWIGEXCODE) CONST TYPE { + return new $typemap(cstype, TYPE)($imcall, true); + } +%typemap(csout, excode=SWIGEXCODE) CONST TYPE & { + return new $typemap(cstype, TYPE)($imcall, true); + } +%typemap(csout, excode=SWIGEXCODE) CONST TYPE * { + IntPtr cPtr = $imcall; + return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true); + } +%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& { + IntPtr cPtr = $imcall; + return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true); + } + +// Base proxy classes +%typemap(csbody) TYPE %{ + private HandleRef swigCPtr; + private bool swigCMemOwnBase; + + public $csclassname(IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwnBase = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + internal static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +// Derived proxy classes +%typemap(csbody_derived) TYPE %{ + private HandleRef swigCPtr; + private bool swigCMemOwnDerived; + + public $csclassname(IntPtr cPtr, bool cMemoryOwn) + : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { + + swigCMemOwnDerived = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + internal static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { + lock(this) { + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwnBase) { + swigCMemOwnBase = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + GC.SuppressFinalize(this); + } + } + +%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { + lock(this) { + if (swigCPtr.Handle != IntPtr.Zero) { + if (swigCMemOwnDerived) { + swigCMemOwnDerived = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + GC.SuppressFinalize(this); + base.Dispose(); + } + } + + +// CONST version needed ???? also for C# +%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "HandleRef" +%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "HandleRef" + + +%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; +%enddef + From 2aeed2fd480f5c17791002c0e0e3d667a2d7f3ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Sep 2011 22:35:14 +0000 Subject: [PATCH 063/147] Add missing intrusive_ptr csvarout typemaps for C# git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12807 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp/Makefile.in | 3 ++- Examples/test-suite/li_boost_intrusive_ptr.i | 9 ++++++++- Lib/csharp/boost_intrusive_ptr.i | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index f9a4bd76f..b89b50eb2 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -22,7 +22,8 @@ CPP_TEST_CASES = \ enum_thorough_simple \ enum_thorough_typesafe \ exception_partial_info \ - intermediary_classname + intermediary_classname \ + li_boost_intrusive_ptr include $(srcdir)/../common.mk diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i index a84af4d45..a122dc26e 100644 --- a/Examples/test-suite/li_boost_intrusive_ptr.i +++ b/Examples/test-suite/li_boost_intrusive_ptr.i @@ -10,6 +10,8 @@ %module li_boost_intrusive_ptr %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); +%warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerived; +%warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerivedDerived; %inline %{ #include "boost/shared_ptr.hpp" @@ -37,7 +39,7 @@ # define SWIG_SHARED_PTR_NAMESPACE SwigBoost #endif -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) #define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED #endif @@ -50,6 +52,7 @@ %intrusive_ptr(Space::KlassDerivedDerived) //For the use_count shared_ptr functions +#if defined(SWIGJAVA) %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{ $1 = $input ? *($&1_ltype)&$input : &tempnull; %} @@ -74,6 +77,10 @@ %typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived" %typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived.getCPtr($javainput)" +#elif defined(SWIGCSHARP) +// TODO! +#endif + #endif // TODO: diff --git a/Lib/csharp/boost_intrusive_ptr.i b/Lib/csharp/boost_intrusive_ptr.i index 66baf3e98..b01fc1690 100644 --- a/Lib/csharp/boost_intrusive_ptr.i +++ b/Lib/csharp/boost_intrusive_ptr.i @@ -239,6 +239,21 @@ $typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode return ret; } +%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{ + get { + $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >& %{ + get { + $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >* %{ + get { + $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode + return ret; + } %} %typemap(csout, excode=SWIGEXCODE) CONST TYPE { From 91d22324e73cbbb6f2071a698d120499a10ec592 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Sep 2011 22:53:35 +0000 Subject: [PATCH 064/147] Add support for eLua including options for Lua Tiny RAM (LTR) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12813 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++ COPYRIGHT | 1 + Lib/lua/lua.swg | 38 +++++++++-- Lib/lua/luarun.swg | 35 +++++++++- Lib/lua/luaruntime.swg | 20 ++++++ Source/Modules/lua.cxx | 149 +++++++++++++++++++++++++++++++++++------ 6 files changed, 217 insertions(+), 30 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 674d48517..83a03e262 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-09-14: wsfulton + [Lua] Patch #3408012 from Raman Gopalan - add support for embedded Lua (eLua) + including options for targeting Lua Tiny RAM (LTR). + 2011-09-14: wsfulton [C#] Add boost_intrusive_ptr.i library contribution from patch #3401571. diff --git a/COPYRIGHT b/COPYRIGHT index aa495f358..2fe0099b8 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -54,6 +54,7 @@ Past SWIG developers and major contributors include: Duncan Temple Lang (R) Miklos Vajna (PHP directors) Mark Gossage (mark@gossage.cjb.net) (Lua) + Raman Gopalan (ramangopalan@gmail.com) (eLua) Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL) John Lenz (Guile, MzScheme updates, Chicken module, runtime system) Ian Lance Taylor (Go) diff --git a/Lib/lua/lua.swg b/Lib/lua/lua.swg index 3267ad5eb..e22f01299 100644 --- a/Lib/lua/lua.swg +++ b/Lib/lua/lua.swg @@ -5,6 +5,30 @@ * This file is parsed by SWIG before reading any other interface file. * ----------------------------------------------------------------------------- */ +%insert("runtime") %{ +/* Lua flavors */ +#define SWIG_LUA_LUA 1 +#define SWIG_LUA_ELUA 2 +#define SWIG_LUA_ELUAC 3 + +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) +# define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0 +# define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0 +# define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0 +# define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0 +# else +# define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C) +# define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C) +# define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C) +# define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C) +#endif + +#if (SWIG_LUA_TARGET == SWIG_LUA_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_ELUAC) +# define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING} +# define LSTRVAL LRO_STRVAL +#endif +%} + /* ----------------------------------------------------------------------------- * includes * ----------------------------------------------------------------------------- */ @@ -18,27 +42,27 @@ * ----------------------------------------------------------------------------- */ // this basically adds to a table of constants %typemap(consttab) int, unsigned int, short, unsigned short, long, unsigned long, unsigned char, signed char, bool, enum SWIGTYPE - { SWIG_LUA_INT, (char *)"$symname", (long) $value, 0, 0, 0} + {SWIG_LUA_CONSTTAB_INT("$symname", $value)} %typemap(consttab) float, double - { SWIG_LUA_FLOAT, (char *)"$symname", 0, (double) $value, 0, 0} + {SWIG_LUA_CONSTTAB_FLOAT("$symname", $value)} %typemap(consttab) long long, unsigned long long, signed long long - { SWIG_LUA_FLOAT, (char *)"$symname", 0, (double) $value, 0, 0} + {SWIG_LUA_CONSTTAB_FLOAT("$symname", $value)} %typemap(consttab) const long long&, const unsigned long long&, const signed long long& - { SWIG_LUA_FLOAT, (char *)"$symname", 0, (double) *$value, 0, 0} + {SWIG_LUA_CONSTTAB_FLOAT("$symname", *$value)} %typemap(consttab) char *, const char *, char [], const char [] - { SWIG_LUA_STRING, (char *)"$symname", 0, 0, (void *)$value, 0} + {SWIG_LUA_CONSTTAB_STRING("$symname", $value)} // note: char is treated as a seperate special type // signed char & unsigned char are numbers %typemap(consttab) char - { SWIG_LUA_CHAR, (char *)"$symname", (long)$value, 0, 0, 0} + {SWIG_LUA_CONSTTAB_CHAR("$symname", $value)} %typemap(consttab) long long, unsigned long long - { SWIG_LUA_STRING, (char *) "$symname", 0, 0, (void *)"$value", 0} + {SWIG_LUA_CONSTTAB_STRING("$symname", "$value")} %typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE [] { SWIG_LUA_POINTER, (char *)"$symname", 0, 0, (void *)$value, &$1_descriptor} diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 1810e9895..8b64b7330 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -181,12 +181,24 @@ SWIGINTERN int SWIG_Lua_module_get(lua_State* L) lua_tostring(L,2)); */ /* get the metatable */ +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) assert(lua_istable(L,1)); /* just in case */ +#else + assert(lua_isrotable(L,1)); +#endif lua_getmetatable(L,1); /* get the metatable */ +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) assert(lua_istable(L,-1)); /* just in case */ +#else + assert(lua_isrotable(L,-1)); +#endif SWIG_Lua_get_table(L,".get"); /* get the .get table */ lua_remove(L,3); /* remove metatable */ +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) if (lua_istable(L,-1)) +#else + if (lua_isrotable(L,-1)) +#endif { /* look for the key in the .get table */ lua_pushvalue(L,2); /* key */ @@ -201,7 +213,7 @@ SWIGINTERN int SWIG_Lua_module_get(lua_State* L) } lua_pop(L,1); /* remove the .get */ lua_pushnil(L); /* return a nil */ - return 1; + return 1; } /* the module.set method used for setting linked data */ @@ -213,12 +225,24 @@ SWIGINTERN int SWIG_Lua_module_set(lua_State* L) (3) any for the new value */ /* get the metatable */ +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) assert(lua_istable(L,1)); /* just in case */ +#else + assert(lua_isrotable(L,1)); +#endif lua_getmetatable(L,1); /* get the metatable */ +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) assert(lua_istable(L,-1)); /* just in case */ +#else + assert(lua_isrotable(L,-1)); +#endif SWIG_Lua_get_table(L,".set"); /* get the .set table */ lua_remove(L,4); /* remove metatable */ +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) if (lua_istable(L,-1)) +#else + if (lua_isrotable(L,-1)) +#endif { /* look for the key in the .set table */ lua_pushvalue(L,2); /* key */ @@ -230,6 +254,11 @@ SWIGINTERN int SWIG_Lua_module_set(lua_State* L) lua_call(L,1,0); return 0; } +#if (SWIG_LUA_TARGET == SWIG_LUA_ELUA) + else { + return 0; // Exits stoically if an invalid key is initialized. + } +#endif } lua_settop(L,3); /* reset back to start */ /* we now have the table, key & new value, so just set directly */ @@ -237,6 +266,7 @@ SWIGINTERN int SWIG_Lua_module_set(lua_State* L) return 0; } +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) /* registering a module in lua. Pushes the module table on the stack. */ SWIGINTERN void SWIG_Lua_module_begin(lua_State* L,const char* name) { @@ -291,6 +321,7 @@ SWIGINTERN void SWIG_Lua_module_add_variable(lua_State* L,const char* name,lua_C } lua_pop(L,1); /* tidy stack (remove meta) */ } +#endif /* adding a function module */ SWIGINTERN void SWIG_Lua_module_add_function(lua_State* L,const char* name,lua_CFunction fn) @@ -705,6 +736,7 @@ SWIGRUNTIME int SWIG_Lua_equal(lua_State* L) * global variable support code: class/struct typemap functions * ----------------------------------------------------------------------------- */ +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) /* Install Constants */ SWIGINTERN void SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]) { @@ -746,6 +778,7 @@ SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]) { } } } +#endif /* ----------------------------------------------------------------------------- * executing lua code from within the wrapper diff --git a/Lib/lua/luaruntime.swg b/Lib/lua/luaruntime.swg index e28644510..b94640153 100644 --- a/Lib/lua/luaruntime.swg +++ b/Lib/lua/luaruntime.swg @@ -21,14 +21,22 @@ extern "C" { added at the very end of the code the function is always called SWIG_init, but an eariler #define will rename it */ +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) SWIGEXPORT int SWIG_init(lua_State* L) +#else +LUALIB_API int SWIG_init(lua_State* L) +#endif { +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) || (SWIG_LUA_TARGET == SWIG_LUA_ELUA) int i; /* start with global table */ lua_pushvalue(L,LUA_GLOBALSINDEX); /* SWIG's internal initalisation */ SWIG_InitializeModule((void*)L); SWIG_PropagateClientData(); +#endif + +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) /* add a global fn */ SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type); SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal); @@ -42,6 +50,9 @@ SWIGEXPORT int SWIG_init(lua_State* L) for (i = 0; swig_variables[i].name; i++){ SWIG_Lua_module_add_variable(L,swig_variables[i].name,swig_variables[i].get,swig_variables[i].set); } +#endif + +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) || (SWIG_LUA_TARGET == SWIG_LUA_ELUA) /* set up base class pointers (the hierachy) */ for (i = 0; swig_types[i]; i++){ if (swig_types[i]->clientdata){ @@ -54,8 +65,14 @@ SWIGEXPORT int SWIG_init(lua_State* L) SWIG_Lua_class_register(L,(swig_lua_class*)(swig_types[i]->clientdata)); } } +#endif + +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) /* constants */ SWIG_Lua_InstallConstants(L,swig_constants); +#endif + +#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) || (SWIG_LUA_TARGET == SWIG_LUA_ELUA) /* invoke user-specific initialization */ SWIG_init_user(L); /* end module */ @@ -63,6 +80,9 @@ SWIGEXPORT int SWIG_init(lua_State* L) point, we have the globals table and out module table on the stack. Returning one value makes the module table the result of the require command. */ return 1; +#else + return 0; +#endif } #ifdef __cplusplus diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index 9b4bb6ee3..e73ed68d7 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -40,8 +40,8 @@ * ver009 class support: ok for basic types, but methods still TDB (code is VERY messed up & needs to be cleaned) - - + * ver010 + Added support for embedded Lua. Try swig -lua -help for more information */ char cvsroot_lua_cxx[] = "$Id$"; @@ -83,11 +83,15 @@ void display_mapping(DOH *d) { NEW LANGUAGE NOTE:END ************************************************/ static const char *usage = (char *) "\ Lua Options (available with -lua)\n\ + -elua - Generates LTR compatible wrappers for smaller devices running elua\n\ + -eluac - LTR compatible wrappers in \"crass compress\" mode for elua\n\ -nomoduleglobal - Do not register the module name as a global variable \n\ but return the module table from calls to require.\n\ \n"; static int nomoduleglobal = 0; +static int elua_ltr = 0; +static int eluac_ltr = 0; /* NEW LANGUAGE NOTE:*********************************************** To add a new language, you need to derive your class from @@ -111,6 +115,9 @@ private: String *s_methods_tab; // table of class methods String *s_attr_tab; // table of class atributes String *s_luacode; // luacode to be called during init + String *s_dot_get; // table of variable 'get' functions + String *s_dot_set; // table of variable 'set' functions + String *s_vars_meta_tab; // metatable for variables int have_constructor; int have_destructor; @@ -176,6 +183,12 @@ public: } else if (strcmp(argv[i], "-nomoduleglobal") == 0) { nomoduleglobal = 1; Swig_mark_arg(i); + } else if(strcmp(argv[i], "-elua") == 0) { + elua_ltr = 1; + Swig_mark_arg(i); + } else if(strcmp(argv[i], "-eluac") == 0) { + eluac_ltr = 1; + Swig_mark_arg(i); } } } @@ -255,6 +268,10 @@ public: s_var_tab = NewString(""); // s_methods_tab = NewString(""); s_const_tab = NewString(""); + + s_dot_get = NewString(""); + s_dot_set = NewString(""); + s_vars_meta_tab = NewString(""); s_luacode = NewString(""); Swig_register_filebyname("luacode", s_luacode); @@ -267,6 +284,13 @@ public: Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGLUA\n"); + if (elua_ltr) + Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_ELUA\n"); + else if (eluac_ltr) + Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_ELUAC\n"); + else + Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_LUA\n"); + if (nomoduleglobal) { Printf(f_runtime, "#define SWIG_LUA_NO_MODULE_GLOBAL\n"); } else { @@ -287,12 +311,31 @@ public: Printf(f_header, "#define SWIG_name \"%s\"\n", module); Printf(f_header, "#define SWIG_init luaopen_%s\n", module); Printf(f_header, "#define SWIG_init_user luaopen_%s_user\n\n", module); - Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n\n", module); + Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n", module); - Printf(s_cmd_tab, "\nstatic const struct luaL_reg swig_commands[] = {\n"); - Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n"); - Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n"); - Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"); + if (elua_ltr || eluac_ltr) + Printf(f_header, "#define swig_commands %s_map\n\n", module); + + if (elua_ltr || eluac_ltr) { + Printf(s_cmd_tab, "\n#define MIN_OPT_LEVEL 2\n#include \"lrodefs.h\"\n"); + Printf(s_cmd_tab, "#include \"lrotable.h\"\n"); + Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_constants[];\n"); + if (elua_ltr) + Printf(s_cmd_tab, "const LUA_REG_TYPE mt[];\n"); + + Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_commands[] = {\n"); + Printf(s_const_tab, "\nconst LUA_REG_TYPE swig_constants[] = {\n"); + Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"); + if (elua_ltr) { + Printf(s_dot_get, "\nconst LUA_REG_TYPE dot_get[] = {\n"); + Printf(s_dot_set, "\nconst LUA_REG_TYPE dot_set[] = {\n"); + } + } else { + Printf(s_cmd_tab, "\nstatic const struct luaL_reg swig_commands[] = {\n"); + Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n"); + Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n"); + Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"); + } /* %init code inclusion, effectively in the SWIG_init function */ Printf(f_init, "void SWIG_init_user(lua_State* L)\n{\n"); @@ -303,11 +346,39 @@ public: Printf(f_wrappers, "#ifdef __cplusplus\n}\n#endif\n"); // Done. Close up the module & write to the wrappers - Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL); - Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL); - Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL); - Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL); - SwigType_emit_type_table(f_runtime, f_wrappers); + if (elua_ltr || eluac_ltr) { + Printv(s_cmd_tab, tab4, "{LSTRKEY(\"const\"), LROVAL(swig_constants)},\n", NIL); + if (elua_ltr) + Printv(s_cmd_tab, tab4, "{LSTRKEY(\"__metatable\"), LROVAL(mt)},\n", NIL); + Printv(s_cmd_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL); + Printv(s_const_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL); + } else { + Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL); + Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL); + Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL); + } + + if (elua_ltr) { + /* Generate the metatable */ + Printf(s_vars_meta_tab, "\nconst LUA_REG_TYPE mt[] = {\n"); + Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__index\"), LFUNCVAL(SWIG_Lua_module_get)},\n", NIL); + Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__newindex\"), LFUNCVAL(SWIG_Lua_module_set)},\n", NIL); + Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".get\"), LROVAL(dot_get)},\n", NIL); + Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".set\"), LROVAL(dot_set)},\n", NIL); + Printv(s_vars_meta_tab, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL); + + Printv(s_dot_get, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL); + Printv(s_dot_set, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL); + } + + if (elua_ltr || eluac_ltr) { + /* Final close up of wrappers */ + Printv(f_wrappers, s_cmd_tab, s_dot_get, s_dot_set, s_vars_meta_tab, s_var_tab, s_const_tab, NIL); + SwigType_emit_type_table(f_runtime, f_wrappers); + } else { + Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL); + SwigType_emit_type_table(f_runtime, f_wrappers); + } /* NEW LANGUAGE NOTE:*********************************************** this basically combines several of the strings together @@ -333,6 +404,9 @@ public: Close(f_begin); Delete(f_runtime); Delete(f_begin); + Delete(s_dot_get); + Delete(s_dot_set); + Delete(s_vars_meta_tab); /* Done */ return SWIG_OK; @@ -661,9 +735,13 @@ public: /* Now register the function with the interpreter. */ if (!Getattr(n, "sym:overloaded")) { // add_method(n, iname, wname, description); - if (current==NO_CPP || current==STATIC_FUNC) // emit normal fns & static fns - Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL); + if (current==NO_CPP || current==STATIC_FUNC) { // emit normal fns & static fns + if(elua_ltr || eluac_ltr) + Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "\")", ", LFUNCVAL(", Swig_name_wrapper(iname), ")", "},\n", NIL); + else + Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL); // Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), "},\n", NIL); + } } else { if (!Getattr(n, "sym:nextSibling")) { dispatchFunction(n); @@ -787,8 +865,17 @@ public: setName = NewString("SWIG_Lua_set_immutable"); // error message //setName = NewString("0"); } + // register the variable - Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName); + if (elua_ltr) { + Printf(s_dot_get, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, getName); + Printf(s_dot_set, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, setName); + } else if (eluac_ltr) { + Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_get", "\")", ", LFUNCVAL(", getName, ")", "},\n", NIL); + Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_set", "\")", ", LFUNCVAL(", setName, ")", "},\n", NIL); + } else { + Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName); + } Delete(getName); Delete(setName); return result; @@ -822,7 +909,7 @@ public: Replaceall(tm, "$target", name); Replaceall(tm, "$value", value); Replaceall(tm, "$nsname", nsname); - Printf(s_const_tab, "%s,\n", tm); + Printf(s_const_tab, " %s,\n", tm); } else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) { Replaceall(tm, "$source", value); Replaceall(tm, "$target", name); @@ -1006,7 +1093,17 @@ public: Printv(f_wrappers, "static swig_lua_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL); if (have_constructor) { - Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name))); + if (elua_ltr) { + Printf(s_cmd_tab, " {LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", class_name, \ + Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name))); + Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name))); + } else if (eluac_ltr) { + Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "new_", class_name, "\")", ", LFUNCVAL(", \ + Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)), ")", "},\n", NIL); + Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name))); + } else { + Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name))); + } Delete(constructor_name); constructor_name = 0; } else { @@ -1014,7 +1111,12 @@ public: } if (have_destructor) { - Printv(f_wrappers, ", swig_delete_", class_name, NIL); + if (eluac_ltr) { + Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "free_", class_name, "\")", ", LFUNCVAL(", "swig_delete_", class_name, ")", "},\n", NIL); + Printv(f_wrappers, ", swig_delete_", class_name, NIL); + } else { + Printv(f_wrappers, ", swig_delete_", class_name, NIL); + } } else { Printf(f_wrappers, ",0"); } @@ -1080,6 +1182,12 @@ public: sname = NewString("SWIG_Lua_set_immutable"); // error message } Printf(s_attr_tab,"%s{ \"%s\", %s, %s},\n",tab4,symname,gname,sname); + if (eluac_ltr) { + Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_get", "\")", \ + ", LFUNCVAL(", gname, ")", "},\n", NIL); + Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_set", "\")", \ + ", LFUNCVAL(", sname, ")", "},\n", NIL); + } Delete(gname); Delete(sname); return SWIG_OK; @@ -1160,9 +1268,7 @@ public: */ String *runtimeCode() { String *s = NewString(""); - const char *filenames[] = { "luarun.swg", 0 - } - ; // must be 0 termiated + const char *filenames[] = { "luarun.swg", 0 } ; // must be 0 terminated String *sfile; for (int i = 0; filenames[i] != 0; i++) { sfile = Swig_include_sys(filenames[i]); @@ -1173,7 +1279,6 @@ public: Delete(sfile); } } - return s; } From fa8915ef5f2cc99a0fd08ba6a7fc418dac134d24 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 19 Sep 2011 20:54:39 +0000 Subject: [PATCH 065/147] Fix regression introduced in swig-2.0.1 (r12157) leading to uncompilable code when using typedef and function pointers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12814 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 7 +++++++ Examples/test-suite/funcptr_cpp.i | 11 +++++++++++ Source/Swig/stype.c | 9 ++++----- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 83a03e262..9c2cbbc2d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,13 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-09-19: wsfulton + Fix regression introduced in swig-2.0.1 reported by Teemu Ikonone leading to uncompilable code + when using typedef and function pointer references, for example: + + typedef int FN(const int &a, int b); + void *typedef_call1(FN *& precallback, FN * postcallback); + 2011-09-14: wsfulton [Lua] Patch #3408012 from Raman Gopalan - add support for embedded Lua (eLua) including options for targeting Lua Tiny RAM (LTR). diff --git a/Examples/test-suite/funcptr_cpp.i b/Examples/test-suite/funcptr_cpp.i index a3d46ea39..015164ed9 100644 --- a/Examples/test-suite/funcptr_cpp.i +++ b/Examples/test-suite/funcptr_cpp.i @@ -20,3 +20,14 @@ int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); } %constant int (*ADD_BY_VALUE)(const int &, int) = addByValue; %constant int * (*ADD_BY_POINTER)(const int &, int) = addByPointer; %constant int & (*ADD_BY_REFERENCE)(const int &, int) = addByReference; + + +%inline %{ +typedef int AddByValueTypedef(const int &a, int b); +typedef int * AddByPointerTypedef(const int &a, int b); +typedef int & AddByReferenceTypedef(const int &a, int b); +void *typedef_call1(AddByValueTypedef *& precallback, AddByValueTypedef * postcallback) { return 0; } +void *typedef_call2(AddByPointerTypedef *& precallback, AddByPointerTypedef * postcallback) { return 0; } +void *typedef_call3(AddByReferenceTypedef *& precallback, AddByReferenceTypedef * postcallback) { return 0; } +%} + diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index b8a9c9c80..6250e0b15 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -823,7 +823,8 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) { Insert(result, 0, "("); Append(result, ")"); } - isreference = 1; + if (!isfunction) + isreference = 1; } else if (SwigType_isarray(element)) { DOH *size; if (firstarray && !isreference) { @@ -869,10 +870,8 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) { cast = NewStringf("(%s)", result); } if (name) { - if (!isfunction) { - if (isreference) { - Append(cast, "*"); - } + if (isreference) { + Append(cast, "*"); } Append(cast, name); } From 2587e92ba92d5251d5599788298e54ca8fccf121 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 24 Sep 2011 13:59:54 +0000 Subject: [PATCH 066/147] Add eLua documentation patch from patch 3408012. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12816 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Lua.html | 107 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 218a9a498..647030bf1 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -13,6 +13,7 @@
          • Preliminaries
          • Running SWIG
              +
            • Additional command line options
            • Compiling and Linking and Interpreter
            • Compiling a dynamic module
            • Using your module @@ -67,11 +68,15 @@

              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

              +

              +eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net +

              +

              25.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). +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). SWIG also supports eLua and works with eLua 0.8. SWIG generated code for eLua has been tested on Stellaris ARM Cortex-M3 LM3S and Infineon TriCore.

              25.2 Running SWIG

              @@ -105,9 +110,25 @@ 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.

              +

              +To build an eLua module, run SWIG using -lua and add either -elua or -eluac. +

              +
              +$ swig -lua -elua example.i
              +
              +

              +or +

              +
              +$ swig -lua -eluac example.i
              +
              +

              +The -elua option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the -eluac option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with -eluac. To access any value from eLua, one must directly call the wrapper function associated with that value. +

              25.2.1 Additional command line options

              +

              The following table list the additional commandline options available for the Lua module. They can also be seen by using:

              @@ -121,6 +142,16 @@ swig -lua -help Lua specific options + +-elua +Generates LTR compatible wrappers for smaller devices running elua. + + + +-eluac +LTR compatible wrappers in "crass compress" mode for elua. + + -nomoduleglobal Do not register the module name as a global variable but return the module table from calls to require. @@ -128,7 +159,7 @@ swig -lua -help -

              25.2.1 Compiling and Linking and Interpreter

              +

              25.2.2 Compiling and Linking and Interpreter

              @@ -174,8 +205,33 @@ $ gcc -I/usr/include/lua -c example_wrap.c -o example_wrap.o $ gcc -c example.c -o example.o $ gcc -I/usr/include/lua -L/usr/lib/lua min.o example_wrap.o example.o -o my_lua +

              +For eLua, the source must be built along with the wrappers generated by SWIG. Make sure the eLua source files platform_conf.h and auxmods.h are updated with the entries of your new module. Please note: "mod" is the module name. +

              +
              +/* Sample platform_conf.h */
              +#define LUA_PLATFORM_LIBS_ROM\
              +  _ROM( AUXLIB_PIO, luaopen_pio, pio_map )\
              +  _ROM( AUXLIB_TMR, luaopen_tmr, tmr_map )\
              +  _ROM( AUXLIB_MOD, luaopen_mod, mod_map )\
              +  ....
              +
              +

              +

              +
              +/* Sample auxmods.h */
              +#define AUXLIB_PIO       "pio"
              +LUALIB_API int ( luaopen_pio )(lua_State *L );
               
              -

              25.2.2 Compiling a dynamic module

              +#define AUXLIB_MOD "mod" +LUALIB_API int ( luaopen_mod )(lua_State *L ); +.... +
              +

              +More information on building and configuring eLua can be found here: http://www.eluaproject.net/doc/v0.8/en_building.html +

              + +

              25.2.3 Compiling a dynamic module

              @@ -243,7 +299,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib -

              25.2.3 Using your module

              +

              25.2.4 Using your module

              @@ -384,6 +440,20 @@ nil > print(example.PI) 3.142 +

              +If you have used the -eluac option for your eLua module, you will have to follow a different approach while manipulating global variables. (This is not applicable for wrappers generated with -elua) +

              +
              +> -- Applicable only with -eluac. (num is defined)
              +> print(example.num_get())
              +20
              +> example.num_set(50) -- new value added
              +> print(example.num_get())
              +50
              +
              +

              +In general, functions of the form "variable_get()" and "variable_set()" are automatically generated by SWIG for use with -eluac. +

              25.3.4 Constants and enums

              @@ -408,6 +478,17 @@ 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.

              +

              +If you're using eLua and have used -elua or -eluac to generate your wrapper, macro constants and enums should be accessed through a rotable called "const". In eLua, macro constants and enums are guaranteed to remain constants since they are all contained within a rotable. A regular C constant is accessed from eLua just as if it were a regular global variable, just that the property of value immutability is demonstrated if an attempt at modifying a C constant is made. +

              +
              +> print(example.ICONST)
              +10
              +> print(example.const.SUNDAY)
              +0
              +> print(example.const.SCONST)
              +Hello World
              +

              25.3.5 Pointers

              @@ -531,6 +612,24 @@ Because the pointer points inside the structure, you can modify the contents and > x = b.f > x.a = 3 -- Modifies the same structure +

              +For eLua with the -eluac option, structure manipulation has to be performed with specific structure functions generated by SWIG. Let's say you have the following structure definition: +

              +
              struct data {
              +   int x, y;
              +   double z;
              +};
              +
              +> --From eLua
              +> a = example.new_data()
              +> example.data_x_set(a, 10)
              +> example.data_y_set(a, 20)
              +> print(example.data_x_get(a), example.data_y_get(a))
              +10 20
              +
              +

              +In general, functions of the form "new_struct()", "struct_member_get()", "struct_member_set()" and "free_struct()" are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the -elua option) +

              25.3.7 C++ classes

              From 5923117e81608694b24d36625f128ad2744d355a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 24 Sep 2011 14:01:20 +0000 Subject: [PATCH 067/147] HTML cosmetics git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12817 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 5 ++++- Doc/Manual/Octave.html | 1 + Doc/Manual/Python.html | 1 + Doc/Manual/SWIGPlus.html | 11 ++++++----- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index e9c923a9e..ea6e75cba 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -242,6 +242,7 @@
            • Exception handling with %catches
            • Pointers to Members
            • Smart pointers and operator->() +
            • C++ reference counted objects - ref/unref feature
            • Using declarations and inheritance
            • Nested classes
            • A brief rant about const-correctness @@ -981,6 +982,7 @@
            • Preliminaries
            • Running SWIG
            • Further details on the Python class interface
                diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index fabc7b0c4..2a4efc99f 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -100,6 +100,7 @@ This creates a C++ source file example_wrap.cpp. A C++ file is generate

                29.2.1 Command-line options

                +

                The swig command line has a number of options you can use, like to redirect its output. Use swig -help to learn about these. Options specific to the Octave module are: diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 78e1fbeed..16058b7f6 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -2055,6 +2055,7 @@ simply use the __deref__() method. For example:

                33.3.15 C++ reference counted objects

                +

                The C++ reference counted objects section contains Python examples of memory management using referencing counting. diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 83b9f9da3..44126dc4b 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -57,6 +57,7 @@

              • Exception handling with %catches
              • Pointers to Members
              • Smart pointers and operator->() +
              • C++ reference counted objects - ref/unref feature
              • Using declarations and inheritance
              • Nested classes
              • A brief rant about const-correctness @@ -4618,7 +4619,7 @@ p = f.__deref__() # Raw pointer from operator-> Note: Smart pointer support was first added in SWIG-1.3.14.

                -

                C++ reference counted objects - ref/unref feature

                +

                6.25 C++ reference counted objects - ref/unref feature

                @@ -4793,7 +4794,7 @@ exit # 'a' is released, SWIG unref 'a' called in the destructor wra -

                6.25 Using declarations and inheritance

                +

                6.26 Using declarations and inheritance

                @@ -4956,7 +4957,7 @@ public:

              -

              6.26 Nested classes

              +

              6.27 Nested classes

              @@ -5100,7 +5101,7 @@ Nested class warnings could also not be suppressed using %warnfilter.

              -

              6.27 A brief rant about const-correctness

              +

              6.28 A brief rant about const-correctness

              @@ -5158,7 +5159,7 @@ using another tool if maintaining constness is the most important part of your project.

              -

              6.28 Where to go for more information

              +

              6.29 Where to go for more information

              From 690185fe855e42e76cebe3256d7cab7cf25b9b17 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 9 Oct 2011 17:52:08 +0000 Subject: [PATCH 068/147] Correct docs on javainterfaces typemap git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12823 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Java.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 428528403..e2cd2a8f6 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -5453,7 +5453,7 @@ import statements for Java class: empty default

              %typemap(javainterfaces)

              -interfaces (extends) for Java class: empty default +interfaces (implements) for Java class: empty default

              %typemap(javafinalize)

              From f8774be92d60bef73a040e5823e87f0dd9dfc70b Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Thu, 13 Oct 2011 23:48:28 +0000 Subject: [PATCH 069/147] Allow Octave modules to be re-loaded after a "clear all" (thanks to Karl Wette; SF 3418908) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12824 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 ++ Examples/Makefile.in | 2 +- Examples/octave/module_load/runme_args.m | 28 +++++++++++ Examples/octave/module_load/runme_gl_func.m | 46 +++++++++++++++++-- .../octave/module_load/runme_gl_func_base.m | 36 +++++++++++++++ Examples/octave/module_load/runme_nogl_func.m | 42 +++++++++++++++-- .../octave/module_load/runme_nogl_func_base.m | 34 ++++++++++++++ Lib/octave/octruntime.swg | 22 +++++---- 8 files changed, 196 insertions(+), 17 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 9c2cbbc2d..af0053061 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-09-13: xavier98 + [octave] Allow Octave modules to be re-loaded after a "clear all". + 2011-09-19: wsfulton Fix regression introduced in swig-2.0.1 reported by Teemu Ikonone leading to uncompilable code when using typedef and function pointer references, for example: diff --git a/Examples/Makefile.in b/Examples/Makefile.in index b86418c2c..ff5686913 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -333,7 +333,7 @@ python_clean: # Make sure these locate your Octave installation OCTAVE_INCLUDE= $(DEFS) @OCTAVEEXT@ OCTAVE_LIB = -OCTAVE = @OCTAVE@ +OCTAVE = @OCTAVE@ -qf # Extra Octave specific dynamic linking options OCTAVE_DLNK = @OCTAVEDYNAMICLINKING@ diff --git a/Examples/octave/module_load/runme_args.m b/Examples/octave/module_load/runme_args.m index bce3c4492..271cdd289 100644 --- a/Examples/octave/module_load/runme_args.m +++ b/Examples/octave/module_load/runme_args.m @@ -2,6 +2,7 @@ # test module loading with arguments +##### BEGIN TEST ##### # test help example -help assert(!isglobal("example")) @@ -10,3 +11,30 @@ assert(!isglobal("example")) example -globals mycvar assert(!isglobal("cvar")) assert(mycvar.ivar == example.ifunc()) +##### END TEST ##### + +# clearing a module results in a segfault for Octave <= 3.0.* +# (tested on Octave 3.0.5), so skip the following test +try + vers = cellfun("str2num", strsplit(OCTAVE_VERSION, ".")); +catch + vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, "."))); +end_try_catch +assert(length(vers) >= 2); +if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0) + disp("skipping 'clear all' test"); + return +endif + +clear all; + +##### BEGIN TEST ##### +# test help +example -help +assert(!isglobal("example")) + +# load module with custom cvar +example -globals mycvar +assert(!isglobal("cvar")) +assert(mycvar.ivar == example.ifunc()) +##### END TEST ##### diff --git a/Examples/octave/module_load/runme_gl_func.m b/Examples/octave/module_load/runme_gl_func.m index 15dfc5237..1624cdd9a 100644 --- a/Examples/octave/module_load/runme_gl_func.m +++ b/Examples/octave/module_load/runme_gl_func.m @@ -3,19 +3,57 @@ # test whether module can be loaded # in a function (global cvar) -# test that everything works from the base context -example -global cvar -assert(cvar.ivar == example.ifunc()) +1; +##### BEGIN TEST ##### function func example global cvar assert(cvar.ivar == example.ifunc()) endfunction +# test that everything works from the base context +example +global cvar +assert(cvar.ivar == example.ifunc()) + # test loading in a function func # test a second time to check everything works func +##### END TEST ##### + +# clearing a module results in a segfault for Octave <= 3.0.* +# (tested on Octave 3.0.5), so skip the following test +try + vers = cellfun("str2num", strsplit(OCTAVE_VERSION, ".")); +catch + vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, "."))); +end_try_catch +assert(length(vers) >= 2); +if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0) + disp("skipping 'clear all' test"); + return +endif + +clear all; + +##### BEGIN TEST ##### +function func + example + global cvar + assert(cvar.ivar == example.ifunc()) +endfunction + +# test that everything works from the base context +example +global cvar +assert(cvar.ivar == example.ifunc()) + +# test loading in a function +func + +# test a second time to check everything works +func +##### END TEST ##### diff --git a/Examples/octave/module_load/runme_gl_func_base.m b/Examples/octave/module_load/runme_gl_func_base.m index 2d312a663..0e3eb6112 100644 --- a/Examples/octave/module_load/runme_gl_func_base.m +++ b/Examples/octave/module_load/runme_gl_func_base.m @@ -5,6 +5,7 @@ 1; +##### BEGIN TEST ##### function func example global cvar @@ -21,3 +22,38 @@ func example global cvar assert(cvar.ivar == example.ifunc()) +##### END TEST ##### + +# clearing a module results in a segfault for Octave <= 3.0.* +# (tested on Octave 3.0.5), so skip the following test +try + vers = cellfun("str2num", strsplit(OCTAVE_VERSION, ".")); +catch + vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, "."))); +end_try_catch +assert(length(vers) >= 2); +if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0) + disp("skipping 'clear all' test"); + return +endif + +clear all; + +##### BEGIN TEST ##### +function func + example + global cvar + assert(cvar.ivar == example.ifunc()) +endfunction + +# test loading in a function +func + +# test a second time to check everything works +func + +# test that everything works from the base context +example +global cvar +assert(cvar.ivar == example.ifunc()) +##### END TEST ##### diff --git a/Examples/octave/module_load/runme_nogl_func.m b/Examples/octave/module_load/runme_nogl_func.m index 6c549a654..fd8e19f37 100644 --- a/Examples/octave/module_load/runme_nogl_func.m +++ b/Examples/octave/module_load/runme_nogl_func.m @@ -3,17 +3,53 @@ # test whether module can be loaded # in a function (no global cvar) -# test that everything works from the base context -example -noglobal -assert(example.cvar.ivar == example.ifunc()) +1; +##### BEGIN TEST ##### function func example -noglobal assert(example.cvar.ivar == example.ifunc()) endfunction +# test that everything works from the base context +example -noglobal +assert(example.cvar.ivar == example.ifunc()) + # test loading in a function func # test a second time to check everything works func +##### END TEST ##### + +# clearing a module results in a segfault for Octave <= 3.0.* +# (tested on Octave 3.0.5), so skip the following test +try + vers = cellfun("str2num", strsplit(OCTAVE_VERSION, ".")); +catch + vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, "."))); +end_try_catch +assert(length(vers) >= 2); +if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0) + disp("skipping 'clear all' test"); + return +endif + +clear all; + +##### BEGIN TEST ##### +function func + example -noglobal + assert(example.cvar.ivar == example.ifunc()) +endfunction + +# test that everything works from the base context +example -noglobal +assert(example.cvar.ivar == example.ifunc()) + +# test loading in a function +func + +# test a second time to check everything works +func +##### END TEST ##### diff --git a/Examples/octave/module_load/runme_nogl_func_base.m b/Examples/octave/module_load/runme_nogl_func_base.m index 0716bc223..bb8da9328 100644 --- a/Examples/octave/module_load/runme_nogl_func_base.m +++ b/Examples/octave/module_load/runme_nogl_func_base.m @@ -5,6 +5,7 @@ 1; +##### BEGIN TEST ##### function func example -noglobal assert(example.cvar.ivar == example.ifunc()) @@ -19,3 +20,36 @@ func # test that everything works from the base context example -noglobal assert(example.cvar.ivar == example.ifunc()) +##### END TEST ##### + +# clearing a module results in a segfault for Octave <= 3.0.* +# (tested on Octave 3.0.5), so skip the following test +try + vers = cellfun("str2num", strsplit(OCTAVE_VERSION, ".")); +catch + vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, "."))); +end_try_catch +assert(length(vers) >= 2); +if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0) + disp("skipping 'clear all' test"); + return +endif + +clear all; + +##### BEGIN TEST ##### +function func + example -noglobal + assert(example.cvar.ivar == example.ifunc()) +endfunction + +# test loading in a function +func + +# test a second time to check everything works +func + +# test that everything works from the base context +example -noglobal +assert(example.cvar.ivar == example.ifunc()) +##### END TEST ##### diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index 0e1434f69..bb173eb22 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -20,11 +20,17 @@ static void SWIG_init_user(octave_swig_type* module_ns); DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) { - static bool already_init=false; - static octave_swig_type* module_ns=0; - - // if module not already loaded - if (!already_init) { + // determine if module is already loaded + bool already_load; +#if OCTAVE_API_VERSION_NUMBER<37 + { + symbol_record *rec = curr_sym_tab->lookup(SWIG_name_d); + already_load = (rec && rec->is_linked_to_global()); + } +#else + already_load = symbol_table::is_global(SWIG_name_d); +#endif + if (!already_load) { // parse command line const char* usage="usage: " SWIG_name_d " [-global|-noglobal] [-globals ]"; @@ -64,8 +70,6 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) { return octave_value_list(); } - already_init=true; - // load module in base frame #if OCTAVE_API_VERSION_NUMBER<37 symbol_table *prev_sym_tab = curr_sym_tab; @@ -89,7 +93,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) { if (swig_globals[j].get_method) cvar_ns->assign(swig_globals[j].name,&swig_globals[j]); - module_ns=new octave_swig_type(0, 0, 0, true); + octave_swig_type* module_ns=new octave_swig_type(0, 0, 0, true); module_ns->assign(global_name,Swig::swig_value_ref(cvar_ns)); for (int j=0;swig_globals[j].name;++j) if (swig_globals[j].method) @@ -130,7 +134,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) { mlock(); #endif - } // !already_init + } // !already_load // link variable to module in current context #if OCTAVE_API_VERSION_NUMBER<37 From da82c2fef764bafef8f15115878b409dcc7413db Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Thu, 13 Oct 2011 23:51:37 +0000 Subject: [PATCH 070/147] fix date in last commit changelog git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12825 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index af0053061..65cb195b5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,7 +5,7 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== -2011-09-13: xavier98 +2011-10-13: xavier98 [octave] Allow Octave modules to be re-loaded after a "clear all". 2011-09-19: wsfulton From fbd6d780b7ed6a803761c7736579c21419f8bbd1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 14 Oct 2011 23:37:16 +0000 Subject: [PATCH 071/147] Remove unnecessary Identifier redefined warning when a using statement redefines a symbol. Behaviour is now like a duplicate typedef of the same symbol. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12826 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + Examples/test-suite/redefined_not.i | 13 +++++++++++++ Source/Swig/naming.c | 20 ++++++++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/redefined_not.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 449f00f06..4f64ca0b3 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -287,6 +287,7 @@ CPP_TEST_CASES += \ protected_rename \ pure_virtual \ redefined \ + redefined_not \ refcount \ reference_global_vars \ register_par \ diff --git a/Examples/test-suite/redefined_not.i b/Examples/test-suite/redefined_not.i new file mode 100644 index 000000000..235c4c92a --- /dev/null +++ b/Examples/test-suite/redefined_not.i @@ -0,0 +1,13 @@ +%module redefined_not + +// These should not emit an Identifer redefined warning +%inline %{ +typedef unsigned int size_t; +namespace std { + using ::size_t; +} +using std::size_t; +typedef unsigned int size_t; +using std::size_t; +%} + diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 13f6659c2..539442bac 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -893,11 +893,14 @@ static int nodes_are_equivalent(Node *a, Node *b, int a_inclass) { /* they must have the same type */ String *ta = nodeType(a); String *tb = nodeType(b); - if (Cmp(ta, tb) != 0) - return 0; + if (!Equal(ta, tb)) { + if (!(Equal(ta, "using") && Equal(tb, "cdecl"))) { + return 0; + } + } - /* cdecl case */ if (Cmp(ta, "cdecl") == 0) { + /* both cdecl case */ /* typedef */ String *a_storage = Getattr(a, "storage"); String *b_storage = Getattr(b, "storage"); @@ -956,8 +959,17 @@ static int nodes_are_equivalent(Node *a, Node *b, int a_inclass) { } } } + } else if (Equal(ta, "using")) { + /* using and cdecl case */ + String *b_storage = Getattr(b, "storage"); + if (Equal(b_storage, "typedef")) { + String *a_name = Getattr(a, "name"); + String *b_name = Getattr(b, "name"); + if (Equal(a_name, b_name)) + return 1; + } } else { - /* %constant case */ + /* both %constant case */ String *a_storage = Getattr(a, "storage"); String *b_storage = Getattr(b, "storage"); if ((Cmp(a_storage, "%constant") == 0) From 17c5f881ee93cc8fe5e78d0c5daa4a030ea715b6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 19 Oct 2011 20:41:24 +0000 Subject: [PATCH 072/147] warning fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12827 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 9868ee844..3e1e96f66 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1165,7 +1165,7 @@ String *replace_captures(const char *input, String *subst, int captures[]) /* Handle substitution */ if (*p == '\0') { Putc('\\', result); - } else if (isdigit(*p)) { + } else if (isdigit((int)*p)) { int group = *p++ - '0'; int l = captures[group*2], r = captures[group*2 + 1]; if (l != -1) { From fb9750698f8b30dd7e2c3812cfac407770ea6ba6 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Mon, 24 Oct 2011 20:31:06 +0000 Subject: [PATCH 073/147] mainly for SF bug #3423119 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12828 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++++ Lib/perl5/perlprimtypes.swg | 16 ++++++++++++---- Source/Modules/perl5.cxx | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 65cb195b5..438be71ab 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,12 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-10-24: talby + [perl5] SF bug #3423119 - overload dispatch stack corruption fix. Better, but more research + is needed on a stable path for tail calls in XS. + + Also, fix for large long longs in 32 bit perl. + 2011-10-13: xavier98 [octave] Allow Octave modules to be re-loaded after a "clear all". diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg index b004d2f7c..9420a2f41 100644 --- a/Lib/perl5/perlprimtypes.swg +++ b/Lib/perl5/perlprimtypes.swg @@ -172,8 +172,12 @@ SWIG_From_dec(long long)(long long value) SV *sv; if (value >= IV_MIN && value <= IV_MAX) sv = newSViv(value); - else - sv = newSVpvf("%lld", value); + else { + //sv = newSVpvf("%lld", value); doesn't work in non 64bit Perl + char temp[256]; + sprintf(temp, "%lld", value); + sv = newSVpv(temp, 0); + } return sv_2mortal(sv); } } @@ -245,8 +249,12 @@ SWIG_From_dec(unsigned long long)(unsigned long long value) SV *sv; if (value <= UV_MAX) sv = newSVuv(value); - else - sv = newSVpvf("%llu", value); + else { + //sv = newSVpvf("%llu", value); doesn't work in non 64bit Perl + char temp[256]; + sprintf(temp, "%llu", value); + sv = newSVpv(temp, 0); + } return sv_2mortal(sv); } } diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 704be814f..e275eb315 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -792,7 +792,7 @@ public: } else if (!Getattr(n, "sym:nextSibling")) { /* Generate overloaded dispatch function */ int maxargs; - String *dispatch = Swig_overload_dispatch_cast(n, "++PL_markstack_ptr; SWIG_CALLXS(%s); return;", &maxargs); + String *dispatch = Swig_overload_dispatch_cast(n, "PUSHMARK(MARK); SWIG_CALLXS(%s); return;", &maxargs); /* Generate a dispatch wrapper for all overloaded functions */ From d1dc016b685e72647909200eb16b6f51f256be3e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 25 Oct 2011 06:53:07 +0000 Subject: [PATCH 074/147] Fix test case so it doesn't clash with the real size_t git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12829 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/redefined_not.i | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/redefined_not.i b/Examples/test-suite/redefined_not.i index 235c4c92a..db9d3a248 100644 --- a/Examples/test-suite/redefined_not.i +++ b/Examples/test-suite/redefined_not.i @@ -2,12 +2,12 @@ // These should not emit an Identifer redefined warning %inline %{ -typedef unsigned int size_t; -namespace std { - using ::size_t; +typedef unsigned int my_size_t; +namespace Std { + using ::my_size_t; } -using std::size_t; -typedef unsigned int size_t; -using std::size_t; +using Std::my_size_t; +typedef unsigned int my_size_t; +using Std::my_size_t; %} From 24133bacd7ba5a670607a7ce5e7ac9800c99ae1e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Oct 2011 21:51:50 +0000 Subject: [PATCH 075/147] Remove numerous hard coded 'result' variable name in generated c/c++ wrappers. The variable name is now defined in just one place, making it possible to change the name easily if a target language so wishes - see cwrap.c. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12830 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/boost_intrusive_ptr.i | 24 +++++++------- Lib/java/various.i | 2 +- Source/Modules/allegrocl.cxx | 6 ++-- Source/Modules/cffi.cxx | 2 +- Source/Modules/chicken.cxx | 12 +++---- Source/Modules/contract.cxx | 2 +- Source/Modules/csharp.cxx | 14 ++++---- Source/Modules/d.cxx | 8 ++--- Source/Modules/emit.cxx | 8 ++--- Source/Modules/go.cxx | 39 +++++++++++----------- Source/Modules/guile.cxx | 12 +++---- Source/Modules/java.cxx | 15 ++++----- Source/Modules/lang.cxx | 2 +- Source/Modules/lua.cxx | 16 +++++----- Source/Modules/modula3.cxx | 18 +++++------ Source/Modules/mzscheme.cxx | 14 ++++---- Source/Modules/ocaml.cxx | 12 +++---- Source/Modules/octave.cxx | 14 ++++---- Source/Modules/perl5.cxx | 12 +++---- Source/Modules/php.cxx | 33 +++++++++---------- Source/Modules/pike.cxx | 14 ++++---- Source/Modules/python.cxx | 53 +++++++++++++++--------------- Source/Modules/r.cxx | 19 ++++++----- Source/Modules/ruby.cxx | 55 ++++++++++++++++---------------- Source/Modules/tcl8.cxx | 12 +++---- Source/Modules/uffi.cxx | 2 +- Source/Swig/cwrap.c | 52 +++++++++++++++++++++--------- Source/Swig/swig.h | 2 ++ Source/Swig/typemap.c | 5 +-- 29 files changed, 252 insertions(+), 227 deletions(-) diff --git a/Lib/csharp/boost_intrusive_ptr.i b/Lib/csharp/boost_intrusive_ptr.i index b01fc1690..fc0422dd7 100644 --- a/Lib/csharp/boost_intrusive_ptr.i +++ b/Lib/csharp/boost_intrusive_ptr.i @@ -92,15 +92,15 @@ // intrusive_ptr by value smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; if (smartarg) { - $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); } %} %typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{ if ($1) { - intrusive_ptr_add_ref(result.get()); - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(result.get(), SWIG_intrusive_deleter< CONST TYPE >()); + intrusive_ptr_add_ref($1.get()); + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1.get(), SWIG_intrusive_deleter< CONST TYPE >()); } else { - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; } %} @@ -116,11 +116,11 @@ %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by reference if ( $input ) { - smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; - temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); - $1 = &temp; + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; + temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + $1 = &temp; } else { - $1 = &tempnull; + $1 = &tempnull; } %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ @@ -142,11 +142,11 @@ %typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ // intrusive_ptr by pointer if ( $input ) { - smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; - temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); - $1 = &temp; + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; + temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); + $1 = &temp; } else { - $1 = &tempnull; + $1 = &tempnull; } %} %typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ diff --git a/Lib/java/various.i b/Lib/java/various.i index 7c396de3e..9e7cf29ca 100644 --- a/Lib/java/various.i +++ b/Lib/java/various.i @@ -68,7 +68,7 @@ /* exception checking omitted */ for (i=0; icode, "%s\n", result_convert); if(!is_void_return) Printf(f->code, " return lresult;\n"); diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index 0aab50332..a807d1487 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -533,8 +533,8 @@ int CHICKEN::functionWrapper(Node *n) { String *actioncode = emit_action(n); /* Return the function value */ - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { + Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$result", "resultobj"); if (GetFlag(n, "feature:new")) { @@ -561,15 +561,15 @@ int CHICKEN::functionWrapper(Node *n) { /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } diff --git a/Source/Modules/contract.cxx b/Source/Modules/contract.cxx index 7a8543928..4240945b0 100644 --- a/Source/Modules/contract.cxx +++ b/Source/Modules/contract.cxx @@ -213,7 +213,7 @@ String *Contracts::make_expression(String *s, Node *n) { for (ei = First(list_assert); ei.item; ei = Next(ei)) { expr = ei.item; if (Len(expr)) { - Replaceid(expr, Getattr(n, "name"), "result"); + Replaceid(expr, Getattr(n, "name"), Swig_cresult_name()); if (Len(str_assert)) Append(str_assert, "&&"); Printf(str_assert, "(%s)", expr); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index fbbe94813..bcf5c2b22 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -933,7 +933,7 @@ public: // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); - Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value"))); + Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value"))); } Swig_director_emit_dynamic_cast(n, f); @@ -943,9 +943,9 @@ public: Swig_restore(n); /* Return value if necessary */ - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { canThrow(n, "out", n); - Replaceall(tm, "$source", "result"); /* deprecated */ + Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Replaceall(tm, "$target", "jresult"); /* deprecated */ Replaceall(tm, "$result", "jresult"); @@ -972,18 +972,18 @@ public: /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { canThrow(n, "newfree", n); - Replaceall(tm, "$source", "result"); /* deprecated */ + Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ if (!native_function_flag) { - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { canThrow(n, "ret", n); - Replaceall(tm, "$source", "result"); /* deprecated */ + Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index e5cf4a52c..3e5375af7 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -1708,7 +1708,7 @@ public: // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); - Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value"))); + Setattr(n, "wrap:action", NewStringf("%s = (%s) %s;", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value"))); } Swig_director_emit_dynamic_cast(n, f); @@ -1718,7 +1718,7 @@ public: Swig_restore(n); /* Return value if necessary */ - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { canThrow(n, "out", n); Replaceall(tm, "$result", "jresult"); @@ -1745,7 +1745,7 @@ public: /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { canThrow(n, "newfree", n); Printf(f->code, "%s\n", tm); } @@ -1753,7 +1753,7 @@ public: /* See if there is any return cleanup code */ if (!native_function_flag) { - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { canThrow(n, "ret", n); Printf(f->code, "%s\n", tm); } diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx index 914cb0da0..efcf9a352 100644 --- a/Source/Modules/emit.cxx +++ b/Source/Modules/emit.cxx @@ -32,11 +32,11 @@ void emit_return_variable(Node *n, SwigType *rt, Wrapper *f) { SwigType *vt = cplus_value_type(rt); SwigType *tt = vt ? vt : rt; SwigType *lt = SwigType_ltype(tt); - String *lstr = SwigType_str(lt, "result"); + String *lstr = SwigType_str(lt, Swig_cresult_name()); if (SwigType_ispointer(lt)) { - Wrapper_add_localv(f, "result", lstr, "= 0", NULL); + Wrapper_add_localv(f, Swig_cresult_name(), lstr, "= 0", NULL); } else { - Wrapper_add_local(f, "result", lstr); + Wrapper_add_local(f, Swig_cresult_name(), lstr); } if (vt) { Delete(vt); @@ -496,7 +496,7 @@ String *emit_action(Node *n) { } /* Look for except typemap (Deprecated) */ - tm = Swig_typemap_lookup("except", n, "result", 0); + tm = Swig_typemap_lookup("except", n, Swig_cresult_name(), 0); if (tm) { Setattr(n, "feature:except", tm); tm = 0; diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index ca565d8f9..8fb2bb25e 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -550,7 +550,7 @@ private: Getattr(n, "parms")); SwigType *type = Copy(getClassType()); SwigType_add_pointer(type); - String *cres = Swig_cresult(type, "result", call); + String *cres = Swig_cresult(type, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); } } else if (Cmp(nodetype, "destructor") == 0) { @@ -1156,7 +1156,7 @@ private: } if (SwigType_type(result) != T_VOID) { Printv(f->code, "\t\tlong : 0;\n", NULL); - String *ln = NewString("result"); + String *ln = NewString(Swig_cresult_name()); String *ct = gcCTypeForGoValue(n, result, ln); Delete(ln); Printv(f->code, "\t\t", ct, ";\n", NULL); @@ -1417,12 +1417,13 @@ private: Setattr(n, "type", result); - String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode); + String *tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode); if (!tm) { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s\n", SwigType_str(result, 0)); } else { if (!gccgo_flag) { - Replaceall(tm, "$result", "swig_a->result"); + static const String *swig_a_result = NewStringf("swig_a->%s", Swig_cresult_name()); + Replaceall(tm, "$result", swig_a_result); } else { Replaceall(tm, "$result", "go_result"); } @@ -1453,7 +1454,7 @@ private: if (!tm) { p = nextSibling(p); } else { - Replaceall(tm, "$result", "result"); + Replaceall(tm, "$result", Swig_cresult_name()); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(f->code, tm, "\n", NULL); p = Getattr(p, "tmap:argout:next"); @@ -1496,9 +1497,9 @@ private: Printv(f->code, cleanup, NULL); if (GetFlag(n, "feature:new")) { - String *tm = Swig_typemap_lookup("newfree", n, "result", 0); + String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0); if (tm) { - Replaceall(tm, "$source", "result"); + Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NULL); Delete(tm); } @@ -1690,7 +1691,7 @@ private: } String *get = NewString(""); - Printv(get, "result = ", NULL); + Printv(get, Swig_cresult_name(), " = ", NULL); char quote; if (Getattr(n, "wrappedasconstant")) { @@ -2040,7 +2041,7 @@ private: } } else { String *call = Swig_cfunction_call(Getattr(method, "name"), Getattr(method, "parms")); - Setattr(method, "wrap:action", Swig_cresult(Getattr(method, "type"), "result", call)); + Setattr(method, "wrap:action", Swig_cresult(Getattr(method, "type"), Swig_cresult_name(), call)); } } @@ -2230,7 +2231,7 @@ private: String *pn = Swig_cparm_name(parm, 0); String *action = NewString(""); - Printv(action, "result = (", Getattr(b.item, "classtype"), "*)", pn, ";", NULL); + Printv(action, Swig_cresult_name(), " = (", Getattr(b.item, "classtype"), "*)", pn, ";", NULL); Delete(pn); Setattr(n, "wrap:action", action); @@ -2556,7 +2557,7 @@ private: Setattr(n, "wrap:name", Swig_name_wrapper(name)); String *action = NewString(""); - Printv(action, "result = new SwigDirector_", class_name, "(", NULL); + Printv(action, Swig_cresult_name(), " = new SwigDirector_", class_name, "(", NULL); String *pname = Swig_cparm_name(NULL, 0); Printv(action, pname, NULL); Delete(pname); @@ -2677,8 +2678,7 @@ private: Setattr(n, "wrap:parms", parms); String *result = NewString("void"); - int r = makeWrappers(n, fnname, fnname, NULL, wname, NULL, parms, result, - isStatic(n)); + int r = makeWrappers(n, fnname, fnname, NULL, wname, NULL, parms, result, isStatic(n)); if (r != SWIG_OK) { return r; } @@ -3130,7 +3130,7 @@ private: String *action = NewString(""); if (SwigType_type(result) != T_VOID) { - Printv(action, "result = (", SwigType_lstr(result, 0), ")", NULL); + Printv(action, Swig_cresult_name(), " = (", SwigType_lstr(result, 0), ")", NULL); if (SwigType_isreference(result)) { Printv(action, "&", NULL); } @@ -3399,7 +3399,7 @@ private: } if (SwigType_type(result) != T_VOID) { Printv(f->code, " long : 0;\n", NULL); - String *rname = NewString("result"); + String *rname = NewString(Swig_cresult_name()); String *cg = gcCTypeForGoValue(n, result, rname); Printv(f->code, " ", cg, ";\n", NULL); Delete(cg); @@ -3440,7 +3440,8 @@ private: Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use type %s as director method result\n", SwigType_str(result, 0)); } else { - Replaceall(tm, "$input", "swig_a.result"); + static const String *swig_a_result = NewStringf("swig_a.%s", Swig_cresult_name()); + Replaceall(tm, "$input", swig_a_result); Replaceall(tm, "$result", "c_result"); Printv(f->code, " ", tm, "\n", NULL); String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result"); @@ -3462,7 +3463,7 @@ private: Printv(f_gc_wrappers, "}\n\n", NULL); } else { if (SwigType_type(result) != T_VOID) { - String *r = NewString("result"); + String *r = NewString(Swig_cresult_name()); String *tm = gccgoCTypeForGoValue(n, result, r); Wrapper_add_local(f, r, tm); Delete(tm); @@ -3502,7 +3503,7 @@ private: Printv(f->code, " ", NULL); if (SwigType_type(result) != T_VOID) { - Printv(f->code, "result = ", NULL); + Printv(f->code, Swig_cresult_name(), " = ", NULL); } Printv(f->code, callback_wname, "(go_val", args, ");\n", NULL); @@ -3514,7 +3515,7 @@ private: Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, "Unable to use type %s as director method result\n", SwigType_str(result, 0)); } else { - Replaceall(tm, "$input", "result"); + Replaceall(tm, "$input", Swig_cresult_name()); Replaceall(tm, "$result", "c_result"); Printv(f->code, " ", tm, "\n", NULL); String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result"); diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index bbeb1db03..90feb366b 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -882,10 +882,10 @@ public: Printv(actioncode, tab4, "gh_allow_ints();\n", NIL); // Now have return value, figure out what to do with it. - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { Replaceall(tm, "$result", "gswig_result"); Replaceall(tm, "$target", "gswig_result"); - Replaceall(tm, "$source", "result"); + Replaceall(tm, "$source", Swig_cresult_name()); if (GetFlag(n, "feature:new")) Replaceall(tm, "$owner", "1"); else @@ -922,14 +922,14 @@ public: // Look for any remaining cleanup if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NIL); } } // Free any memory allocated by the function being wrapped.. - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NIL); } // Wrap things up (in a manner of speaking) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index bf7098b7a..12b8102e4 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1021,7 +1021,7 @@ public: // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); - Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value"))); + Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value"))); } // Now write code to make the function call @@ -1035,9 +1035,9 @@ public: Swig_restore(n); /* Return value if necessary */ - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { addThrows(n, "tmap:out", n); - Replaceall(tm, "$source", "result"); /* deprecated */ + Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Replaceall(tm, "$target", "jresult"); /* deprecated */ Replaceall(tm, "$result", "jresult"); @@ -1063,18 +1063,18 @@ public: /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { addThrows(n, "tmap:newfree", n); - Replaceall(tm, "$source", "result"); /* deprecated */ + Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ if (!native_function_flag) { - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { addThrows(n, "tmap:ret", n); - Replaceall(tm, "$source", "result"); /* deprecated */ + Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } @@ -1848,7 +1848,6 @@ public: "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", " jlong baseptr = 0;\n" " ", smartnamestr, " *argp1;\n" - " ", bsmartnamestr, " result;\n" " (void)jenv;\n" " (void)jcls;\n" " argp1 = *(", smartnamestr, " **)&jarg1;\n" diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 0fc214694..c797a101e 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1111,7 +1111,7 @@ int Language::globalfunctionHandler(Node *n) { } Setattr(n, "parms", nonvoid_parms(parms)); String *call = Swig_cfunction_call(name, parms); - String *cres = Swig_cresult(type, "result", call); + String *cres = Swig_cresult(type, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index e73ed68d7..bec5aef33 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -637,7 +637,7 @@ public: // } // else returnval++; Replaceall(tm, "$source", Getattr(p, "lname")); - Replaceall(tm, "$target", "result"); + Replaceall(tm, "$target", Swig_cresult_name()); Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input")); Printv(outarg, tm, "\n", NIL); @@ -658,7 +658,7 @@ public: this is because there is a typemap for void NEW LANGUAGE NOTE:END ************************************************/ // Return value if necessary - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { // managing the number of returning variables // if (numoutputs=Getattr(tm,"numoutputs")){ // int i=GetInt(tm,"numoutputs"); @@ -666,7 +666,7 @@ public: // returnval+=GetInt(tm,"numoutputs"); // } // else returnval++; - Replaceall(tm, "$source", "result"); + Replaceall(tm, "$source", Swig_cresult_name()); if (GetFlag(n, "feature:new")) { Replaceall(tm, "$owner", "1"); } else { @@ -687,15 +687,15 @@ public: /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } @@ -714,7 +714,7 @@ public: /* Substitute the function name */ Replaceall(f->code, "$symname", iname); - Replaceall(f->code, "$result", "result"); + Replaceall(f->code, "$result", Swig_cresult_name()); /* Dump the function out */ /* in Lua we will not emit the destructor as a wrappered function, diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 5a3cf1d24..19a02cbbc 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -1422,7 +1422,7 @@ MODULA3(): // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); - Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value"))); + Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value"))); } Setattr(n, "wrap:name", wname); @@ -1437,9 +1437,9 @@ MODULA3(): /* Return value if necessary */ String *tm; - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { addThrows(throws_hash, "out", n); - Replaceall(tm, "$source", "result"); /* deprecated */ + Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Replaceall(tm, "$target", "cresult"); /* deprecated */ Replaceall(tm, "$result", "cresult"); Printf(f->code, "%s", tm); @@ -1459,19 +1459,19 @@ MODULA3(): /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { - String *tm = Swig_typemap_lookup("newfree", n, "result", 0); + String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0); if (tm != NIL) { addThrows(throws_hash, "newfree", n); - Replaceall(tm, "$source", "result"); /* deprecated */ + Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ if (!native_function_flag) { - String *tm = Swig_typemap_lookup("ret", n, "result", 0); + String *tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0); if (tm != NIL) { - Replaceall(tm, "$source", "result"); /* deprecated */ + Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } @@ -3197,7 +3197,7 @@ MODULA3(): writeArg(return_variables, state, NIL, NIL, NIL, NIL); if (multiretval) { - Printv(result_name, "result", NIL); + Printv(result_name, Swig_cresult_name(), NIL); Printf(result_m3wraptype, "%sResult", func_name); m3wrap_intf.enterBlock(blocktype); Printf(m3wrap_intf.f, "%s =\nRECORD\n%sEND;\n", result_m3wraptype, return_variables); @@ -3455,7 +3455,7 @@ MODULA3(): if ((hasContent(outcheck) || hasContent(storeout) || hasContent(cleanup)) && (!hasContent(result_name)) && (return_raw == NIL)) { - Printv(result_name, "result", NIL); + Printv(result_name, Swig_cresult_name(), NIL); Printf(local_variables, "%s: %s;\n", result_name, result_m3wraptype); } diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index 7dc095d06..c8d758bb9 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -250,7 +250,7 @@ public: ParmList *parms = Getattr(n, "parms"); SwigType *type = Getattr(n, "type"); String *name = NewString("caller"); - Setattr(n, "wrap:action", Swig_cresult(type, "result", Swig_cfunction_call(name, parms))); + Setattr(n, "wrap:action", Swig_cresult(type, Swig_cresult_name(), Swig_cfunction_call(name, parms))); } // PATCH DLOPEN @@ -403,8 +403,8 @@ public: String *actioncode = emit_action(n); // Now have return value, figure out what to do with it. - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { + Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "values[0]"); Replaceall(tm, "$result", "values[0]"); if (GetFlag(n, "feature:new")) @@ -426,15 +426,15 @@ public: // Look for any remaining cleanup if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NIL); } } // Free any memory allocated by the function being wrapped.. - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NIL); } // Wrap things up (in a manner of speaking) diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 676a5b7ae..0e42bd866 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -657,7 +657,7 @@ public: Swig_director_emit_dynamic_cast(n, f); String *actioncode = emit_action(n); - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { Replaceall(tm, "$source", "swig_result"); Replaceall(tm, "$target", "rv"); Replaceall(tm, "$result", "rv"); @@ -677,15 +677,15 @@ public: // Look for any remaining cleanup if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Replaceall(tm, "$source", "swig_result"); Printv(f->code, tm, "\n", NIL); } } // Free any memory allocated by the function being wrapped.. - if ((tm = Swig_typemap_lookup("swig_result", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("swig_result", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NIL); } // Wrap things up (in a manner of speaking) @@ -1586,12 +1586,12 @@ public: "swig_result = caml_swig_alloc(1,C_list);\n" "SWIG_Store_field(swig_result,0,args);\n" "args = swig_result;\n" "swig_result = Val_unit;\n", 0); Printf(w->code, "swig_result = " "callback3(*caml_named_value(\"swig_runmethod\")," "swig_get_self(),copy_string(\"%s\"),args);\n", Getattr(n, "name")); /* exception handling */ - tm = Swig_typemap_lookup("director:except", n, "result", 0); + tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0); if (!tm) { tm = Getattr(n, "feature:director:except"); } if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { - Printf(w->code, "if (!result) {\n"); + Printf(w->code, "if (!%s) {\n", Swig_cresult_name()); Printf(w->code, " CAML_VALUE error = *caml_named_value(\"director_except\");\n"); Replaceall(tm, "$error", "error"); Printv(w->code, Str(tm), "\n", NIL); diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 49d07a3a3..4d54084da 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -694,8 +694,8 @@ public: Wrapper_add_local(f, "_outv", "octave_value _outv"); // Return the function value - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { + Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "_outv"); Replaceall(tm, "$result", "_outv"); @@ -716,14 +716,14 @@ public: Printv(f->code, cleanup, NIL); if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } } - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$result", "_outv"); Printf(f->code, "%s\n", tm); Delete(tm); @@ -1402,7 +1402,7 @@ public: Printf(w->code, "}\n"); Setattr(n, "type", return_type); - tm = Swig_typemap_lookup("directorout", n, "result", w); + tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); Setattr(n, "type", type); if (tm != 0) { char temp[24]; diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index e275eb315..00a66b801 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -730,9 +730,9 @@ public: Swig_director_emit_dynamic_cast(n, f); String *actioncode = emit_action(n); - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { SwigType *t = Getattr(n, "type"); - Replaceall(tm, "$source", "result"); + Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "ST(argvi)"); Replaceall(tm, "$result", "ST(argvi)"); if (is_shadow(t)) { @@ -760,14 +760,14 @@ public: Printv(f->code, cleanup, NIL); if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } } - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index a428afedb..3e8df76b9 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -961,9 +961,9 @@ public: /* emit function call */ String *actioncode = emit_action(n); - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { - Replaceall(tm, "$input", "result"); - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { + Replaceall(tm, "$input", Swig_cresult_name()); + Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "return_value"); Replaceall(tm, "$result", "return_value"); Replaceall(tm, "$owner", newobject ? "1" : "0"); @@ -983,14 +983,14 @@ public: /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { Printf(f->code, "%s\n", tm); Delete(tm); } } /* See if there is any return cleanup code */ - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { Printf(f->code, "%s\n", tm); Delete(tm); } @@ -2253,13 +2253,13 @@ done: director_prot_ctor_code = NewStringEmpty(); Printf(director_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n"); Printf(director_prot_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n"); - Printf(director_ctor_code, " result = (%s *)new %s(%s);\n", ctype, ctype, args); + Printf(director_ctor_code, " %s = (%s *)new %s(%s);\n", Swig_cresult_name(), ctype, ctype, args); Printf(director_prot_ctor_code, " SWIG_PHP_Error(E_ERROR, \"accessing abstract class or protected constructor\");\n", name, name, args); if (i) { Insert(args, 0, ", "); } - Printf(director_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", ctype, sname, args); - Printf(director_prot_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", ctype, sname, args); + Printf(director_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args); + Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args); Delete(args); wrapperType = directorconstructor; @@ -2595,7 +2595,7 @@ done: } /* exception handling */ - tm = Swig_typemap_lookup("director:except", n, "result", 0); + tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0); if (!tm) { tm = Getattr(n, "feature:director:except"); if (tm) @@ -2616,8 +2616,8 @@ done: } else { Printf(w->code, "zval *args[%d];\n", idx); } - Append(w->code, "zval *result, funcname;\n"); - Append(w->code, "MAKE_STD_ZVAL(result);\n"); + Printf(w->code, "zval *%s, funcname;\n", Swig_cresult_name()); + Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name()); Printf(w->code, "ZVAL_STRING(&funcname, (char *)\"%s\", 0);\n", GetChar(n, "sym:name")); Append(w->code, "if (!swig_self) {\n"); Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");"); @@ -2627,7 +2627,7 @@ done: Printv(w->code, wrap_args, NIL); Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,\n"); - Printf(w->code, " result, %d, args TSRMLS_CC);\n", idx); + Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx); if (tm) { Printv(w->code, Str(tm), "\n", NIL); @@ -2651,10 +2651,11 @@ done: * occurs in Language::cDeclaration(). */ Setattr(n, "type", return_type); - tm = Swig_typemap_lookup("directorout", n, "result", w); + tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); Setattr(n, "type", type); if (tm != 0) { - Replaceall(tm, "$input", "&result"); + static const String *amp_result = NewStringf("&%s", Swig_cresult_name()); + Replaceall(tm, "$input", amp_result); char temp[24]; sprintf(temp, "%d", idx); Replaceall(tm, "$argnum", temp); @@ -2679,7 +2680,7 @@ done: /* marshal outputs */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) { - Replaceall(tm, "$input", "result"); + Replaceall(tm, "$input", Swig_cresult_name()); Replaceall(tm, "$result", Getattr(p, "name")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); @@ -2688,7 +2689,7 @@ done: } } - Append(w->code, "FREE_ZVAL(result);\n"); + Printf(w->code, "FREE_ZVAL(%s);\n", Swig_cresult_name()); Delete(parse_args); Delete(cleanup); diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index 81adc5462..9fba5d5b0 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -421,15 +421,15 @@ public: /* Return the function value */ if (current == CONSTRUCTOR) { - Printv(actioncode, "THIS = (void *) result;\n", NIL); + Printv(actioncode, "THIS = (void *) ", Swig_cresult_name(), ";\n", NIL); Printv(description, ", tVoid", NIL); } else if (current == DESTRUCTOR) { Printv(description, ", tVoid", NIL); } else { Printv(description, ", ", NIL); - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { actioncode = 0; - Replaceall(tm, "$source", "result"); + Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$result", "resultobj"); if (GetFlag(n, "feature:new")) { @@ -460,15 +460,15 @@ public: /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } } /* See if there is any return cleanup code */ - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 34f7248ca..f94d54106 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2445,7 +2445,7 @@ public: /* This part below still needs cleanup */ /* Return the function value */ - tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode); + tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode); if (tm) { if (builtin_self) { @@ -2455,7 +2455,7 @@ public: } else { Replaceall(tm, "$self", "obj0"); } - Replaceall(tm, "$source", "result"); + Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$result", "resultobj"); if (builtin_ctor) { @@ -2491,7 +2491,7 @@ public: } if (unwrap) { Wrapper_add_local(f, "director", "Swig::Director *director = 0"); - Append(f->code, "director = SWIG_DIRECTOR_CAST(result);\n"); + Printf(f->code, "director = SWIG_DIRECTOR_CAST(%s);\n", Swig_cresult_name()); Append(f->code, "if (director) {\n"); Append(f->code, " resultobj = director->swig_get_self();\n"); Append(f->code, " Py_INCREF(resultobj);\n"); @@ -2521,23 +2521,23 @@ public: /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); Delete(tm); } } /* See if there is any return cleanup code */ - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); Delete(tm); } if (director_method) { - if ((tm = Swig_typemap_lookup("directorfree", n, "result", 0))) { - Replaceall(tm, "$input", "result"); + if ((tm = Swig_typemap_lookup("directorfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$input", Swig_cresult_name()); Replaceall(tm, "$result", "resultobj"); Printf(f->code, "%s\n", tm); Delete(tm); @@ -4818,33 +4818,32 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { Append(w->code, "PyObject* method = swig_get_method(swig_method_index, swig_method_name);\n"); if (Len(parse_args) > 0) { if (use_parse || !modernargs) { - Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", parse_args, arglist); + Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", Swig_cresult_name(), parse_args, arglist); } else { - Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunctionObjArgs(method %s, NULL);\n", arglist); + Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunctionObjArgs(method %s, NULL);\n", Swig_cresult_name(), arglist); } } else { if (modernargs) { Append(w->code, "swig::SwigVar_PyObject args = PyTuple_New(0);\n"); - Append(w->code, "swig::SwigVar_PyObject result = PyObject_Call(method, (PyObject*) args, NULL);\n"); + Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_Call(method, (PyObject*) args, NULL);\n", Swig_cresult_name()); } else { - Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunction(method, NULL, NULL);\n"); + Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunction(method, NULL, NULL);\n", Swig_cresult_name()); } } Append(w->code, "#else\n"); if (Len(parse_args) > 0) { if (use_parse || !modernargs) { - Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", - pyname, parse_args, arglist); + Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", Swig_cresult_name(), pyname, parse_args, arglist); } else { - Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); - Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", arglist); + Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", Swig_cresult_name(), pyname); + Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", Swig_cresult_name(), arglist); } } else { if (!modernargs) { - Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", pyname); + Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", Swig_cresult_name(), pyname); } else { Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); - Append(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n"); + Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n", Swig_cresult_name()); } } Append(w->code, "#endif\n"); @@ -4853,13 +4852,13 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { Printf(w->code, "swig_set_inner(\"%s\", false);\n", name); /* exception handling */ - tm = Swig_typemap_lookup("director:except", n, "result", 0); + tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0); if (!tm) { tm = Getattr(n, "feature:director:except"); if (tm) tm = Copy(tm); } - Append(w->code, "if (!result) {\n"); + Printf(w->code, "if (!%s) {\n", Swig_cresult_name()); Append(w->code, " PyObject *error = PyErr_Occurred();\n"); if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { Replaceall(tm, "$error", "error"); @@ -4886,7 +4885,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { if (outputs > 1) { Wrapper_add_local(w, "output", "PyObject *output"); - Append(w->code, "if (!PyTuple_Check(result)) {\n"); + Printf(w->code, "if (!PyTuple_Check(%s)) {\n", Swig_cresult_name()); Printf(w->code, " Swig::DirectorTypeMismatchException::raise(\"Python method %s.%sfailed to return a tuple.\");\n", classname, pyname); Append(w->code, "}\n"); } @@ -4903,14 +4902,14 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { * occurs in Language::cDeclaration(). */ Setattr(n, "type", return_type); - tm = Swig_typemap_lookup("directorout", n, "result", w); + tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); Setattr(n, "type", type); if (tm != 0) { if (outputs > 1) { - Printf(w->code, "output = PyTuple_GetItem(result, %d);\n", idx++); + Printf(w->code, "output = PyTuple_GetItem(%s, %d);\n", Swig_cresult_name(), idx++); Replaceall(tm, "$input", "output"); } else { - Replaceall(tm, "$input", "result"); + Replaceall(tm, "$input", Swig_cresult_name()); } char temp[24]; sprintf(temp, "%d", idx); @@ -4940,10 +4939,10 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) { if (outputs > 1) { - Printf(w->code, "output = PyTuple_GetItem(result, %d);\n", idx++); + Printf(w->code, "output = PyTuple_GetItem(%s, %d);\n", Swig_cresult_name(), idx++); Replaceall(tm, "$input", "output"); } else { - Replaceall(tm, "$input", "result"); + Replaceall(tm, "$input", Swig_cresult_name()); } Replaceall(tm, "$result", Getattr(p, "name")); Printv(w->code, tm, "\n", NIL); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index dd43565d0..16266c96a 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -675,12 +675,12 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { XXX Have to be a little more clever so that we can deal with struct A * - the * is getting lost. Is this still true? If so, will a SwigType_push() solve things? */ - Parm *bbase = NewParm(rettype, "result", n); - String *returnTM = Swig_typemap_lookup("in", bbase, "result", f); + Parm *bbase = NewParm(rettype, Swig_cresult_name(), n); + String *returnTM = Swig_typemap_lookup("in", bbase, Swig_cresult_name(), f); if(returnTM) { String *tm = returnTM; Replaceall(tm,"$input", "r_swig_cb_data->retValue"); - Replaceall(tm,"$target", "result"); + Replaceall(tm,"$target", Swig_cresult_name()); replaceRClass(tm, rettype); Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); Replaceall(tm,"$disown","0"); @@ -693,7 +693,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { Printv(f->code, "\n", UnProtectWrapupCode, NIL); if(!isVoidType) - Printv(f->code, "return result;\n", NIL); + Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL); Printv(f->code, "\n}\n", NIL); @@ -1975,7 +1975,7 @@ int R::functionWrapper(Node *n) { String *actioncode = emit_action(n); /* Deal with the explicit return value. */ - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { SwigType *retType = Getattr(n, "type"); //Printf(stderr, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no"); /* if(SwigType_isarray(retType)) { @@ -1983,7 +1983,7 @@ int R::functionWrapper(Node *n) { } */ - Replaceall(tm,"$1", "result"); + Replaceall(tm,"$1", Swig_cresult_name()); Replaceall(tm,"$result", "r_ans"); replaceRClass(tm, retType); @@ -2043,8 +2043,8 @@ int R::functionWrapper(Node *n) { /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { - Replaceall(tm, "$source", "result"); /* deprecated */ + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } @@ -2052,8 +2052,7 @@ int R::functionWrapper(Node *n) { Printv(f->code, UnProtectWrapupCode, NIL); /*If the user gave us something to convert the result in */ - if ((tm = Swig_typemap_lookup("scoerceout", n, - "result", sfun))) { + if ((tm = Swig_typemap_lookup("scoerceout", n, Swig_cresult_name(), sfun))) { Replaceall(tm,"$source","ans"); Replaceall(tm,"$result","ans"); replaceRClass(tm, Getattr(n, "type")); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index a12d93b68..5d3adce80 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1827,9 +1827,9 @@ public: Wrapper_add_local(f, "classname", classname); } if (action) { - Append(action, "\nDATA_PTR(self) = result;"); + Printf(action, "\nDATA_PTR(self) = %s;", Swig_cresult_name()); if (GetFlag(pn, "feature:trackobjects")) { - Append(action, "\nSWIG_RubyAddTracking(result, self);"); + Printf(action, "\nSWIG_RubyAddTracking(%s, self);", Swig_cresult_name()); } } } @@ -1855,13 +1855,13 @@ public: if (SwigType_type(t) != T_VOID && current != CONSTRUCTOR_INITIALIZE) { need_result = 1; if (GetFlag(n, "feature:predicate")) { - Printv(actioncode, tab4, "vresult = (result ? Qtrue : Qfalse);\n", NIL); + Printv(actioncode, tab4, "vresult = (", Swig_cresult_name(), " ? Qtrue : Qfalse);\n", NIL); } else { - tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode); + tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode); actioncode = 0; if (tm) { Replaceall(tm, "$result", "vresult"); - Replaceall(tm, "$source", "result"); + Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$target", "vresult"); if (GetFlag(n, "feature:new")) @@ -1890,7 +1890,7 @@ public: } if (unwrap) { Wrapper_add_local(f, "director", "Swig::Director *director = 0"); - Printf(f->code, "director = dynamic_cast(result);\n"); + Printf(f->code, "director = dynamic_cast(%s);\n", Swig_cresult_name()); Printf(f->code, "if (director) {\n"); Printf(f->code, " vresult = director->swig_get_self();\n"); Printf(f->code, "} else {\n"); @@ -1925,7 +1925,6 @@ public: Printf(f->code, "#endif\n"); } else if (current == CONSTRUCTOR_INITIALIZE) { need_result = 1; - // Printf(f->code, "DATA_PTR(self) = result;\n"); } else { @@ -1953,25 +1952,25 @@ public: /* Look for any remaining cleanup. This processes the %new directive */ if (current != CONSTRUCTOR_ALLOCATE && GetFlag(n, "feature:new")) { - tm = Swig_typemap_lookup("newfree", n, "result", 0); + tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0); if (tm) { - Replaceall(tm, "$source", "result"); + Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, "\n", NIL); Delete(tm); } } /* Special processing on return value. */ - tm = Swig_typemap_lookup("ret", n, "result", 0); + tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0); if (tm) { - Replaceall(tm, "$source", "result"); + Replaceall(tm, "$source", Swig_cresult_name()); Printv(f->code, tm, NIL); Delete(tm); } if (director_method) { - if ((tm = Swig_typemap_lookup("directorfree", n, "result", 0))) { - Replaceall(tm, "$input", "result"); + if ((tm = Swig_typemap_lookup("directorfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$input", Swig_cresult_name()); Replaceall(tm, "$result", "vresult"); Printf(f->code, "%s\n", tm); } @@ -2947,7 +2946,7 @@ public: String *depthCountName = NewStringf("%s_%s_call_depth", className, methodName); // Check for an exception typemap of some kind - String *tm = Swig_typemap_lookup("director:except", n, "result", 0); + String *tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0); if (!tm) { tm = Getattr(n, "feature:director:except"); } @@ -2960,11 +2959,11 @@ public: // Function body Printf(body->def, "VALUE %s(VALUE data) {\n", bodyName); Wrapper_add_localv(body, "args", "Swig::body_args *", "args", "= reinterpret_cast(data)", NIL); - Wrapper_add_localv(body, "result", "VALUE", "result", "= Qnil", NIL); + Wrapper_add_localv(body, Swig_cresult_name(), "VALUE", Swig_cresult_name(), "= Qnil", NIL); Printf(body->code, "%s++;\n", depthCountName); - Printv(body->code, "result = rb_funcall2(args->recv, args->id, args->argc, args->argv);\n", NIL); + Printv(body->code, Swig_cresult_name(), " = rb_funcall2(args->recv, args->id, args->argc, args->argv);\n", NIL); Printf(body->code, "%s--;\n", depthCountName); - Printv(body->code, "return result;\n", NIL); + Printv(body->code, "return ", Swig_cresult_name(), ";\n", NIL); Printv(body->code, "}", NIL); // Exception handler @@ -2991,7 +2990,7 @@ public: } else { Printv(w->code, "args.argv = 0;\n", NIL); } - Printf(w->code, "result = rb_protect(PROTECTFUNC(%s), reinterpret_cast(&args), &status);\n", bodyName); + Printf(w->code, "%s = rb_protect(PROTECTFUNC(%s), reinterpret_cast(&args), &status);\n", Swig_cresult_name(), bodyName); if ( initstack ) Printf(w->code, "SWIG_RELEASE_STACK;\n"); Printf(w->code, "if (status) {\n"); Printf(w->code, "VALUE lastErr = rb_gv_get(\"$!\");\n"); @@ -3005,9 +3004,9 @@ public: Wrapper_print(rescue, f_directors_helpers); } else { if (argc > 0) { - Printf(w->code, "result = rb_funcall(swig_get_self(), rb_intern(\"%s\"), %d%s);\n", methodName, argc, args); + Printf(w->code, "%s = rb_funcall(swig_get_self(), rb_intern(\"%s\"), %d%s);\n", Swig_cresult_name(), methodName, argc, args); } else { - Printf(w->code, "result = rb_funcall(swig_get_self(), rb_intern(\"%s\"), 0, NULL);\n", methodName); + Printf(w->code, "%s = rb_funcall(swig_get_self(), rb_intern(\"%s\"), 0, NULL);\n", Swig_cresult_name(), methodName); } if ( initstack ) Printf(w->code, "SWIG_RELEASE_STACK;\n"); } @@ -3273,7 +3272,9 @@ public: } /* declare Ruby return value */ - Wrapper_add_local(w, "result", "VALUE result"); + String *value_result = NewStringf("VALUE %s", Swig_cresult_name()); + Wrapper_add_local(w, Swig_cresult_name(), value_result); + Delete(value_result); /* wrap complex arguments to VALUEs */ Printv(w->code, wrap_args, NIL); @@ -3294,7 +3295,7 @@ public: if (outputs > 1) { Wrapper_add_local(w, "output", "VALUE output"); - Printf(w->code, "if (TYPE(result) != T_ARRAY) {\n"); + Printf(w->code, "if (TYPE(%s) != T_ARRAY) {\n", Swig_cresult_name()); Printf(w->code, "Ruby_DirectorTypeMismatchException(\"Ruby method failed to return an array.\");\n"); Printf(w->code, "}\n"); } @@ -3309,14 +3310,14 @@ public: * It's not just me, similar silliness also occurs in Language::cDeclaration(). */ Setattr(n, "type", return_type); - tm = Swig_typemap_lookup("directorout", n, "result", w); + tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); Setattr(n, "type", type); if (tm != 0) { if (outputs > 1 && !asvoid ) { - Printf(w->code, "output = rb_ary_entry(result, %d);\n", idx++); + Printf(w->code, "output = rb_ary_entry(%s, %d);\n", Swig_cresult_name(), idx++); Replaceall(tm, "$input", "output"); } else { - Replaceall(tm, "$input", "result"); + Replaceall(tm, "$input", Swig_cresult_name()); } /* TODO check this */ if (Getattr(n, "wrap:disown")) { @@ -3338,10 +3339,10 @@ public: for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) { if (outputs > 1) { - Printf(w->code, "output = rb_ary_entry(result, %d);\n", idx++); + Printf(w->code, "output = rb_ary_entry(%s, %d);\n", Swig_cresult_name(), idx++); Replaceall(tm, "$input", "output"); } else { - Replaceall(tm, "$input", "result"); + Replaceall(tm, "$input", Swig_cresult_name()); } Replaceall(tm, "$result", Getattr(p, "name")); Printv(w->code, tm, "\n", NIL); diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 26d2701b8..3913392c4 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -460,8 +460,8 @@ public: /* Need to redo all of this code (eventually) */ /* Return value if necessary */ - if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { + Replaceall(tm, "$source", Swig_cresult_name()); #ifdef SWIG_USE_RESULTOBJ Replaceall(tm, "$target", "resultobj"); Replaceall(tm, "$result", "resultobj"); @@ -488,14 +488,14 @@ public: /* Look for any remaining cleanup */ if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } } - if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) { - Replaceall(tm, "$source", "result"); + if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$source", Swig_cresult_name()); Printf(f->code, "%s\n", tm); } #ifdef SWIG_USE_RESULTOBJ diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index 728319dfb..3fcb4dcd1 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -324,7 +324,7 @@ int UFFI::functionWrapper(Node *n) { //" :strings-convert t\n" //" :call-direct %s\n" //" :optimize-for-space t" - ")\n", get_ffi_type(n, Getattr(n, "type"), "result") + ")\n", get_ffi_type(n, Getattr(n, "type"), Swig_cresult_name()) //,varargs ? "nil" : "t" ); diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index a996c6e29..5e2e6367d 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -17,6 +17,7 @@ char cvsroot_cwrap_c[] = "$Id$"; #include "swig.h" extern int cparse_cplusplus; +static const char *cresult_variable_name = "result"; static Parm *nonvoid_parms(Parm *p) { if (p) { @@ -28,7 +29,28 @@ static Parm *nonvoid_parms(Parm *p) { } /* ----------------------------------------------------------------------------- - * Swig_parm_name() + * Swig_cresult_name_set() + * + * Change the name of the variable used to hold the return value from C/C++ wrapper functions + * from the default "result". + * ----------------------------------------------------------------------------- */ + +void Swig_cresult_name_set(const char *new_name) { + cresult_variable_name = new_name; +} + +/* ----------------------------------------------------------------------------- + * Swig_cresult_name() + * + * Get the name of the variable used to hold the return value from C/C++ wrapper functions + * ----------------------------------------------------------------------------- */ + +const char *Swig_cresult_name(void) { + return cresult_variable_name; +} + +/* ----------------------------------------------------------------------------- + * Swig_cparm_name() * * Generates a name for the ith argument in an argument list * ----------------------------------------------------------------------------- */ @@ -880,7 +902,7 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas } call = Swig_cmethod_call(explicitcall_name ? explicitcall_name : name, p, self, explicit_qualifier, director_type); - cres = Swig_cresult(Getattr(n, "type"), "result", call); + cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call); if (pure_virtual && is_director && (flags & CWRAP_DIRECTOR_TWO_CALLS)) { String *qualifier = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname")); @@ -893,7 +915,7 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas /* Create two method calls, one to call the explicit method, the other a normal polymorphic function call */ String *cres_both_calls = NewStringf(""); String *call_extra = Swig_cmethod_call(name, p, self, 0, director_type); - String *cres_extra = Swig_cresult(Getattr(n, "type"), "result", call_extra); + String *cres_extra = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call_extra); Printv(cres_both_calls, "if (upcall) {\n", cres, "\n", "} else {", cres_extra, "\n}", NIL); Setattr(n, "wrap:action", cres_both_calls); Delete(cres_extra); @@ -974,12 +996,12 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas } } Append(func, ")"); - cres = Swig_cresult(Getattr(n, "type"), "result", func); + cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), func); Setattr(n, "wrap:action", cres); Delete(cres); } else { String *call = Swig_cfunction_call(mangled, p); - String *cres = Swig_cresult(Getattr(n, "type"), "result", call); + String *cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(call); Delete(cres); @@ -1089,7 +1111,7 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String } call = Swig_cfunction_call(mangled, parms); - cres = Swig_cresult(type, "result", call); + cres = Swig_cresult(type, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); @@ -1120,7 +1142,7 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String * implemented in the target language, calls to those methods will * generate Swig::DirectorPureVirtualException exceptions. */ - String *cres = Swig_cresult(type, "result", director_call); + String *cres = Swig_cresult(type, Swig_cresult_name(), director_call); Append(action, cres); Delete(cres); } else { @@ -1135,11 +1157,11 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String Append(action, director_ctor); Replaceall(action, "$comparison", tmp_none_comparison); - cres = Swig_cresult(type, "result", director_call); + cres = Swig_cresult(type, Swig_cresult_name(), director_call); Replaceall(action, "$director_new", cres); Delete(cres); - cres = Swig_cresult(type, "result", nodirector_call); + cres = Swig_cresult(type, Swig_cresult_name(), nodirector_call); Replaceall(action, "$nondirector_new", cres); Delete(cres); } @@ -1149,14 +1171,14 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String Delete(directorname); } else { String *call = Swig_cppconstructor_call(classname, parms); - String *cres = Swig_cresult(type, "result", call); + String *cres = Swig_cresult(type, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); } } else { String *call = Swig_cconstructor_call(classname); - String *cres = Swig_cresult(type, "result", call); + String *cres = Swig_cresult(type, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); @@ -1371,7 +1393,7 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) { Swig_add_extension_code(n, mangled, parms, ty, code, cparse_cplusplus, "self"); } call = Swig_cfunction_call(mangled, parms); - cres = Swig_cresult(ty, "result", call); + cres = Swig_cresult(ty, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(cres); @@ -1381,7 +1403,7 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) { Delete(gname); } else { String *call = Swig_cmemberget_call(name, type, self, varcref); - String *cres = Swig_cresult(ty, "result", call); + String *cres = Swig_cresult(ty, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(call); Delete(cres); @@ -1472,14 +1494,14 @@ int Swig_VargetToFunction(Node *n, int flags) { String *sname = Swig_name_get(0, name); String *mangled = Swig_name_mangle(sname); call = Swig_cfunction_call(mangled, 0); - cres = Swig_cresult(ty, "result", call); + cres = Swig_cresult(ty, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(mangled); Delete(sname); } else { String *nname = SwigType_namestr(name); call = Swig_wrapped_var_assign(type, nname, varcref); - cres = Swig_cresult(ty, "result", call); + cres = Swig_cresult(ty, Swig_cresult_name(), call); Setattr(n, "wrap:action", cres); Delete(nname); } diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index fcb79c142..e9185600a 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -335,6 +335,8 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern String *Swig_stringify_with_location(DOH *object); /* --- C Wrappers --- */ + extern void Swig_cresult_name_set(const char *new_name); + extern const char *Swig_cresult_name(void); extern String *Swig_cparm_name(Parm *p, int i); extern String *Swig_wrapped_var_type(SwigType *t, int varcref); extern int Swig_cargs(Wrapper *w, ParmList *l); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 0d582a157..5b1ced0b5 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1390,6 +1390,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No * If f and actioncode are NULL, then the caller is just looking to attach the "out" attributes * ie, not use the typemap code, otherwise both f and actioncode must be non null. */ if (actioncode) { + const String *result_equals = NewStringf("%s = ", Swig_cresult_name()); clname = Copy(actioncode); /* check that the code in the typemap can be used in this optimal way. * The code should be in the form "result = ...;\n". We need to extract @@ -1398,8 +1399,8 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No * hack and circumvents the normal requirement for a temporary variable * to hold the result returned from a wrapped function call. */ - if (Strncmp(clname, "result = ", 9) == 0) { - int numreplacements = Replace(clname, "result = ", "", DOH_REPLACE_ID_BEGIN); + if (Strncmp(clname, result_equals, 9) == 0) { + int numreplacements = Replace(clname, result_equals, "", DOH_REPLACE_ID_BEGIN); if (numreplacements == 1) { numreplacements = Replace(clname, ";\n", "", DOH_REPLACE_ID_END); if (numreplacements == 1) { From 0463a49df537e35c6543a918238f89491536abea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Nov 2011 23:06:53 +0000 Subject: [PATCH 076/147] Fix named output typemaps not being used when the symbol uses a qualifier and contains a number git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12831 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++++ Examples/test-suite/typemap_various.i | 17 +++++++++++++++++ Source/Swig/symbol.c | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 438be71ab..768fae509 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,12 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-01: wsfulton + Fix named output typemaps not being used when the symbol uses a qualifier and contains + a number, eg: + + %typemap(out) double ABC::m1 "..." + 2011-10-24: talby [perl5] SF bug #3423119 - overload dispatch stack corruption fix. Better, but more research is needed on a stable path for tail calls in XS. diff --git a/Examples/test-suite/typemap_various.i b/Examples/test-suite/typemap_various.i index 0b7035ecf..58dbe6667 100644 --- a/Examples/test-suite/typemap_various.i +++ b/Examples/test-suite/typemap_various.i @@ -55,3 +55,20 @@ void foo2(Foo f, const Foo& ff) {} }; } + +// Test obscure bug where named typemaps where not being applied when symbol name contained a number +%typemap(out) double "_typemap_for_double_no_compile_" +%typemap(out) double ABC::meth "$1 = 0.0;" +%typemap(out) double ABC::m1 "$1 = 0.0;" +%typemap(out) double ABC::_x2 "$1 = 0.0;" +%typemap(out) double ABC::y_ "$1 = 0.0;" +%typemap(out) double ABC::_3 "$1 = 0.0;" +%inline %{ +struct ABC { + double meth() {} + double m1() {} + double _x2() {} + double y_() {} + double _3() {} +}; +%} diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index fd6644bb2..5ee6c3ec0 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -1749,8 +1749,9 @@ String *Swig_symbol_string_qualify(String *s, Symtab *st) { String *id = NewStringEmpty(); String *r = NewStringEmpty(); char *c = Char(s); + int first_char = 1; while (*c) { - if (isalpha((int) *c) || (*c == '_') || (*c == ':')) { + if (isalpha((int) *c) || (*c == '_') || (*c == ':') || (isdigit((int) *c) && !first_char)) { Putc(*c, id); have_id = 1; } else { @@ -1763,6 +1764,7 @@ String *Swig_symbol_string_qualify(String *s, Symtab *st) { } Putc(*c, r); } + first_char = (*c == ':'); c++; } if (have_id) { From 3c1ca906ac28d061b811f4388524c080dec03613 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 Nov 2011 19:41:09 +0000 Subject: [PATCH 077/147] Expand special variables in typemap warnings git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12832 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++ Examples/test-suite/errors/expected.log | 7 +++ Examples/test-suite/errors/make.sh | 1 + .../test-suite/errors/swig_typemap_warn.i | 7 +++ Source/Swig/typemap.c | 45 ++++++++++++++----- 5 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 Examples/test-suite/errors/swig_typemap_warn.i diff --git a/CHANGES.current b/CHANGES.current index 768fae509..9b6d456dd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-03: wsfulton + Expand special variables in typemap warnings, eg: + + %typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name") int "..." + 2011-11-01: wsfulton Fix named output typemaps not being used when the symbol uses a qualifier and contains a number, eg: diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log index 2779469ca..6615d0fdb 100644 --- a/Examples/test-suite/errors/expected.log +++ b/Examples/test-suite/errors/expected.log @@ -205,6 +205,13 @@ $source by $input and $target by $1. For typemaps related to return values (ou argout,ret,except), replace $source by $1 and $target by $result. See the file Doc/Manual/Typemaps.html for complete details. +:::::::::::::::::::::::::::::::: swig_typemap_warn.i ::::::::::::::::::::::::::::::::::: +swig_typemap_warn.i:7: Warning 1001: Test warning for 'out' typemap for double mmm (result) - name: mmm symname: mmm &1_ltype: double * descriptor: SWIGTYPE_double +swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int +swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg2 (arg2) - argnum: 2 &1_ltype: int * descriptor: SWIGTYPE_int +swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int +swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg2 (arg2) - argnum: 2 &1_ltype: int * descriptor: SWIGTYPE_int + :::::::::::::::::::::::::::::::: cpp_bad_extern.i ::::::::::::::::::::::::::::::::::: cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL". cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL". diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh index 44d58a344..e243315ec 100755 --- a/Examples/test-suite/errors/make.sh +++ b/Examples/test-suite/errors/make.sh @@ -58,6 +58,7 @@ swig_identifier swig_insert_bad swig_typemap_copy swig_typemap_old +swig_typemap_warn ' # Files run in C++ mode diff --git a/Examples/test-suite/errors/swig_typemap_warn.i b/Examples/test-suite/errors/swig_typemap_warn.i new file mode 100644 index 000000000..057eb3e29 --- /dev/null +++ b/Examples/test-suite/errors/swig_typemap_warn.i @@ -0,0 +1,7 @@ +%module xxx + +%typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name ($1) - argnum: $argnum &1_ltype: $&1_ltype descriptor: $1_descriptor") int "" + +%typemap(out, warning="1001:Test warning for 'out' typemap for $1_type $1_name ($1) - name: $name symname: $symname &1_ltype: $&1_ltype descriptor: $1_descriptor") double "" + +double mmm(int abc, int); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 5b1ced0b5..ee3e8da36 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1254,16 +1254,15 @@ static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) { * typemap_warn() * * If any warning message is attached to this parameter's "tmap::warning" - * attribute, print that warning message. + * attribute, return the warning message (special variables will need expanding + * before displaying the warning). * ----------------------------------------------------------------------------- */ -static void typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) { +static String *typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) { String *temp = NewStringf("%s:warning", tmap_method); String *w = Getattr(p, typemap_method_name(temp)); Delete(temp); - if (w) { - Swig_warning(0, Getfile(p), Getline(p), "%s\n", w); - } + return w ? Copy(w) : 0; } /* ----------------------------------------------------------------------------- @@ -1298,6 +1297,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No Hash *tm = 0; String *s = 0; String *sdef = 0; + String *warning = 0; ParmList *locals; ParmList *kw; char temp[256]; @@ -1443,10 +1443,16 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No lname = clname; } + warning = typemap_warn(cmethod, node); + if (mtype && SwigType_isarray(mtype)) { num_substitutions = typemap_replace_vars(s, locals, mtype, type, pname, (char *) lname, 1); + if (warning) + typemap_replace_vars(warning, 0, mtype, type, pname, (char *) lname, 1); } else { num_substitutions = typemap_replace_vars(s, locals, type, type, pname, (char *) lname, 1); + if (warning) + typemap_replace_vars(warning, 0, type, type, pname, (char *) lname, 1); } if (optimal_substitution && num_substitutions > 1) { Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to\n", Swig_name_decl(node)); @@ -1467,8 +1473,16 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No Replace(s, "$name", pname, DOH_REPLACE_ANY); symname = Getattr(node, "sym:name"); - if (symname) { + if (symname) Replace(s, "$symname", symname, DOH_REPLACE_ANY); + + /* Print warnings, if any */ + if (warning) { + Replace(warning, "$name", pname, DOH_REPLACE_ANY); + if (symname) + Replace(warning, "$symname", symname, DOH_REPLACE_ANY); + Swig_warning(0, Getfile(node), Getline(node), "%s\n", warning); + Delete(warning); } Setattr(node, typemap_method_name(tmap_method), s); @@ -1483,9 +1497,6 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No Setattr(node, typemap_method_name(temp), "1"); } - /* Print warnings, if any */ - typemap_warn(cmethod, node); - /* Look for code fragments */ { String *fragment; @@ -1606,6 +1617,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p int nmatch = 0; int i; String *s; + String *warning = 0; ParmList *locals; int argnum = 0; char temp[256]; @@ -1705,6 +1717,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p if (locals) locals = CopyParmList(locals); firstp = p; + warning = typemap_warn(tmap_method, firstp); #ifdef SWIG_DEBUG Printf(stdout, "nmatch: %d\n", nmatch); #endif @@ -1722,9 +1735,13 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p if (mtype) { typemap_replace_vars(s, locals, mtype, type, pname, lname, i + 1); + if (warning) + typemap_replace_vars(warning, 0, mtype, type, pname, lname, i + 1); Delattr(p, "tmap:match"); } else { typemap_replace_vars(s, locals, type, type, pname, lname, i + 1); + if (warning) + typemap_replace_vars(warning, 0, type, type, pname, lname, i + 1); } if (Checkattr(tm, "type", "SWIGTYPE")) { @@ -1750,6 +1767,13 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p #endif Setattr(firstp, typemap_method_name(tmap_method), s); /* Code object */ + /* Print warnings, if any */ + if (warning) { + Replace(warning, "$argnum", temp, DOH_REPLACE_ANY); + Swig_warning(0, Getfile(firstp), Getline(firstp), "%s\n", warning); + Delete(warning); + } + if (locals) { sprintf(temp, "%s:locals", cmethod); Setattr(firstp, typemap_method_name(temp), locals); @@ -1763,9 +1787,6 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p /* Attach kwargs */ typemap_attach_kwargs(tm, tmap_method, firstp); - /* Print warnings, if any */ - typemap_warn(tmap_method, firstp); - /* Look for code fragments */ typemap_emit_code_fragments(tmap_method, firstp); From bb3528c480463e58a07d381638c08b1a5ffce24d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 Nov 2011 20:31:35 +0000 Subject: [PATCH 078/147] Expand special variables in typemap warnings - rework implementation git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12833 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/errors/expected.log | 6 +- .../test-suite/errors/swig_typemap_warn.i | 2 +- Source/Swig/typemap.c | 90 ++++++++----------- 3 files changed, 44 insertions(+), 54 deletions(-) diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log index 6615d0fdb..b7883c403 100644 --- a/Examples/test-suite/errors/expected.log +++ b/Examples/test-suite/errors/expected.log @@ -206,11 +206,13 @@ argout,ret,except), replace $source by $1 and $target by $result. See the file Doc/Manual/Typemaps.html for complete details. :::::::::::::::::::::::::::::::: swig_typemap_warn.i ::::::::::::::::::::::::::::::::::: +swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int +swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int swig_typemap_warn.i:7: Warning 1001: Test warning for 'out' typemap for double mmm (result) - name: mmm symname: mmm &1_ltype: double * descriptor: SWIGTYPE_double swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int -swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg2 (arg2) - argnum: 2 &1_ltype: int * descriptor: SWIGTYPE_int +swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int -swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg2 (arg2) - argnum: 2 &1_ltype: int * descriptor: SWIGTYPE_int +swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int :::::::::::::::::::::::::::::::: cpp_bad_extern.i ::::::::::::::::::::::::::::::::::: cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL". diff --git a/Examples/test-suite/errors/swig_typemap_warn.i b/Examples/test-suite/errors/swig_typemap_warn.i index 057eb3e29..f0545bca1 100644 --- a/Examples/test-suite/errors/swig_typemap_warn.i +++ b/Examples/test-suite/errors/swig_typemap_warn.i @@ -4,4 +4,4 @@ %typemap(out, warning="1001:Test warning for 'out' typemap for $1_type $1_name ($1) - name: $name symname: $symname &1_ltype: $&1_ltype descriptor: $1_descriptor") double "" -double mmm(int abc, int); +double mmm(int abc, short def, int); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index ee3e8da36..60d15ea99 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1308,6 +1308,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No int optimal_attribute = 0; int optimal_substitution = 0; int num_substitutions = 0; + SwigType *matchtype = 0; type = Getattr(node, "type"); if (!type) @@ -1443,17 +1444,8 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No lname = clname; } - warning = typemap_warn(cmethod, node); - - if (mtype && SwigType_isarray(mtype)) { - num_substitutions = typemap_replace_vars(s, locals, mtype, type, pname, (char *) lname, 1); - if (warning) - typemap_replace_vars(warning, 0, mtype, type, pname, (char *) lname, 1); - } else { - num_substitutions = typemap_replace_vars(s, locals, type, type, pname, (char *) lname, 1); - if (warning) - typemap_replace_vars(warning, 0, type, type, pname, (char *) lname, 1); - } + matchtype = mtype && SwigType_isarray(mtype) ? mtype : type; + num_substitutions = typemap_replace_vars(s, locals, matchtype, type, pname, (char *) lname, 1); if (optimal_substitution && num_substitutions > 1) { Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to\n", Swig_name_decl(node)); Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "optimal attribute usage in the out typemap.\n"); @@ -1476,15 +1468,6 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No if (symname) Replace(s, "$symname", symname, DOH_REPLACE_ANY); - /* Print warnings, if any */ - if (warning) { - Replace(warning, "$name", pname, DOH_REPLACE_ANY); - if (symname) - Replace(warning, "$symname", symname, DOH_REPLACE_ANY); - Swig_warning(0, Getfile(node), Getline(node), "%s\n", warning); - Delete(warning); - } - Setattr(node, typemap_method_name(tmap_method), s); if (locals) { sprintf(temp, "%s:locals", cmethod); @@ -1497,6 +1480,17 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No Setattr(node, typemap_method_name(temp), "1"); } + /* Print warnings, if any */ + warning = typemap_warn(cmethod, node); + if (warning) { + typemap_replace_vars(warning, 0, matchtype, type, pname, (char *) lname, 1); + Replace(warning, "$name", pname, DOH_REPLACE_ANY); + if (symname) + Replace(warning, "$symname", symname, DOH_REPLACE_ANY); + Swig_warning(0, Getfile(node), Getline(node), "%s\n", warning); + Delete(warning); + } + /* Look for code fragments */ { String *fragment; @@ -1717,32 +1711,19 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p if (locals) locals = CopyParmList(locals); firstp = p; - warning = typemap_warn(tmap_method, firstp); #ifdef SWIG_DEBUG Printf(stdout, "nmatch: %d\n", nmatch); #endif for (i = 0; i < nmatch; i++) { - SwigType *type; - String *pname; - String *lname; - SwigType *mtype; + SwigType *type = Getattr(p, "type"); + String *pname = Getattr(p, "name"); + String *lname = Getattr(p, "lname"); + SwigType *mtype = Getattr(p, "tmap:match"); + SwigType *matchtype = mtype ? mtype : type; - - type = Getattr(p, "type"); - pname = Getattr(p, "name"); - lname = Getattr(p, "lname"); - mtype = Getattr(p, "tmap:match"); - - if (mtype) { - typemap_replace_vars(s, locals, mtype, type, pname, lname, i + 1); - if (warning) - typemap_replace_vars(warning, 0, mtype, type, pname, lname, i + 1); + typemap_replace_vars(s, locals, matchtype, type, pname, lname, i + 1); + if (mtype) Delattr(p, "tmap:match"); - } else { - typemap_replace_vars(s, locals, type, type, pname, lname, i + 1); - if (warning) - typemap_replace_vars(warning, 0, type, type, pname, lname, i + 1); - } if (Checkattr(tm, "type", "SWIGTYPE")) { sprintf(temp, "%s:SWIGTYPE", cmethod); @@ -1757,23 +1738,12 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p replace_embedded_typemap(s, firstp, f, tm); - /* Replace the argument number */ - sprintf(temp, "%d", argnum); - Replace(s, "$argnum", temp, DOH_REPLACE_ANY); - /* Attach attributes to object */ #ifdef SWIG_DEBUG Printf(stdout, "attach: %s %s %s\n", Getattr(firstp, "name"), typemap_method_name(tmap_method), s); #endif Setattr(firstp, typemap_method_name(tmap_method), s); /* Code object */ - /* Print warnings, if any */ - if (warning) { - Replace(warning, "$argnum", temp, DOH_REPLACE_ANY); - Swig_warning(0, Getfile(firstp), Getline(firstp), "%s\n", warning); - Delete(warning); - } - if (locals) { sprintf(temp, "%s:locals", cmethod); Setattr(firstp, typemap_method_name(temp), locals); @@ -1787,6 +1757,24 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p /* Attach kwargs */ typemap_attach_kwargs(tm, tmap_method, firstp); + /* Replace the argument number */ + sprintf(temp, "%d", argnum); + Replace(s, "$argnum", temp, DOH_REPLACE_ANY); + + /* Print warnings, if any */ + warning = typemap_warn(tmap_method, firstp); + if (warning) { + SwigType *type = Getattr(firstp, "type"); + String *pname = Getattr(firstp, "name"); + String *lname = Getattr(firstp, "lname"); + SwigType *mtype = Getattr(firstp, "tmap:match"); + SwigType *matchtype = mtype ? mtype : type; + typemap_replace_vars(warning, 0, matchtype, type, pname, lname, 1); + Replace(warning, "$argnum", temp, DOH_REPLACE_ANY); + Swig_warning(0, Getfile(firstp), Getline(firstp), "%s\n", warning); + Delete(warning); + } + /* Look for code fragments */ typemap_emit_code_fragments(tmap_method, firstp); From e00bbdc59177a8a14745eaeb9a2c376c0dc97518 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 4 Nov 2011 19:51:17 +0000 Subject: [PATCH 079/147] Add docs on special variable expansion in typemap warnings git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12834 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Typemaps.html | 8 ++++++++ Doc/Manual/Warnings.html | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 6331aa1ac..184062c42 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -3597,6 +3597,14 @@ with non-consecutive C/C++ arguments; a workaround such as a helper function re- the arguments to make them consecutive will need to be written.

              +

              10.10 Typemap warnings

              + +

              +Warnings can be added to typemaps so that SWIG generates a warning message whenever the typemap is used. +See the information in the issuing warnings section. +

              + +

              10.10 Typemap fragments

              diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 8d155ec99..2a3ce560d 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -257,16 +257,23 @@ Warning messages can be associated with typemaps using the
              -%typemap(in, warning="901:You are really going to regret this") blah * {
              +%typemap(in, warning="901:You are really going to regret this usage of $1_type $1_name") blah * {
                  ...
               }
               

              -In this case, the warning message will be printed whenever the typemap is actually used. +In this case, the warning message will be printed whenever the typemap is actually used and the special variables will be expanded as appropriate, for example:

              +
              +
              +example.i:23: Warning 901: You are really going to regret this usage of blah * self
              +example.i:24: Warning 901: You are really going to regret this usage of blah * stuff
              +
              +
              +

              14.5 Symbolic symbols

              From 2bf6de71b874e41eda8c26e773375af25cf95df8 Mon Sep 17 00:00:00 2001 From: Stefan Zager Date: Sat, 5 Nov 2011 03:35:03 +0000 Subject: [PATCH 080/147] bug 3429388: python unsigned integer handling on 32-bit architectures. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12835 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/python/pyhead.swg | 1 + Lib/python/pyprimtypes.swg | 7 +++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 9b6d456dd..db12bd864 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-04: szager + [python] Bug 3429388: python unsigned integer handling on 32-bit architectures. + 2011-11-03: wsfulton Expand special variables in typemap warnings, eg: diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index 803cd0745..206b81a37 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -4,6 +4,7 @@ #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) #define PyInt_Check(x) PyLong_Check(x) #define PyInt_AsLong(x) PyLong_AsLong(x) +#define PyInt_AsUnsignedLongMask(x) PyLong_AsUnsignedLongMask(x) #define PyInt_FromLong(x) PyLong_FromLong(x) #define PyString_Check(name) PyBytes_Check(name) #define PyString_FromString(x) PyUnicode_FromString(x) diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg index aa5ddaf62..43a3375b7 100644 --- a/Lib/python/pyprimtypes.swg +++ b/Lib/python/pyprimtypes.swg @@ -100,13 +100,12 @@ SWIGINTERN int SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val) { if (PyInt_Check(obj)) { - long v = PyInt_AsLong(obj); - if (v >= 0) { + unsigned long v = PyInt_AsUnsignedLongMask(obj); + if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; - } else { - return SWIG_OverflowError; } + PyErr_Clear(); } else if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { From 498e564e849097e58c1afa63017bec5f46f179d4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Nov 2011 00:10:40 +0000 Subject: [PATCH 081/147] Fix pcre-build.sh to work with non-compressed tarballs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12836 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Tools/pcre-build.sh | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index db12bd864..7de2131e2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-11: wsfulton + Fix pcre-build.sh to work with non-compressed tarballs - problem reported by Adrian Blakely. + 2011-11-04: szager [python] Bug 3429388: python unsigned integer handling on 32-bit architectures. diff --git a/Tools/pcre-build.sh b/Tools/pcre-build.sh index 876a58a7e..2d991ceba 100755 --- a/Tools/pcre-build.sh +++ b/Tools/pcre-build.sh @@ -36,8 +36,9 @@ fi echo "Looking for PCRE tarball..." rm -rf pcre -pcre_tarball=`ls pcre-*.tar.*` -test -f "$pcre_tarball" || bail "Could not find tarball" +pcre_tarball=`ls pcre-*.tar*` +test -n "$pcre_tarball" || bail "Could not find tarball matching pattern: pcre-*.tar*" +test -f "$pcre_tarball" || bail "Could not find a single PCRE tarball. Found: $pcre_tarball" echo "Extracting tarball: $pcre_tarball" tar -xf $pcre_tarball || bail "Could not untar $pcre_tarball" From f13d958214e1a8ee69d1591592663c42faa83564 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 13 Nov 2011 17:08:15 +0000 Subject: [PATCH 082/147] same class name in different namespaces confusion when using multiple modules. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12837 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/ruby.cxx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 7de2131e2..ab1bb867d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-13: wsfulton + [Ruby] Apply patch #3421876 from Robin Stocke to fix #3416818 - same class name in + different namespaces confusion when using multiple modules. + 2011-11-11: wsfulton Fix pcre-build.sh to work with non-compressed tarballs - problem reported by Adrian Blakely. diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 5d3adce80..6aaa8d398 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2519,7 +2519,7 @@ public: Clear(klass->type); Printv(klass->type, Getattr(n, "classtype"), NIL); - Printv(f_wrappers, "swig_class SwigClass", valid_name, ";\n\n", NIL); + Printv(f_wrappers, "static swig_class SwigClass", valid_name, ";\n\n", NIL); Printv(klass->init, "\n", tab4, NIL); if (!useGlobalModule) { From 3b446d75c13a1491edc72ab89e28729540ebfa6c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Nov 2011 20:06:21 +0000 Subject: [PATCH 083/147] Correct patch submitter's name git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12838 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index ab1bb867d..55b0da85f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -6,7 +6,7 @@ Version 2.0.5 (in progress) =========================== 2011-11-13: wsfulton - [Ruby] Apply patch #3421876 from Robin Stocke to fix #3416818 - same class name in + [Ruby] Apply patch #3421876 from Robin Stocker to fix #3416818 - same class name in different namespaces confusion when using multiple modules. 2011-11-11: wsfulton From 931c331f9f857496dee3ddf16cfdeb0a7038fe23 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Nov 2011 07:56:34 +0000 Subject: [PATCH 084/147] Remove non ascii characters from docs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12839 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/D.html | 4 ++-- Doc/Manual/Java.html | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index abcffa58e..b58ff89e6 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -44,7 +44,7 @@

              20.1 Introduction

              -

              From the D Programming Language web site: »D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code.« As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?

              +

              From the D Programming Language web site: D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code. As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?

              Well, besides the obvious downside that the C header files have to be manually converted to D modules for this to work, there is one major inconvenience with this approach: D code usually is on a higher abstraction level than C, and many of the features that make D interesting are simply not available when dealing with C libraries, requiring you e.g. to manually convert strings between pointers to \0-terminated char arrays and D char arrays, making the algorithms from the D2 standard library unusable with C arrays and data structures, and so on.

              @@ -395,7 +395,7 @@ struct A {

              20.8.2 Native pointer support

              -

              Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a »primtive type« below.

              +

              Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a primitive type below.

              Central to this custom pointer handling scheme are two typemap attributes: the cprimitive attribute on the dtype typemap and the nativepointer attribute on all the typemaps which influence the D side of the code (dtype, din, dout, ...). When a D typemap is looked up, the following happens behind the scenes:

              diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index e2cd2a8f6..8f0790164 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -364,7 +364,7 @@ To load your shared native library module in Java, simply use Java's System. public class runme { static { -  System.loadLibrary("example"); + System.loadLibrary("example"); } public static void main(String argv[]) { @@ -6281,7 +6281,7 @@ public class runme { static { try { -  System.loadLibrary("example"); + System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. " + e); System.exit(1); @@ -6500,7 +6500,7 @@ public class runme { static { try { -  System.loadLibrary("example"); + System.loadLibrary("example"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. " + e); System.exit(1); From 6cedddb2c19cd6e233b917dbce627c5c5bfb2d23 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Nov 2011 20:30:33 +0000 Subject: [PATCH 085/147] Fix platform SWIG is built for shown in -version and correct the detection of the unix like platforms (build) on Windows for which an extra swig library should be added. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12840 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index e960d1abc..a4fa62b52 100644 --- a/configure.in +++ b/configure.in @@ -35,7 +35,7 @@ AM_PROG_CC_C_O # Needed for subdir-objects in AUTOMAKE_OPTIONS AC_COMPILE_WARNINGS # Increase warning levels AC_DEFINE_UNQUOTED(SWIG_CXX, ["$CXX"], [Compiler that built SWIG]) -AC_DEFINE_UNQUOTED(SWIG_PLATFORM, ["$build"], [Platform that SWIG is built for]) +AC_DEFINE_UNQUOTED(SWIG_PLATFORM, ["$host"], [Platform that SWIG is built for]) dnl Checks for header files. AC_HEADER_STDC @@ -2332,7 +2332,7 @@ AC_ARG_WITH(swiglibdir,[ --with-swiglibdir=DIR Put SWIG system-independent li AC_SUBST(swig_lib) AC_DEFINE_DIR(SWIG_LIB, swig_lib, [Directory for SWIG system-independent libraries]) -case $host in +case $build in # Windows does not understand unix directories. Convert into a windows directory with drive letter. *-*-mingw*) SWIG_LIB_WIN_UNIX=`cmd //c echo $SWIG_LIB | sed -e "s/[ ]*$//"`;; # This echo converts unix to mixed paths. Then zap unexpected trailing space. *-*-cygwin*) SWIG_LIB_WIN_UNIX=`cygpath --mixed "$SWIG_LIB"`;; From 3aafb9632547e58a5e893fb820028313408b91ef Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 18 Nov 2011 07:03:49 +0000 Subject: [PATCH 086/147] Bug fix: Remove root directory from directory search list in Windows. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12841 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/main.cxx | 33 ++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 55b0da85f..d0c9deb63 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-17: wsfulton + Bug fix: Remove root directory from directory search list in Windows. + 2011-11-13: wsfulton [Ruby] Apply patch #3421876 from Robin Stocker to fix #3416818 - same class name in different namespaces confusion when using multiple modules. diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 87a0bed8d..4fe5a3f11 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -155,9 +155,9 @@ is equivalent to: \n\ \n"; // Local variables -static String *LangSubDir = 0; // Target language library subdirectory -static char *SwigLib = 0; // Library directory -static String *SwigLibWin = 0; // Extra Library directory for Windows +static String *LangSubDir = 0; // Target language library subdirectory +static String *SwigLib = 0; // Library directory +static String *SwigLibWinUnix = 0; // Extra library directory on Windows static int freeze = 0; static String *lang_config = 0; static char *hpp_extension = (char *) "h"; @@ -581,9 +581,9 @@ void SWIG_getoptions(int argc, char *argv[]) { Swig_cparse_follow_locators(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-swiglib") == 0) { - if (SwigLibWin) - Printf(stdout, "%s\n", SwigLibWin); Printf(stdout, "%s\n", SwigLib); + if (SwigLibWinUnix) + Printf(stdout, "%s\n", SwigLibWinUnix); SWIG_exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-o") == 0) { Swig_mark_arg(i); @@ -914,14 +914,17 @@ int SWIG_main(int argc, char *argv[], Language *l) { char *p; if (!(GetModuleFileName(0, buf, MAX_PATH) == 0 || (p = strrchr(buf, '\\')) == 0)) { *(p + 1) = '\0'; - SwigLibWin = NewStringf("%sLib", buf); // Native windows installation path + SwigLib = NewStringf("%sLib", buf); // Native windows installation path + } else { + SwigLib = NewStringf(""); // Unexpected error } - SwigLib = Swig_copy_string(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw) + if (Len(SWIG_LIB_WIN_UNIX) > 0) + SwigLibWinUnix = NewString(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw) #else - SwigLib = Swig_copy_string(SWIG_LIB); + SwigLib = NewString(SWIG_LIB); #endif } else { - SwigLib = Swig_copy_string(c); + SwigLib = NewString(c); } libfiles = NewList(); @@ -953,9 +956,9 @@ int SWIG_main(int argc, char *argv[], Language *l) { String *rl = NewString(""); Printf(rl, ".%sswig_lib%s%s", SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER, LangSubDir); Swig_add_directory(rl); - if (SwigLibWin) { + if (SwigLibWinUnix) { rl = NewString(""); - Printf(rl, "%s%s%s", SwigLibWin, SWIG_FILE_DELIMITER, LangSubDir); + Printf(rl, "%s%s%s", SwigLibWinUnix, SWIG_FILE_DELIMITER, LangSubDir); Swig_add_directory(rl); } rl = NewString(""); @@ -964,9 +967,9 @@ int SWIG_main(int argc, char *argv[], Language *l) { } Swig_add_directory((String *) "." SWIG_FILE_DELIMITER "swig_lib"); - if (SwigLibWin) - Swig_add_directory((String *) SwigLibWin); - Swig_add_directory((String *) SwigLib); + if (SwigLibWinUnix) + Swig_add_directory((String *) SwigLibWinUnix); + Swig_add_directory(SwigLib); if (Verbose) { Printf(stdout, "Language subdirectory: %s\n", LangSubDir); @@ -1107,7 +1110,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { for (int i = 0; i < Len(files); i++) { int use_file = 1; if (depend == 2) { - if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWin && (Strncmp(Getitem(files, i), SwigLibWin, Len(SwigLibWin)) == 0))) + if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWinUnix && (Strncmp(Getitem(files, i), SwigLibWinUnix, Len(SwigLibWinUnix)) == 0))) use_file = 0; } if (use_file) From 959fdf20538cdec8e8ed7f5890512d323f9865a4 Mon Sep 17 00:00:00 2001 From: Stefan Zager Date: Wed, 23 Nov 2011 06:34:02 +0000 Subject: [PATCH 087/147] Bug 3440044 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12842 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Lib/python/pyrun.swg | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index d0c9deb63..38edca8a5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-22: szager + [python] Bug 3440044: #ifdef out SWIG_Python_NonDynamicSetAttr if -builtin + isn't being used, to avoid unnecessary binary incompatibilities between + python installations. + 2011-11-17: wsfulton Bug fix: Remove root directory from directory search list in Windows. diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index d730a2dbe..0ea009d2e 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1721,6 +1721,7 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(arg return result; } +#ifdef SWIGPYTHON_BUILTIN SWIGRUNTIME int SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { PyTypeObject *tp = obj->ob_type; @@ -1729,15 +1730,15 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { descrsetfunc f; int res; -#ifdef Py_USING_UNICODE +# ifdef Py_USING_UNICODE if (PyString_Check(name)) { name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); if (!name) return -1; } else if (!PyUnicode_Check(name)) -#else +# else if (!PyString_Check(name)) -#endif +# endif { PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); return -1; @@ -1772,6 +1773,7 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { Py_DECREF(name); return res; } +#endif #ifdef __cplusplus From 6a74028e65821de5cf1650bb906d8deaf177a4a5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 Nov 2011 20:56:56 +0000 Subject: [PATCH 088/147] Fix inconsistencies in Java and C# getCPtr() and pointer constructor visibility - change to protected/internal from public. Add SWIG_JAVABODY_PROXY, SWIG_JAVABODY_TYPEWRAPPER and SWIG_CSBODY_PROXY, SWIG_CSBODY_TYPEWRAPPER for users to easily change when using multiple modules. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12843 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 24 ++++++++++++++++++ Doc/Manual/CSharp.html | 8 ++++++ Doc/Manual/Java.html | 42 ++++++++++++++++++++++---------- Lib/csharp/boost_intrusive_ptr.i | 33 ++++++++++++++----------- Lib/csharp/boost_shared_ptr.i | 16 ++++++++---- Lib/csharp/csharp.swg | 40 +++++++++++++++++++----------- Lib/java/boost_intrusive_ptr.i | 30 +++++++++++++++-------- Lib/java/boost_shared_ptr.i | 16 ++++++++---- Lib/java/java.swg | 36 +++++++++++++++------------ 9 files changed, 168 insertions(+), 77 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 38edca8a5..660fefad7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,30 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-25: wsfulton + [C#] Provide an easy way to override the default visibility for the proxy class pointer + constructors and getCPtr() method. The visibility is 'internal' by default and if multiple + SWIG modules are being used and compiled into different assemblies, then they need to be + 'public' in order to use the constructor or getCPtr() method from a different assembly. + Use the following macros to change the visibilities in the proxy and type wrapper class: + + SWIG_CSBODY_PROXY(public, public, SWIGTYPE) + SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE) + + [Java] Provide an easy way to override the default visibility for the proxy class pointer + constructors and getCPtr() method. The visibility is 'protected' by default and if multiple + SWIG modules are being used and compiled into different packages, then they need to be + 'public' in order to use the constructor or getCPtr() method from a different package. + Use the following macros to change the visibilities in the proxy and type wrapper class: + + SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) + SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE) + + The default for Java has changed from public to protected for the proxy classes. Use the + SWIG_JAVABODY_PROXY macro above to restore to the previous visibilities. + + *** POTENTIAL INCOMPATIBILITY *** + 2011-11-22: szager [python] Bug 3440044: #ifdef out SWIG_Python_NonDynamicSetAttr if -builtin isn't being used, to avoid unnecessary binary incompatibilities between diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index d3d68bd53..eacd29853 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -170,6 +170,14 @@ javadestruct_derived -> csdestruct_derived
            • +
            • +

              Typemap macros:

              +
              +SWIG_JAVABODY_PROXY         -> SWIG_CSBODY_PROXY
              +SWIG_JAVABODY_TYPEWRAPPER   -> SWIG_CSBODY_TYPEWRAPPER
              +
              +
            • +
            • Additional typemaps:

              diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 8f0790164..ca33b2f60 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -2379,7 +2379,7 @@ public class Foo { swigCPtr = cPtr; } - public static long getCPtr(Foo obj) { + protected static long getCPtr(Foo obj) { return (obj == null) ? 0 : obj.swigCPtr; } @@ -2630,7 +2630,7 @@ public class Base { swigCPtr = cPtr; } - public static long getCPtr(Base obj) { + protected static long getCPtr(Base obj) { return (obj == null) ? 0 : obj.swigCPtr; } @@ -2670,7 +2670,7 @@ public class Derived extends Base { swigCPtr = cPtr; } - public static long getCPtr(Derived obj) { + protected static long getCPtr(Derived obj) { return (obj == null) ? 0 : obj.swigCPtr; } @@ -2949,7 +2949,7 @@ public class Test { swigCPtr = cPtr; } - public static long getCPtr(Test obj) { + protected static long getCPtr(Test obj) { return (obj == null) ? 0 : obj.swigCPtr; } @@ -5550,15 +5550,8 @@ The typemap code is the same that is in "java.swg", barring the last tw Note that SWIGTYPE will target all proxy classes, but not the type wrapper classes. Also the above typemap is only used for proxy classes that are potential base classes. To target proxy classes that are derived from a wrapped class as well, the "javabody_derived" typemap should also be overridden. -There is a macro in java.swg that implements this and the above can instead be implemented using:

              -
              -
              -SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE)
              -
              -
              -

              For the typemap to be used in all type wrapper classes, all the different types that type wrapper classes could be used for should be targeted:

              @@ -5568,7 +5561,7 @@ For the typemap to be used in all type wrapper classes, all the different types %typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ private long swigCPtr; - public $javaclassname(long cPtr, boolean bFutureUse) { + protected $javaclassname(long cPtr, boolean bFutureUse) { swigCPtr = cPtr; } @@ -5576,7 +5569,7 @@ For the typemap to be used in all type wrapper classes, all the different types swigCPtr = 0; } - public static long getCPtr($javaclassname obj) { + protected static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} @@ -5587,6 +5580,29 @@ 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.

              +

              +When using multiple modules it is common to invoke SWIG with a different -package +command line option for each module. +However, by default the generated code may not compile if +generated classes in one package use generated classes in another package. +The visibility of the +getCPtr() and pointer constructor generated from the javabody typemaps needs changing. +The default visibility is protected but it needs to be public for access from a different package. +Just changing 'protected' to 'public' in the typemap achieves this. +Two macros are available in java.swg to make this easier and using them is the preferred approach +over simply copying the typemaps and modifying as this is forward compatible with any changes in +the javabody typemap in future versions of SWIG. +The macros are for the proxy and typewrapper classes and can respectively be used to +to make the method and constructor public: +

              + +
              +
              +  SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
              +  SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
              +
              +
              +

              23.9.10 Director specific typemaps

              diff --git a/Lib/csharp/boost_intrusive_ptr.i b/Lib/csharp/boost_intrusive_ptr.i index fc0422dd7..9884ccc44 100644 --- a/Lib/csharp/boost_intrusive_ptr.i +++ b/Lib/csharp/boost_intrusive_ptr.i @@ -1,7 +1,16 @@ +// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the +// visibility of the constructor and getCPtr method if desired to public if using multiple modules. +#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS +#define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE) +#endif +#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP +#define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(internal, internal, CONST, TYPE) +#endif + %include // Language specific macro implementing all the customisations for handling the smart pointer -%define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) +%define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; @@ -280,12 +289,12 @@ private HandleRef swigCPtr; private bool swigCMemOwnBase; - public $csclassname(IntPtr cPtr, bool cMemoryOwn) { + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } - internal static HandleRef getCPtr($csclassname obj) { + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} @@ -295,14 +304,12 @@ private HandleRef swigCPtr; private bool swigCMemOwnDerived; - public $csclassname(IntPtr cPtr, bool cMemoryOwn) - : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { - + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { swigCMemOwnDerived = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } - internal static HandleRef getCPtr($csclassname obj) { + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} @@ -349,7 +356,7 @@ %include -%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) +%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; @@ -441,12 +448,12 @@ private HandleRef swigCPtr; private bool swigCMemOwnBase; - public $csclassname(IntPtr cPtr, bool cMemoryOwn) { + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } - internal static HandleRef getCPtr($csclassname obj) { + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} @@ -456,14 +463,12 @@ private HandleRef swigCPtr; private bool swigCMemOwnDerived; - public $csclassname(IntPtr cPtr, bool cMemoryOwn) - : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { - + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { swigCMemOwnDerived = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } - internal static HandleRef getCPtr($csclassname obj) { + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} diff --git a/Lib/csharp/boost_shared_ptr.i b/Lib/csharp/boost_shared_ptr.i index 54c2a6e87..5e6f66469 100644 --- a/Lib/csharp/boost_shared_ptr.i +++ b/Lib/csharp/boost_shared_ptr.i @@ -1,7 +1,13 @@ +// Users can provide their own SWIG_SHARED_PTR_TYPEMAPS macro before including this file to change the +// visibility of the constructor and getCPtr method if desired to public if using multiple modules. +#ifndef SWIG_SHARED_PTR_TYPEMAPS +#define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE) +#endif + %include // Language specific macro implementing all the customisations for handling the smart pointer -%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) +%define SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; @@ -175,12 +181,12 @@ private HandleRef swigCPtr; private bool swigCMemOwnBase; - internal $csclassname(IntPtr cPtr, bool cMemoryOwn) { + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } - internal static HandleRef getCPtr($csclassname obj) { + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} @@ -190,12 +196,12 @@ private HandleRef swigCPtr; private bool swigCMemOwnDerived; - internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) { swigCMemOwnDerived = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } - internal static HandleRef getCPtr($csclassname obj) { + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index d16584565..82452c4be 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -820,66 +820,78 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { %typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" %typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" + +// csbody typemaps... these are in macros so that the visibility of the methods can be easily changed by users. + +%define SWIG_CSBODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Proxy classes (base classes, ie, not derived classes) -%typemap(csbody) SWIGTYPE %{ +%typemap(csbody) TYPE %{ private HandleRef swigCPtr; protected bool swigCMemOwn; - internal $csclassname(IntPtr cPtr, bool cMemoryOwn) { + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = new HandleRef(this, cPtr); } - internal static HandleRef getCPtr($csclassname obj) { + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} // Derived proxy classes -%typemap(csbody_derived) SWIGTYPE %{ +%typemap(csbody_derived) TYPE %{ private HandleRef swigCPtr; - internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGUpcast(cPtr), cMemoryOwn) { + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGUpcast(cPtr), cMemoryOwn) { swigCPtr = new HandleRef(this, cPtr); } - internal static HandleRef getCPtr($csclassname obj) { + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} +%enddef +%define SWIG_CSBODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Typewrapper classes -%typemap(csbody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{ +%typemap(csbody) TYPE *, TYPE &, TYPE [] %{ private HandleRef swigCPtr; - internal $csclassname(IntPtr cPtr, bool futureUse) { + PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool futureUse) { swigCPtr = new HandleRef(this, cPtr); } - protected $csclassname() { + DEFAULTCTOR_VISIBILITY $csclassname() { swigCPtr = new HandleRef(null, IntPtr.Zero); } - internal static HandleRef getCPtr($csclassname obj) { + CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } %} -%typemap(csbody) SWIGTYPE (CLASS::*) %{ +%typemap(csbody) TYPE (CLASS::*) %{ private string swigCMemberPtr; - internal $csclassname(string cMemberPtr, bool futureUse) { + PTRCTOR_VISIBILITY $csclassname(string cMemberPtr, bool futureUse) { swigCMemberPtr = cMemberPtr; } - protected $csclassname() { + DEFAULTCTOR_VISIBILITY $csclassname() { swigCMemberPtr = null; } - internal static string getCMemberPtr($csclassname obj) { + CPTR_VISIBILITY static string getCMemberPtr($csclassname obj) { return obj.swigCMemberPtr; } %} +%enddef + +/* Set the default csbody typemaps to use internal visibility. + Use the macros to change to public if using multiple modules. */ +SWIG_CSBODY_PROXY(internal, internal, SWIGTYPE) +SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE) %typemap(csfinalize) SWIGTYPE %{ ~$csclassname() { diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i index 8e7a57426..3ae3ed886 100644 --- a/Lib/java/boost_intrusive_ptr.i +++ b/Lib/java/boost_intrusive_ptr.i @@ -1,7 +1,17 @@ +// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the +// visibility of the constructor and getCPtr method if desired to public if using multiple modules. +#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP +#define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(protected, protected, CONST, TYPE) +#endif +#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS +#define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(protected, protected, CONST, TYPE) +#endif + + %include // Language specific macro implementing all the customisations for handling the smart pointer -%define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) +%define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; @@ -256,12 +266,12 @@ private long swigCPtr; private boolean swigCMemOwnBase; - public $javaclassname(long cPtr, boolean cMemoryOwn) { + PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = cPtr; } - protected static long getCPtr($javaclassname obj) { + CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} @@ -271,13 +281,13 @@ private long swigCPtr; private boolean swigCMemOwnDerived; - public $javaclassname(long cPtr, boolean cMemoryOwn) { + PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true); swigCMemOwnDerived = cMemoryOwn; swigCPtr = cPtr; } - protected static long getCPtr($javaclassname obj) { + CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} @@ -314,7 +324,7 @@ %include -%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) +%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; @@ -406,12 +416,12 @@ private long swigCPtr; private boolean swigCMemOwnBase; - public $javaclassname(long cPtr, boolean cMemoryOwn) { + PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = cPtr; } - protected static long getCPtr($javaclassname obj) { + CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} @@ -421,13 +431,13 @@ private long swigCPtr; private boolean swigCMemOwnDerived; - public $javaclassname(long cPtr, boolean cMemoryOwn) { + PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true); swigCMemOwnDerived = cMemoryOwn; swigCPtr = cPtr; } - protected static long getCPtr($javaclassname obj) { + CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i index dd7344ea6..31d7efdf9 100644 --- a/Lib/java/boost_shared_ptr.i +++ b/Lib/java/boost_shared_ptr.i @@ -1,7 +1,13 @@ +// Users can provide their own SWIG_SHARED_PTR_TYPEMAPS macro before including this file to change the +// visibility of the constructor and getCPtr method if desired to public if using multiple modules. +#ifndef SWIG_SHARED_PTR_TYPEMAPS +#define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(protected, protected, CONST, TYPE) +#endif + %include // Language specific macro implementing all the customisations for handling the smart pointer -%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) +%define SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...) // %naturalvar is as documented for member variables %naturalvar TYPE; @@ -142,12 +148,12 @@ private long swigCPtr; private boolean swigCMemOwnBase; - public $javaclassname(long cPtr, boolean cMemoryOwn) { + PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { swigCMemOwnBase = cMemoryOwn; swigCPtr = cPtr; } - protected static long getCPtr($javaclassname obj) { + CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} @@ -157,13 +163,13 @@ private long swigCPtr; private boolean swigCMemOwnDerived; - public $javaclassname(long cPtr, boolean cMemoryOwn) { + PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true); swigCMemOwnDerived = cMemoryOwn; swigCPtr = cPtr; } - protected static long getCPtr($javaclassname obj) { + CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 159aafb17..fbea6a07c 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1116,9 +1116,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { /* javabody typemaps */ -%define SWIG_JAVABODY_METHODS(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPENAME...) +%define SWIG_JAVABODY_METHODS(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE) %enddef // legacy name + +%define SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Base proxy classes -%typemap(javabody) TYPENAME %{ +%typemap(javabody) TYPE %{ private long swigCPtr; protected boolean swigCMemOwn; @@ -1133,7 +1135,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { %} // Derived proxy classes -%typemap(javabody_derived) TYPENAME %{ +%typemap(javabody_derived) TYPE %{ private long swigCPtr; PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { @@ -1147,43 +1149,45 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { %} %enddef -/* Set the default for SWIGTYPE: pointer constructor is protected, - getCPtr is protected. Season to your own taste! */ - -SWIG_JAVABODY_METHODS(public, public, SWIGTYPE) - +%define SWIG_JAVABODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) // Typewrapper classes -%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{ +%typemap(javabody) TYPE *, TYPE &, TYPE [] %{ private long swigCPtr; - protected $javaclassname(long cPtr, boolean futureUse) { + PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean futureUse) { swigCPtr = cPtr; } - protected $javaclassname() { + DEFAULTCTOR_VISIBILITY $javaclassname() { swigCPtr = 0; } - protected static long getCPtr($javaclassname obj) { + CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } %} -%typemap(javabody) SWIGTYPE (CLASS::*) %{ +%typemap(javabody) TYPE (CLASS::*) %{ private String swigCMemberPtr; - protected $javaclassname(String cMemberPtr, boolean futureUse) { + PTRCTOR_VISIBILITY $javaclassname(String cMemberPtr, boolean futureUse) { swigCMemberPtr = cMemberPtr; } - protected $javaclassname() { + DEFAULTCTOR_VISIBILITY $javaclassname() { swigCMemberPtr = null; } - protected static String getCMemberPtr($javaclassname obj) { + CPTR_VISIBILITY static String getCMemberPtr($javaclassname obj) { return obj.swigCMemberPtr; } %} +%enddef + +/* Set the default javabody typemaps to use protected visibility. + Use the macros to change to public if using multiple modules. */ +SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) +SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE) %typemap(javafinalize) SWIGTYPE %{ protected void finalize() { From 6e56d874712a3f665534fd7607e7bde51f13fc83 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 Nov 2011 21:20:47 +0000 Subject: [PATCH 089/147] Fix inconsistencies in Java and C# getCPtr() and pointer constructor visibility - change to protected/internal from public. Add SWIG_JAVABODY_PROXY, SWIG_JAVABODY_TYPEWRAPPER and SWIG_CSBODY_PROXY, SWIG_CSBODY_TYPEWRAPPER for users to easily change when using multiple modules. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12844 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 34 ++++++++++++++++++++++++++++++++++ Lib/java/java.swg | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index eacd29853..521114cdf 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -1656,6 +1656,40 @@ 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 Multiples modules

              + +

              +When using multiple modules it is is possible to compile each SWIG generated wrapper +into a different assembly. +However, by default the generated code may not compile if +generated classes in one assembly use generated classes in another assembly. +The visibility of the +getCPtr() and pointer constructor generated from the csbody typemaps needs changing. +The default visibility is internal but it needs to be public for access from a different assembly. +Just changing 'internal' to 'public' in the typemap achieves this. +Two macros are available in csharp.swg to make this easier and using them is the preferred approach +over simply copying the typemaps and modifying as this is forward compatible with any changes in +the csbody typemap in future versions of SWIG. +The macros are for the proxy and typewrapper classes and can respectively be used to +to make the method and constructor public: +

              + +
              +
              +  SWIG_CSBODY_PROXY(public, public, SWIGTYPE)
              +  SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
              +
              +
              + +

              +Alternatively, instead of exposing these as public, consider +using the [assembly:InternalsVisibleTo("Name")] attribute available in the .NET framework when you +know which assemblies these can be exposed to. +Another approach would be to make these public, but also to hide them from intellisense by using +the [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] attribute +if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers. +

              +

              18.7 C# Typemap examples

              diff --git a/Lib/java/java.swg b/Lib/java/java.swg index fbea6a07c..c727d9611 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1186,7 +1186,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { /* Set the default javabody typemaps to use protected visibility. Use the macros to change to public if using multiple modules. */ -SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) +SWIG_JAVABODY_PROXY(protected, protected, SWIGTYPE) SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE) %typemap(javafinalize) SWIGTYPE %{ From ee474ece0ee00c75b1fc081ea579c92bd2e4a5a8 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 28 Nov 2011 04:07:44 +0000 Subject: [PATCH 090/147] Update keyword list to include keywords add in PHP releases up to 5.3. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12845 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 ++ Lib/php/phpkw.swg | 134 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 660fefad7..cf55cb8d6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-28: olly + [PHP] Update keyword list to include keywords added in PHP releases up to 5.3. + 2011-11-25: wsfulton [C#] Provide an easy way to override the default visibility for the proxy class pointer constructors and getCPtr() method. The visibility is 'internal' by default and if multiple diff --git a/Lib/php/phpkw.swg b/Lib/php/phpkw.swg index c40421062..c55766928 100644 --- a/Lib/php/phpkw.swg +++ b/Lib/php/phpkw.swg @@ -124,6 +124,8 @@ PHPBN2(E_COMPILE_WARNING); PHPBN2(E_USER_ERROR); PHPBN2(E_USER_WARNING); PHPBN2(E_USER_NOTICE); +PHPBN2(E_DEPRECATED); // As of PHP 5.3 +PHPBN2(E_USER_DEPRECATED); // As of PHP 5.3 PHPBN2(PHP_OS); PHPBN2(PHP_VERSION); PHPBN2(PHP_SAPI); @@ -146,6 +148,20 @@ PHPBN2(PHP_SHLIB_SUFFIX); PHPBN2(PHP_OUTPUT_HANDLER_START); PHPBN2(PHP_OUTPUT_HANDLER_CONT); PHPBN2(PHP_OUTPUT_HANDLER_END); +PHPBN2(PHP_MAXPATHLEN); // As of PHP 5.3 +/* These don't actually seem to be set (tested on Linux, I guess they're + * Windows only?) */ +PHPBN2(PHP_WINDOWS_NT_DOMAIN_CONTROLLER); // As of PHP 5.3 +PHPBN2(PHP_WINDOWS_NT_SERVER); // As of PHP 5.3 +PHPBN2(PHP_WINDOWS_NT_WORKSTATION); // As of PHP 5.3 +PHPBN2(PHP_WINDOWS_VERSION_BUILD); // As of PHP 5.3 +PHPBN2(PHP_WINDOWS_VERSION_MAJOR); // As of PHP 5.3 +PHPBN2(PHP_WINDOWS_VERSION_MINOR); // As of PHP 5.3 +PHPBN2(PHP_WINDOWS_VERSION_PLATFORM); // As of PHP 5.3 +PHPBN2(PHP_WINDOWS_VERSION_PRODUCTTYPE); // As of PHP 5.3 +PHPBN2(PHP_WINDOWS_VERSION_SP_MAJOR); // As of PHP 5.3 +PHPBN2(PHP_WINDOWS_VERSION_SP_MINOR); // As of PHP 5.3 +PHPBN2(PHP_WINDOWS_VERSION_SUITEMASK); // As of PHP 5.3 /* "Standard Predefined Constants" from http://uk2.php.net/manual/en/reserved.constants.php */ PHPBN2(EXTR_OVERWRITE); PHPBN2(EXTR_SKIP); @@ -175,6 +191,8 @@ PHPBN2(INI_USER); PHPBN2(INI_PERDIR); PHPBN2(INI_SYSTEM); PHPBN2(INI_ALL); +PHPBN2(INI_SCANNER_NORMAL); // As of PHP 5.3 +PHPBN2(INI_SCANNER_RAW); // As of PHP 5.3 PHPBN2(M_E); PHPBN2(M_LOG2E); PHPBN2(M_LOG10E); @@ -188,6 +206,10 @@ PHPBN2(M_2_PI); PHPBN2(M_2_SQRTPI); PHPBN2(M_SQRT2); PHPBN2(M_SQRT1_2); +PHPBN2(M_EULER); // As of PHP 5.2 +PHPBN2(M_LNPI); // As of PHP 5.2 +PHPBN2(M_SQRT3); // As of PHP 5.2 +PHPBN2(M_SQRTPI); // As of PHP 5.2 PHPBN2(CRYPT_SALT_LENGTH); PHPBN2(CRYPT_STD_DES); PHPBN2(CRYPT_EXT_DES); @@ -228,6 +250,7 @@ PHPBN2(STR_PAD_BOTH); PHPBN2(PATHINFO_DIRNAME); PHPBN2(PATHINFO_BASENAME); PHPBN2(PATHINFO_EXTENSION); +PHPBN2(PATHINFO_FILENAME); // As of PHP 5.2 PHPBN2(PATH_SEPARATOR); PHPBN2(CHAR_MAX); PHPBN2(LC_CTYPE); @@ -351,6 +374,117 @@ PHPBN2(LOG_PERROR); PHPBN2(E_STRICT); PHPBN2(__COMPILER_HALT_OFFSET__); +/* Added in PHP 5.2 */ +PHPBN2(PREG_BACKTRACK_LIMIT_ERROR); +PHPBN2(PREG_BAD_UTF8_ERROR); +PHPBN2(PREG_INTERNAL_ERROR); +PHPBN2(PREG_NO_ERROR); +PHPBN2(PREG_RECURSION_LIMIT_ERROR); +PHPBN2(UPLOAD_ERR_EXTENSION); +PHPBN2(STREAM_SHUT_RD); +PHPBN2(STREAM_SHUT_WR); +PHPBN2(STREAM_SHUT_RDWR); +PHPBN2(CURLE_FILESIZE_EXCEEDED); +PHPBN2(CURLE_FTP_SSL_FAILED); +PHPBN2(CURLE_LDAP_INVALID_URL); +PHPBN2(CURLFTPAUTH_DEFAULT); +PHPBN2(CURLFTPAUTH_SSL); +PHPBN2(CURLFTPAUTH_TLS); +PHPBN2(CURLFTPSSL_ALL); +PHPBN2(CURLFTPSSL_CONTROL); +PHPBN2(CURLFTPSSL_NONE); +PHPBN2(CURLFTPSSL_TRY); +PHPBN2(CURLOPT_FTP_SSL); +PHPBN2(CURLOPT_FTPSSLAUTH); +PHPBN2(CURLOPT_TCP_NODELAY); // Added in PHP 5.2.1 +PHPBN2(CURLOPT_TIMEOUT_MS); // Added in PHP 5.2.3 +PHPBN2(CURLOPT_CONNECTTIMEOUT_MS); // Added in PHP 5.2.3 +PHPBN2(GMP_VERSION); // Added in PHP 5.2.2 +PHPBN2(SWFTEXTFIELD_USEFONT); +PHPBN2(SWFTEXTFIELD_AUTOSIZE); +PHPBN2(SWF_SOUND_NOT_COMPRESSED); +PHPBN2(SWF_SOUND_ADPCM_COMPRESSED); +PHPBN2(SWF_SOUND_MP3_COMPRESSED); +PHPBN2(SWF_SOUND_NOT_COMPRESSED_LE); +PHPBN2(SWF_SOUND_NELLY_COMPRESSED); +PHPBN2(SWF_SOUND_5KHZ); +PHPBN2(SWF_SOUND_11KHZ); +PHPBN2(SWF_SOUND_22KHZ); +PHPBN2(SWF_SOUND_44KHZ); +PHPBN2(SWF_SOUND_8BITS); +PHPBN2(SWF_SOUND_16BITS); +PHPBN2(SWF_SOUND_MONO); +PHPBN2(SWF_SOUND_STEREO); +PHPBN2(OPENSSL_VERSION_NUMBER); +PHPBN2(SNMP_OID_OUTPUT_FULL); +PHPBN2(SNMP_OID_OUTPUT_NUMERIC); +PHPBN2(MSG_EAGAIN); +PHPBN2(MSG_ENOMSG); + +/* Added in PHP 5.3 */ +PHPBN2(CURLOPT_PROGRESSFUNCTION); +PHPBN2(IMG_FILTER_PIXELATE); +PHPBN2(JSON_ERROR_CTRL_CHAR); +PHPBN2(JSON_ERROR_DEPTH); +PHPBN2(JSON_ERROR_NONE); +PHPBN2(JSON_ERROR_STATE_MISMATCH); +PHPBN2(JSON_ERROR_SYNTAX); +PHPBN2(JSON_FORCE_OBJECT); +PHPBN2(JSON_HEX_TAG); +PHPBN2(JSON_HEX_AMP); +PHPBN2(JSON_HEX_APOS); +PHPBN2(JSON_HEX_QUOT); +PHPBN2(LDAP_OPT_NETWORK_TIMEOUT); +PHPBN2(LIBXML_LOADED_VERSION); +PHPBN2(PREG_BAD_UTF8_OFFSET_ERROR); +PHPBN2(BUS_ADRALN); +PHPBN2(BUS_ADRERR); +PHPBN2(BUS_OBJERR); +PHPBN2(CLD_CONTIUNED); +PHPBN2(CLD_DUMPED); +PHPBN2(CLD_EXITED); +PHPBN2(CLD_KILLED); +PHPBN2(CLD_STOPPED); +PHPBN2(CLD_TRAPPED); +PHPBN2(FPE_FLTDIV); +PHPBN2(FPE_FLTINV); +PHPBN2(FPE_FLTOVF); +PHPBN2(FPE_FLTRES); +PHPBN2(FPE_FLTSUB); +PHPBN2(FPE_FLTUND); +PHPBN2(FPE_INTDIV); +PHPBN2(FPE_INTOVF); +PHPBN2(ILL_BADSTK); +PHPBN2(ILL_COPROC); +PHPBN2(ILL_ILLADR); +PHPBN2(ILL_ILLOPC); +PHPBN2(ILL_ILLOPN); +PHPBN2(ILL_ILLTRP); +PHPBN2(ILL_PRVOPC); +PHPBN2(ILL_PRVREG); +PHPBN2(POLL_ERR); +PHPBN2(POLL_HUP); +PHPBN2(POLL_IN); +PHPBN2(POLL_MSG); +PHPBN2(POLL_OUT); +PHPBN2(POLL_PRI); +PHPBN2(SEGV_ACCERR); +PHPBN2(SEGV_MAPERR); +PHPBN2(SI_ASYNCIO); +PHPBN2(SI_KERNEL); +PHPBN2(SI_MESGQ); +PHPBN2(SI_NOINFO); +PHPBN2(SI_QUEUE); +PHPBN2(SI_SIGIO); +PHPBN2(SI_TIMER); +PHPBN2(SI_TKILL); +PHPBN2(SI_USER); +PHPBN2(SIG_BLOCK); +PHPBN2(SIG_SETMASK); +PHPBN2(SIG_UNBLOCK); +PHPBN2(TRAP_BRKPT); +PHPBN2(TRAP_TRACE); + /* Class names reserved by PHP */ /* case insensitive */ PHPCN(stdclass); From 5b8ca942ada9adf592253b8074945aab13304151 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 28 Nov 2011 04:08:25 +0000 Subject: [PATCH 091/147] This is a minor portability fix - isdigit() (and friends) are only portably defined for unsigned char values (though glibc extends them to work for signed char too) so this fixes this code to handle top bit set characters on non-glibc platforms where char is signed by default. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12846 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 3e1e96f66..77679ca63 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1165,7 +1165,7 @@ String *replace_captures(const char *input, String *subst, int captures[]) /* Handle substitution */ if (*p == '\0') { Putc('\\', result); - } else if (isdigit((int)*p)) { + } else if (isdigit((unsigned char)*p)) { int group = *p++ - '0'; int l = captures[group*2], r = captures[group*2 + 1]; if (l != -1) { From cc85a98f73f5ad9d3800bc9b6589eb2eda5fad38 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 28 Nov 2011 06:38:46 +0000 Subject: [PATCH 092/147] Remove duplicate macros when using -external-runtime git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12847 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/main.cxx | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 4fe5a3f11..d2f5d3bc0 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -418,13 +418,6 @@ static void SWIG_dump_runtime() { Printf(runtime, "%s", s); Delete(s); - s = Swig_include_sys("swigerrors.swg"); - if (!s) { - Printf(stderr, "*** Unable to open 'swigerrors.swg'\n"); - Close(runtime); - SWIG_exit(EXIT_FAILURE); - } - Printf(runtime, "%s", s); s = Swig_include_sys("swigrun.swg"); if (!s) { Printf(stderr, "*** Unable to open 'swigrun.swg'\n"); From 5e4c27cdfdee8e702806521767b5e366c774cf5d Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 28 Nov 2011 06:56:16 +0000 Subject: [PATCH 093/147] [Perl] Fix warnings when compiling generated wrappers with certain GCC warning options (Debian bug #436711). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12848 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/perl5/perlinit.swg | 15 ++++++++++----- Lib/perl5/perlrun.swg | 25 ++++++++++++++----------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index cf55cb8d6..bbc131133 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-28: olly + [Perl] Fix warnings when compiling generated wrappers with certain + GCC warning options (Debian bug #436711). + 2011-11-28: olly [PHP] Update keyword list to include keywords added in PHP releases up to 5.3. diff --git a/Lib/perl5/perlinit.swg b/Lib/perl5/perlinit.swg index 550921554..af9a35a98 100644 --- a/Lib/perl5/perlinit.swg +++ b/Lib/perl5/perlinit.swg @@ -33,25 +33,30 @@ XS(SWIG_init) { /* Install commands */ for (i = 0; swig_commands[i].name; i++) { - newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); + // Casts only needed for Perl < 5.10. +#ifdef __cplusplus + newXS(const_cast(swig_commands[i].name), swig_commands[i].wrapper, const_cast(__FILE__)); +#else + newXS((char*)swig_commands[i].name, swig_commands[i].wrapper, (char*)__FILE__); +#endif } /* Install variables */ for (i = 0; swig_variables[i].name; i++) { SV *sv; - sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI); + sv = get_sv(swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI); if (swig_variables[i].type) { SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); } else { sv_setiv(sv,(IV) 0); } - swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); + swig_create_magic(sv, swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); } /* Install constant */ for (i = 0; swig_constants[i].type; i++) { SV *sv; - sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI); + sv = get_sv(swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI); switch(swig_constants[i].type) { case SWIG_INT: sv_setiv(sv, (IV) swig_constants[i].lvalue); @@ -60,7 +65,7 @@ XS(SWIG_init) { sv_setnv(sv, (double) swig_constants[i].dvalue); break; case SWIG_STRING: - sv_setpv(sv, (char *) swig_constants[i].pvalue); + sv_setpv(sv, (const char *) swig_constants[i].pvalue); break; case SWIG_POINTER: SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index d89865665..4130a065e 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -212,8 +212,7 @@ SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { - if ( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) || - (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0)) ) { + if (strcmp(SWIG_Perl_TypeProxyName(iter->type), c) == 0) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ @@ -344,7 +343,7 @@ SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, i SV *obj=newSV(0); HV *hash=newHV(); HV *stash; - sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr); + sv_setref_pv(obj, SWIG_Perl_TypeProxyName(t), ptr); stash=SvSTASH(SvRV(obj)); if (flags & SWIG_POINTER_OWN) { HV *hv; @@ -362,7 +361,7 @@ SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, i sv_bless(sv, stash); } else { - sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr); + sv_setref_pv(sv, SWIG_Perl_TypeProxyName(t), ptr); } } @@ -453,19 +452,23 @@ typedef struct { /* Magic variable code */ #ifndef PERL_OBJECT -#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c) - #ifndef MULTIPLICITY - SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) - #else - SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) - #endif +# ifdef __cplusplus +# define swig_create_magic(s,a,b,c) _swig_create_magic(s,const_cast(a),b,c) +# else +# define swig_create_magic(s,a,b,c) _swig_create_magic(s,(char*)(a),b,c) +# endif +# ifndef MULTIPLICITY +SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) +# else +SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) +# endif #else # define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) #endif { MAGIC *mg; - sv_magic(sv,sv,'U',(char *) name,strlen(name)); + sv_magic(sv,sv,'U',name,strlen(name)); mg = mg_find(sv,'U'); mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); mg->mg_virtual->svt_get = (SwigMagicFunc) get; From 6d922f2ddd752c8e4dd0133df3af854d78de92af Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 28 Nov 2011 19:35:44 +0000 Subject: [PATCH 094/147] Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12849 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + Examples/test-suite/typemap_manyargs.i | 20 ++++++++++++++++++++ Source/DOH/doh.h | 1 + Source/DOH/string.c | 17 +++++++++++++++++ Source/Swig/typemap.c | 2 +- 5 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/typemap_manyargs.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 4f64ca0b3..b02afb463 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -420,6 +420,7 @@ CPP_TEST_CASES += \ typemap_arrays \ typemap_delete \ typemap_global_scope \ + typemap_manyargs \ typemap_namespace \ typemap_ns_using \ typemap_numinputs \ diff --git a/Examples/test-suite/typemap_manyargs.i b/Examples/test-suite/typemap_manyargs.i new file mode 100644 index 000000000..bde1f8d90 --- /dev/null +++ b/Examples/test-suite/typemap_manyargs.i @@ -0,0 +1,20 @@ +%module typemap_manyargs + +%typemap(in,numinputs=0) (int* a1, int* a2, int* a3, int* a4, int* a5, int* a6, int *a7, int *a8, int *a9, int *a10) (int temp1,int temp2,int temp3,int temp4,int temp5,int temp6,int temp7,int temp8, int temp9, int temp10) +{ + $1 = &temp1; // the code generate for this is arg2 = &temp1; + $2 = &temp2; // the code generate for this is arg3 = &temp2; + $3 = &temp3; // and so on... + $4 = &temp4; + $5 = &temp5; + $6 = &temp6; + $7 = &temp7; + $8 = &temp8; + $9 = &temp9; + $10 = &temp10; // the code generated for this is arg20 = &temp1, and arg20 does not exist. + int $10_ptr = 0; // Was arg20_ptr +} + +%inline %{ +void my_c_function(char * filename,int* a1, int* a2, int* a3, int* a4, int* a5, int* a6, int *a7, int *a8, int *a9, int *a10) {} +%} diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index bca5f0f0f..621d0957c 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -294,6 +294,7 @@ extern char *DohStrchr(const DOHString_or_char *s1, int ch); #define DOH_REPLACE_FIRST 0x08 #define DOH_REPLACE_ID_BEGIN 0x10 #define DOH_REPLACE_ID_END 0x20 +#define DOH_REPLACE_NUMBER_END 0x40 #define Replaceall(s,t,r) DohReplace(s,t,r,DOH_REPLACE_ANY) #define Replaceid(s,t,r) DohReplace(s,t,r,DOH_REPLACE_ID) diff --git a/Source/DOH/string.c b/Source/DOH/string.c index b067d239c..e94a2bdb2 100644 --- a/Source/DOH/string.c +++ b/Source/DOH/string.c @@ -651,6 +651,21 @@ static char *match_identifier_end(char *base, char *s, char *token, int tokenlen return 0; } +static char *match_number_end(char *base, char *s, char *token, int tokenlen) { + (void) base; + while (s) { + s = strstr(s, token); + if (!s) + return 0; + if (isdigit((int) *(s + tokenlen))) { + s += tokenlen; + continue; + } + return s; + } + return 0; +} + /* ----------------------------------------------------------------------------- * replace_simple() * @@ -899,6 +914,8 @@ static int String_replace(DOH *stro, const DOHString_or_char *token, const DOHSt return replace_simple(str, Char(token), Char(rep), flags, count, match_identifier_begin); } else if (flags & DOH_REPLACE_ID) { return replace_simple(str, Char(token), Char(rep), flags, count, match_identifier); + } else if (flags & DOH_REPLACE_NUMBER_END) { + return replace_simple(str, Char(token), Char(rep), flags, count, match_number_end); } else { return replace_simple(str, Char(token), Char(rep), flags, count, match_simple); } diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 60d15ea99..da5e3309c 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1178,7 +1178,7 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi /* Replace the bare $n variable */ sprintf(var, "$%d", index); - bare_substitution_count = Replace(s, var, lname, DOH_REPLACE_ANY); + bare_substitution_count = Replace(s, var, lname, DOH_REPLACE_NUMBER_END); Delete(ftype); return bare_substitution_count; } From de8cd399290da2e850cbf6cf5a1ff082be62b29f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 28 Nov 2011 19:46:37 +0000 Subject: [PATCH 095/147] Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12850 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index bbc131133..cd9e8ec8e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-28: wsfulton + Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments. + 2011-11-28: olly [Perl] Fix warnings when compiling generated wrappers with certain GCC warning options (Debian bug #436711). From 91888c01ecfb375b3990001182b81b604cc0b0dd Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 29 Nov 2011 05:20:45 +0000 Subject: [PATCH 096/147] Fix comment typo in William's recent change git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12851 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/typemap_manyargs.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/typemap_manyargs.i b/Examples/test-suite/typemap_manyargs.i index bde1f8d90..d26e97714 100644 --- a/Examples/test-suite/typemap_manyargs.i +++ b/Examples/test-suite/typemap_manyargs.i @@ -11,7 +11,7 @@ $7 = &temp7; $8 = &temp8; $9 = &temp9; - $10 = &temp10; // the code generated for this is arg20 = &temp1, and arg20 does not exist. + $10 = &temp10; // the code generated for this was arg20 = &temp10; and arg20 does not exist. int $10_ptr = 0; // Was arg20_ptr } From 83cc1f6a3e13ba0b488ae8137cbce858dc3fd615 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 29 Nov 2011 05:31:37 +0000 Subject: [PATCH 097/147] [Python] Fix some warnings when compiling generated wrappers with certain GCC warning options (Debian bug #650246). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12852 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/python/pyrun.swg | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index cd9e8ec8e..46449a187 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-27: olly + [Python] Fix some warnings when compiling generated wrappers with + certain GCC warning options (Debian bug #650246). + 2011-11-28: wsfulton Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments. diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 0ea009d2e..1716aa56a 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -71,7 +71,7 @@ SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { SWIGINTERN void SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, (char *) msg); + PyErr_SetString(errtype, msg); SWIG_PYTHON_THREAD_END_BLOCK; } @@ -90,7 +90,11 @@ SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { +#if PY_VERSION_HEX < 0x02030000 PyDict_SetItemString(d, (char *)name, obj); +#else + PyDict_SetItemString(d, name, obj); +#endif Py_DECREF(obj); if (public_interface) SwigPyBuiltin_AddPublicSymbol(public_interface, name); @@ -100,7 +104,11 @@ SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *nam SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { +#if PY_VERSION_HEX < 0x02030000 PyDict_SetItemString(d, (char *)name, obj); +#else + PyDict_SetItemString(d, name, obj); +#endif Py_DECREF(obj); } @@ -625,8 +633,10 @@ SwigPyObject_own(PyObject *v, PyObject *args) PyObject *val = 0; #if (PY_VERSION_HEX < 0x02020000) if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) -#else +#elif (PY_VERSION_HEX < 0x02050000) if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) +#else + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) #endif { return NULL; @@ -1388,7 +1398,7 @@ SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) SWIGINTERN PyObject * SWIG_Python_InitShadowInstance(PyObject *args) { PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { + if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { return NULL; } else { SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); @@ -1664,7 +1674,7 @@ SwigPyObject_GetDesc(PyObject *self) { SwigPyObject *v = (SwigPyObject *)self; swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : (char*)""; + return ty ? ty->str : ""; } SWIGRUNTIME void From ff8ba43ff61936c27b8d716252c63f8ce69c3d54 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 30 Nov 2011 20:09:46 +0000 Subject: [PATCH 098/147] R tidy up removing C++ comments git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12853 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/r/rrun.swg | 1 - Lib/r/rstdcommon.swg | 18 ++++++------------ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 46449a187..7507e53f4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-11-30: wsfulton + [R] Remove C++ comments from generated C code. + 2011-11-27: olly [Python] Fix some warnings when compiling generated wrappers with certain GCC warning options (Debian bug #650246). diff --git a/Lib/r/rrun.swg b/Lib/r/rrun.swg index 32946c7b5..332cd1d39 100644 --- a/Lib/r/rrun.swg +++ b/Lib/r/rrun.swg @@ -261,7 +261,6 @@ SWIG_R_NewPointerObj(void *ptr, swig_type_info *type, int flags) { SEXP rptr = R_MakeExternalPtr(ptr, R_MakeExternalPtr(type, R_NilValue, R_NilValue), R_NilValue); SET_S4_OBJECT(rptr); -// rptr = Rf_setAttrib(rptr, R_ClassSymbol, mkChar(SWIG_TypeName(type))); return rptr; } diff --git a/Lib/r/rstdcommon.swg b/Lib/r/rstdcommon.swg index 56cbe2cdd..b11cf677b 100644 --- a/Lib/r/rstdcommon.swg +++ b/Lib/r/rstdcommon.swg @@ -104,10 +104,8 @@ namespace swig { Type v; int res = asval(obj, &v); if (!obj || !SWIG_IsOK(res)) { -// if (!PyErr_Occurred()) { -// %type_error(swig::type_name()); -// } - if (throw_error) throw std::invalid_argument("bad type"); + if (throw_error) + throw std::invalid_argument("bad type"); } return v; } @@ -129,10 +127,8 @@ namespace swig { } else { // Uninitialized return value, no Type() constructor required. static Type *v_def = (Type*) malloc(sizeof(Type)); -// if (!PyErr_Occurred()) { -// %type_error(swig::type_name()); -// } - if (throw_error) throw std::invalid_argument("bad type"); + if (throw_error) + throw std::invalid_argument("bad type"); memset(v_def,0,sizeof(Type)); return *v_def; } @@ -147,10 +143,8 @@ namespace swig { if (SWIG_IsOK(res)) { return v; } else { -// if (!PyErr_Occurred()) { -// %type_error(swig::type_name()); -// } - if (throw_error) throw std::invalid_argument("bad type"); + if (throw_error) + throw std::invalid_argument("bad type"); return 0; } } From 9dda4dd3fdcc19c1b69912a87f9af23221ecf888 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 Dec 2011 20:30:21 +0000 Subject: [PATCH 099/147] Lua documentation patch on %newobject from Thomas Pollak git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12854 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Lua.html | 98 ++++++++++++++++++++++++++++----------------- 1 file changed, 62 insertions(+), 36 deletions(-) diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 647030bf1..e73cd0a5c 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -32,32 +32,33 @@
            • C++ overloaded functions
            • C++ operators
            • Class extension with %extend -
            • C++ templates -
            • C++ Smart Pointers -
            • C++ Exceptions +
            • Using %newobject to release memory +
            • C++ templates +
            • C++ Smart Pointers +
            • C++ Exceptions
            -
          • Typemaps +
          • Typemaps -
          • Writing typemaps +
          • Writing typemaps -
          • Customization of your Bindings +
          • Customization of your Bindings -
          • Details on the Lua binding +
          • Details on the Lua binding
          @@ -1001,7 +1002,32 @@ 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).

          -

          25.3.13 C++ templates

          + +

          25.3.13 Using %newobject to release memory

          + + +

          If you have a function that allocates memory like this,

          +
          +
          char *foo() {
          +   char *result = (char *) malloc(...);
          +   ...
          +   return result;
          +}
          +
          +
          +

          then the SWIG generated wrappers will have a memory leak--the + returned data will be copied into a string object and the old contents + ignored.

          +

          To fix the memory leak, use the %newobject directive.

          +
          +
          %newobject foo;
          +...
          +char *foo();
          +
          +
          +

          This will release the allocated memory.

          + +

          25.3.14 C++ templates

          @@ -1036,7 +1062,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.

          -

          25.3.14 C++ Smart Pointers

          +

          25.3.15 C++ Smart Pointers

          @@ -1088,7 +1114,7 @@ If you ever need to access the underlying pointer returned by operator->( > f = p:__deref__() -- Returns underlying Foo * -

          25.3.15 C++ Exceptions

          +

          25.3.16 C++ Exceptions

          @@ -1232,12 +1258,12 @@ add exception specification to functions or globally (respectively).

          -

          25.4 Typemaps

          +

          25.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

          -

          25.4.1 What is a typemap?

          +

          25.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:

          @@ -1265,7 +1291,7 @@ Received an integer : 6 720 -

          25.4.2 Using typemaps

          +

          25.4.2 Using typemaps

          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.

          @@ -1318,7 +1344,7 @@ void swap(int *sx, int *sy);

          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).

          -

          25.4.3 Typemaps and arrays

          +

          25.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 @@ -1382,7 +1408,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In

          Note: SWIG also can support arrays of pointers in a similar manner.

          -

          25.4.4 Typemaps and pointer-pointer functions

          +

          25.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:

          @@ -1416,7 +1442,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs) ptr=nil -- the iMath* will be GC'ed as normal -

          25.5 Writing typemaps

          +

          25.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.

          @@ -1425,7 +1451,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

          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).

          -

          25.5.1 Typemaps you can write

          +

          25.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.

          @@ -1438,7 +1464,7 @@ ptr=nil -- the iMath* will be GC'ed as normal (the syntax for the typecheck is different from the typemap, see typemaps for details).
        -

        25.5.2 SWIG's Lua-C API

        +

        25.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.

        @@ -1487,7 +1513,7 @@ This macro, when called within the context of a SWIG wrappered function, will di
        Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
        -

        25.6 Customization of your Bindings

        +

        25.6 Customization of your Bindings

        @@ -1496,7 +1522,7 @@ This section covers adding of some small extra bits to your module to add the la -

        25.6.1 Writing your own custom wrappers

        +

        25.6.1 Writing your own custom wrappers

        @@ -1515,7 +1541,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.

        -

        25.6.2 Adding additional Lua code

        +

        25.6.2 Adding additional Lua code

        @@ -1553,7 +1579,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.

        -

        25.7 Details on the Lua binding

        +

        25.7 Details on the Lua binding

        @@ -1564,7 +1590,7 @@ See Examples/lua/arrays for an example of this code.

        -

        25.7.1 Binding global data into the module.

        +

        25.7.1 Binding global data into the module.

        @@ -1624,7 +1650,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)'.

        -

        25.7.2 Userdata and Metatables

        +

        25.7.2 Userdata and Metatables

        @@ -1704,7 +1730,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.

        -

        25.7.3 Memory management

        +

        25.7.3 Memory management

        From bdc9b61dc202823ff63181bce1ffb1197e7339c1 Mon Sep 17 00:00:00 2001 From: Stefan Zager Date: Thu, 1 Dec 2011 20:59:19 +0000 Subject: [PATCH 100/147] Fix for bug 3447426: memory leak in vector.__getitem__ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12855 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/python/pycontainer.swg | 1 + 2 files changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 7507e53f4..a70c0c023 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-12-01: szager + [python] Fixed bug 3447426: memory leak in vector.__getitem__. + 2011-11-30: wsfulton [R] Remove C++ comments from generated C code. diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 4e55538d3..24ce8816b 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -608,6 +608,7 @@ namespace swig %define %swig_container_methods(Container...) %newobject __getslice__; + %newobject __getitem__(PySliceObject *slice); #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "nb_nonzero", functype="inquiry") __nonzero__; From 730e14077d5830f9c1ae0f6b33333c56a585dae4 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 3 Dec 2011 19:46:46 +0000 Subject: [PATCH 101/147] [D] Fix exception glue code for newer DMD 2 versions. Thanks to Andrej Mitrovic for reporting. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12856 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/d/dhead.swg | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index a70c0c023..0cc18f7f2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-12-03: klickvebrot + [D] Fix exception glue code for newer DMD 2 versions. + 2011-12-01: szager [python] Fixed bug 3447426: memory leak in vector.__getitem__. diff --git a/Lib/d/dhead.swg b/Lib/d/dhead.swg index 4326b7f8c..170e0243f 100644 --- a/Lib/d/dhead.swg +++ b/Lib/d/dhead.swg @@ -186,7 +186,7 @@ private class SwigExceptionHelper { ); } - static void setException(char* message) { + static void setException(const char* message) { auto exception = new object.Exception(std.conv.to!string(message).idup); exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); From 3da8d17ca8772595022b6aab2cd948b5e4601a25 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 3 Dec 2011 19:46:58 +0000 Subject: [PATCH 102/147] [D] Do not default to 32 bit glue code for DMD anymore. DMD now has x86_64 support on Linux, OS X and BSD. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12857 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 1 + Examples/Makefile.in | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 0cc18f7f2..60858a4ba 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,7 @@ Version 2.0.5 (in progress) 2011-12-03: klickvebrot [D] Fix exception glue code for newer DMD 2 versions. + [D] Do not default to 32 bit glue code for DMD anymore. 2011-12-01: szager [python] Fixed bug 3447426: memory leak in vector.__getitem__. diff --git a/Examples/Makefile.in b/Examples/Makefile.in index ff5686913..da7101255 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -12,7 +12,7 @@ # certain packages have been installed. Set the prefixes # accordingly. # -# 2. To use this makefile, set required varibles, eg SRCS, INTERFACE, +# 2. To use this makefile, set required varibles, eg SRCS, INTERFACE, # INTERFACEDIR, INCLUDES, LIBS, TARGET, and do a # $(MAKE) -f Makefile.template.in SRCS='$(SRCS)' \ # INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \ @@ -1243,11 +1243,6 @@ else DCOMPILER = @D1COMPILER@ endif -ifeq (dmd,$(DCOMPILER)) - # DMD is 32bit only by now - DCFLAGS = -m32 -endif - # ---------------------------------------------------------------- # Build a dynamically loadable D wrapper for a C module # ---------------------------------------------------------------- From 388484bb77bb07249d7340d5f9c549a2c3c2199c Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 3 Dec 2011 19:47:12 +0000 Subject: [PATCH 103/147] [D] Improved allprotected test case error messages. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12858 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/d/allprotected_runme.2.d | 44 ++++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/Examples/test-suite/d/allprotected_runme.2.d b/Examples/test-suite/d/allprotected_runme.2.d index 799230291..f7c396d17 100644 --- a/Examples/test-suite/d/allprotected_runme.2.d +++ b/Examples/test-suite/d/allprotected_runme.2.d @@ -2,6 +2,8 @@ module allprotected_runme; import allprotected.Klass; import allprotected.ProtectedBase; +import std.conv : text; +import std.exception : enforce; void main() { auto mpb = new MyProtectedBase("MyProtectedBase"); @@ -16,50 +18,46 @@ public: void accessProtected() { string s = virtualMethod(); - if (s != "ProtectedBase") - throw new Exception("Failed"); + enforce(s == "ProtectedBase", "Failed, got '" ~ s ~ "'"); - Klass k = instanceMethod(new Klass("xyz")); - if (k.getName() != "xyz") - throw new Exception("Failed"); + Klass k; + void expect(string name) { + auto kName = k.getName(); + enforce(kName == name, "Failed, expected '" ~ name ~ "' instead of '" ~ + kName ~ "'."); + } + + k = instanceMethod(new Klass("xyz")); + expect("xyz"); k = instanceOverloaded(new Klass("xyz")); - if (k.getName() != "xyz") - throw new Exception("Failed"); + expect("xyz"); k = instanceOverloaded(new Klass("xyz"), "abc"); - if (k.getName() != "abc") - throw new Exception("Failed"); + expect("abc"); k = staticMethod(new Klass("abc")); - if (k.getName() != "abc") - throw new Exception("Failed"); + expect("abc"); k = staticOverloaded(new Klass("xyz")); - if (k.getName() != "xyz") - throw new Exception("Failed"); + expect("xyz"); k = staticOverloaded(new Klass("xyz"), "abc"); - if (k.getName() != "abc") - throw new Exception("Failed"); + expect("abc"); instanceMemberVariable = 30; int i = instanceMemberVariable; - if (i != 30) - throw new Exception("Failed"); + enforce(i == 30, text("Failed, expected ", 30, "instead of ", i)); staticMemberVariable = 40; i = staticMemberVariable; - if (i != 40) - throw new Exception("Failed"); + enforce(i == 40, text("Failed, expected ", 40, "instead of ", i)); i = staticConstMemberVariable; - if (i != 20) - throw new Exception("Failed"); + enforce(i == 20, text("Failed, expected ", 20, "instead of ", i)); anEnum = ProtectedBase.AnEnum.EnumVal1; ProtectedBase.AnEnum ae = anEnum; - if (ae != ProtectedBase.AnEnum.EnumVal1) - throw new Exception("Failed"); + enforce(ae == ProtectedBase.AnEnum.EnumVal1); } } From 3d82a7a1856c6eaa632cb258574a7ecd62729042 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 3 Dec 2011 19:47:26 +0000 Subject: [PATCH 104/147] [D] Test case fix: Aliases now required for non-overridden base class overloads. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12859 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/d/director_ignore_runme.2.d | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Examples/test-suite/d/director_ignore_runme.2.d b/Examples/test-suite/d/director_ignore_runme.2.d index b3e29b48d..0d9f7f733 100644 --- a/Examples/test-suite/d/director_ignore_runme.2.d +++ b/Examples/test-suite/d/director_ignore_runme.2.d @@ -19,7 +19,9 @@ public: int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; } int OverloadedMethod(int n, int xoffset) { return 0; } int OverloadedMethod(int n) { return 0; } + alias super.OverloadedMethod OverloadedMethod; +protected: int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; } int OverloadedProtectedMethod(int n, int xoffset) { return 0; } int OverloadedProtectedMethod(int n) { return 0; } @@ -31,7 +33,9 @@ public: int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; } int OverloadedMethod(int n, int xoffset) { return 0; } int OverloadedMethod(int n) { return 0; } + alias super.OverloadedMethod OverloadedMethod; +protected: int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; } int OverloadedProtectedMethod(int n, int xoffset) { return 0; } int OverloadedProtectedMethod(int n) { return 0; } From 5e5d1e2775935648c853388773f42eb26f89fbfd Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 3 Dec 2011 19:47:39 +0000 Subject: [PATCH 105/147] [D] Test case fix: IntVector holds ints, not size_t. Also changed for() to foreach() for better style. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12860 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/d/li_std_vector_runme.2.d | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Examples/test-suite/d/li_std_vector_runme.2.d b/Examples/test-suite/d/li_std_vector_runme.2.d index 195ed8473..f4a666716 100644 --- a/Examples/test-suite/d/li_std_vector_runme.2.d +++ b/Examples/test-suite/d/li_std_vector_runme.2.d @@ -22,7 +22,7 @@ void main() { // Basic functionality tests. { auto vector = new IntVector(); - for (size_t i = 0; i < SIZE; ++i) { + foreach (int i; 0 .. SIZE) { vector ~= i * 10; } @@ -56,7 +56,7 @@ void main() { // To array conversion tests. { auto dVector = new DoubleVector(); - for (size_t i = 0; i < SIZE; ++i) { + foreach (i; 0 .. SIZE) { dVector ~= i * 10.1f; } @@ -67,13 +67,13 @@ void main() { auto sVector = new StructVector(); - for (size_t i = 0; i < SIZE; i++) { + foreach (i; 0 .. SIZE) { sVector ~= new Struct(i / 10.0); } Struct[] sArray = array(sVector[]); - for (size_t i = 0; i < SIZE; i++) { + foreach (i; 0 .. SIZE) { // Make sure that a shallow copy has been made. void* aPtr = Struct.swigGetCPtr(sArray[i]); void* vPtr = Struct.swigGetCPtr(sVector[i]); @@ -84,7 +84,7 @@ void main() { // remove() tests. { auto iVector = new IntVector(); - for (int i = 0; i < SIZE; i++) { + foreach (int i; 0 .. SIZE) { iVector ~= i; } @@ -108,7 +108,7 @@ void main() { // Test the methods being wrapped. { auto iv = new IntVector(); - for (int i=0; i<4; i++) { + foreach (int i; 0 .. 4) { iv ~= i; } @@ -117,7 +117,7 @@ void main() { RealVector rv = half(new RealVector([10.0f, 10.5f, 11.0f, 11.5f])); auto dv = new DoubleVector(); - for (size_t i = 0; i < SIZE; i++) { + foreach (i; 0 .. SIZE) { dv ~= i / 2.0; } halve_in_place(dv); @@ -147,13 +147,13 @@ void main() { // Test vectors of pointers. { auto vector = new StructPtrVector(); - for (size_t i = 0; i < SIZE; i++) { + foreach (i; 0 .. SIZE) { vector ~= new Struct(i / 10.0); } Struct[] array = array(vector[]); - for (size_t i = 0; i < SIZE; i++) { + foreach (i; 0 .. SIZE) { // Make sure that a shallow copy has been made. void* aPtr = Struct.swigGetCPtr(array[i]); void* vPtr = Struct.swigGetCPtr(vector[i]); @@ -164,13 +164,13 @@ void main() { // Test vectors of const pointers. { auto vector = new StructConstPtrVector(); - for (size_t i = 0; i < SIZE; i++) { + foreach (i; 0 .. SIZE) { vector ~= new Struct(i / 10.0); } Struct[] array = array(vector[]); - for (size_t i = 0; i < SIZE; i++) { + foreach (i; 0 .. SIZE) { // Make sure that a shallow copy has been made. void* aPtr = Struct.swigGetCPtr(array[i]); void* vPtr = Struct.swigGetCPtr(vector[i]); From e2b2f26bf6a6c01c95b9106bda9a4b59dfd4e2bd Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 3 Dec 2011 19:48:01 +0000 Subject: [PATCH 106/147] [D] Use stdc.config.c_long/c_ulong to represent C long types. Previously, C's long/ulong types would always be mapped to 32 bit integers in D, which is wrong on D_LP64, but was not really a problem in practice since DMD used to be 32 bit only. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12861 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 1 + .../test-suite/d/li_boost_shared_ptr_runme.2.d | 2 +- .../test-suite/d/preproc_constants_c_runme.1.d | 13 +++++++------ .../test-suite/d/preproc_constants_c_runme.2.d | 13 +++++++------ .../test-suite/d/preproc_constants_runme.1.d | 13 +++++++------ .../test-suite/d/preproc_constants_runme.2.d | 13 +++++++------ Lib/d/dprimitives.swg | 17 +++++++++++++++-- Lib/d/typemaps.i | 12 ++++++------ 8 files changed, 51 insertions(+), 33 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 60858a4ba..8105a0fe6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -8,6 +8,7 @@ Version 2.0.5 (in progress) 2011-12-03: klickvebrot [D] Fix exception glue code for newer DMD 2 versions. [D] Do not default to 32 bit glue code for DMD anymore. + [D] Use stdc.config.c_long/c_ulong to represent C long types. 2011-12-01: szager [python] Fixed bug 3447426: memory leak in vector.__getitem__. diff --git a/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d b/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d index 773ae74d5..0027aad05 100644 --- a/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d +++ b/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d @@ -583,7 +583,7 @@ private void verifyCount(int expected, Klass k) { // We deliberately call the use_count(Klass) overload also for objects which // are instances of a subclass of Klass (due to static dispatch); things still // have to work. - int got = use_count(k); + auto got = use_count(k); if (expected != got) throw new Exception("verify use_count failed. Expected: " ~ to!string(expected) ~ " Got: " ~ to!string(got)); } diff --git a/Examples/test-suite/d/preproc_constants_c_runme.1.d b/Examples/test-suite/d/preproc_constants_c_runme.1.d index f25bbfdee..d846c71ac 100644 --- a/Examples/test-suite/d/preproc_constants_c_runme.1.d +++ b/Examples/test-suite/d/preproc_constants_c_runme.1.d @@ -1,5 +1,6 @@ module preproc_constants_c_runme; +import tango.stdc.config; import preproc_constants_c.preproc_constants_c; // Same as preproc_constants.i testcase, but bool types are int instead. @@ -10,10 +11,10 @@ void main() { static assert(is(uint == typeof(CONST_UINT2()))); static assert(is(uint == typeof(CONST_UINT3()))); static assert(is(uint == typeof(CONST_UINT4()))); - static assert(is(int == typeof(CONST_LONG1()))); - static assert(is(int == typeof(CONST_LONG2()))); - static assert(is(int == typeof(CONST_LONG3()))); - static assert(is(int == typeof(CONST_LONG4()))); + static assert(is(c_long == typeof(CONST_LONG1()))); + static assert(is(c_long == typeof(CONST_LONG2()))); + static assert(is(c_long == typeof(CONST_LONG3()))); + static assert(is(c_long == typeof(CONST_LONG4()))); static assert(is(long == typeof(CONST_LLONG1()))); static assert(is(long == typeof(CONST_LLONG2()))); static assert(is(long == typeof(CONST_LLONG3()))); @@ -38,8 +39,8 @@ void main() { // static assert(is(int == typeof(INT_AND_CHAR()))); static assert(is(int == typeof(INT_AND_INT()))); static assert(is(uint == typeof(INT_AND_UINT()))); - static assert(is(int == typeof(INT_AND_LONG()))); - static assert(is(uint == typeof(INT_AND_ULONG()))); + static assert(is(c_long == typeof(INT_AND_LONG()))); + static assert(is(c_ulong == typeof(INT_AND_ULONG()))); static assert(is(long == typeof(INT_AND_LLONG()))); static assert(is(ulong == typeof(INT_AND_ULLONG()))); static assert(is(int == typeof(BOOL_AND_BOOL()))); diff --git a/Examples/test-suite/d/preproc_constants_c_runme.2.d b/Examples/test-suite/d/preproc_constants_c_runme.2.d index 07d6ac53d..9bdbb9372 100644 --- a/Examples/test-suite/d/preproc_constants_c_runme.2.d +++ b/Examples/test-suite/d/preproc_constants_c_runme.2.d @@ -1,5 +1,6 @@ module preproc_constants_c_runme; +import core.stdc.config; import preproc_constants_c.preproc_constants_c; // Same as preproc_constants.i testcase, but bool types are int instead. @@ -10,10 +11,10 @@ void main() { static assert(is(uint == typeof(CONST_UINT2()))); static assert(is(uint == typeof(CONST_UINT3()))); static assert(is(uint == typeof(CONST_UINT4()))); - static assert(is(int == typeof(CONST_LONG1()))); - static assert(is(int == typeof(CONST_LONG2()))); - static assert(is(int == typeof(CONST_LONG3()))); - static assert(is(int == typeof(CONST_LONG4()))); + static assert(is(c_long == typeof(CONST_LONG1()))); + static assert(is(c_long == typeof(CONST_LONG2()))); + static assert(is(c_long == typeof(CONST_LONG3()))); + static assert(is(c_long == typeof(CONST_LONG4()))); static assert(is(long == typeof(CONST_LLONG1()))); static assert(is(long == typeof(CONST_LLONG2()))); static assert(is(long == typeof(CONST_LLONG3()))); @@ -38,8 +39,8 @@ void main() { // static assert(is(int == typeof(INT_AND_CHAR()))); static assert(is(int == typeof(INT_AND_INT()))); static assert(is(uint == typeof(INT_AND_UINT()))); - static assert(is(int == typeof(INT_AND_LONG()))); - static assert(is(uint == typeof(INT_AND_ULONG()))); + static assert(is(c_long == typeof(INT_AND_LONG()))); + static assert(is(c_ulong == typeof(INT_AND_ULONG()))); static assert(is(long == typeof(INT_AND_LLONG()))); static assert(is(ulong == typeof(INT_AND_ULLONG()))); static assert(is(int == typeof(BOOL_AND_BOOL()))); diff --git a/Examples/test-suite/d/preproc_constants_runme.1.d b/Examples/test-suite/d/preproc_constants_runme.1.d index a2aaa8fcd..009405fc7 100644 --- a/Examples/test-suite/d/preproc_constants_runme.1.d +++ b/Examples/test-suite/d/preproc_constants_runme.1.d @@ -1,5 +1,6 @@ module preproc_constants_runme; +import tango.stdc.config; import preproc_constants.preproc_constants; void main() { @@ -9,10 +10,10 @@ void main() { static assert(is(uint == typeof(CONST_UINT2()))); static assert(is(uint == typeof(CONST_UINT3()))); static assert(is(uint == typeof(CONST_UINT4()))); - static assert(is(int == typeof(CONST_LONG1()))); - static assert(is(int == typeof(CONST_LONG2()))); - static assert(is(int == typeof(CONST_LONG3()))); - static assert(is(int == typeof(CONST_LONG4()))); + static assert(is(c_long == typeof(CONST_LONG1()))); + static assert(is(c_long == typeof(CONST_LONG2()))); + static assert(is(c_long == typeof(CONST_LONG3()))); + static assert(is(c_long == typeof(CONST_LONG4()))); static assert(is(long == typeof(CONST_LLONG1()))); static assert(is(long == typeof(CONST_LLONG2()))); static assert(is(long == typeof(CONST_LLONG3()))); @@ -37,8 +38,8 @@ void main() { // static assert(is(int == typeof(INT_AND_CHAR()))); static assert(is(int == typeof(INT_AND_INT()))); static assert(is(uint == typeof(INT_AND_UINT()))); - static assert(is(int == typeof(INT_AND_LONG()))); - static assert(is(uint == typeof(INT_AND_ULONG()))); + static assert(is(c_long == typeof(INT_AND_LONG()))); + static assert(is(c_ulong == typeof(INT_AND_ULONG()))); static assert(is(long == typeof(INT_AND_LLONG()))); static assert(is(ulong == typeof(INT_AND_ULLONG()))); static assert(is(int == typeof(BOOL_AND_BOOL()))); diff --git a/Examples/test-suite/d/preproc_constants_runme.2.d b/Examples/test-suite/d/preproc_constants_runme.2.d index e2eab2c46..2d92ef052 100644 --- a/Examples/test-suite/d/preproc_constants_runme.2.d +++ b/Examples/test-suite/d/preproc_constants_runme.2.d @@ -1,5 +1,6 @@ module preproc_constants_runme; +import core.stdc.config; import preproc_constants.preproc_constants; void main() { @@ -9,10 +10,10 @@ void main() { static assert(is(uint == typeof(CONST_UINT2()))); static assert(is(uint == typeof(CONST_UINT3()))); static assert(is(uint == typeof(CONST_UINT4()))); - static assert(is(int == typeof(CONST_LONG1()))); - static assert(is(int == typeof(CONST_LONG2()))); - static assert(is(int == typeof(CONST_LONG3()))); - static assert(is(int == typeof(CONST_LONG4()))); + static assert(is(c_long == typeof(CONST_LONG1()))); + static assert(is(c_long == typeof(CONST_LONG2()))); + static assert(is(c_long == typeof(CONST_LONG3()))); + static assert(is(c_long == typeof(CONST_LONG4()))); static assert(is(long == typeof(CONST_LLONG1()))); static assert(is(long == typeof(CONST_LLONG2()))); static assert(is(long == typeof(CONST_LLONG3()))); @@ -37,8 +38,8 @@ void main() { // static assert(is(int == typeof(INT_AND_CHAR()))); static assert(is(int == typeof(INT_AND_INT()))); static assert(is(uint == typeof(INT_AND_UINT()))); - static assert(is(int == typeof(INT_AND_LONG()))); - static assert(is(uint == typeof(INT_AND_ULONG()))); + static assert(is(c_long == typeof(INT_AND_LONG()))); + static assert(is(c_ulong == typeof(INT_AND_ULONG()))); static assert(is(long == typeof(INT_AND_LLONG()))); static assert(is(ulong == typeof(INT_AND_ULLONG()))); static assert(is(int == typeof(BOOL_AND_BOOL()))); diff --git a/Lib/d/dprimitives.swg b/Lib/d/dprimitives.swg index 53a4b89da..24ac8c9a0 100644 --- a/Lib/d/dprimitives.swg +++ b/Lib/d/dprimitives.swg @@ -4,6 +4,19 @@ * Typemaps for primitive types. * ----------------------------------------------------------------------------- */ +// C long/ulong width depends on the target arch, use stdlib aliases for them. +#if (SWIG_D_VERSION == 1) +%pragma(d) imdmoduleimports = "static import tango.stdc.config;" +%pragma(d) globalproxyimports = "static import tango.stdc.config;" +#define SWIG_LONG_DTYPE tango.stdc.config.c_long +#define SWIG_ULONG_DTYPE tango.stdc.config.c_ulong +#else +%pragma(d) imdmoduleimports = "static import core.stdc.config;" +%pragma(d) globalproxyimports = "static import core.stdc.config;" +#define SWIG_LONG_DTYPE core.stdc.config.c_long +#define SWIG_ULONG_DTYPE core.stdc.config.c_ulong +#endif + /* * The SWIG_D_PRIMITIVE macro is used to define the typemaps for the primitive * types, because are more or less the same for all of them. The few special @@ -49,8 +62,8 @@ SWIG_D_PRIMITIVE(short, short) SWIG_D_PRIMITIVE(unsigned short, ushort) SWIG_D_PRIMITIVE(int, int) SWIG_D_PRIMITIVE(unsigned int, uint) -SWIG_D_PRIMITIVE(long, int) -SWIG_D_PRIMITIVE(unsigned long, uint) +SWIG_D_PRIMITIVE(long, SWIG_LONG_DTYPE) +SWIG_D_PRIMITIVE(unsigned long, SWIG_ULONG_DTYPE) SWIG_D_PRIMITIVE(size_t, size_t) SWIG_D_PRIMITIVE(long long, long) SWIG_D_PRIMITIVE(unsigned long long, ulong) diff --git a/Lib/d/typemaps.i b/Lib/d/typemaps.i index 143c736f5..4f1b5997c 100644 --- a/Lib/d/typemaps.i +++ b/Lib/d/typemaps.i @@ -74,8 +74,8 @@ INPUT_TYPEMAP(short, short, short) INPUT_TYPEMAP(unsigned short, unsigned short, ushort) INPUT_TYPEMAP(int, int, int) INPUT_TYPEMAP(unsigned int, unsigned int, uint) -INPUT_TYPEMAP(long, long, int) -INPUT_TYPEMAP(unsigned long, unsigned long, uint) +INPUT_TYPEMAP(long, long, SWIG_LONG_DTYPE) +INPUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE) INPUT_TYPEMAP(long long, long long, long) INPUT_TYPEMAP(unsigned long long, unsigned long long, ulong) INPUT_TYPEMAP(float, float, float) @@ -157,8 +157,8 @@ OUTPUT_TYPEMAP(short, short, short, INT16_PTR) OUTPUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR) OUTPUT_TYPEMAP(int, int, int, INT32_PTR) OUTPUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR) -OUTPUT_TYPEMAP(long, long, int, INT32_PTR) -OUTPUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR) +OUTPUT_TYPEMAP(long, long, SWIG_LONG_DTYPE,INT32_PTR) +OUTPUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE,UINT32_PTR) OUTPUT_TYPEMAP(long long, long long, long, INT64_PTR) OUTPUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR) OUTPUT_TYPEMAP(float, float, float, FLOAT_PTR) @@ -248,8 +248,8 @@ INOUT_TYPEMAP(short, short, short, INT16_PTR) INOUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR) INOUT_TYPEMAP(int, int, int, INT32_PTR) INOUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR) -INOUT_TYPEMAP(long, long, int, INT32_PTR) -INOUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR) +INOUT_TYPEMAP(long, long, SWIG_LONG_DTYPE,INT32_PTR) +INOUT_TYPEMAP(unsigned long, unsigned long, SWIG_ULONG_DTYPE,UINT32_PTR) INOUT_TYPEMAP(long long, long long, long, INT64_PTR) INOUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR) INOUT_TYPEMAP(float, float, float, FLOAT_PTR) From 07c97f8742ad85d4a7d33c406c464753fa818af6 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 3 Dec 2011 21:49:44 +0000 Subject: [PATCH 107/147] Fix comment typo git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12862 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index da7101255..a2dc9fe23 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -12,7 +12,7 @@ # certain packages have been installed. Set the prefixes # accordingly. # -# 2. To use this makefile, set required varibles, eg SRCS, INTERFACE, +# 2. To use this makefile, set required variables, eg SRCS, INTERFACE, # INTERFACEDIR, INCLUDES, LIBS, TARGET, and do a # $(MAKE) -f Makefile.template.in SRCS='$(SRCS)' \ # INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \ From 5cf5f252d30d83758eaa1058ef617b5bac288533 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 6 Dec 2011 00:39:19 +0000 Subject: [PATCH 108/147] Improvements to PHP documentation git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12863 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Php.html | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index ccc0f039c..38a24bf2c 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -49,19 +49,23 @@

        -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, +SWIG supports generating wrappers for PHP5. Support for PHP4 was removed +in 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. +doesn't make much sense for SWIG to continue to support PHP4 now. If you +really need to continue to use PHP4, just stick with SWIG 1.3.36. +

        + +

        +Currently any PHP5 release should work, but we don't regularly test with +PHP < 5.3.

        In this chapter, we discuss SWIG's support of PHP. The PHP module 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. +OO wrappers for PHP5 was added in 1.3.30. The PHP module now supports most +of the features available in some of the other languages.

        @@ -175,7 +179,8 @@ attempts to do the dl() call for you: It is important to understand that PHP uses a single global namespace into which all symbols from extension modules are loaded. It is quite possible for names of symbols in one extension module to clash with -other symbols unless care is taken to %rename them. +other symbols unless care is taken to %rename them. At present +SWIG doesn't have support for the namespace feature added in PHP 5.3.

        31.2.1 Constants

        @@ -549,9 +554,11 @@ variable, or assigning NULL to a variable.

        -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. +SWIG defaults to wrapping C++ structs and classes with PHP classes - this +is done by generating a PHP wrapper script which defines proxy classes +which calls a set of flat functions which actually wrap the C++ class. +You can disable this wrapper layer by passing the command-line option +"-noproxy" in which case you'll just get the flat functions.

        From 1d1e8650a31ae90ca44564565a7c5fa680bc1cba Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 8 Dec 2011 05:59:37 +0000 Subject: [PATCH 109/147] Remove old copies of Perl Test::Builder and Test::More - these have been included with Perl since 5.6.0. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12864 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/perl5/Test/Builder.pm | 1591 --------------------- Examples/test-suite/perl5/Test/More.pm | 1448 ------------------- 2 files changed, 3039 deletions(-) delete mode 100644 Examples/test-suite/perl5/Test/Builder.pm delete mode 100644 Examples/test-suite/perl5/Test/More.pm diff --git a/Examples/test-suite/perl5/Test/Builder.pm b/Examples/test-suite/perl5/Test/Builder.pm deleted file mode 100644 index 9f6a3a43d..000000000 --- a/Examples/test-suite/perl5/Test/Builder.pm +++ /dev/null @@ -1,1591 +0,0 @@ -package Test::Builder; - -use 5.004; - -# $^C was only introduced in 5.005-ish. We do this to prevent -# use of uninitialized value warnings in older perls. -$^C ||= 0; - -use strict; -use vars qw($VERSION); -$VERSION = '0.22'; -$VERSION = eval $VERSION; # make the alpha version come out as a number - -# Make Test::Builder thread-safe for ithreads. -BEGIN { - use Config; - # Load threads::shared when threads are turned on - if( $] >= 5.008 && $Config{useithreads} && $INC{'threads.pm'}) { - require threads::shared; - - # Hack around YET ANOTHER threads::shared bug. It would - # occassionally forget the contents of the variable when sharing it. - # So we first copy the data, then share, then put our copy back. - *share = sub (\[$@%]) { - my $type = ref $_[0]; - my $data; - - if( $type eq 'HASH' ) { - %$data = %{$_[0]}; - } - elsif( $type eq 'ARRAY' ) { - @$data = @{$_[0]}; - } - elsif( $type eq 'SCALAR' ) { - $$data = ${$_[0]}; - } - else { - die "Unknown type: ".$type; - } - - $_[0] = &threads::shared::share($_[0]); - - if( $type eq 'HASH' ) { - %{$_[0]} = %$data; - } - elsif( $type eq 'ARRAY' ) { - @{$_[0]} = @$data; - } - elsif( $type eq 'SCALAR' ) { - ${$_[0]} = $$data; - } - else { - die "Unknown type: ".$type; - } - - return $_[0]; - }; - } - # 5.8.0's threads::shared is busted when threads are off. - # We emulate it here. - else { - *share = sub { return $_[0] }; - *lock = sub { 0 }; - } -} - - -=head1 NAME - -Test::Builder - Backend for building test libraries - -=head1 SYNOPSIS - - package My::Test::Module; - use Test::Builder; - require Exporter; - @ISA = qw(Exporter); - @EXPORT = qw(ok); - - my $Test = Test::Builder->new; - $Test->output('my_logfile'); - - sub import { - my($self) = shift; - my $pack = caller; - - $Test->exported_to($pack); - $Test->plan(@_); - - $self->export_to_level(1, $self, 'ok'); - } - - sub ok { - my($test, $name) = @_; - - $Test->ok($test, $name); - } - - -=head1 DESCRIPTION - -Test::Simple and Test::More have proven to be popular testing modules, -but they're not always flexible enough. Test::Builder provides the a -building block upon which to write your own test libraries I. - -=head2 Construction - -=over 4 - -=item B - - my $Test = Test::Builder->new; - -Returns a Test::Builder object representing the current state of the -test. - -Since you only run one test per program, there is B -Test::Builder object. No matter how many times you call new(), you're -getting the same object. (This is called a singleton). - -=cut - -my $Test = Test::Builder->new; -sub new { - my($class) = shift; - $Test ||= bless ['Move along, nothing to see here'], $class; - return $Test; -} - -=item B - - $Test->reset; - -Reinitializes the Test::Builder singleton to its original state. -Mostly useful for tests run in persistent environments where the same -test might be run multiple times in the same process. - -=cut - -my $Test_Died; -my $Have_Plan; -my $No_Plan; -my $Curr_Test; share($Curr_Test); -use vars qw($Level); -my $Original_Pid; -my @Test_Results; share(@Test_Results); - -my $Exported_To; -my $Expected_Tests; - -my $Skip_All; - -my $Use_Nums; - -my($No_Header, $No_Ending); - -$Test->reset; - -sub reset { - my ($self) = @_; - - $Test_Died = 0; - $Have_Plan = 0; - $No_Plan = 0; - $Curr_Test = 0; - $Level = 1; - $Original_Pid = $$; - @Test_Results = (); - - $Exported_To = undef; - $Expected_Tests = 0; - - $Skip_All = 0; - - $Use_Nums = 1; - - ($No_Header, $No_Ending) = (0,0); - - $self->_dup_stdhandles unless $^C; - - return undef; -} - -=back - -=head2 Setting up tests - -These methods are for setting up tests and declaring how many there -are. You usually only want to call one of these methods. - -=over 4 - -=item B - - my $pack = $Test->exported_to; - $Test->exported_to($pack); - -Tells Test::Builder what package you exported your functions to. -This is important for getting TODO tests right. - -=cut - -sub exported_to { - my($self, $pack) = @_; - - if( defined $pack ) { - $Exported_To = $pack; - } - return $Exported_To; -} - -=item B - - $Test->plan('no_plan'); - $Test->plan( skip_all => $reason ); - $Test->plan( tests => $num_tests ); - -A convenient way to set up your tests. Call this and Test::Builder -will print the appropriate headers and take the appropriate actions. - -If you call plan(), don't call any of the other methods below. - -=cut - -sub plan { - my($self, $cmd, $arg) = @_; - - return unless $cmd; - - if( $Have_Plan ) { - die sprintf "You tried to plan twice! Second plan at %s line %d\n", - ($self->caller)[1,2]; - } - - if( $cmd eq 'no_plan' ) { - $self->no_plan; - } - elsif( $cmd eq 'skip_all' ) { - return $self->skip_all($arg); - } - elsif( $cmd eq 'tests' ) { - if( $arg ) { - return $self->expected_tests($arg); - } - elsif( !defined $arg ) { - die "Got an undefined number of tests. Looks like you tried to ". - "say how many tests you plan to run but made a mistake.\n"; - } - elsif( !$arg ) { - die "You said to run 0 tests! You've got to run something.\n"; - } - } - else { - require Carp; - my @args = grep { defined } ($cmd, $arg); - Carp::croak("plan() doesn't understand @args"); - } - - return 1; -} - -=item B - - my $max = $Test->expected_tests; - $Test->expected_tests($max); - -Gets/sets the # of tests we expect this test to run and prints out -the appropriate headers. - -=cut - -sub expected_tests { - my $self = shift; - my($max) = @_; - - if( @_ ) { - die "Number of tests must be a postive integer. You gave it '$max'.\n" - unless $max =~ /^\+?\d+$/ and $max > 0; - - $Expected_Tests = $max; - $Have_Plan = 1; - - $self->_print("1..$max\n") unless $self->no_header; - } - return $Expected_Tests; -} - - -=item B - - $Test->no_plan; - -Declares that this test will run an indeterminate # of tests. - -=cut - -sub no_plan { - $No_Plan = 1; - $Have_Plan = 1; -} - -=item B - - $plan = $Test->has_plan - -Find out whether a plan has been defined. $plan is either C (no plan has been set), C (indeterminate # of tests) or an integer (the number of expected tests). - -=cut - -sub has_plan { - return($Expected_Tests) if $Expected_Tests; - return('no_plan') if $No_Plan; - return(undef); -}; - - -=item B - - $Test->skip_all; - $Test->skip_all($reason); - -Skips all the tests, using the given $reason. Exits immediately with 0. - -=cut - -sub skip_all { - my($self, $reason) = @_; - - my $out = "1..0"; - $out .= " # Skip $reason" if $reason; - $out .= "\n"; - - $Skip_All = 1; - - $self->_print($out) unless $self->no_header; - exit(0); -} - -=back - -=head2 Running tests - -These actually run the tests, analogous to the functions in -Test::More. - -$name is always optional. - -=over 4 - -=item B - - $Test->ok($test, $name); - -Your basic test. Pass if $test is true, fail if $test is false. Just -like Test::Simple's ok(). - -=cut - -sub ok { - my($self, $test, $name) = @_; - - # $test might contain an object which we don't want to accidentally - # store, so we turn it into a boolean. - $test = $test ? 1 : 0; - - unless( $Have_Plan ) { - require Carp; - Carp::croak("You tried to run a test without a plan! Gotta have a plan."); - } - - lock $Curr_Test; - $Curr_Test++; - - # In case $name is a string overloaded object, force it to stringify. - $self->_unoverload(\$name); - - $self->diag(<caller; - - my $todo = $self->todo($pack); - $self->_unoverload(\$todo); - - my $out; - my $result = &share({}); - - unless( $test ) { - $out .= "not "; - @$result{ 'ok', 'actual_ok' } = ( ( $todo ? 1 : 0 ), 0 ); - } - else { - @$result{ 'ok', 'actual_ok' } = ( 1, $test ); - } - - $out .= "ok"; - $out .= " $Curr_Test" if $self->use_numbers; - - if( defined $name ) { - $name =~ s|#|\\#|g; # # in a name can confuse Test::Harness. - $out .= " - $name"; - $result->{name} = $name; - } - else { - $result->{name} = ''; - } - - if( $todo ) { - $out .= " # TODO $todo"; - $result->{reason} = $todo; - $result->{type} = 'todo'; - } - else { - $result->{reason} = ''; - $result->{type} = ''; - } - - $Test_Results[$Curr_Test-1] = $result; - $out .= "\n"; - - $self->_print($out); - - unless( $test ) { - my $msg = $todo ? "Failed (TODO)" : "Failed"; - $self->_print_diag("\n") if $ENV{HARNESS_ACTIVE}; - $self->diag(" $msg test ($file at line $line)\n"); - } - - return $test ? 1 : 0; -} - - -sub _unoverload { - my $self = shift; - - local($@,$!); - - eval { require overload } || return; - - foreach my $thing (@_) { - eval { - if( defined $$thing ) { - if( my $string_meth = overload::Method($$thing, '""') ) { - $$thing = $$thing->$string_meth(); - } - } - }; - } -} - - -=item B - - $Test->is_eq($got, $expected, $name); - -Like Test::More's is(). Checks if $got eq $expected. This is the -string version. - -=item B - - $Test->is_num($got, $expected, $name); - -Like Test::More's is(). Checks if $got == $expected. This is the -numeric version. - -=cut - -sub is_eq { - my($self, $got, $expect, $name) = @_; - local $Level = $Level + 1; - - if( !defined $got || !defined $expect ) { - # undef only matches undef and nothing else - my $test = !defined $got && !defined $expect; - - $self->ok($test, $name); - $self->_is_diag($got, 'eq', $expect) unless $test; - return $test; - } - - return $self->cmp_ok($got, 'eq', $expect, $name); -} - -sub is_num { - my($self, $got, $expect, $name) = @_; - local $Level = $Level + 1; - - if( !defined $got || !defined $expect ) { - # undef only matches undef and nothing else - my $test = !defined $got && !defined $expect; - - $self->ok($test, $name); - $self->_is_diag($got, '==', $expect) unless $test; - return $test; - } - - return $self->cmp_ok($got, '==', $expect, $name); -} - -sub _is_diag { - my($self, $got, $type, $expect) = @_; - - foreach my $val (\$got, \$expect) { - if( defined $$val ) { - if( $type eq 'eq' ) { - # quote and force string context - $$val = "'$$val'" - } - else { - # force numeric context - $$val = $$val+0; - } - } - else { - $$val = 'undef'; - } - } - - return $self->diag(sprintf < - - $Test->isnt_eq($got, $dont_expect, $name); - -Like Test::More's isnt(). Checks if $got ne $dont_expect. This is -the string version. - -=item B - - $Test->is_num($got, $dont_expect, $name); - -Like Test::More's isnt(). Checks if $got ne $dont_expect. This is -the numeric version. - -=cut - -sub isnt_eq { - my($self, $got, $dont_expect, $name) = @_; - local $Level = $Level + 1; - - if( !defined $got || !defined $dont_expect ) { - # undef only matches undef and nothing else - my $test = defined $got || defined $dont_expect; - - $self->ok($test, $name); - $self->_cmp_diag($got, 'ne', $dont_expect) unless $test; - return $test; - } - - return $self->cmp_ok($got, 'ne', $dont_expect, $name); -} - -sub isnt_num { - my($self, $got, $dont_expect, $name) = @_; - local $Level = $Level + 1; - - if( !defined $got || !defined $dont_expect ) { - # undef only matches undef and nothing else - my $test = defined $got || defined $dont_expect; - - $self->ok($test, $name); - $self->_cmp_diag($got, '!=', $dont_expect) unless $test; - return $test; - } - - return $self->cmp_ok($got, '!=', $dont_expect, $name); -} - - -=item B - - $Test->like($this, qr/$regex/, $name); - $Test->like($this, '/$regex/', $name); - -Like Test::More's like(). Checks if $this matches the given $regex. - -You'll want to avoid qr// if you want your tests to work before 5.005. - -=item B - - $Test->unlike($this, qr/$regex/, $name); - $Test->unlike($this, '/$regex/', $name); - -Like Test::More's unlike(). Checks if $this B the -given $regex. - -=cut - -sub like { - my($self, $this, $regex, $name) = @_; - - local $Level = $Level + 1; - $self->_regex_ok($this, $regex, '=~', $name); -} - -sub unlike { - my($self, $this, $regex, $name) = @_; - - local $Level = $Level + 1; - $self->_regex_ok($this, $regex, '!~', $name); -} - -=item B - - $Test->maybe_regex(qr/$regex/); - $Test->maybe_regex('/$regex/'); - -Convenience method for building testing functions that take regular -expressions as arguments, but need to work before perl 5.005. - -Takes a quoted regular expression produced by qr//, or a string -representing a regular expression. - -Returns a Perl value which may be used instead of the corresponding -regular expression, or undef if it's argument is not recognised. - -For example, a version of like(), sans the useful diagnostic messages, -could be written as: - - sub laconic_like { - my ($self, $this, $regex, $name) = @_; - my $usable_regex = $self->maybe_regex($regex); - die "expecting regex, found '$regex'\n" - unless $usable_regex; - $self->ok($this =~ m/$usable_regex/, $name); - } - -=cut - - -sub maybe_regex { - my ($self, $regex) = @_; - my $usable_regex = undef; - - return $usable_regex unless defined $regex; - - my($re, $opts); - - # Check for qr/foo/ - if( ref $regex eq 'Regexp' ) { - $usable_regex = $regex; - } - # Check for '/foo/' or 'm,foo,' - elsif( ($re, $opts) = $regex =~ m{^ /(.*)/ (\w*) $ }sx or - (undef, $re, $opts) = $regex =~ m,^ m([^\w\s]) (.+) \1 (\w*) $,sx - ) - { - $usable_regex = length $opts ? "(?$opts)$re" : $re; - } - - return $usable_regex; -}; - -sub _regex_ok { - my($self, $this, $regex, $cmp, $name) = @_; - - local $Level = $Level + 1; - - my $ok = 0; - my $usable_regex = $self->maybe_regex($regex); - unless (defined $usable_regex) { - $ok = $self->ok( 0, $name ); - $self->diag(" '$regex' doesn't look much like a regex to me."); - return $ok; - } - - { - local $^W = 0; - my $test = $this =~ /$usable_regex/ ? 1 : 0; - $test = !$test if $cmp eq '!~'; - $ok = $self->ok( $test, $name ); - } - - unless( $ok ) { - $this = defined $this ? "'$this'" : 'undef'; - my $match = $cmp eq '=~' ? "doesn't match" : "matches"; - $self->diag(sprintf < - - $Test->cmp_ok($this, $type, $that, $name); - -Works just like Test::More's cmp_ok(). - - $Test->cmp_ok($big_num, '!=', $other_big_num); - -=cut - -sub cmp_ok { - my($self, $got, $type, $expect, $name) = @_; - - my $test; - { - local $^W = 0; - local($@,$!); # don't interfere with $@ - # eval() sometimes resets $! - $test = eval "\$got $type \$expect"; - } - local $Level = $Level + 1; - my $ok = $self->ok($test, $name); - - unless( $ok ) { - if( $type =~ /^(eq|==)$/ ) { - $self->_is_diag($got, $type, $expect); - } - else { - $self->_cmp_diag($got, $type, $expect); - } - } - return $ok; -} - -sub _cmp_diag { - my($self, $got, $type, $expect) = @_; - - $got = defined $got ? "'$got'" : 'undef'; - $expect = defined $expect ? "'$expect'" : 'undef'; - return $self->diag(sprintf < - - $Test->BAILOUT($reason); - -Indicates to the Test::Harness that things are going so badly all -testing should terminate. This includes running any additional test -scripts. - -It will exit with 255. - -=cut - -sub BAILOUT { - my($self, $reason) = @_; - - $self->_print("Bail out! $reason"); - exit 255; -} - -=item B - - $Test->skip; - $Test->skip($why); - -Skips the current test, reporting $why. - -=cut - -sub skip { - my($self, $why) = @_; - $why ||= ''; - $self->_unoverload(\$why); - - unless( $Have_Plan ) { - require Carp; - Carp::croak("You tried to run tests without a plan! Gotta have a plan."); - } - - lock($Curr_Test); - $Curr_Test++; - - $Test_Results[$Curr_Test-1] = &share({ - 'ok' => 1, - actual_ok => 1, - name => '', - type => 'skip', - reason => $why, - }); - - my $out = "ok"; - $out .= " $Curr_Test" if $self->use_numbers; - $out .= " # skip"; - $out .= " $why" if length $why; - $out .= "\n"; - - $Test->_print($out); - - return 1; -} - - -=item B - - $Test->todo_skip; - $Test->todo_skip($why); - -Like skip(), only it will declare the test as failing and TODO. Similar -to - - print "not ok $tnum # TODO $why\n"; - -=cut - -sub todo_skip { - my($self, $why) = @_; - $why ||= ''; - - unless( $Have_Plan ) { - require Carp; - Carp::croak("You tried to run tests without a plan! Gotta have a plan."); - } - - lock($Curr_Test); - $Curr_Test++; - - $Test_Results[$Curr_Test-1] = &share({ - 'ok' => 1, - actual_ok => 0, - name => '', - type => 'todo_skip', - reason => $why, - }); - - my $out = "not ok"; - $out .= " $Curr_Test" if $self->use_numbers; - $out .= " # TODO & SKIP $why\n"; - - $Test->_print($out); - - return 1; -} - - -=begin _unimplemented - -=item B - - $Test->skip_rest; - $Test->skip_rest($reason); - -Like skip(), only it skips all the rest of the tests you plan to run -and terminates the test. - -If you're running under no_plan, it skips once and terminates the -test. - -=end _unimplemented - -=back - - -=head2 Test style - -=over 4 - -=item B - - $Test->level($how_high); - -How far up the call stack should $Test look when reporting where the -test failed. - -Defaults to 1. - -Setting $Test::Builder::Level overrides. This is typically useful -localized: - - { - local $Test::Builder::Level = 2; - $Test->ok($test); - } - -=cut - -sub level { - my($self, $level) = @_; - - if( defined $level ) { - $Level = $level; - } - return $Level; -} - - -=item B - - $Test->use_numbers($on_or_off); - -Whether or not the test should output numbers. That is, this if true: - - ok 1 - ok 2 - ok 3 - -or this if false - - ok - ok - ok - -Most useful when you can't depend on the test output order, such as -when threads or forking is involved. - -Test::Harness will accept either, but avoid mixing the two styles. - -Defaults to on. - -=cut - -sub use_numbers { - my($self, $use_nums) = @_; - - if( defined $use_nums ) { - $Use_Nums = $use_nums; - } - return $Use_Nums; -} - -=item B - - $Test->no_header($no_header); - -If set to true, no "1..N" header will be printed. - -=item B - - $Test->no_ending($no_ending); - -Normally, Test::Builder does some extra diagnostics when the test -ends. It also changes the exit code as described below. - -If this is true, none of that will be done. - -=cut - -sub no_header { - my($self, $no_header) = @_; - - if( defined $no_header ) { - $No_Header = $no_header; - } - return $No_Header; -} - -sub no_ending { - my($self, $no_ending) = @_; - - if( defined $no_ending ) { - $No_Ending = $no_ending; - } - return $No_Ending; -} - - -=back - -=head2 Output - -Controlling where the test output goes. - -It's ok for your test to change where STDOUT and STDERR point to, -Test::Builder's default output settings will not be affected. - -=over 4 - -=item B - - $Test->diag(@msgs); - -Prints out the given @msgs. Like C, arguments are simply -appended together. - -Normally, it uses the failure_output() handle, but if this is for a -TODO test, the todo_output() handle is used. - -Output will be indented and marked with a # so as not to interfere -with test output. A newline will be put on the end if there isn't one -already. - -We encourage using this rather than calling print directly. - -Returns false. Why? Because diag() is often used in conjunction with -a failing test (C) it "passes through" the failure. - - return ok(...) || diag(...); - -=for blame transfer -Mark Fowler - -=cut - -sub diag { - my($self, @msgs) = @_; - return unless @msgs; - - # Prevent printing headers when compiling (i.e. -c) - return if $^C; - - # Smash args together like print does. - # Convert undef to 'undef' so its readable. - my $msg = join '', map { defined($_) ? $_ : 'undef' } @msgs; - - # Escape each line with a #. - $msg =~ s/^/# /gm; - - # Stick a newline on the end if it needs it. - $msg .= "\n" unless $msg =~ /\n\Z/; - - local $Level = $Level + 1; - $self->_print_diag($msg); - - return 0; -} - -=begin _private - -=item B<_print> - - $Test->_print(@msgs); - -Prints to the output() filehandle. - -=end _private - -=cut - -sub _print { - my($self, @msgs) = @_; - - # Prevent printing headers when only compiling. Mostly for when - # tests are deparsed with B::Deparse - return if $^C; - - my $msg = join '', @msgs; - - local($\, $", $,) = (undef, ' ', ''); - my $fh = $self->output; - - # Escape each line after the first with a # so we don't - # confuse Test::Harness. - $msg =~ s/\n(.)/\n# $1/sg; - - # Stick a newline on the end if it needs it. - $msg .= "\n" unless $msg =~ /\n\Z/; - - print $fh $msg; -} - - -=item B<_print_diag> - - $Test->_print_diag(@msg); - -Like _print, but prints to the current diagnostic filehandle. - -=cut - -sub _print_diag { - my $self = shift; - - local($\, $", $,) = (undef, ' ', ''); - my $fh = $self->todo ? $self->todo_output : $self->failure_output; - print $fh @_; -} - -=item B - - $Test->output($fh); - $Test->output($file); - -Where normal "ok/not ok" test output should go. - -Defaults to STDOUT. - -=item B - - $Test->failure_output($fh); - $Test->failure_output($file); - -Where diagnostic output on test failures and diag() should go. - -Defaults to STDERR. - -=item B - - $Test->todo_output($fh); - $Test->todo_output($file); - -Where diagnostics about todo test failures and diag() should go. - -Defaults to STDOUT. - -=cut - -my($Out_FH, $Fail_FH, $Todo_FH); -sub output { - my($self, $fh) = @_; - - if( defined $fh ) { - $Out_FH = _new_fh($fh); - } - return $Out_FH; -} - -sub failure_output { - my($self, $fh) = @_; - - if( defined $fh ) { - $Fail_FH = _new_fh($fh); - } - return $Fail_FH; -} - -sub todo_output { - my($self, $fh) = @_; - - if( defined $fh ) { - $Todo_FH = _new_fh($fh); - } - return $Todo_FH; -} - - -sub _new_fh { - my($file_or_fh) = shift; - - my $fh; - if( _is_fh($file_or_fh) ) { - $fh = $file_or_fh; - } - else { - $fh = do { local *FH }; - open $fh, ">$file_or_fh" or - die "Can't open test output log $file_or_fh: $!"; - } - - return $fh; -} - - -sub _is_fh { - my $maybe_fh = shift; - - return 1 if ref \$maybe_fh eq 'GLOB'; # its a glob - - return UNIVERSAL::isa($maybe_fh, 'GLOB') || - UNIVERSAL::isa($maybe_fh, 'IO::Handle') || - - # 5.5.4's tied() and can() doesn't like getting undef - UNIVERSAL::can((tied($maybe_fh) || ''), 'TIEHANDLE'); -} - - -sub _autoflush { - my($fh) = shift; - my $old_fh = select $fh; - $| = 1; - select $old_fh; -} - - -my $Opened_Testhandles = 0; -sub _dup_stdhandles { - my $self = shift; - - $self->_open_testhandles unless $Opened_Testhandles; - - # Set everything to unbuffered else plain prints to STDOUT will - # come out in the wrong order from our own prints. - _autoflush(\*TESTOUT); - _autoflush(\*STDOUT); - _autoflush(\*TESTERR); - _autoflush(\*STDERR); - - $Test->output(\*TESTOUT); - $Test->failure_output(\*TESTERR); - $Test->todo_output(\*TESTOUT); -} - -sub _open_testhandles { - # We dup STDOUT and STDERR so people can change them in their - # test suites while still getting normal test output. - open(TESTOUT, ">&STDOUT") or die "Can't dup STDOUT: $!"; - open(TESTERR, ">&STDERR") or die "Can't dup STDERR: $!"; - $Opened_Testhandles = 1; -} - - -=back - - -=head2 Test Status and Info - -=over 4 - -=item B - - my $curr_test = $Test->current_test; - $Test->current_test($num); - -Gets/sets the current test number we're on. You usually shouldn't -have to set this. - -If set forward, the details of the missing tests are filled in as 'unknown'. -if set backward, the details of the intervening tests are deleted. You -can erase history if you really want to. - -=cut - -sub current_test { - my($self, $num) = @_; - - lock($Curr_Test); - if( defined $num ) { - unless( $Have_Plan ) { - require Carp; - Carp::croak("Can't change the current test number without a plan!"); - } - - $Curr_Test = $num; - - # If the test counter is being pushed forward fill in the details. - if( $num > @Test_Results ) { - my $start = @Test_Results ? $#Test_Results + 1 : 0; - for ($start..$num-1) { - $Test_Results[$_] = &share({ - 'ok' => 1, - actual_ok => undef, - reason => 'incrementing test number', - type => 'unknown', - name => undef - }); - } - } - # If backward, wipe history. Its their funeral. - elsif( $num < @Test_Results ) { - $#Test_Results = $num - 1; - } - } - return $Curr_Test; -} - - -=item B

        - - my @tests = $Test->summary; - -A simple summary of the tests so far. True for pass, false for fail. -This is a logical pass/fail, so todos are passes. - -Of course, test #1 is $tests[0], etc... - -=cut - -sub summary { - my($self) = shift; - - return map { $_->{'ok'} } @Test_Results; -} - -=item B
        - - my @tests = $Test->details; - -Like summary(), but with a lot more detail. - - $tests[$test_num - 1] = - { 'ok' => is the test considered a pass? - actual_ok => did it literally say 'ok'? - name => name of the test (if any) - type => type of test (if any, see below). - reason => reason for the above (if any) - }; - -'ok' is true if Test::Harness will consider the test to be a pass. - -'actual_ok' is a reflection of whether or not the test literally -printed 'ok' or 'not ok'. This is for examining the result of 'todo' -tests. - -'name' is the name of the test. - -'type' indicates if it was a special test. Normal tests have a type -of ''. Type can be one of the following: - - skip see skip() - todo see todo() - todo_skip see todo_skip() - unknown see below - -Sometimes the Test::Builder test counter is incremented without it -printing any test output, for example, when current_test() is changed. -In these cases, Test::Builder doesn't know the result of the test, so -it's type is 'unkown'. These details for these tests are filled in. -They are considered ok, but the name and actual_ok is left undef. - -For example "not ok 23 - hole count # TODO insufficient donuts" would -result in this structure: - - $tests[22] = # 23 - 1, since arrays start from 0. - { ok => 1, # logically, the test passed since it's todo - actual_ok => 0, # in absolute terms, it failed - name => 'hole count', - type => 'todo', - reason => 'insufficient donuts' - }; - -=cut - -sub details { - return @Test_Results; -} - -=item B - - my $todo_reason = $Test->todo; - my $todo_reason = $Test->todo($pack); - -todo() looks for a $TODO variable in your tests. If set, all tests -will be considered 'todo' (see Test::More and Test::Harness for -details). Returns the reason (ie. the value of $TODO) if running as -todo tests, false otherwise. - -todo() is pretty part about finding the right package to look for -$TODO in. It uses the exported_to() package to find it. If that's -not set, it's pretty good at guessing the right package to look at. - -Sometimes there is some confusion about where todo() should be looking -for the $TODO variable. If you want to be sure, tell it explicitly -what $pack to use. - -=cut - -sub todo { - my($self, $pack) = @_; - - $pack = $pack || $self->exported_to || $self->caller(1); - - no strict 'refs'; - return defined ${$pack.'::TODO'} ? ${$pack.'::TODO'} - : 0; -} - -=item B - - my $package = $Test->caller; - my($pack, $file, $line) = $Test->caller; - my($pack, $file, $line) = $Test->caller($height); - -Like the normal caller(), except it reports according to your level(). - -=cut - -sub caller { - my($self, $height) = @_; - $height ||= 0; - - my @caller = CORE::caller($self->level + $height + 1); - return wantarray ? @caller : $caller[0]; -} - -=back - -=cut - -=begin _private - -=over 4 - -=item B<_sanity_check> - - _sanity_check(); - -Runs a bunch of end of test sanity checks to make sure reality came -through ok. If anything is wrong it will die with a fairly friendly -error message. - -=cut - -#'# -sub _sanity_check { - _whoa($Curr_Test < 0, 'Says here you ran a negative number of tests!'); - _whoa(!$Have_Plan and $Curr_Test, - 'Somehow your tests ran without a plan!'); - _whoa($Curr_Test != @Test_Results, - 'Somehow you got a different number of results than tests ran!'); -} - -=item B<_whoa> - - _whoa($check, $description); - -A sanity check, similar to assert(). If the $check is true, something -has gone horribly wrong. It will die with the given $description and -a note to contact the author. - -=cut - -sub _whoa { - my($check, $desc) = @_; - if( $check ) { - die < - - _my_exit($exit_num); - -Perl seems to have some trouble with exiting inside an END block. 5.005_03 -and 5.6.1 both seem to do odd things. Instead, this function edits $? -directly. It should ONLY be called from inside an END block. It -doesn't actually exit, that's your job. - -=cut - -sub _my_exit { - $? = $_[0]; - - return 1; -} - - -=back - -=end _private - -=cut - -$SIG{__DIE__} = sub { - # We don't want to muck with death in an eval, but $^S isn't - # totally reliable. 5.005_03 and 5.6.1 both do the wrong thing - # with it. Instead, we use caller. This also means it runs under - # 5.004! - my $in_eval = 0; - for( my $stack = 1; my $sub = (CORE::caller($stack))[3]; $stack++ ) { - $in_eval = 1 if $sub =~ /^\(eval\)/; - } - $Test_Died = 1 unless $in_eval; -}; - -sub _ending { - my $self = shift; - - _sanity_check(); - - # Don't bother with an ending if this is a forked copy. Only the parent - # should do the ending. - do{ _my_exit($?) && return } if $Original_Pid != $$; - - # Bailout if plan() was never called. This is so - # "require Test::Simple" doesn't puke. - do{ _my_exit(0) && return } if !$Have_Plan && !$Test_Died; - - # Figure out if we passed or failed and print helpful messages. - if( @Test_Results ) { - # The plan? We have no plan. - if( $No_Plan ) { - $self->_print("1..$Curr_Test\n") unless $self->no_header; - $Expected_Tests = $Curr_Test; - } - - # Auto-extended arrays and elements which aren't explicitly - # filled in with a shared reference will puke under 5.8.0 - # ithreads. So we have to fill them in by hand. :( - my $empty_result = &share({}); - for my $idx ( 0..$Expected_Tests-1 ) { - $Test_Results[$idx] = $empty_result - unless defined $Test_Results[$idx]; - } - - my $num_failed = grep !$_->{'ok'}, @Test_Results[0..$Expected_Tests-1]; - $num_failed += abs($Expected_Tests - @Test_Results); - - if( $Curr_Test < $Expected_Tests ) { - my $s = $Expected_Tests == 1 ? '' : 's'; - $self->diag(<<"FAIL"); -Looks like you planned $Expected_Tests test$s but only ran $Curr_Test. -FAIL - } - elsif( $Curr_Test > $Expected_Tests ) { - my $num_extra = $Curr_Test - $Expected_Tests; - my $s = $Expected_Tests == 1 ? '' : 's'; - $self->diag(<<"FAIL"); -Looks like you planned $Expected_Tests test$s but ran $num_extra extra. -FAIL - } - elsif ( $num_failed ) { - my $s = $num_failed == 1 ? '' : 's'; - $self->diag(<<"FAIL"); -Looks like you failed $num_failed test$s of $Expected_Tests. -FAIL - } - - if( $Test_Died ) { - $self->diag(<<"FAIL"); -Looks like your test died just after $Curr_Test. -FAIL - - _my_exit( 255 ) && return; - } - - _my_exit( $num_failed <= 254 ? $num_failed : 254 ) && return; - } - elsif ( $Skip_All ) { - _my_exit( 0 ) && return; - } - elsif ( $Test_Died ) { - $self->diag(<<'FAIL'); -Looks like your test died before it could output anything. -FAIL - _my_exit( 255 ) && return; - } - else { - $self->diag("No tests run!\n"); - _my_exit( 255 ) && return; - } -} - -END { - $Test->_ending if defined $Test and !$Test->no_ending; -} - -=head1 EXIT CODES - -If all your tests passed, Test::Builder will exit with zero (which is -normal). If anything failed it will exit with how many failed. If -you run less (or more) tests than you planned, the missing (or extras) -will be considered failures. If no tests were ever run Test::Builder -will throw a warning and exit with 255. If the test died, even after -having successfully completed all its tests, it will still be -considered a failure and will exit with 255. - -So the exit codes are... - - 0 all tests successful - 255 test died - any other number how many failed (including missing or extras) - -If you fail more than 254 tests, it will be reported as 254. - - -=head1 THREADS - -In perl 5.8.0 and later, Test::Builder is thread-safe. The test -number is shared amongst all threads. This means if one thread sets -the test number using current_test() they will all be effected. - -Test::Builder is only thread-aware if threads.pm is loaded I -Test::Builder. - -=head1 EXAMPLES - -CPAN can provide the best examples. Test::Simple, Test::More, -Test::Exception and Test::Differences all use Test::Builder. - -=head1 SEE ALSO - -Test::Simple, Test::More, Test::Harness - -=head1 AUTHORS - -Original code by chromatic, maintained by Michael G Schwern -Eschwern@pobox.comE - -=head1 COPYRIGHT - -Copyright 2002, 2004 by chromatic Echromatic@wgz.orgE and - Michael G Schwern Eschwern@pobox.comE. - -This program is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. - -See F - -=cut - -1; diff --git a/Examples/test-suite/perl5/Test/More.pm b/Examples/test-suite/perl5/Test/More.pm deleted file mode 100644 index aa0280851..000000000 --- a/Examples/test-suite/perl5/Test/More.pm +++ /dev/null @@ -1,1448 +0,0 @@ -package Test::More; - -use 5.004; - -use strict; -use Test::Builder; - - -# Can't use Carp because it might cause use_ok() to accidentally succeed -# even though the module being used forgot to use Carp. Yes, this -# actually happened. -sub _carp { - my($file, $line) = (caller(1))[1,2]; - warn @_, " at $file line $line\n"; -} - - - -require Exporter; -use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS $TODO); -$VERSION = '0.54'; -$VERSION = eval $VERSION; # make the alpha version come out as a number - -@ISA = qw(Exporter); -@EXPORT = qw(ok use_ok require_ok - is isnt like unlike is_deeply - cmp_ok - skip todo todo_skip - pass fail - eq_array eq_hash eq_set - $TODO - plan - can_ok isa_ok - diag - ); - -my $Test = Test::Builder->new; -my $Show_Diag = 1; - - -# 5.004's Exporter doesn't have export_to_level. -sub _export_to_level -{ - my $pkg = shift; - my $level = shift; - (undef) = shift; # redundant arg - my $callpkg = caller($level); - $pkg->export($callpkg, @_); -} - - -=head1 NAME - -Test::More - yet another framework for writing test scripts - -=head1 SYNOPSIS - - use Test::More tests => $Num_Tests; - # or - use Test::More qw(no_plan); - # or - use Test::More skip_all => $reason; - - BEGIN { use_ok( 'Some::Module' ); } - require_ok( 'Some::Module' ); - - # Various ways to say "ok" - ok($this eq $that, $test_name); - - is ($this, $that, $test_name); - isnt($this, $that, $test_name); - - # Rather than print STDERR "# here's what went wrong\n" - diag("here's what went wrong"); - - like ($this, qr/that/, $test_name); - unlike($this, qr/that/, $test_name); - - cmp_ok($this, '==', $that, $test_name); - - is_deeply($complex_structure1, $complex_structure2, $test_name); - - SKIP: { - skip $why, $how_many unless $have_some_feature; - - ok( foo(), $test_name ); - is( foo(42), 23, $test_name ); - }; - - TODO: { - local $TODO = $why; - - ok( foo(), $test_name ); - is( foo(42), 23, $test_name ); - }; - - can_ok($module, @methods); - isa_ok($object, $class); - - pass($test_name); - fail($test_name); - - # Utility comparison functions. - eq_array(\@this, \@that); - eq_hash(\%this, \%that); - eq_set(\@this, \@that); - - # UNIMPLEMENTED!!! - my @status = Test::More::status; - - # UNIMPLEMENTED!!! - BAIL_OUT($why); - - -=head1 DESCRIPTION - -B If you're just getting started writing tests, have a look at -Test::Simple first. This is a drop in replacement for Test::Simple -which you can switch to once you get the hang of basic testing. - -The purpose of this module is to provide a wide range of testing -utilities. Various ways to say "ok" with better diagnostics, -facilities to skip tests, test future features and compare complicated -data structures. While you can do almost anything with a simple -C function, it doesn't provide good diagnostic output. - - -=head2 I love it when a plan comes together - -Before anything else, you need a testing plan. This basically declares -how many tests your script is going to run to protect against premature -failure. - -The preferred way to do this is to declare a plan when you C. - - use Test::More tests => $Num_Tests; - -There are rare cases when you will not know beforehand how many tests -your script is going to run. In this case, you can declare that you -have no plan. (Try to avoid using this as it weakens your test.) - - use Test::More qw(no_plan); - -B: using no_plan requires a Test::Harness upgrade else it will -think everything has failed. See L) - -In some cases, you'll want to completely skip an entire testing script. - - use Test::More skip_all => $skip_reason; - -Your script will declare a skip with the reason why you skipped and -exit immediately with a zero (success). See L for -details. - -If you want to control what functions Test::More will export, you -have to use the 'import' option. For example, to import everything -but 'fail', you'd do: - - use Test::More tests => 23, import => ['!fail']; - -Alternatively, you can use the plan() function. Useful for when you -have to calculate the number of tests. - - use Test::More; - plan tests => keys %Stuff * 3; - -or for deciding between running the tests at all: - - use Test::More; - if( $^O eq 'MacOS' ) { - plan skip_all => 'Test irrelevant on MacOS'; - } - else { - plan tests => 42; - } - -=cut - -sub plan { - my(@plan) = @_; - - my $idx = 0; - my @cleaned_plan; - while( $idx <= $#plan ) { - my $item = $plan[$idx]; - - if( $item eq 'no_diag' ) { - $Show_Diag = 0; - } - else { - push @cleaned_plan, $item; - } - - $idx++; - } - - $Test->plan(@cleaned_plan); -} - -sub import { - my($class) = shift; - - my $caller = caller; - - $Test->exported_to($caller); - - my $idx = 0; - my @plan; - my @imports; - while( $idx <= $#_ ) { - my $item = $_[$idx]; - - if( $item eq 'import' ) { - push @imports, @{$_[$idx+1]}; - $idx++; - } - else { - push @plan, $item; - } - - $idx++; - } - - plan(@plan); - - __PACKAGE__->_export_to_level(1, __PACKAGE__, @imports); -} - - -=head2 Test names - -By convention, each test is assigned a number in order. This is -largely done automatically for you. However, it's often very useful to -assign a name to each test. Which would you rather see: - - ok 4 - not ok 5 - ok 6 - -or - - ok 4 - basic multi-variable - not ok 5 - simple exponential - ok 6 - force == mass * acceleration - -The later gives you some idea of what failed. It also makes it easier -to find the test in your script, simply search for "simple -exponential". - -All test functions take a name argument. It's optional, but highly -suggested that you use it. - - -=head2 I'm ok, you're not ok. - -The basic purpose of this module is to print out either "ok #" or "not -ok #" depending on if a given test succeeded or failed. Everything -else is just gravy. - -All of the following print "ok" or "not ok" depending on if the test -succeeded or failed. They all also return true or false, -respectively. - -=over 4 - -=item B - - ok($this eq $that, $test_name); - -This simply evaluates any expression (C<$this eq $that> is just a -simple example) and uses that to determine if the test succeeded or -failed. A true expression passes, a false one fails. Very simple. - -For example: - - ok( $exp{9} == 81, 'simple exponential' ); - ok( Film->can('db_Main'), 'set_db()' ); - ok( $p->tests == 4, 'saw tests' ); - ok( !grep !defined $_, @items, 'items populated' ); - -(Mnemonic: "This is ok.") - -$test_name is a very short description of the test that will be printed -out. It makes it very easy to find a test in your script when it fails -and gives others an idea of your intentions. $test_name is optional, -but we B strongly encourage its use. - -Should an ok() fail, it will produce some diagnostics: - - not ok 18 - sufficient mucus - # Failed test 18 (foo.t at line 42) - -This is actually Test::Simple's ok() routine. - -=cut - -sub ok ($;$) { - my($test, $name) = @_; - $Test->ok($test, $name); -} - -=item B - -=item B - - is ( $this, $that, $test_name ); - isnt( $this, $that, $test_name ); - -Similar to ok(), is() and isnt() compare their two arguments -with C and C respectively and use the result of that to -determine if the test succeeded or failed. So these: - - # Is the ultimate answer 42? - is( ultimate_answer(), 42, "Meaning of Life" ); - - # $foo isn't empty - isnt( $foo, '', "Got some foo" ); - -are similar to these: - - ok( ultimate_answer() eq 42, "Meaning of Life" ); - ok( $foo ne '', "Got some foo" ); - -(Mnemonic: "This is that." "This isn't that.") - -So why use these? They produce better diagnostics on failure. ok() -cannot know what you are testing for (beyond the name), but is() and -isnt() know what the test was and why it failed. For example this -test: - - my $foo = 'waffle'; my $bar = 'yarblokos'; - is( $foo, $bar, 'Is foo the same as bar?' ); - -Will produce something like this: - - not ok 17 - Is foo the same as bar? - # Failed test (foo.t at line 139) - # got: 'waffle' - # expected: 'yarblokos' - -So you can figure out what went wrong without rerunning the test. - -You are encouraged to use is() and isnt() over ok() where possible, -however do not be tempted to use them to find out if something is -true or false! - - # XXX BAD! - is( exists $brooklyn{tree}, 1, 'A tree grows in Brooklyn' ); - -This does not check if C is true, it checks if -it returns 1. Very different. Similar caveats exist for false and 0. -In these cases, use ok(). - - ok( exists $brooklyn{tree}, 'A tree grows in Brooklyn' ); - -For those grammatical pedants out there, there's an C -function which is an alias of isnt(). - -=cut - -sub is ($$;$) { - $Test->is_eq(@_); -} - -sub isnt ($$;$) { - $Test->isnt_eq(@_); -} - -*isn't = \&isnt; - - -=item B - - like( $this, qr/that/, $test_name ); - -Similar to ok(), like() matches $this against the regex C. - -So this: - - like($this, qr/that/, 'this is like that'); - -is similar to: - - ok( $this =~ /that/, 'this is like that'); - -(Mnemonic "This is like that".) - -The second argument is a regular expression. It may be given as a -regex reference (i.e. C) or (for better compatibility with older -perls) as a string that looks like a regex (alternative delimiters are -currently not supported): - - like( $this, '/that/', 'this is like that' ); - -Regex options may be placed on the end (C<'/that/i'>). - -Its advantages over ok() are similar to that of is() and isnt(). Better -diagnostics on failure. - -=cut - -sub like ($$;$) { - $Test->like(@_); -} - - -=item B - - unlike( $this, qr/that/, $test_name ); - -Works exactly as like(), only it checks if $this B match the -given pattern. - -=cut - -sub unlike ($$;$) { - $Test->unlike(@_); -} - - -=item B - - cmp_ok( $this, $op, $that, $test_name ); - -Halfway between ok() and is() lies cmp_ok(). This allows you to -compare two arguments using any binary perl operator. - - # ok( $this eq $that ); - cmp_ok( $this, 'eq', $that, 'this eq that' ); - - # ok( $this == $that ); - cmp_ok( $this, '==', $that, 'this == that' ); - - # ok( $this && $that ); - cmp_ok( $this, '&&', $that, 'this && that' ); - ...etc... - -Its advantage over ok() is when the test fails you'll know what $this -and $that were: - - not ok 1 - # Failed test (foo.t at line 12) - # '23' - # && - # undef - -It's also useful in those cases where you are comparing numbers and -is()'s use of C will interfere: - - cmp_ok( $big_hairy_number, '==', $another_big_hairy_number ); - -=cut - -sub cmp_ok($$$;$) { - $Test->cmp_ok(@_); -} - - -=item B - - can_ok($module, @methods); - can_ok($object, @methods); - -Checks to make sure the $module or $object can do these @methods -(works with functions, too). - - can_ok('Foo', qw(this that whatever)); - -is almost exactly like saying: - - ok( Foo->can('this') && - Foo->can('that') && - Foo->can('whatever') - ); - -only without all the typing and with a better interface. Handy for -quickly testing an interface. - -No matter how many @methods you check, a single can_ok() call counts -as one test. If you desire otherwise, use: - - foreach my $meth (@methods) { - can_ok('Foo', $meth); - } - -=cut - -sub can_ok ($@) { - my($proto, @methods) = @_; - my $class = ref $proto || $proto; - - unless( @methods ) { - my $ok = $Test->ok( 0, "$class->can(...)" ); - $Test->diag(' can_ok() called with no methods'); - return $ok; - } - - my @nok = (); - foreach my $method (@methods) { - local($!, $@); # don't interfere with caller's $@ - # eval sometimes resets $! - eval { $proto->can($method) } || push @nok, $method; - } - - my $name; - $name = @methods == 1 ? "$class->can('$methods[0]')" - : "$class->can(...)"; - - my $ok = $Test->ok( !@nok, $name ); - - $Test->diag(map " $class->can('$_') failed\n", @nok); - - return $ok; -} - -=item B - - isa_ok($object, $class, $object_name); - isa_ok($ref, $type, $ref_name); - -Checks to see if the given C<< $object->isa($class) >>. Also checks to make -sure the object was defined in the first place. Handy for this sort -of thing: - - my $obj = Some::Module->new; - isa_ok( $obj, 'Some::Module' ); - -where you'd otherwise have to write - - my $obj = Some::Module->new; - ok( defined $obj && $obj->isa('Some::Module') ); - -to safeguard against your test script blowing up. - -It works on references, too: - - isa_ok( $array_ref, 'ARRAY' ); - -The diagnostics of this test normally just refer to 'the object'. If -you'd like them to be more specific, you can supply an $object_name -(for example 'Test customer'). - -=cut - -sub isa_ok ($$;$) { - my($object, $class, $obj_name) = @_; - - my $diag; - $obj_name = 'The object' unless defined $obj_name; - my $name = "$obj_name isa $class"; - if( !defined $object ) { - $diag = "$obj_name isn't defined"; - } - elsif( !ref $object ) { - $diag = "$obj_name isn't a reference"; - } - else { - # We can't use UNIVERSAL::isa because we want to honor isa() overrides - local($@, $!); # eval sometimes resets $! - my $rslt = eval { $object->isa($class) }; - if( $@ ) { - if( $@ =~ /^Can't call method "isa" on unblessed reference/ ) { - if( !UNIVERSAL::isa($object, $class) ) { - my $ref = ref $object; - $diag = "$obj_name isn't a '$class' it's a '$ref'"; - } - } else { - die <isa on your object and got some weird error. -This should never happen. Please contact the author immediately. -Here's the error. -$@ -WHOA - } - } - elsif( !$rslt ) { - my $ref = ref $object; - $diag = "$obj_name isn't a '$class' it's a '$ref'"; - } - } - - - - my $ok; - if( $diag ) { - $ok = $Test->ok( 0, $name ); - $Test->diag(" $diag\n"); - } - else { - $ok = $Test->ok( 1, $name ); - } - - return $ok; -} - - -=item B - -=item B - - pass($test_name); - fail($test_name); - -Sometimes you just want to say that the tests have passed. Usually -the case is you've got some complicated condition that is difficult to -wedge into an ok(). In this case, you can simply use pass() (to -declare the test ok) or fail (for not ok). They are synonyms for -ok(1) and ok(0). - -Use these very, very, very sparingly. - -=cut - -sub pass (;$) { - $Test->ok(1, @_); -} - -sub fail (;$) { - $Test->ok(0, @_); -} - -=back - -=head2 Diagnostics - -If you pick the right test function, you'll usually get a good idea of -what went wrong when it failed. But sometimes it doesn't work out -that way. So here we have ways for you to write your own diagnostic -messages which are safer than just C. - -=over 4 - -=item B - - diag(@diagnostic_message); - -Prints a diagnostic message which is guaranteed not to interfere with -test output. Like C @diagnostic_message is simply concatinated -together. - -Handy for this sort of thing: - - ok( grep(/foo/, @users), "There's a foo user" ) or - diag("Since there's no foo, check that /etc/bar is set up right"); - -which would produce: - - not ok 42 - There's a foo user - # Failed test (foo.t at line 52) - # Since there's no foo, check that /etc/bar is set up right. - -You might remember C with the mnemonic C. - -All diag()s can be made silent by passing the "no_diag" option to -Test::More. C 1, 'no_diag'>. This is useful -if you have diagnostics for personal testing but then wish to make -them silent for release without commenting out each individual -statement. - -B The exact formatting of the diagnostic output is still -changing, but it is guaranteed that whatever you throw at it it won't -interfere with the test. - -=cut - -sub diag { - return unless $Show_Diag; - $Test->diag(@_); -} - - -=back - -=head2 Module tests - -You usually want to test if the module you're testing loads ok, rather -than just vomiting if its load fails. For such purposes we have -C and C. - -=over 4 - -=item B - - BEGIN { use_ok($module); } - BEGIN { use_ok($module, @imports); } - -These simply use the given $module and test to make sure the load -happened ok. It's recommended that you run use_ok() inside a BEGIN -block so its functions are exported at compile-time and prototypes are -properly honored. - -If @imports are given, they are passed through to the use. So this: - - BEGIN { use_ok('Some::Module', qw(foo bar)) } - -is like doing this: - - use Some::Module qw(foo bar); - -Version numbers can be checked like so: - - # Just like "use Some::Module 1.02" - BEGIN { use_ok('Some::Module', 1.02) } - -Don't try to do this: - - BEGIN { - use_ok('Some::Module'); - - ...some code that depends on the use... - ...happening at compile time... - } - -because the notion of "compile-time" is relative. Instead, you want: - - BEGIN { use_ok('Some::Module') } - BEGIN { ...some code that depends on the use... } - - -=cut - -sub use_ok ($;@) { - my($module, @imports) = @_; - @imports = () unless @imports; - - my($pack,$filename,$line) = caller; - - local($@,$!); # eval sometimes interferes with $! - - if( @imports == 1 and $imports[0] =~ /^\d+(?:\.\d+)?$/ ) { - # probably a version check. Perl needs to see the bare number - # for it to work with non-Exporter based modules. - eval <ok( !$@, "use $module;" ); - - unless( $ok ) { - chomp $@; - $@ =~ s{^BEGIN failed--compilation aborted at .*$} - {BEGIN failed--compilation aborted at $filename line $line.}m; - $Test->diag(< - - require_ok($module); - require_ok($file); - -Like use_ok(), except it requires the $module or $file. - -=cut - -sub require_ok ($) { - my($module) = shift; - - my $pack = caller; - - # Try to deterine if we've been given a module name or file. - # Module names must be barewords, files not. - $module = qq['$module'] unless _is_module_name($module); - - local($!, $@); # eval sometimes interferes with $! - eval <ok( !$@, "require $module;" ); - - unless( $ok ) { - chomp $@; - $Test->diag(<. - -The way Test::More handles this is with a named block. Basically, a -block of tests which can be skipped over or made todo. It's best if I -just show you... - -=over 4 - -=item B - - SKIP: { - skip $why, $how_many if $condition; - - ...normal testing code goes here... - } - -This declares a block of tests that might be skipped, $how_many tests -there are, $why and under what $condition to skip them. An example is -the easiest way to illustrate: - - SKIP: { - eval { require HTML::Lint }; - - skip "HTML::Lint not installed", 2 if $@; - - my $lint = new HTML::Lint; - isa_ok( $lint, "HTML::Lint" ); - - $lint->parse( $html ); - is( $lint->errors, 0, "No errors found in HTML" ); - } - -If the user does not have HTML::Lint installed, the whole block of -code I. Test::More will output special ok's -which Test::Harness interprets as skipped, but passing, tests. - -It's important that $how_many accurately reflects the number of tests -in the SKIP block so the # of tests run will match up with your plan. -If your plan is C $how_many is optional and will default to 1. - -It's perfectly safe to nest SKIP blocks. Each SKIP block must have -the label C, or Test::More can't work its magic. - -You don't skip tests which are failing because there's a bug in your -program, or for which you don't yet have code written. For that you -use TODO. Read on. - -=cut - -#'# -sub skip { - my($why, $how_many) = @_; - - unless( defined $how_many ) { - # $how_many can only be avoided when no_plan is in use. - _carp "skip() needs to know \$how_many tests are in the block" - unless $Test->has_plan eq 'no_plan'; - $how_many = 1; - } - - for( 1..$how_many ) { - $Test->skip($why); - } - - local $^W = 0; - last SKIP; -} - - -=item B - - TODO: { - local $TODO = $why if $condition; - - ...normal testing code goes here... - } - -Declares a block of tests you expect to fail and $why. Perhaps it's -because you haven't fixed a bug or haven't finished a new feature: - - TODO: { - local $TODO = "URI::Geller not finished"; - - my $card = "Eight of clubs"; - is( URI::Geller->your_card, $card, 'Is THIS your card?' ); - - my $spoon; - URI::Geller->bend_spoon; - is( $spoon, 'bent', "Spoon bending, that's original" ); - } - -With a todo block, the tests inside are expected to fail. Test::More -will run the tests normally, but print out special flags indicating -they are "todo". Test::Harness will interpret failures as being ok. -Should anything succeed, it will report it as an unexpected success. -You then know the thing you had todo is done and can remove the -TODO flag. - -The nice part about todo tests, as opposed to simply commenting out a -block of tests, is it's like having a programmatic todo list. You know -how much work is left to be done, you're aware of what bugs there are, -and you'll know immediately when they're fixed. - -Once a todo test starts succeeding, simply move it outside the block. -When the block is empty, delete it. - -B: TODO tests require a Test::Harness upgrade else it will -treat it as a normal failure. See L) - - -=item B - - TODO: { - todo_skip $why, $how_many if $condition; - - ...normal testing code... - } - -With todo tests, it's best to have the tests actually run. That way -you'll know when they start passing. Sometimes this isn't possible. -Often a failing test will cause the whole program to die or hang, even -inside an C with and using C. In these extreme -cases you have no choice but to skip over the broken tests entirely. - -The syntax and behavior is similar to a C except the -tests will be marked as failing but todo. Test::Harness will -interpret them as passing. - -=cut - -sub todo_skip { - my($why, $how_many) = @_; - - unless( defined $how_many ) { - # $how_many can only be avoided when no_plan is in use. - _carp "todo_skip() needs to know \$how_many tests are in the block" - unless $Test->has_plan eq 'no_plan'; - $how_many = 1; - } - - for( 1..$how_many ) { - $Test->todo_skip($why); - } - - local $^W = 0; - last TODO; -} - -=item When do I use SKIP vs. TODO? - -B, use SKIP. -This includes optional modules that aren't installed, running under -an OS that doesn't have some feature (like fork() or symlinks), or maybe -you need an Internet connection and one isn't available. - -B, use TODO. This -is for any code you haven't written yet, or bugs you have yet to fix, -but want to put tests in your testing script (always a good idea). - - -=back - -=head2 Comparison functions - -Not everything is a simple eq check or regex. There are times you -need to see if two arrays are equivalent, for instance. For these -instances, Test::More provides a handful of useful functions. - -B I'm not quite sure what will happen with filehandles. - -=over 4 - -=item B - - is_deeply( $this, $that, $test_name ); - -Similar to is(), except that if $this and $that are hash or array -references, it does a deep comparison walking each data structure to -see if they are equivalent. If the two structures are different, it -will display the place where they start differing. - -Test::Differences and Test::Deep provide more in-depth functionality -along these lines. - -=cut - -use vars qw(@Data_Stack %Refs_Seen); -my $DNE = bless [], 'Does::Not::Exist'; -sub is_deeply { - unless( @_ == 2 or @_ == 3 ) { - my $msg = <is_eq($this, $that, $name); - } - else { - local @Data_Stack = (); - local %Refs_Seen = (); - if( _deep_check($this, $that) ) { - $ok = $Test->ok(1, $name); - } - else { - $ok = $Test->ok(0, $name); - $ok = $Test->diag(_format_stack(@Data_Stack)); - } - } - - return $ok; -} - -sub _format_stack { - my(@Stack) = @_; - - my $var = '$FOO'; - my $did_arrow = 0; - foreach my $entry (@Stack) { - my $type = $entry->{type} || ''; - my $idx = $entry->{'idx'}; - if( $type eq 'HASH' ) { - $var .= "->" unless $did_arrow++; - $var .= "{$idx}"; - } - elsif( $type eq 'ARRAY' ) { - $var .= "->" unless $did_arrow++; - $var .= "[$idx]"; - } - elsif( $type eq 'REF' ) { - $var = "\${$var}"; - } - } - - my @vals = @{$Stack[-1]{vals}}[0,1]; - my @vars = (); - ($vars[0] = $var) =~ s/\$FOO/ \$got/; - ($vars[1] = $var) =~ s/\$FOO/\$expected/; - - my $out = "Structures begin differing at:\n"; - foreach my $idx (0..$#vals) { - my $val = $vals[$idx]; - $vals[$idx] = !defined $val ? 'undef' : - $val eq $DNE ? "Does not exist" - : "'$val'"; - } - - $out .= "$vars[0] = $vals[0]\n"; - $out .= "$vars[1] = $vals[1]\n"; - - $out =~ s/^/ /msg; - return $out; -} - - -sub _type { - my $thing = shift; - - return '' if !ref $thing; - - for my $type (qw(ARRAY HASH REF SCALAR GLOB Regexp)) { - return $type if UNIVERSAL::isa($thing, $type); - } - - return ''; -} - - -=item B - - eq_array(\@this, \@that); - -Checks if two arrays are equivalent. This is a deep check, so -multi-level structures are handled correctly. - -=cut - -#'# -sub eq_array { - local @Data_Stack; - local %Refs_Seen; - _eq_array(@_); -} - -sub _eq_array { - my($a1, $a2) = @_; - - if( grep !_type($_) eq 'ARRAY', $a1, $a2 ) { - warn "eq_array passed a non-array ref"; - return 0; - } - - return 1 if $a1 eq $a2; - - if($Refs_Seen{$a1}) { - return $Refs_Seen{$a1} eq $a2; - } - else { - $Refs_Seen{$a1} = "$a2"; - } - - my $ok = 1; - my $max = $#$a1 > $#$a2 ? $#$a1 : $#$a2; - for (0..$max) { - my $e1 = $_ > $#$a1 ? $DNE : $a1->[$_]; - my $e2 = $_ > $#$a2 ? $DNE : $a2->[$_]; - - push @Data_Stack, { type => 'ARRAY', idx => $_, vals => [$e1, $e2] }; - $ok = _deep_check($e1,$e2); - pop @Data_Stack if $ok; - - last unless $ok; - } - - return $ok; -} - -sub _deep_check { - my($e1, $e2) = @_; - my $ok = 0; - - { - # Quiet uninitialized value warnings when comparing undefs. - local $^W = 0; - - $Test->_unoverload(\$e1, \$e2); - - # Either they're both references or both not. - my $same_ref = !(!ref $e1 xor !ref $e2); - - if( defined $e1 xor defined $e2 ) { - $ok = 0; - } - elsif ( $e1 == $DNE xor $e2 == $DNE ) { - $ok = 0; - } - elsif ( $same_ref and ($e1 eq $e2) ) { - $ok = 1; - } - else { - my $type = _type($e1); - $type = '' unless _type($e2) eq $type; - - if( !$type ) { - push @Data_Stack, { vals => [$e1, $e2] }; - $ok = 0; - } - elsif( $type eq 'ARRAY' ) { - $ok = _eq_array($e1, $e2); - } - elsif( $type eq 'HASH' ) { - $ok = _eq_hash($e1, $e2); - } - elsif( $type eq 'REF' ) { - push @Data_Stack, { type => 'REF', vals => [$e1, $e2] }; - $ok = _deep_check($$e1, $$e2); - pop @Data_Stack if $ok; - } - elsif( $type eq 'SCALAR' ) { - push @Data_Stack, { type => 'REF', vals => [$e1, $e2] }; - $ok = _deep_check($$e1, $$e2); - pop @Data_Stack if $ok; - } - } - } - - return $ok; -} - - -=item B - - eq_hash(\%this, \%that); - -Determines if the two hashes contain the same keys and values. This -is a deep check. - -=cut - -sub eq_hash { - local @Data_Stack; - local %Refs_Seen; - return _eq_hash(@_); -} - -sub _eq_hash { - my($a1, $a2) = @_; - - if( grep !_type($_) eq 'HASH', $a1, $a2 ) { - warn "eq_hash passed a non-hash ref"; - return 0; - } - - return 1 if $a1 eq $a2; - - if( $Refs_Seen{$a1} ) { - return $Refs_Seen{$a1} eq $a2; - } - else { - $Refs_Seen{$a1} = "$a2"; - } - - my $ok = 1; - my $bigger = keys %$a1 > keys %$a2 ? $a1 : $a2; - foreach my $k (keys %$bigger) { - my $e1 = exists $a1->{$k} ? $a1->{$k} : $DNE; - my $e2 = exists $a2->{$k} ? $a2->{$k} : $DNE; - - push @Data_Stack, { type => 'HASH', idx => $k, vals => [$e1, $e2] }; - $ok = _deep_check($e1, $e2); - pop @Data_Stack if $ok; - - last unless $ok; - } - - return $ok; -} - -=item B - - eq_set(\@this, \@that); - -Similar to eq_array(), except the order of the elements is B -important. This is a deep check, but the irrelevancy of order only -applies to the top level. - -B By historical accident, this is not a true set comparision. -While the order of elements does not matter, duplicate elements do. - -=cut - -sub eq_set { - my($a1, $a2) = @_; - return 0 unless @$a1 == @$a2; - - # There's faster ways to do this, but this is easiest. - local $^W = 0; - - # We must make sure that references are treated neutrally. It really - # doesn't matter how we sort them, as long as both arrays are sorted - # with the same algorithm. - # Have to inline the sort routine due to a threading/sort bug. - # See [rt.cpan.org 6782] - return eq_array( - [sort { ref $a ? -1 : ref $b ? 1 : $a cmp $b } @$a1], - [sort { ref $a ? -1 : ref $b ? 1 : $a cmp $b } @$a2] - ); -} - -=back - - -=head2 Extending and Embedding Test::More - -Sometimes the Test::More interface isn't quite enough. Fortunately, -Test::More is built on top of Test::Builder which provides a single, -unified backend for any test library to use. This means two test -libraries which both use Test::Builder B. - -If you simply want to do a little tweaking of how the tests behave, -you can access the underlying Test::Builder object like so: - -=over 4 - -=item B - - my $test_builder = Test::More->builder; - -Returns the Test::Builder object underlying Test::More for you to play -with. - -=cut - -sub builder { - return Test::Builder->new; -} - -=back - - -=head1 EXIT CODES - -If all your tests passed, Test::Builder will exit with zero (which is -normal). If anything failed it will exit with how many failed. If -you run less (or more) tests than you planned, the missing (or extras) -will be considered failures. If no tests were ever run Test::Builder -will throw a warning and exit with 255. If the test died, even after -having successfully completed all its tests, it will still be -considered a failure and will exit with 255. - -So the exit codes are... - - 0 all tests successful - 255 test died - any other number how many failed (including missing or extras) - -If you fail more than 254 tests, it will be reported as 254. - - -=head1 CAVEATS and NOTES - -=over 4 - -=item Backwards compatibility - -Test::More works with Perls as old as 5.004_05. - - -=item Overloaded objects - -String overloaded objects are compared B. This prevents -Test::More from piercing an object's interface allowing better blackbox -testing. So if a function starts returning overloaded objects instead of -bare strings your tests won't notice the difference. This is good. - -However, it does mean that functions like is_deeply() cannot be used to -test the internals of string overloaded objects. In this case I would -suggest Test::Deep which contains more flexible testing functions for -complex data structures. - - -=item Threads - -Test::More will only be aware of threads if "use threads" has been done -I Test::More is loaded. This is ok: - - use threads; - use Test::More; - -This may cause problems: - - use Test::More - use threads; - - -=item Test::Harness upgrade - -no_plan and todo depend on new Test::Harness features and fixes. If -you're going to distribute tests that use no_plan or todo your -end-users will have to upgrade Test::Harness to the latest one on -CPAN. If you avoid no_plan and TODO tests, the stock Test::Harness -will work fine. - -Installing Test::More should also upgrade Test::Harness. - -=back - - -=head1 HISTORY - -This is a case of convergent evolution with Joshua Pritikin's Test -module. I was largely unaware of its existence when I'd first -written my own ok() routines. This module exists because I can't -figure out how to easily wedge test names into Test's interface (along -with a few other problems). - -The goal here is to have a testing utility that's simple to learn, -quick to use and difficult to trip yourself up with while still -providing more flexibility than the existing Test.pm. As such, the -names of the most common routines are kept tiny, special cases and -magic side-effects are kept to a minimum. WYSIWYG. - - -=head1 SEE ALSO - -L if all this confuses you and you just want to write -some tests. You can upgrade to Test::More later (it's forward -compatible). - -L is the old testing module. Its main benefit is that it has -been distributed with Perl since 5.004_05. - -L for details on how your test results are interpreted -by Perl. - -L for more ways to test complex data structures. -And it plays well with Test::More. - -L is like XUnit but more perlish. - -L gives you more powerful complex data structure testing. - -L is XUnit style testing. - -L shows the idea of embedded testing. - -L installs a whole bunch of useful test modules. - - -=head1 AUTHORS - -Michael G Schwern Eschwern@pobox.comE with much inspiration -from Joshua Pritikin's Test module and lots of help from Barrie -Slaymaker, Tony Bowden, blackstar.co.uk, chromatic, Fergal Daly and -the perl-qa gang. - - -=head1 BUGS - -See F to report and view bugs. - - -=head1 COPYRIGHT - -Copyright 2001, 2002, 2004 by Michael G Schwern Eschwern@pobox.comE. - -This program is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. - -See F - -=cut - -1; From 084425335f0c637fa5d31fa880d193995effb324 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 8 Dec 2011 22:34:08 +0000 Subject: [PATCH 110/147] Fix bug which could result in %rename not taking effect for derived classes. We used to modify the hash table that we iterated on in Swig_name_object_inherit() and this could, and sometimes did, change the iteration order in such way that not all entries we were looking for could be found. In practice this means that sometimes the methods renamed or ignored in the base class could be mysteriously not renamed or ignored in a derived class. Fix this by avoiding modifying the hash table in place and using another temporary hash table instead. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12865 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Swig/naming.c | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 8105a0fe6..3b283bd75 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-12-08: vadz + Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes + (they could be sometimes mysteriously not renamed or ignored there before). + 2011-12-03: klickvebrot [D] Fix exception glue code for newer DMD 2 versions. [D] Do not default to 32 bit glue code for DMD anymore. diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 539442bac..a35a92ac7 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -565,6 +565,7 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) { Iterator ki; + Hash *derh; String *bprefix; String *dprefix; char *cbprefix; @@ -573,6 +574,9 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) { if (!namehash) return; + /* Temporary hash holding all the entries we add while we iterate over + namehash itself as we can't modify the latter while iterating over it. */ + derh = NULL; bprefix = NewStringf("%s::", base); dprefix = NewStringf("%s::", derived); cbprefix = Char(bprefix); @@ -580,13 +584,19 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) { for (ki = First(namehash); ki.key; ki = Next(ki)) { char *k = Char(ki.key); if (strncmp(k, cbprefix, plen) == 0) { + /* Copy, adjusting name, this element to the derived hash. */ Iterator oi; String *nkey = NewStringf("%s%s", dprefix, k + plen); Hash *n = ki.item; - Hash *newh = Getattr(namehash, nkey); + Hash *newh; + + if (!derh) + derh = NewHash(); + + newh = Getattr(derh, nkey); if (!newh) { newh = NewHash(); - Setattr(namehash, nkey, newh); + Setattr(derh, nkey, newh); Delete(newh); } for (oi = First(n); oi.key; oi = Next(oi)) { @@ -599,8 +609,17 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) { Delete(nkey); } } + + /* Merge the contents of derived hash into the main hash. */ + if (derh) { + for (ki = First(derh); ki.key; ki = Next(ki)) { + Setattr(namehash, ki.key, ki.item); + } + } + Delete(bprefix); Delete(dprefix); + Delete(derh); } /* ----------------------------------------------------------------------------- From 6d40bb0db81b74024096e3eb241ef4f84bdb6c7e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 10 Dec 2011 14:54:31 +0000 Subject: [PATCH 111/147] Add Android examples git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12866 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/android/check.list | 3 + Examples/android/class/AndroidManifest.xml | 15 +++ Examples/android/class/Makefile | 29 +++++ Examples/android/class/ant.properties | 17 +++ Examples/android/class/build.xml | 85 ++++++++++++++ Examples/android/class/jni/Android.mk | 10 ++ Examples/android/class/jni/example.cpp | 28 +++++ Examples/android/class/jni/example.h | 34 ++++++ Examples/android/class/jni/example.i | 9 ++ Examples/android/class/local.properties | 10 ++ Examples/android/class/proguard.cfg | 40 +++++++ Examples/android/class/project.properties | 11 ++ Examples/android/class/res/layout/main.xml | 25 +++++ Examples/android/class/res/values/strings.xml | 4 + .../src/org/swig/classexample/SwigClass.java | 106 ++++++++++++++++++ Examples/android/simple/AndroidManifest.xml | 15 +++ Examples/android/simple/Makefile | 29 +++++ Examples/android/simple/ant.properties | 17 +++ Examples/android/simple/build.xml | 85 ++++++++++++++ Examples/android/simple/jni/Android.mk | 9 ++ Examples/android/simple/jni/example.c | 17 +++ Examples/android/simple/jni/example.i | 7 ++ Examples/android/simple/local.properties | 10 ++ Examples/android/simple/proguard.cfg | 40 +++++++ Examples/android/simple/project.properties | 11 ++ Examples/android/simple/res/layout/main.xml | 25 +++++ .../android/simple/res/values/strings.xml | 4 + .../src/org/swig/simple/SwigSimple.java | 75 +++++++++++++ Makefile.in | 3 + configure.in | 53 +++++++++ 30 files changed, 826 insertions(+) create mode 100644 Examples/android/check.list create mode 100644 Examples/android/class/AndroidManifest.xml create mode 100644 Examples/android/class/Makefile create mode 100644 Examples/android/class/ant.properties create mode 100644 Examples/android/class/build.xml create mode 100644 Examples/android/class/jni/Android.mk create mode 100644 Examples/android/class/jni/example.cpp create mode 100644 Examples/android/class/jni/example.h create mode 100644 Examples/android/class/jni/example.i create mode 100644 Examples/android/class/local.properties create mode 100644 Examples/android/class/proguard.cfg create mode 100644 Examples/android/class/project.properties create mode 100644 Examples/android/class/res/layout/main.xml create mode 100644 Examples/android/class/res/values/strings.xml create mode 100644 Examples/android/class/src/org/swig/classexample/SwigClass.java create mode 100644 Examples/android/simple/AndroidManifest.xml create mode 100644 Examples/android/simple/Makefile create mode 100644 Examples/android/simple/ant.properties create mode 100644 Examples/android/simple/build.xml create mode 100644 Examples/android/simple/jni/Android.mk create mode 100644 Examples/android/simple/jni/example.c create mode 100644 Examples/android/simple/jni/example.i create mode 100644 Examples/android/simple/local.properties create mode 100644 Examples/android/simple/proguard.cfg create mode 100644 Examples/android/simple/project.properties create mode 100644 Examples/android/simple/res/layout/main.xml create mode 100644 Examples/android/simple/res/values/strings.xml create mode 100644 Examples/android/simple/src/org/swig/simple/SwigSimple.java diff --git a/Examples/android/check.list b/Examples/android/check.list new file mode 100644 index 000000000..69d56a4f6 --- /dev/null +++ b/Examples/android/check.list @@ -0,0 +1,3 @@ +# see top-level Makefile.in +class +simple diff --git a/Examples/android/class/AndroidManifest.xml b/Examples/android/class/AndroidManifest.xml new file mode 100644 index 000000000..45c1fb1c7 --- /dev/null +++ b/Examples/android/class/AndroidManifest.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/Examples/android/class/Makefile b/Examples/android/class/Makefile new file mode 100644 index 000000000..7de95f559 --- /dev/null +++ b/Examples/android/class/Makefile @@ -0,0 +1,29 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +TARGET = example +INTERFACE = example.i +PACKAGEDIR = src/org/swig +PACKAGENAME= org.swig.classexample +SWIGOPT = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/classexample +PROJECTNAME= SwigClass +TARGETID = 1 + +all:: android + +android:: + android update project --target $(TARGETID) --name $(PROJECTNAME) --path . + $(SWIG) -c++ -java $(SWIGOPT) -o jni/$(TARGET)_wrap.cpp jni/$(INTERFACE) + ndk-build + ant debug + +install:: + -adb uninstall $(PACKAGENAME) + adb install bin/$(PROJECTNAME)-debug.apk + +clean:: + ant clean + rm -f jni/$(TARGET)_wrap.cpp + rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` + + +check: all diff --git a/Examples/android/class/ant.properties b/Examples/android/class/ant.properties new file mode 100644 index 000000000..ee52d86d9 --- /dev/null +++ b/Examples/android/class/ant.properties @@ -0,0 +1,17 @@ +# This file is used to override default values used by the Ant build system. +# +# This file must be checked in Version Control Systems, as it is +# integral to the build system of your project. + +# This file is only used by the Ant script. + +# You can use this to override default values such as +# 'source.dir' for the location of your java source folder and +# 'out.dir' for the location of your output folder. + +# You can also use it define how the release builds are signed by declaring +# the following properties: +# 'key.store' for the location of your keystore and +# 'key.alias' for the name of the key to use. +# The password will be asked during the build when you use the 'release' target. + diff --git a/Examples/android/class/build.xml b/Examples/android/class/build.xml new file mode 100644 index 000000000..fe06943a9 --- /dev/null +++ b/Examples/android/class/build.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/android/class/jni/Android.mk b/Examples/android/class/jni/Android.mk new file mode 100644 index 000000000..25d42b541 --- /dev/null +++ b/Examples/android/class/jni/Android.mk @@ -0,0 +1,10 @@ +# File: Android.mk +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := example +LOCAL_SRC_FILES := example_wrap.cpp example.cpp +LOCAL_CFLAGS := -frtti + +include $(BUILD_SHARED_LIBRARY) diff --git a/Examples/android/class/jni/example.cpp b/Examples/android/class/jni/example.cpp new file mode 100644 index 000000000..d59cc7c32 --- /dev/null +++ b/Examples/android/class/jni/example.cpp @@ -0,0 +1,28 @@ +/* File : example.cpp */ + +#include "example.h" +#define M_PI 3.14159265358979323846 + +/* Move the shape to a new location */ +void Shape::move(double dx, double dy) { + x += dx; + y += dy; +} + +int Shape::nshapes = 0; + +double Circle::area(void) { + return M_PI*radius*radius; +} + +double Circle::perimeter(void) { + return 2*M_PI*radius; +} + +double Square::area(void) { + return width*width; +} + +double Square::perimeter(void) { + return 4*width; +} diff --git a/Examples/android/class/jni/example.h b/Examples/android/class/jni/example.h new file mode 100644 index 000000000..64b7684fa --- /dev/null +++ b/Examples/android/class/jni/example.h @@ -0,0 +1,34 @@ +/* File : example.h */ + +class Shape { +public: + Shape() { + nshapes++; + } + virtual ~Shape() { + nshapes--; + }; + double x, y; + void move(double dx, double dy); + virtual double area(void) = 0; + virtual double perimeter(void) = 0; + static int nshapes; +}; + +class Circle : public Shape { +private: + double radius; +public: + Circle(double r) : radius(r) { }; + virtual double area(void); + virtual double perimeter(void); +}; + +class Square : public Shape { +private: + double width; +public: + Square(double w) : width(w) { }; + virtual double area(void); + virtual double perimeter(void); +}; diff --git a/Examples/android/class/jni/example.i b/Examples/android/class/jni/example.i new file mode 100644 index 000000000..fbdf7249f --- /dev/null +++ b/Examples/android/class/jni/example.i @@ -0,0 +1,9 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" diff --git a/Examples/android/class/local.properties b/Examples/android/class/local.properties new file mode 100644 index 000000000..14b8d63b4 --- /dev/null +++ b/Examples/android/class/local.properties @@ -0,0 +1,10 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must *NOT* be checked in Version Control Systems, +# as it contains information specific to your local configuration. + +# location of the SDK. This is only used by Ant +# For customization when using a Version Control System, please read the +# header note. +sdk.dir=/home/william/android/android-sdk-linux_x86 diff --git a/Examples/android/class/proguard.cfg b/Examples/android/class/proguard.cfg new file mode 100644 index 000000000..b1cdf17b5 --- /dev/null +++ b/Examples/android/class/proguard.cfg @@ -0,0 +1,40 @@ +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontpreverify +-verbose +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* + +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class * extends android.app.backup.BackupAgentHelper +-keep public class * extends android.preference.Preference +-keep public class com.android.vending.licensing.ILicensingService + +-keepclasseswithmembernames class * { + native ; +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet, int); +} + +-keepclassmembers class * extends android.app.Activity { + public void *(android.view.View); +} + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} diff --git a/Examples/android/class/project.properties b/Examples/android/class/project.properties new file mode 100644 index 000000000..ea89160e0 --- /dev/null +++ b/Examples/android/class/project.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-8 diff --git a/Examples/android/class/res/layout/main.xml b/Examples/android/class/res/layout/main.xml new file mode 100644 index 000000000..d4e5d7fe8 --- /dev/null +++ b/Examples/android/class/res/layout/main.xml @@ -0,0 +1,25 @@ + + +
      -

      18.7.5 Turning wrapped classes into partial classes

      +

      19.8.5 Turning wrapped classes into partial classes

      @@ -2428,7 +2430,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.7.6 Extending proxy classes with additional C# code

      +

      19.8.6 Extending proxy classes with additional C# code

      @@ -2467,7 +2469,7 @@ public class ExtendMe : IDisposable { -

      18.7.7 Underlying type for enums

      +

      19.8.7 Underlying type for enums

      diff --git a/Doc/Manual/Chicken.html b/Doc/Manual/Chicken.html index 006b648d6..4e43b9b90 100644 --- a/Doc/Manual/Chicken.html +++ b/Doc/Manual/Chicken.html @@ -8,7 +8,7 @@ -

      19 SWIG and Chicken

      +

      20 SWIG and Chicken

        @@ -72,7 +72,7 @@

        -

        19.1 Preliminaries

        +

        20.1 Preliminaries

        @@ -89,7 +89,7 @@ directory for the basic steps to run SWIG CHICKEN.

        -

        19.1.1 Running SWIG in C mode

        +

        20.1.1 Running SWIG in C mode

        @@ -122,7 +122,7 @@ object files and linked into your project.

        -

        19.1.2 Running SWIG in C++ mode

        +

        20.1.2 Running SWIG in C++ mode

        @@ -151,10 +151,10 @@ object files and linked into your project.

        -

        19.2 Code Generation

        +

        20.2 Code Generation

        -

        19.2.1 Naming Conventions

        +

        20.2.1 Naming Conventions

        @@ -170,7 +170,7 @@ %rename SWIG directive in the SWIG interface file.

        -

        19.2.2 Modules

        +

        20.2.2 Modules

        @@ -192,7 +192,7 @@ (uses modulename)) CHICKEN Scheme form.

        -

        19.2.3 Constants and Variables

        +

        20.2.3 Constants and Variables

        @@ -229,7 +229,7 @@ for info on how to apply the %feature.

        -

        19.2.4 Functions

        +

        20.2.4 Functions

        @@ -248,7 +248,7 @@ parameters). The return values can then be accessed with (call-with-values).

        -

        19.2.5 Exceptions

        +

        20.2.5 Exceptions

        The SWIG chicken module has support for exceptions thrown from @@ -290,7 +290,7 @@

      -

      19.3 TinyCLOS

      +

      20.3 TinyCLOS

      @@ -333,7 +333,7 @@

      -

      19.4 Linkage

      +

      20.4 Linkage

      @@ -354,7 +354,7 @@

      -

      19.4.1 Static binary or shared library linked at compile time

      +

      20.4.1 Static binary or shared library linked at compile time

      We can easily use csc to build a static binary.

      @@ -395,7 +395,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

      +

      20.4.2 Building chicken extension libraries

      Building a shared library like in the above section only works if the library @@ -453,7 +453,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

      +

      20.4.3 Linking multiple SWIG modules with TinyCLOS

      Linking together multiple modules that share type information using the %import @@ -477,7 +477,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

      +

      20.5 Typemaps

      @@ -486,7 +486,7 @@ all the modules.

      Lib/chicken/chicken.swg.

      -

      19.6 Pointers

      +

      20.6 Pointers

      @@ -519,7 +519,7 @@ all the modules.

      type. flags is either zero or SWIG_POINTER_DISOWN (see below).

      -

      19.6.1 Garbage collection

      +

      20.6.1 Garbage collection

      If the owner flag passed to SWIG_NewPointerObj is 1, NewPointerObj will add a @@ -550,7 +550,7 @@ all the modules.

      must be called manually.

      -

      19.7 Unsupported features and known problems

      +

      20.7 Unsupported features and known problems

      -

      19.7.1 TinyCLOS problems with Chicken version <= 1.92

      +

      20.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 ea6e75cba..7cae25e7f 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -397,6 +397,7 @@

    • Typemaps for multiple target languages
    • Optimal code generation when returning by value
    • Multi-argument typemaps +
    • Typemap warnings
    • Typemap fragments +
    • Multiples modules
    • C# Typemap examples -
    • Examples +
    • Java Examples
    -

    24 SWIG and Common Lisp

    +

    25 SWIG and Common Lisp

    @@ -974,7 +992,7 @@
    -

    25 SWIG and Lua

    +

    26 SWIG and Lua

    @@ -1001,38 +1019,39 @@
  • C++ overloaded functions
  • C++ operators
  • Class extension with %extend -
  • C++ templates -
  • C++ Smart Pointers -
  • C++ Exceptions +
  • Using %newobject to release memory +
  • C++ templates +
  • C++ Smart Pointers +
  • C++ Exceptions -
  • Typemaps +
  • Typemaps -
  • Writing typemaps +
  • Writing typemaps -
  • Customization of your Bindings +
  • Customization of your Bindings -
  • Details on the Lua binding +
  • Details on the Lua binding -

    26 SWIG and Modula-3

    +

    27 SWIG and Modula-3

    @@ -1070,7 +1089,7 @@
    -

    27 SWIG and MzScheme/Racket

    +

    28 SWIG and MzScheme/Racket

    @@ -1082,7 +1101,7 @@
    -

    28 SWIG and Ocaml

    +

    29 SWIG and Ocaml

    @@ -1133,7 +1152,7 @@
    -

    29 SWIG and Octave

    +

    30 SWIG and Octave

    @@ -1169,7 +1188,7 @@
    -

    30 SWIG and Perl5

    +

    31 SWIG and Perl5

    @@ -1236,7 +1255,7 @@
    -

    31 SWIG and PHP

    +

    32 SWIG and PHP

    @@ -1276,7 +1295,7 @@
    -

    32 SWIG and Pike

    +

    33 SWIG and Pike

    @@ -1300,7 +1319,7 @@
    -

    33 SWIG and Python

    +

    34 SWIG and Python

    @@ -1410,7 +1429,7 @@
    -

    34 SWIG and R

    +

    35 SWIG and R

    @@ -1426,7 +1445,7 @@
    -

    35 SWIG and Ruby

    +

    36 SWIG and Ruby

    @@ -1560,7 +1579,7 @@
    -

    36 SWIG and Tcl

    +

    37 SWIG and Tcl

    @@ -1626,7 +1645,7 @@
    -

    37 Extending SWIG to support new languages

    +

    38 Extending SWIG to support new languages

    diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index b58ff89e6..43fa69196 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -6,7 +6,7 @@ -

    20 SWIG and D

    +

    21 SWIG and D

      @@ -41,7 +41,7 @@ -

      20.1 Introduction

      +

      21.1 Introduction

      From the D Programming Language web site: D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code. As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?

      @@ -53,7 +53,7 @@

      To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on C# (and also on Java, since the C# module was in turn forked from it).

      -

      20.2 Command line invocation

      +

      21.2 Command line invocation

      To activate the D module, pass the -d option to SWIG at the command line. The same standard command line switches as with any other language module are available, plus the following D specific ones:

      @@ -83,10 +83,10 @@ -

      20.3 Typemaps

      +

      21.3 Typemaps

      -

      20.3.1 C# <-> D name comparison

      +

      21.3.1 C# <-> D name comparison

      If you already know the SWIG C# module, you might find the following name comparison table useful:

      @@ -112,7 +112,7 @@
    -

    20.3.2 ctype, imtype, dtype

    +

    21.3.2 ctype, imtype, dtype

    Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.

    @@ -120,7 +120,7 @@

    The ctype typemap is used to determine the types to use in the C wrapper functions. The types from the imtype typemap are used in the extern(C) declarations of these functions in the intermediary D module. The dtype typemap contains the D types used in the D proxy module/class.

    -

    20.3.3 in, out, directorin, directorout

    +

    21.3.3 in, out, directorin, directorout

    Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).

    @@ -130,7 +130,7 @@

    The directorin typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by directorout (see below).

    -

    20.3.4 din, dout, ddirectorin, ddirectorout

    +

    21.3.4 din, dout, ddirectorin, ddirectorout

    Typemaps for code generation in D proxy and type wrapper classes.

    @@ -157,13 +157,13 @@ dtype DClass.method(dtype a)
    -

    20.3.5 typecheck typemaps

    +

    21.3.5 typecheck typemaps

    Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).

    -

    20.3.6 Code injection typemaps

    +

    21.3.6 Code injection typemaps

    These typemaps are used for generating the skeleton of proxy classes for C++ types.

    @@ -175,7 +175,7 @@

    dconstructor, ddestructor, ddispose and ddispose_derived are used to generate the class constructor, destructor and dispose() method, respectively. The auxiliary code for handling the pointer to the C++ object is stored in dbody and dbody_derived. You can override them for specific types.

    -

    20.3.7 Special variable macros

    +

    21.3.7 Special variable macros

    The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation, for example $1, $input, $result etc.

    @@ -295,7 +295,7 @@ $importtype(AnotherInterface) -

    20.4 %features

    +

    21.4 %features

    The D module defines a number of directives which modify the SWIG features set globally or for a specific declaration:

    @@ -325,7 +325,7 @@ struct A { -

    20.5 Pragmas

    +

    21.5 Pragmas

    There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:

    @@ -364,7 +364,7 @@ struct A { -

    20.6 D Exceptions

    +

    21.6 D Exceptions

    Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.

    @@ -374,7 +374,7 @@ struct A {

    As this feature is implemented in exactly the same way it is for C#, please see the C# documentation for a more detailed explanation.

    -

    20.7 D Directors

    +

    21.7 D Directors

    When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.

    @@ -383,16 +383,16 @@ struct A {

    -

    20.8 Other features

    +

    21.8 Other features

    -

    20.8.1 Extended namespace support (nspace)

    +

    21.8.1 Extended namespace support (nspace)

    By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the nspace feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, free variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.

    -

    20.8.2 Native pointer support

    +

    21.8.2 Native pointer support

    Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a primitive type below.

    @@ -404,7 +404,7 @@ struct A {

    To determine if a type should be considered primitive, the cprimitive attribute on its dtype attribute is used. For example, the dtype typemap for float has cprimitive="1", so the code from the nativepointer attribute is taken into account e.g. for float ** or the function pointer float (*)(float *).

    -

    20.8.3 Operator overloading

    +

    21.8.3 Operator overloading

    The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:

    @@ -416,7 +416,7 @@ struct A {

    There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, [], in combination with assignments - while operator [] in C++ simply returns a reference which is then written to, D resorts to a separate opIndexAssign method -, or implicit casting (which was introduced in D2 via alias this). Despite the lack of automatic support, manually handling these cases should be perfectly possible.

    -

    20.8.4 Running the test-suite

    +

    21.8.4 Running the test-suite

    As with any other language, the SWIG test-suite can be built for D using the *-d-test-suite targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional D_VERSION variable, e.g. make check-d-test-suite D_VERSION=2.

    @@ -424,14 +424,14 @@ struct A {

    Note: If you want to use GDC on Linux or another platform which requires you to link libdl for dynamically loading the shared library, you might have to add -ldl manually to the d_compile target in Examples/Makefile, because GDC does not currently honor the pragma(lib,...) statement.

    -

    20.9 D Typemap examples

    +

    21.9 D Typemap examples

    There are no D-specific typemap examples yet. However, with the above name comparison table, you should be able to get an idea what can be done by looking at the corresponding C# section.

    -

    20.10 Work in progress and planned features

    +

    21.10 Work in progress and planned features

    There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index ff666791c..c3b2740f4 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -6,7 +6,7 @@ -

    37 Extending SWIG to support new languages

    +

    38 Extending SWIG to support new languages

      @@ -75,7 +75,7 @@ -

      37.1 Introduction

      +

      38.1 Introduction

      @@ -91,7 +91,7 @@ Also, this chapter is not meant to be a hand-holding tutorial. As a starting po you should probably look at one of SWIG's existing modules.

      -

      37.2 Prerequisites

      +

      38.2 Prerequisites

      @@ -121,7 +121,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of wrapper code are driven by C++ datatypes.

      -

      37.3 The Big Picture

      +

      38.3 The Big Picture

      @@ -158,7 +158,7 @@ role in making the system work. For example, both typemaps and declaration anno based on pattern matching and interact heavily with the underlying type system.

      -

      37.4 Execution Model

      +

      38.4 Execution Model

      @@ -203,7 +203,7 @@ latter stage of compilation. The next few sections briefly describe some of these stages.

      -

      37.4.1 Preprocessing

      +

      38.4.1 Preprocessing

      @@ -284,7 +284,7 @@ been expanded as well as everything else that goes into the low-level construction of the wrapper code.

      -

      37.4.2 Parsing

      +

      38.4.2 Parsing

      @@ -385,7 +385,7 @@ returning a foo and taking types a and b as arguments).

      -

      37.4.3 Parse Trees

      +

      38.4.3 Parse Trees

      @@ -640,7 +640,7 @@ $ swig -c++ -python -debug-module 4 example.i

    -

    37.4.4 Attribute namespaces

    +

    38.4.4 Attribute namespaces

    @@ -659,7 +659,7 @@ that matches the name of the target language. For example, python:foo perl:foo.

    -

    37.4.5 Symbol Tables

    +

    38.4.5 Symbol Tables

    @@ -750,7 +750,7 @@ example.i:5. Previous declaration is foo_i(int ) -

    37.4.6 The %feature directive

    +

    38.4.6 The %feature directive

    @@ -806,7 +806,7 @@ For example, the exception code above is simply stored without any modifications.

    -

    37.4.7 Code Generation

    +

    38.4.7 Code Generation

    @@ -928,7 +928,7 @@ public : The role of these functions is described shortly.

    -

    37.4.8 SWIG and XML

    +

    38.4.8 SWIG and XML

    @@ -941,7 +941,7 @@ internal data structures, it may be useful to keep XML in the back of your mind as a model.

    -

    37.5 Primitive Data Structures

    +

    38.5 Primitive Data Structures

    @@ -987,7 +987,7 @@ typedef Hash Typetab; -

    37.5.1 Strings

    +

    38.5.1 Strings

    @@ -1128,7 +1128,7 @@ Returns the number of replacements made (if any). -

    37.5.2 Hashes

    +

    38.5.2 Hashes

    @@ -1205,7 +1205,7 @@ Returns the list of hash table keys. -

    37.5.3 Lists

    +

    38.5.3 Lists

    @@ -1294,7 +1294,7 @@ If t is not a standard object, it is assumed to be a char * and is used to create a String object. -

    37.5.4 Common operations

    +

    38.5.4 Common operations

    The following operations are applicable to all datatypes. @@ -1349,7 +1349,7 @@ objects and report errors. Gets the line number associated with x. -

    37.5.5 Iterating over Lists and Hashes

    +

    38.5.5 Iterating over Lists and Hashes

    To iterate over the elements of a list or a hash table, the following functions are used: @@ -1394,7 +1394,7 @@ for (j = First(j); j.item; j= Next(j)) { -

    37.5.6 I/O

    +

    38.5.6 I/O

    Special I/O functions are used for all internal I/O. These operations @@ -1531,7 +1531,7 @@ Similarly, the preprocessor and parser all operate on string-files. -

    37.6 Navigating and manipulating parse trees

    +

    38.6 Navigating and manipulating parse trees

    Parse trees are built as collections of hash tables. Each node is a hash table in which @@ -1665,7 +1665,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u the parent so that sibling nodes are unaffected. -

    37.7 Working with attributes

    +

    38.7 Working with attributes

    @@ -1782,7 +1782,7 @@ the attribute is optional. Swig_restore() must always be called after function. -

    37.8 Type system

    +

    38.8 Type system

    @@ -1791,7 +1791,7 @@ pointers, references, and pointers to members. A detailed discussion of type theory is impossible here. However, let's cover the highlights.

    -

    37.8.1 String encoding of types

    +

    38.8.1 String encoding of types

    @@ -1892,7 +1892,7 @@ make the final type, the two parts are just joined together using string concatenation.

    -

    37.8.2 Type construction

    +

    38.8.2 Type construction

    @@ -2061,7 +2061,7 @@ Returns the prefix of a type. For example, if ty is ty is unmodified. -

    37.8.3 Type tests

    +

    38.8.3 Type tests

    @@ -2148,7 +2148,7 @@ Checks if ty is a varargs type. Checks if ty is a templatized type. -

    37.8.4 Typedef and inheritance

    +

    38.8.4 Typedef and inheritance

    @@ -2250,7 +2250,7 @@ Fully reduces ty according to typedef rules. Resulting datatype will consist only of primitive typenames. -

    37.8.5 Lvalues

    +

    38.8.5 Lvalues

    @@ -2287,7 +2287,7 @@ Literal y; // type = 'Literal', ltype='p.char' -

    37.8.6 Output functions

    +

    38.8.6 Output functions

    @@ -2349,7 +2349,7 @@ SWIG, but is most commonly associated with type-descriptor objects that appear in wrappers (e.g., SWIGTYPE_p_double). -

    37.9 Parameters

    +

    38.9 Parameters

    @@ -2448,7 +2448,7 @@ included. Used to emit prototypes. Returns the number of required (non-optional) arguments in p. -

    37.10 Writing a Language Module

    +

    38.10 Writing a Language Module

    @@ -2463,7 +2463,7 @@ describes the creation of a minimal Python module. You should be able to extra this to other languages.

    -

    37.10.1 Execution model

    +

    38.10.1 Execution model

    @@ -2473,7 +2473,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.

    -

    37.10.2 Starting out

    +

    38.10.2 Starting out

    @@ -2581,7 +2581,7 @@ that activates your module. For example, swig -python foo.i. The messages from your new module should appear.

    -

    37.10.3 Command line options

    +

    38.10.3 Command line options

    @@ -2640,7 +2640,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit unrecognized command line option error.

    -

    37.10.4 Configuration and preprocessing

    +

    38.10.4 Configuration and preprocessing

    @@ -2689,7 +2689,7 @@ an implementation file python.cxx and a configuration file python.swg.

    -

    37.10.5 Entry point to code generation

    +

    38.10.5 Entry point to code generation

    @@ -2747,7 +2747,7 @@ int Python::top(Node *n) { -

    37.10.6 Module I/O and wrapper skeleton

    +

    38.10.6 Module I/O and wrapper skeleton

    @@ -2896,7 +2896,7 @@ functionWrapper : void Shape_y_set(Shape *self,double y) -

    37.10.7 Low-level code generators

    +

    38.10.7 Low-level code generators

    @@ -3050,7 +3050,7 @@ but without the typemaps, there is still work to do.

    -

    37.10.8 Configuration files

    +

    38.10.8 Configuration files

    @@ -3194,7 +3194,7 @@ politely displays the ignoring language message. -

    37.10.9 Runtime support

    +

    38.10.9 Runtime support

    @@ -3203,7 +3203,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g. the SWIG files that implement those functions.

    -

    37.10.10 Standard library files

    +

    38.10.10 Standard library files

    @@ -3222,7 +3222,7 @@ The following are the minimum that are usually supported: Please copy these and modify for any new language.

    -

    37.10.11 User examples

    +

    38.10.11 User examples

    @@ -3251,7 +3251,7 @@ during this process, see the section on .

    -

    37.10.12 Test driven development and the test-suite

    +

    38.10.12 Test driven development and the test-suite

    @@ -3310,7 +3310,7 @@ It is therefore essential that the runtime tests are written in a manner that di but error/exception out with an error message on stderr on failure.

    -

    37.10.12.1 Running the test-suite

    +

    38.10.12.1 Running the test-suite

    @@ -3496,7 +3496,7 @@ The syntax for setting environment variables varies from one shell to the next, make ret_by_value.ctest SWIG_FEATURES="-debug-tmsearch" -

    37.10.13 Documentation

    +

    38.10.13 Documentation

    @@ -3528,7 +3528,7 @@ Some topics that you'll want to be sure to address include: if available. -

    37.10.14 Prerequisites for adding a new language module to the SWIG distribution

    +

    38.10.14 Prerequisites for adding a new language module to the SWIG distribution

    @@ -3585,7 +3585,7 @@ should be added should there be an area not already covered by the existing tests.

    -

    37.10.15 Coding style guidelines

    +

    38.10.15 Coding style guidelines

    @@ -3609,7 +3609,7 @@ The generated C/C++ code should also follow this style as close as possible. How should be avoided as unlike the SWIG developers, users will never have consistent tab settings.

    -

    37.11 Debugging Options

    +

    38.11 Debugging Options

    @@ -3636,7 +3636,7 @@ There are various command line options which can aid debugging a SWIG interface The complete list of command line options for SWIG are available by running swig -help.

    -

    37.12 Guide to parse tree nodes

    +

    38.12 Guide to parse tree nodes

    @@ -4044,7 +4044,7 @@ extern "X" { ... } declaration. -

    37.13 Further Development Information

    +

    38.13 Further Development Information

    diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 5c3c1b4f2..cd39d1fa1 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -5,7 +5,7 @@ -

    21 SWIG and Go

    +

    22 SWIG and Go

      @@ -43,7 +43,7 @@ the Go programming language see golang.org.

      -

      21.1 Overview

      +

      22.1 Overview

      @@ -67,7 +67,7 @@ checking and runtime library are not used with Go. This should be borne in mind when reading the rest of the SWIG documentation.

      -

      21.2 Running SWIG with Go

      +

      22.2 Running SWIG with Go

      @@ -76,7 +76,7 @@ default SWIG will generate code for the gc compilers. To generate code for gccgo, you should also use the -gccgo option.

      -

      21.2.1 Additional Commandline Options

      +

      22.2.1 Additional Commandline Options

      @@ -129,7 +129,7 @@ swig -go -help -

      21.2.2 Go Output Files

      +

      22.2.2 Go Output Files

      When generating Go code, SWIG will generate the following @@ -174,7 +174,7 @@ A typical command sequence would look like this: % 6l main.6

    -

    21.3 A tour of basic C/C++ wrapping

    +

    22.3 A tour of basic C/C++ wrapping

    @@ -184,7 +184,7 @@ modifications have to occur. This section briefly covers the essential aspects of this wrapping.

    -

    21.3.1 Go Package Name

    +

    22.3.1 Go Package Name

    @@ -194,7 +194,7 @@ directive. You may override this by using SWIG's -package command line option.

    -

    21.3.2 Go Names

    +

    22.3.2 Go Names

    @@ -226,7 +226,7 @@ followed by that name, and the destructor will be named Delete followed by that name.

    -

    21.3.3 Go Constants

    +

    22.3.3 Go Constants

    @@ -234,7 +234,7 @@ C/C++ constants created via #define or the %constant directive become Go constants, declared with a const declaration. -

    21.3.4 Go Enumerations

    +

    22.3.4 Go Enumerations

    @@ -244,7 +244,7 @@ usual). The values of the enumeration will become variables in Go; code should avoid modifying those variables.

    -

    21.3.5 Go Classes

    +

    22.3.5 Go Classes

    @@ -322,7 +322,7 @@ returns a go interface. If the returned pointer can be null, you can check for this by calling the Swigcptr() method.

    -

    21.3.5.1 Go Class Inheritance

    +

    22.3.5.1 Go Class Inheritance

    @@ -334,7 +334,7 @@ Doing the reverse will require an explicit type assertion, which will be checked dynamically.

    -

    21.3.6 Go Templates

    +

    22.3.6 Go Templates

    @@ -342,7 +342,7 @@ In order to use C++ templates in Go, you must tell SWIG to create wrappers for a particular template instantation. To do this, use the %template directive. -

    21.3.7 Go Director Classes

    +

    22.3.7 Go Director Classes

    @@ -385,7 +385,7 @@ method defined in Go. The Go code may of course call other methods on itself, and those methods may be defined either in Go or in C++.

    -

    21.3.8 Default Go primitive type mappings

    +

    22.3.8 Default Go primitive type mappings

    @@ -492,7 +492,7 @@ that typemap, or add new values, to control how C/C++ types are mapped into Go types.

    -

    21.3.9 Output arguments

    +

    22.3.9 Output arguments

    Because of limitations in the way output arguments are processed in swig, @@ -545,7 +545,7 @@ void f(char *output); -

    21.3.10 Adding additional go code

    +

    22.3.10 Adding additional go code

    Often the APIs generated by swig are not very natural in go, especially if diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 111c48214..6f1300492 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -8,7 +8,7 @@ -

    22 SWIG and Guile

    +

    23 SWIG and Guile

      @@ -47,7 +47,7 @@

      This section details guile-specific support in SWIG. -

      22.1 Meaning of "Module"

      +

      23.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". -

      22.2 Using the SCM or GH Guile API

      +

      23.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.

      -

      22.3 Linkage

      +

      23.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. -

      22.3.1 Simple Linkage

      +

      23.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. -

      22.3.2 Passive Linkage

      +

      23.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. -

      22.3.3 Native Guile Module Linkage

      +

      23.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:

    -

    22.3.4 Old Auto-Loading Guile Module Linkage

    +

    23.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. -

    22.3.5 Hobbit4D Linkage

    +

    23.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.

    -

    22.4 Underscore Folding

    +

    23.4 Underscore Folding

    @@ -320,7 +320,7 @@ complained so far. %rename to specify the Guile name of the wrapped functions and variables (see CHANGES). -

    22.5 Typemaps

    +

    23.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.

    -

    22.6 Representation of pointers as smobs

    +

    23.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. -

    22.6.1 GH Smobs

    +

    23.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.

    -

    22.6.2 SCM Smobs

    +

    23.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.

    -

    22.6.3 Garbage Collection

    +

    23.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 22.7 Exception Handling +

    23.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. -

    22.8 Procedure documentation

    +

    23.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. -

    22.9 Procedures with setters

    +

    23.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. -

    22.10 GOOPS Proxy Classes

    +

    23.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.

    -

    22.10.1 Naming Issues

    +

    23.10.1 Naming Issues

    As you can see in the example above, there are potential naming conflicts. The default exported @@ -767,7 +767,7 @@ guile-modules. For example,

    (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:))) -

    22.10.2 Linking

    +

    23.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 ca33b2f60..9ae05ce7e 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -5,7 +5,7 @@ -

    23 SWIG and Java

    +

    24 SWIG and Java

  • Examples +
  • Java Examples @@ -155,7 +155,7 @@ It covers most SWIG features, but certain low-level details are covered in less

    -

    23.1 Overview

    +

    24.1 Overview

    @@ -190,7 +190,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.

    -

    23.2 Preliminaries

    +

    24.2 Preliminaries

    @@ -206,7 +206,11 @@ 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.

    -

    23.2.1 Running SWIG

    +

    +Android uses Java JNI and also works with SWIG. Please read the Android chapter in conjunction with this one if you are targeting Android. +

    + +

    24.2.1 Running SWIG

    @@ -265,7 +269,7 @@ The following sections have further practical examples and details on how you mi compiling and using the generated files.

    -

    23.2.2 Additional Commandline Options

    +

    24.2.2 Additional Commandline Options

    @@ -302,7 +306,7 @@ swig -java -help Their use will become clearer by the time you have finished reading this section on SWIG and Java.

    -

    23.2.3 Getting the right header files

    +

    24.2.3 Getting the right header files

    @@ -317,7 +321,7 @@ They are usually in directories like this:

    The exact location may vary on your machine, but the above locations are typical.

    -

    23.2.4 Compiling a dynamic module

    +

    24.2.4 Compiling a dynamic module

    @@ -353,7 +357,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.

    -

    23.2.5 Using your module

    +

    24.2.5 Using your module

    @@ -388,7 +392,7 @@ $ If it doesn't work have a look at the following section which discusses problems loading the shared library.

    -

    23.2.6 Dynamic linking problems

    +

    24.2.6 Dynamic linking problems

    @@ -475,7 +479,7 @@ The following section also contains some C++ specific linking problems and solut

    -

    23.2.7 Compilation problems and compiling with C++

    +

    24.2.7 Compilation problems and compiling with C++

    @@ -528,7 +532,7 @@ Finally make sure the version of JDK header files matches the version of Java th

    -

    23.2.8 Building on Windows

    +

    24.2.8 Building on Windows

    @@ -537,7 +541,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.

    -

    23.2.8.1 Running SWIG from Visual Studio

    +

    24.2.8.1 Running SWIG from Visual Studio

    @@ -576,7 +580,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.

    -

    23.2.8.2 Using NMAKE

    +

    24.2.8.2 Using NMAKE

    @@ -635,7 +639,7 @@ Of course you may want to make changes for it to work for C++ by adding in the -

    -

    23.3 A tour of basic C/C++ wrapping

    +

    24.3 A tour of basic C/C++ wrapping

    @@ -645,7 +649,7 @@ variables are wrapped with JavaBean type getters and setters and so forth. This section briefly covers the essential aspects of this wrapping.

    -

    23.3.1 Modules, packages and generated Java classes

    +

    24.3.1 Modules, packages and generated Java classes

    @@ -681,7 +685,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.

    -

    23.3.2 Functions

    +

    24.3.2 Functions

    @@ -715,7 +719,7 @@ System.out.println(example.fact(4)); -

    23.3.3 Global variables

    +

    24.3.3 Global variables

    @@ -802,7 +806,7 @@ extern char *path; // Read-only (due to %immutable) -

    23.3.4 Constants

    +

    24.3.4 Constants

    @@ -942,7 +946,7 @@ Or if you decide this practice isn't so bad and your own class implements ex

    -

    23.3.5 Enumerations

    +

    24.3.5 Enumerations

    @@ -956,7 +960,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.

    -

    23.3.5.1 Anonymous enums

    +

    24.3.5.1 Anonymous enums

    @@ -1019,7 +1023,7 @@ As in the case of constants, you can access them through either the module class

    -

    23.3.5.2 Typesafe enums

    +

    24.3.5.2 Typesafe enums

    @@ -1113,7 +1117,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.

    -

    23.3.5.3 Proper Java enums

    +

    24.3.5.3 Proper Java enums

    @@ -1166,7 +1170,7 @@ The additional support methods need not be generated if none of the enum items h Simpler Java enums for enums without initializers section.

    -

    23.3.5.4 Type unsafe enums

    +

    24.3.5.4 Type unsafe enums

    @@ -1214,7 +1218,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.

    -

    23.3.5.5 Simple enums

    +

    24.3.5.5 Simple enums

    @@ -1233,7 +1237,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.

    -

    23.3.6 Pointers

    +

    24.3.6 Pointers

    @@ -1321,7 +1325,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.

    -

    23.3.7 Structures

    +

    24.3.7 Structures

    @@ -1489,7 +1493,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a -

    23.3.8 C++ classes

    +

    24.3.8 C++ classes

    @@ -1552,7 +1556,7 @@ int bar = Spam.getBar(); -

    23.3.9 C++ inheritance

    +

    24.3.9 C++ inheritance

    @@ -1613,7 +1617,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.

    -

    23.3.10 Pointers, references, arrays and pass by value

    +

    24.3.10 Pointers, references, arrays and pass by value

    @@ -1668,7 +1672,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).

    -

    23.3.10.1 Null pointers

    +

    24.3.10.1 Null pointers

    @@ -1692,7 +1696,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.

    -

    23.3.11 C++ overloaded functions

    +

    24.3.11 C++ overloaded functions

    @@ -1807,7 +1811,7 @@ void spam(unsigned short); // Ignored -

    23.3.12 C++ default arguments

    +

    24.3.12 C++ default arguments

    @@ -1850,7 +1854,7 @@ Further details on default arguments and how to restore this approach are given

    -

    23.3.13 C++ namespaces

    +

    24.3.13 C++ namespaces

    @@ -1930,7 +1934,7 @@ in an unnamed package. -

    23.3.14 C++ templates

    +

    24.3.14 C++ templates

    @@ -1979,7 +1983,7 @@ Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter.

    -

    23.3.15 C++ Smart Pointers

    +

    24.3.15 C++ Smart Pointers

    @@ -2063,7 +2067,7 @@ Foo f = p.__deref__(); // Returns underlying Foo * -

    23.4 Further details on the generated Java classes

    +

    24.4 Further details on the generated Java classes

    @@ -2078,7 +2082,7 @@ Finally enum classes are covered. First, the crucial intermediary JNI class is considered.

    -

    23.4.1 The intermediary JNI class

    +

    24.4.1 The intermediary JNI class

    @@ -2198,7 +2202,7 @@ If name is the same as modulename then the module class name g from modulename to modulenameModule.

    -

    23.4.1.1 The intermediary JNI class pragmas

    +

    24.4.1.1 The intermediary JNI class pragmas

    @@ -2277,7 +2281,7 @@ For example, let's change the intermediary JNI class access to just the default All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

    -

    23.4.2 The Java module class

    +

    24.4.2 The Java module class

    @@ -2308,7 +2312,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.

    -

    23.4.2.1 The Java module class pragmas

    +

    24.4.2.1 The Java module class pragmas

    @@ -2359,7 +2363,7 @@ See The intermediary JNI class pragmas secti

    -

    23.4.3 Java proxy classes

    +

    24.4.3 Java proxy classes

    @@ -2435,7 +2439,7 @@ int y = f.spam(5, new Foo()); -

    23.4.3.1 Memory management

    +

    24.4.3.1 Memory management

    @@ -2597,7 +2601,7 @@ and

    -

    23.4.3.2 Inheritance

    +

    24.4.3.2 Inheritance

    @@ -2713,7 +2717,7 @@ However, true cross language polymorphism can be achieved using the 23.4.3.3 Proxy classes and garbage collection +

    24.4.3.3 Proxy classes and garbage collection

    @@ -2796,7 +2800,7 @@ The section on Java typemaps details how to specify See the How to Handle Java Finalization's Memory-Retention Issues article for alternative approaches to managing memory by avoiding finalizers altogether.

    -

    23.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    24.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    @@ -2918,7 +2922,7 @@ For example: Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

    -

    23.4.3.5 Single threaded applications and thread safety

    +

    24.4.3.5 Single threaded applications and thread safety

    @@ -3006,7 +3010,7 @@ for (int i=0; i<100000; i++) { -

    23.4.4 Type wrapper classes

    +

    24.4.4 Type wrapper classes

    @@ -3093,7 +3097,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... } -

    23.4.5 Enum classes

    +

    24.4.5 Enum classes

    @@ -3102,7 +3106,7 @@ The Enumerations section discussed these but om The following sub-sections detail the various types of enum classes that can be generated.

    -

    23.4.5.1 Typesafe enum classes

    +

    24.4.5.1 Typesafe enum classes

    @@ -3186,7 +3190,7 @@ The swigValue method is used for marshalling in the other direction. The toString method is overridden so that the enum name is available.

    -

    23.4.5.2 Proper Java enum classes

    +

    24.4.5.2 Proper Java enum classes

    @@ -3264,7 +3268,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.

    -

    23.4.5.3 Type unsafe enum classes

    +

    24.4.5.3 Type unsafe enum classes

    @@ -3295,7 +3299,7 @@ public final class Beverage { -

    23.5 Cross language polymorphism using directors

    +

    24.5 Cross language polymorphism using directors

    @@ -3317,7 +3321,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.

    -

    23.5.1 Enabling directors

    +

    24.5.1 Enabling directors

    @@ -3388,7 +3392,7 @@ public: -

    23.5.2 Director classes

    +

    24.5.2 Director classes

    @@ -3415,7 +3419,7 @@ If the correct implementation is in Java, the Java API is used to call the metho

    -

    23.5.3 Overhead and code bloat

    +

    24.5.3 Overhead and code bloat

    @@ -3433,7 +3437,7 @@ This situation can be optimized by selectively enabling director methods (using

    -

    23.5.4 Simple directors example

    +

    24.5.4 Simple directors example

    @@ -3498,7 +3502,7 @@ DirectorDerived::upcall_method() invoked. -

    23.5.5 Director threading issues

    +

    24.5.5 Director threading issues

    @@ -3518,7 +3522,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern -

    23.6 Accessing protected members

    +

    24.6 Accessing protected members

    @@ -3614,7 +3618,7 @@ class MyProtectedBase extends ProtectedBase -

    23.7 Common customization features

    +

    24.7 Common customization features

    @@ -3626,7 +3630,7 @@ be awkward. This section describes some common SWIG features that are used to improve the interface to existing C/C++ code.

    -

    23.7.1 C/C++ helper functions

    +

    24.7.1 C/C++ helper functions

    @@ -3692,7 +3696,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.

    -

    23.7.2 Class extension with %extend

    +

    24.7.2 Class extension with %extend

    @@ -3755,7 +3759,7 @@ Vector(2,3,4) in any way---the extensions only show up in the Java interface.

    -

    23.7.3 Exception handling with %exception and %javaexception

    +

    24.7.3 Exception handling with %exception and %javaexception

    @@ -3914,7 +3918,7 @@ to raise exceptions. See the SWIG Library ch The typemap example Handling C++ exception specifications as Java exceptions provides further exception handling capabilities.

    -

    23.7.4 Method access with %javamethodmodifiers

    +

    24.7.4 Method access with %javamethodmodifiers

    @@ -3940,7 +3944,7 @@ protected static void protect_me() { -

    23.8 Tips and techniques

    +

    24.8 Tips and techniques

    @@ -3950,7 +3954,7 @@ strings and arrays. This chapter discusses the common techniques for solving these problems.

    -

    23.8.1 Input and output parameters using primitive pointers and references

    +

    24.8.1 Input and output parameters using primitive pointers and references

    @@ -4124,7 +4128,7 @@ void foo(Bar *OUTPUT); will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

    -

    23.8.2 Simple pointers

    +

    24.8.2 Simple pointers

    @@ -4190,7 +4194,7 @@ System.out.println("3 + 4 = " + result); See the SWIG Library chapter for further details.

    -

    23.8.3 Wrapping C arrays with Java arrays

    +

    24.8.3 Wrapping C arrays with Java arrays

    @@ -4257,7 +4261,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.

    -

    23.8.4 Unbounded C Arrays

    +

    24.8.4 Unbounded C Arrays

    @@ -4402,7 +4406,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

    -

    23.8.5 Binary data vs Strings

    +

    24.8.5 Binary data vs Strings

    @@ -4446,7 +4450,7 @@ len: 5 data: 68 69 0 6a 6b -

    23.8.6 Overriding new and delete to allocate from Java heap

    +

    24.8.6 Overriding new and delete to allocate from Java heap

    @@ -4563,7 +4567,7 @@ model and use these functions in place of malloc and free in your own code.

    -

    23.9 Java typemaps

    +

    24.9 Java typemaps

    @@ -4584,7 +4588,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. -

    23.9.1 Default primitive type mappings

    +

    24.9.1 Default primitive type mappings

    @@ -4736,7 +4740,7 @@ However, the mappings allow the full range of values for each C type from Java.

    -

    23.9.2 Default typemaps for non-primitive types

    +

    24.9.2 Default typemaps for non-primitive types

    @@ -4751,7 +4755,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.

    -

    23.9.3 Sixty four bit JVMs

    +

    24.9.3 Sixty four bit JVMs

    @@ -4764,7 +4768,7 @@ Unfortunately it won't of course hold true for JNI code.

    -

    23.9.4 What is a typemap?

    +

    24.9.4 What is a typemap?

    @@ -4887,7 +4891,7 @@ int c = example.count('e',"Hello World"); -

    23.9.5 Typemaps for mapping C/C++ types to Java types

    +

    24.9.5 Typemaps for mapping C/C++ types to Java types

    @@ -5147,7 +5151,7 @@ These are listed below: -

    23.9.6 Java typemap attributes

    +

    24.9.6 Java typemap attributes

    @@ -5193,7 +5197,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.

    -

    23.9.7 Java special variables

    +

    24.9.7 Java special variables

    @@ -5344,7 +5348,7 @@ This special variable expands to the intermediary class name. Usually this is th unless the jniclassname attribute is specified in the %module directive.

    -

    23.9.8 Typemaps for both C and C++ compilation

    +

    24.9.8 Typemaps for both C and C++ compilation

    @@ -5381,7 +5385,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps

    -

    23.9.9 Java code typemaps

    +

    24.9.9 Java code typemaps

    @@ -5603,7 +5607,7 @@ to make the method and constructor public: -

    23.9.10 Director specific typemaps

    +

    24.9.10 Director specific typemaps

    @@ -5828,7 +5832,7 @@ The basic strategy here is to provide a default package typemap for the majority -

    23.10 Typemap Examples

    +

    24.10 Typemap Examples

    @@ -5838,7 +5842,7 @@ the SWIG library.

    -

    23.10.1 Simpler Java enums for enums without initializers

    +

    24.10.1 Simpler Java enums for enums without initializers

    @@ -5917,7 +5921,7 @@ This would be done by using the original versions of these typemaps in "enums.sw

    -

    23.10.2 Handling C++ exception specifications as Java exceptions

    +

    24.10.2 Handling C++ exception specifications as Java exceptions

    @@ -6042,7 +6046,7 @@ We could alternatively have used %rename to rename what() into

    -

    23.10.3 NaN Exception - exception handling for a particular type

    +

    24.10.3 NaN Exception - exception handling for a particular type

    @@ -6197,7 +6201,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.

    -

    23.10.4 Converting Java String arrays to char **

    +

    24.10.4 Converting Java String arrays to char **

    @@ -6341,7 +6345,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

    -

    23.10.5 Expanding a Java object to multiple arguments

    +

    24.10.5 Expanding a Java object to multiple arguments

    @@ -6423,7 +6427,7 @@ example.foo(new String[]{"red", "green", "blue", "white"}); -

    23.10.6 Using typemaps to return arguments

    +

    24.10.6 Using typemaps to return arguments

    @@ -6541,7 +6545,7 @@ $ java runme 1 12.0 340.0 -

    23.10.7 Adding Java downcasts to polymorphic return types

    +

    24.10.7 Adding Java downcasts to polymorphic return types

    @@ -6747,7 +6751,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.

    -

    23.10.8 Adding an equals method to the Java classes

    +

    24.10.8 Adding an equals method to the Java classes

    @@ -6791,7 +6795,7 @@ System.out.println("foo1? " + foo1.equals(foo2)); -

    23.10.9 Void pointers and a common Java base class

    +

    24.10.9 Void pointers and a common Java base class

    @@ -6850,7 +6854,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. -

    23.10.10 Struct pointer to pointer

    +

    24.10.10 Struct pointer to pointer

    @@ -7030,7 +7034,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.

    -

    23.10.11 Memory management when returning references to member variables

    +

    24.10.11 Memory management when returning references to member variables

    @@ -7153,7 +7157,7 @@ public class Bike { Note the addReference call.

    -

    23.10.12 Memory management for objects passed to the C++ layer

    +

    24.10.12 Memory management for objects passed to the C++ layer

    @@ -7269,7 +7273,7 @@ The 'javacode' typemap simply adds in the specified code into the Java proxy cla -

    23.10.13 Date marshalling using the javain typemap and associated attributes

    +

    24.10.13 Date marshalling using the javain typemap and associated attributes

    @@ -7446,7 +7450,7 @@ A few things to note: -

    23.11 Living with Java Directors

    +

    24.11 Living with Java Directors

    @@ -7627,10 +7631,10 @@ public abstract class UserVisibleFoo extends Foo {

  • -

    23.12 Odds and ends

    +

    24.12 Odds and ends

    -

    23.12.1 JavaDoc comments

    +

    24.12.1 JavaDoc comments

    @@ -7686,7 +7690,7 @@ public class Barmy { -

    23.12.2 Functional interface without proxy classes

    +

    24.12.2 Functional interface without proxy classes

    @@ -7747,7 +7751,7 @@ All destructors have to be called manually for example the delete_Foo(foo) -

    23.12.3 Using your own JNI functions

    +

    24.12.3 Using your own JNI functions

    @@ -7797,7 +7801,7 @@ This directive is only really useful if you want to mix your own hand crafted JN

    -

    23.12.4 Performance concerns and hints

    +

    24.12.4 Performance concerns and hints

    @@ -7818,7 +7822,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.

    -

    23.12.5 Debugging

    +

    24.12.5 Debugging

    @@ -7840,7 +7844,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh

    -

    23.13 Examples

    +

    24.13 Java Examples

    diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index 92af4e6c9..01ff3a3ec 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -6,7 +6,7 @@ -

    24 SWIG and Common Lisp

    +

    25 SWIG and Common Lisp

      @@ -41,7 +41,7 @@ Lisp, Common Foreign Function Interface(CFFI), CLisp and UFFI foreign function interfaces.

      -

      24.1 Allegro Common Lisp

      +

      25.1 Allegro Common Lisp

      @@ -50,7 +50,7 @@ here

      -

      24.2 Common Foreign Function Interface(CFFI)

      +

      25.2 Common Foreign Function Interface(CFFI)

      @@ -77,7 +77,7 @@ swig -cffi -module module-name file-name files and the various things which you can do with them.

      -

      24.2.1 Additional Commandline Options

      +

      25.2.1 Additional Commandline Options

      @@ -118,7 +118,7 @@ swig -cffi -help -

      24.2.2 Generating CFFI bindings

      +

      25.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
    -

    24.2.3 Generating CFFI bindings for C++ code

    +

    25.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. -

    24.2.4 Inserting user code into generated files

    +

    25.2.4 Inserting user code into generated files

    @@ -608,7 +608,7 @@ Note that the block %{ ... %} is effectively a shortcut for

    -

    24.3 CLISP

    +

    25.3 CLISP

    @@ -638,7 +638,7 @@ swig -clisp -module module-name file-name interface file for the CLISP module. The CLISP module tries to produce code which is both human readable and easily modifyable.

    -

    24.3.1 Additional Commandline Options

    +

    25.3.1 Additional Commandline Options

    @@ -671,7 +671,7 @@ and global variables will be created otherwise only definitions for
    -

    24.3.2 Details on CLISP bindings

    +

    25.3.2 Details on CLISP bindings

    @@ -795,7 +795,7 @@ struct bar { -

    24.4 UFFI

    +

    25.4 UFFI

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index e73cd0a5c..2bc5ddef9 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -6,7 +6,7 @@ -

    25 SWIG and Lua

    +

    26 SWIG and Lua

      @@ -73,13 +73,13 @@ Lua is an extension programming language designed to support general procedural eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net

      -

      25.1 Preliminaries

      +

      26.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). SWIG also supports eLua and works with eLua 0.8. SWIG generated code for eLua has been tested on Stellaris ARM Cortex-M3 LM3S and Infineon TriCore.

      -

      25.2 Running SWIG

      +

      26.2 Running SWIG

      @@ -127,7 +127,7 @@ $ swig -lua -eluac example.i The -elua option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the -eluac option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with -eluac. To access any value from eLua, one must directly call the wrapper function associated with that value.

      -

      25.2.1 Additional command line options

      +

      26.2.1 Additional command line options

      @@ -160,7 +160,7 @@ swig -lua -help -

      25.2.2 Compiling and Linking and Interpreter

      +

      26.2.2 Compiling and Linking and Interpreter

      @@ -232,7 +232,7 @@ LUALIB_API int ( luaopen_mod )(lua_State *L ); More information on building and configuring eLua can be found here: http://www.eluaproject.net/doc/v0.8/en_building.html

      -

      25.2.3 Compiling a dynamic module

      +

      26.2.3 Compiling a dynamic module

      @@ -300,7 +300,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib -

      25.2.4 Using your module

      +

      26.2.4 Using your module

      @@ -318,19 +318,19 @@ $ ./my_lua >

    -

    25.3 A tour of basic C/C++ wrapping

    +

    26.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.

    -

    25.3.1 Modules

    +

    26.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.

    -

    25.3.2 Functions

    +

    26.3.2 Functions

    @@ -368,7 +368,7 @@ It is also possible to rename the module with an assignment. 24 -

    25.3.3 Global variables

    +

    26.3.3 Global variables

    @@ -456,7 +456,7 @@ If you have used the -eluac option for your eLua module, you will have In general, functions of the form "variable_get()" and "variable_set()" are automatically generated by SWIG for use with -eluac.

    -

    25.3.4 Constants and enums

    +

    26.3.4 Constants and enums

    @@ -490,7 +490,7 @@ If you're using eLua and have used -elua or -eluac to generate > print(example.const.SCONST) Hello World -

    25.3.5 Pointers

    +

    26.3.5 Pointers

    @@ -528,7 +528,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor nil -

    25.3.6 Structures

    +

    26.3.6 Structures

    @@ -632,7 +632,7 @@ For eLua with the -eluac option, structure manipulation has to be perfo In general, functions of the form "new_struct()", "struct_member_get()", "struct_member_set()" and "free_struct()" are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the -elua option)

    -

    25.3.7 C++ classes

    +

    26.3.7 C++ classes

    @@ -693,7 +693,7 @@ It is not (currently) possible to access static members of an instance: -- does NOT work -

    25.3.8 C++ inheritance

    +

    26.3.8 C++ inheritance

    @@ -718,7 +718,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas

    It is safe to use multiple inheritance with SWIG.

    -

    25.3.9 Pointers, references, values, and arrays

    +

    26.3.9 Pointers, references, values, and arrays

    @@ -749,7 +749,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.

    -

    25.3.10 C++ overloaded functions

    +

    26.3.10 C++ overloaded functions

    @@ -835,7 +835,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.

    -

    25.3.11 C++ operators

    +

    26.3.11 C++ operators

    @@ -947,7 +947,7 @@ It is also possible to overload the operator[], but currently this cann }; -

    25.3.12 Class extension with %extend

    +

    26.3.12 Class extension with %extend

    @@ -1003,7 +1003,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).

    -

    25.3.13 Using %newobject to release memory

    +

    26.3.13 Using %newobject to release memory

    If you have a function that allocates memory like this,

    @@ -1027,7 +1027,7 @@ char *foo();

    This will release the allocated memory.

    -

    25.3.14 C++ templates

    +

    26.3.14 C++ templates

    @@ -1062,7 +1062,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.

    -

    25.3.15 C++ Smart Pointers

    +

    26.3.15 C++ Smart Pointers

    @@ -1114,7 +1114,7 @@ If you ever need to access the underlying pointer returned by operator->( > f = p:__deref__() -- Returns underlying Foo * -

    25.3.16 C++ Exceptions

    +

    26.3.16 C++ Exceptions

    @@ -1258,12 +1258,12 @@ add exception specification to functions or globally (respectively).

    -

    25.4 Typemaps

    +

    26.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

    -

    25.4.1 What is a typemap?

    +

    26.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:

    @@ -1291,7 +1291,7 @@ Received an integer : 6 720 -

    25.4.2 Using typemaps

    +

    26.4.2 Using typemaps

    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.

    @@ -1344,7 +1344,7 @@ void swap(int *sx, int *sy);

    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).

    -

    25.4.3 Typemaps and arrays

    +

    26.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 @@ -1408,7 +1408,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In

    Note: SWIG also can support arrays of pointers in a similar manner.

    -

    25.4.4 Typemaps and pointer-pointer functions

    +

    26.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:

    @@ -1442,7 +1442,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs) ptr=nil -- the iMath* will be GC'ed as normal -

    25.5 Writing typemaps

    +

    26.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.

    @@ -1451,7 +1451,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

    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).

    -

    25.5.1 Typemaps you can write

    +

    26.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.

    @@ -1464,7 +1464,7 @@ ptr=nil -- the iMath* will be GC'ed as normal (the syntax for the typecheck is different from the typemap, see typemaps for details). -

    25.5.2 SWIG's Lua-C API

    +

    26.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.

    @@ -1513,7 +1513,7 @@ This macro, when called within the context of a SWIG wrappered function, will di
    Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
    -

    25.6 Customization of your Bindings

    +

    26.6 Customization of your Bindings

    @@ -1522,7 +1522,7 @@ This section covers adding of some small extra bits to your module to add the la -

    25.6.1 Writing your own custom wrappers

    +

    26.6.1 Writing your own custom wrappers

    @@ -1541,7 +1541,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.

    -

    25.6.2 Adding additional Lua code

    +

    26.6.2 Adding additional Lua code

    @@ -1579,7 +1579,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.

    -

    25.7 Details on the Lua binding

    +

    26.7 Details on the Lua binding

    @@ -1590,7 +1590,7 @@ See Examples/lua/arrays for an example of this code.

    -

    25.7.1 Binding global data into the module.

    +

    26.7.1 Binding global data into the module.

    @@ -1650,7 +1650,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)'.

    -

    25.7.2 Userdata and Metatables

    +

    26.7.2 Userdata and Metatables

    @@ -1730,7 +1730,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.

    -

    25.7.3 Memory management

    +

    26.7.3 Memory management

    diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index f9400abee..065313fa2 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -5,7 +5,7 @@ -

    26 SWIG and Modula-3

    +

    27 SWIG and Modula-3

      @@ -54,7 +54,7 @@ especially typemaps.

      -

      26.1 Overview

      +

      27.1 Overview

      @@ -84,7 +84,7 @@ FFTW -

      26.1.1 Motivation

      +

      27.1.1 Motivation

      @@ -131,10 +131,10 @@ functions), but it doesn't allow you to easily integrate a Module-3 module into a C/C++ project.

      -

      26.2 Conception

      +

      27.2 Conception

      -

      26.2.1 Interfaces to C libraries

      +

      27.2.1 Interfaces to C libraries

      @@ -283,7 +283,7 @@ and the principal type must be renamed (%typemap).

      -

      26.2.2 Interfaces to C++ libraries

      +

      27.2.2 Interfaces to C++ libraries

      @@ -384,10 +384,10 @@ There is no C++ library I wrote a SWIG interface for, so I'm not sure if this is possible or sensible, yet.

      -

      26.3 Preliminaries

      +

      27.3 Preliminaries

      -

      26.3.1 Compilers

      +

      27.3.1 Compilers

      @@ -400,7 +400,7 @@ For testing examples I use Critical Mass cm3.

      -

      26.3.2 Additional Commandline Options

      +

      27.3.2 Additional Commandline Options

      @@ -477,10 +477,10 @@ Instead generate templates for some basic typemaps. -

      26.4 Modula-3 typemaps

      +

      27.4 Modula-3 typemaps

      -

      26.4.1 Inputs and outputs

      +

      27.4.1 Inputs and outputs

      @@ -694,7 +694,7 @@ consist of the following parts: -

      26.4.2 Subranges, Enumerations, Sets

      +

      27.4.2 Subranges, Enumerations, Sets

      @@ -746,7 +746,7 @@ that I'd like to automate.

      -

      26.4.3 Objects

      +

      27.4.3 Objects

      @@ -759,7 +759,7 @@ is not really useful, yet.

      -

      26.4.4 Imports

      +

      27.4.4 Imports

      @@ -792,7 +792,7 @@ IMPORT M3toC;

    -

    26.4.5 Exceptions

    +

    27.4.5 Exceptions

    @@ -816,7 +816,7 @@ you should declare %typemap("m3wrapinconv:throws") blah * %{OSError.E%}.

    -

    26.4.6 Example

    +

    27.4.6 Example

    @@ -863,10 +863,10 @@ where almost everything is generated by a typemap: -

    26.5 More hints to the generator

    +

    27.5 More hints to the generator

    -

    26.5.1 Features

    +

    27.5.1 Features

    @@ -903,7 +903,7 @@ where almost everything is generated by a typemap:
    -

    26.5.2 Pragmas

    +

    27.5.2 Pragmas

    @@ -926,7 +926,7 @@ where almost everything is generated by a typemap:
    -

    26.6 Remarks

    +

    27.6 Remarks

      diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html index 984b2dded..3b49a2974 100644 --- a/Doc/Manual/Mzscheme.html +++ b/Doc/Manual/Mzscheme.html @@ -8,7 +8,7 @@ -

      27 SWIG and MzScheme/Racket

      +

      28 SWIG and MzScheme/Racket

        @@ -24,7 +24,7 @@

        This section contains information on SWIG's support of Racket, formally known as MzScheme. -

        27.1 Creating native structures

        +

        28.1 Creating native structures

        @@ -65,7 +65,7 @@ Then in scheme, you can use regular struct access procedures like

      -

      27.2 Simple example

      +

      28.2 Simple example

      @@ -166,7 +166,7 @@ Some points of interest:

    • The above requests mzc to create an extension using the CGC garbage-collector. The alternative -- the 3m collector -- has generally better performance, but work is still required for SWIG to emit code which is compatible with it.
    -

    27.3 External documentation

    +

    28.3 External documentation

    diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 56c3db142..ba8aa5fa9 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -6,7 +6,7 @@ -

    28 SWIG and Ocaml

    +

    29 SWIG and Ocaml

      @@ -80,7 +80,7 @@ If you're not familiar with the Objective Caml language, you can visit The Ocaml Website.

      -

      28.1 Preliminaries

      +

      29.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.

      -

      28.1.1 Running SWIG

      +

      29.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).

      -

      28.1.2 Compiling the code

      +

      29.1.2 Compiling the code

      @@ -158,7 +158,7 @@ the user more freedom with respect to custom typing.

    -

    28.1.3 The camlp4 module

    +

    29.1.3 The camlp4 module

    @@ -234,7 +234,7 @@ let b = C_string (getenv "PATH") -

    28.1.4 Using your module

    +

    29.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.

    -

    28.1.5 Compilation problems and compiling with C++

    +

    29.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.

    -

    28.2 The low-level Ocaml/C interface

    +

    29.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.

    -

    28.2.1 The generated module

    +

    29.2.1 The generated module

    @@ -394,7 +394,7 @@ it describes the output SWIG will generate for class definitions. -

    28.2.2 Enums

    +

    29.2.2 Enums

    @@ -457,7 +457,7 @@ val x : Enum_test.c_obj = C_enum `a -

    28.2.2.1 Enum typing in Ocaml

    +

    29.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.

    -

    28.2.3 Arrays

    +

    29.2.3 Arrays

    -

    28.2.3.1 Simple types of bounded arrays

    +

    29.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.

    -

    28.2.3.2 Complex and unbounded arrays

    +

    29.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.

    -

    28.2.3.3 Using an object

    +

    29.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.

    -

    28.2.3.4 Example typemap for a function taking float * and int

    +

    29.2.3.4 Example typemap for a function taking float * and int

    @@ -572,7 +572,7 @@ void printfloats( float *tab, int len ); -

    28.2.4 C++ Classes

    +

    29.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.

    -

    28.2.4.1 STL vector and string Example

    +

    29.2.4.1 STL vector and string Example

    @@ -695,7 +695,7 @@ baz # -

    28.2.4.2 C++ Class Example

    +

    29.2.4.2 C++ Class Example

    @@ -725,7 +725,7 @@ public: }; -

    28.2.4.3 Compiling the example

    +

    29.2.4.3 Compiling the example

    @@ -743,7 +743,7 @@ bash-2.05a$ ocamlmktop -custom swig.cmo -I `camlp4 -where` \
       -L$QTPATH/lib -cclib -lqt
     
    -

    28.2.4.4 Sample Session

    +

    29.2.4.4 Sample Session

    @@ -770,10 +770,10 @@ Assuming you have a working installation of QT, you will see a window
     containing the string "hi" in a button.  
     

    -

    28.2.5 Director Classes

    +

    29.2.5 Director Classes

    -

    28.2.5.1 Director Introduction

    +

    29.2.5.1 Director Introduction

    @@ -800,7 +800,7 @@ class foo { };

    -

    28.2.5.2 Overriding Methods in Ocaml

    +

    29.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.

    -

    28.2.5.3 Director Usage Example

    +

    29.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++.

    -

    28.2.5.4 Creating director objects

    +

    29.2.5.4 Creating director objects

    @@ -928,7 +928,7 @@ object from causing a core dump, as long as the object is destroyed properly.

    -

    28.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    +

    29.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.

    -

    28.2.5.6 directorin typemap

    +

    29.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.

    -

    28.2.5.7 directorout typemap

    +

    29.2.5.7 directorout typemap

    @@ -961,7 +961,7 @@ for the same type, except when there are special requirements for object ownership, etc.

    -

    28.2.5.8 directorargout typemap

    +

    29.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.

    -

    28.2.6 Exceptions

    +

    29.2.6 Exceptions

    diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index 2a4efc99f..8a01e7c76 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -8,7 +8,7 @@ -

    29 SWIG and Octave

    +

    30 SWIG and Octave

      @@ -55,7 +55,7 @@ More information can be found at O Also, there are a dozen or so examples in the Examples/octave directory, and hundreds in the test suite (Examples/test-suite and Examples/test-suite/octave).

      -

      29.1 Preliminaries

      +

      30.1 Preliminaries

      @@ -66,7 +66,7 @@ The SWIG implemention was first based on Octave 2.9.12, so this is the minimum v As of SWIG 2.0.5, the Octave module should work with Octave versions 3.0.5, 3.2.4, and 3.4.0.

      -

      29.2 Running SWIG

      +

      30.2 Running SWIG

      @@ -98,7 +98,7 @@ The -c++ option is also required when wrapping C++ code: This creates a C++ source file example_wrap.cpp. A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.

      -

      29.2.1 Command-line options

      +

      30.2.1 Command-line options

      @@ -122,7 +122,7 @@ The -globals option sets the name of the variable which is the namespac The -opprefix options sets the prefix of the names of global/friend operator functions.

      -

      29.2.2 Compiling a dynamic module

      +

      30.2.2 Compiling a dynamic module

      @@ -149,7 +149,7 @@ $ mkoctfile example_wrap.cpp example.c

      octave:1> example
      -

      29.2.3 Using your module

      +

      30.2.3 Using your module

      @@ -167,10 +167,10 @@ octave:4> example.cvar.Foo=4; octave:5> example.cvar.Foo ans = 4

    -

    29.3 A tour of basic C/C++ wrapping

    +

    30.3 A tour of basic C/C++ wrapping

    -

    29.3.1 Modules

    +

    30.3.1 Modules

    @@ -248,7 +248,7 @@ octave:4> example.gcd(4,6) ans = 2 -

    29.3.2 Functions

    +

    30.3.2 Functions

    @@ -265,7 +265,7 @@ int fact(int n);

    octave:1> example.fact(4)
     24 
    -

    29.3.3 Global variables

    +

    30.3.3 Global variables

    @@ -318,7 +318,7 @@ octave:2> example.PI=3.142; octave:3> example.PI ans = 3.1420 -

    29.3.4 Constants and enums

    +

    30.3.4 Constants and enums

    @@ -340,7 +340,7 @@ example.SCONST="Hello World" example.SUNDAY=0 .... -

    29.3.5 Pointers

    +

    30.3.5 Pointers

    @@ -387,7 +387,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 -

    29.3.6 Structures and C++ classes

    +

    30.3.6 Structures and C++ classes

    @@ -522,7 +522,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.

    -

    29.3.7 C++ inheritance

    +

    30.3.7 C++ inheritance

    @@ -531,7 +531,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.

    -

    29.3.8 C++ overloaded functions

    +

    30.3.8 C++ overloaded functions

    @@ -541,7 +541,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.

    -

    29.3.9 C++ operators

    +

    30.3.9 C++ operators

    @@ -645,7 +645,7 @@ On the C++ side, the default mappings are as follows: Octave can also utilise friend (i.e. non-member) operators with a simple %rename: see the example in the Examples/octave/operator directory.

    -

    29.3.10 Class extension with %extend

    +

    30.3.10 Class extension with %extend

    @@ -675,7 +675,7 @@ octave:3> printf("%s\n",a); octave:4> a.__str() 4 -

    29.3.11 C++ templates

    +

    30.3.11 C++ templates

    @@ -752,14 +752,14 @@ ans = -

    29.3.12 C++ Smart Pointers

    +

    30.3.12 C++ Smart Pointers

    C++ smart pointers are fully supported as in other modules.

    -

    29.3.13 Directors (calling Octave from C++ code)

    +

    30.3.13 Directors (calling Octave from C++ code)

    @@ -840,14 +840,14 @@ c-side routine called octave-side routine called -

    29.3.14 Threads

    +

    30.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.

    -

    29.3.15 Memory management

    +

    30.3.15 Memory management

    @@ -881,14 +881,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).

    -

    29.3.16 STL support

    +

    30.3.16 STL support

    Various STL library files are provided for wrapping STL containers.

    -

    29.3.17 Matrix typemaps

    +

    30.3.17 Matrix typemaps

    diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 72fe78be8..da2344759 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -6,7 +6,7 @@ -

    30 SWIG and Perl5

    +

    31 SWIG and Perl5

      @@ -87,7 +87,7 @@ later. We're no longer testing regularly with older versions, but Perl 5.6 seems to mostly work, while older versions don't.

      -

      30.1 Overview

      +

      31.1 Overview

      @@ -108,7 +108,7 @@ described. Advanced customization features, typemaps, and other options are found near the end of the chapter.

      -

      30.2 Preliminaries

      +

      31.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.

      -

      30.2.1 Getting the right header files

      +

      31.2.1 Getting the right header files

      @@ -165,7 +165,7 @@ loaded, an easy way to find out is to run Perl itself.

    -

    30.2.2 Compiling a dynamic module

    +

    31.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.

    -

    30.2.3 Building a dynamic module with MakeMaker

    +

    31.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.

    -

    30.2.4 Building a static version of Perl

    +

    31.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.

    -

    30.2.5 Using the module

    +

    31.2.5 Using the module

    @@ -456,7 +456,7 @@ system configuration (this requires root access and you will need to read the man pages).

    -

    30.2.6 Compilation problems and compiling with C++

    +

    31.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.

    -

    30.2.7 Compiling for 64-bit platforms

    +

    31.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).

    -

    30.3 Building Perl Extensions under Windows

    +

    31.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.

    -

    30.3.1 Running SWIG from Developer Studio

    +

    31.3.1 Running SWIG from Developer Studio

    @@ -700,7 +700,7 @@ print "$a\n"; -

    30.3.2 Using other compilers

    +

    31.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.

    -

    30.4 The low-level interface

    +

    31.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.

    -

    30.4.1 Functions

    +

    31.4.1 Functions

    @@ -741,7 +741,7 @@ use example; $a = &example::fact(2); -

    30.4.2 Global variables

    +

    31.4.2 Global variables

    @@ -811,7 +811,7 @@ extern char *path; // Declared later in the input -

    30.4.3 Constants

    +

    31.4.3 Constants

    @@ -851,7 +851,7 @@ print example::FOO,"\n"; -

    30.4.4 Pointers

    +

    31.4.4 Pointers

    @@ -960,7 +960,7 @@ as XS and xsubpp. Given the advancement of the SWIG typesystem and the SWIG and XS, this is no longer supported.

    -

    30.4.5 Structures

    +

    31.4.5 Structures

    @@ -1094,7 +1094,7 @@ void Bar_f_set(Bar *b, Foo *val) { -

    30.4.6 C++ classes

    +

    31.4.6 C++ classes

    @@ -1159,7 +1159,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.

    -

    30.4.7 C++ classes and type-checking

    +

    31.4.7 C++ classes and type-checking

    @@ -1195,7 +1195,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece multiple inheritance is used).

    -

    30.4.8 C++ overloaded functions

    +

    31.4.8 C++ overloaded functions

    @@ -1239,7 +1239,7 @@ example::Spam_foo_d($s,3.14); Please refer to the "SWIG Basics" chapter for more information.

    -

    30.4.9 Operators

    +

    31.4.9 Operators

    @@ -1266,7 +1266,7 @@ The following C++ operators are currently supported by the Perl module:

  • operator or
  • -

    30.4.10 Modules and packages

    +

    31.4.10 Modules and packages

    @@ -1361,7 +1361,7 @@ print Foo::fact(4),"\n"; # Call a function in package FooBar --> -

    30.5 Input and output parameters

    +

    31.5 Input and output parameters

    @@ -1580,7 +1580,7 @@ print "$c\n"; Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).

    -

    30.6 Exception handling

    +

    31.6 Exception handling

    @@ -1745,7 +1745,7 @@ This is still supported, but it is deprecated. The newer %exception di functionality, but it has additional capabilities that make it more powerful.

    -

    30.7 Remapping datatypes with typemaps

    +

    31.7 Remapping datatypes with typemaps

    @@ -1762,7 +1762,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Perl interface.

    -

    30.7.1 A simple typemap example

    +

    31.7.1 A simple typemap example

    @@ -1866,7 +1866,7 @@ example::count("e","Hello World"); -

    30.7.2 Perl5 typemaps

    +

    31.7.2 Perl5 typemaps

    @@ -1971,7 +1971,7 @@ Return of C++ member data (all languages). Check value of input parameter. -

    30.7.3 Typemap variables

    +

    31.7.3 Typemap variables

    @@ -2042,7 +2042,7 @@ properly assigned. The Perl name of the wrapper function being created. -

    30.7.4 Useful functions

    +

    31.7.4 Useful functions

    @@ -2111,7 +2111,7 @@ int sv_isa(SV *, char *0; -

    30.8 Typemap Examples

    +

    31.8 Typemap Examples

    @@ -2120,7 +2120,7 @@ might look at the files "perl5.swg" and "typemaps.i" in the SWIG library.

    -

    30.8.1 Converting a Perl5 array to a char **

    +

    31.8.1 Converting a Perl5 array to a char **

    @@ -2212,7 +2212,7 @@ print @$b,"\n"; # Print it out -

    30.8.2 Return values

    +

    31.8.2 Return values

    @@ -2241,7 +2241,7 @@ can be done using the EXTEND() macro as in : } -

    30.8.3 Returning values from arguments

    +

    31.8.3 Returning values from arguments

    @@ -2295,7 +2295,7 @@ print "multout(7,13) = @r\n"; ($x,$y) = multout(7,13); -

    30.8.4 Accessing array structure members

    +

    31.8.4 Accessing array structure members

    @@ -2358,7 +2358,7 @@ the "in" typemap in the previous section would be used to convert an to copy the converted array into a C data structure.

    -

    30.8.5 Turning Perl references into C pointers

    +

    31.8.5 Turning Perl references into C pointers

    @@ -2423,7 +2423,7 @@ print "$c\n"; -

    30.8.6 Pointer handling

    +

    31.8.6 Pointer handling

    @@ -2502,7 +2502,7 @@ For example: -

    30.9 Proxy classes

    +

    31.9 Proxy classes

    @@ -2518,7 +2518,7 @@ to the underlying code. This section describes the implementation details of the proxy interface.

    -

    30.9.1 Preliminaries

    +

    31.9.1 Preliminaries

    @@ -2540,7 +2540,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.

    -

    30.9.2 Structure and class wrappers

    +

    31.9.2 Structure and class wrappers

    @@ -2666,7 +2666,7 @@ $v->DESTROY(); -

    30.9.3 Object Ownership

    +

    31.9.3 Object Ownership

    @@ -2753,7 +2753,7 @@ counting, garbage collection, or advanced features one might find in sophisticated languages.

    -

    30.9.4 Nested Objects

    +

    31.9.4 Nested Objects

    @@ -2806,7 +2806,7 @@ $p->{f}->{x} = 0.0; %${$p->{v}} = ( x=>0, y=>0, z=>0); -

    30.9.5 Proxy Functions

    +

    31.9.5 Proxy Functions

    @@ -2840,7 +2840,7 @@ This function replaces the original function, but operates in an identical manner.

    -

    30.9.6 Inheritance

    +

    31.9.6 Inheritance

    @@ -2916,7 +2916,7 @@ particular, inheritance of data members is extremely tricky (and I'm not even sure if it really works).

    -

    30.9.7 Modifying the proxy methods

    +

    31.9.7 Modifying the proxy methods

    @@ -2944,7 +2944,7 @@ public: }; -

    30.10 Adding additional Perl code

    +

    31.10 Adding additional Perl code

    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 38a24bf2c..19ace7192 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -7,7 +7,7 @@ -

    31 SWIG and PHP

    +

    32 SWIG and PHP

      @@ -79,7 +79,7 @@ your extension into php directly, you will need the complete PHP source tree available.

      -

      31.1 Generating PHP Extensions

      +

      32.1 Generating PHP Extensions

      @@ -126,7 +126,7 @@ and it doesn't play nicely with package system. We don't recommend this approach, or provide explicit support for it.

      -

      31.1.1 Building a loadable extension

      +

      32.1.1 Building a loadable extension

      @@ -141,7 +141,7 @@ least work for Linux though): gcc -shared example_wrap.o -o example.so

    -

    31.1.2 Using PHP Extensions

    +

    32.1.2 Using PHP Extensions

    @@ -172,7 +172,7 @@ attempts to do the dl() call for you: include("example.php"); -

    31.2 Basic PHP interface

    +

    32.2 Basic PHP interface

    @@ -183,7 +183,7 @@ other symbols unless care is taken to %rename them. At present SWIG doesn't have support for the namespace feature added in PHP 5.3.

    -

    31.2.1 Constants

    +

    32.2.1 Constants

    @@ -260,7 +260,7 @@ is treated as true by the if test, when the value of the intended constant would be treated as false!

    -

    31.2.2 Global Variables

    +

    32.2.2 Global Variables

    @@ -309,7 +309,7 @@ undefined. At this time SWIG does not support custom accessor methods.

    -

    31.2.3 Functions

    +

    32.2.3 Functions

    @@ -362,7 +362,7 @@ print $s; # The value of $s was not changed. --> -

    31.2.4 Overloading

    +

    32.2.4 Overloading

    @@ -418,7 +418,7 @@ taking the integer argument.

    --> -

    31.2.5 Pointers and References

    +

    32.2.5 Pointers and References

    @@ -550,7 +550,7 @@ PHP in a number of ways: by using unset on an existing variable, or assigning NULL to a variable.

    -

    31.2.6 Structures and C++ classes

    +

    32.2.6 Structures and C++ classes

    @@ -611,7 +611,7 @@ Would be used in the following way from PHP5: Member variables and methods are accessed using the -> operator.

    -

    31.2.6.1 Using -noproxy

    +

    32.2.6.1 Using -noproxy

    @@ -637,7 +637,7 @@ Complex_im_set($obj,$d); Complex_im_get($obj); -

    31.2.6.2 Constructors and Destructors

    +

    32.2.6.2 Constructors and Destructors

    @@ -678,7 +678,7 @@ the programmer can either reassign the variable or call unset($v)

    -

    31.2.6.3 Static Member Variables

    +

    32.2.6.3 Static Member Variables

    @@ -721,7 +721,7 @@ Ko::threats(10); echo "There has now been " . Ko::threats() . " threats\n"; -

    31.2.6.4 Static Member Functions

    +

    32.2.6.4 Static Member Functions

    @@ -743,7 +743,7 @@ Ko::threats(); -

    31.2.7 PHP Pragmas, Startup and Shutdown code

    +

    32.2.7 PHP Pragmas, Startup and Shutdown code

    @@ -831,7 +831,7 @@ The %rinit and %rshutdown statements are very similar but inse into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.

    -

    31.3 Cross language polymorphism

    +

    32.3 Cross language polymorphism

    @@ -866,7 +866,7 @@ wrapper functions takes care of all the cross-language method routing transparently.

    -

    31.3.1 Enabling directors

    +

    32.3.1 Enabling directors

    @@ -958,7 +958,7 @@ class MyFoo extends Foo { -

    31.3.2 Director classes

    +

    32.3.2 Director classes

    @@ -1038,7 +1038,7 @@ so there is no need for the extra overhead involved with routing the calls through PHP.

    -

    31.3.3 Ownership and object destruction

    +

    32.3.3 Ownership and object destruction

    @@ -1094,7 +1094,7 @@ In this example, we are assuming that FooContainer will take care of deleting all the Foo pointers it contains at some point.

    -

    31.3.4 Exception unrolling

    +

    32.3.4 Exception unrolling

    @@ -1153,7 +1153,7 @@ Swig::DirectorMethodException is thrown, PHP will register the exception as soon as the C wrapper function returns.

    -

    31.3.5 Overhead and code bloat

    +

    32.3.5 Overhead and code bloat

    @@ -1186,7 +1186,7 @@ optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in PHP.

    -

    31.3.6 Typemaps

    +

    32.3.6 Typemaps

    @@ -1200,7 +1200,7 @@ need to be supported.

    -

    31.3.7 Miscellaneous

    +

    32.3.7 Miscellaneous

    Director typemaps for STL classes are mostly in place, and hence you diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html index 8bd6b410f..8c1eb2d36 100644 --- a/Doc/Manual/Pike.html +++ b/Doc/Manual/Pike.html @@ -6,7 +6,7 @@ -

    32 SWIG and Pike

    +

    33 SWIG and Pike

      @@ -46,10 +46,10 @@ least, make sure you read the "SWIG Basics" chapter.

      -

      32.1 Preliminaries

      +

      33.1 Preliminaries

      -

      32.1.1 Running SWIG

      +

      33.1.1 Running SWIG

      @@ -94,7 +94,7 @@ can use the -o option:

      $ swig -pike -o pseudonym.c example.i
      -

      32.1.2 Getting the right header files

      +

      33.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.

      -

      32.1.3 Using your module

      +

      33.1.3 Using your module

      @@ -129,10 +129,10 @@ Pike v7.4 release 10 running Hilfe v3.5 (Incremental Pike Frontend) (1) Result: 24

    -

    32.2 Basic C/C++ Mapping

    +

    33.2 Basic C/C++ Mapping

    -

    32.2.1 Modules

    +

    33.2.1 Modules

    @@ -143,7 +143,7 @@ concerned), SWIG's %module directive doesn't really have any significance.

    -

    32.2.2 Functions

    +

    33.2.2 Functions

    @@ -168,7 +168,7 @@ exactly as you'd expect it to: (1) Result: 24 -

    32.2.3 Global variables

    +

    33.2.3 Global variables

    @@ -197,7 +197,7 @@ will result in two functions, Foo_get() and Foo_set(): (3) Result: 3.141590 -

    32.2.4 Constants and enumerated types

    +

    33.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.

    -

    32.2.5 Constructors and Destructors

    +

    33.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.

    -

    32.2.6 Static Members

    +

    33.2.6 Static Members

    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 16058b7f6..a9a9bc44e 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6,7 +6,7 @@ -

    33 SWIG and Python

    +

    34 SWIG and Python

      @@ -135,7 +135,7 @@ very least, make sure you read the "SWIG Basics" chapter.

      -

      33.1 Overview

      +

      34.1 Overview

      @@ -162,10 +162,10 @@ described followed by a discussion of low-level implementation details.

      -

      33.2 Preliminaries

      +

      34.2 Preliminaries

      -

      33.2.1 Running SWIG

      +

      34.2.1 Running SWIG

      @@ -263,7 +263,7 @@ The following sections have further practical examples and details on how you might go about compiling and using the generated files.

      -

      33.2.2 Using distutils

      +

      34.2.2 Using distutils

      @@ -355,7 +355,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)

      -

      33.2.3 Hand compiling a dynamic module

      +

      34.2.3 Hand compiling a dynamic module

      @@ -403,7 +403,7 @@ module actually consists of two files; socket.py and

      -

      33.2.4 Static linking

      +

      34.2.4 Static linking

      @@ -482,7 +482,7 @@ If using static linking, you might want to rely on a different approach (perhaps using distutils).

      -

      33.2.5 Using your module

      +

      34.2.5 Using your module

      @@ -639,7 +639,7 @@ system configuration (this requires root access and you will need to read the man pages).

      -

      33.2.6 Compilation of C++ extensions

      +

      34.2.6 Compilation of C++ extensions

      @@ -731,7 +731,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.2.7 Compiling for 64-bit platforms

      +

      34.2.7 Compiling for 64-bit platforms

      @@ -768,7 +768,7 @@ and -m64 allow you to choose the desired binary format for your python extension.

      -

      33.2.8 Building Python Extensions under Windows

      +

      34.2.8 Building Python Extensions under Windows

      @@ -877,7 +877,7 @@ SWIG Wiki.

      -

      33.3 A tour of basic C/C++ wrapping

      +

      34.3 A tour of basic C/C++ wrapping

      @@ -886,7 +886,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.

      -

      33.3.1 Modules

      +

      34.3.1 Modules

      @@ -899,7 +899,7 @@ module name, make sure you don't use the same name as a built-in Python command or standard module name.

      -

      33.3.2 Functions

      +

      34.3.2 Functions

      @@ -923,7 +923,7 @@ like you think it does: >>>

    -

    33.3.3 Global variables

    +

    34.3.3 Global variables

    @@ -1061,7 +1061,7 @@ that starts with a leading underscore. SWIG does not create cvar if there are no global variables in a module.

    -

    33.3.4 Constants and enums

    +

    34.3.4 Constants and enums

    @@ -1101,7 +1101,7 @@ other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

    -

    33.3.5 Pointers

    +

    34.3.5 Pointers

    @@ -1242,7 +1242,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

    +

    34.3.6 Structures

    @@ -1431,7 +1431,7 @@ everything works just like you would expect. For example: -

    33.3.7 C++ classes

    +

    34.3.7 C++ classes

    @@ -1520,7 +1520,7 @@ they are accessed through cvar like this: -

    33.3.8 C++ inheritance

    +

    34.3.8 C++ inheritance

    @@ -1575,7 +1575,7 @@ then the function spam() accepts Foo * or a pointer to any cla It is safe to use multiple inheritance with SWIG.

    -

    33.3.9 Pointers, references, values, and arrays

    +

    34.3.9 Pointers, references, values, and arrays

    @@ -1636,7 +1636,7 @@ treated as a returning value, and it will follow the same allocation/deallocation process.

    -

    33.3.10 C++ overloaded functions

    +

    34.3.10 C++ overloaded functions

    @@ -1759,7 +1759,7 @@ first declaration takes precedence. Please refer to the "SWIG and C++" chapter for more information about overloading.

    -

    33.3.11 C++ operators

    +

    34.3.11 C++ operators

    @@ -1848,7 +1848,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.

    -

    33.3.12 C++ namespaces

    +

    34.3.12 C++ namespaces

    @@ -1915,7 +1915,7 @@ utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

    -

    33.3.13 C++ templates

    +

    34.3.13 C++ templates

    @@ -1969,7 +1969,7 @@ Some more complicated examples will appear later.

    -

    33.3.14 C++ Smart Pointers

    +

    34.3.14 C++ Smart Pointers

    @@ -2053,7 +2053,7 @@ simply use the __deref__() method. For example: -

    33.3.15 C++ reference counted objects

    +

    34.3.15 C++ reference counted objects

    @@ -2062,7 +2062,7 @@ Python examples of memory management using referencing counting.

    -

    33.4 Further details on the Python class interface

    +

    34.4 Further details on the Python class interface

    @@ -2085,7 +2085,7 @@ the -builtin option are in the Built-in section.

    -

    33.4.1 Proxy classes

    +

    34.4.1 Proxy classes

    @@ -2174,7 +2174,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).

    -

    33.4.2 Built-in Types

    +

    34.4.2 Built-in Types

    @@ -2218,7 +2218,7 @@ please refer to the python documentation:

    http://docs.python.org/extending/newtypes.html

    -

    33.4.2.1 Limitations

    +

    34.4.2.1 Limitations

    Use of the -builtin option implies a couple of limitations: @@ -2386,7 +2386,7 @@ assert(issubclass(B.Derived, A.Base)) -

    33.4.2.2 Operator overloads -- use them!

    +

    34.4.2.2 Operator overloads -- use them!

    The entire justification for the -builtin option is improved @@ -2487,7 +2487,7 @@ structs.

    -

    33.4.3 Memory management

    +

    34.4.3 Memory management

    NOTE: Although this section refers to proxy objects, everything here also applies @@ -2682,7 +2682,7 @@ It is also possible to deal with situations like this using typemaps--an advanced topic discussed later.

    -

    33.4.4 Python 2.2 and classic classes

    +

    34.4.4 Python 2.2 and classic classes

    @@ -2719,7 +2719,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).

    -

    33.5 Cross language polymorphism

    +

    34.5 Cross language polymorphism

    @@ -2753,7 +2753,7 @@ proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

    -

    33.5.1 Enabling directors

    +

    34.5.1 Enabling directors

    @@ -2846,7 +2846,7 @@ class MyFoo(mymodule.Foo): -

    33.5.2 Director classes

    +

    34.5.2 Director classes

    @@ -2928,7 +2928,7 @@ so there is no need for the extra overhead involved with routing the calls through Python.

    -

    33.5.3 Ownership and object destruction

    +

    34.5.3 Ownership and object destruction

    @@ -2995,7 +2995,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard references to the Foo objects remain in Python.

    -

    33.5.4 Exception unrolling

    +

    34.5.4 Exception unrolling

    @@ -3054,7 +3054,7 @@ Swig::DirectorMethodException is thrown, Python will register the exception as soon as the C wrapper function returns.

    -

    33.5.5 Overhead and code bloat

    +

    34.5.5 Overhead and code bloat

    @@ -3088,7 +3088,7 @@ directive) for only those methods that are likely to be extended in Python.

    -

    33.5.6 Typemaps

    +

    34.5.6 Typemaps

    @@ -3102,7 +3102,7 @@ need to be supported.

    -

    33.5.7 Miscellaneous

    +

    34.5.7 Miscellaneous

    @@ -3149,7 +3149,7 @@ methods that return const references.

    -

    33.6 Common customization features

    +

    34.6 Common customization features

    @@ -3162,7 +3162,7 @@ This section describes some common SWIG features that are used to improve your the interface to an extension module.

    -

    33.6.1 C/C++ helper functions

    +

    34.6.1 C/C++ helper functions

    @@ -3243,7 +3243,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps, customization features as covered in later sections.

    -

    33.6.2 Adding additional Python code

    +

    34.6.2 Adding additional Python code

    @@ -3392,7 +3392,7 @@ public: -

    33.6.3 Class extension with %extend

    +

    34.6.3 Class extension with %extend

    @@ -3481,7 +3481,7 @@ Vector(12,14,16) in any way---the extensions only show up in the Python interface.

    -

    33.6.4 Exception handling with %exception

    +

    34.6.4 Exception handling with %exception

    @@ -3607,7 +3607,7 @@ The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

    -

    33.7 Tips and techniques

    +

    34.7 Tips and techniques

    @@ -3617,7 +3617,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques solving these problems.

    -

    33.7.1 Input and output parameters

    +

    34.7.1 Input and output parameters

    @@ -3830,7 +3830,7 @@ void foo(Bar *OUTPUT); may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

    -

    33.7.2 Simple pointers

    +

    34.7.2 Simple pointers

    @@ -3899,7 +3899,7 @@ If you replace %pointer_functions() by %pointer_class(type,name)SWIG Library chapter for further details.

    -

    33.7.3 Unbounded C Arrays

    +

    34.7.3 Unbounded C Arrays

    @@ -3961,7 +3961,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

    -

    33.7.4 String handling

    +

    34.7.4 String handling

    @@ -4030,7 +4030,7 @@ If you need to return binary data, you might use the also be used to extra binary data from arbitrary pointers.

    -

    33.8 Typemaps

    +

    34.8 Typemaps

    @@ -4047,7 +4047,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.

    -

    33.8.1 What is a typemap?

    +

    34.8.1 What is a typemap?

    @@ -4163,7 +4163,7 @@ parameter is omitted): -

    33.8.2 Python typemaps

    +

    34.8.2 Python typemaps

    @@ -4204,7 +4204,7 @@ a look at the SWIG library version 1.3.20 or so.

    -

    33.8.3 Typemap variables

    +

    34.8.3 Typemap variables

    @@ -4275,7 +4275,7 @@ properly assigned. The Python name of the wrapper function being created. -

    33.8.4 Useful Python Functions

    +

    34.8.4 Useful Python Functions

    @@ -4403,7 +4403,7 @@ write me -

    33.9 Typemap Examples

    +

    34.9 Typemap Examples

    @@ -4412,7 +4412,7 @@ might look at the files "python.swg" and "typemaps.i" in the SWIG library.

    -

    33.9.1 Converting Python list to a char **

    +

    34.9.1 Converting Python list to a char **

    @@ -4492,7 +4492,7 @@ memory allocation is used to allocate memory for the array, the the C function.

    -

    33.9.2 Expanding a Python object into multiple arguments

    +

    34.9.2 Expanding a Python object into multiple arguments

    @@ -4571,7 +4571,7 @@ to supply the argument count. This is automatically set by the typemap code. F -

    33.9.3 Using typemaps to return arguments

    +

    34.9.3 Using typemaps to return arguments

    @@ -4660,7 +4660,7 @@ function can now be used as follows: >>> -

    33.9.4 Mapping Python tuples into small arrays

    +

    34.9.4 Mapping Python tuples into small arrays

    @@ -4709,7 +4709,7 @@ array, such an approach would not be recommended for huge arrays, but for small structures, this approach works fine.

    -

    33.9.5 Mapping sequences to C arrays

    +

    34.9.5 Mapping sequences to C arrays

    @@ -4798,7 +4798,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) { -

    33.9.6 Pointer handling

    +

    34.9.6 Pointer handling

    @@ -4895,7 +4895,7 @@ class object (if applicable). -

    33.10 Docstring Features

    +

    34.10 Docstring Features

    @@ -4923,7 +4923,7 @@ of your users much simpler.

    -

    33.10.1 Module docstring

    +

    34.10.1 Module docstring

    @@ -4957,7 +4957,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." -

    33.10.2 %feature("autodoc")

    +

    34.10.2 %feature("autodoc")

    @@ -4985,7 +4985,7 @@ four levels for autodoc controlled by the value given to the feature, %feature("autodoc", "level"). The four values for level are covered in the following sub-sections. -

    33.10.2.1 %feature("autodoc", "0")

    +

    34.10.2.1 %feature("autodoc", "0")

    @@ -5014,7 +5014,7 @@ def function_name(*args, **kwargs): -

    33.10.2.2 %feature("autodoc", "1")

    +

    34.10.2.2 %feature("autodoc", "1")

    @@ -5039,7 +5039,7 @@ def function_name(*args, **kwargs): -

    33.10.2.3 %feature("autodoc", "2")

    +

    34.10.2.3 %feature("autodoc", "2")

    @@ -5099,7 +5099,7 @@ def function_name(*args, **kwargs): -

    33.10.2.4 %feature("autodoc", "3")

    +

    34.10.2.4 %feature("autodoc", "3")

    @@ -5124,7 +5124,7 @@ def function_name(*args, **kwargs): -

    33.10.2.5 %feature("autodoc", "docstring")

    +

    34.10.2.5 %feature("autodoc", "docstring")

    @@ -5143,7 +5143,7 @@ void GetPosition(int* OUTPUT, int* OUTPUT); -

    33.10.3 %feature("docstring")

    +

    34.10.3 %feature("docstring")

    @@ -5175,7 +5175,7 @@ with more than one line. -

    33.11 Python Packages

    +

    34.11 Python Packages

    @@ -5202,7 +5202,7 @@ and also in base class declarations, etc. if the package name is different than its own.

    -

    33.12 Python 3 Support

    +

    34.12 Python 3 Support

    @@ -5229,7 +5229,7 @@ The following are Python 3.0 new features that are currently supported by SWIG.

    -

    33.12.1 Function annotation

    +

    34.12.1 Function annotation

    @@ -5262,7 +5262,7 @@ For detailed usage of function annotation, see PEP 3107.

    -

    33.12.2 Buffer interface

    +

    34.12.2 Buffer interface

    @@ -5414,7 +5414,7 @@ modify the buffer. -

    33.12.3 Abstract base classes

    +

    34.12.3 Abstract base classes

    diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index e8cee6448..ceea32146 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -6,7 +6,7 @@ -

    34 SWIG and R

    +

    35 SWIG and R

      @@ -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

      +

      35.1 Bugs

      @@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:

    • C Array wrappings
    -

    34.2 Using R and SWIG

    +

    35.2 Using R and SWIG

    @@ -119,7 +119,7 @@ Without it, inheritance of wrapped objects may fail. These two files can be loaded in any order

    -

    34.3 Precompiling large R files

    +

    35.3 Precompiling large R files

    In cases where the R file is large, one make save a lot of loading @@ -137,7 +137,7 @@ will save a large amount of loading time. -

    34.4 General policy

    +

    35.4 General policy

    @@ -146,7 +146,7 @@ wrapping over the underlying functions and rely on the R type system to provide R syntax.

    -

    34.5 Language conventions

    +

    35.5 Language conventions

    @@ -155,7 +155,7 @@ and [ are overloaded to allow for R syntax (one based indices and slices)

    -

    34.6 C++ classes

    +

    35.6 C++ classes

    @@ -167,7 +167,7 @@ keep track of the pointer object which removes the necessity for a lot of the proxy class baggage you see in other languages.

    -

    34.7 Enumerations

    +

    35.7 Enumerations

    diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index f21e353ce..8cede1cf8 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -7,7 +7,7 @@ -

    35 SWIG and Ruby

    +

    36 SWIG and Ruby

      @@ -148,7 +148,7 @@ -

      35.1 Preliminaries

      +

      36.1 Preliminaries

      SWIG 1.3 is known to work with Ruby versions 1.6 and later. @@ -171,7 +171,7 @@ of Ruby.

      -

      35.1.1 Running SWIG

      +

      36.1.1 Running SWIG

      To build a Ruby module, run SWIG using the -ruby @@ -225,7 +225,7 @@ to compile this file and link it with the rest of your program.

      -

      35.1.2 Getting the right header files

      +

      36.1.2 Getting the right header files

      In order to compile the wrapper code, the compiler needs the ruby.h @@ -274,7 +274,7 @@ installed, you can run Ruby to find out. For example:

      -

      35.1.3 Compiling a dynamic module

      +

      36.1.3 Compiling a dynamic module

      Ruby extension modules are typically compiled into shared @@ -428,7 +428,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.

      -

      35.1.4 Using your module

      +

      36.1.4 Using your module

      Ruby module names must be capitalized, @@ -488,7 +488,7 @@ begins with:

      -

      35.1.5 Static linking

      +

      36.1.5 Static linking

      An alternative approach to dynamic linking is to rebuild the @@ -509,7 +509,7 @@ finally rebuilding Ruby.

      -

      35.1.6 Compilation of C++ extensions

      +

      36.1.6 Compilation of C++ extensions

      On most machines, C++ extension modules should be linked @@ -561,7 +561,7 @@ extension, e.g.

      -

      35.2 Building Ruby Extensions under Windows 95/NT

      +

      36.2 Building Ruby Extensions under Windows 95/NT

      Building a SWIG extension to Ruby under Windows 95/NT is @@ -600,7 +600,7 @@ files.

      -

      35.2.1 Running SWIG from Developer Studio

      +

      36.2.1 Running SWIG from Developer Studio

      If you are developing your application within Microsoft @@ -742,7 +742,7 @@ directory, then run the Ruby script from the DOS/Command prompt:

      -

      35.3 The Ruby-to-C/C++ Mapping

      +

      36.3 The Ruby-to-C/C++ Mapping

      This section describes the basics of how SWIG maps C or C++ @@ -752,7 +752,7 @@ declarations in your SWIG interface files to Ruby constructs.

      -

      35.3.1 Modules

      +

      36.3.1 Modules

      The SWIG %module directive specifies @@ -921,7 +921,7 @@ Ruby's built-in names.

      -

      35.3.2 Functions

      +

      36.3.2 Functions

      Global functions are wrapped as Ruby module methods. For @@ -984,7 +984,7 @@ module that can be used like so:

      -

      35.3.3 Variable Linking

      +

      36.3.3 Variable Linking

      C/C++ global variables are wrapped as a pair of singleton @@ -1084,7 +1084,7 @@ effect until it is explicitly disabled using %mutable. -

      35.3.4 Constants

      +

      36.3.4 Constants

      C/C++ constants are wrapped as module constants initialized @@ -1128,7 +1128,7 @@ constant values, e.g.

      -

      35.3.5 Pointers

      +

      36.3.5 Pointers

      "Opaque" pointers to arbitrary C/C++ types (i.e. types that @@ -1180,7 +1180,7 @@ the Ruby nil object.

      -

      35.3.6 Structures

      +

      36.3.6 Structures

      C/C++ structs are wrapped as Ruby classes, with accessor @@ -1355,7 +1355,7 @@ pointers. For example,

      -

      35.3.7 C++ classes

      +

      36.3.7 C++ classes

      Like structs, C++ classes are wrapped by creating a new Ruby @@ -1441,7 +1441,7 @@ class. -

      35.3.8 C++ Inheritance

      +

      36.3.8 C++ Inheritance

      The SWIG type-checker is fully aware of C++ inheritance. @@ -1672,7 +1672,7 @@ Typing").

      -

      35.3.9 C++ Overloaded Functions

      +

      36.3.9 C++ Overloaded Functions

      C++ overloaded functions, methods, and constructors are @@ -1872,7 +1872,7 @@ and C++" chapter for more information about overloading.

      -

      35.3.10 C++ Operators

      +

      36.3.10 C++ Operators

      For the most part, overloaded operators are handled @@ -1953,7 +1953,7 @@ on operator overloading.

      -

      35.3.11 C++ namespaces

      +

      36.3.11 C++ namespaces

      SWIG is aware of C++ namespaces, but namespace names do not @@ -2029,7 +2029,7 @@ identical symbol names, well, then you get what you deserve.

      -

      35.3.12 C++ templates

      +

      36.3.12 C++ templates

      C++ templates don't present a huge problem for SWIG. However, @@ -2073,7 +2073,7 @@ directive. For example:

      -

      35.3.13 C++ Standard Template Library (STL)

      +

      36.3.13 C++ Standard Template Library (STL)

      On a related note, the standard SWIG library contains a @@ -2326,7 +2326,7 @@ chapter.

      -

      35.3.14 C++ STL Functors

      +

      36.3.14 C++ STL Functors

      Some containers in the STL allow you to modify their default @@ -2526,7 +2526,7 @@ b
      -

      35.3.15 C++ STL Iterators

      +

      36.3.15 C++ STL Iterators

      The STL is well known for the use of iterators.  There @@ -2737,7 +2737,7 @@ i
      -

      35.3.16 C++ Smart Pointers

      +

      36.3.16 C++ Smart Pointers

      In certain C++ programs, it is common to use classes that @@ -2862,7 +2862,7 @@ method. For example:

      -

      35.3.17 Cross-Language Polymorphism

      +

      36.3.17 Cross-Language Polymorphism

      SWIG's Ruby module supports cross-language polymorphism @@ -2875,7 +2875,7 @@ using this feature with Ruby.

      -

      35.3.17.1 Exception Unrolling

      +

      36.3.17.1 Exception Unrolling

      Whenever a C++ director class routes one of its virtual @@ -2913,7 +2913,7 @@ caught here and a C++ exception is raised in its place.

      -

      35.4 Naming

      +

      36.4 Naming

      Ruby has several common naming conventions. Constants are @@ -3009,7 +3009,7 @@ planned to become the default option in future releases.

      -

      35.4.1 Defining Aliases

      +

      36.4.1 Defining Aliases

      It's a fairly common practice in the Ruby built-ins and @@ -3101,7 +3101,7 @@ Features") for more details).

      -

      35.4.2 Predicate Methods

      +

      36.4.2 Predicate Methods

      Ruby methods that return a boolean value and end in a @@ -3190,7 +3190,7 @@ Features") for more details).

      -

      35.4.3 Bang Methods

      +

      36.4.3 Bang Methods

      Ruby methods that modify an object in-place and end in an @@ -3254,7 +3254,7 @@ Features") for more details).

      -

      35.4.4 Getters and Setters

      +

      36.4.4 Getters and Setters

      Often times a C++ library will expose properties through @@ -3324,7 +3324,7 @@ methods to be exposed in Ruby as value and value=. -

      35.5 Input and output parameters

      +

      36.5 Input and output parameters

      A common problem in some C programs is handling parameters @@ -3575,10 +3575,10 @@ of %apply

      -

      35.6 Exception handling

      +

      36.6 Exception handling

      -

      35.6.1 Using the %exception directive

      +

      36.6.1 Using the %exception directive

      The SWIG %exception directive can be @@ -3673,7 +3673,7 @@ Features for more examples.

      -

      35.6.2 Handling Ruby Blocks

      +

      36.6.2 Handling Ruby Blocks

      One of the highlights of Ruby and most of its standard library @@ -3854,7 +3854,7 @@ RUBY_YIELD_SELF );

      For more information on typemaps, see Typemaps.

      -

      35.6.3 Raising exceptions

      +

      36.6.3 Raising exceptions

      There are three ways to raise exceptions from C++ code to @@ -4615,7 +4615,7 @@ the built-in Ruby exception types.

      -

      35.6.4 Exception classes

      +

      36.6.4 Exception classes

      Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass @@ -4673,7 +4673,7 @@ providing for a more natural integration between C++ code and Ruby code.

      -

      35.7 Typemaps

      +

      36.7 Typemaps

      This section describes how you can modify SWIG's default @@ -4696,7 +4696,7 @@ of the primitive C-Ruby interface.

      -

      35.7.1 What is a typemap?

      +

      36.7.1 What is a typemap?

      A typemap is nothing more than a code generation rule that is @@ -4958,7 +4958,7 @@ to be used as follows (notice how the length parameter is omitted):

      -

      35.7.2 Typemap scope

      +

      36.7.2 Typemap scope

      Once defined, a typemap remains in effect for all of the @@ -5006,7 +5006,7 @@ where the class itself is defined. For example:

      -

      35.7.3 Copying a typemap

      +

      36.7.3 Copying a typemap

      A typemap is copied by using assignment. For example:

      @@ -5108,7 +5108,7 @@ rules as for -

      35.7.4 Deleting a typemap

      +

      36.7.4 Deleting a typemap

      A typemap can be deleted by simply defining no code. For @@ -5160,7 +5160,7 @@ typemaps immediately after the clear operation.

      -

      35.7.5 Placement of typemaps

      +

      36.7.5 Placement of typemaps

      Typemap declarations can be declared in the global scope, @@ -5244,7 +5244,7 @@ string -

      35.7.6 Ruby typemaps

      +

      36.7.6 Ruby typemaps

      The following list details all of the typemap methods that @@ -5254,7 +5254,7 @@ can be used by the Ruby module:

      -

      35.7.6.1  "in" typemap

      +

      36.7.6.1  "in" typemap

      Converts Ruby objects to input @@ -5497,7 +5497,7 @@ arguments to be specified. For example:

      -

      35.7.6.2 "typecheck" typemap

      +

      36.7.6.2 "typecheck" typemap

      The "typecheck" typemap is used to support overloaded @@ -5538,7 +5538,7 @@ on "Typemaps and Overloading."

      -

      35.7.6.3  "out" typemap

      +

      36.7.6.3  "out" typemap

      Converts return value of a C function @@ -5770,7 +5770,7 @@ version of the C datatype matched by the typemap. -

      35.7.6.4 "arginit" typemap

      +

      36.7.6.4 "arginit" typemap

      The "arginit" typemap is used to set the initial value of a @@ -5795,7 +5795,7 @@ applications. For example:

      -

      35.7.6.5 "default" typemap

      +

      36.7.6.5 "default" typemap

      The "default" typemap is used to turn an argument into a @@ -5837,7 +5837,7 @@ default argument wrapping.

      -

      35.7.6.6 "check" typemap

      +

      36.7.6.6 "check" typemap

      The "check" typemap is used to supply value checking code @@ -5861,7 +5861,7 @@ arguments have been converted. For example:

      -

      35.7.6.7 "argout" typemap

      +

      36.7.6.7 "argout" typemap

      The "argout" typemap is used to return values from arguments. @@ -6019,7 +6019,7 @@ some function like SWIG_Ruby_AppendOutput.

      -

      35.7.6.8 "freearg" typemap

      +

      36.7.6.8 "freearg" typemap

      The "freearg" typemap is used to cleanup argument data. It is @@ -6055,7 +6055,7 @@ abort prematurely.

      -

      35.7.6.9 "newfree" typemap

      +

      36.7.6.9 "newfree" typemap

      The "newfree" typemap is used in conjunction with the %newobject @@ -6086,7 +6086,7 @@ ownership and %newobject for further details.

      -

      35.7.6.10 "memberin" typemap

      +

      36.7.6.10 "memberin" typemap

      The "memberin" typemap is used to copy data from an @@ -6119,7 +6119,7 @@ other objects.

      -

      35.7.6.11 "varin" typemap

      +

      36.7.6.11 "varin" typemap

      The "varin" typemap is used to convert objects in the target @@ -6130,7 +6130,7 @@ This is implementation specific.

      -

      35.7.6.12 "varout" typemap

      +

      36.7.6.12 "varout" typemap

      The "varout" typemap is used to convert a C/C++ object to an @@ -6141,7 +6141,7 @@ This is implementation specific.

      -

      35.7.6.13 "throws" typemap

      +

      36.7.6.13 "throws" typemap

      The "throws" typemap is only used when SWIG parses a C++ @@ -6200,7 +6200,7 @@ handling with %exception section.

      -

      35.7.6.14 directorin typemap

      +

      36.7.6.14 directorin typemap

      Converts C++ objects in director @@ -6454,7 +6454,7 @@ referring to the class itself. -

      35.7.6.15 directorout typemap

      +

      36.7.6.15 directorout typemap

      Converts Ruby objects in director @@ -6714,7 +6714,7 @@ exception.
      -

      35.7.6.16 directorargout typemap

      +

      36.7.6.16 directorargout typemap

      Output argument processing in director @@ -6954,7 +6954,7 @@ referring to the instance of the class itself -

      35.7.6.17 ret typemap

      +

      36.7.6.17 ret typemap

      Cleanup of function return values @@ -6964,7 +6964,7 @@ referring to the instance of the class itself -

      35.7.6.18 globalin typemap

      +

      36.7.6.18 globalin typemap

      Setting of C global variables @@ -6974,7 +6974,7 @@ referring to the instance of the class itself -

      35.7.7 Typemap variables

      +

      36.7.7 Typemap variables

      @@ -7084,7 +7084,7 @@ being created.

    -

    35.7.8 Useful Functions

    +

    36.7.8 Useful Functions

    When you write a typemap, you usually have to work directly @@ -7108,7 +7108,7 @@ across multiple languages.

    -

    35.7.8.1 C Datatypes to Ruby Objects

    +

    36.7.8.1 C Datatypes to Ruby Objects

    @@ -7164,7 +7164,7 @@ SWIG_From_float(float) -

    35.7.8.2 Ruby Objects to C Datatypes

    +

    36.7.8.2 Ruby Objects to C Datatypes

    Here, while the Ruby versions return the value directly, the SWIG @@ -7253,7 +7253,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -

    35.7.8.3 Macros for VALUE

    +

    36.7.8.3 Macros for VALUE

    RSTRING_LEN(str)

    @@ -7316,7 +7316,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -

    35.7.8.4 Exceptions

    +

    36.7.8.4 Exceptions

    void rb_raise(VALUE exception, const char *fmt, @@ -7483,7 +7483,7 @@ arguments are interpreted as with printf().

    -

    35.7.8.5 Iterators

    +

    36.7.8.5 Iterators

    void rb_iter_break()

    @@ -7585,7 +7585,7 @@ VALUE), VALUE value)

    -

    35.7.9 Typemap Examples

    +

    36.7.9 Typemap Examples

    This section includes a few examples of typemaps. For more @@ -7596,7 +7596,7 @@ directory.

    -

    35.7.10 Converting a Ruby array to a char **

    +

    36.7.10 Converting a Ruby array to a char **

    A common problem in many C programs is the processing of @@ -7651,7 +7651,7 @@ after the execution of the C function.

    -

    35.7.11 Collecting arguments in a hash

    +

    36.7.11 Collecting arguments in a hash

    Ruby's solution to the "keyword arguments" capability of some @@ -7930,7 +7930,7 @@ directory of the SWIG distribution.

    -

    35.7.12 Pointer handling

    +

    36.7.12 Pointer handling

    Occasionally, it might be necessary to convert pointer values @@ -8029,7 +8029,7 @@ For example:

    -

    35.7.12.1 Ruby Datatype Wrapping

    +

    36.7.12.1 Ruby Datatype Wrapping

    VALUE Data_Wrap_Struct(VALUE class, void @@ -8080,7 +8080,7 @@ and assigns that pointer to ptr.

    -

    35.7.13 Example: STL Vector to Ruby Array

    +

    36.7.13 Example: STL Vector to Ruby Array

    Another use for macros and type maps is to create a Ruby array @@ -8189,7 +8189,7 @@ the C++ Standard Template Library.
    -

    35.8 Docstring Features

    +

    36.8 Docstring Features

    @@ -8250,7 +8250,7 @@ generate ri documentation from a c wrap file, you could do:

    -

    35.8.1 Module docstring

    +

    36.8.1 Module docstring

    @@ -8301,7 +8301,7 @@ macro. For example: -

    35.8.2 %feature("autodoc")

    +

    36.8.2 %feature("autodoc")

    Since SWIG does know everything about the function it wraps, @@ -8330,7 +8330,7 @@ feature, described below. -

    35.8.2.1 %feature("autodoc", "0")

    +

    36.8.2.1 %feature("autodoc", "0")

    @@ -8378,7 +8378,7 @@ Then Ruby code like this will be generated: -

    35.8.2.2 %feature("autodoc", "1")

    +

    36.8.2.2 %feature("autodoc", "1")

    @@ -8410,7 +8410,7 @@ this: -

    35.8.2.3 %feature("autodoc", "2")

    +

    36.8.2.3 %feature("autodoc", "2")

    @@ -8426,7 +8426,7 @@ this: -

    35.8.2.4 %feature("autodoc", "3")

    +

    36.8.2.4 %feature("autodoc", "3")

    @@ -8454,7 +8454,7 @@ this: -

    35.8.2.5 %feature("autodoc", "docstring")

    +

    36.8.2.5 %feature("autodoc", "docstring")

    @@ -8482,7 +8482,7 @@ generated string. For example: -

    35.8.3 %feature("docstring")

    +

    36.8.3 %feature("docstring")

    @@ -8497,10 +8497,10 @@ docstring and they are output together.

    -

    35.9 Advanced Topics

    +

    36.9 Advanced Topics

    -

    35.9.1 Operator overloading

    +

    36.9.1 Operator overloading

    SWIG allows operator overloading with, by using the %extend @@ -9517,7 +9517,7 @@ parses the expression a != b as !(a == b). -

    35.9.2 Creating Multi-Module Packages

    +

    36.9.2 Creating Multi-Module Packages

    The chapter on Working @@ -9698,7 +9698,7 @@ initialized:

    -

    35.9.3 Specifying Mixin Modules

    +

    36.9.3 Specifying Mixin Modules

    The Ruby language doesn't support multiple inheritance, but @@ -9796,7 +9796,7 @@ Features") for more details).

    -

    35.10 Memory Management

    +

    36.10 Memory Management

    One of the most common issues in generating SWIG bindings for @@ -9843,7 +9843,7 @@ understanding of how the underlying library manages memory.

    -

    35.10.1 Mark and Sweep Garbage Collector

    +

    36.10.1 Mark and Sweep Garbage Collector

    Ruby uses a mark and sweep garbage collector. When the garbage @@ -9891,7 +9891,7 @@ this memory.

    -

    35.10.2 Object Ownership

    +

    36.10.2 Object Ownership

    As described above, memory management depends on clearly @@ -10149,7 +10149,7 @@ public: -

    35.10.3 Object Tracking

    +

    36.10.3 Object Tracking

    The remaining parts of this section will use the class library @@ -10400,7 +10400,7 @@ methods.

    -

    35.10.4 Mark Functions

    +

    36.10.4 Mark Functions

    With a bit more testing, we see that our class library still @@ -10518,7 +10518,7 @@ test suite.

    -

    35.10.5 Free Functions

    +

    36.10.5 Free Functions

    By default, SWIG creates a "free" function that is called when @@ -10768,7 +10768,7 @@ been freed, and thus raises a runtime exception.

    -

    35.10.6 Embedded Ruby and the C++ Stack

    +

    36.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/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 44126dc4b..b4baca6ae 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -4761,9 +4761,6 @@ is passed to python, and it will always 'delete' the underlying object when python releases the proxy instance.

    -

    -

    -

    The %newobject feature is designed to indicate to the target language that it should take ownership of the returned object. diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 6f6f18bed..ebe6fa476 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -33,7 +33,8 @@ Last update : SWIG-2.0.5 (in progress)

    Language Module Documentation

      -
    • Allegro CL support
    • +
    • Allegro Common Lisp support
    • +
    • Android support
    • C# support
    • Chicken support
    • D support
    • @@ -43,7 +44,7 @@ Last update : SWIG-2.0.5 (in progress)
    • Common Lisp support
    • Lua support
    • Modula3 support
    • -
    • MzScheme support
    • +
    • MzScheme/Racket support
    • Ocaml support
    • Octave support
    • Perl5 support
    • diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index c677f6eed..f55a7f139 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -6,7 +6,7 @@ -

      36 SWIG and Tcl

      +

      37 SWIG and Tcl

        @@ -83,7 +83,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but this is no longer supported.

        -

        36.1 Preliminaries

        +

        37.1 Preliminaries

        @@ -109,7 +109,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.

        -

        36.1.1 Getting the right header files

        +

        37.1.1 Getting the right header files

        @@ -127,7 +127,7 @@ this is the case, you should probably make a symbolic link so that tcl.h -

        36.1.2 Compiling a dynamic module

        +

        37.1.2 Compiling a dynamic module

        @@ -162,7 +162,7 @@ The name of the module is specified using the %module directive or the -module command line option.

        -

        36.1.3 Static linking

        +

        37.1.3 Static linking

        @@ -228,7 +228,7 @@ minimal in most situations (and quite frankly not worth the extra hassle in the opinion of this author).

        -

        36.1.4 Using your module

        +

        37.1.4 Using your module

        @@ -356,7 +356,7 @@ to the default system configuration (this requires root access and you will need the man pages).

        -

        36.1.5 Compilation of C++ extensions

        +

        37.1.5 Compilation of C++ extensions

        @@ -439,7 +439,7 @@ erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

        -

        36.1.6 Compiling for 64-bit platforms

        +

        37.1.6 Compiling for 64-bit platforms

        @@ -466,7 +466,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

        -

        36.1.7 Setting a package prefix

        +

        37.1.7 Setting a package prefix

        @@ -485,7 +485,7 @@ option will append the prefix to the name when creating a command and call it "Foo_bar".

        -

        36.1.8 Using namespaces

        +

        37.1.8 Using namespaces

        @@ -507,7 +507,7 @@ When the -namespace option is used, objects in the module are always accessed with the namespace name such as Foo::bar.

        -

        36.2 Building Tcl/Tk Extensions under Windows 95/NT

        +

        37.2 Building Tcl/Tk Extensions under Windows 95/NT

        @@ -518,7 +518,7 @@ covers the process of using SWIG with Microsoft Visual C++. although the procedure may be similar with other compilers.

        -

        36.2.1 Running SWIG from Developer Studio

        +

        37.2.1 Running SWIG from Developer Studio

        @@ -576,7 +576,7 @@ MSDOS > tclsh80 %

      -

      36.2.2 Using NMAKE

      +

      37.2.2 Using NMAKE

      @@ -639,7 +639,7 @@ to get you started. With a little practice, you'll be making lots of Tcl extensions.

      -

      36.3 A tour of basic C/C++ wrapping

      +

      37.3 A tour of basic C/C++ wrapping

      @@ -650,7 +650,7 @@ classes. This section briefly covers the essential aspects of this wrapping.

      -

      36.3.1 Modules

      +

      37.3.1 Modules

      @@ -684,7 +684,7 @@ To fix this, supply an extra argument to load like this: -

      36.3.2 Functions

      +

      37.3.2 Functions

      @@ -709,7 +709,7 @@ like you think it does: % -

      36.3.3 Global variables

      +

      37.3.3 Global variables

      @@ -789,7 +789,7 @@ extern char *path; // Read-only (due to %immutable) -

      36.3.4 Constants and enums

      +

      37.3.4 Constants and enums

      @@ -873,7 +873,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.

      -

      36.3.5 Pointers

      +

      37.3.5 Pointers

      @@ -969,7 +969,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.

      -

      36.3.6 Structures

      +

      37.3.6 Structures

      @@ -1251,7 +1251,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the memory management section that appears shortly.

      -

      36.3.7 C++ classes

      +

      37.3.7 C++ classes

      @@ -1318,7 +1318,7 @@ In Tcl, the static member is accessed as follows: -

      36.3.8 C++ inheritance

      +

      37.3.8 C++ inheritance

      @@ -1367,7 +1367,7 @@ For instance: It is safe to use multiple inheritance with SWIG.

      -

      36.3.9 Pointers, references, values, and arrays

      +

      37.3.9 Pointers, references, values, and arrays

      @@ -1421,7 +1421,7 @@ to hold the result and a pointer is returned (Tcl will release this memory when the return value is garbage collected).

      -

      36.3.10 C++ overloaded functions

      +

      37.3.10 C++ overloaded functions

      @@ -1544,7 +1544,7 @@ first declaration takes precedence. Please refer to the "SWIG and C++" chapter for more information about overloading.

      -

      36.3.11 C++ operators

      +

      37.3.11 C++ operators

      @@ -1646,7 +1646,7 @@ There are ways to make this operator appear as part of the class using the % Keep reading.

      -

      36.3.12 C++ namespaces

      +

      37.3.12 C++ namespaces

      @@ -1710,7 +1710,7 @@ utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

      -

      36.3.13 C++ templates

      +

      37.3.13 C++ templates

      @@ -1762,7 +1762,7 @@ More details can be found in the SWIG and C++ -

      36.3.14 C++ Smart Pointers

      +

      37.3.14 C++ Smart Pointers

      @@ -1846,7 +1846,7 @@ simply use the __deref__() method. For example: -

      36.4 Further details on the Tcl class interface

      +

      37.4 Further details on the Tcl class interface

      @@ -1859,7 +1859,7 @@ of low-level details were omitted. This section provides a brief overview of how the proxy classes work.

      -

      36.4.1 Proxy classes

      +

      37.4.1 Proxy classes

      @@ -1924,7 +1924,7 @@ function. This allows objects to be encapsulated objects that look a lot like as shown in the last section.

      -

      36.4.2 Memory management

      +

      37.4.2 Memory management

      @@ -2112,7 +2112,7 @@ typemaps--an advanced topic discussed later.

      -

      36.5 Input and output parameters

      +

      37.5 Input and output parameters

      @@ -2300,7 +2300,7 @@ set c [lindex $dim 1] -

      36.6 Exception handling

      +

      37.6 Exception handling

      @@ -2434,7 +2434,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.

      -

      36.7 Typemaps

      +

      37.7 Typemaps

      @@ -2451,7 +2451,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Tcl interface.

      -

      36.7.1 What is a typemap?

      +

      37.7.1 What is a typemap?

      @@ -2568,7 +2568,7 @@ parameter is omitted): -

      36.7.2 Tcl typemaps

      +

      37.7.2 Tcl typemaps

      @@ -2706,7 +2706,7 @@ Initialize an argument to a value before any conversions occur. Examples of these methods will appear shortly.

      -

      36.7.3 Typemap variables

      +

      37.7.3 Typemap variables

      @@ -2777,7 +2777,7 @@ properly assigned. The Tcl name of the wrapper function being created. -

      36.7.4 Converting a Tcl list to a char **

      +

      37.7.4 Converting a Tcl list to a char **

      @@ -2839,7 +2839,7 @@ argv[2] = Larry 3 -

      36.7.5 Returning values in arguments

      +

      37.7.5 Returning values in arguments

      @@ -2881,7 +2881,7 @@ result, a Tcl function using these typemaps will work like this : % -

      36.7.6 Useful functions

      +

      37.7.6 Useful functions

      @@ -2958,7 +2958,7 @@ int Tcl_IsShared(Tcl_Obj *obj); -

      36.7.7 Standard typemaps

      +

      37.7.7 Standard typemaps

      @@ -3042,7 +3042,7 @@ work) -

      36.7.8 Pointer handling

      +

      37.7.8 Pointer handling

      @@ -3118,7 +3118,7 @@ For example: -

      36.8 Turning a SWIG module into a Tcl Package.

      +

      37.8 Turning a SWIG module into a Tcl Package.

      @@ -3190,7 +3190,7 @@ As a final note, most SWIG examples do not yet use the to use the load command instead.

      -

      36.9 Building new kinds of Tcl interfaces (in Tcl)

      +

      37.9 Building new kinds of Tcl interfaces (in Tcl)

      @@ -3289,7 +3289,7 @@ danger of blowing something up (although it is easily accomplished with an out of bounds array access).

      -

      36.9.1 Proxy classes

      +

      37.9.1 Proxy classes

      @@ -3410,7 +3410,7 @@ short, but clever Tcl script can be combined with SWIG to do many interesting things.

      -

      36.10 Tcl/Tk Stubs

      +

      37.10 Tcl/Tk Stubs

      diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 184062c42..b6e8cf3ce 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -73,6 +73,7 @@

    • Typemaps for multiple target languages
    • Optimal code generation when returning by value
    • Multi-argument typemaps +
    • Typemap warnings
    • Typemap fragments
      • Fragment type specialization @@ -3599,13 +3600,14 @@ the arguments to make them consecutive will need to be written.

        10.10 Typemap warnings

        +

        Warnings can be added to typemaps so that SWIG generates a warning message whenever the typemap is used. See the information in the issuing warnings section.

        -

        10.10 Typemap fragments

        +

        10.11 Typemap fragments

        @@ -3854,7 +3856,7 @@ fragment usage unless a desire to really get to grips with some powerful but tricky macro and fragment usage that is used in parts of the SWIG typemap library.

        -

        10.10.1 Fragment type specialization

        +

        10.11.1 Fragment type specialization

        @@ -3887,7 +3889,7 @@ struct A { -

        10.10.2 Fragments and automatic typemap specialization

        +

        10.11.2 Fragments and automatic typemap specialization

        @@ -3933,7 +3935,7 @@ The interested (or very brave) reader can take a look at the fragments.swg file

        -

        10.11 The run-time type checker

        +

        10.12 The run-time type checker

        @@ -3959,7 +3961,7 @@ language modules.

      • Modules can be unloaded from the type system.
      -

      10.11.1 Implementation

      +

      10.12.1 Implementation

      @@ -4145,7 +4147,7 @@ structures rather than creating new ones. These swig_module_info structures are chained together in a circularly linked list.

      -

      10.11.2 Usage

      +

      10.12.2 Usage

      This section covers how to use these functions from typemaps. To learn how to @@ -4239,7 +4241,7 @@ probably just look at the output of SWIG to get a better sense for how types are managed.

      -

      10.12 Typemaps and overloading

      +

      10.13 Typemaps and overloading

      @@ -4550,7 +4552,7 @@ Subsequent "in" typemaps would then perform more extensive type-checking.

    -

    10.13 More about %apply and %clear

    +

    10.14 More about %apply and %clear

    @@ -4636,7 +4638,7 @@ example: -

    10.14 Passing data between typemaps

    +

    10.15 Passing data between typemaps

    @@ -4673,7 +4675,7 @@ sure that the typemaps sharing information have exactly the same types and names

    -

    10.15 C++ "this" pointer

    +

    10.16 C++ "this" pointer

    @@ -4733,7 +4735,7 @@ will also match the typemap. One work around is to create an interface file tha the method, but gives the argument a name other than self.

    -

    10.16 Where to go for more information?

    +

    10.17 Where to go for more information?

    diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 924c8cfde..40e227164 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -15,6 +15,7 @@ Warnings.html Modules.html CCache.html Allegrocl.html +Android.html CSharp.html Chicken.html D.html From f571b357e7143130f3a788380d1f43cebf1a7b13 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 10 Dec 2011 17:03:50 +0000 Subject: [PATCH 115/147] Add Android docs - supporting screenshots git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12870 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/android-class.png | Bin 0 -> 14646 bytes Doc/Manual/android-simple.png | Bin 0 -> 7860 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Doc/Manual/android-class.png create mode 100644 Doc/Manual/android-simple.png diff --git a/Doc/Manual/android-class.png b/Doc/Manual/android-class.png new file mode 100644 index 0000000000000000000000000000000000000000..f7061cb3a32b4c22102c15c560a511b3da0f37ce GIT binary patch literal 14646 zcma*Oby(C-6feBX!ct2k9ZN`qODRY#jf8}NwB*u)bOxK3X8Bk^xv^LlyV1_42WHlodklq0<(TXM1>ue^xwynlc!G-J@b9C?fw zQAx>-+cF1LdlfBLl@XV7mywg(OmQEZvR#LfRxQ`^x68Y&NgY;99;d4=;QXj|NIRRr z4gxu0Cv-ab%JN5srztlyD#>=bLRZk4=%x6jx$RVBJ-XFe!mF3qOd%g%KF3y#WAT-B z^DWqCRWX%V7z8Ga16pnt215X=bJVDBPsc8Q zXFqYybe+~6Oyd3+<9o2SfyKRgWp-+RR%n^f5I-i=6 zjegzxJZNRkj5F=TE$a8HkY04RmtJMwrLE!8_i*!CjN5Ud_5O_hjW}YgGuYB?Shx`g z78(F^A(jmAYN^dG=j&`grCg%K6(Sz!PULsc`1`v-ED*+^c4fa%FJ{@*-;ebeuGkNl zo~JBb9ei`g7s7l)ZVV9o*4CDNm#^x3{Lx0V|76ZG+vny_-}%8}L~+hVny&IthA_z> z&duS>8^7CU-~L3Q#4&S!(I?^iH+}j2uKx0TjmZQ0*54vT-R~L?Tkj@SuCt$gUGBP- zkTa^=%WFtd98@gaD74^IER0YrY^czwclk5kV`%Bd;IjyUEr!gr9=KA>ca%z8bP&Mo z{8m8pU)ST6+5ss&H8q}B+r?v+L)Z#|>Tfm!Akn2}9RV0ykfmeLBN|Z;wU7rGJvjmb zuTCaZ8>W9K5a`$kUb!Fq{BVr|C@y8p24+8zX0+cKN%jT0DNpN(#?9E9>-m`)Q_1yW ziCb$KM%+zcY^Y!ah&96zO-B4^Jp2B}QjHWr97}dUAa*i}f+#r`@6ky&iRz@&aGLPn zsKP2vhYY>D+}C#fMo4Cs@@8^#79p;W3?#~+nG5w~O?|=0~kUeQJ{a}?AQr)i6-&61^{GFfq=9bs^1tAHUJupM9 z{(S>lSR3C>=HYwHkDvnjdGWG)dh_m{>!ow?QJy>PMBq`f|IfDL#A*eb-i-SZzdPrV zEV1RA&1Xc|myhC>Zx7swdiiG4dZK1fYow!V+|t(`eo6l;7?(UC4~lL^>tD=|7*dIlaR;F7}_mY8L}Y)zDs}Ggqw^jW(KHN35-Bv>GZ+=U(U2dkw zf!Vvt5CwRIGGoxfk>Ze9&m5IUVLt={#b zC1YXzk@CmJ{JGms0{g3I@lC6B)CMs+EqhIC*umRJ1A2Oa(yKV1tb4*A$-iDJ$&Ze2 zj3uU=seTjl%_K6p8k`poF^$a*$nSmKb~P1W0-H6}~aECL8R~JbsH^B@>ecsrBjGwAIK@=j zQn3BA6%RL}-EIC=>TY87`@+bZ**{IV%8f z$e@qj{ifm-f=B1HjmOA+R+j$ciNukcM9pei*HZmK+epg0q0-`PoIA;+Cdw5nYNL}p z^4sQshL#O(fsJ2}44eiY-y7kj;`*eBdh*Ez4DwBPgkIexeM^bqXXCIqLch?1P5ARwttu5=Mr$59VwsIMId3Y={2Ba6cBm5jWR$^ zwR8~*H7o~MZL5!}V^!mhd!G2dQ>;#pdxivNp>P?fcQmv1yElrO7b;cN-bBxP(*GR* z7>B=1AwsJtVNm_Hvt{g~^$bK~0ZK#5D|RE<98Pz?J)Oz+ySwBAtBwe*K?*dTGo8M( zr_@(il)=*`UW%v;4_Y~_w1pHzyc@krpnEJuFaQHgYvi2b+5)X%O@ju|UFRRd#R#6x zpN-C1V6)n1@Sk5SN63`OsL6N?!hpPS;V2I;nV-TwsEIP?Bg*-MfnYdMsO7eR$WiCM z1yjsF7pS!lJACgD5r?YOJG`l@swxFIa#*l0k2IT()yUv+1bu>&g<~hfH>l z-TrocCU(0w(e59J3I7V+@W%tK`Ud705-kZKJt`Vv5qr_RalJ9*khSFw(G{G8zug~I zp~EQ65i&KoQs05{X5NludWTU4jK2rtQsfi!t0(*Qy{Zd-|GRl@i4ep#vxWc1r|Uv& zEobsi>zdE*6?$vcA-VtQ-TDfqBW7jHvRE|7j6owwh8U;Uv_VsmyXzr|s;GY{ zK)`3E1LVQnd(7RT6Mel^r49qojU^v_vu@;yZw{z$Tcqj`%1PN>kkqd#J9J7A!bIGlbJ$&!}b2l6K6mOj4%~H0nMui`I8LD!G z)FBePbQ$?hH@a))=K*;mxdb*bLk>$ zQrMtk)ntQNIT>|#EZd2RD&vYqy1}z78s8^h(3Kj_D$Skl5PNm{@2oxN^Mc$+XYVZ4g$dVvHVf5{r0LhBqqVEHnu9EG-aV;GvUxT(|m&B1uM#z=V9$w5h8 zT=h9+q$cn7(ThO+;E>I4-e*zE{8>vr?+-6V>ltAB(_#o1X~MHa0x_4ZQKrytvDV$V z6{97Mwk6`gI68bWkF5_ZXm+u#F_aJtsA6vZS?K2Cmjm9wT!4(QWM)j^dwFhE(YXJb zzq2sy((zN^pq0HZV0ZVU>u>6VgrE@?&gT7bw}uxv^|4eQF>#^u9|vLY_-*kv+NK&& zi2g@9;5j|%j6Wtpf$zC6!+%6}Bs}0tt@sXCwcD?XUNT6t%undJXJdYT7#vyh%HSO1 z{6(m0-cf)oZb&`ez=in%CV}~)8CV)fw1Luy{_yRW5TxT=gP6cK_ZHi?Jq|KD|G@c=#i0F$TTEC9F52m#6jfz@BPQRsKL+2z5?OMZBp1A~+qay*=vw|!6dOFlo6OV}6&W|AP3 zc`@nP@D&rX5?ZXB$ye`fck|=V4@g1fL+wRX@#;J-S!11YYFz=?sBO~2i6Nk$h!&VDjbAjeOPI4A(`$LHogq(B|d zzecJnk)3<@{*x#CeYxypqx<`jB{5P3cIChDf5Whv*zA32F%x0pBByj(SSL2!5vK>yGxxPybz_y2wN0e3KL-kGl?l@ ziF$gNr_{PITDv@b-)6bI6+QNYX-=Gn$#QFNkBgf`0VD9@%&YE8Q!+Z!5ecH)D~xAP4Qhl8OzKMOvj`) zN5Z*_r7s3{vz9Xz(u@G4HCHG5+iGto=$J)}E9CS@9I(^mbGc zH$8601NrP;hjA$?1p%=P3@tyH5UY0Bpu`+nk8iRcoV_t@5u`5W`<;)d&3FuLWaiT= z+(XgNBy;TGF3}Jp^_8TKJKO7EU@tWo9?kb8_k7%FNZo^j%u~^uP|Z8H4!sd}*>3=% z#vI-Jwcka-&Gu<8Ut2tXgU}m%WUYCDy~G!`ff)uWke(bx!Na=auVAoR=>ev6$T z#o#64$H|d0zd+PM#98z5+>i4&;QZ~QNx2k!fZoZY7sT>l3Sht2keeK3GqV`KMKl zGSEAH1fVcj%D9BNH%)PhLr|a5IZ->o$~6e!6Plx~cM5*q0>6QQB3l>_AS=dzkvAA| zqc8M7UVJG2YNb5o`y2<;Vq$Bdxrw}hKuX4+h!PN-4`gl&pedD8`;yjc_hCqOO^kvi z5@@by@^|vLDt~)Fw-wmR0Bj7?qk3lv0OuDHz5Z80Z9SZ*uY3R*RgIb4N@A=cb>ulRv1hi*Vgr_LEa!NBc2i&$6-1ENZWbL;*Z*!PMoyB+_NwCVZM0* zcX+obH;}NjFroRQ#+T2Q76kURl)08r#8s-=uY4>|c1#hOXCxIqyz$N1==Vqw3VM#7Z_$Dxs{>XaSDw!f=CMKCxUogW8p z8pD*7>faj8^1(w1Enm=v;kWF(m6T;y_!#eu@x|V??rBpvY5qW%2ng~M24Bd``pl_^ zS(X^ULLWC_-LH6{u1{?!8$RaJErNN}a8zze8caV@w4Tq7RjMc%-%rTqz;j+rUfl1b zotvHCEVq4atZV4`ag!44E{aPM@Dw>`D52DAw9ORqf=$6q98r z$;7|VOo9zcLNpk0O>4!=@HU5k4iO#F7{5%e-&23&tNfVW-v%R>qYxSlRKuc;8hZgt zB9w81%AYzLjZ#|ak=gp5Rgnezj?Ymlwp%!4{pJW=B1&V1X!K9dyQCHX87pJ-0xyN0 zICsYbDjh>fZ1Q0#(|19^@5E}2r+v$%5uXx)GFA9h) zE+Y`8M7rq(i_L4b+FYUt3?Ih?q6n1226Hd_IMCBKlyxx9dQ9g~qjRBKMo*7opf#fF zZ{H=E(#@y+euXRNQrr8&(est?tP896jqnjdnr!OJTMQ;1J!x_*I~gLKG9Uyf-`vZAo_Vjal(fJ)k3@mkWp-ZH$YILup>T_=mZ2h%+IN%WHa_`{tTC66GOUWI6 zc;}VWDFxBEi<5w1etVp*PTG}Va7lZZjnaxud~UG0Y88R@snoY*JSg-Xsu&H^3~bNLg^WFiKY#~o$1q)A04D!C|93L&|q zm9my&D!;HCKORk0@FD9mYQX7-D&=F7>3kws2c1Do1jV#TnI~qaUM__#q70`GbIomv z#1f`}+rue9lZEUBRqpvE+;L8rpYuDQihMjpb;Eiubpp8$hxt#U%O04@J^5^UrDJ)Vrk`Uuj^1k1ynNAq;{Sc>>w-h_RX3Y@;~A+LvbdOe=uwW z3C_NEcpGDvgnyNerzxJ*#4VBvAvAo=@tR6)cosuZ?M=V(A*Ecth*3o8#KI1 zvq~Tb1(1^9*o1iv{Hbgjt3(x5lJ~?Juy_sq@3~hWL6w7m%3Rz@DFsD)c849+x3xT= zqlaV@aXoHA*f+e)meDi*AcXyIoyAv-9eN&Y<$I7cUc7b2(o7k-?M}LQE2!6|uP8!B z{@BgmbY}tCGMVWxy4+n=-}X4P=M%HVeozP11e~XaW}hY3?Rigve)gs44|9RY^?kIS z@rFN%=AwQ|(WL5I8DVGA&tvvvm_HM;M@&rYsA>$QggB=z@~XyB+9Myn9%}&R1}euz zoW*bFBzUx!+eIp9$O-q$&Kq_!Ae6frvHFR(M%Y>uua_gw;3#fZw-%87HRw{JnWT*5 zDZu1WAszKRg%{t6a}=CL&3grsBB0X}k9uA_PcD3QD@wn|zay*X=1(=zAPM1tbTPk1 zZmtt!=_AX-N(Au(*|maAC?|Aysy}ZfA4kq(lnxA8feI|hOL%>#3koKjVBk%% zT%yL@H+6xl>}HKWY18(o4`c=q%4UrU9BRqW{jCn9QK6i2Chlf9-tGeO#}+4v?l4S$)V~HnZVXl#oh(Alq`-RoglbgJHw4Rd~XrIOz06a@BmIXNC*a%Xp z3fyis0S~Y-DHXUd^#)D*2Oo8cevl!WH{K4!|hDRM(E zF_NqyeT#b7Pst|3djsa@cw!OQeahArfO1}%*S4H^{A~%AW|EiB$R>Zd`P0yKvlS)+ zX?h)Jbz-k?Yx6$kxYgszcve2Vw^^eP!Z>!K?lLix+_&T^$=pY?PI4SdAo*KOFa3QM z-%QAktK>Ekqwb3#bb|OL6m?FRXqx^jST)AMTXDsYT%d@qbNios9GBouq6>I-B}8Ft zkYR{nzvTnfe9HNmm(v7SK>(hTCFqm7pxg(ncNPGwI)B;Box}Qg*}vSVXaN}9!xI~n zAvUX_Mh%^Y0Q{BT>J~f;6j;`X^%}B%x!Mh|V=oaSR079hek2~?Trf9bR}f_IuaEm4 zRrIbqDPSIiqM3_Um-}Y^{)NFD3yG5C39s*HWLyqYQ7@4`jtz*}5g*Qa1}zduu>bs- zG)OK$brkWF$U*(9v67^{zqy;gRr^cnITmLnNprTIJt|Zeg6=PPdIKPvBr2v=cc<@9 zQ+06S*|^yU0=+72|8X<&bn7S2xKi9gur=Gl1FNs&Ce`cA2@Kc5xH0N5#>X)f&q@-x zF?cnk^jJIWZ#;SOGh>r@2>Ai|kK3Ezky80N%ODs9dKQo(SWdDH6SXoAJ_BA7stz6j zL`nr(0OWEzP@j()QzF%^{%vQS2cZ0OEzr%87!hPCN#reh(XBM9OnRi8m4utd8>|WD zh5_Gfd7~}`)OVp;960i^ZqwlnW>0=kgrReAXiT=By0tO>gG zLUccHP17`x)25!zMO7z!4J=7^k{sIn4d+Im@@Yh^>0>EFAIirvE^tH>z&8409V4^~ z0(VmsU4E~SXdP?QCYN>%jRGnwNm7Ay6tPSIpYBTOV#FqRlT1Hgf%x%)@NH$+m-=dT z3m$P2ZSD+eNZsQ1*VY&AJTQgwOwnMZajCS6y)Vtdj`}z_+#S6D0rgq#1h%Z2$zu%A z(EjK84s$>RkZX8Z`|4HXV zK6=z%e|PbeV(tO-O!Dp_4h2GiVxr@f+)*yXb}dUqPIpCajo zJxLmewj{b$;9hrUA}uKZ3xQ1qg3|dp8=qEsi4}Qv@=> zmT`w8T!Dxu{KBlZvVdK*IrXoV<9Pw90sANcW9g9h<0Fs(NXrM*@S#w%@_?F}2P5!L zy>LB%>j7-w!3S{t-#$a_q|4H{*Oy-leig~6wU?q_iNmrXO`&5^REQbTj87Pdt{znX85R)jRz@VJx91U^e1qo|Fd%1>R5qjj03%6oFFLL#S`KkYt8 zq;$5El=CJn?omkiSAJwIj${bKs!m(ny=_WsCdc*D5PN#t)_9;fh*`i)L>ru9RsRLI zj3~FgCIE4vVEqMQt8hKLEMQVVwLfN*kh(ZeoIv?2n~Nxva^(E4{a$ zB12ecRNkILy&!D**&M*d5C*JZ3~dhVcwVCp9=$@PKDW3{gyLEtqcx}0sY50XmYv_C zhHGEwv}%J#BlnfL2HyV_!UsFLtHoztA#`OI+e zZGBL%@iQIr63>;}YZ??r(lHT8ngCb-w14G;^v6gkbEL5xU39=iHNrNcrV)->hvw;P zuy`L#`z5tbIu&6A4(+JohsG+W65e-BT?*L4DZuVazl}qJGd$bU&)t@Q`BDMePz?Q0 z+KzYnT7|!2tdy3@_xzu#MQ@Hp#*v^LJB9GnFl_a)v7g4NB0ggyf~+kd%EYq3PcECX zj-v5!>XLOY)IsF1?>AxT2q4~+xq{<)5jB_RG)a*N`g0~9^d`+2ilTHFCDY9%H?}Cm z>Ln3vjEwxI+t`wX%A3=qz;k0dTNt1G4j(cdsEI*cP7Vz{hy}4J(!SN|Gr{8r0PW=L zs~Tu(C7a5P*D+CJ6zwwa0xJW7G+AFd5dhcLTw(l(M)c$NZ9;67OHN05sX(VNLl<`dUCvXplHvKT!q88SLcNl7cH z!)Z~NbCXZW2e|V#$uG+Lo1Z3(Wd?Xo^ih*~?6aETyd-)ekZK|xzAy@T&N%v#KnFF7 z)wnQx<|ogUqrMp7<3SZ|a69ZnaSEo@CF$7bSWucb26+PPnC95;h!rq6P<%{FT`hw&zhejogq0`3nM|?G zsn$E%U$_J!2LQZvfdVCv(Ui2{f|ITM>k_*|A)m`5AOM%cU*m$W|RCAQ}%zG-1j3&Y^Y6&8Lt zU2Pz0Vh;Tp;!Er zewiKC{12LAz1h44tL#}s*tA)ST7tJlvi@&f6iNdq+rz)|ArpZD&0=GfR{{uptbzXE zd>0VYt9W&=B61TO#Jzj%t$h}|tB@xw|EaTedB^DI_LqU0vwpqWlY`e|&1LR(=M=>G zU+}Z75QogQ;Fah$XsvziEEj2?ympWy{fs;II6ErRv&m zF%1M@*#4PJ?GDputT41?qkS_bTdbyUGtf?2P59*WxtG$L3f%O^oQlz=QwA6E1GfJ2 zbn@JiUcbwsg9@LkVA)oBhb(E90!Xjd7OX{0IGQS=PjmwI-pRZ#lv}Ei7+myeee!4* zNXh6)*1iMEklqWHSzM4ZS+409MfcWepJ5Bm``l-a(GCOt@T<< zhq67su*sbm0cz2MK+DPQCus&H9-S!;w;V`t)?PFC3=j?s0*V&1!nA#;o?5=hfi_E$XQ`S80}v&1DFt$(#j98|wR3lL*o&&FEVl%V>L zqWw5d5~(~Z{j`S^To#P4d+t=DcCMraNbgD z+tVe^$N;i^@oegnQ7XYz@707YgaHK z2l&y#L5G`7R_0bg{ExU-KpsX<)UEtIb)`xRTJZQDLUVH&6r>@Zdc;fq2Ayh4z~f`C9CW6B5*{} z32~9OOkegfpv2qvnf<;lZtV`OZem2ICX!h>2Aw1n9P&24ZqRGsF5>iNjo(HTiztZG zzL|+wH!MMgzzW4h)CONO6Uf9DlSE#RA3iHgq>jBLs1ERuj;74Y<&-M^kfmyVlFcAz zC-r(sQ%CqhqMN!R(sBN>yx6M7N-)hvwx}Lrou1onJV#hXoWDyum+)`!SY_wKV&d@k zg(ikil~~A``(>-~Z)Mj$V3xS|GrsWr{0lf7X)Q!9>AK9~S!W%xHxUo~nT9s*%B&tT zRJa`ur3}%yd6wgSgrtx?%JWeG*Cge8ny6F4XN<=Zj39N4uk^tMA=vVCCeJlZPhS0Y zT*L|0i%thtG`+B)`eLrB;zc-#v5v;SLhLsYPAsdakpvUV8A$1MBI>@9w`p_>`xH;g zX7HTq17js+du8m}Ww+!+L(#fUA?Iov5mnw1VqhZ6GGi}oBS<~4v?Fh3YuiS4Q^LP@ z?c(i@wP-Y4U9<^QL7lq? z%ehDjMDyJ`euZ)C7CZ)hedHAOnN{PpioWHy3<%R>v?+%Gc&zuL5Pu z$22*|>nv_ml}p}>y6!$f1xtzy%qtaM^6eaim!%a=Kbp4qVqQ>SO%myk2-78H)UE>w zx(d?YBFnbI+h8n(8}6XzH4-H9YRHB+!|{V@jzi_Ybsg;#z6>ipmqJBU1_laV z4+Ey1M4wRf^n~aMW?EBm=|v$x0`_DO2Z2uiw^qM)N8fz@0WkS4t0!yoMq#$lUdELG zo~~JmlIhudY?&*EQ;3R?DucxYDD5FqP|)qdAi+Yk*4nn9B!Xk}S3~ycZ$O!}UB_KJFE#q;pfdomrP$7?}63XiC)-1-%Pp8ZXDKrei^ry^fdh`G4 zHKvy)n%S2X@<^u(rwW~3?M)aH}f0U=kUP&ftl}*vuk79k&##G==9hPS1 zH(r;KLl#qZ3(4;L};Ou?HkoSPZLy`{cjbFVSJK22mqLg6UC1)>@(U!Kp_7y>hv+iQAZ%O`ZQlp zsjqB+DYtZ0W>S#vkw+dI+E_Ag;I~H1Co%)_<(%P+vAWH5!9~X!Sz~4Va3+z_De=Zt z=>_ahHphg@S{ZCja@r!of{*+I3}`!yQl}A@Q$bqQFI3F5$jVAh&A%mOFp={itzmu6 zUNahk`gtPv8nlSU!I*JGA7zHHq%hZ#kW18%fjX&wcj^qsb!xKaG4C$lL`pbZT{F^@ zPUR_mV+xQ9?EEvjw+wGh#`UhSN$H*UVOje-O*@-yg_4lB%*qkZ)Lo)#A85#&bBf$r z9115~Z7Mhb>;g$P0N+w9ErDjH`vQqK)(I}a(J=CF9 zaU!o%7}Y31R*K?YhV=sYvN^CvOrggb;&I88?dE_`ckXiCp!pwdWt8n3t>tJl5aWsQ zF#*p>Cz>)LlP0+X1CwyLi4yeH0LmTMLOpWGz1=9JVSK^|H(aXAgCVDY(?MModP~iD zwR4l>V}d&zWs*f4FG&rV_+OLCLWdb+x#mz)M=4t@QrVvV_uNEF7D@eM5W>Y~ZBj5y z>4-E`_u!aGYGRyM(33?o5Tcc#&?F~U#TE|dBTnXEO&Row0@`q($!hYB8!7#WBd3JU z;VFWd7?1ftsC#34l1AnLR7ReqzX#=bng<*715WcgXwz>POuJAS9ulh+%>~DoWW(oF zh#jgI{UnjKts!+g5H%WllP{|2+=;m3*B{dk1&8cY!YFdEjk;##b(VaBUOW*ZX8Y(C zrH)mC-kQYmeB8jz$1Ume5fwu4xs0K-qD`Q5CPy zradl;Rly+?=9)JP4+SHAf;JZADg1v*=bG5epuY}+!3|NAj;V^asZtGX17=`nL`m-S zCd2~9>6(mkCpaKuApmNJTCzJ=n-u7nxK;iyrUoRyvIAx8z)G63lUDfq|XvxP~|oR37GPoSR%dlxjc0}@c!C`d=R+& z_8-l^u@`SE&RUg}NhfS6uCZ+CoPGd$&>tRBP=`EiF>C~kSW;;RO%OXIk#2Y?TCg`R zB~JPXLWt9xNY}Fz-GvsjAVk0<(cg0pFyiqEvQBayiW#OQ^Pq{LXq0-3K;B$p{e^@o zq%{(SV$k(5$yLRoq?aw;nF5@rL!sYkmnkwCZXbh^neYjbT#f!t0>VlKS2P?g<}NHw zY26gupBn=Uur7V|r6IqkQ{<^3lVeFk~{hbmLa^u3N? z$;QLf{yYE^=l=>!h@AGnkkkL6vHm|pnE%IVs2(!P&>|2R8X_Mu5aSsTMIxT(4oQBN z$f}Yia9ulxN)cCNcj|Od6-Bb4B8w*uTg4;QqW7Q@=5%fLZ1I&ery)|O`X7*X1;S6} zfL-z`BgPoRci^64>@e<#rIZbY>G9!4 zvmq*ks748gw2FlA_NS7X@pi81V{uioVYpG2`IUwJ0Cb)xSnw9Hgsqw?*9``A=oDIW zf~@2WCKc-oMd)Z90ueLB)^%3dt=%lO8Tr7%ub`*{!MdW1o_ep0dYPe_X%ajw-mzX`p65(T93k~~;5k@JQwodbSVRSTTb zeN3sq5f&5+4z|YA5>|7%x*w-#&n54MsG)a@VPZM^6qcUr)O9NdXQX9ycGiZ}8nU1W zO(Ywo7!mTriDH=ybEfAxENU^GT!@Dt?N;JW1-RY+N&!@GVp#sn&3_BvAL@rPAWILa z2PSD|2l9S?u3tK4C>W34F!o>7mx1+}!XrjN(r$Ds(eJ7$(93gIa7!#_|=BzcpYp>Z64C zKV{$hN${y&H`pWORv|ZuN>^w{Sd8W#S}H2> zL_r*|%}Hhoz$p)hhtZ(24zfo7wbN{)=`tkgg!CAInb_B_m_1OJ`9x>=HDse*`~^lW zo2`WwjbY4AVyIbLqk=22dT+>}%e%1V#yvGlEN{(fuuRUgcR_^F)Yd$K>QSgzvRoK` z#PezSC|&?Pm_J_1fD$jt&lds#uNPRAmwo1s?wC~7EK@_(RS*a;uqMxcIH{ZEQ z375|D%ONXXfPfizDdEnm<+_vV`|@A+A37B+1^sqb`dP(Ku{{iE!ozZ{Jp9*5hZ5OZ zhB7vKd=E+K|A!7%tfw@Xi6u?!;nn(_i?2WrLvHZ*W_TnslG51ax0NsIN=c-q{~uCF zJ8MT|KmY+xz_@ S(;NWm?}hA3nJOvcfd2tY(DozT1V z5(piHKyrECciq2mKi&Co=B!yWd!F5%z1KNWI$AHNDVZq&006c6OBFo;fav;_D1n^# zdK&cM_W%Ic1JzX&4g4~8Gij3z4V$`Lp9Msp9WwH7{e|foBoK1D`S9;`XeDv1(pnG(;VUkK2Nl?N;IP$0 zJ5SFtJViXa&NueY%c@Ujd1#_eGr`d?3C_xNhEQdY_obYWI}Ba)nBjdoO>HHGTNf?+5`S`vpSOp;73Fdxq!W z(+wB|-=F%#j_mbMKllA2OOg6N#06fc&R7;Hdvre26Wjg;jvi}0{vqj=n5k;z3hU+e zsL?`DG?Xk%z({5vKZF*g%%(K+UxUJ29zr$b_J7@g;AR&c92{1CmyXs4lIj~x>3Lq& zFMknu&X!$Vyj2am+9|JF2r*@CZ4ZtVctxVyXWOy`_E9QnDP=Gc5%TcLi;5%Tw)fAht7 z1;P|ng+!iWEC?4;%?GhVLF-TS65n^`x~p>E12r#s(hFc^F>yGaO?dsD)5aUW#n0&} zu`vIh;{&_cNkHx~TOObaB21HQZZSSio*iHjd@|k&?@8iqG+pV6hew2`Wb+o(C#WHK&r(5(xv{S9Lji?wWqbQA?iABU;PB4c zNpr_QHG$R~Q+*!oR0!@bE^D{$^1S`a20iUF7`Zri?F5|YH%x}jK%Q8(va-TgS zCRN)uH=tCc<)D+rrvK;Bplri!v{@L;cfnscWgWnL+v&ov)Mz)_Y9LKQ@`IiO&Fw&+ zO#}AeW8J7SY#76@@HwAZXV<0^BP**FZODawm}5=+dP!MXjqm=oyK<@hPp9n`1NY>j z@H4fJDIykGxO`5vn1nYuxR6ORU%7*J`id6(#UcTJW`RFU(SClun#irmfOs7hD8AyK zG}wqoi1yV5*9Vv=VKW`$QoXmhdsfS=J$yVSGOQ2L)`!bat8KMlPn$Ml9u*9k5QVq9 zucz9TIHnXnzd9b>MtXl36L?7^{-x)KKW?|q`=K}wUu-~dil(O+Kx^ z!DNDaRrR%G$0PN-_(BUgng58tEpBiq+L0V^DF874DAa}_GzhD_^16}ejF5}1@^Ll^ zjY-Seu5fA=d>si0l1acV5}HZL210gL@`A8zUbm#?+&W z#R@NvKcJdx)FtG>jh!z2u3ID1h2wn+wTDi(PE2|z%w8_Dnvz2y2&Wm29K8iwf zz4rNR89~Fw{7OFP@36a-cGKF|PkVS6?IO-#Ijac2mQ_UO>B=Otb*Zk2-kP)sc0R*2 zR=hNOYQOBC#G|EW&-o&r6-`4T%}*0m65)^POBAmfkSpEkMW|b1BdJfIzX&#>dAs zknSsL=Qdp%(s|Y^pXs%Jh~;g;1n+uhCUS!wj=2JLDiz<*Q8GOV=&yg$$vDKUb8bPw z7LAt`#T3T#FJ-TgWxnw$yp{A$IfA|DRTnK#Q1F@0pUU2GQA)Rd(Jt26wqGA^6p${S z5BiEbr#-P7tW0GMJ{}QH(F3lug;9-5o*ZBU?D4CY+gc2PnDRPc0eSi{PMJ} z#qb-e-7{?cN`_8xbxP*tjAKPl8d}Hd24kuCSJSWv)&P}*ej;co{aPu#Z<*HI>C0Tp zwFn^lw&#&@uuCvp`}}(HhY!`BoiQ0mZ+7R!vtE0FFDCB+eQ{ZdV=Pm#8Q;X3%wadD z*`I4)uY3+U!_E&@U>6H?FaFDec3|igf2o?1h^ z;BcKuo<@c6gK@A$CN5@shemeiap2-O#w730b+I1UnXY!uwk#kWG3Cv4L&NpelKXM- z0>BH?fJR@xtUkG+4A~1)qk{_N2pU$;nfqJuRjcKIu1@#;Rx-%5U)MF;sjJm@G5D;c z6mj9lBb+ib+ya5H@Ckui4jUJ*v`{|SIexG{HxmTym#)B1D|bA64SY}e+sC9>Dv_T$ zxguYO$CN1ltS-Ux;=b4#6ougPkL(6AB)n$~V7G>9wnpu^?6_XUvfI4)9;X|6?W8;o z+*B97i3EhUX`BV~R#BPNqglO%6@@2xpC3@zcvVJlgw#8TaO#!tgYlek(rq2UwTBU` zX!R790A{_=_@GtJ#JlqWSEfj(R2dZzzs;FIyIKb@REK$hKHOHZFl9Zdixo2q_80gy z;tmJW1(>+@wMWtKHDH9_gb1rtUNAivT2EDf8#$#aCa;g_Yg4a>EyQALZ5y`9 ztgM_3BD$5Y8Qh7#=c48+M|^wUOgQS~=|)ENqUkpZdY+q%w*sW-up@adSdzHo`1K3n z$~y`4Yvq858^@2XTR!4Y^P7|aGVyB!?*L7aKN+)qY@ByXj7{ejmXI%qO29_x{R+>ue}HgnP_%CN5#tvPDgXFO+PpLZ+OeifKHl5kgw*|GP{x6^qW z!`9;wbQKCU^f8*n`-p?c;gwckw*@M{%0t)YyzQ_z40^~Sk#H$gK~s2eVx3y?kVjFo zKDNZz*rsn}31^r*`dQ&A>IxYY*xj;t{P$o(p4iW<%9FczU^aa*WY4+MYJ*1ohu4E9 zF6X&|EJ0yWM4OE(Kj?QSX;LSZlwLEJ(Ar3j(rI%oxGOFN^iU53o&J&2Dl!aBeN)8- zxpd34d1rG{vVGl0Nw_$OZ?E#_tJ{x@Rj=3A?;3{w(ruZz+{&?cOtMDUd+PhEqQ3qN zgLYOAv#>skH|=>p`i&>E%1JRbWahVu5MPCfz8&TCGGkQ-!=tax3lkY%{S;A0Q;D&& z%at33$yIQ^;#ANc`t<;XVb&*3R}%8+=~xyPZny0pnj6XA21GQ?Qf3-`E5bikvGk3l z2xvU95=f?VL7iYQ+@oKr2+4K5`Ynis!dC;D{CPBtF7zhaE9+`cp6|?;Cdj#Bbr;sl z2Z~wrk*f{0-e2_m*3cS;J$%0|!dK_=NpFXxx6h^zgmU75o<1L<(+T81e$E)54+i6e ztOzfgV|NBcp4=TVaZMQ%f_7{0NvOPZfGQlhaE@ZO%j-2C6_C;mk9|zO)NrEGtrHSD zWPEGZbnE_+1sd#=O79P6EtTJ1DR^QOmQSHJTqmJPb{V5N+POS4oGp%AJ$~eRJ93QU zOu^^K2mo=}W;@i}E%)x$H+pBF%A6}$ zaHMJWkkTL$8dy++;u`L_cXw~P`o&tZ>FY;SUCBSP`@b{_@{wq$CqMAID_ilS;oZOw zovQb0=G4kM-aLauoQ(^Fs zP9v(&8Y~ah?2M1$ThpsAOZh=uRxXli{K)xha$jD^JQ#3KfMlvk0B+0dQ^szL0@t5> z-X3xfDbi&VE?#e$q`hufAhb z*U<|leRTCV4}bY0^v}^>ZurqTpY77?5w?niS_5x6M5Cv2P3QHstF%>3FvE1;58{aL`KmWEK5+Ys zHoD`t$sX{mWf)@UM57%vZkWE2Pu06qDjHQWlB7UU=x8yPR(kRkVtWqkjRoqFS{M@h zU!je+|Fls5`9sd?FA&O@m+fey<-+$&vY>rr>SCcf=nc)%b0%tCUYVKW`ZdIMsd~xVR%z*JyI-zOB|St_N+Emd7|wL8yRyt4lh_3PzE-}=?0VAh;hisxb0(GOS`Q3ZfN=K2)2@rq{K?uuJq z^IC<5{Wy1D?7t^}C{6!tdPD4BRth)-`v=lWIJ*GTbgY&2j`U72+v#CQSqv4>N)tF7i5E((P}Vo9q&uBV*#29K&gmv#Ag zdih2Z5r1!5MDFSox!fG{9AJGrb-P$`{0lIw2KZ~jw$Ub6#Ukk@ORoRNey$W>d936U znt#u{OydM zvo$w2R*xD9km+&l`p?Kms(AypI0%zuX7Fpa|4cjI0v$9`pC6;Z58&&5|Lb1kwGgY6 z`gE4Ye?q7%c0m=r7klHsC^&X?a+;bN-a-`pw}3xRxdWhiHOKmEFGtF!3U&t&z(9>* zX|QCU^ALA>|L+wqML;;$vbm(;fmk-|*%6)Hh>X--j8M(rqk}++(hh1LJxl%s-i=7|GNbydV%=jcSgrQT3I- z=Cb=v{lJSMR%$-qvJ`9pt|&v8y_v1BkiRN3*5&@kQ6UXtjOJpsTubGZRCmqY3_euN z-u6D)4gh_S7>7m!2S~5W6WxoH$;31m`hLOG!%q=6F`U{z7<1D2Qb;*c1eyfPWhToJ zEMiWPpq-ifKn@z|vY52Jo0A58mkDk!y~@NH7#QBae(5I=wmmt{`|MmG6YPKvTozUb z4QQfZqG5qE1+UdNHg)r2iN`)ODjXIa(l2~`RzPuYL`t^>xex%IhZops6lb(4mTLmr zBq&xrJ^-IJwF|aUAw`qvXr%jD6@s@lTC|~V@S+-BF=H;)!oG^)Z)_smUp4rQf>DQBU=fgK$XEjB0XGe0dvRM#CDsW zUft+tws(|&EzprFBL=os`W#{_G?)Hf;{w|3;+#pX+tayBnW5Fj_JsJR!+V}vLQyvQ zBw(nTsE23!d!Px-7h@hN0FKr*m(nYhrqA!o?v%v-Ozmg$_i1F`!8sR z1%}5)g(oZHHN-`otvV$O$E+s@Er=-Z%BEiDIQB(cI!frCG^eMTsz$8Tr1 zyy5F#pkkXofFfAD;7#PZ+=}lWs-ML|_PJlrHMNW|fcOqAglvGJ4gOKh4gP0%zWR^9 z3IwwZ1Y2YR*-i&4mGmYHoXSRo82|y&AscMBF%#V4H>j-4vu%M2os=OWH%UTi0X|{c zZAl&ibGxsV=*`5E-w~G|yn66$T7g!jGybMQcx-A(KxeS*w_&bFn&EUpNpEHCZBwcL zGsH1qCkYo$jmOHJhAE_EHtk~K4ncE5Q>q*}FG%8?mi8i6S*u^DZ8CYaHI|>!Dxa=3 z1*;RD*EL1HL8B*ck`kzF&UVO~aTO*e8x`V?{(>&kd*hK6{;M%;%Htk{y|7I8q$>2O z_lt8LEKf${F~_jHq#|ma-;7~X(;?c)dxg6>+Nm~qE}bmaByQHyY`#TBcCP`dREbg&i1w)9 z(E}L>Tp8FEIx=hQ=m;~u?-UjRV>o#1xXd1IKN#?c4}%tXYC0F?YQi{y%^8e_$VzOL zv{Gr7DX*o*QU0j8;XQT-P_|^5cgNxvh-IbQU81TWCadx{IWTm!pYp?3$vtO<_nGm^l2PSfu%Cr} z-3oMq5dBb96qtVN?l!v7bV*f%z18_6ojWA8&aldLGa23Nt8ZxLyprefjXt1~&Fo~= z<@>g4bZz2Nn=+`+ry-%F%Y{5UEyBkdZBru~9mb#_f0aZUWrAUJS`V4@BIy`0ZTc20 zlOX{&HL6#>>x3-5!)QJL zdZgy53ckB$4zi}7Qir0%cMSpH0ywdCbg!A#d(0PB%7piKbOa1@pauwgly*vESd&?XjlQK%+5HE+)u$E1lff z4<*I$1tF-hY6?oWf^kI1E7VQBtVF8FGCc5o`j8|N5kSdfWWP?8n&r~CuQTcaL!2BU z2X0o?-}z;{R0&(_Z<^?nd}0d%^C-IC^4Zp4bt=9hcikaRaCR(qlGt+~dD&imbZ{X2 z#Y}^t#$71KbOfpzl~Eeyv2#RUri58&%29XgQ~u?{r-1dyO}`grBu7GziPLbsdZ8?| zG*Y-GZI-Z^^%7?YK$V2b3zil4ZGQ4ZoOle}sulLiO^}|kqmwD?s92w+#B@uNbt7vH zkZHbOh-+xaf4dqkPVlk=$S6-gd^(sGI+fjAVFqyA62ET`7~kZV^3hZV05+%V!xW~? zXKHT@@b6;eq~xgS%tVQYomDtQnj!t^f{m2fYf;}heLBb$>h9=;4u4FVNqHMc6tVD-;p>v#}oHZFY=*a`_?n-{}_`|iZ6I|6v;QMX{zyA-2OzX^>Ls73j zZq$t9D;=OyXog9qb9zkdovI2nf<)Wcc-pV(@QE{ zCvB7FNo%`|>JA6Ogb+%b5G!m>Wlh1au;U_`BX1hv^IbH(%CE!*N!NSXf}B-X^G;wZ zum-~7-4&i)i|MAD(dG$}O0RE`C-eQTKA@>y1?{{lmj8-MilIEd3jQr11_-)_lfcb4 zSJ^ntRYf4k*ZhugGjaLsllYZreS*!NuHPD9xw%}c@a^@|peXU`)H^j9dtbdMEZ2%Q z>Cg5Uz-{fx3KEUg3P7c7|I|jhhSfNy4=1s;E1)|);la9}(S4Tj=OmFKuB6$4-F~#UFFo|vH*%|j$BJWNj8qVZ5?91f5s??$ zG{b{q6ub;p@9^8M!%|*i{6lF4(Tuj6kd6+K5-hs+RJRBjWF&a1DO)!BnOzZi=fP!p zz95IUL*MmwMuiWVvyVfO2^GYj<=w}_hrV Date: Sat, 10 Dec 2011 17:09:46 +0000 Subject: [PATCH 116/147] Tidy up: remove unused pictures git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12871 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/ch11.1.png | Bin 2492 -> 0 bytes Doc/Manual/ch11.2.png | Bin 2624 -> 0 bytes Doc/Manual/ch11.3.png | Bin 2942 -> 0 bytes Doc/Manual/ch12.1.png | Bin 3605 -> 0 bytes Doc/Manual/ch9.table.2.png | Bin 3821 -> 0 bytes 5 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Doc/Manual/ch11.1.png delete mode 100644 Doc/Manual/ch11.2.png delete mode 100644 Doc/Manual/ch11.3.png delete mode 100644 Doc/Manual/ch12.1.png delete mode 100644 Doc/Manual/ch9.table.2.png diff --git a/Doc/Manual/ch11.1.png b/Doc/Manual/ch11.1.png deleted file mode 100644 index 2cc2becd48a094a1cd55b4e6e00e85369ed79451..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2492 zcmeHIYfO_@7(R$xh62{MV!5O!byGodIKQBbD>ku4aN z9*+mLO6Y)OP%6`?ATneY?2%YPDIq$8DGW7tDg%%S;Rr_pGF$|uT2v-VV9Fk7SC*@~ zfrV1x4#G)*5Dy`CRUBi866l{I#x=r~*JvHUAQK^+;94WZf_Ugv4d_&jgE8EKpy z92$uM^*|kZ8>(1Y-`UxTYXoYV23asG45u7YZh`=PSFWfsRGk!TxPyEGtr!g~APN$7 z65>~_fOKFX0!?t?shSLApHLM;7f^8q890VUP7FXnm%xR#!(CiqQs4?oMIbsuTrQXD z4CYKwT_LMz%!-;$MUVNy4_a{yArQq3kcvPeVJaXo4H!y@#c6a+-Az2TGJC2f@VpI!A{!B6L0)(4TCXwk=4{ zWxt=gqAVDb6_itt#LR!<%+^mC6J`$O7o7HbY}I+~A9dxl?7EmV766dpPaY_ZJ||Yq zGsgDB-YfIkPBa|axAW(<{&f!5(f*UqO4_WCqQhkV_8G?J{wU`H=Rn06Ycafi3%c1M=VmO=fy*BicUrtg!xk?DdA>-P>DCp2Od|vg2i9R?oxMh0Dt8 zH#v`1l-JL842~NU4mX)!pK_+Ea%3~g>d`K}XkBPJl-$1AT)E+^k^HM#QSPm9;V;Vh z|NP~=9_?G+17Gk^Qwu2ua@p4zXc>6dG#?O$&k2PO>b zZU4evbN)|}JBRBWos(rtv8SskyM!mUam^;}aCyPI14{-Y&RjGfPq62|H-37!-TowPjU)a~M_xlr*MYQr z-P7g%uG`wTv92q#=GR@bV}cG_!)weKQe?5{we7*;o^I=!sL1OzlfPbYseRV(6Sc7^ zo-DkWLZT;XwN;OJW8Y)z96jTd+tY2mv2oKSvlpDp$4^fP%++EV(j9Dk7Ewe=Ma=a(cJ z3e~qAM%~Qa@%gsrQ$Jxd@4va?qG3a6UTkWd=SEt3PuyNw?77>zr#dh2d?-C{!sdaI zA%B&B&*+Z+SJ&;A_< zP+bKq>$D`iSh71)GZGit2sF~Z#MB(Rp$0mLlBIwpF;36n-rH=`O}G57KfZ70JLh?y z_j#Z9{l2d>eMw5#NaIK%3QJ2hKTG7-jrE$40NgKKty)JEKET>R z$)ymI2~BcM2#skP&af*uC&6&SIBATS*4Ea>Br(RM;F57oGEH!eAs7@I7r=4QFh&Fl zChF_!IpUB)FtBJyE10I9HKgQ%ILL%xBuRjmo6TmT3@O1+l98rKO&~KQARp(r6e}n- z5*k8HCX)u$no19D4G+-4Kn5)1kOnRRIf8^BMh1g{qi~>cq=@i@49H9jH4etWV}v8O zq7%?a2Gj#}=pLpGd2K0zx+0}F_P z#2y;XuUY}=-~s|o$iQ7S8O-&Xsu;S!iap4{HZ%${fCXJbF0>u);s}!hS5PW|=nQ3K zWT?(y&NSAem=zkcqNY=&$9&;}R%}BEL~#S80!R|3f)dk!p@dlM2CXi*fcsx*<^|Tg z3t5@tN5lpWqopx9Ht0dEbUNvHVpINTB}*F1zm5`>!Jf6#R@Uiwt$akb-yP1n4ITMj zNzQv&+mdd?h2`z}?3OH?(-*Nuz57zSD(sGAt8C89v^Cq#ohq?;7+u@3y|;M1aoSA% z`!%X^K(Y6tRi> zx2KjLWH0U3Bq#-M@KVitf zVEJkR^Q z@1ET-YetN>m&S__;vM^(A&wBY3wX})^uYIu%oltJ@gTFFk2iA836lwt+uPe^nQ|_3 zO1VTCml>r@Vhk~yQduTcLPU}YlZeDxTU#YgBuU~_=90{~#Hh?96a#|E6nQdWB#96} zNVK-LRz@8ts00)SS}HN|&Oj+sA_I(4iEu)JD;o?3LM)sEpKysV#u)`OB!Ewr@e!zi zWP~!5YPDJh)lAR>o8bjIB!D4Tk|7OP6mlq`lt{$a*H=d4$VNy2;SCI6CKB337SxGE zR5MxPR;v}ga_E3$Pzuu|MtF}|u!rLjN(pI~VTz2ND}({4gm9#z02LO3R<)uMEy%(i zXcv}?zJY~S;SSPCDU z)MmUK=TA%ui+HFviP6E8(UEzDZM%d;qO8jtImmr^(&wn%Tkaj1O(%v39hJA8E zHOZZB`!nr&&bP9+n&4+P-MH126j|+w19+tIvDf7A{-3ZY|4}Y-`;2REpIy;(Vp#o0 zf$F5ZDvu=1@9XH5;y%42Y3oMkY=b)Odq14I#DJztgT`i;hKCo=3@gnv*qmO>^jhEqe zN%{vVfsXkf`&cHvuNq%BWY9}Tx*7v_G`u!$ZR?qamb{gtgF0%8;%9a@{%C5sGAAr| zsIg!364#jQ$(@Dot$O5*&ai$RPS+h!H_&lA7!!qx{>>ow-TgaZ`*-8?C=Obz@HRdB6QST)jBz^atD`&pm#2 z^}1u4KhhU%znM`Oc3^7mbbffY=d{lc^?9n)&JXq3aB#$c-rGLt-JxgK6}puFzq0?0 z4|VZVch;W2x^ltf9oP1b3Vk-^=kNy*-@BXs#ozk_YCT9sz(>Qk{JA(@aK##D7!F3w G&HWp6-r?E+ diff --git a/Doc/Manual/ch12.1.png b/Doc/Manual/ch12.1.png deleted file mode 100644 index 2072f06a4865fe71a889acba50b0ec35d26cadaf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3605 zcmd^BeNa@_6~BDC5*A%STo;k>Sotatl-d~94#hMkd^lzUs7>b8sBJo^u^|*K$(T+2DgoKO{ayCa@&7u`Wb()E z-1qJ|zwNCbe1B2Oq0fh!mc213dy1wNrX zkt8aKhztsdCkXg4R6t5Zl;Fy7oCMYq3lD4w58%NA47R)gYQPdfM~0A*Ln* zpzcf+mIlj{M>On#J^@#>1{NR%icT^WpOpgCfdvZ`p&b9L$UyFuSjON5RJ;QXyaq>+ zsDOehAr{IGb+Ls`fhtH9hNuiFFE3}6L7z#ylOZ!}^a|@v79RbDAGqQ*h=7!!0#z6i z3Q+-xZa`ClEZ+KW-hPFUfD46&WvhO3W!+k}Un(0BWTweY^?e8{-%;902DkfrFqKA) zf0AbzV#!!g6_Hjd$EZ;&U5{@0T+q(Dw@!@RefgWZoAoSV3Um+ z;zrR1GmS~CbRDZ1>f^#cZ&D=n*V)rncJA@^aLF{$sJ)4SWA1ZnidE@+POq(@DaHN! z@%?Ad$QFs$Qx10rKigun-EXyITJA?IeJk>Mj%J3Z09d)izdLm@YM^IVqPGx`fpL&c?3Me4Gjb`8#;%;|#K{ejUE1c9Q<1Os6z&`WZqZOmVD^yQ-I1my zeZ7}U8)@smq)y(KF!14w`T>WlQCBl#$8*a5x`EYZbK2tF> zx^SJ-;hf>gl4~ix5VT2eQ|R{k`L{LrrL1|Zz|v4P8hXWIJan$+$lDp#+9eD3>F>lU z*=GkE3gbz4{?b1yE8~MVZe6w@JHInC>Z2UJcDeu2+lr@$+7@cZBAyH_>7TW2sCjVk zT!(tftL;?G_pL3%tzT51aj(xJ!N2_Ug~JJ^_R<6osOGR^(beba;s7_Lx9Y<-4!L8} zOzmYiJPNIQ+ijviPpv^13V1O>@wq$WDfY?`+E$&G^Mp=KNs6xQ)ft$cF*7!I+% zjybNE7W<#t-u!Gz+4NZ5G#f4VTfGlXM$DhS528(RW%WxPJyUzczdyCth{vMs3K0&C@l<4#xn(D;kT zOAb_hqT6B`_4C|iZOezs(vIi9GQ_pkzrJ;!I>6mnr3ss~6^{HXuW8b!T5;*?KUAF8 zE_!16qW+8R>EZEi%3%)TwbL|4w~(jM$q zW5VyoolUpU%C&(>6P51_7T0Q{WJIpwNaTxQv3c#6N3qHY{nZe+H_WI$8T)*8=K6y@ zGMMI2UgYXy-v-a`ik%-ccA~qY?1|5Prf<;1Epxo*{q?&;FKUD5bc*dxmvy*j7wWWO&z+Bl1!DaQpM2Hv0o$ ntnatg$$kI82jc(n{pmy0UtIpodbs5WcC;1d78yEn*1q;%+h~A= diff --git a/Doc/Manual/ch9.table.2.png b/Doc/Manual/ch9.table.2.png deleted file mode 100644 index ac6647e1786397ac99dae376fb4d0bc2538c364a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3821 zcmc&%dsGu=7XJ{UAqJWR#fTyhc~+yyfUg#TFd`VImqHC+DShhu^etRcLw`c#^)6=tiHs?TQ=DYXz``zEY z^UWkLGJKI0$Bu&#vI+?%qY)YQ=(7o_Mh#&||DKMd+F+o!bnt)`0pcNFvDFB8b z5CRB-YJm@YD=176fIdTs)E2M6-Y1!9UvJf8Pfq&zMa0Fl(hoC+~2BRBX1~zaS5Fk{9>KO<5OoiYJ zh=Ma16Q~#PnYn;*Sh8dZg0@4&h!4Gorh+>d903e)p6M$@gAk^FhDL$GPy-_hL90Yy z2~dJJM(Y6{oJR^sfFx$x4ECdXAYpvvquktFsEyGIN}2Wm8x#ZaFqNQyi9!JVl(`B_ zFggSb12b#TWEc{NCsI>WVfq-k;5|Y+Jf^_dkF5(K17g!|B_;@2RT;~e1&r+$R%N99 ziNldceir5V{7(OqzWS|$SZ+JP2$Cq|TxJp5?-q>NlxSJGC${wTjlhDbk4{yvOe7*T zi{F4PJIohP7EE-BTs^p0-0oZxz&0(1iJLAzJm0v?49-E_d>{US;WyS>w@zYR5?oTV zTveo#Hq3KNMa@j-mIEb@myW!istwh&n0+Ys3U0s$kuD@@w-xLJhHQbFB{<5}Jm2HS z9=*)jt9421Roi0r8BTR~;G5ZzAK5iam2@vz&CUj}P{4sM0i>skiS-;ne4APOsC9GEsY} zb22OSFR-7oM-{u0A1da$`v^n>uiZYDX_|8)m2#neJd7Sw<6<>S{gE`NM>V;l`>}&W z%?h(w{2)-P_o^#tHKEN{=a{Wk2CS{PJ3TJ)Zx8)G2y4%{o)omM%<(!`8J69X(soeR z88_cu&FV^#3rG5GO?h?&D+awrYd>krxTRS5!@OCJ(*hr7l#d(6rv@uuR}J1g=;QPY zy`kA`YwU#l{H|9iS?Lx+qbSvCt~Mwo$n3HSX=C1MZ*3%V!bld&g3Ja?$C48hlm$N( zjA}4>_9qAG_cTd={61AwhIxjKrGZUSUD(A9yzuFq(7#w1>BGcT>YOwO6XAdBtjQ`) zFd>BZneF+6w`Dly>LO!-y1SJvqyA#qm0lStAy}pPPaosCf!XB~a&x&uiOYv;3o&{7 zRoRC2*BygzFSTA-fIS9`jnzF3__%$b?0|h;$Yky;?_b|{sOD8Ah^SdzA>eO=s|cGs#ag_%OZ zIR7z^!^>11TkNfl1%64{;+46NID-+prTk>R%UO*X&(kVnpteA}UFG~OY<1AGPfJb- z5RV)9D~|BXiV3+oahcBrm#CP1jVyljIqB|k-!x`sPgQ1(@vofe`tfwH&&Y$T-q@b@ z_}$*bdo?=i;tCt#gCIhAW>S9d&ZUj@(n+%TuYQVpW`L#(r2^z>5x5ykYo`TC*4{q% z&0UtcSiRzYkhFE=H0iUqpy{nv`O!6P;bUJ{v*O>?FNmJu*UcK^Gk#29=dR3I>r(Li zE5|G0sg1F&%X8`h+4GBS>D(B0we9G$>Ic{}R9u(RUM7qDaZ0lKfuFfr&1&A{?3Lii zJo%ZNQkh16!3ZgJ<9K(ugTJzMpvN?{sqBjjg}Ev86l7ZB65@FD9%rs_AVUjyOD}JKgT$#q?-# zO}et;kUVYw^Xh}m-O0w0)vfXPYhTcdhbQom^^a3=U9`k3r}sNEVQE$2a_?Yq_2JKX zImXiL>|Z+EXKJ=LX|@X!XMN?WduLRPCZ?$RkbR}VK+0TRpyi7Gz&#;(R{0^^UOW6u z+mARd=&J4g|M{(T=og!=okhIugp?O%tWDP^IOVnb(KU&%XfJ;gf9p2FD(zNnvLF9O zs^zb>ZyyfuHo0}tMcHG&u_Pz>XB#GH%ccrrP?T6}LMoL#PwsTu)yUf`Z%=-s^6QkE zwjx<@PXyT?FIhHQbg#RCy!6}cOv#?FGsONVdQbHEn5g&XeCzKvVe!v4T?s|Ji!at6 zjVojiF^?mRMa43q=D2O;oUu;ZM2Ry3I?iO5&2OPb$1CLtj=TK$60vrhr94^O*1S3| zW4}?0Xr{K@m9?`Z=XKSy-AKA=GA-OPa#WtL$hiQ zOYiIw^;MYHKN0A@%gtVURbXbC0MUutp;hiLBQy@-4Fy@w+RpDS8d3&EB34af9@J3U z=N;kqpNa&t$I5%BkUxN7Uh@~F+FY_r7D;SK=J^5J{PcTooo&UL(`8A;rY(w@vsv2C zwMD#vBaYXN6*JcwUG0u8V4i)D^&j?Q$+HXpkJ;%Q4a2&h8bCTCm%1+_z?0=B1KeyPu@{)AU!~@AL!`DTIA26`5Ew_<>CC$ye zR6ycWO8+x2%(R?|!+-&MS=}*`!)iK`+uctF59D1-u2$K(gkC<^#MT){3-(0ehUB4y z1jod+><^RyJ>RRojNCEziKD2}Rnqg*`HaH#A$P*F&vaSzCRZz*l!x2=A0A)Gn{6y{ zmez40KSa$EPk;U1nq$`e_9R(jt6!mV)AGIx&!%La=f_1k$UTmPv;g5~V~(qKq@!!W z@r0>en%e={Q?=#mIixagWRb^vKxFYr-hnH&s~R`nAi1kn$}HqYFLk%BxNIrn-76rI zcI*~L&UBD8lN-~XIO--9cW-0KdxYfmZ6dv^-_O2Mc23PUKB7{$ZWd6}B*(+1i;dU0qP$JKuZfHlEc-de!DWj>ss}?r4RtzAgQO$F(ua zf4x6sd1^--G<(^9|5}vmXh>&fy1~`1`VY-C{ckh<`-{w Date: Sat, 10 Dec 2011 18:32:43 +0000 Subject: [PATCH 117/147] Fix typo git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12872 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Android.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index 1a4c4e250..443d77691 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -61,7 +61,7 @@ $ cd AnrdoidApps

    The examples use a target id of 1. This might need changing depending on your setup. After installation of the Android SDK, the available target ids can be viewed by running the command below. -Please adjust the id to suite your target device. +Please adjust the id to suit your target device.

    From e7a4f42877037e7c8c443584ce6d6e43bf46110d Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Sat, 10 Dec 2011 18:33:04 +0000 Subject: [PATCH 118/147] perl5 error handling improvements git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12873 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/perl5/perlerrors.swg | 39 ++++++++++++-------------------------- Lib/perl5/perlrun.swg | 15 ++++++--------- Lib/perl5/perltypemaps.swg | 2 +- 4 files changed, 23 insertions(+), 37 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index fc17331c8..2165d84f1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-12-10: talby + [perl5] SWIG_error() now gets decorated with perl source file/line number. + [perl5] error handling now conforms to public XS api (fixes perl v5.14 issue). + 2011-12-10: wsfulton [Android/Java] Fix directors to compile on Android. diff --git a/Lib/perl5/perlerrors.swg b/Lib/perl5/perlerrors.swg index 024f03798..57296c679 100644 --- a/Lib/perl5/perlerrors.swg +++ b/Lib/perl5/perlerrors.swg @@ -4,46 +4,31 @@ SWIGINTERN const char* SWIG_Perl_ErrorType(int code) { - const char* type = 0; switch(code) { case SWIG_MemoryError: - type = "MemoryError"; - break; + return "MemoryError"; case SWIG_IOError: - type = "IOError"; - break; + return "IOError"; case SWIG_RuntimeError: - type = "RuntimeError"; - break; + return "RuntimeError"; case SWIG_IndexError: - type = "IndexError"; - break; + return "IndexError"; case SWIG_TypeError: - type = "TypeError"; - break; + return "TypeError"; case SWIG_DivisionByZero: - type = "ZeroDivisionError"; - break; + return "ZeroDivisionError"; case SWIG_OverflowError: - type = "OverflowError"; - break; + return "OverflowError"; case SWIG_SyntaxError: - type = "SyntaxError"; - break; + return "SyntaxError"; case SWIG_ValueError: - type = "ValueError"; - break; + return "ValueError"; case SWIG_SystemError: - type = "SystemError"; - break; + return "SystemError"; case SWIG_AttributeError: - type = "AttributeError"; - break; + return "AttributeError"; default: - type = "RuntimeError"; + return "RuntimeError"; } - return type; } - - diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index 4130a065e..5c1b586b4 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -47,7 +47,7 @@ /* Error manipulation */ #define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code) -#define SWIG_Error(code, msg) sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg) +#define SWIG_Error(code, msg) sv_setpvf(get_sv("@", GV_ADD), "%s %s", SWIG_ErrorType(code), msg) #define SWIG_fail goto fail /* Perl-specific SWIG API */ @@ -141,8 +141,6 @@ typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); #endif /* MULTIPLICITY */ #endif /* PERL_OBJECT */ -/* Workaround for bug in perl 5.6.x croak and earlier */ -#if (PERL_VERSION < 8) # ifdef PERL_OBJECT # define SWIG_croak_null() SWIG_Perl_croak_null(pPerl) static void SWIG_Perl_croak_null(CPerlObj *pPerl) @@ -150,17 +148,16 @@ static void SWIG_Perl_croak_null(CPerlObj *pPerl) static void SWIG_croak_null() # endif { - SV *err=ERRSV; + SV *err = get_sv("@", GV_ADD); # if (PERL_VERSION < 6) croak("%_", err); # else - if (SvOK(err) && !SvROK(err)) croak("%_", err); - croak(Nullch); + if (sv_isobject(err)) + croak(0); + else + croak("%s", SvPV_nolen(err)); # endif } -#else -# define SWIG_croak_null() croak(Nullch) -#endif /* diff --git a/Lib/perl5/perltypemaps.swg b/Lib/perl5/perltypemaps.swg index 540974476..5df456fd7 100644 --- a/Lib/perl5/perltypemaps.swg +++ b/Lib/perl5/perltypemaps.swg @@ -69,7 +69,7 @@ %end_block %enddef /* raise exception */ -%define %raise(obj, type, desc) sv_setsv(GvSV(PL_errgv), obj); SWIG_fail %enddef +%define %raise(obj, type, desc) sv_setsv(get_sv("@", GV_ADD), obj); SWIG_fail %enddef /* Include the unified typemap library */ %include From 9cdc66cc84f5f5dd4d34df00eb3c0d4b03955953 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 11 Dec 2011 16:29:51 +0000 Subject: [PATCH 119/147] Don't override existing entries when inheriting various hashes. Check if the value being inherited doesn't already exist for the derived class: if it does, we must not overwrite it. Fixes regression introduced in r12865. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12874 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/naming.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index a35a92ac7..1be1405a3 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -590,11 +590,12 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) { Hash *n = ki.item; Hash *newh; - if (!derh) - derh = NewHash(); - - newh = Getattr(derh, nkey); + /* Don't overwrite an existing value for the derived class, if any. */ + newh = Getattr(namehash, nkey); if (!newh) { + if (!derh) + derh = NewHash(); + newh = NewHash(); Setattr(derh, nkey, newh); Delete(newh); From dce1a85757dd2bb057526ca6003a3bc5e0c3fd41 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 14 Dec 2011 11:12:12 +0000 Subject: [PATCH 120/147] Fix typos git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12875 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Lua.html | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 2bc5ddef9..43584421c 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -1166,7 +1166,7 @@ stack traceback:

    -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.

    +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 an 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 @@ -1261,7 +1261,7 @@ add exception specification to functions or globally (respectively).

    26.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

    +

    This section explains what typemaps are and the usage of them. The default wrapping 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 wrapping. This section will be explaining how to use typemaps to best effect

    26.4.1 What is a typemap?

    @@ -1427,7 +1427,7 @@ ok=Create_Math(&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:

    +

    SWIG has a ready written typemap to deal with such a kind of function in <typemaps.i>. It provides the correct wrapping 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
    @@ -1447,7 +1447,7 @@ ptr=nil -- the iMath* will be GC'ed as normal
     
     

    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, it should be stressed that writing typemaps is rarely needed unless you want to change some aspect of the wrapping, 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).

    @@ -1472,7 +1472,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

    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. +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 necessary 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()
    @@ -1493,7 +1493,7 @@ This function is a version of SWIG_ConvertPtr(), except that it will either work

    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.
    +This macro, when called within the context of a SWIG wrapped 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");
    @@ -1503,7 +1503,7 @@ if (!SWIG_IsOK(SWIG_ConvertPtr( .....)){
     

    SWIG_fail_arg(char* func_name,int argnum,char* type)

    -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 +This macro, when called within the context of a SWIG wrapped 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'"
     
    @@ -1526,7 +1526,7 @@ This section covers adding of some small extra bits to your module to add the la

    -Sometimes, it may be neccesary to add your own special functions, which bypass the normal SWIG wrappering method, and just use the native Lua API calls. These 'native' functions allow direct adding of your own code into the module. This is performed with the %native directive as follows: +Sometimes, it may be necessary to add your own special functions, which bypass the normal SWIG wrapper method, and just use the native Lua API calls. These 'native' functions allow direct adding of your own code into the module. This is performed with the %native directive as follows:

    %native(my_func) int native_function(lua_State*L);  // registers native_function() with SWIG
     ...
    @@ -1538,7 +1538,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. +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 wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.

    26.6.2 Adding additional Lua code

    @@ -1586,7 +1586,7 @@ See Examples/lua/arrays for an example of this code. In the previous section, a high-level view of Lua wrapping was presented. Obviously a lot of stuff happens behind the scenes to make this happen. This section will explain some of the low-level details on how this is achieved.

    - If you just want to use SWIG and don't care how it works, then stop reading here. This is going into the guts of the code and how it works. Its mainly for people who need to know whats going on within the code. + If you just want to use SWIG and don't care how it works, then stop reading here. This is going into the guts of the code and how it works. It's mainly for people who need to know what's going on within the code.

    @@ -1725,7 +1725,7 @@ So when 'p:Print()' is called, the __index looks on the object metatable for a ' In theory, you can play with this usertable & add new features, but remember that it is a shared table between all instances of one class, and you could very easily corrupt the functions in all the instances.

    -Note: Both the opaque structures (like the FILE*) and normal wrappered classes/structs use the same 'swig_lua_userdata' structure. Though the opaque structures has do not have a metatable attached, or any information on how to dispose of them when the interpreter has finished with them. +Note: Both the opaque structures (like the FILE*) and normal wrapped classes/structs use the same 'swig_lua_userdata' structure. Though the opaque structures has do not have a metatable attached, or any information on how to dispose of them when the interpreter has finished with them.

    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. @@ -1734,7 +1734,7 @@ Note: Operator overloads are basically done in the same way, by adding functions

    -Lua is very helpful with the memory management. The 'swig_lua_userdata' is fully managed by the interpreter itself. This means that neither the C code nor the Lua code can damage it. Once a piece of userdata has no references to it, it is not instantly collected, but will be collected when Lua deems is necessary. (You can force collection by calling the Lua function collectgarbage()). Once the userdata is about to be free'ed, the interpreter will check the userdata for a metatable and for a function '__gc'. If this exists this is called. For all complete types (ie normal wrappered classes & structs) this should exist. The '__gc' function will check the 'swig_lua_userdata' to check for the 'own' field and if this is true (which is will be for all owned data's) it will then call the destructor on the pointer. +Lua is very helpful with the memory management. The 'swig_lua_userdata' is fully managed by the interpreter itself. This means that neither the C code nor the Lua code can damage it. Once a piece of userdata has no references to it, it is not instantly collected, but will be collected when Lua deems is necessary. (You can force collection by calling the Lua function collectgarbage()). Once the userdata is about to be free'ed, the interpreter will check the userdata for a metatable and for a function '__gc'. If this exists this is called. For all complete types (ie normal wrapped classes & structs) this should exist. The '__gc' function will check the 'swig_lua_userdata' to check for the 'own' field and if this is true (which is will be for all owned data) it will then call the destructor on the pointer.

    It is currently not recommended to edit this field or add some user code, to change the behaviour. Though for those who wish to try, here is where to look. From 67993c878662d1ff2b7aaf92696611603be1a941 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 14 Dec 2011 11:15:06 +0000 Subject: [PATCH 121/147] Escape literal > to > git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12876 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Lua.html | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 43584421c..9bbb3891d 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -1133,13 +1133,13 @@ SWIG will automatically convert this to a Lua error.

    -> message()
    +> message()
     I died.
     stack traceback:
             [C]: in function 'message'
             stdin:1: in main chunk
             [C]: ?
    ->
    +>
     

    @@ -1148,13 +1148,13 @@ Using xpcall will allow you to obtain additional debug information (such as a st

    -> function a() b() end -- function a() calls function b()
    -> function b() message() end -- function b() calls C++ function message(), which throws 
    -> ok,res=pcall(a)  -- call the function
    -> print(ok,res)
    +> function a() b() end -- function a() calls function b()
    +> function b() message() end -- function b() calls C++ function message(), which throws 
    +> ok,res=pcall(a)  -- call the function
    +> print(ok,res)
     false   I died.
    -> ok,res=xpcall(a,debug.traceback)  -- call the function
    -> print(ok,res)
    +> ok,res=xpcall(a,debug.traceback)  -- call the function
    +> print(ok,res)
     false   I died.
     stack traceback:
             [C]: in function 'message'
    @@ -1189,13 +1189,13 @@ SWIG will just convert it (poorly) to a string and use that as its error. (Yes i
     

    -> throw_A()
    +> throw_A()
     object exception:A *
     stack traceback:
             [C]: in function 'unknown'
             stdin:1: in main chunk
             [C]: ?
    ->
    +>
     

    To get a more useful behaviour out of SWIG you must either: provide a way to convert your exceptions into strings, or @@ -1236,14 +1236,14 @@ void throw_exc() throw(Exc) { Then the following code can be used (note: we use pcall to catch the error so we can process the exception).

    -> ok,res=pcall(throw_exc)
    -> print(ok)
    +> ok,res=pcall(throw_exc)
    +> print(ok)
     false
    -> print(res)
    +> print(res)
     userdata: 0003D880
    -> print(res.code,res.msg)
    +> print(res.code,res.msg)
     42      Hosed
    ->
    +>
     

    From 468ca084fc464f7eec1d0780e8a92bf451e5ea61 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Dec 2011 20:50:36 +0000 Subject: [PATCH 122/147] Correct special variables in 'directorargout' typemap. This change will break any 'directorargout' typemaps you may have written. Please change: to and to \n Also fix the named 'directorargout' DIRECTOROUT typemaps for these languages which didn't previously compile and add in , etc expansion.\n [C#, Go, Java, D] Add support for the 'directorargout' typemap.\n [Java] Add (char *STRING, size_t LENGTH) director typemaps. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12877 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 17 +++++++ Examples/test-suite/common.mk | 1 + Examples/test-suite/director_binary_string.i | 50 +++++++++++++++++++ .../java/director_binary_string_runme.java | 42 ++++++++++++++++ Lib/java/java.swg | 7 +++ Lib/typemaps/ptrtypes.swg | 6 +-- Lib/typemaps/valtypes.swg | 7 ++- Source/Modules/csharp.cxx | 29 ++++++----- Source/Modules/d.cxx | 29 ++++++----- Source/Modules/directors.cxx | 26 ++++++++++ Source/Modules/go.cxx | 28 +++++++---- Source/Modules/java.cxx | 29 ++++++----- Source/Modules/ocaml.cxx | 5 +- Source/Modules/octave.cxx | 8 ++- Source/Modules/php.cxx | 8 ++- Source/Modules/python.cxx | 10 ++-- Source/Modules/ruby.cxx | 42 +++++----------- Source/Modules/swigmod.h | 1 + 18 files changed, 249 insertions(+), 96 deletions(-) create mode 100644 Examples/test-suite/director_binary_string.i create mode 100644 Examples/test-suite/java/director_binary_string_runme.java diff --git a/CHANGES.current b/CHANGES.current index 2165d84f1..936a8bc46 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,23 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-12-20: wsfulton + [Java] Add (char *STRING, size_t LENGTH) director typemaps. + +2011-12-20: wsfulton + [C#, Go, Java, D] Add support for the 'directorargout' typemap. + +2011-12-20: wsfulton + [Ocaml, Octave, PHP, Python, Ruby] Correct special variables in 'directorargout' typemap. + This change will break any 'directorargout' typemaps you may have written. Please change: + $result to $1 + $input to $result + + Also fix the named 'directorargout' DIRECTOROUT typemaps for these languages which didn't + previously compile and add in $1, $2 etc expansion. + + *** POTENTIAL INCOMPATIBILITY *** + 2011-12-10: talby [perl5] SWIG_error() now gets decorated with perl source file/line number. [perl5] error handling now conforms to public XS api (fixes perl v5.14 issue). diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index b02afb463..85cd50244 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -159,6 +159,7 @@ CPP_TEST_CASES += \ director_abstract \ director_alternating \ director_basic \ + director_binary_string \ director_classes \ director_classic \ director_constructor \ diff --git a/Examples/test-suite/director_binary_string.i b/Examples/test-suite/director_binary_string.i new file mode 100644 index 000000000..ec64bc4b4 --- /dev/null +++ b/Examples/test-suite/director_binary_string.i @@ -0,0 +1,50 @@ +%module(directors="1") director_binary_string; + +%feature("director") Callback; + +%apply (char *STRING, size_t LENGTH) { (char *dataBufferAA, int sizeAA) }; +%apply (char *STRING, size_t LENGTH) { (char *dataBufferBB, int sizeBB) }; + +%inline %{ +#include + +#define BUFFER_SIZE_AA 8 +#define BUFFER_SIZE_BB 5 + +class Callback { +public: + virtual ~Callback() {} + virtual void run(char* dataBufferAA, int sizeAA, char* dataBufferBB, int sizeBB) { + memset(dataBufferAA, -1, sizeAA); + memset(dataBufferBB, -1, sizeBB); + } +}; + +class Caller { +private: + Callback *_callback; +public: + Caller(): _callback(0) {} + ~Caller() { delCallback(); } + void delCallback() { delete _callback; _callback = 0; } + void setCallback(Callback *cb) { delCallback(); _callback = cb; } + int call() { + if (_callback) { + char* aa = (char*)malloc(BUFFER_SIZE_AA); + memset(aa, 9, BUFFER_SIZE_AA); + char* bb = (char*)malloc(BUFFER_SIZE_BB); + memset(bb, 13, BUFFER_SIZE_BB); + int sum = 0; + _callback->run(aa, BUFFER_SIZE_AA, bb, BUFFER_SIZE_BB); + for (int i = 0; i < BUFFER_SIZE_AA; i++) + sum += aa[i]; + for (int i = 0; i < BUFFER_SIZE_BB; i++) + sum += bb[i]; + free(aa); + free(bb); + return sum; + } + } +}; + +%} diff --git a/Examples/test-suite/java/director_binary_string_runme.java b/Examples/test-suite/java/director_binary_string_runme.java new file mode 100644 index 000000000..e2bf4da40 --- /dev/null +++ b/Examples/test-suite/java/director_binary_string_runme.java @@ -0,0 +1,42 @@ + +import director_binary_string.*; + +public class director_binary_string_runme { + + static { + try { + System.loadLibrary("director_binary_string"); + } 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[]) { + Caller caller = new Caller(); + Callback callback = new DirectorBinaryStringCallback(); + caller.setCallback(callback); + int sum = caller.call(); + caller.delCallback(); + + if (sum != 9*2*8 + 13*3*5) + throw new RuntimeException("Unexpected sum: " + sum); + } +} + +class DirectorBinaryStringCallback extends Callback { + public DirectorBinaryStringCallback() { + super(); + } + + @Override + public void run(byte[] dataBufferAA, byte[] dataBufferBB) + { + for (int i = 0; i < dataBufferAA.length; i++) + dataBufferAA[i] = (byte)(dataBufferAA[i] * 2); + + for (int i = 0; i < dataBufferBB.length; i++) + dataBufferBB[i] = (byte)(dataBufferBB[i] * 3); + } +} + diff --git a/Lib/java/java.swg b/Lib/java/java.swg index c727d9611..81b7c5d07 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1307,6 +1307,13 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) %typemap(argout) (char *STRING, size_t LENGTH) { JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0); } +%typemap(directorin, descriptor="[B") (char *STRING, size_t LENGTH) { + jbyteArray jb = (jenv)->NewByteArray($2); + (jenv)->SetByteArrayRegion(jb, 0, $2, (jbyte *)$1); + $input = jb; +} +%typemap(directorargout) (char *STRING, size_t LENGTH) +%{(jenv)->GetByteArrayRegion($input, 0, $2, (jbyte *)$1); %} %apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) } /* java keywords */ diff --git a/Lib/typemaps/ptrtypes.swg b/Lib/typemaps/ptrtypes.swg index e1bc476ed..e8439e6dc 100644 --- a/Lib/typemaps/ptrtypes.swg +++ b/Lib/typemaps/ptrtypes.swg @@ -66,14 +66,14 @@ /* directorout */ %define %ptr_directorout_typemap(asptr_meth,frag,Type...) - %typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT ($*ltype temp) { + %typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT ($*ltype temp, int swig_ores) { Type *swig_optr = 0; - int swig_ores = $input ? asptr_meth($input, &swig_optr) : 0; + swig_ores = $result ? asptr_meth($result, &swig_optr) : 0; if (!SWIG_IsOK(swig_ores) || !swig_optr) { %dirout_fail((swig_optr ? swig_ores : SWIG_TypeError),"$type"); } temp = *swig_optr; - $result = &temp; + $1 = &temp; if (SWIG_IsNewObj(swig_ores)) %delete(swig_optr); } diff --git a/Lib/typemaps/valtypes.swg b/Lib/typemaps/valtypes.swg index cd1143073..a72e719cd 100644 --- a/Lib/typemaps/valtypes.swg +++ b/Lib/typemaps/valtypes.swg @@ -107,13 +107,12 @@ /* directorout */ %define %value_directorout_typemap(asval_meth,frag,Type...) - %typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT { - Type swig_val; - int swig_res = asval_meth($input, &swig_val); + %typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT(Type swig_val, int swig_res) { + swig_res = asval_meth($result, &swig_val); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res, "$type"); } - *$result = %static_cast(swig_val, $type); + *$1 = swig_val; } %typemap(directorout,noblock=1,fragment=frag) Type { Type swig_val; diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index bcf5c2b22..fe28e0ae9 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3576,19 +3576,7 @@ public: Delete(retpm); } - /* Go through argument list, attach lnames for arguments */ - for (i = 0, p = l; p; p = nextSibling(p), ++i) { - String *arg = Getattr(p, "name"); - String *lname = NewString(""); - - if (!arg && Cmp(Getattr(p, "type"), "void")) { - lname = NewStringf("arg%d", i); - Setattr(p, "name", lname); - } else - lname = arg; - - Setattr(p, "lname", lname); - } + Swig_director_parms_fixup(l); /* Attach the standard typemaps */ Swig_typemap_attach_parms("out", l, 0); @@ -3597,6 +3585,7 @@ public: Swig_typemap_attach_parms("cstype", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("csdirectorin", l, 0); + Swig_typemap_attach_parms("directorargout", l, w); /* Preamble code */ if (!ignored_method) @@ -3653,6 +3642,7 @@ public: /* Add input marshalling code */ if ((tm = Getattr(p, "tmap:directorin"))) { + Setattr(p, "emit:directorinput", arg); Replaceall(tm, "$input", arg); Replaceall(tm, "$owner", "0"); @@ -3830,6 +3820,19 @@ public: Delete(result_str); } + /* Marshal outputs */ + for (p = l; p;) { + if ((tm = Getattr(p, "tmap:directorargout"))) { + canThrow(n, "directorargout", p); + Replaceall(tm, "$result", "jresult"); + Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); + Printv(w->code, tm, "\n", NIL); + p = Getattr(p, "tmap:directorargout:next"); + } else { + p = nextSibling(p); + } + } + /* Terminate wrapper code */ Printf(w->code, "}\n"); if (!is_void) diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 3e5375af7..8e13799bd 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -2057,19 +2057,7 @@ public: Delete(retpm); } - /* Go through argument list, attach lnames for arguments */ - for (i = 0, p = l; p; p = nextSibling(p), ++i) { - String *arg = Getattr(p, "name"); - String *lname = NewString(""); - - if (!arg && Cmp(Getattr(p, "type"), "void")) { - lname = NewStringf("arg%d", i); - Setattr(p, "name", lname); - } else - lname = arg; - - Setattr(p, "lname", lname); - } + Swig_director_parms_fixup(l); // Attach the standard typemaps. Swig_typemap_attach_parms("out", l, 0); @@ -2078,6 +2066,7 @@ public: Swig_typemap_attach_parms("dtype", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("ddirectorin", l, 0); + Swig_typemap_attach_parms("directorargout", l, w); // Preamble code. if (!ignored_method) @@ -2135,6 +2124,7 @@ public: /* Add input marshalling code */ if ((tm = Getattr(p, "tmap:directorin"))) { + Setattr(p, "emit:directorinput", arg); Replaceall(tm, "$input", arg); Replaceall(tm, "$owner", "0"); @@ -2318,6 +2308,19 @@ public: Delete(result_str); } + /* Marshal outputs */ + for (p = l; p;) { + if ((tm = Getattr(p, "tmap:directorargout"))) { + canThrow(n, "directorargout", p); + Replaceall(tm, "$result", "jresult"); + Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); + Printv(w->code, tm, "\n", NIL); + p = Getattr(p, "tmap:directorargout:next"); + } else { + p = nextSibling(p); + } + } + /* Terminate wrapper code */ Printf(w->code, "}\n"); if (!is_void) diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx index 6064e1758..af1798b8b 100644 --- a/Source/Modules/directors.cxx +++ b/Source/Modules/directors.cxx @@ -290,3 +290,29 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) { } } +/* ------------------------------------------------------------ + * Swig_director_parms_fixup() + * + * For each parameter in the C++ member function, copy the parameter name + * to its "lname"; this ensures that Swig_typemap_attach_parms() will do + * the right thing when it sees strings like "$1" in "directorin" typemaps. + * ------------------------------------------------------------ */ + +void Swig_director_parms_fixup(ParmList *parms) { + Parm *p; + int i; + for (i = 0, p = parms; p; p = nextSibling(p), ++i) { + String *arg = Getattr(p, "name"); + String *lname = 0; + + if (!arg && !Equal(Getattr(p, "type"), "void")) { + lname = NewStringf("arg%d", i); + Setattr(p, "name", lname); + } else + lname = Copy(arg); + + Setattr(p, "lname", lname); + Delete(lname); + } +} + diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 8fb2bb25e..4e5f6d5ca 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -2941,21 +2941,13 @@ private: Append(go_with_over_name, overname); } + Parm *p = 0; Wrapper *f = NewWrapper(); - Parm *p = parms; - for (int i = 0; i < parm_count; ++i) { - p = getParm(p); - Swig_cparm_name(p, i); - if (!Getattr(p, "name")) { - String *pn = NewString(""); - Printf(pn, "arg%d", i); - Setattr(p, "name", pn); - } - p = nextParm(p); - } + Swig_director_parms_fixup(parms); Swig_typemap_attach_parms("directorin", parms, f); + Swig_typemap_attach_parms("directorargout", parms, f); if (!is_ignored) { // We use an interface to see if this method is defined in Go. @@ -3422,6 +3414,7 @@ private: String *ln = Getattr(p, "lname"); String *input = NewString(""); Printv(input, "swig_a.", ln, NULL); + Setattr(p, "emit:directorinput", input); Replaceall(tm, "$input", input); Replaceall(tm, "$owner", "0"); Delete(input); @@ -3527,6 +3520,19 @@ private: Delete(rname); } } + + /* Marshal outputs */ + for (p = parms; p;) { + String *tm; + if ((tm = Getattr(p, "tmap:directorargout"))) { + Replaceall(tm, "$result", "jresult"); + Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); + Printv(f->code, tm, "\n", NIL); + p = Getattr(p, "tmap:directorargout:next"); + } else { + p = nextSibling(p); + } + } } else { assert(is_pure_virtual); Printv(f->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 12b8102e4..3439dacb1 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -3682,19 +3682,7 @@ public: Delete(retpm); } - /* Go through argument list, attach lnames for arguments */ - for (i = 0, p = l; p; p = nextSibling(p), ++i) { - String *arg = Getattr(p, "name"); - String *lname = NewString(""); - - if (!arg && Cmp(Getattr(p, "type"), "void")) { - lname = NewStringf("arg%d", i); - Setattr(p, "name", lname); - } else - lname = arg; - - Setattr(p, "lname", lname); - } + Swig_director_parms_fixup(l); /* Attach the standard typemaps */ Swig_typemap_attach_parms("out", l, 0); @@ -3702,6 +3690,7 @@ public: Swig_typemap_attach_parms("jtype", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("javadirectorin", l, 0); + Swig_typemap_attach_parms("directorargout", l, w); if (!ignored_method) { /* Add Java environment pointer to wrapper */ @@ -3811,6 +3800,7 @@ public: Append(jnidesc, jni_canon); Delete(jni_canon); + Setattr(p, "emit:directorinput", arg); Replaceall(tm, "$input", arg); Replaceall(tm, "$owner", "0"); @@ -4014,6 +4004,19 @@ public: Delete(result_str); } + /* Marshal outputs */ + for (p = l; p;) { + if ((tm = Getattr(p, "tmap:directorargout"))) { + addThrows(n, "tmap:directorargout", p); + Replaceall(tm, "$result", "jresult"); + Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); + Printv(w->code, tm, "\n", NIL); + p = Getattr(p, "tmap:directorargout:next"); + } else { + p = nextSibling(p); + } + } + Delete(imclass_desc); Delete(class_desc); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 0e42bd866..2184440c1 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1499,6 +1499,7 @@ public: Putc(',', arglist); if ((tm = Getattr(p, "tmap:directorin")) != 0) { + Setattr(p, "emit:directorinput", pname); Replaceall(tm, "$input", pname); Replaceall(tm, "$owner", "0"); if (Len(tm) == 0) @@ -1638,8 +1639,8 @@ public: /* marshal outputs */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) { - Replaceall(tm, "$input", "swig_result"); - Replaceall(tm, "$result", Getattr(p, "name")); + Replaceall(tm, "$result", "swig_result"); + Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 4d54084da..7bf33169b 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -1325,6 +1325,8 @@ public: // attach typemaps to arguments (C/C++ -> Python) String *parse_args = NewString(""); + Swig_director_parms_fixup(l); + Swig_typemap_attach_parms("in", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("directorargout", l, w); @@ -1354,6 +1356,7 @@ public: if ((tm = Getattr(p, "tmap:directorin")) != 0) { String *parse = Getattr(p, "tmap:directorin:parse"); if (!parse) { + Setattr(p, "emit:directorinput", "tmpv"); Replaceall(tm, "$input", "tmpv"); Replaceall(tm, "$owner", "0"); Printv(wrap_args, tm, "\n", NIL); @@ -1361,6 +1364,7 @@ public: Putc('O', parse_args); } else { Append(parse_args, parse); + Setattr(p, "emit:directorinput", pname); Replaceall(tm, "$input", pname); Replaceall(tm, "$owner", "0"); if (Len(tm) == 0) @@ -1430,8 +1434,8 @@ public: if ((tm = Getattr(p, "tmap:directorargout")) != 0) { char temp[24]; sprintf(temp, "out(%d)", idx); - Replaceall(tm, "$input", temp); - Replaceall(tm, "$result", Getattr(p, "name")); + Replaceall(tm, "$result", temp); + Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 3e8df76b9..6bcb2d457 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2535,6 +2535,8 @@ done: /* attach typemaps to arguments (C/C++ -> PHP) */ String *parse_args = NewStringEmpty(); + Swig_director_parms_fixup(l); + /* remove the wrapper 'w' since it was producing spurious temps */ Swig_typemap_attach_parms("in", l, 0); Swig_typemap_attach_parms("directorin", l, 0); @@ -2567,6 +2569,7 @@ done: if (!parse) { sprintf(source, "obj%d", idx++); String *input = NewStringf("&%s", source); + Setattr(p, "emit:directorinput", input); Replaceall(tm, "$input", input); Delete(input); Replaceall(tm, "$owner", "0"); @@ -2577,6 +2580,7 @@ done: Putc('O', parse_args); } else { Append(parse_args, parse); + Setattr(p, "emit:directorinput", pname); Replaceall(tm, "$input", pname); Replaceall(tm, "$owner", "0"); if (Len(tm) == 0) @@ -2680,8 +2684,8 @@ done: /* marshal outputs */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) { - Replaceall(tm, "$input", Swig_cresult_name()); - Replaceall(tm, "$result", Getattr(p, "name")); + Replaceall(tm, "$result", Swig_cresult_name()); + Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index f94d54106..296a920b7 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4656,6 +4656,8 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { String *arglist = NewString(""); String *parse_args = NewString(""); + Swig_director_parms_fixup(l); + /* remove the wrapper 'w' since it was producing spurious temps */ Swig_typemap_attach_parms("in", l, 0); Swig_typemap_attach_parms("directorin", l, 0); @@ -4698,6 +4700,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { if (!parse) { sprintf(source, "obj%d", idx++); String *input = NewString(source); + Setattr(p, "emit:directorinput", input); Replaceall(tm, "$input", input); Delete(input); Replaceall(tm, "$owner", "0"); @@ -4710,6 +4713,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { } else { use_parse = 1; Append(parse_args, parse); + Setattr(p, "emit:directorinput", pname); Replaceall(tm, "$input", pname); Replaceall(tm, "$owner", "0"); if (Len(tm) == 0) @@ -4940,11 +4944,11 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) { if (outputs > 1) { Printf(w->code, "output = PyTuple_GetItem(%s, %d);\n", Swig_cresult_name(), idx++); - Replaceall(tm, "$input", "output"); + Replaceall(tm, "$result", "output"); } else { - Replaceall(tm, "$input", Swig_cresult_name()); + Replaceall(tm, "$result", Swig_cresult_name()); } - Replaceall(tm, "$result", Getattr(p, "name")); + Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 6aaa8d398..f9582b8f4 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -3152,13 +3152,7 @@ public: /* attach typemaps to arguments (C/C++ -> Ruby) */ String *arglist = NewString(""); - /** - * For each parameter to the C++ member function, copy the parameter name - * to its "lname"; this ensures that Swig_typemap_attach_parms() will do - * the right thing when it sees strings like "$1" in your "directorin" typemaps. - * Not sure if it's OK to leave it like this, but seems OK so far. - */ - typemap_copy_pname_to_lname(l); + Swig_director_parms_fixup(l); Swig_typemap_attach_parms("in", l, 0); Swig_typemap_attach_parms("directorin", l, 0); @@ -3182,11 +3176,10 @@ public: if (Getattr(p, "tmap:directorargout") != 0) outputs++; - if ( checkAttribute( p, "tmap:in:numinputs", "0") ) - { - p = Getattr(p, "tmap:in:next"); - continue; - } + if ( checkAttribute( p, "tmap:in:numinputs", "0") ) { + p = Getattr(p, "tmap:in:next"); + continue; + } String *parameterName = Getattr(p, "name"); String *parameterType = Getattr(p, "type"); @@ -3194,8 +3187,11 @@ public: Putc(',', arglist); if ((tm = Getattr(p, "tmap:directorin")) != 0) { sprintf(source, "obj%d", idx++); - Replaceall(tm, "$input", source); + String *input = NewString(source); + Setattr(p, "emit:directorinput", input); + Replaceall(tm, "$input", input); Replaceall(tm, "$owner", "0"); + Delete(input); Printv(wrap_args, tm, "\n", NIL); Wrapper_add_localv(w, source, "VALUE", source, "= Qnil", NIL); Printv(arglist, source, NIL); @@ -3340,11 +3336,11 @@ public: if ((tm = Getattr(p, "tmap:directorargout")) != 0) { if (outputs > 1) { Printf(w->code, "output = rb_ary_entry(%s, %d);\n", Swig_cresult_name(), idx++); - Replaceall(tm, "$input", "output"); + Replaceall(tm, "$result", "output"); } else { - Replaceall(tm, "$input", Swig_cresult_name()); + Replaceall(tm, "$result", Swig_cresult_name()); } - Replaceall(tm, "$result", Getattr(p, "name")); + Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { @@ -3417,20 +3413,6 @@ public: return Language::classDirectorDisown(n); } - void typemap_copy_pname_to_lname(ParmList *parms) { - Parm *p; - String *pname; - String *lname; - - p = parms; - while (p) { - pname = Getattr(p, "name"); - lname = Copy(pname); - Setattr(p, "lname", lname); - p = nextSibling(p); - } - } - String *runtimeCode() { String *s = NewString(""); String *shead = Swig_include_sys("rubyhead.swg"); diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 208a7b026..7733391fc 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -355,6 +355,7 @@ String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms); String *Swig_method_decl(SwigType *rtype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values); String *Swig_director_declaration(Node *n); void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f); +void Swig_director_parms_fixup(ParmList *parms); /* directors.cxx end */ extern "C" { From b2b2dd65de4f333fcfcb0263c772395a00c64cfa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Dec 2011 21:17:21 +0000 Subject: [PATCH 123/147] Ruby doc improvements after directorargout typemap changes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12878 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Ruby.html | 120 +++++-------------------------------------- 1 file changed, 14 insertions(+), 106 deletions(-) diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 8cede1cf8..69005c731 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -6517,49 +6517,16 @@ typemap.

    - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - + @@ -6763,80 +6730,21 @@ $result = output_helper( $result, NUM2INT($1) );
    - - - - - - - - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - + - - - - - From 4c898b023c724c8c9b7cae0086fe90b6da2a5235 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 21 Dec 2011 07:16:44 +0000 Subject: [PATCH 124/147] The 'directorin' typemap now accepts , etc expansions instead of having to use workarounds - _name, _name etc. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12879 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/csharp.swg | 26 +++++++++++++------------- Lib/csharp/enums.swg | 4 ++-- Lib/csharp/enumsimple.swg | 4 ++-- Lib/csharp/enumtypesafe.swg | 4 ++-- Lib/d/denums.swg | 2 +- Lib/d/dprimitives.swg | 2 +- Lib/go/go.swg | 24 ++++++++++++------------ Lib/go/std_string.i | 4 ++-- Lib/java/enums.swg | 4 ++-- Lib/java/enumsimple.swg | 4 ++-- Lib/java/enumtypesafe.swg | 4 ++-- Lib/java/enumtypeunsafe.swg | 4 ++-- Lib/java/java.swg | 26 +++++++++++++------------- Lib/ocaml/typemaps.i | 2 +- Lib/php/php.swg | 10 +++++----- Lib/php/std_string.i | 2 +- Lib/pike/std_string.i | 4 ++-- Lib/typemaps/strings.swg | 8 ++++---- Lib/typemaps/swigobject.swg | 2 +- Lib/typemaps/swigtype.swg | 10 +++++----- Lib/typemaps/valtypes.swg | 4 ++-- Lib/typemaps/void.swg | 2 +- Source/Modules/ocaml.cxx | 2 ++ 23 files changed, 80 insertions(+), 78 deletions(-) diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 82452c4be..107695da1 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -297,19 +297,19 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { temp = ($*1_ltype)$input; $result = &temp; %} -%typemap(directorin) const bool & "$input = $1_name;" -%typemap(directorin) const char & "$input = $1_name;" -%typemap(directorin) const signed char & "$input = $1_name;" -%typemap(directorin) const unsigned char & "$input = $1_name;" -%typemap(directorin) const short & "$input = $1_name;" -%typemap(directorin) const unsigned short & "$input = $1_name;" -%typemap(directorin) const int & "$input = $1_name;" -%typemap(directorin) const unsigned int & "$input = $1_name;" -%typemap(directorin) const long & "$input = $1_name;" -%typemap(directorin) const unsigned long & "$input = $1_name;" -%typemap(directorin) const long long & "$input = $1_name;" -%typemap(directorin) const float & "$input = $1_name;" -%typemap(directorin) const double & "$input = $1_name;" +%typemap(directorin) const bool & "$input = $1;" +%typemap(directorin) const char & "$input = $1;" +%typemap(directorin) const signed char & "$input = $1;" +%typemap(directorin) const unsigned char & "$input = $1;" +%typemap(directorin) const short & "$input = $1;" +%typemap(directorin) const unsigned short & "$input = $1;" +%typemap(directorin) const int & "$input = $1;" +%typemap(directorin) const unsigned int & "$input = $1;" +%typemap(directorin) const long & "$input = $1;" +%typemap(directorin) const unsigned long & "$input = $1;" +%typemap(directorin) const long long & "$input = $1;" +%typemap(directorin) const float & "$input = $1;" +%typemap(directorin) const double & "$input = $1;" %typemap(csdirectorin) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), diff --git a/Lib/csharp/enums.swg b/Lib/csharp/enums.swg index 6605da8c8..70e483fd6 100644 --- a/Lib/csharp/enums.swg +++ b/Lib/csharp/enums.swg @@ -18,7 +18,7 @@ %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} -%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" +%typemap(directorin) const enum SWIGTYPE & "$input = $1;" %typemap(csdirectorin) const enum SWIGTYPE & "($*csclassname)$iminput" %typemap(csdirectorout) const enum SWIGTYPE & "(int)$cscall" @@ -51,7 +51,7 @@ %typemap(out) enum SWIGTYPE %{ $result = $1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} -%typemap(directorin) enum SWIGTYPE "$input = $1;" +%typemap(directorin) enum SWIGTYPE "$input = $1;" %typemap(csdirectorin) enum SWIGTYPE "($csclassname)$iminput" %typemap(csdirectorout) enum SWIGTYPE "(int)$cscall" diff --git a/Lib/csharp/enumsimple.swg b/Lib/csharp/enumsimple.swg index 2b1cb182b..a193e758a 100644 --- a/Lib/csharp/enumsimple.swg +++ b/Lib/csharp/enumsimple.swg @@ -20,7 +20,7 @@ %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} -%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" +%typemap(directorin) const enum SWIGTYPE & "$input = $1;" %typemap(csdirectorin) const enum SWIGTYPE & "$iminput" %typemap(csdirectorout) const enum SWIGTYPE & "$cscall" @@ -53,7 +53,7 @@ %typemap(out) enum SWIGTYPE %{ $result = $1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} -%typemap(directorin) enum SWIGTYPE "$input = $1;" +%typemap(directorin) enum SWIGTYPE "$input = $1;" %typemap(csdirectorin) enum SWIGTYPE "$iminput" %typemap(csdirectorout) enum SWIGTYPE "$cscall" diff --git a/Lib/csharp/enumtypesafe.swg b/Lib/csharp/enumtypesafe.swg index a6bf64b9a..ed483f0cb 100644 --- a/Lib/csharp/enumtypesafe.swg +++ b/Lib/csharp/enumtypesafe.swg @@ -19,7 +19,7 @@ %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} -%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" +%typemap(directorin) const enum SWIGTYPE & "$input = $1;" %typemap(csdirectorin) const enum SWIGTYPE & "$*csclassname.swigToEnum($iminput)" %typemap(csdirectorout) const enum SWIGTYPE & "$cscall.swigValue" @@ -52,7 +52,7 @@ %typemap(out) enum SWIGTYPE %{ $result = $1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} -%typemap(directorin) enum SWIGTYPE "$input = $1;" +%typemap(directorin) enum SWIGTYPE "$input = $1;" %typemap(csdirectorin) enum SWIGTYPE "$csclassname.swigToEnum($iminput)" %typemap(csdirectorout) enum SWIGTYPE "$cscall.swigValue" diff --git a/Lib/d/denums.swg b/Lib/d/denums.swg index a216527b2..5917da90d 100644 --- a/Lib/d/denums.swg +++ b/Lib/d/denums.swg @@ -45,7 +45,7 @@ $1 = &temp; %} %typemap(out) const enum SWIGTYPE & %{ $result = *$1; %} -%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" +%typemap(directorin) const enum SWIGTYPE & "$input = $1;" %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} diff --git a/Lib/d/dprimitives.swg b/Lib/d/dprimitives.swg index 24ac8c9a0..445437957 100644 --- a/Lib/d/dprimitives.swg +++ b/Lib/d/dprimitives.swg @@ -38,7 +38,7 @@ %{ temp = ($*1_ltype)$input; $1 = &temp; %} %typemap(out) const TYPE & "$result = *$1;" -%typemap(directorin) const TYPE & "$input = $1_name;" +%typemap(directorin) const TYPE & "$input = $1;" %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const TYPE & %{ static $*1_ltype temp; temp = ($*1_ltype)$input; diff --git a/Lib/go/go.swg b/Lib/go/go.swg index 587d219be..82f0b91f6 100644 --- a/Lib/go/go.swg +++ b/Lib/go/go.swg @@ -108,7 +108,7 @@ unsigned long long, float, double -%{ $input = ($1_ltype)$1_name; %} +%{ $input = ($1_ltype)$1; %} %typemap(directorin) const bool &, const char &, @@ -124,7 +124,7 @@ const unsigned long long &, const float &, const double & -%{ $input = ($*1_ltype)$1_name; %} +%{ $input = ($*1_ltype)$1; %} %typemap(directorout) bool, char, @@ -182,10 +182,10 @@ %{ $result = ($*1_ltype)*$1; %} %typemap(directorin) size_t -%{ $input = (size_t)$1_name; %} +%{ $input = (size_t)$1; %} %typemap(directorin) const size_t & -%{ $input = ($*1_ltype)$1_name; %} +%{ $input = ($*1_ltype)$1; %} %typemap(directorout) size_t %{ $result = ($1_ltype)$input; %} @@ -211,7 +211,7 @@ %} %typemap(directorin) SWIGTYPE (CLASS::*) -%{ $input = *($&1_ltype)$1_name; %} +%{ $input = *($&1_ltype)$1; %} %typemap(directorout) SWIGTYPE (CLASS::*) %{ @@ -233,7 +233,7 @@ %{ *($&1_ltype)&$result = $1; %} %typemap(directorin) SWIGTYPE * -%{ $input = ($1_ltype)$1_name; %} +%{ $input = ($1_ltype)$1; %} %typemap(directorout) SWIGTYPE * %{ $result = ($1_ltype)$input; %} @@ -268,7 +268,7 @@ %{ *($&1_ltype)&$result = $1; %} %typemap(directorin) SWIGTYPE & -%{ $input = ($1_ltype)&$1_name; %} +%{ $input = ($1_ltype)&$1; %} %typemap(directorout) SWIGTYPE & %{ *($&1_ltype)&$result = $input; %} @@ -286,7 +286,7 @@ %{ *($&1_ltype)&$result = $1; %} %typemap(directorin) SWIGTYPE [] -%{ $input = *($1_ltype)&$1_name; %} +%{ $input = *($1_ltype)&$1; %} %typemap(directorout) SWIGTYPE [] %{ *($&1_ltype)&$result = $input; %} @@ -324,7 +324,7 @@ signed char *, signed char *&, signed char[ANY], signed char[], unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] %{ - $input = _swig_makegostring((char*)$1_name, $1_name ? strlen((char*)$1_name) : 0); + $input = _swig_makegostring((char*)$1, $1 ? strlen((char*)$1) : 0); %} %typemap(directorout) @@ -347,7 +347,7 @@ %{ $result = _swig_makegostring((char*)$1, (size_t)$2); %} %typemap(directorin) (char *STRING, size_t LENGTH) -%{ $input = _swig_makegostring((char*)$1_name, $2_name); %} +%{ $input = _swig_makegostring((char*)$1, $2); %} %typemap(directorout) (char *STRING, size_t LENGTH) %{ @@ -369,7 +369,7 @@ %{ $result = $1; %} %typemap(directorin) enum SWIGTYPE -%{ $input = ($1_ltype)$1_name; %} +%{ $input = ($1_ltype)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} @@ -402,7 +402,7 @@ #endif %typemap(directorin) SWIGTYPE -%{ $input = ($&1_ltype)&$1_name; %} +%{ $input = ($&1_ltype)&$1; %} %typemap(directorout) SWIGTYPE %{ $result = *($&1_ltype)$input; %} diff --git a/Lib/go/std_string.i b/Lib/go/std_string.i index fb99ccdcd..e7c964263 100644 --- a/Lib/go/std_string.i +++ b/Lib/go/std_string.i @@ -31,7 +31,7 @@ class string; %{ $result = _swig_makegostring($1.data(), $1.length()); %} %typemap(directorin) string -%{ $input = _swig_makegostring($1_name.data(), $1_name.length()); %} +%{ $input = _swig_makegostring($1.data(), $1.length()); %} %typemap(in) const string & %{ @@ -50,6 +50,6 @@ class string; %{ $result = _swig_makegostring((*$1).data(), (*$1).length()); %} %typemap(directorin) const string & -%{ $input = _swig_makegostring($1_name.data(), $1_name.length()); %} +%{ $input = _swig_makegostring($1.data(), $1.length()); %} } diff --git a/Lib/java/enums.swg b/Lib/java/enums.swg index edb67c417..b8b7f9e2e 100644 --- a/Lib/java/enums.swg +++ b/Lib/java/enums.swg @@ -20,7 +20,7 @@ %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} -%typemap(directorin, descriptor="L$packagepath/$*javaclassname;") const enum SWIGTYPE & "$input = (jint)$1_name;" +%typemap(directorin, descriptor="L$packagepath/$*javaclassname;") const enum SWIGTYPE & "$input = (jint)$1;" %typemap(javadirectorin) const enum SWIGTYPE & "$*javaclassname.swigToEnum($jniinput)" %typemap(javadirectorout) const enum SWIGTYPE & "($javacall).swigValue()" @@ -45,7 +45,7 @@ %typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} -%typemap(directorin, descriptor="L$packagepath/$javaclassname;") enum SWIGTYPE "$input = (jint) $1;" +%typemap(directorin, descriptor="L$packagepath/$javaclassname;") enum SWIGTYPE "$input = (jint) $1;" %typemap(javadirectorin) enum SWIGTYPE "$javaclassname.swigToEnum($jniinput)" %typemap(javadirectorout) enum SWIGTYPE "($javacall).swigValue()" diff --git a/Lib/java/enumsimple.swg b/Lib/java/enumsimple.swg index e08401869..c270149bd 100644 --- a/Lib/java/enumsimple.swg +++ b/Lib/java/enumsimple.swg @@ -20,7 +20,7 @@ %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} -%typemap(directorin, descriptor="I") const enum SWIGTYPE & "$input = (jint)$1_name;" +%typemap(directorin, descriptor="I") const enum SWIGTYPE & "$input = (jint)$1;" %typemap(javadirectorin) const enum SWIGTYPE & "$jniinput" %typemap(javadirectorout) const enum SWIGTYPE & "$javacall" @@ -45,7 +45,7 @@ %typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} -%typemap(directorin, descriptor="I") enum SWIGTYPE "$input = (jint) $1;" +%typemap(directorin, descriptor="I") enum SWIGTYPE "$input = (jint) $1;" %typemap(javadirectorin) enum SWIGTYPE "$jniinput" %typemap(javadirectorout) enum SWIGTYPE "$javacall" diff --git a/Lib/java/enumtypesafe.swg b/Lib/java/enumtypesafe.swg index d6c6e5190..976364b0a 100644 --- a/Lib/java/enumtypesafe.swg +++ b/Lib/java/enumtypesafe.swg @@ -19,7 +19,7 @@ %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} -%typemap(directorin, descriptor="L$packagepath/$*javaclassname;") const enum SWIGTYPE & "$input = (jint)$1_name;" +%typemap(directorin, descriptor="L$packagepath/$*javaclassname;") const enum SWIGTYPE & "$input = (jint)$1;" %typemap(javadirectorin) const enum SWIGTYPE & "$*javaclassname.swigToEnum($jniinput)" %typemap(javadirectorout) const enum SWIGTYPE & "($javacall).swigValue()" @@ -43,7 +43,7 @@ %typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} -%typemap(directorin, descriptor="L$packagepath/$javaclassname;") enum SWIGTYPE "$input = (jint) $1;" +%typemap(directorin, descriptor="L$packagepath/$javaclassname;") enum SWIGTYPE "$input = (jint) $1;" %typemap(javadirectorin) enum SWIGTYPE "$javaclassname.swigToEnum($jniinput)" %typemap(javadirectorout) enum SWIGTYPE "($javacall).swigValue()" diff --git a/Lib/java/enumtypeunsafe.swg b/Lib/java/enumtypeunsafe.swg index d9a7c4d29..31fb8a79d 100644 --- a/Lib/java/enumtypeunsafe.swg +++ b/Lib/java/enumtypeunsafe.swg @@ -20,7 +20,7 @@ %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} -%typemap(directorin, descriptor="I") const enum SWIGTYPE & "$input = (jint)$1_name;" +%typemap(directorin, descriptor="I") const enum SWIGTYPE & "$input = (jint)$1;" %typemap(javadirectorin) const enum SWIGTYPE & "$jniinput" %typemap(javadirectorout) const enum SWIGTYPE & "$javacall" @@ -45,7 +45,7 @@ %typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} -%typemap(directorin, descriptor="I") enum SWIGTYPE "$input = (jint) $1;" +%typemap(directorin, descriptor="I") enum SWIGTYPE "$input = (jint) $1;" %typemap(javadirectorin) enum SWIGTYPE "$jniinput" %typemap(javadirectorout) enum SWIGTYPE "$javacall" diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 81b7c5d07..794b58d88 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -469,19 +469,19 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { temp = ($*1_ltype)$input; $result = &temp; %} -%typemap(directorin, descriptor="Z") const bool & "$input = (jboolean)$1_name;" -%typemap(directorin, descriptor="C") const char & "$input = (jchar)$1_name;" -%typemap(directorin, descriptor="B") const signed char & "$input = (jbyte)$1_name;" -%typemap(directorin, descriptor="S") const unsigned char & "$input = (jshort)$1_name;" -%typemap(directorin, descriptor="S") const short & "$input = (jshort)$1_name;" -%typemap(directorin, descriptor="I") const unsigned short & "$input = (jint)$1_name;" -%typemap(directorin, descriptor="I") const int & "$input = (jint)$1_name;" -%typemap(directorin, descriptor="J") const unsigned int & "$input = (jlong)$1_name;" -%typemap(directorin, descriptor="I") const long & "$input = (jint)$1_name;" -%typemap(directorin, descriptor="J") const unsigned long & "$input = (jlong)$1_name;" -%typemap(directorin, descriptor="J") const long long & "$input = (jlong)$1_name;" -%typemap(directorin, descriptor="F") const float & "$input = (jfloat)$1_name;" -%typemap(directorin, descriptor="D") const double & "$input = (jdouble)$1_name;" +%typemap(directorin, descriptor="Z") const bool & "$input = (jboolean)$1;" +%typemap(directorin, descriptor="C") const char & "$input = (jchar)$1;" +%typemap(directorin, descriptor="B") const signed char & "$input = (jbyte)$1;" +%typemap(directorin, descriptor="S") const unsigned char & "$input = (jshort)$1;" +%typemap(directorin, descriptor="S") const short & "$input = (jshort)$1;" +%typemap(directorin, descriptor="I") const unsigned short & "$input = (jint)$1;" +%typemap(directorin, descriptor="I") const int & "$input = (jint)$1;" +%typemap(directorin, descriptor="J") const unsigned int & "$input = (jlong)$1;" +%typemap(directorin, descriptor="I") const long & "$input = (jint)$1;" +%typemap(directorin, descriptor="J") const unsigned long & "$input = (jlong)$1;" +%typemap(directorin, descriptor="J") const long long & "$input = (jlong)$1;" +%typemap(directorin, descriptor="F") const float & "$input = (jfloat)$1;" +%typemap(directorin, descriptor="D") const double & "$input = (jdouble)$1;" %typemap(javadirectorin) const char & ($*1_ltype temp), const signed char & ($*1_ltype temp), diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index cada7b957..a15dc16ec 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -165,7 +165,7 @@ swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); } %typemap(directorin) C_NAME { - args = caml_list_append(args,C_TO_MZ($1_name)); + args = caml_list_append(args,C_TO_MZ($1)); } %enddef diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 2affdd1ac..d46de93ea 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -266,7 +266,7 @@ size_t, enum SWIGTYPE { - ZVAL_LONG($input,$1_name); + ZVAL_LONG($input,$1); } %typemap(out) bool @@ -281,7 +281,7 @@ %typemap(directorin) bool { - ZVAL_BOOL($input,($1_name)?1:0); + ZVAL_BOOL($input,($1)?1:0); } %typemap(out) float, @@ -299,7 +299,7 @@ %typemap(directorin) float, double { - ZVAL_DOUBLE($input,$1_name); + ZVAL_DOUBLE($input,$1); } %typemap(out) char @@ -347,7 +347,7 @@ SWIGTYPE [], SWIGTYPE & %{ - SWIG_SetPointerZval($input, (void *)&$1_name, $1_descriptor, ($owner)|2); + SWIG_SetPointerZval($input, (void *)&$1, $1_descriptor, ($owner)|2); %} %typemap(out, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) @@ -390,7 +390,7 @@ %typemap(directorin) SWIGTYPE { - SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1_name), $&1_descriptor, 2); + SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1), $&1_descriptor, 2); } %typemap(out) void ""; diff --git a/Lib/php/std_string.i b/Lib/php/std_string.i index 5b82fde53..ff70bc83c 100644 --- a/Lib/php/std_string.i +++ b/Lib/php/std_string.i @@ -42,7 +42,7 @@ namespace std { %} %typemap(directorin) string, const string& %{ - ZVAL_STRINGL($input, const_cast($1_name.data()), $1_name.size(), 1); + ZVAL_STRINGL($input, const_cast($1.data()), $1.size(), 1); %} %typemap(out) const string & %{ diff --git a/Lib/pike/std_string.i b/Lib/pike/std_string.i index 0694035bf..c6fc48c8d 100644 --- a/Lib/pike/std_string.i +++ b/Lib/pike/std_string.i @@ -36,9 +36,9 @@ namespace std { %typemap(out, pikedesc="tStr") const string & "push_text($1->c_str());"; - %typemap(directorin) string, const string &, string & "$1_name.c_str()"; + %typemap(directorin) string, const string &, string & "$1.c_str()"; - %typemap(directorin) string *, const string * "$1_name->c_str()"; + %typemap(directorin) string *, const string * "$1->c_str()"; %typemap(directorout) string { if ($input.type == T_STRING) diff --git a/Lib/typemaps/strings.swg b/Lib/typemaps/strings.swg index 8c39b8322..d3c219430 100644 --- a/Lib/typemaps/strings.swg +++ b/Lib/typemaps/strings.swg @@ -159,7 +159,7 @@ %typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtr) Char *, Char const*, Char *const, Char const *const, Char const *&, Char *const &, Char const *const & { - $input = SWIG_FromCharPtr((const Char *)$1_name); + $input = SWIG_FromCharPtr((const Char *)$1); } @@ -326,9 +326,9 @@ { size_t size = $1_dim0; %#ifndef SWIG_PRESERVE_CARRAY_SIZE - while (size && ($1_name[size - 1] == '\0')) --size; + while (size && ($1[size - 1] == '\0')) --size; %#endif - $input = SWIG_FromCharPtrAndSize($1_name, size); + $input = SWIG_FromCharPtrAndSize($1, size); } /* directorout */ @@ -389,7 +389,7 @@ %typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtrAndSize) Char FIXSIZE[ANY], const Char FIXSIZE[ANY] { - $input = SWIG_FromCharPtrAndSize($1_name, $1_dim0); + $input = SWIG_FromCharPtrAndSize($1, $1_dim0); } #endif /* SWIG_DIRECTOR_TYPEMAPS */ diff --git a/Lib/typemaps/swigobject.swg b/Lib/typemaps/swigobject.swg index 4a7965d96..b1e6dc9d8 100644 --- a/Lib/typemaps/swigobject.swg +++ b/Lib/typemaps/swigobject.swg @@ -30,7 +30,7 @@ #if defined(SWIG_DIRECTOR_TYPEMAPS) -%typemap(directorin) SWIG_Object "$input = $1_name;"; +%typemap(directorin) SWIG_Object "$input = $1;"; %typemap(directorout) SWIG_Object "$result = $input;"; #endif /* SWIG_DIRECTOR_TYPEMAPS */ diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg index 47baabf52..4f5e01afa 100644 --- a/Lib/typemaps/swigtype.swg +++ b/Lib/typemaps/swigtype.swg @@ -344,15 +344,15 @@ /* directorin */ %typemap(directorin,noblock=1) SWIGTYPE *, SWIGTYPE *const& { - $input = SWIG_NewPointerObj(%as_voidptr($1_name), $descriptor, %newpointer_flags); + $input = SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags); } %typemap(directorin,noblock=1) SWIGTYPE { - $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $&descriptor, %newpointer_flags); + $input = SWIG_NewPointerObj(%as_voidptr(&$1), $&descriptor, %newpointer_flags); } %typemap(directorin,noblock=1) SWIGTYPE & { - $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags); + $input = SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags); } /* directorout */ @@ -480,7 +480,7 @@ /* directorin */ %typemap(directorin,noblock=1) SWIGTYPE (CLASS::*) { - $input = SWIG_NewMemberObj(%as_voidptr(&$1_name), sizeof($type), $descriptor); + $input = SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor); } /* directorout */ @@ -540,7 +540,7 @@ /* directorin */ %typemap(directorin,noblock=1) SWIGTYPE ((*)(ANY)) { - $input = SWIG_NewFunctionPtrObj((void*)($1_name), $descriptor); + $input = SWIG_NewFunctionPtrObj((void*)($1), $descriptor); } /* directorout */ diff --git a/Lib/typemaps/valtypes.swg b/Lib/typemaps/valtypes.swg index a72e719cd..11eac5985 100644 --- a/Lib/typemaps/valtypes.swg +++ b/Lib/typemaps/valtypes.swg @@ -97,10 +97,10 @@ %define %value_directorin_typemap(from_meth,frag,Type...) %typemap(directorin,noblock=1,fragment=frag) Type *DIRECTORIN { - $input = from_meth(%static_cast(*$1_name,Type)); + $input = from_meth(%static_cast(*$1,Type)); } %typemap(directorin,noblock=1,fragment=frag) Type, const Type& { - $input = from_meth(%static_cast($1_name,Type)); + $input = from_meth(%static_cast($1,Type)); } %enddef diff --git a/Lib/typemaps/void.swg b/Lib/typemaps/void.swg index aa1258312..bbd68ed87 100644 --- a/Lib/typemaps/void.swg +++ b/Lib/typemaps/void.swg @@ -56,7 +56,7 @@ %typemap(directorin,noblock=1) void *, void const*, void *const, void const *const, void const *&, void *const &, void const *const & { - $input = SWIG_NewPointerObj(%as_voidptr($1_name), $descriptor, %newpointer_flags); + $input = SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags); } /* directorout */ diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 2184440c1..8f314c964 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1471,6 +1471,8 @@ public: /* attach typemaps to arguments (C/C++ -> Ocaml) */ String *arglist = NewString(""); + Swig_director_parms_fixup(l); + Swig_typemap_attach_parms("in", l, 0); Swig_typemap_attach_parms("directorin", l, 0); Swig_typemap_attach_parms("directorargout", l, w); From b50e6858ac3e7ac95ea669692416ec1633f9738c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 21 Dec 2011 07:18:45 +0000 Subject: [PATCH 125/147] keyword variable workaround in testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12880 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../extend_constructor_destructor.i | 26 +++++++++---------- .../extend_constructor_destructor_runme.java | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Examples/test-suite/extend_constructor_destructor.i b/Examples/test-suite/extend_constructor_destructor.i index 08a9dc2bf..a0ab1a0f6 100644 --- a/Examples/test-suite/extend_constructor_destructor.i +++ b/Examples/test-suite/extend_constructor_destructor.i @@ -1,7 +1,7 @@ %module extend_constructor_destructor %inline %{ -int global = 0; +int globalVar = 0; namespace Space { typedef struct tagAStruct { @@ -41,11 +41,11 @@ namespace Space { tagAStruct(int ivar0) { Space::AStruct *s = new Space::AStruct(); s->ivar = ivar0; - global = ivar0; + globalVar = ivar0; return s; } ~tagAStruct() { - global = -$self->ivar; + globalVar = -$self->ivar; delete $self; } } @@ -54,11 +54,11 @@ namespace Space { BStruct(int ivar0) { Space::BStruct *s = new Space::BStruct(); s->ivar = ivar0; - global = ivar0; + globalVar = ivar0; return s; } ~BStruct() { - global = -$self->ivar; + globalVar = -$self->ivar; delete $self; } } @@ -67,11 +67,11 @@ namespace Space { CStruct(int ivar0) { Space::CStruct *s = new Space::CStruct(); s->ivar = ivar0; - global = ivar0; + globalVar = ivar0; return s; } ~CStruct() { - global = -$self->ivar; + globalVar = -$self->ivar; delete $self; } } @@ -80,11 +80,11 @@ namespace Space { DStruct(int ivar0) { Space::DStruct *s = new Space::DStruct(); s->ivar = ivar0; - global = ivar0; + globalVar = ivar0; return s; } ~DStruct() { - global = -$self->ivar; + globalVar = -$self->ivar; delete $self; } } @@ -95,11 +95,11 @@ namespace Space { EStruct(int ivar0) { EStruct *s = new EStruct(); s->ivar = ivar0; - global = ivar0; + globalVar = ivar0; return s; } ~EStruct() { - global = -$self->ivar; + globalVar = -$self->ivar; delete $self; } } @@ -109,11 +109,11 @@ namespace Space { FFStruct(int ivar0) { Space::FFStruct *s = new Space::FFStruct(); s->ivar = ivar0; - global = ivar0; + globalVar = ivar0; return s; } ~FFStruct() { - global = -$self->ivar; + globalVar = -$self->ivar; delete $self; } } diff --git a/Examples/test-suite/java/extend_constructor_destructor_runme.java b/Examples/test-suite/java/extend_constructor_destructor_runme.java index de1515839..db7a2bba3 100644 --- a/Examples/test-suite/java/extend_constructor_destructor_runme.java +++ b/Examples/test-suite/java/extend_constructor_destructor_runme.java @@ -44,7 +44,7 @@ public class extend_constructor_destructor_runme { } public static void checkGlobal(int val) { - int global = extend_constructor_destructor.getGlobal(); + int global = extend_constructor_destructor.getGlobalVar(); if (global != val) throw new RuntimeException("global value incorrect. Expected: " + val + " got: " + global); } From a082b1e069daeae1620fcd6109e71c5a568dcbfb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 21 Dec 2011 21:58:34 +0000 Subject: [PATCH 126/147] The 'directorin' typemap now accepts , etc expansions instead of having to use workarounds - _name, _name etc. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12881 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 936a8bc46..7f60b3d3f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2011-12-21: wsfulton + The 'directorin' typemap now accepts $1, $2 etc expansions instead of having to use workarounds - + $1_name, $2_name etc. + 2011-12-20: wsfulton [Java] Add (char *STRING, size_t LENGTH) director typemaps. From a5f8ffba91f83e0b813331809eae862e24879e35 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 21 Dec 2011 22:01:27 +0000 Subject: [PATCH 127/147] Remove warning: 'self' is a ruby keyword, renaming to 'C_self' since improving autodoc for Ruby git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12882 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/director_basic.i | 4 ++-- Lib/cpointer.i | 36 ++++++++++++++-------------- Lib/typemaps/cpointer.swg | 26 ++++++++++---------- Source/Modules/ruby.cxx | 17 ++++++------- 4 files changed, 40 insertions(+), 43 deletions(-) diff --git a/Examples/test-suite/director_basic.i b/Examples/test-suite/director_basic.i index 12cb0db65..56864f4a7 100644 --- a/Examples/test-suite/director_basic.i +++ b/Examples/test-suite/director_basic.i @@ -10,7 +10,7 @@ virtual std::string ping() { return "Foo::ping()"; } virtual std::string pong() { return "Foo::pong();" + ping(); } - static Foo* get_self(Foo *self) {return self;} + static Foo* get_self(Foo *slf) {return slf;} }; @@ -27,7 +27,7 @@ virtual std::string ping(); virtual std::string pong(); - static Foo* get_self(Foo *self); + static Foo* get_self(Foo *slf); }; diff --git a/Lib/cpointer.i b/Lib/cpointer.i index 6b15a8417..881c511fc 100644 --- a/Lib/cpointer.i +++ b/Lib/cpointer.i @@ -55,14 +55,14 @@ NAME() { return new TYPE(); } ~NAME() { - if (self) delete self; + if ($self) delete $self; } #else NAME() { return (TYPE *) calloc(1,sizeof(TYPE)); } ~NAME() { - if (self) free(self); + if ($self) free($self); } #endif } @@ -70,13 +70,13 @@ NAME() { %extend NAME { void assign(TYPE value) { - *self = value; + *$self = value; } TYPE value() { - return *self; + return *$self; } TYPE * cast() { - return self; + return $self; } static NAME * frompointer(TYPE *t) { return (NAME *) t; @@ -126,34 +126,34 @@ static TYPE *copy_##NAME(TYPE value) { %} #ifdef __cplusplus %{ return new TYPE(value); %} #else -%{ TYPE *self = (TYPE *) calloc(1,sizeof(TYPE)); - *self = value; - return self; %} +%{ TYPE *obj = (TYPE *) calloc(1,sizeof(TYPE)); + *obj = value; + return obj; %} #endif %{} -static void delete_##NAME(TYPE *self) { %} +static void delete_##NAME(TYPE *obj) { %} #ifdef __cplusplus -%{ if (self) delete self; %} +%{ if (obj) delete obj; %} #else -%{ if (self) free(self); %} +%{ if (obj) free(obj); %} #endif %{} -static void NAME ##_assign(TYPE *self, TYPE value) { - *self = value; +static void NAME ##_assign(TYPE *obj, TYPE value) { + *obj = value; } -static TYPE NAME ##_value(TYPE *self) { - return *self; +static TYPE NAME ##_value(TYPE *obj) { + return *obj; } %} TYPE *new_##NAME(); TYPE *copy_##NAME(TYPE value); -void delete_##NAME(TYPE *self); -void NAME##_assign(TYPE *self, TYPE value); -TYPE NAME##_value(TYPE *self); +void delete_##NAME(TYPE *obj); +void NAME##_assign(TYPE *obj, TYPE value); +TYPE NAME##_value(TYPE *obj); %enddef diff --git a/Lib/typemaps/cpointer.swg b/Lib/typemaps/cpointer.swg index f797a6895..94bbbd6bc 100644 --- a/Lib/typemaps/cpointer.swg +++ b/Lib/typemaps/cpointer.swg @@ -55,20 +55,20 @@ typedef struct { return %new_instance(TYPE); } ~NAME() { - if (self) %delete(self); + if ($self) %delete($self); } } %extend NAME { void assign(TYPE value) { - *self = value; + *$self = value; } TYPE value() { - return *self; + return *$self; } TYPE * cast() { - return self; + return $self; } static NAME * frompointer(TYPE *t) { return (NAME *) t; @@ -113,24 +113,24 @@ typedef struct { return %new_copy(value, TYPE); } - static void delete_##NAME(TYPE *self) { - if (self) %delete(self); + static void delete_##NAME(TYPE *obj) { + if (obj) %delete(obj); } - static void NAME ##_assign(TYPE *self, TYPE value) { - *self = value; + static void NAME ##_assign(TYPE *obj, TYPE value) { + *obj = value; } - static TYPE NAME ##_value(TYPE *self) { - return *self; + static TYPE NAME ##_value(TYPE *obj) { + return *obj; } %} TYPE *new_##NAME(); TYPE *copy_##NAME(TYPE value); -void delete_##NAME(TYPE *self); -void NAME##_assign(TYPE *self, TYPE value); -TYPE NAME##_value(TYPE *self); +void delete_##NAME(TYPE *obj); +void NAME##_assign(TYPE *obj, TYPE value); +TYPE NAME##_value(TYPE *obj); %enddef diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index f9582b8f4..5520ff2dc 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -657,9 +657,9 @@ private: Printf(doc, " %s.new(%s)", class_name, paramList); else Printf(doc, " %s.new", class_name); - } else - Printf(doc, " %s.new(%s)", class_name, - make_autodocParmList(n, showTypes)); + } else { + Printf(doc, " %s.new(%s)", class_name, make_autodocParmList(n, showTypes)); + } break; case AUTODOC_DTOR: @@ -2640,9 +2640,12 @@ public: current = CONSTRUCTOR_ALLOCATE; Swig_name_register("construct", "%n%c_allocate"); - Language::constructorHandler(n); + String* docs = docstring(n, AUTODOC_CTOR); + Printf(f_wrappers, "%s", docs); + Delete(docs); + /* * If we're wrapping the constructor of a C++ director class, prepend a new parameter * to receive the scripting language object (e.g. 'self') @@ -2665,13 +2668,7 @@ public: Delete(self); } - - /* Now do the instance initialize method */ - String* docs = docstring(n, AUTODOC_CTOR); - Printf(f_wrappers, "%s", docs); - Delete(docs); - current = CONSTRUCTOR_INITIALIZE; Swig_name_register("construct", "new_%n%c"); Language::constructorHandler(n); From 5d678a7b09291709bd1e8e3a04b41641103063dd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 22 Dec 2011 21:14:09 +0000 Subject: [PATCH 128/147] Fix regression introduced in r12784 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12883 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/ruby.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 5520ff2dc..f778b0af5 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2369,9 +2369,7 @@ public: if (!Getattr(n, "feature:onlychildren")) { String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); - String *tdname = Getattr(n, "tdname"); - name = tdname ? tdname : name; String *namestr = SwigType_namestr(name); klass = RCLASS(classes, Char(namestr)); if (!klass) { From 06b81fca823d2a8646356ef6c401ff0489c69b20 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 22 Dec 2011 21:42:02 +0000 Subject: [PATCH 129/147] cosmetics git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12884 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 7f60b3d3f..14e78d84d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -198,7 +198,7 @@ Version 2.0.5 (in progress) B(){} // NOT a constructor --illegal, but was accepted by SWIG } B; - For C code, the fix now results in use the use of 'struct A *' instead of just 'B *' in + For C code, the fix now results in the use of 'struct A *' instead of just 'B *' in the generated code when wrapping members in A, but ultimately this does not matter, as they are the same thing. From f29193e5a749f68239f7b90dd595ba8d29ee9210 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 22 Dec 2011 21:48:33 +0000 Subject: [PATCH 130/147] Use svn:eol-style CRLF for Visual Studio project files git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12885 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/csharp/callback/example-cs.csproj | 198 ++++----- Examples/csharp/callback/example-vc.vcproj | 316 +++++++------- Examples/csharp/callback/example.sln | 60 +-- Examples/csharp/class/example-cs.csproj | 208 ++++----- Examples/csharp/class/example-vc.vcproj | 316 +++++++------- Examples/csharp/class/example.sln | 60 +-- Examples/csharp/enum/example-cs.csproj | 198 ++++----- Examples/csharp/enum/example-vc.vcproj | 316 +++++++------- Examples/csharp/enum/example.sln | 60 +-- Examples/csharp/extend/example-cs.csproj | 208 ++++----- Examples/csharp/extend/example-vc.vcproj | 316 +++++++------- Examples/csharp/extend/example.sln | 60 +-- Examples/csharp/funcptr/example-cs.csproj | 188 ++++----- Examples/csharp/funcptr/example-vc.vcproj | 320 +++++++------- Examples/csharp/funcptr/example.sln | 60 +-- Examples/csharp/reference/example-cs.csproj | 198 ++++----- Examples/csharp/reference/example-vc.vcproj | 316 +++++++------- Examples/csharp/reference/example.sln | 60 +-- Examples/csharp/simple/example-cs.csproj | 178 ++++---- Examples/csharp/simple/example-vc.vcproj | 444 ++++++++++---------- Examples/csharp/simple/example.sln | 52 +-- Examples/csharp/template/example-cs.csproj | 218 +++++----- Examples/csharp/template/example-vc.vcproj | 314 +++++++------- Examples/csharp/template/example.sln | 60 +-- Examples/csharp/variables/example-cs.csproj | 198 ++++----- Examples/csharp/variables/example-vc.vcproj | 314 +++++++------- Examples/csharp/variables/example.sln | 60 +-- 27 files changed, 2648 insertions(+), 2648 deletions(-) diff --git a/Examples/csharp/callback/example-cs.csproj b/Examples/csharp/callback/example-cs.csproj index 5fc34527f..ce5ccfd9a 100644 --- a/Examples/csharp/callback/example-cs.csproj +++ b/Examples/csharp/callback/example-cs.csproj @@ -1,99 +1,99 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/callback/example-vc.vcproj b/Examples/csharp/callback/example-vc.vcproj index 7c0b8ef13..8cb4780f4 100644 --- a/Examples/csharp/callback/example-vc.vcproj +++ b/Examples/csharp/callback/example-vc.vcproj @@ -1,158 +1,158 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/callback/example.sln b/Examples/csharp/callback/example.sln index 28b9851b0..88995ffd3 100644 --- a/Examples/csharp/callback/example.sln +++ b/Examples/csharp/callback/example.sln @@ -1,30 +1,30 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" - ProjectSection(ProjectDependencies) = postProject - {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" + ProjectSection(ProjectDependencies) = postProject + {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Examples/csharp/class/example-cs.csproj b/Examples/csharp/class/example-cs.csproj index 0b9ea2e05..8b105d7fc 100644 --- a/Examples/csharp/class/example-cs.csproj +++ b/Examples/csharp/class/example-cs.csproj @@ -1,104 +1,104 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/class/example-vc.vcproj b/Examples/csharp/class/example-vc.vcproj index 7c0b8ef13..8cb4780f4 100644 --- a/Examples/csharp/class/example-vc.vcproj +++ b/Examples/csharp/class/example-vc.vcproj @@ -1,158 +1,158 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/class/example.sln b/Examples/csharp/class/example.sln index 28b9851b0..88995ffd3 100644 --- a/Examples/csharp/class/example.sln +++ b/Examples/csharp/class/example.sln @@ -1,30 +1,30 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" - ProjectSection(ProjectDependencies) = postProject - {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" + ProjectSection(ProjectDependencies) = postProject + {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Examples/csharp/enum/example-cs.csproj b/Examples/csharp/enum/example-cs.csproj index 9d37ce2b4..44face8ed 100644 --- a/Examples/csharp/enum/example-cs.csproj +++ b/Examples/csharp/enum/example-cs.csproj @@ -1,99 +1,99 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/enum/example-vc.vcproj b/Examples/csharp/enum/example-vc.vcproj index 7c0b8ef13..8cb4780f4 100644 --- a/Examples/csharp/enum/example-vc.vcproj +++ b/Examples/csharp/enum/example-vc.vcproj @@ -1,158 +1,158 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/enum/example.sln b/Examples/csharp/enum/example.sln index 28b9851b0..88995ffd3 100644 --- a/Examples/csharp/enum/example.sln +++ b/Examples/csharp/enum/example.sln @@ -1,30 +1,30 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" - ProjectSection(ProjectDependencies) = postProject - {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" + ProjectSection(ProjectDependencies) = postProject + {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Examples/csharp/extend/example-cs.csproj b/Examples/csharp/extend/example-cs.csproj index 4e8874669..95923991b 100644 --- a/Examples/csharp/extend/example-cs.csproj +++ b/Examples/csharp/extend/example-cs.csproj @@ -1,104 +1,104 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/extend/example-vc.vcproj b/Examples/csharp/extend/example-vc.vcproj index 7c0b8ef13..8cb4780f4 100644 --- a/Examples/csharp/extend/example-vc.vcproj +++ b/Examples/csharp/extend/example-vc.vcproj @@ -1,158 +1,158 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/extend/example.sln b/Examples/csharp/extend/example.sln index 28b9851b0..88995ffd3 100644 --- a/Examples/csharp/extend/example.sln +++ b/Examples/csharp/extend/example.sln @@ -1,30 +1,30 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" - ProjectSection(ProjectDependencies) = postProject - {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" + ProjectSection(ProjectDependencies) = postProject + {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Examples/csharp/funcptr/example-cs.csproj b/Examples/csharp/funcptr/example-cs.csproj index 5ff0d9da9..5a107c528 100644 --- a/Examples/csharp/funcptr/example-cs.csproj +++ b/Examples/csharp/funcptr/example-cs.csproj @@ -1,94 +1,94 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/funcptr/example-vc.vcproj b/Examples/csharp/funcptr/example-vc.vcproj index 03047bfb0..6ce8e8d77 100644 --- a/Examples/csharp/funcptr/example-vc.vcproj +++ b/Examples/csharp/funcptr/example-vc.vcproj @@ -1,160 +1,160 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/funcptr/example.sln b/Examples/csharp/funcptr/example.sln index 28b9851b0..88995ffd3 100644 --- a/Examples/csharp/funcptr/example.sln +++ b/Examples/csharp/funcptr/example.sln @@ -1,30 +1,30 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" - ProjectSection(ProjectDependencies) = postProject - {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" + ProjectSection(ProjectDependencies) = postProject + {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Examples/csharp/reference/example-cs.csproj b/Examples/csharp/reference/example-cs.csproj index e55912bdc..a3efbe036 100644 --- a/Examples/csharp/reference/example-cs.csproj +++ b/Examples/csharp/reference/example-cs.csproj @@ -1,99 +1,99 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/reference/example-vc.vcproj b/Examples/csharp/reference/example-vc.vcproj index 7c0b8ef13..8cb4780f4 100644 --- a/Examples/csharp/reference/example-vc.vcproj +++ b/Examples/csharp/reference/example-vc.vcproj @@ -1,158 +1,158 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/reference/example.sln b/Examples/csharp/reference/example.sln index 28b9851b0..88995ffd3 100644 --- a/Examples/csharp/reference/example.sln +++ b/Examples/csharp/reference/example.sln @@ -1,30 +1,30 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" - ProjectSection(ProjectDependencies) = postProject - {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" + ProjectSection(ProjectDependencies) = postProject + {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Examples/csharp/simple/example-cs.csproj b/Examples/csharp/simple/example-cs.csproj index d801057d9..3d91f9a47 100644 --- a/Examples/csharp/simple/example-cs.csproj +++ b/Examples/csharp/simple/example-cs.csproj @@ -1,89 +1,89 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/simple/example-vc.vcproj b/Examples/csharp/simple/example-vc.vcproj index 14f50049b..43f261231 100644 --- a/Examples/csharp/simple/example-vc.vcproj +++ b/Examples/csharp/simple/example-vc.vcproj @@ -1,222 +1,222 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/simple/example.sln b/Examples/csharp/simple/example.sln index 9967f7e20..3ebbba5c6 100644 --- a/Examples/csharp/simple/example.sln +++ b/Examples/csharp/simple/example.sln @@ -1,26 +1,26 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" - ProjectSection(ProjectDependencies) = postProject - {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|Any CPU - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|Any CPU - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" + ProjectSection(ProjectDependencies) = postProject + {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|Any CPU + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|Any CPU + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Examples/csharp/template/example-cs.csproj b/Examples/csharp/template/example-cs.csproj index b51122ba6..bf17c141f 100644 --- a/Examples/csharp/template/example-cs.csproj +++ b/Examples/csharp/template/example-cs.csproj @@ -1,109 +1,109 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/template/example-vc.vcproj b/Examples/csharp/template/example-vc.vcproj index 867e694c1..367bab8ac 100644 --- a/Examples/csharp/template/example-vc.vcproj +++ b/Examples/csharp/template/example-vc.vcproj @@ -1,157 +1,157 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/template/example.sln b/Examples/csharp/template/example.sln index 28b9851b0..88995ffd3 100644 --- a/Examples/csharp/template/example.sln +++ b/Examples/csharp/template/example.sln @@ -1,30 +1,30 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" - ProjectSection(ProjectDependencies) = postProject - {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" + ProjectSection(ProjectDependencies) = postProject + {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Examples/csharp/variables/example-cs.csproj b/Examples/csharp/variables/example-cs.csproj index f0e015929..a73c879fb 100644 --- a/Examples/csharp/variables/example-cs.csproj +++ b/Examples/csharp/variables/example-cs.csproj @@ -1,99 +1,99 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/variables/example-vc.vcproj b/Examples/csharp/variables/example-vc.vcproj index be0dfc742..f56c51945 100644 --- a/Examples/csharp/variables/example-vc.vcproj +++ b/Examples/csharp/variables/example-vc.vcproj @@ -1,157 +1,157 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/csharp/variables/example.sln b/Examples/csharp/variables/example.sln index 28b9851b0..88995ffd3 100644 --- a/Examples/csharp/variables/example.sln +++ b/Examples/csharp/variables/example.sln @@ -1,30 +1,30 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" - ProjectSection(ProjectDependencies) = postProject - {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET - {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 - {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}" + ProjectSection(ProjectDependencies) = postProject + {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET + {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32 + {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal From 0770ea75f42455421d4aa314cc0c3c526f2b78e0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 22 Dec 2011 21:52:37 +0000 Subject: [PATCH 131/147] Remove a warning when building in C# project files when they are converted for use by Visual Studio 2010 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12886 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/csharp/callback/example-vc.vcproj | 8 ++++---- Examples/csharp/class/example-vc.vcproj | 8 ++++---- Examples/csharp/enum/example-vc.vcproj | 8 ++++---- Examples/csharp/extend/example-vc.vcproj | 8 ++++---- Examples/csharp/funcptr/example-vc.vcproj | 8 ++++---- Examples/csharp/reference/example-vc.vcproj | 8 ++++---- Examples/csharp/simple/example-vc.vcproj | 8 ++++---- Examples/csharp/template/example-vc.vcproj | 8 ++++---- Examples/csharp/variables/example-vc.vcproj | 8 ++++---- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Examples/csharp/callback/example-vc.vcproj b/Examples/csharp/callback/example-vc.vcproj index 8cb4780f4..5788bc9c7 100644 --- a/Examples/csharp/callback/example-vc.vcproj +++ b/Examples/csharp/callback/example-vc.vcproj @@ -2,7 +2,7 @@ @@ -34,9 +34,9 @@ OutputFile="example.dll" LinkIncremental="2" GenerateDebugInformation="TRUE" - ProgramDatabaseFile="$(OutDir)/example-vc.pdb" + ProgramDatabaseFile="$(OutDir)/example.pdb" SubSystem="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> @@ -83,7 +83,7 @@ SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> diff --git a/Examples/csharp/class/example-vc.vcproj b/Examples/csharp/class/example-vc.vcproj index 8cb4780f4..5788bc9c7 100644 --- a/Examples/csharp/class/example-vc.vcproj +++ b/Examples/csharp/class/example-vc.vcproj @@ -2,7 +2,7 @@ @@ -34,9 +34,9 @@ OutputFile="example.dll" LinkIncremental="2" GenerateDebugInformation="TRUE" - ProgramDatabaseFile="$(OutDir)/example-vc.pdb" + ProgramDatabaseFile="$(OutDir)/example.pdb" SubSystem="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> @@ -83,7 +83,7 @@ SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> diff --git a/Examples/csharp/enum/example-vc.vcproj b/Examples/csharp/enum/example-vc.vcproj index 8cb4780f4..5788bc9c7 100644 --- a/Examples/csharp/enum/example-vc.vcproj +++ b/Examples/csharp/enum/example-vc.vcproj @@ -2,7 +2,7 @@ @@ -34,9 +34,9 @@ OutputFile="example.dll" LinkIncremental="2" GenerateDebugInformation="TRUE" - ProgramDatabaseFile="$(OutDir)/example-vc.pdb" + ProgramDatabaseFile="$(OutDir)/example.pdb" SubSystem="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> @@ -83,7 +83,7 @@ SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> diff --git a/Examples/csharp/extend/example-vc.vcproj b/Examples/csharp/extend/example-vc.vcproj index 8cb4780f4..5788bc9c7 100644 --- a/Examples/csharp/extend/example-vc.vcproj +++ b/Examples/csharp/extend/example-vc.vcproj @@ -2,7 +2,7 @@ @@ -34,9 +34,9 @@ OutputFile="example.dll" LinkIncremental="2" GenerateDebugInformation="TRUE" - ProgramDatabaseFile="$(OutDir)/example-vc.pdb" + ProgramDatabaseFile="$(OutDir)/example.pdb" SubSystem="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> @@ -83,7 +83,7 @@ SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> diff --git a/Examples/csharp/funcptr/example-vc.vcproj b/Examples/csharp/funcptr/example-vc.vcproj index 6ce8e8d77..7ba8cbde1 100644 --- a/Examples/csharp/funcptr/example-vc.vcproj +++ b/Examples/csharp/funcptr/example-vc.vcproj @@ -2,7 +2,7 @@ @@ -34,9 +34,9 @@ OutputFile="example.dll" LinkIncremental="2" GenerateDebugInformation="TRUE" - ProgramDatabaseFile="$(OutDir)/example-vc.pdb" + ProgramDatabaseFile="$(OutDir)/example.pdb" SubSystem="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> @@ -83,7 +83,7 @@ SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> diff --git a/Examples/csharp/reference/example-vc.vcproj b/Examples/csharp/reference/example-vc.vcproj index 8cb4780f4..5788bc9c7 100644 --- a/Examples/csharp/reference/example-vc.vcproj +++ b/Examples/csharp/reference/example-vc.vcproj @@ -2,7 +2,7 @@ @@ -34,9 +34,9 @@ OutputFile="example.dll" LinkIncremental="2" GenerateDebugInformation="TRUE" - ProgramDatabaseFile="$(OutDir)/example-vc.pdb" + ProgramDatabaseFile="$(OutDir)/example.pdb" SubSystem="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> @@ -83,7 +83,7 @@ SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> diff --git a/Examples/csharp/simple/example-vc.vcproj b/Examples/csharp/simple/example-vc.vcproj index 43f261231..ec289c6eb 100644 --- a/Examples/csharp/simple/example-vc.vcproj +++ b/Examples/csharp/simple/example-vc.vcproj @@ -2,7 +2,7 @@ @@ -63,9 +63,9 @@ OutputFile="example.dll" LinkIncremental="2" GenerateDebugInformation="true" - ProgramDatabaseFile="$(OutDir)/example-vc.pdb" + ProgramDatabaseFile="$(OutDir)/example.pdb" SubSystem="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1" /> @@ -34,9 +34,9 @@ OutputFile="example.dll" LinkIncremental="2" GenerateDebugInformation="TRUE" - ProgramDatabaseFile="$(OutDir)/example-vc.pdb" + ProgramDatabaseFile="$(OutDir)/example.pdb" SubSystem="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> @@ -83,7 +83,7 @@ SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> diff --git a/Examples/csharp/variables/example-vc.vcproj b/Examples/csharp/variables/example-vc.vcproj index f56c51945..acd55a379 100644 --- a/Examples/csharp/variables/example-vc.vcproj +++ b/Examples/csharp/variables/example-vc.vcproj @@ -2,7 +2,7 @@ @@ -34,9 +34,9 @@ OutputFile="example.dll" LinkIncremental="2" GenerateDebugInformation="TRUE" - ProgramDatabaseFile="$(OutDir)/example-vc.pdb" + ProgramDatabaseFile="$(OutDir)/example.pdb" SubSystem="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> @@ -83,7 +83,7 @@ SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" - ImportLibrary="$(OutDir)/example-vc.lib" + ImportLibrary="$(OutDir)/example.lib" TargetMachine="1"/> From de5a78c7810ca16a8d97e19403e96dca3dea67e5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Dec 2011 16:27:15 +0000 Subject: [PATCH 132/147] Expand symname special variable in director typemaps git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12887 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 3 +- Source/Modules/d.cxx | 3 +- Source/Modules/go.cxx | 66 ++++++++++++++++++++------------------- Source/Modules/java.cxx | 3 +- 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index fe28e0ae9..bee1004cc 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3856,7 +3856,7 @@ public: Delete(extra_method_name); } - /* emit code */ + /* emit the director method */ if (status == SWIG_OK && output_director) { if (!is_void) { Replaceall(w->code, "$null", qualified_return); @@ -3866,6 +3866,7 @@ public: if (!ignored_method) Printv(director_delegate_callback, "\n", callback_def, callback_code, NIL); if (!Getattr(n, "defaultargs")) { + Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, inline_extra_method, NIL); diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 8e13799bd..6a01ed8a4 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -2344,7 +2344,7 @@ public: Delete(extra_method_name); } - /* emit code */ + /* emit the director method */ if (status == SWIG_OK && output_director) { if (!is_void) { Replaceall(w->code, "$null", qualified_return); @@ -2354,6 +2354,7 @@ public: if (!ignored_method) Printv(director_dcallbacks_code, callback_def, callback_code, NIL); if (!Getattr(n, "defaultargs")) { + Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, inline_extra_method, NIL); diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 4e5f6d5ca..2e077cde4 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -2859,6 +2859,7 @@ private: * ------------------------------------------------------------ */ int oneClassDirectorMethod(Node *n, Node *parent, String *super) { + String *symname = Getattr(n, "sym:name"); if (!checkFunctionVisibility(n, parent)) { return SWIG_OK; } @@ -2942,12 +2943,12 @@ private: } Parm *p = 0; - Wrapper *f = NewWrapper(); + Wrapper *w = NewWrapper(); Swig_director_parms_fixup(parms); - Swig_typemap_attach_parms("directorin", parms, f); - Swig_typemap_attach_parms("directorargout", parms, f); + Swig_typemap_attach_parms("directorin", parms, w); + Swig_typemap_attach_parms("directorargout", parms, w); if (!is_ignored) { // We use an interface to see if this method is defined in Go. @@ -3354,29 +3355,29 @@ private: String *qname = NewString(""); Printv(qname, "SwigDirector_", class_name, "::", Getattr(n, "name"), NULL); decl = Swig_method_decl(rtype, Getattr(n, "decl"), qname, parms, 0, 0); - Printv(f->def, decl, NULL); + Printv(w->def, decl, NULL); Delete(decl); Delete(qname); String *throws = buildThrow(n); if (throws) { Printv(f_c_directors_h, " ", throws, NULL); - Printv(f->def, " ", throws, NULL); + Printv(w->def, " ", throws, NULL); Delete(throws); } Printv(f_c_directors_h, ";\n", NULL); - Printv(f->def, " {\n", NULL); + Printv(w->def, " {\n", NULL); if (SwigType_type(result) != T_VOID) { - Wrapper_add_local(f, "c_result", SwigType_lstr(Getattr(n, "returntype"), "c_result")); + Wrapper_add_local(w, "c_result", SwigType_lstr(Getattr(n, "returntype"), "c_result")); } if (!is_ignored) { if (!gccgo_flag) { - Printv(f->code, " struct {\n", NULL); - Printv(f->code, " void *go_val;\n", NULL); + Printv(w->code, " struct {\n", NULL); + Printv(w->code, " void *go_val;\n", NULL); p = parms; while (p) { @@ -3385,21 +3386,21 @@ private: } String *ln = Getattr(p, "lname"); String *cg = gcCTypeForGoValue(p, Getattr(p, "type"), ln); - Printv(f->code, " ", cg, ";\n", NULL); + Printv(w->code, " ", cg, ";\n", NULL); Delete(cg); p = Getattr(p, "tmap:directorin:next"); } if (SwigType_type(result) != T_VOID) { - Printv(f->code, " long : 0;\n", NULL); + Printv(w->code, " long : 0;\n", NULL); String *rname = NewString(Swig_cresult_name()); String *cg = gcCTypeForGoValue(n, result, rname); - Printv(f->code, " ", cg, ";\n", NULL); + Printv(w->code, " ", cg, ";\n", NULL); Delete(cg); Delete(rname); } - Printv(f->code, " } swig_a;\n", NULL); - Printv(f->code, " swig_a.go_val = go_val;\n", NULL); + Printv(w->code, " } swig_a;\n", NULL); + Printv(w->code, " swig_a.go_val = go_val;\n", NULL); p = parms; while (p) { @@ -3418,12 +3419,12 @@ private: Replaceall(tm, "$input", input); Replaceall(tm, "$owner", "0"); Delete(input); - Printv(f->code, "\t", tm, "\n", NULL); + Printv(w->code, "\t", tm, "\n", NULL); } p = Getattr(p, "tmap:directorin:next"); } - Printv(f->code, " crosscall2(", callback_wname, ", &swig_a, (int) sizeof swig_a);\n", NULL); + Printv(w->code, " crosscall2(", callback_wname, ", &swig_a, (int) sizeof swig_a);\n", NULL); if (SwigType_type(result) != T_VOID) { String *rname = NewString("c_result"); @@ -3436,9 +3437,9 @@ private: static const String *swig_a_result = NewStringf("swig_a.%s", Swig_cresult_name()); Replaceall(tm, "$input", swig_a_result); Replaceall(tm, "$result", "c_result"); - Printv(f->code, " ", tm, "\n", NULL); + Printv(w->code, " ", tm, "\n", NULL); String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result"); - Printv(f->code, " return ", retstr, ";\n", NULL); + Printv(w->code, " return ", retstr, ";\n", NULL); Delete(retstr); Delete(tm); } @@ -3458,7 +3459,7 @@ private: if (SwigType_type(result) != T_VOID) { String *r = NewString(Swig_cresult_name()); String *tm = gccgoCTypeForGoValue(n, result, r); - Wrapper_add_local(f, r, tm); + Wrapper_add_local(w, r, tm); Delete(tm); Delete(r); } @@ -3476,7 +3477,7 @@ private: Setattr(p, "emit:input", pn); String *tm = gccgoCTypeForGoValue(n, Getattr(p, "type"), pn); - Wrapper_add_local(f, pn, tm); + Wrapper_add_local(w, pn, tm); Delete(tm); tm = Getattr(p, "tmap:directorin"); @@ -3486,7 +3487,7 @@ private: } else { Replaceall(tm, "$input", pn); Replaceall(tm, "$owner", 0); - Printv(f->code, " ", tm, "\n", NULL); + Printv(w->code, " ", tm, "\n", NULL); Printv(args, ", ", pn, NULL); } @@ -3494,11 +3495,11 @@ private: p = Getattr(p, "tmap:directorin:next"); } - Printv(f->code, " ", NULL); + Printv(w->code, " ", NULL); if (SwigType_type(result) != T_VOID) { - Printv(f->code, Swig_cresult_name(), " = ", NULL); + Printv(w->code, Swig_cresult_name(), " = ", NULL); } - Printv(f->code, callback_wname, "(go_val", args, ");\n", NULL); + Printv(w->code, callback_wname, "(go_val", args, ");\n", NULL); if (SwigType_type(result) != T_VOID) { String *rname = NewString("c_result"); @@ -3510,9 +3511,9 @@ private: } else { Replaceall(tm, "$input", Swig_cresult_name()); Replaceall(tm, "$result", "c_result"); - Printv(f->code, " ", tm, "\n", NULL); + Printv(w->code, " ", tm, "\n", NULL); String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result"); - Printv(f->code, " return ", retstr, ";\n", NULL); + Printv(w->code, " return ", retstr, ";\n", NULL); Delete(retstr); Delete(tm); } @@ -3527,7 +3528,7 @@ private: if ((tm = Getattr(p, "tmap:directorargout"))) { Replaceall(tm, "$result", "jresult"); Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); - Printv(f->code, tm, "\n", NIL); + Printv(w->code, tm, "\n", NIL); p = Getattr(p, "tmap:directorargout:next"); } else { p = nextSibling(p); @@ -3535,19 +3536,20 @@ private: } } else { assert(is_pure_virtual); - Printv(f->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL); + Printv(w->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL); if (SwigType_type(result) != T_VOID) { String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result"); - Printv(f->code, " return ", retstr, ";\n", NULL); + Printv(w->code, " return ", retstr, ";\n", NULL); Delete(retstr); } } - Printv(f->code, "}", NULL); + Printv(w->code, "}", NULL); - Wrapper_print(f, f_c_directors); + Wrapper_print(w, f_c_directors); + Replaceall(w->code, "$symname", symname); - DelWrapper(f); + DelWrapper(w); } Delete(cn); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 3439dacb1..fee9147d9 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -4048,7 +4048,7 @@ public: Delete(extra_method_name); } - /* emit code */ + /* emit the director method */ if (status == SWIG_OK && output_director) { if (!is_void) { Replaceall(w->code, "$null", qualified_return); @@ -4058,6 +4058,7 @@ public: if (!GetFlag(n, "feature:ignore")) Printv(imclass_directors, callback_def, callback_code, NIL); if (!Getattr(n, "defaultargs")) { + Replaceall(w->code, "$symname", symname); Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, inline_extra_method, NIL); From 5ef2affe53dc78d0145f77e234ca0723d4655651 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Dec 2011 20:03:09 +0000 Subject: [PATCH 133/147] Use public visibility for pointer constructor and getCPtr() when using nspace fixes and docs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12888 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Java.html | 7 ++++++- Examples/test-suite/nspace.i | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 9ae05ce7e..76e147be5 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -1934,6 +1934,11 @@ in an unnamed package. +

    +If the resulting use of the nspace feature and hence packages results in a proxy class in one package deriving or using a proxy class from another package, +you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps. +

    +

    24.3.14 C++ templates

    @@ -5585,7 +5590,7 @@ Again this is the same that is in "java.swg", barring the method modifi

    -When using multiple modules it is common to invoke SWIG with a different -package +When using multiple modules or the nspace feature it is common to invoke SWIG with a different -package command line option for each module. However, by default the generated code may not compile if generated classes in one package use generated classes in another package. diff --git a/Examples/test-suite/nspace.i b/Examples/test-suite/nspace.i index 89009b939..65c6aafa1 100644 --- a/Examples/test-suite/nspace.i +++ b/Examples/test-suite/nspace.i @@ -4,6 +4,10 @@ // nspace feature only supported by these languages #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) +#if defined(SWIGJAVA) +SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) +#endif + %nspace; %nonspace Outer::Inner2::NoNSpacePlease; From cd519088604df29a33d241871cff46975be4ddab Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Dec 2011 20:05:00 +0000 Subject: [PATCH 134/147] Use public visibility for pointer constructor and getCPtr() when using nspace fixes and docs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12889 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/nspace_extend.i | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Examples/test-suite/nspace_extend.i b/Examples/test-suite/nspace_extend.i index 47ede95d0..96e97a4ff 100644 --- a/Examples/test-suite/nspace_extend.i +++ b/Examples/test-suite/nspace_extend.i @@ -4,6 +4,9 @@ // nspace feature only supported by these languages #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) +#if defined(SWIGJAVA) +SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) +#endif %nspace; %extend Outer::Inner1::Color { From debd5e9246e19b90e23dea4833e0a93f9e96c3f1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 6 Jan 2012 18:57:25 +0000 Subject: [PATCH 135/147] Add support for %nspace when using directors - Java git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12891 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 + Examples/test-suite/common.mk | 1 + Examples/test-suite/director_nspace.i | 68 +++++++++++++++++++ Examples/test-suite/java/Makefile.in | 1 + .../java/director_nspace_runme.java | 48 +++++++++++++ Source/Modules/java.cxx | 23 +++++-- 6 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 Examples/test-suite/director_nspace.i create mode 100644 Examples/test-suite/java/director_nspace_runme.java diff --git a/CHANGES.current b/CHANGES.current index 14e78d84d..d3c417d45 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2012-01-06: wsfulton + [Java] Patch #3452560 from Brant Kyser - add support for %nspace when using directors. + 2011-12-21: wsfulton The 'directorin' typemap now accepts $1, $2 etc expansions instead of having to use workarounds - $1_name, $2_name etc. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 85cd50244..58d7c14ff 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -173,6 +173,7 @@ CPP_TEST_CASES += \ director_ignore \ director_keywords \ director_namespace_clash \ + director_nspace \ director_nested \ director_overload \ director_primitives \ diff --git a/Examples/test-suite/director_nspace.i b/Examples/test-suite/director_nspace.i new file mode 100644 index 000000000..61190ef3e --- /dev/null +++ b/Examples/test-suite/director_nspace.i @@ -0,0 +1,68 @@ +%module(directors="1") director_nspace + +#ifdef SWIGJAVA +SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) +SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE) +#endif + +%{ +#include + +namespace Bar +{ + class FooBar { + public: + FooBar() {} + FooBar(const FooBar&) {} + virtual ~FooBar() {} + + std::string FooBarDo() { return "Bar::Foo2::Foo2Bar()"; } + }; + + class Foo { + public: + virtual ~Foo() {} + virtual std::string ping() { return "Bar::Foo::ping()"; } + virtual std::string pong() { return "Bar::Foo::pong();" + ping(); } + virtual std::string fooBar(FooBar* fooBar) { return fooBar->FooBarDo(); } + virtual Foo makeFoo() { return Foo(); } + virtual FooBar makeFooBar() { return FooBar(); } + + static Foo* get_self(Foo *self) {return self;} + }; +} + +%} + +%include + +%nspace Bar::Foo; +%nspace Bar::FooBar; + +%feature("director") Bar::Foo; + +namespace Bar +{ + class FooBar { + public: + FooBar(); + FooBar(const FooBar&); + virtual ~FooBar(); + + std::string FooBarDo(); + + }; + + class Foo + { + public: + virtual ~Foo(); + virtual std::string ping(); + virtual std::string pong(); + virtual std::string fooBar(FooBar* fooBar); + virtual Foo makeFoo(); + virtual FooBar makeFooBar(); + + static Foo* get_self(Foo *self); + }; +} diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 1ba888fc1..2f0b27ec2 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -43,6 +43,7 @@ SWIGOPT += -package $(JAVA_PACKAGE) # Custom tests - tests with additional commandline options nspace.%: JAVA_PACKAGE = $*Package nspace_extend.%: JAVA_PACKAGE = $*Package +director_nspace.%: JAVA_PACKAGE = $*Package # Rules for the different types of tests %.cpptest: diff --git a/Examples/test-suite/java/director_nspace_runme.java b/Examples/test-suite/java/director_nspace_runme.java new file mode 100644 index 000000000..4e56f91c2 --- /dev/null +++ b/Examples/test-suite/java/director_nspace_runme.java @@ -0,0 +1,48 @@ +// Make sure that directors are connected and disconnected when used inconjunction with +// the %nspace feature + +public class director_nspace_runme { + + static { + try { + System.loadLibrary("director_nspace"); + } 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[]) { + director_nspace_MyBarFoo myBarFoo = + new director_nspace_MyBarFoo(); + } + +} + +class director_nspace_MyBarFoo extends director_nspacePackage.Bar.Foo { + + @Override + public String ping() { + return "director_nspace_MyBarFoo.ping();"; + } + + @Override + public String pong() { + return "director_nspace_MyBarFoo.pong();" + ping(); + } + + @Override + public String fooBar(director_nspacePackage.Bar.FooBar fooBar) { + return fooBar.FooBarDo(); + } + + @Override + public director_nspacePackage.Bar.Foo makeFoo() { + return new director_nspacePackage.Bar.Foo(); + } + + @Override + public director_nspacePackage.Bar.FooBar makeFooBar() { + return new director_nspacePackage.Bar.FooBar(); + } +} diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index fee9147d9..b04812d05 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -3483,21 +3483,21 @@ public: String *pkg_path = Swig_typemap_lookup("javapackage", p, "", 0); SwigType *type = Getattr(p, "type"); - if (pkg_path && Len(pkg_path) != 0) { - Replaceall(pkg_path, ".", "/"); - } else + if (pkg_path || Len(pkg_path) == 0) pkg_path = package_path; String *descriptor_out = Copy(descriptor_in); - if (Len(pkg_path) > 0) { + substituteClassname(type, descriptor_out, true); + + if (Len(pkg_path) > 0 && Strchr(descriptor_out, '.') == NULL) { Replaceall(descriptor_out, "$packagepath", pkg_path); } else { Replaceall(descriptor_out, "$packagepath/", empty_string); Replaceall(descriptor_out, "$packagepath", empty_string); } - substituteClassname(type, descriptor_out, true); + Replaceall(descriptor_out, ".", "/"); if (pkg_path != package_path) Delete(pkg_path); @@ -3550,6 +3550,11 @@ public: String *imcall_args = NewString(""); int classmeth_off = curr_class_dmethod - first_class_dmethod; bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; + String *qualified_classname = Copy(classname); + String *nspace = getNSpace(); + + if (nspace) + Insert(qualified_classname, 0, NewStringf("%s.%s.", package, nspace)); // Kludge Alert: functionWrapper sets sym:overload properly, but it // isn't at this point, so we have to manufacture it ourselves. At least @@ -3614,7 +3619,7 @@ public: tm = Swig_typemap_lookup("jtype", tp, "", 0); if (tm) { - Printf(callback_def, " public static %s %s(%s self", tm, imclass_dmethod, classname); + Printf(callback_def, " public static %s %s(%s self", tm, imclass_dmethod, qualified_classname); } else { Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s\n", SwigType_str(returntype, 0)); } @@ -3680,6 +3685,7 @@ public: Delete(adjustedreturntypeparm); Delete(retpm); + Delete(qualified_classname); } Swig_director_parms_fixup(l); @@ -4259,7 +4265,10 @@ public: Wrapper *w = NewWrapper(); if (Len(package_path) > 0) - internal_classname = NewStringf("%s/%s", package_path, classname); + if (Len(getNSpace()) > 0) + internal_classname = NewStringf("%s/%s/%s", package_path, getNSpace(), classname); + else + internal_classname = NewStringf("%s/%s", package_path, classname); else internal_classname = NewStringf("%s", classname); From 11185e66b16a53102aba0dabea87bc8d2a16415e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 7 Jan 2012 22:09:28 +0000 Subject: [PATCH 136/147] Add support for %nspace when using directors - C# git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12892 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 ++ .../csharp/director_nspace_runme.cs | 32 +++++++++++++++++++ Examples/test-suite/director_nspace.i | 4 +-- Source/Modules/csharp.cxx | 11 +++++-- 4 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 Examples/test-suite/csharp/director_nspace_runme.cs diff --git a/CHANGES.current b/CHANGES.current index d3c417d45..c6bbba974 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2012-01-07: wsfulton + [C#] Add support for %nspace when using directors. + 2012-01-06: wsfulton [Java] Patch #3452560 from Brant Kyser - add support for %nspace when using directors. diff --git a/Examples/test-suite/csharp/director_nspace_runme.cs b/Examples/test-suite/csharp/director_nspace_runme.cs new file mode 100644 index 000000000..8126535eb --- /dev/null +++ b/Examples/test-suite/csharp/director_nspace_runme.cs @@ -0,0 +1,32 @@ + +using System; +using director_nspaceNamespace; + +public class bools_runme { + + public static void Main() { + } +} + +class director_nspace_MyBarFoo : director_nspaceNamespace.Bar.Foo { + + public override String ping() { + return "director_nspace_MyBarFoo.ping();"; + } + + public override String pong() { + return "director_nspace_MyBarFoo.pong();" + ping(); + } + + public override String fooBar(director_nspaceNamespace.Bar.FooBar fooBar) { + return fooBar.FooBarDo(); + } + + public override director_nspaceNamespace.Bar.Foo makeFoo() { + return new director_nspaceNamespace.Bar.Foo(); + } + + public override director_nspaceNamespace.Bar.FooBar makeFooBar() { + return new director_nspaceNamespace.Bar.FooBar(); + } +} diff --git a/Examples/test-suite/director_nspace.i b/Examples/test-suite/director_nspace.i index 61190ef3e..f730592f3 100644 --- a/Examples/test-suite/director_nspace.i +++ b/Examples/test-suite/director_nspace.i @@ -24,7 +24,7 @@ namespace Bar virtual ~Foo() {} virtual std::string ping() { return "Bar::Foo::ping()"; } virtual std::string pong() { return "Bar::Foo::pong();" + ping(); } - virtual std::string fooBar(FooBar* fooBar) { return fooBar->FooBarDo(); } + virtual std::string fooBar(FooBar* fb) { return fb->FooBarDo(); } virtual Foo makeFoo() { return Foo(); } virtual FooBar makeFooBar() { return FooBar(); } @@ -59,7 +59,7 @@ namespace Bar virtual ~Foo(); virtual std::string ping(); virtual std::string pong(); - virtual std::string fooBar(FooBar* fooBar); + virtual std::string fooBar(FooBar* fb); virtual Foo makeFoo(); virtual FooBar makeFooBar(); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index bee1004cc..57d050cde 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3396,12 +3396,16 @@ public: String *swig_director_connect = Swig_name_member(getNSpace(), proxy_class_name, "director_connect"); String *wname = Swig_name_wrapper(swig_director_connect); String *sym_name = Getattr(n, "sym:name"); - Wrapper *code_wrap; + String *qualified_classname = Copy(sym_name); + String *nspace = getNSpace(); + + if (nspace) + Insert(qualified_classname, 0, NewStringf("%s.", nspace)); Printv(imclass_class_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); Printf(imclass_class_code, " public static extern void %s(HandleRef jarg1", swig_director_connect); - code_wrap = NewWrapper(); + Wrapper *code_wrap = NewWrapper(); Printf(code_wrap->def, "SWIGEXPORT void SWIGSTDCALL %s(void *objarg", wname); Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name); @@ -3419,7 +3423,7 @@ public: Printf(code_wrap->code, ", "); Printf(code_wrap->def, "SwigDirector_%s::SWIG_Callback%s_t callback%s", sym_name, methid, methid); Printf(code_wrap->code, "callback%s", methid); - Printf(imclass_class_code, ", %s.SwigDelegate%s_%s delegate%s", sym_name, sym_name, methid, methid); + Printf(imclass_class_code, ", %s.SwigDelegate%s_%s delegate%s", qualified_classname, sym_name, methid, methid); } Printf(code_wrap->def, ") {\n"); @@ -3433,6 +3437,7 @@ public: Delete(wname); Delete(swig_director_connect); + Delete(qualified_classname); } /* --------------------------------------------------------------- From 0f1e483af7a52f82af6daccfa9c980c88cd4f3c1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 7 Jan 2012 22:55:07 +0000 Subject: [PATCH 137/147] Workaround for C# nameclash to fix error CS0082 in testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12893 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/template_typemaps.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/template_typemaps.i b/Examples/test-suite/template_typemaps.i index b5fc1c9aa..deaf8351a 100644 --- a/Examples/test-suite/template_typemaps.i +++ b/Examples/test-suite/template_typemaps.i @@ -34,12 +34,12 @@ { T val; - T get_val() const + T get_value() const { return val; } - void set_val(T v) + void set_value(T v) { val = v; } From 280666ed3864e137860fba191d11dab731ee0bad Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 7 Jan 2012 23:42:15 +0000 Subject: [PATCH 138/147] Add PCRE build instructions to Windows build instructions git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12894 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Windows.html | 12 ++++++++++++ Tools/pcre-build.sh | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index da8a5d6bf..6349f355a 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -313,6 +313,18 @@ If you want to check out SWIG to a different folder to the proposed the autotools will fail miserably on those. +

  • +The PCRE third party library needs to be built next. +Download the latest PCRE source tarball, such as pcre-8.10.tar.bz2, from +PCRE and place in the /usr/src/swig directory. +Build PCRE as a static library using the Tools/pcre-build.sh script as follows: + +
    +cd /usr/src/swig
    +Tools/pcre-build.sh
    +
    +
  • +
  • You are now ready to build SWIG. Execute the following commands to build swig.exe:
    diff --git a/Tools/pcre-build.sh b/Tools/pcre-build.sh
    index 2d991ceba..68ffe0b03 100755
    --- a/Tools/pcre-build.sh
    +++ b/Tools/pcre-build.sh
    @@ -14,7 +14,8 @@ usage() {
       echo "  - Download the latest PCRE source tarball from http://www.pcre.org and place in the"
       echo "    directory that you will configure and build SWIG."
       echo "  - Run this script in the same directory that you intend to configure and build SWIG in."
    -  echo "  - Afterwards run the SWIG configure scrip which will then find and use the PCRE static"
    +  echo "    This will configure and build PCRE as a static library."
    +  echo "  - Afterwards run the SWIG configure script which will then find and use the PCRE static"
       echo "    libraries in the $pcre_subdir subdirectory."
       exit 0
     }
    
    From 6c80f765caa25b64c0212abbd6071a02472f8354 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Mon, 16 Jan 2012 22:50:07 +0000
    Subject: [PATCH 139/147] Slight change to the Lua macro names to separate ELUA
     and ELUAC from normal Lua - patch from Raman Gopalan
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12896 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     Lib/lua/lua.swg        | 20 +++++++++----------
     Lib/lua/luarun.swg     | 44 ++++++++++++++++++++++--------------------
     Lib/lua/luaruntime.swg | 16 +++++++--------
     Source/Modules/lua.cxx |  6 +++---
     4 files changed, 44 insertions(+), 42 deletions(-)
    
    diff --git a/Lib/lua/lua.swg b/Lib/lua/lua.swg
    index e22f01299..1cd7201c2 100644
    --- a/Lib/lua/lua.swg
    +++ b/Lib/lua/lua.swg
    @@ -7,23 +7,23 @@
     
     %insert("runtime") %{
     /* Lua flavors */
    -#define SWIG_LUA_LUA 1
    -#define SWIG_LUA_ELUA 2
    -#define SWIG_LUA_ELUAC 3
    +#define SWIG_LUA_FLAVOR_LUA 1
    +#define SWIG_LUA_FLAVOR_ELUA 2
    +#define SWIG_LUA_FLAVOR_ELUAC 3
     
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
    -#  define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0
    -#  define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0
    -#  define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0
    -#  define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0
    -# else
    +#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
     #  define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C)
     #  define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C)
     #  define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C)
     #  define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C)
    +# else /* SWIG_LUA_FLAVOR_LUA */
    +#  define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0
    +#  define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0
    +#  define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0
    +#  define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0
     #endif
     
    -#if (SWIG_LUA_TARGET == SWIG_LUA_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_ELUAC)
    +#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
     #  define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING}
     #  define LSTRVAL LRO_STRVAL
     #endif
    diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg
    index 8b64b7330..2baa9666d 100644
    --- a/Lib/lua/luarun.swg
    +++ b/Lib/lua/luarun.swg
    @@ -181,23 +181,23 @@ SWIGINTERN int SWIG_Lua_module_get(lua_State* L)
        lua_tostring(L,2));
     */
       /* get the metatable */
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
    -  assert(lua_istable(L,1));  /* just in case */
    +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
    +  assert(lua_isrotable(L,1)); /* just in case */
     #else
    -  assert(lua_isrotable(L,1));
    +  assert(lua_istable(L,1)); /* default Lua action */
     #endif
       lua_getmetatable(L,1);  /* get the metatable */
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
    -  assert(lua_istable(L,-1));  /* just in case */
    +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
    +  assert(lua_isrotable(L,-1));  /* just in case */
     #else
    -  assert(lua_isrotable(L,-1));
    +  assert(lua_istable(L,-1));
     #endif
       SWIG_Lua_get_table(L,".get");  /* get the .get table */
       lua_remove(L,3);  /* remove metatable */
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
    -  if (lua_istable(L,-1))
    -#else
    +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
       if (lua_isrotable(L,-1))
    +#else
    +  if (lua_istable(L,-1))
     #endif
       {
         /* look for the key in the .get table */
    @@ -225,23 +225,23 @@ SWIGINTERN int SWIG_Lua_module_set(lua_State* L)
       (3) any for the new value
     */
       /* get the metatable */
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
    -  assert(lua_istable(L,1));  /* just in case */
    +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
    +  assert(lua_isrotable(L,1));  /* just in case */
     #else
    -  assert(lua_isrotable(L,1));
    +  assert(lua_istable(L,1)); /* default Lua action */
     #endif
       lua_getmetatable(L,1);  /* get the metatable */
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
    -  assert(lua_istable(L,-1));  /* just in case */
    +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
    +  assert(lua_isrotable(L,-1));  /* just in case */
     #else
    -  assert(lua_isrotable(L,-1));  
    +  assert(lua_istable(L,-1));
     #endif
       SWIG_Lua_get_table(L,".set");  /* get the .set table */
       lua_remove(L,4);  /* remove metatable */
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
    -  if (lua_istable(L,-1))
    -#else
    +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
       if (lua_isrotable(L,-1))
    +#else
    +  if (lua_istable(L,-1))
     #endif
       {
         /* look for the key in the .set table */
    @@ -254,7 +254,7 @@ SWIGINTERN int SWIG_Lua_module_set(lua_State* L)
           lua_call(L,1,0);
           return 0;
         }
    -#if (SWIG_LUA_TARGET == SWIG_LUA_ELUA)
    +#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) 
         else {
           return 0; // Exits stoically if an invalid key is initialized.
         }
    @@ -266,7 +266,7 @@ SWIGINTERN int SWIG_Lua_module_set(lua_State* L)
       return 0;
     }
     
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
    +#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC))
     /* registering a module in lua. Pushes the module table on the stack. */
     SWIGINTERN void  SWIG_Lua_module_begin(lua_State* L,const char* name)
     {
    @@ -623,7 +623,9 @@ SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State* L,void* ptr,swig_type_info *t
       usr->ptr=ptr;  /* set the ptr */
       usr->type=type;
       usr->own=own;
    +#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
       _SWIG_Lua_AddMetatable(L,type); /* add metatable */
    +#endif
     }
     
     /* takes a object from the lua stack & converts it into an object of the correct type
    @@ -736,7 +738,7 @@ SWIGRUNTIME int SWIG_Lua_equal(lua_State* L)
      * global variable support code: class/struct typemap functions
      * ----------------------------------------------------------------------------- */
     
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
    +#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC))
     /* Install Constants */
     SWIGINTERN void
     SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]) {
    diff --git a/Lib/lua/luaruntime.swg b/Lib/lua/luaruntime.swg
    index b94640153..f96f3d19f 100644
    --- a/Lib/lua/luaruntime.swg
    +++ b/Lib/lua/luaruntime.swg
    @@ -21,13 +21,13 @@ extern "C" {
       added at the very end of the code
       the function is always called SWIG_init, but an eariler #define will rename it
     */
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
    -SWIGEXPORT int SWIG_init(lua_State* L)
    -#else
    +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
     LUALIB_API int SWIG_init(lua_State* L)
    +#else
    +SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */
     #endif
     {
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) || (SWIG_LUA_TARGET == SWIG_LUA_ELUA)
    +#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */
       int i;
       /* start with global table */
       lua_pushvalue(L,LUA_GLOBALSINDEX);
    @@ -36,7 +36,7 @@ LUALIB_API int SWIG_init(lua_State* L)
       SWIG_PropagateClientData();
     #endif
     
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
    +#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC))
       /* add a global fn */
       SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type);
       SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal);
    @@ -52,7 +52,7 @@ LUALIB_API int SWIG_init(lua_State* L)
       }
     #endif
     
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) || (SWIG_LUA_TARGET == SWIG_LUA_ELUA)
    +#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
       /* set up base class pointers (the hierachy) */
       for (i = 0; swig_types[i]; i++){
         if (swig_types[i]->clientdata){
    @@ -67,12 +67,12 @@ LUALIB_API int SWIG_init(lua_State* L)
       }
     #endif
     
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
    +#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC))
       /* constants */
       SWIG_Lua_InstallConstants(L,swig_constants);
     #endif
     
    -#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) || (SWIG_LUA_TARGET == SWIG_LUA_ELUA)
    +#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
       /* invoke user-specific initialization */
       SWIG_init_user(L);
       /* end module */
    diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx
    index bec5aef33..3623b80ff 100644
    --- a/Source/Modules/lua.cxx
    +++ b/Source/Modules/lua.cxx
    @@ -285,11 +285,11 @@ public:
         Printf(f_runtime, "#define SWIGLUA\n");
     
         if (elua_ltr)
    -      Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_ELUA\n");
    +      Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUA\n");
         else if (eluac_ltr)
    -      Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_ELUAC\n");
    +      Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUAC\n");
         else
    -      Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_LUA\n");
    +      Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA\n");
     
         if (nomoduleglobal) {
           Printf(f_runtime, "#define SWIG_LUA_NO_MODULE_GLOBAL\n");
    
    From 459e083b3d72e49d0f642ce6844664f8995ab6b3 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Tue, 17 Jan 2012 07:06:22 +0000
    Subject: [PATCH 140/147] Fix forward class declaration in a class when used as
     a base
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12897 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     CHANGES.current                     |  3 +++
     Examples/test-suite/class_forward.i | 10 ++++++++++
     Examples/test-suite/common.mk       |  1 +
     Source/Modules/go.cxx               |  2 +-
     4 files changed, 15 insertions(+), 1 deletion(-)
     create mode 100644 Examples/test-suite/class_forward.i
    
    diff --git a/CHANGES.current b/CHANGES.current
    index c6bbba974..ab0d5a3c7 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release.
     Version 2.0.5 (in progress)
     ===========================
     
    +2012-01-17: wsfulton
    +            [Go] Fix forward class declaration within a class when used as a base.
    +
     2012-01-07: wsfulton
                 [C#] Add support for %nspace when using directors.
     
    diff --git a/Examples/test-suite/class_forward.i b/Examples/test-suite/class_forward.i
    new file mode 100644
    index 000000000..f1c0a122f
    --- /dev/null
    +++ b/Examples/test-suite/class_forward.i
    @@ -0,0 +1,10 @@
    +%module class_forward
    +
    +%inline %{
    +struct A { 
    +   class B;
    +};
    +class C : public A {
    +};
    +%}
    +
    diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
    index 58d7c14ff..3271170d3 100644
    --- a/Examples/test-suite/common.mk
    +++ b/Examples/test-suite/common.mk
    @@ -126,6 +126,7 @@ CPP_TEST_CASES += \
     	casts \
     	char_binary \
     	char_strings \
    +	class_forward \
     	class_ignore \
     	class_scope_weird \
     	compactdefaultargs \
    diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx
    index 2e077cde4..7aa5124dc 100644
    --- a/Source/Modules/go.cxx
    +++ b/Source/Modules/go.cxx
    @@ -1913,7 +1913,7 @@ private:
           }
     
           String *type = Getattr(ni, "nodeType");
    -      if (Strcmp(type, "constructor") == 0 || Strcmp(type, "destructor") == 0 || Strcmp(type, "enum") == 0 || Strcmp(type, "using") == 0) {
    +      if (Strcmp(type, "constructor") == 0 || Strcmp(type, "destructor") == 0 || Strcmp(type, "enum") == 0 || Strcmp(type, "using") == 0 || Strcmp(type, "classforward") == 0) {
     	continue;
           }
           String *storage = Getattr(ni, "storage");
    
    From 1b47ddf8f07cbdb50608d5b31edc3f0947592afb Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Fri, 20 Jan 2012 21:14:03 +0000
    Subject: [PATCH 141/147] Add support for slicing steps to Python STL wrappers
     (positive step only atm - these work the same as other Python sequences such
     as list)
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12898 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     CHANGES.current                             |  39 +++++
     Examples/test-suite/common.mk               |   1 +
     Examples/test-suite/li_std_containers_int.i |  12 ++
     Lib/python/pycontainer.swg                  | 173 ++++++++++++++------
     4 files changed, 178 insertions(+), 47 deletions(-)
     create mode 100644 Examples/test-suite/li_std_containers_int.i
    
    diff --git a/CHANGES.current b/CHANGES.current
    index ab0d5a3c7..450b948b0 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -5,6 +5,45 @@ See the RELEASENOTES file for a summary of changes in each release.
     Version 2.0.5 (in progress)
     ===========================
     
    +2012-01-20: wsfulton
    +            [Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list).
    +            Assigning to a slice, reading a slice and deleting a slice with steps now work.
    +            Positive steps only at the moment. For example:
    +
    +            %template(vector_i) std::vector
    +
    +              vi = vector_i(range(10))
    +              print list(vi)
    +              vi[1:4:2] = [111, 333]
    +              print list(vi)
    +              del vi[3:10:3]
    +              print list(vi)
    +
    +            gives (same behaviour as native Python sequences such as list):
    +
    +              [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    +              [0, 111, 2, 333, 4, 5, 6, 7, 8, 9]
    +              [0, 111, 2, 4, 5, 7, 8]
    +
    +
    +2012-01-20: wsfulton
    +            [Python] Fix some indexing bugs in Python STL wrappers when the index is negative, eg:
    +
    +            %template(vector_i) std::vector
    +
    +              iv=vector_i([0,1,2,3,4,5])
    +              iv[-7:]
    +
    +            now returns [0, 1, 2, 3, 4, 5] instead of [5].
    +
    +              vv[7:9] = [22,33]
    +
    +            now returns [0, 1, 2, 3, 4, 5, 22, 33] instead of "index out range" error.
    +
    +            Also fix some segfaults when replacing ranges, eg when il is a std::list wrapper:
    +
    +              il[0:2] = [11]
    +
     2012-01-17: wsfulton
                 [Go] Fix forward class declaration within a class when used as a base.
     
    diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
    index 3271170d3..08da73451 100644
    --- a/Examples/test-suite/common.mk
    +++ b/Examples/test-suite/common.mk
    @@ -465,6 +465,7 @@ CPP_STD_TEST_CASES += \
     	director_string \
     	ignore_template_constructor \
     	li_std_combinations \
    +	li_std_containers_int \
     	li_std_deque \
     	li_std_except \
     	li_std_map \
    diff --git a/Examples/test-suite/li_std_containers_int.i b/Examples/test-suite/li_std_containers_int.i
    new file mode 100644
    index 000000000..d0c76d911
    --- /dev/null
    +++ b/Examples/test-suite/li_std_containers_int.i
    @@ -0,0 +1,12 @@
    +%module li_std_containers_int
    +
    +//
    +// Test containers of type int
    +//
    +
    +%include std_vector.i
    +%include std_list.i
    +
    +%template(vector_int) std::vector;
    +%template(list_int) std::list;
    +
    diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
    index 24ce8816b..d0a4bf6df 100644
    --- a/Lib/python/pycontainer.swg
    +++ b/Lib/python/pycontainer.swg
    @@ -198,23 +198,28 @@ namespace swig {
         } else if (insert && ((size_t) i == size)) {
           return size;
         }
    -    
         throw std::out_of_range("index out of range");
       }
     
    -  inline size_t
    -  slice_index(ptrdiff_t i, size_t size) {
    +  void
    +  slice_adjust(ptrdiff_t i, ptrdiff_t j, ptrdiff_t step, size_t size, size_t &ii, size_t &jj, bool insert = false) {
         if ( i < 0 ) {
    -      if ((size_t) (-i) <= size) {
    -	return (size_t) (i + size);
    -      } else {
    -	throw std::out_of_range("index out of range");
    -      }
    +      ii = 0;
    +    } else if ( (size_t) i < size ) {
    +      ii = (size_t) i;
    +    } else if (insert && ((size_t) i >= size)) {
    +      ii = size;
         } else {
    -      return ( (size_t) i < size ) ? ((size_t) i) : size;
    +      throw std::out_of_range("index out of range");
    +    }
    +    if ( j < 0 ) {
    +      jj = 0;
    +    } else {
    +      jj = ( (size_t) j < size ) ? ((size_t) j) : size;
         }
       }
     
    +
       template 
       inline typename Sequence::iterator
       getpos(Sequence* self, Difference i)  {
    @@ -233,17 +238,35 @@ namespace swig {
     
       template 
       inline Sequence*
    -  getslice(const Sequence* self, Difference i, Difference j) {
    +  getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) {
    +    if (step == 0)
    +      throw std::invalid_argument("slice step cannot be zero");
    +
    +    if (step < 0)
    +      throw std::invalid_argument("negative steps not implemented");
    +
         typename Sequence::size_type size = self->size();
    -    typename Sequence::size_type ii = swig::check_index(i, size);
    -    typename Sequence::size_type jj = swig::slice_index(j, size);
    +    typename Sequence::size_type ii = 0;
    +    typename Sequence::size_type jj = 0;
    +    swig::slice_adjust(i, j, step, size, ii, jj);
     
         if (jj > ii) {
    -      typename Sequence::const_iterator vb = self->begin();
    -      typename Sequence::const_iterator ve = self->begin();
    -      std::advance(vb,ii);
    -      std::advance(ve,jj);
    -      return new Sequence(vb, ve);
    +      typename Sequence::const_iterator sb = self->begin();
    +      typename Sequence::const_iterator se = self->begin();
    +      std::advance(sb,ii);
    +      std::advance(se,jj);
    +      if (step == 1) {
    +        return new Sequence(sb, se);
    +      } else {
    +        typename Sequence::const_iterator it = sb;
    +        Sequence *sequence = new Sequence();
    +        while (it!=se) {
    +          sequence->push_back(*it);
    +          for (typename Sequence::size_type c=0; c
       inline void
    -  setslice(Sequence* self, Difference i, Difference j, const InputSeq& v = InputSeq()) {
    +  setslice(Sequence* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) {
    +    if (step == 0)
    +      throw std::invalid_argument("slice step cannot be zero");
    +
    +    if (step < 0)
    +      throw std::invalid_argument("negative steps not implemented");
    +
         typename Sequence::size_type size = self->size();
    -    typename Sequence::size_type ii = swig::check_index(i, size, true);
    -    typename Sequence::size_type jj = swig::slice_index(j, size);
    -    if (jj < ii) jj = ii;
    -    size_t ssize = jj - ii;
    -    if (ssize <= v.size()) {
    -      typename Sequence::iterator sb = self->begin();
    -      typename InputSeq::const_iterator vmid = v.begin();
    -      std::advance(sb,ii);
    -      std::advance(vmid, jj - ii);
    -      self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end());
    +    typename Sequence::size_type ii = 0;
    +    typename Sequence::size_type jj = 0;
    +    swig::slice_adjust(i, j, step, size, ii, jj, true);
    +    if (jj < ii)
    +      jj = ii;
    +    if (step == 1) {
    +      size_t ssize = jj - ii;
    +      if (ssize <= is.size()) {
    +        // expanding/staying the same size
    +        typename Sequence::iterator sb = self->begin();
    +        typename InputSeq::const_iterator isit = is.begin();
    +        std::advance(sb,ii);
    +        std::advance(isit, jj - ii);
    +        self->insert(std::copy(is.begin(), isit, sb), isit, is.end());
    +      } else {
    +        // shrinking
    +        typename Sequence::iterator sb = self->begin();
    +        typename Sequence::iterator se = self->begin();
    +        std::advance(sb,ii);
    +        std::advance(se,jj);
    +        self->erase(sb,se);
    +        sb = self->begin();
    +        std::advance(sb,ii);
    +        self->insert(sb, is.begin(), is.end());
    +      }
         } else {
    -      typename Sequence::iterator sb = self->begin();
    -      typename Sequence::iterator se = self->begin();
    -      std::advance(sb,ii);
    -      std::advance(se,jj);
    -      self->erase(sb,se);
    -      self->insert(sb, v.begin(), v.end());
    +      size_t replacecount = (jj - ii + step - 1) / step;
    +      if (is.size() != replacecount) {
    +        char msg[1024];
    +        sprintf(msg, "attempt to assign sequence of size %d to extended slice of size %d", is.size(), replacecount);
    +        throw std::invalid_argument(msg);
    +      }
    +      typename Sequence::const_iterator isit = is.begin();
    +      typename Sequence::iterator it = self->begin();
    +      std::advance(it,ii);
    +      for (size_t rc=0; rc
       inline void
    -  delslice(Sequence* self, Difference i, Difference j) {
    +  delslice(Sequence* self, Difference i, Difference j, Py_ssize_t step) {
    +    if (step == 0)
    +      throw std::invalid_argument("slice step cannot be zero");
    +
    +    if (step < 0)
    +      throw std::invalid_argument("negative steps not implemented");
    +
         typename Sequence::size_type size = self->size();
    -    typename Sequence::size_type ii = swig::check_index(i, size, true);
    -    typename Sequence::size_type jj = swig::slice_index(j, size);
    +    typename Sequence::size_type ii = 0;
    +    typename Sequence::size_type jj = 0;
    +    swig::slice_adjust(i, j, step, size, ii, jj, true);
         if (jj > ii) {
           typename Sequence::iterator sb = self->begin();
           typename Sequence::iterator se = self->begin();
           std::advance(sb,ii);
    -      std::advance(se,jj);
    -      self->erase(sb,se);
    +      if (step == 1) {
    +        std::advance(se,jj);
    +        self->erase(sb,se);
    +      } else {
    +        typename Sequence::iterator it = sb;
    +        std::advance(se,jj-1);
    +        size_t delcount = (jj - ii + step - 1) / step;
    +        while (delcount) {
    +          it = self->erase(it);
    +          if (it==self->end())
    +            break;
    +          for (typename Sequence::size_type c=0; c<(step-1); ++c)
    +            it++;
    +          delcount--;
    +        }
    +      }
         }
       }
     }
    @@ -607,7 +680,10 @@ namespace swig
     
     %define %swig_container_methods(Container...)
     
    +/* deprecated in Python 2 */
    +#if 1
       %newobject __getslice__;
    +#endif
       %newobject __getitem__(PySliceObject *slice);
     
     #if defined(SWIGPYTHON_BUILTIN)
    @@ -669,18 +745,21 @@ namespace swig
           $1 = PySlice_Check($input);
         }
     
    +/* deprecated in Python 2 */
    +#if 1
         Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) {
    -      return swig::getslice(self, i, j);
    +      return swig::getslice(self, i, j, 1);
         }
     
         void __setslice__(difference_type i, difference_type j, const Sequence& v = Sequence()) 
           throw (std::out_of_range, std::invalid_argument) {
    -      swig::setslice(self, i, j, v);
    +      swig::setslice(self, i, j, 1, v);
         }
     
         void __delslice__(difference_type i, difference_type j) throw (std::out_of_range) {
    -      swig::delslice(self, i, j);
    +      swig::delslice(self, i, j, 1);
         }
    +#endif
     
         void __delitem__(difference_type i) throw (std::out_of_range) {
           self->erase(swig::getpos(self,i));
    @@ -690,14 +769,14 @@ namespace swig
         /* Overloaded methods for Python 3 compatibility 
          * (Also useful in Python 2.x)
          */
    -    Sequence* __getitem__(PySliceObject *slice) throw (std::out_of_range) {
    +    Sequence* __getitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) {
           Py_ssize_t i, j, step;
           if( !PySlice_Check(slice) ) {
             SWIG_Error(SWIG_TypeError, "Slice object expected.");
             return NULL;
           }
           PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step);
    -      return swig::getslice(self, i, j);
    +      return swig::getslice(self, i, j, step);
         }
     
         void __setitem__(PySliceObject *slice, const Sequence& v)
    @@ -708,7 +787,7 @@ namespace swig
             return;
           }
           PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step);
    -      swig::setslice(self, i, j, v);
    +      swig::setslice(self, i, j, step, v);
         }
     
         void __setitem__(PySliceObject *slice)
    @@ -719,7 +798,7 @@ namespace swig
             return;
           }
           PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step);
    -      swig::delslice(self, i,j);
    +      swig::delslice(self, i, j, step);
         }
     
         void __delitem__(PySliceObject *slice)
    @@ -730,7 +809,7 @@ namespace swig
             return;
           }
           PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step);
    -      swig::delslice(self, i,j);
    +      swig::delslice(self, i, j, step);
         }
          
       }
    
    From 8fa4d20ec3ac570d1d2d5cd868803e91bd5608ec Mon Sep 17 00:00:00 2001
    From: David Nadlinger 
    Date: Mon, 23 Jan 2012 21:59:00 +0000
    Subject: [PATCH 142/147] [D] Correctly annotate function pointers with C
     linkage.
    
    Minor cleanups as well.
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12899 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     CHANGES.current                               |  5 ++-
     .../test-suite/d/d_nativepointers_runme.1.d   |  4 +-
     .../test-suite/d/d_nativepointers_runme.2.d   |  4 +-
     Lib/d/dhead.swg                               | 42 +++++++++++++++++--
     Source/Modules/d.cxx                          |  3 +-
     5 files changed, 50 insertions(+), 8 deletions(-)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 450b948b0..89b7d0b33 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release.
     Version 2.0.5 (in progress)
     ===========================
     
    +2012-01-23: klickverbot
    +            [D] Correctly annotate function pointers with C linkage.
    +
     2012-01-20: wsfulton
                 [Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list).
                 Assigning to a slice, reading a slice and deleting a slice with steps now work.
    @@ -87,7 +90,7 @@ Version 2.0.5 (in progress)
     	    Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes
     	    (they could be sometimes mysteriously not renamed or ignored there before).
     
    -2011-12-03: klickvebrot
    +2011-12-03: klickverbot
                 [D] Fix exception glue code for newer DMD 2 versions.
                 [D] Do not default to 32 bit glue code for DMD anymore.
                 [D] Use stdc.config.c_long/c_ulong to represent C long types.
    diff --git a/Examples/test-suite/d/d_nativepointers_runme.1.d b/Examples/test-suite/d/d_nativepointers_runme.1.d
    index 797c057d3..dfafacca4 100644
    --- a/Examples/test-suite/d/d_nativepointers_runme.1.d
    +++ b/Examples/test-suite/d/d_nativepointers_runme.1.d
    @@ -6,6 +6,8 @@ import d_nativepointers.SWIGTYPE_p_OpaqueClass;
     import d_nativepointers.SWIGTYPE_p_p_SomeClass;
     import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
     
    +extern(C) alias void function(int**, char***) GType;
    +
     void main() {
       check!(a, int*);
       check!(b, float**);
    @@ -13,7 +15,7 @@ void main() {
       check!(d, SomeClass);
       check!(e, SWIGTYPE_p_p_SomeClass);
       check!(f, SWIGTYPE_p_OpaqueClass);
    -  check!(g, void function(int**, char***));
    +  check!(g, GType);
       check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
     
       {
    diff --git a/Examples/test-suite/d/d_nativepointers_runme.2.d b/Examples/test-suite/d/d_nativepointers_runme.2.d
    index 797c057d3..dfafacca4 100644
    --- a/Examples/test-suite/d/d_nativepointers_runme.2.d
    +++ b/Examples/test-suite/d/d_nativepointers_runme.2.d
    @@ -6,6 +6,8 @@ import d_nativepointers.SWIGTYPE_p_OpaqueClass;
     import d_nativepointers.SWIGTYPE_p_p_SomeClass;
     import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
     
    +extern(C) alias void function(int**, char***) GType;
    +
     void main() {
       check!(a, int*);
       check!(b, float**);
    @@ -13,7 +15,7 @@ void main() {
       check!(d, SomeClass);
       check!(e, SWIGTYPE_p_p_SomeClass);
       check!(f, SWIGTYPE_p_OpaqueClass);
    -  check!(g, void function(int**, char***));
    +  check!(g, GType);
       check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
     
       {
    diff --git a/Lib/d/dhead.swg b/Lib/d/dhead.swg
    index 170e0243f..4325f3581 100644
    --- a/Lib/d/dhead.swg
    +++ b/Lib/d/dhead.swg
    @@ -3,15 +3,23 @@
      *
      * Support code for exceptions if the SWIG_D_NO_EXCEPTION_HELPER is not defined
      * Support code for strings if the SWIG_D_NO_STRING_HELPER is not defined
    - * ----------------------------------------------------------------------------- */
    + *
    + * Support code for function pointers. ----------------------------------------------------------------------------- */
     
     %insert(runtime) %{
     #include 
     #include 
     #include 
    +
    +/* Contract support. */
    +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_DSetPendingException(SWIG_DException, msg); return nullreturn; } else
     %}
     
     
    +/*
    + * Exception support code.
    + */
    +
     #if !defined(SWIG_D_NO_EXCEPTION_HELPER)
     %insert(runtime) %{
     // Support for throwing D exceptions from C/C++.
    @@ -250,6 +258,11 @@ alias void function(const char* message) SwigExceptionCallback;
     // Callback registering function in wrapperloader.swg.
     #endif // SWIG_D_NO_EXCEPTION_HELPER
     
    +
    +/*
    + * String support code.
    + */
    +
     #if !defined(SWIG_D_NO_STRING_HELPER)
     %insert(runtime) %{
     // Callback for returning strings to D without leaking memory.
    @@ -304,7 +317,28 @@ alias const(char)* function(const(char*) cString) SwigStringCallback;
     // Callback registering function in wrapperloader.swg.
     #endif // SWIG_D_NO_STRING_HELPER
     
    -%insert(runtime) %{
    -/* Contract support. */
    -#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_DSetPendingException(SWIG_DException, msg); return nullreturn; } else
    +
    +/*
    + * Function pointer support code.
    + */
    +#if (SWIG_D_VERSION == 1)
    +%pragma(d) imdmodulecode = %{
    +template SwigExternC(T) {
    +  static if (is(typeof(*(T.init)) R == return)) {
    +    static if (is(typeof(*(T.init)) P == function)) {
    +      alias extern(C) R function(P) SwigExternC;
    +    }
    +  }
    +}
     %}
    +#else
    +%pragma(d) imdmodulecode = %{
    +template SwigExternC(T) if (is(typeof(*(T.init)) P == function)) {
    +  static if (is(typeof(*(T.init)) R == return)) {
    +    static if (is(typeof(*(T.init)) P == function)) {
    +      alias extern(C) R function(P) SwigExternC;
    +    }
    +  }
    +}
    +%}
    +#endif
    diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx
    index 6a01ed8a4..bf4d15987 100644
    --- a/Source/Modules/d.cxx
    +++ b/Source/Modules/d.cxx
    @@ -3877,7 +3877,8 @@ private:
     	}
           }
     
    -      dtype = NewStringf("%s function(%s)", return_dtype, param_list);
    +      dtype = NewStringf("%s.SwigExternC!(%s function(%s))", im_dmodule_fq_name,
    +        return_dtype, param_list);
           Delete(param_list);
           Delete(param_dtypes);
           Delete(return_dtype);
    
    From 17a7ba0403d014fbe9f27d5cfe813a61c7a80e7a Mon Sep 17 00:00:00 2001
    From: David Nadlinger 
    Date: Mon, 23 Jan 2012 21:59:20 +0000
    Subject: [PATCH 143/147] [D] Exception and Error have become blessed names;
     removed d_exception_name test case.
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12900 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     CHANGES.current                        |  1 +
     Examples/test-suite/d/Makefile.in      |  1 -
     Examples/test-suite/d_exception_name.i | 15 ---------------
     Lib/d/dkw.swg                          |  2 ++
     4 files changed, 3 insertions(+), 16 deletions(-)
     delete mode 100644 Examples/test-suite/d_exception_name.i
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 89b7d0b33..e47e934ca 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -7,6 +7,7 @@ Version 2.0.5 (in progress)
     
     2012-01-23: klickverbot
                 [D] Correctly annotate function pointers with C linkage.
    +            [D] Exception and Error have become blessed names; removed d_exception_name test case.
     
     2012-01-20: wsfulton
                 [Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list).
    diff --git a/Examples/test-suite/d/Makefile.in b/Examples/test-suite/d/Makefile.in
    index 53b9f2859..8128e4f7a 100644
    --- a/Examples/test-suite/d/Makefile.in
    +++ b/Examples/test-suite/d/Makefile.in
    @@ -16,7 +16,6 @@ endif
     TESTSUFFIX = _runme$(VERSIONSUFFIX).d
     
     CPP_TEST_CASES = \
    -	d_exception_name \
     	d_nativepointers \
     	exception_partial_info
     
    diff --git a/Examples/test-suite/d_exception_name.i b/Examples/test-suite/d_exception_name.i
    deleted file mode 100644
    index 23f338a73..000000000
    --- a/Examples/test-suite/d_exception_name.i
    +++ /dev/null
    @@ -1,15 +0,0 @@
    -// Tests if exception handling still works in the presence of a wrapped C++
    -// class called »Exception«, which could shadow the built-in Exception class.
    -%module d_exception_name
    -
    -%inline %{
    -  class Exception {
    -    Exception(int i) {}
    -  };
    -
    -  class Foo {
    -    ~Foo() {}
    -  public:
    -    void bar(Exception *e) {}
    -  };
    -%}
    diff --git a/Lib/d/dkw.swg b/Lib/d/dkw.swg
    index 5091f02cc..581093f96 100644
    --- a/Lib/d/dkw.swg
    +++ b/Lib/d/dkw.swg
    @@ -5,6 +5,8 @@
     #define DKEYWORD(x) %keywordwarn("'" `x` "' is a D keyword, renaming to '_" `x` "'",rename="_%s")  `x`
     
     // Source: http://www.digitalmars.com/d/{1.0,2.0}/lex.html and
    +DKEYWORD(Error);
    +DKEYWORD(Exception);
     DKEYWORD(Object);
     DKEYWORD(__FILE__);
     DKEYWORD(__LINE__);
    
    From 4e61e0bb769a4f730f6aa77527983c9818c146b6 Mon Sep 17 00:00:00 2001
    From: David Nadlinger 
    Date: Mon, 23 Jan 2012 21:59:34 +0000
    Subject: [PATCH 144/147] [D] Fixed possible output ordering issue in test
     case.
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12901 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     Examples/d/variables/d2/runme.d | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/Examples/d/variables/d2/runme.d b/Examples/d/variables/d2/runme.d
    index f80b81819..6e18d2d64 100644
    --- a/Examples/d/variables/d2/runme.d
    +++ b/Examples/d/variables/d2/runme.d
    @@ -66,6 +66,7 @@ void main() {
       example.pt = example.ptptr;
     
       write( "The new value is " );
    +  stdout.flush();
       example.pt_print();
       writefln( "You should see the value %s", example.Point_print(example.ptptr) );
     }
    
    From 6ee6278bc5133346e61d256317b9f2fce5fdcfad Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Tue, 24 Jan 2012 20:38:50 +0000
    Subject: [PATCH 145/147] Add runtime testcase for python slicing
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12902 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     .../python/li_std_containers_int_runme.py     | 246 ++++++++++++++++++
     1 file changed, 246 insertions(+)
     create mode 100644 Examples/test-suite/python/li_std_containers_int_runme.py
    
    diff --git a/Examples/test-suite/python/li_std_containers_int_runme.py b/Examples/test-suite/python/li_std_containers_int_runme.py
    new file mode 100644
    index 000000000..6cb9e2e4f
    --- /dev/null
    +++ b/Examples/test-suite/python/li_std_containers_int_runme.py
    @@ -0,0 +1,246 @@
    +# Check std::vector and std::list behaves the same as Python iterable types (list)
    +
    +from li_std_containers_int import *
    +
    +def failed(a, b, msg):
    +  raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
    +
    +def compare_sequences(a, b):
    +  if len(a) != len(b):
    +    failed(a, b, "different sizes")
    +  for i in range(len(a)):
    +    if a[i] != b[i]:
    +      failed(a, b, "elements are different")
    +
    +def compare_containers(pythonlist, swigvector, swiglist):
    +  compare_sequences(pythonlist, swigvector)
    +  compare_sequences(pythonlist, swiglist)
    +
    +# Check std::vector and std::list assignment behaves same as Python list assignment including exceptions
    +def container_insert_step(i, j, step, newval):
    +  ps = range(6)
    +  iv = vector_int(ps)
    +  il = list_int(ps)
    +
    +  # Python slice
    +  try:
    +    if step == None:
    +      if j == None:
    +        ps[i] = newval
    +      else:
    +        ps[i:j] = newval
    +    else:
    +      if j == None:
    +        ps[i::step] = newval
    +      else:
    +        ps[i:j:step] = newval
    +    ps_error = None
    +  except ValueError, e:
    +    ps_error = e
    +  except IndexError, e:
    +    ps_error = e
    +
    +  # std::vector
    +  try:
    +    if step == None:
    +      if j == None:
    +        iv[i] = newval
    +      else:
    +        iv[i:j] = newval
    +    else:
    +      if j == None:
    +        iv[i::step] = newval
    +      else:
    +        iv[i:j:step] = newval
    +    iv_error = None
    +  except ValueError, e:
    +    iv_error = e
    +  except IndexError, e:
    +    iv_error = e
    +
    +  # std::list
    +  try:
    +    if step == None:
    +      if j == None:
    +        il[i] = newval
    +      else:
    +        il[i:j] = newval
    +    else:
    +      if j == None:
    +        il[i::step] = newval
    +      else:
    +        il[i:j:step] = newval
    +    il_error = None
    +  except ValueError, e:
    +    il_error = e
    +  except IndexError, e:
    +    il_error = e
    +
    +  if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
    +    raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error)
    +
    +  compare_containers(ps, iv, il)
    +
    +
    +# Check std::vector and std::list delete behaves same as Python list delete including exceptions
    +def container_delete_step(i, j, step):
    +  ps = range(6)
    +  iv = vector_int(ps)
    +  il = list_int(ps)
    +
    +  # Python slice
    +  try:
    +    if step == None:
    +      if j == None:
    +        del ps[i]
    +      else:
    +        del ps[i:j]
    +    else:
    +      if j == None:
    +        del ps[i::step]
    +      else:
    +        del ps[i:j:step]
    +    ps_error = None
    +  except ValueError, e:
    +    ps_error = e
    +  except IndexError, e:
    +    ps_error = e
    +
    +  # std::vector
    +  try:
    +    if step == None:
    +      if j == None:
    +        del iv[i]
    +      else:
    +        del iv[i:j]
    +    else:
    +      if j == None:
    +        del iv[i::step]
    +      else:
    +        del iv[i:j:step]
    +    iv_error = None
    +  except ValueError, e:
    +    iv_error = e
    +  except IndexError, e:
    +    iv_error = e
    +
    +  # std::list
    +  try:
    +    if step == None:
    +      if j == None:
    +        del il[i]
    +      else:
    +        del il[i:j]
    +    else:
    +      if j == None:
    +        del il[i::step]
    +      else:
    +        del il[i:j:step]
    +    il_error = None
    +  except ValueError, e:
    +    il_error = e
    +  except IndexError, e:
    +    il_error = e
    +
    +  if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
    +    raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error)
    +
    +  compare_containers(ps, iv, il)
    +
    +
    +ps = [0,1,2,3,4,5]
    +
    +iv = vector_int(ps)
    +il = list_int(ps)
    +
    +# slices
    +compare_containers(ps[0:0], iv[0:0], il[0:0])
    +compare_containers(ps[1:1], iv[1:1], il[1:1])
    +compare_containers(ps[1:3], iv[1:3], il[1:3])
    +compare_containers(ps[2:4], iv[2:4], il[2:4])
    +compare_containers(ps[0:3], iv[0:3], il[0:3])
    +compare_containers(ps[3:6], iv[3:6], il[3:6])
    +compare_containers(ps[3:10], iv[3:10], il[3:10]) # beyond end of range
    +
    +# before beginning of range (negative indexing)
    +compare_containers(ps[-1:7], iv[-1:7], il[-1:7])
    +compare_containers(ps[-2:7], iv[-2:7], il[-2:7])
    +compare_containers(ps[-5:7], iv[-5:7], il[-5:7])
    +compare_containers(ps[-6:7], iv[-6:7], il[-6:7])
    +
    +# before beginning of range (negative indexing, negative index is > container size)
    +compare_containers(ps[-7:7], iv[-7:7], il[-7:7])
    +compare_containers(ps[-100:7], iv[-100:7], il[-100:7])
    +
    +compare_containers(ps[3:], iv[3:], il[3:])
    +compare_containers(ps[:3], iv[:3], il[:3])
    +compare_containers(ps[:], iv[:], il[:])
    +compare_containers(ps[-3:], iv[-3:], il[-3:])
    +compare_containers(ps[-7:], iv[-7:], il[-7:])
    +compare_containers(ps[:-1], iv[:-1], il[:-1])
    +compare_containers(ps[:-7], iv[:-7], il[:-7])
    +
    +# step slicing
    +compare_containers(ps[1:5:1], iv[1:5:1], il[1:5:1])
    +compare_containers(ps[1:5:2], iv[1:5:2], il[1:5:2])
    +compare_containers(ps[1:5:3], iv[1:5:3], il[1:5:3])
    +compare_containers(ps[1:5:4], iv[1:5:4], il[1:5:4])
    +compare_containers(ps[1:6:5], iv[1:6:5], il[1:6:5])
    +compare_containers(ps[1:7:5], iv[1:7:5], il[1:7:5])
    +compare_containers(ps[-1:7:1], iv[-1:7:1], il[-1:7:1])
    +compare_containers(ps[-1:7:2], iv[-1:7:2], il[-1:7:2])
    +compare_containers(ps[-6:7:2], iv[-6:7:2], il[-6:7:2])
    +compare_containers(ps[-100:7:2], iv[-100:7:2], il[-100:7:2])
    +
    +compare_containers(ps[::1], iv[::1], il[::1])
    +compare_containers(ps[::2], iv[::2], il[::2])
    +#compare_containers(ps[::-1], iv[::-1], il[])
    +
    +
    +# insert sequences (growing, shrinking and staying same size)
    +for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
    +  # single element set/replace
    +  container_insert_step(start, None, None, 111)
    +  for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
    +    container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666, 777])
    +    container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666])
    +    container_insert_step(start, end, None, [111, 222, 333, 444, 555])
    +    container_insert_step(start, end, None, [111, 222, 333, 444])
    +    container_insert_step(start, end, None, [111, 222, 333])
    +    container_insert_step(start, end, None, [111, 222])
    +    container_insert_step(start, end, None, [111])
    +    container_insert_step(start, end, None, [])
    +
    +# delete sequences (growing, shrinking and staying same size)
    +for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
    +  # single element delete
    +  container_delete_step(start, None, None)
    +  for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
    +    container_delete_step(start, end, None)
    +    for step in range(1,7):
    +      container_delete_step(start, end, step)
    +
    +ps = range(6)
    +iv = vector_int(ps)
    +il = list_int(ps)
    +del ps[:]; del iv[:]; del il[:]
    +compare_containers(ps, iv, il)
    +
    +for end in range(7):
    +  for step in range(1,7):
    +    for start in range(7):
    +      container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666, 777])
    +      container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666])
    +      container_insert_step(start, end, step, [111, 222, 333, 444, 555])
    +      container_insert_step(start, end, step, [111, 222, 333, 444])
    +      container_insert_step(start, end, step, [111, 222, 333])
    +      container_insert_step(start, end, step, [111, 222])
    +      container_insert_step(start, end, step, [111])
    +      container_insert_step(start, end, step, [])
    +
    +try:
    +  x = iv[::0]
    +  raise RuntimeError("Zero step not caught")
    +except ValueError:
    +  pass
    +
    
    From 7c58a044d2f4b33067765c1c2f02ff8e3b5e33fa Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Tue, 24 Jan 2012 23:41:40 +0000
    Subject: [PATCH 146/147] Add support for negative steps in Python slices on
     the STL containers
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12903 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     CHANGES.current                               |  13 +-
     .../python/li_std_containers_int_runme.py     |  27 ++-
     Lib/python/pycontainer.swg                    | 214 +++++++++++-------
     3 files changed, 160 insertions(+), 94 deletions(-)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index e47e934ca..79410bd38 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -5,14 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
     Version 2.0.5 (in progress)
     ===========================
     
    -2012-01-23: klickverbot
    -            [D] Correctly annotate function pointers with C linkage.
    -            [D] Exception and Error have become blessed names; removed d_exception_name test case.
    -
    -2012-01-20: wsfulton
    +2012-01-24: wsfulton
                 [Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list).
                 Assigning to a slice, reading a slice and deleting a slice with steps now work.
    -            Positive steps only at the moment. For example:
    +            For example:
     
                 %template(vector_i) std::vector
     
    @@ -22,13 +18,18 @@ Version 2.0.5 (in progress)
                   print list(vi)
                   del vi[3:10:3]
                   print list(vi)
    +              print list(vi[::-1])
     
                 gives (same behaviour as native Python sequences such as list):
     
                   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
                   [0, 111, 2, 333, 4, 5, 6, 7, 8, 9]
                   [0, 111, 2, 4, 5, 7, 8]
    +              [8, 7, 5, 4, 2, 111, 0]
     
    +2012-01-23: klickverbot
    +            [D] Correctly annotate function pointers with C linkage.
    +            [D] Exception and Error have become blessed names; removed d_exception_name test case.
     
     2012-01-20: wsfulton
                 [Python] Fix some indexing bugs in Python STL wrappers when the index is negative, eg:
    diff --git a/Examples/test-suite/python/li_std_containers_int_runme.py b/Examples/test-suite/python/li_std_containers_int_runme.py
    index 6cb9e2e4f..7611ee63e 100644
    --- a/Examples/test-suite/python/li_std_containers_int_runme.py
    +++ b/Examples/test-suite/python/li_std_containers_int_runme.py
    @@ -191,10 +191,29 @@ compare_containers(ps[-1:7:1], iv[-1:7:1], il[-1:7:1])
     compare_containers(ps[-1:7:2], iv[-1:7:2], il[-1:7:2])
     compare_containers(ps[-6:7:2], iv[-6:7:2], il[-6:7:2])
     compare_containers(ps[-100:7:2], iv[-100:7:2], il[-100:7:2])
    -
     compare_containers(ps[::1], iv[::1], il[::1])
     compare_containers(ps[::2], iv[::2], il[::2])
    -#compare_containers(ps[::-1], iv[::-1], il[])
    +
    +compare_containers(ps[::-1], iv[::-1], il[::-1])
    +compare_containers(ps[6::-1], iv[6::-1], il[6::-1])
    +compare_containers(ps[:-3:-1], iv[:-3:-1], il[:-3:-1])
    +compare_containers(ps[:-6:-1], iv[:-6:-1], il[:-6:-1])
    +compare_containers(ps[:-7:-1], iv[:-7:-1], il[:-7:-1])
    +compare_containers(ps[:-8:-1], iv[:-8:-1], il[:-8:-1])
    +compare_containers(ps[:-100:-1], iv[:-100:-1], il[:-100:-1])
    +compare_containers(ps[4:6:-1], iv[4:6:-1], il[4:6:-1])
    +compare_containers(ps[4:5:-1], iv[4:5:-1], il[4:5:-1])
    +compare_containers(ps[4:4:-1], iv[4:4:-1], il[4:4:-1])
    +compare_containers(ps[4:3:-1], iv[4:3:-1], il[4:3:-1])
    +compare_containers(ps[4:2:-1], iv[4:2:-1], il[4:2:-1])
    +compare_containers(ps[100:104:-1], iv[100:104:-1], il[100:104:-1])
    +compare_containers(ps[104:100:-1], iv[104:100:-1], il[104:100:-1])
    +compare_containers(ps[-100:-104:-1], iv[-100:-104:-1], il[-100:-104:-1])
    +compare_containers(ps[-104:-100:-1], iv[-104:-100:-1], il[-104:-100:-1])
    +compare_containers(ps[::-2], iv[::-2], il[::-2])
    +compare_containers(ps[::-3], iv[::-3], il[::-3])
    +compare_containers(ps[::-4], iv[::-4], il[::-4])
    +compare_containers(ps[::-5], iv[::-5], il[::-5])
     
     
     # insert sequences (growing, shrinking and staying same size)
    @@ -217,7 +236,7 @@ for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 10
       container_delete_step(start, None, None)
       for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
         container_delete_step(start, end, None)
    -    for step in range(1,7):
    +    for step in range(-7,7):
           container_delete_step(start, end, step)
     
     ps = range(6)
    @@ -227,7 +246,7 @@ del ps[:]; del iv[:]; del il[:]
     compare_containers(ps, iv, il)
     
     for end in range(7):
    -  for step in range(1,7):
    +  for step in range(-7,7):
         for start in range(7):
           container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666, 777])
           container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666])
    diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
    index d0a4bf6df..7b69b9fd6 100644
    --- a/Lib/python/pycontainer.swg
    +++ b/Lib/python/pycontainer.swg
    @@ -202,24 +202,40 @@ namespace swig {
       }
     
       void
    -  slice_adjust(ptrdiff_t i, ptrdiff_t j, ptrdiff_t step, size_t size, size_t &ii, size_t &jj, bool insert = false) {
    -    if ( i < 0 ) {
    -      ii = 0;
    -    } else if ( (size_t) i < size ) {
    -      ii = (size_t) i;
    -    } else if (insert && ((size_t) i >= size)) {
    -      ii = size;
    +  slice_adjust(ptrdiff_t i, ptrdiff_t j, ptrdiff_t step, size_t size, ptrdiff_t &ii, ptrdiff_t &jj, bool insert = false) {
    +    if (step == 0) {
    +      throw std::invalid_argument("slice step cannot be zero");
    +    } else if (step > 0) {
    +      // Required range: 0 <= i < size, 0 <= j < size
    +      if (i < 0) {
    +        ii = 0;
    +      } else if (i < (ptrdiff_t)size) {
    +        ii = i;
    +      } else if (insert && (i >= (ptrdiff_t)size)) {
    +        ii = (ptrdiff_t)size;
    +      }
    +      if ( j < 0 ) {
    +        jj = 0;
    +      } else {
    +        jj = (j < (ptrdiff_t)size) ? j : (ptrdiff_t)size;
    +      }
         } else {
    -      throw std::out_of_range("index out of range");
    -    }
    -    if ( j < 0 ) {
    -      jj = 0;
    -    } else {
    -      jj = ( (size_t) j < size ) ? ((size_t) j) : size;
    +      // Required range: -1 <= i < size-1, -1 <= j < size-1
    +      if (i < -1) {
    +        ii = -1;
    +      } else if (i < (ptrdiff_t) size) {
    +        ii = i;
    +      } else if (i >= (ptrdiff_t)(size-1)) {
    +        ii = (ptrdiff_t)(size-1);
    +      }
    +      if (j < -1) {
    +        jj = -1;
    +      } else {
    +        jj = (j < (ptrdiff_t)size ) ? j : (ptrdiff_t)(size-1);
    +      }
         }
       }
     
    -
       template 
       inline typename Sequence::iterator
       getpos(Sequence* self, Difference i)  {
    @@ -239,18 +255,12 @@ namespace swig {
       template 
       inline Sequence*
       getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) {
    -    if (step == 0)
    -      throw std::invalid_argument("slice step cannot be zero");
    -
    -    if (step < 0)
    -      throw std::invalid_argument("negative steps not implemented");
    -
         typename Sequence::size_type size = self->size();
    -    typename Sequence::size_type ii = 0;
    -    typename Sequence::size_type jj = 0;
    +    Difference ii = 0;
    +    Difference jj = 0;
         swig::slice_adjust(i, j, step, size, ii, jj);
     
    -    if (jj > ii) {
    +    if (step > 0) {
           typename Sequence::const_iterator sb = self->begin();
           typename Sequence::const_iterator se = self->begin();
           std::advance(sb,ii);
    @@ -258,68 +268,94 @@ namespace swig {
           if (step == 1) {
             return new Sequence(sb, se);
           } else {
    -        typename Sequence::const_iterator it = sb;
             Sequence *sequence = new Sequence();
    +        typename Sequence::const_iterator it = sb;
             while (it!=se) {
               sequence->push_back(*it);
               for (typename Sequence::size_type c=0; c jj) {
    +        typename Sequence::const_reverse_iterator sb = self->rbegin();
    +        typename Sequence::const_reverse_iterator se = self->rbegin();
    +        std::advance(sb,size-ii-1);
    +        std::advance(se,size-jj-1);
    +        typename Sequence::const_reverse_iterator it = sb;
    +        while (it!=se) {
    +          sequence->push_back(*it);
    +          for (typename Sequence::size_type c=0; c<-step && it!=se; ++c)
    +            it++;
    +        }
    +      }
    +      return sequence;
         }
       }
     
       template 
       inline void
       setslice(Sequence* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) {
    -    if (step == 0)
    -      throw std::invalid_argument("slice step cannot be zero");
    -
    -    if (step < 0)
    -      throw std::invalid_argument("negative steps not implemented");
    -
         typename Sequence::size_type size = self->size();
    -    typename Sequence::size_type ii = 0;
    -    typename Sequence::size_type jj = 0;
    +    Difference ii = 0;
    +    Difference jj = 0;
         swig::slice_adjust(i, j, step, size, ii, jj, true);
    -    if (jj < ii)
    -      jj = ii;
    -    if (step == 1) {
    -      size_t ssize = jj - ii;
    -      if (ssize <= is.size()) {
    -        // expanding/staying the same size
    -        typename Sequence::iterator sb = self->begin();
    -        typename InputSeq::const_iterator isit = is.begin();
    -        std::advance(sb,ii);
    -        std::advance(isit, jj - ii);
    -        self->insert(std::copy(is.begin(), isit, sb), isit, is.end());
    +    if (step > 0) {
    +      if (jj < ii)
    +        jj = ii;
    +      if (step == 1) {
    +        size_t ssize = jj - ii;
    +        if (ssize <= is.size()) {
    +          // expanding/staying the same size
    +          typename Sequence::iterator sb = self->begin();
    +          typename InputSeq::const_iterator isit = is.begin();
    +          std::advance(sb,ii);
    +          std::advance(isit, jj - ii);
    +          self->insert(std::copy(is.begin(), isit, sb), isit, is.end());
    +        } else {
    +          // shrinking
    +          typename Sequence::iterator sb = self->begin();
    +          typename Sequence::iterator se = self->begin();
    +          std::advance(sb,ii);
    +          std::advance(se,jj);
    +          self->erase(sb,se);
    +          sb = self->begin();
    +          std::advance(sb,ii);
    +          self->insert(sb, is.begin(), is.end());
    +        }
           } else {
    -        // shrinking
    -        typename Sequence::iterator sb = self->begin();
    -        typename Sequence::iterator se = self->begin();
    -        std::advance(sb,ii);
    -        std::advance(se,jj);
    -        self->erase(sb,se);
    -        sb = self->begin();
    -        std::advance(sb,ii);
    -        self->insert(sb, is.begin(), is.end());
    +        size_t replacecount = (jj - ii + step - 1) / step;
    +        if (is.size() != replacecount) {
    +          char msg[1024];
    +          sprintf(msg, "attempt to assign sequence of size %d to extended slice of size %d", is.size(), replacecount);
    +          throw std::invalid_argument(msg);
    +        }
    +        typename Sequence::const_iterator isit = is.begin();
    +        typename Sequence::iterator it = self->begin();
    +        std::advance(it,ii);
    +        for (size_t rc=0; rc ii)
    +        jj = ii;
    +      size_t replacecount = (ii - jj - step - 1) / -step;
           if (is.size() != replacecount) {
             char msg[1024];
             sprintf(msg, "attempt to assign sequence of size %d to extended slice of size %d", is.size(), replacecount);
             throw std::invalid_argument(msg);
           }
           typename Sequence::const_iterator isit = is.begin();
    -      typename Sequence::iterator it = self->begin();
    -      std::advance(it,ii);
    +      typename Sequence::reverse_iterator it = self->rbegin();
    +      std::advance(it,size-ii-1);
           for (size_t rc=0; rc
       inline void
       delslice(Sequence* self, Difference i, Difference j, Py_ssize_t step) {
    -    if (step == 0)
    -      throw std::invalid_argument("slice step cannot be zero");
    -
    -    if (step < 0)
    -      throw std::invalid_argument("negative steps not implemented");
    -
         typename Sequence::size_type size = self->size();
    -    typename Sequence::size_type ii = 0;
    -    typename Sequence::size_type jj = 0;
    +    Difference ii = 0;
    +    Difference jj = 0;
         swig::slice_adjust(i, j, step, size, ii, jj, true);
    -    if (jj > ii) {
    -      typename Sequence::iterator sb = self->begin();
    -      typename Sequence::iterator se = self->begin();
    -      std::advance(sb,ii);
    -      if (step == 1) {
    -        std::advance(se,jj);
    -        self->erase(sb,se);
    -      } else {
    -        typename Sequence::iterator it = sb;
    -        std::advance(se,jj-1);
    -        size_t delcount = (jj - ii + step - 1) / step;
    +    if (step > 0) {
    +      if (jj > ii) {
    +        typename Sequence::iterator sb = self->begin();
    +        std::advance(sb,ii);
    +        if (step == 1) {
    +          typename Sequence::iterator se = self->begin();
    +          std::advance(se,jj);
    +          self->erase(sb,se);
    +        } else {
    +          typename Sequence::iterator it = sb;
    +          size_t delcount = (jj - ii + step - 1) / step;
    +          while (delcount) {
    +            it = self->erase(it);
    +            if (it==self->end())
    +              break;
    +            for (typename Sequence::size_type c=0; c<(step-1); ++c)
    +              it++;
    +            delcount--;
    +          }
    +        }
    +      }
    +    } else {
    +      if (ii > jj) {
    +        typename Sequence::reverse_iterator sb = self->rbegin();
    +        std::advance(sb,size-ii-1);
    +        typename Sequence::reverse_iterator it = sb;
    +        size_t delcount = (ii - jj - step - 1) / -step;
             while (delcount) {
    -          it = self->erase(it);
    -          if (it==self->end())
    +          self->erase((++it).base());
    +          if (it==self->rend())
                 break;
    -          for (typename Sequence::size_type c=0; c<(step-1); ++c)
    +          for (typename Sequence::size_type c=0; c<(-step-1); ++c)
                 it++;
               delcount--;
             }
    @@ -747,7 +793,7 @@ namespace swig
     
     /* deprecated in Python 2 */
     #if 1
    -    Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) {
    +    Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) {
           return swig::getslice(self, i, j, 1);
         }
     
    @@ -756,7 +802,7 @@ namespace swig
           swig::setslice(self, i, j, 1, v);
         }
     
    -    void __delslice__(difference_type i, difference_type j) throw (std::out_of_range) {
    +    void __delslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) {
           swig::delslice(self, i, j, 1);
         }
     #endif
    @@ -791,7 +837,7 @@ namespace swig
         }
     
         void __setitem__(PySliceObject *slice)
    -      throw (std::out_of_range) {
    +      throw (std::out_of_range, std::invalid_argument) {
           Py_ssize_t i, j, step;
           if( !PySlice_Check(slice) ) {
             SWIG_Error(SWIG_TypeError, "Slice object expected.");
    @@ -802,7 +848,7 @@ namespace swig
         }
     
         void __delitem__(PySliceObject *slice)
    -      throw (std::out_of_range) {
    +      throw (std::out_of_range, std::invalid_argument) {
           Py_ssize_t i, j, step;
           if( !PySlice_Check(slice) ) {
             SWIG_Error(SWIG_TypeError, "Slice object expected.");
    
    From 29fd1e3ce497bd231763bc665ed825e5862fb35f Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Fri, 27 Jan 2012 20:55:32 +0000
    Subject: [PATCH 147/147] Fix crash when requesting more matches than available
     in regex
    
    git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12904 626c5289-ae23-0410-ae9c-e8d60b6d4f22
    ---
     CHANGES.current    |  3 +++
     Source/Swig/misc.c | 20 ++++++++++++--------
     2 files changed, 15 insertions(+), 8 deletions(-)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 79410bd38..5bd6e6910 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release.
     Version 2.0.5 (in progress)
     ===========================
     
    +2012-01-24: wsfulton
    +            Fix crash with bad regex - bug #3474250.
    +
     2012-01-24: wsfulton
                 [Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list).
                 Assigning to a slice, reading a slice and deleting a slice with steps now work.
    diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
    index 77679ca63..6d0297b05 100644
    --- a/Source/Swig/misc.c
    +++ b/Source/Swig/misc.c
    @@ -1147,7 +1147,7 @@ err_out:
       exit(1);
     }
     
    -String *replace_captures(const char *input, String *subst, int captures[])
    +String *replace_captures(int num_captures, const char *input, String *subst, int captures[], String *pattern, String *s)
     {
       String *result = NewStringEmpty();
       const char *p = Char(subst);
    @@ -1167,9 +1167,14 @@ String *replace_captures(const char *input, String *subst, int captures[])
           Putc('\\', result);
         } else if (isdigit((unsigned char)*p)) {
           int group = *p++ - '0';
    -      int l = captures[group*2], r = captures[group*2 + 1];
    -      if (l != -1) {
    -        Write(result, input + l, r - l);
    +      if (group < num_captures) {
    +	int l = captures[group*2], r = captures[group*2 + 1];
    +	if (l != -1) {
    +	  Write(result, input + l, r - l);
    +	}
    +      } else {
    +	Swig_error("SWIG", Getline(s), "PCRE capture replacement failed while matching \"%s\" using \"%s\" - request for group %d is greater than the number of captures %d.\n",
    +	    Char(pattern), input, group, num_captures-1);
           }
         }
       }
    @@ -1206,10 +1211,9 @@ String *Swig_string_regex(String *s) {
         }
         rc = pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30);
         if (rc >= 0) {
    -      res = replace_captures(input, subst, captures);
    -    }
    -    else if (rc != PCRE_ERROR_NOMATCH) {
    -      Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" in \"%s\".\n",
    +      res = replace_captures(rc, input, subst, captures, pattern, s);
    +    } else if (rc != PCRE_ERROR_NOMATCH) {
    +      Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n",
     	rc, Char(pattern), input);
           exit(1);
         }
    
  • $symname Name of -function/method being wrapped$inputRuby object being sent to the function
    $symname Name of function/method being wrapped
    $1...n Argument being -sent to the functionArgument being sent to the function
    $resultResult that the -director function returnsResult that the director function returns
    $inputRuby object being sent to the function
    $symnamename of the -function/method being wrappedname of the function/method being wrapped
    $1...nArgument being -sent to the functionArgument being sent to the function