From 38f37ef5ae7026dd7c04ac8c39cb2aec4bf90838 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 29 Jan 2013 06:55:22 +0000 Subject: [PATCH 001/273] Apply patch SF #335 - Truly ignore constructors in directors with %ignore and correct testcase that tests this --- CHANGES.current | 3 ++ Examples/test-suite/director_ignore.i | 49 +++++++++++++++++++-------- Source/Modules/lang.cxx | 3 ++ 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ad2f1e764..9c014aa82 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.10 (in progress) ============================ +2013-01-28: William + [Java] Apply patch SF #335 - Truly ignore constructors in directors with %ignore. + 2013-01-18: Brant Kyser [Java] Patch #15 - Allow the use of the nspace feature without the -package commandline option. This works as long and the new jniclasspackage pragma is used to place the JNI intermediate class diff --git a/Examples/test-suite/director_ignore.i b/Examples/test-suite/director_ignore.i index 05ba17ce1..57cbc13d8 100644 --- a/Examples/test-suite/director_ignore.i +++ b/Examples/test-suite/director_ignore.i @@ -68,21 +68,6 @@ class DAbstractIgnores virtual double OverloadedProtectedMethod() = 0; }; -class DIgnoreConstructor -{ - public: - virtual ~DIgnoreConstructor() {} - DIgnoreConstructor(std::string s, int i) {} - DIgnoreConstructor(bool b) {} -}; - -class DIgnoreOnlyConstructor -{ - public: - virtual ~DIgnoreOnlyConstructor() {} - DIgnoreOnlyConstructor(bool b) {} -}; - template class DTemplateAbstractIgnores { T t; @@ -101,3 +86,37 @@ template class DTemplateAbstractIgnores %template(DTemplateAbstractIgnoresInt) DTemplateAbstractIgnores; +class DIgnoreConstructor +{ + public: + virtual ~DIgnoreConstructor() {} + DIgnoreConstructor(std::string s, int i) {} + DIgnoreConstructor(bool b) {} +}; + +class DIgnoreOnlyConstructor +{ + public: + virtual ~DIgnoreOnlyConstructor() {} + DIgnoreOnlyConstructor(bool b) {} +}; + +%{ +class DIgnoreConstructor +{ + public: + virtual ~DIgnoreConstructor() {} + DIgnoreConstructor(std::string s, int i) {} + private: // Hide constructor + DIgnoreConstructor(bool b) {} +}; + +class DIgnoreOnlyConstructor +{ + public: + virtual ~DIgnoreOnlyConstructor() {} + private: // Hide constructor + DIgnoreOnlyConstructor(bool b) {} +}; +%} + diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 4f1657825..69df79271 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1995,6 +1995,9 @@ int Language::classDirectorConstructors(Node *n) { for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) { nodeType = Getattr(ni, "nodeType"); if (Cmp(nodeType, "constructor") == 0) { + if (GetFlag(ni, "feature:ignore")) + continue; + Parm *parms = Getattr(ni, "parms"); if (is_public(ni)) { /* emit public constructor */ From d172e3d0ed96e1f242ebaa4066f556a8abe0e764 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 29 Jan 2013 07:28:32 +0000 Subject: [PATCH 002/273] Apply patch SF #334 - Fix Python default value conversions TRUE->True, FALSE->False. --- CHANGES.current | 3 +++ Source/Modules/octave.cxx | 6 +----- Source/Modules/python.cxx | 2 +- Source/Modules/ruby.cxx | 6 +----- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 9c014aa82..1d09ab875 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.10 (in progress) ============================ +2013-01-28: William + [Python] Apply patch SF #334 - Fix default value conversions "TRUE"->True, "FALSE"->False. + 2013-01-28: William [Java] Apply patch SF #335 - Truly ignore constructors in directors with %ignore. diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 5584176a1..bbe442b7e 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -524,11 +524,7 @@ public: } 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) + if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) return NewString("true"); if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) return NewString("false"); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 280a36923..e3d8c7d50 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1556,7 +1556,7 @@ public: else return v; } - if (Strcmp(v, "true") == 0 || Strcmp(v, "FALSE") == 0) + if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) return NewString("True"); if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) return NewString("False"); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index eaec0e185..48680e803 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -790,11 +790,7 @@ private: } 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) + if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) return NewString("True"); if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) return NewString("False"); From 397409fbb1336690c99e77f4f23043626e495d98 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 30 Jan 2013 22:18:13 +0000 Subject: [PATCH 003/273] Ensure 'javapackage' typemap is used as it stopped working from version 2.0.5 --- CHANGES.current | 3 +++ Doc/Manual/Java.html | 7 ++++--- Source/Modules/java.cxx | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1d09ab875..e6aebdb06 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.10 (in progress) ============================ +2013-01-29: William + [Java] Ensure 'javapackage' typemap is used as it stopped working from version 2.0.5. + 2013-01-28: William [Python] Apply patch SF #334 - Fix default value conversions "TRUE"->True, "FALSE"->False. diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 8245d46eb..0024d602a 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -5662,7 +5662,7 @@ to make the method and constructor public:

The Java directors feature requires the "javadirectorin", "javadirectorout", "directorin" and the "directorout" typemaps in order to work properly. -The "javapackage" typemap is an optional typemap used to identify the Java package path for individual SWIG generated proxy classes. +The "javapackage" typemap is an optional typemap used to identify the Java package path for individual SWIG generated proxy classes used in director methods.

%typemap(directorin)

@@ -5803,6 +5803,7 @@ The target method is the method in the Java proxy class which overrides the virt

The "javapackage" typemap is optional; it serves to identify a class's Java package. This typemap should be used in conjunction with classes that are defined outside of the current SWIG interface file. +The typemap is only used if the type is used in a director method, that is, in a virtual method in a director class. For example:

@@ -5819,7 +5820,7 @@ For example: class Example { public: virtual ~Example(); - void ping(Foo *arg1, Bar *arg2); + virtual void ping(Foo *arg1, Bar *arg2); }; } @@ -5844,7 +5845,7 @@ The corrected interface file looks like: class Example { public: virtual ~Example(); - void ping(Foo *arg1, Bar *arg2); + virtual void ping(Foo *arg1, Bar *arg2); }; } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 987b6ddf6..2fb21eca8 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -3527,7 +3527,7 @@ public: String *pkg_path = Swig_typemap_lookup("javapackage", p, "", 0); SwigType *type = Getattr(p, "type"); - if (pkg_path || Len(pkg_path) == 0) + if (!pkg_path || Len(pkg_path) == 0) pkg_path = package_path; String *descriptor_out = Copy(descriptor_in); From 9193b3ed77b54ac46bde5af1de148a9e014daa6e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Feb 2013 20:10:02 +0000 Subject: [PATCH 004/273] Remove unnecessary file/line setting in parser --- Source/CParse/parser.y | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index c93f44cd0..36adf5a09 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1158,8 +1158,6 @@ static Node *nested_forward_declaration(const char *storage, const char *kind, S if (sname) { /* Add forward declaration of the nested type */ Node *n = new_node("classforward"); - Setfile(n, cparse_file); - Setline(n, cparse_line); Setattr(n, "kind", kind); Setattr(n, "name", sname); Setattr(n, "storage", storage); @@ -3832,8 +3830,6 @@ cpp_forward_class_decl : storage_class cpptype idcolon SEMI { $$ = 0; } else { $$ = new_node("classforward"); - Setfile($$,cparse_file); - Setline($$,cparse_line); Setattr($$,"kind",$2); Setattr($$,"name",$3); Setattr($$,"sym:weak", "1"); From 054f9dba1a6f2914d1ed69042162aa4f9d72e0ef Mon Sep 17 00:00:00 2001 From: tpapp Date: Sat, 9 Feb 2013 13:46:46 +0100 Subject: [PATCH 005/273] CFFI - Fix missing package before &body - patch #22 Should fix https://github.com/swig/swig/issues/21. --- CHANGES.current | 9 ++++++--- Lib/cffi/cffi.swg | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index e6aebdb06..9436c29e7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,13 +5,16 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.10 (in progress) ============================ -2013-01-29: William +2013-02-09: wsfulton + [CFFI] Apply patch #22 - Fix missing package before &body + +2013-01-29: wsfulton [Java] Ensure 'javapackage' typemap is used as it stopped working from version 2.0.5. -2013-01-28: William +2013-01-28: wsfulton [Python] Apply patch SF #334 - Fix default value conversions "TRUE"->True, "FALSE"->False. -2013-01-28: William +2013-01-28: wsfulton [Java] Apply patch SF #335 - Truly ignore constructors in directors with %ignore. 2013-01-18: Brant Kyser diff --git a/Lib/cffi/cffi.swg b/Lib/cffi/cffi.swg index 6ac82f45e..427a8dc17 100644 --- a/Lib/cffi/cffi.swg +++ b/Lib/cffi/cffi.swg @@ -152,7 +152,7 @@ %insert("swiglisp") %{ ;;;SWIG wrapper code starts here -(cl:defmacro defanonenum (&body enums) +(cl:defmacro defanonenum (cl:&body enums) "Converts anonymous enums to defconstants." `(cl:progn ,@(cl:loop for value in enums for index = 0 then (cl:1+ index) From b80f4dc5e257a343381e3dbeebb206c1376e3ca3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Feb 2013 19:53:37 +0000 Subject: [PATCH 006/273] Restrict the name used in %extend to be just the struct/class name and not a typedef to a class/struct. Typedefs were only partially working anyway. Anonymous struct typedefs excluded. Deprecate with a warning for now. --- CHANGES.current | 19 ++++++++ Doc/Manual/SWIG.html | 43 ++++++++++++++++--- Doc/Manual/Warnings.html | 3 +- Examples/test-suite/errors/expected.log | 4 ++ Examples/test-suite/errors/make.sh | 1 + Examples/test-suite/errors/swig_extend.i | 35 +++++++++++++++ .../extend_constructor_destructor.i | 3 ++ Examples/test-suite/extend_typedef_class.i | 3 ++ Source/CParse/parser.y | 42 ++++++++++++------ Source/Include/swigwarn.h | 1 + 10 files changed, 134 insertions(+), 20 deletions(-) create mode 100644 Examples/test-suite/errors/swig_extend.i diff --git a/CHANGES.current b/CHANGES.current index 9436c29e7..a111818d9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,25 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.10 (in progress) ============================ +2013-02-15: wsfulton + Deprecate typedef names used in %extend that are not the real class/struct name. For example: + + typedef struct StructBName { + int myint; + } StructB; + + %extend StructB { + void method() {} + } + + will now trigger a warning: + + swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name StructBName + should be used instead of the typedef name StructB. + + This is only partially working anyway (the %extend only worked if placed after the class + definition). + 2013-02-09: wsfulton [CFFI] Apply patch #22 - Fix missing package before &body diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 58a3c8e55..25dc899de 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -2699,7 +2699,7 @@ the following declaration :

 /* file : vector.h */
 ...
-typedef struct {
+typedef struct Vector {
 	double x,y,z;
 } Vector;
 
@@ -2772,7 +2772,7 @@ of the Vector structure. For example:

#include "vector.h" %} -typedef struct { +typedef struct Vector { double x,y,z; %extend { Vector(double x, double y, double z) { ... } @@ -2783,7 +2783,7 @@ typedef struct {

-Finally, %extend can be used to access externally written +Note that %extend can be used to access externally written functions provided they follow the naming convention used in this example :

@@ -2814,7 +2814,7 @@ double Vector_magnitude(Vector *v) { #include "vector.h" %} -typedef struct { +typedef struct Vector { double x,y,z; %extend { Vector(int,int,int); // This calls new_Vector() @@ -2826,6 +2826,37 @@ typedef struct { +

+The name used for %extend should be the name of the struct and not the name of any typedef to the struct. +For example: +

+ +
+typedef struct Integer {
+	int value;
+} Int;
+%extend Integer { ...  } /* Correct name */
+%extend Int { ...  } /* Incorrect name */
+
+struct Float {
+	float value;
+};
+typedef struct Float FloatValue;
+%extend Float { ...  } /* Correct name */
+%extend FloatValue { ...  } /* Incorrect name */
+
+ +

+There is one exception to this rule and that is when the struct is anonymously named such as: +

+ +
+typedef struct {
+	double value;
+} Double;
+%extend Double { ...  } /* Okay */
+
+

A little known feature of the %extend directive is that it can also be used to add synthesized attributes or to modify the @@ -2862,7 +2893,7 @@ For example, consider this interface:

-typedef struct {
+typedef struct Person {
   char name[50];
   ...
 } Person;
@@ -2876,7 +2907,7 @@ the interface as follows to ensure this occurs whenever a name is read or writte
 
 
-typedef struct {
+typedef struct Person {
   %extend {
     char name[50];
   }
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 1571146f1..ccb1751d5 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -423,7 +423,8 @@ example.i(4) : Syntax error in input.
 
  • 322. Redundant redeclaration of 'name'.
  • 323. Recursive scope inheritance of 'name'.
  • 324. Named nested template instantiations not supported. Processing as if no name was given to %template(). -
  • 325. Nested class not currently supported (name ignored). +
  • 325. Nested kind not currently supported (name ignored). +
  • 326. Deprecated %extend name used - the kind name 'name' should be used instead of the typedef name 'name'.
  • 350. operator new ignored.
  • 351. operator delete ignored.
  • 352. operator+ ignored. diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log index 9d4e5db77..d344d076b 100644 --- a/Examples/test-suite/errors/expected.log +++ b/Examples/test-suite/errors/expected.log @@ -188,6 +188,10 @@ pp_variable_args.i:6: Error: Variable length macro argument must be last paramet :::::::::::::::::::::::::::::::: swig_apply_nargs.i ::::::::::::::::::::::::::::::::::: swig_apply_nargs.i:6: Error: Can't apply (char *str,int len) to (int x). Number of arguments don't match. +:::::::::::::::::::::::::::::::: swig_extend.i ::::::::::::::::::::::::::::::::::: +swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name 'StructBName' should be used instead of the typedef name 'StructB'. +swig_extend.i:34: Warning 303: %extend defined for an undeclared class StructDName. + :::::::::::::::::::::::::::::::: swig_identifier.i ::::::::::::::::::::::::::::::::::: swig_identifier.i:5: Warning 503: Can't wrap 'foo bar' unless renamed to a valid identifier. diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh index 90f17a92a..b194299c9 100755 --- a/Examples/test-suite/errors/make.sh +++ b/Examples/test-suite/errors/make.sh @@ -54,6 +54,7 @@ pp_unterm_comment pp_unterm_string pp_variable_args swig_apply_nargs +swig_extend swig_identifier swig_insert_bad swig_typemap_copy diff --git a/Examples/test-suite/errors/swig_extend.i b/Examples/test-suite/errors/swig_extend.i new file mode 100644 index 000000000..ef0652320 --- /dev/null +++ b/Examples/test-suite/errors/swig_extend.i @@ -0,0 +1,35 @@ +%module xxx + +typedef struct { + int myint; +} StructA; + +typedef struct StructBName { + int myint; +} StructB; + +typedef struct StructC { + int myint; +} StructC; + +%extend StructA { + void method() {} +} + +%extend StructB { + void method() {} +} + +%extend StructC { + void method() {} +} + +struct StructD { + int myint; +}; +typedef struct StructD StructDName; + +%extend StructDName { + void method() {} +} + diff --git a/Examples/test-suite/extend_constructor_destructor.i b/Examples/test-suite/extend_constructor_destructor.i index a0ab1a0f6..95b48a6c5 100644 --- a/Examples/test-suite/extend_constructor_destructor.i +++ b/Examples/test-suite/extend_constructor_destructor.i @@ -1,5 +1,8 @@ %module extend_constructor_destructor +%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) Space::tagCStruct; +%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagEStruct; + %inline %{ int globalVar = 0; diff --git a/Examples/test-suite/extend_typedef_class.i b/Examples/test-suite/extend_typedef_class.i index 731802573..2b8c38351 100644 --- a/Examples/test-suite/extend_typedef_class.i +++ b/Examples/test-suite/extend_typedef_class.i @@ -1,5 +1,8 @@ %module extend_typedef_class +%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagCClass; +%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagCStruct; + // classes in global namespace %inline %{ typedef struct tagAClass { diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 36adf5a09..74d41079c 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -38,6 +38,7 @@ static Node *top = 0; /* Top of the generated parse tree */ static int unnamed = 0; /* Unnamed datatype counter */ static Hash *extendhash = 0; /* Hash table of added methods */ static Hash *classes = 0; /* Hash table of classes */ +static Hash *classes_typedefs = 0; /* Hash table of typedef classes: typedef struct X {...} Y; */ static Symtab *prev_symtab = 0; static Node *current_class = 0; String *ModuleName = 0; @@ -718,7 +719,7 @@ static void check_extensions() { for (ki = First(extendhash); ki.key; ki = Next(ki)) { if (!Strchr(ki.key,'<')) { SWIG_WARN_NODE_BEGIN(ki.item); - Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(ki.item), Getline(ki.item), "%%extend defined for an undeclared class %s.\n", ki.key); + Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(ki.item), Getline(ki.item), "%%extend defined for an undeclared class %s.\n", SwigType_namestr(ki.key)); SWIG_WARN_NODE_END(ki.item); } } @@ -1909,20 +1910,34 @@ extend_directive : EXTEND options idcolon LBRACE { String *clsname; cplus_mode = CPLUS_PUBLIC; if (!classes) classes = NewHash(); + if (!classes_typedefs) classes_typedefs = NewHash(); if (!extendhash) extendhash = NewHash(); clsname = make_class_name($3); cls = Getattr(classes,clsname); if (!cls) { - /* No previous definition. Create a new scope */ - Node *am = Getattr(extendhash,clsname); - if (!am) { - Swig_symbol_newscope(); - Swig_symbol_setscopename($3); - prev_symtab = 0; + cls = Getattr(classes_typedefs, clsname); + if (!cls) { + /* No previous definition. Create a new scope */ + Node *am = Getattr(extendhash,clsname); + if (!am) { + Swig_symbol_newscope(); + Swig_symbol_setscopename($3); + prev_symtab = 0; + } else { + prev_symtab = Swig_symbol_setscope(Getattr(am,"symtab")); + } + current_class = 0; } else { - prev_symtab = Swig_symbol_setscope(Getattr(am,"symtab")); + /* Previous typedef class definition. Use its symbol table. + Deprecated, just the real name should be used. + Note that %extend before the class typedef never worked, only %extend after the class typdef. */ + prev_symtab = Swig_symbol_setscope(Getattr(cls, "symtab")); + current_class = cls; + extendmode = 1; + SWIG_WARN_NODE_BEGIN(cls); + Swig_warning(WARN_PARSE_EXTEND_NAME, cparse_file, cparse_line, "Deprecated %%extend name used - the %s name '%s' should be used instead of the typedef name '%s'.\n", Getattr(cls, "kind"), SwigType_namestr(Getattr(cls, "name")), $3); + SWIG_WARN_NODE_END(cls); } - current_class = 0; } else { /* Previous class definition. Use its symbol table */ prev_symtab = Swig_symbol_setscope(Getattr(cls,"symtab")); @@ -3585,7 +3600,6 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { if (!classes) classes = NewHash(); scpname = Swig_symbol_qualifiedscopename(0); Setattr(classes,scpname,$$); - Delete(scpname); appendChild($$,$7); @@ -3606,7 +3620,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { Setattr(p,"type",ty); p = nextSibling(p); } - /* Dump nested classes */ + /* Class typedefs */ { String *name = $3; if ($9) { @@ -3626,8 +3640,9 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { Delete(class_rename); class_rename = NewString(name); } - if (!Getattr(classes,tdscopename)) { - Setattr(classes,tdscopename,$$); + if (!classes_typedefs) classes_typedefs = NewHash(); + if (!Equal(scpname, tdscopename) && !Getattr(classes_typedefs, tdscopename)) { + Setattr(classes_typedefs, tdscopename, $$); } Setattr($$,"decl",decltype); Delete(class_scope); @@ -3638,6 +3653,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { } appendChild($$,dump_nested(Char(name))); } + Delete(scpname); if (cplus_mode != CPLUS_PUBLIC) { /* we 'open' the class at the end, to allow %template diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 76f61ea93..a3fb31012 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -89,6 +89,7 @@ #define WARN_PARSE_REC_INHERITANCE 323 #define WARN_PARSE_NESTED_TEMPLATE 324 #define WARN_PARSE_NAMED_NESTED_CLASS 325 +#define WARN_PARSE_EXTEND_NAME 326 #define WARN_IGNORE_OPERATOR_NEW 350 /* new */ #define WARN_IGNORE_OPERATOR_DELETE 351 /* delete */ From 70cd52f44d4e61460524105dabbe1ac7f29dc6f2 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Mon, 18 Feb 2013 10:31:23 +0100 Subject: [PATCH 007/273] Use "(void)" instead of "()" when wrapping no-argument extension functions. --- CHANGES.current | 39 +++++++++++++++++++++++++++++++++++++++ Source/Swig/cwrap.c | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index a111818d9..4f2477b02 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.10 (in progress) ============================ +2013-02-18: wsfulton + Deprecate typedef names used as constructor and destructor names in %extend. The real + class/struct name should be used. + + typedef struct tagEStruct { + int ivar; + } EStruct; + + %extend tagEStruct { + EStruct() // illegal name, should be tagEStruct() + { + EStruct *s = new EStruct(); + s->ivar = ivar0; + return s; + } + ~EStruct() // illegal name, should be ~tagEStruct() + { + delete $self; + } + } + + For now these trigger a warning: + + extend_constructor_destructor.i:107: Warning 522: Use of an illegal constructor name 'EStruct' in + %extend is deprecated, the constructor name should be 'tagEStruct'. + extend_constructor_destructor.i:111: Warning 523: Use of an illegal destructor name 'EStruct' in + %extend is deprecated, the destructor name should be 'tagEStruct'. + + These %extend destructor and constructor names were valid up to swig-2.0.4, however swig-2.0.5 ignored + them altogether for C code as reported in SF bug #1306. The old behaviour of using them has been + restored for now, but is officially deprecated. This does not apply to anonymously defined typedef + classes/structs such as: + + typedef struct {...} X; + +2013-02-17: kwwette + When generating functions which wrap C extension code, use "(void)" for no-argument functions + instead of "()". This prevents warnings when compiling with "gcc -Wstrict-prototypes". + 2013-02-15: wsfulton Deprecate typedef names used in %extend that are not the real class/struct name. For example: diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 8cd48e94e..c7e101842 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -807,7 +807,7 @@ void Swig_replace_special_variables(Node *n, Node *parentnode, String *code) { * ----------------------------------------------------------------------------- */ static String *extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self) { String *parms_str = cplusplus ? ParmList_str_defaultargs(parms) : ParmList_str(parms); - String *sig = NewStringf("%s(%s)", function_name, parms_str); + String *sig = NewStringf("%s(%s)", function_name, (cplusplus || Len(parms_str)) ? parms_str : "void"); String *rt_sig = SwigType_str(return_type, sig); String *body = NewStringf("SWIGINTERN %s", rt_sig); Printv(body, code, "\n", NIL); From 2435b98a24f0be0abee1573948bb5d1f20d4b711 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Feb 2013 22:37:43 +0000 Subject: [PATCH 008/273] Tweak to changes note --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 4f2477b02..0b65717ff 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -41,7 +41,7 @@ Version 2.0.10 (in progress) typedef struct {...} X; 2013-02-17: kwwette - When generating functions which wrap C extension code, use "(void)" for no-argument functions + When generating functions provided by %extend, use "(void)" for no-argument functions instead of "()". This prevents warnings when compiling with "gcc -Wstrict-prototypes". 2013-02-15: wsfulton From d1b40b468b607c4c71f424a1a2d36c5b240ca975 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Feb 2013 08:40:20 +0000 Subject: [PATCH 009/273] Fix C code where a typedef name was used for constructor and destructor names in %extend. Deprecate use of typedef names for constructor and destructor names going forwards. --- Doc/Manual/Warnings.html | 2 ++ Examples/test-suite/errors/expected.log | 6 ++++ Examples/test-suite/errors/swig_extend.i | 25 +++++++++++++++++ .../extend_constructor_destructor.i | 4 +++ Source/Include/swigwarn.h | 2 ++ Source/Modules/lang.cxx | 28 +++++++++++++++++-- 6 files changed, 65 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index ccb1751d5..cf4c38d7e 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -527,6 +527,8 @@ example.i(4) : Syntax error in input.
  • 519. %template() contains no name. Template method ignored: declaration
  • 520. Base/Derived class 'classname1' of 'classname2' is not similarly marked as a smart pointer.
  • 521. Illegal destructor name name. Ignored. +
  • 522. Use of an illegal constructor name 'name' in %extend is deprecated, the constructor name should be 'name'. +
  • 523. Use of an illegal destructor name 'name' in %extend is deprecated, the destructor name should be 'name'.

    14.9.6 Language module specific (700-899)

    diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log index d344d076b..2db3d8cbc 100644 --- a/Examples/test-suite/errors/expected.log +++ b/Examples/test-suite/errors/expected.log @@ -190,7 +190,13 @@ swig_apply_nargs.i:6: Error: Can't apply (char *str,int len) to (int x). Number :::::::::::::::::::::::::::::::: swig_extend.i ::::::::::::::::::::::::::::::::::: swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name 'StructBName' should be used instead of the typedef name 'StructB'. +swig_extend.i:45: Warning 326: Deprecated %extend name used - the struct name 'stru_struct' should be used instead of the typedef name 'stru'. +swig_extend.i:56: Warning 326: Deprecated %extend name used - the union name 'uni_union' should be used instead of the typedef name 'uni'. swig_extend.i:34: Warning 303: %extend defined for an undeclared class StructDName. +swig_extend.i:50: Warning 522: Use of an illegal constructor name 'stru' in %extend is deprecated, the constructor name should be 'stru_struct'. +swig_extend.i:53: Warning 523: Use of an illegal destructor name 'stru' in %extend is deprecated, the destructor name should be 'stru_struct'. +swig_extend.i:57: Warning 522: Use of an illegal constructor name 'uni' in %extend is deprecated, the constructor name should be 'uni_union'. +swig_extend.i:58: Warning 523: Use of an illegal destructor name 'uni' in %extend is deprecated, the destructor name should be 'uni_union'. :::::::::::::::::::::::::::::::: swig_identifier.i ::::::::::::::::::::::::::::::::::: swig_identifier.i:5: Warning 503: Can't wrap 'foo bar' unless renamed to a valid identifier. diff --git a/Examples/test-suite/errors/swig_extend.i b/Examples/test-suite/errors/swig_extend.i index ef0652320..3f8d9a787 100644 --- a/Examples/test-suite/errors/swig_extend.i +++ b/Examples/test-suite/errors/swig_extend.i @@ -33,3 +33,28 @@ typedef struct StructD StructDName; void method() {} } + +typedef struct stru_struct { + int bar; +} stru; +typedef union uni_union { + int un1; + double un2; +} uni; + +%extend stru { + stru() { + stru* s = (stru*)malloc(sizeof(stru)); + s->bar = 11; + return s; + } + ~stru() { + free($self); + } +} + +%extend uni { + uni() { return 0; } + ~uni() { free($self); } +} + diff --git a/Examples/test-suite/extend_constructor_destructor.i b/Examples/test-suite/extend_constructor_destructor.i index 95b48a6c5..c25b81b03 100644 --- a/Examples/test-suite/extend_constructor_destructor.i +++ b/Examples/test-suite/extend_constructor_destructor.i @@ -2,6 +2,10 @@ %warnfilter(SWIGWARN_PARSE_EXTEND_NAME) Space::tagCStruct; %warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagEStruct; +%warnfilter(SWIGWARN_LANG_EXTEND_CONSTRUCTOR) Space::tagCStruct::CStruct; +%warnfilter(SWIGWARN_LANG_EXTEND_DESTRUCTOR) Space::tagCStruct::~CStruct; +%warnfilter(SWIGWARN_LANG_EXTEND_CONSTRUCTOR) tagEStruct::EStruct; +%warnfilter(SWIGWARN_LANG_EXTEND_DESTRUCTOR) tagEStruct::~EStruct; %inline %{ int globalVar = 0; diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index a3fb31012..daf8b1791 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -197,6 +197,8 @@ #define WARN_LANG_TEMPLATE_METHOD_IGNORE 519 #define WARN_LANG_SMARTPTR_MISSING 520 #define WARN_LANG_ILLEGAL_DESTRUCTOR 521 +#define WARN_LANG_EXTEND_CONSTRUCTOR 522 +#define WARN_LANG_EXTEND_DESTRUCTOR 523 /* -- Reserved (600-799) -- */ diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 69df79271..4d1cefc69 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2631,10 +2631,22 @@ int Language::constructorDeclaration(Node *n) { if (!Equal(actual_name, 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'. + // Check for typedef names used as a constructor name in %extend. This is deprecated except for anonymous + // typedef structs which have had their symbol names adjusted to the typedef name in the parser. SwigType *name_resolved = SwigType_typedef_resolve_all(actual_name); SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name); + + if (!CPlusPlus) { + if (Strncmp(name_resolved, "struct ", 7) == 0) + Replace(name_resolved, "struct ", "", DOH_REPLACE_FIRST); + else if (Strncmp(name_resolved, "union ", 6) == 0) + Replace(name_resolved, "union ", "", DOH_REPLACE_FIRST); + } + illegal_name = !Equal(name_resolved, expected_name_resolved); + if (!illegal_name) + Swig_warning(WARN_LANG_EXTEND_CONSTRUCTOR, input_file, line_number, "Use of an illegal constructor name '%s' in %%extend is deprecated, the constructor name should be '%s'.\n", + SwigType_str(Swig_scopename_last(actual_name), 0), SwigType_str(Swig_scopename_last(expected_name), 0)); Delete(name_resolved); Delete(expected_name_resolved); } @@ -2770,10 +2782,22 @@ int Language::destructorDeclaration(Node *n) { if (!Equal(actual_name, 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'. + // Check for typedef names used as a destructor name in %extend. This is deprecated except for anonymous + // typedef structs which have had their symbol names adjusted to the typedef name in the parser. SwigType *name_resolved = SwigType_typedef_resolve_all(actual_name); SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name); + + if (!CPlusPlus) { + if (Strncmp(name_resolved, "struct ", 7) == 0) + Replace(name_resolved, "struct ", "", DOH_REPLACE_FIRST); + else if (Strncmp(name_resolved, "union ", 6) == 0) + Replace(name_resolved, "union ", "", DOH_REPLACE_FIRST); + } + illegal_name = !Equal(name_resolved, expected_name_resolved); + if (!illegal_name) + Swig_warning(WARN_LANG_EXTEND_DESTRUCTOR, input_file, line_number, "Use of an illegal destructor name '%s' in %%extend is deprecated, the destructor name should be '%s'.\n", + SwigType_str(Swig_scopename_last(actual_name), 0), SwigType_str(Swig_scopename_last(expected_name), 0)); Delete(name_resolved); Delete(expected_name_resolved); } From 9d330a99703f079bdff5a8d7945cc1d2d7c56f53 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 19 Feb 2013 11:46:27 +0100 Subject: [PATCH 010/273] Fix qualifier parsing in SwigType_add_qualifier() - use list to ensure qualifiers are unique and sorted - now allows 'qual' to contain multiple qualifiers --- Source/Swig/typeobj.c | 78 +++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index 20caa9ec9..cb9327dc7 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -16,6 +16,7 @@ #include "swig.h" #include +#include /* ----------------------------------------------------------------------------- * Synopsis @@ -425,61 +426,66 @@ int SwigType_isreference(const SwigType *t) { * Repeated qualifications have no effect. Moreover, the order of qualifications * is alphabetical---meaning that "const volatile" and "volatile const" are * stored in exactly the same way as "q(const volatile)". + * 'qual' can be a list of multiple qualifiers in any order, separated by spaces. * ----------------------------------------------------------------------------- */ -SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) { - String *newq; - int sz, added = 0; - char *q, *cqual; +/* Helper function to sort the mangled list */ +static int SwigType_compare_qualifiers(const DOH *a, const DOH *b) { + return strcmp(Char(a), Char(b)); +} - char *c = Char(t); +SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) { + List *qlist; + String *allq, *newq, *q; + int i, sz; + char *c, *cqual, *cq, *cqprev; + c = Char(t); cqual = Char(qual); - if (!(strncmp(c, "q(", 2) == 0)) { + /* if 't' has no qualifiers and 'qual' is a single qualifier, simply add it */ + if ((strncmp(c, "q(", 2) != 0) && (strstr(cqual, " ") == NULL)) { String *temp = NewStringf("q(%s).", cqual); Insert(t, 0, temp); Delete(temp); return t; } - /* The type already has a qualifier on it. In this case, we first check to - see if the qualifier is already specified. In that case do nothing. - If it is a new qualifier, we add it to the qualifier list in alphabetical - order */ - - sz = element_size(c); - - if (strstr(c, cqual)) { - /* Qualifier already added */ - return t; + /* create string of all qualifiers */ + if (strncmp(c, "q(", 2) == 0) { + allq = SwigType_parm(t); + Append(allq, " "); + SwigType_del_element(t); /* delete old qualifier list from 't' */ + } else { + allq = NewStringEmpty(); } + Append(allq, qual); - /* Add the qualifier to the existing list. */ + /* create list of all qualifiers from string */ + qlist = Split(allq, ' ', INT_MAX); + Delete(allq); + /* sort list */ + SortList(qlist, SwigType_compare_qualifiers); + + /* create new qualifier string from unique elements of list */ + sz = Len(qlist); newq = NewString("q("); - q = c + 2; - q = strtok(q, " )."); - while (q) { - if (strcmp(cqual, q) < 0) { - /* New qualifier is less that current qualifier. We need to insert it */ - Append(newq, cqual); - Append(newq, " "); - Append(newq, q); - added = 1; - } else { + cqprev = NULL; + for (i = 0; i < sz; ++i) { + q = Getitem(qlist, i); + cq = Char(q); + if (cqprev == NULL || strcmp(cqprev, cq) != 0) { + if (i > 0) { + Append(newq, " "); + } Append(newq, q); + cqprev = cq; } - q = strtok(NULL, " )."); - if (q) { - Append(newq, " "); - } - } - if (!added) { - Append(newq, " "); - Append(newq, cqual); } Append(newq, ")."); - Delslice(t, 0, sz); + Delete(qlist); + + /* replace qualifier string with new one */ Insert(t, 0, newq); Delete(newq); return t; From ee2b46abe0b747bc949538f51c9e2a989a867da9 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Mon, 18 Feb 2013 09:48:42 +0100 Subject: [PATCH 011/273] Fix SWIG's handling of qualified (e.g. const) variables of array type --- CHANGES.current | 12 +++ Examples/test-suite/common.mk | 1 + .../test-suite/typemap_array_qualifiers.i | 79 +++++++++++++++++++ Source/Swig/typesys.c | 61 ++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 Examples/test-suite/typemap_array_qualifiers.i diff --git a/CHANGES.current b/CHANGES.current index 0b65717ff..779e20528 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,18 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.10 (in progress) ============================ +2013-02-19: kwwette + Fix bug in SWIG's handling of qualified (e.g. const) variables of array type. Given the typedef + a(7).q(volatile).double myarray // typedef volatile double[7] myarray; + the type + q(const).myarray // const myarray + becomes + a(7).q(const volatile).double // const volatile double[7] + Previously, SwigType_typedef_resolve() produces the type + q(const).a(7).q(volatile).double // non-sensical type + which would never match %typemap declarations, whose types were parsed correctly. + Add typemap_array_qualifiers.i to the test suite which checks for the correct behaviour. + 2013-02-18: wsfulton Deprecate typedef names used as constructor and destructor names in %extend. The real class/struct name should be used. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 173e9b287..83be90d2d 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -433,6 +433,7 @@ CPP_TEST_CASES += \ typedef_sizet \ typedef_struct \ typemap_arrays \ + typemap_array_qualifiers \ typemap_delete \ typemap_directorout \ typemap_global_scope \ diff --git a/Examples/test-suite/typemap_array_qualifiers.i b/Examples/test-suite/typemap_array_qualifiers.i new file mode 100644 index 000000000..947721402 --- /dev/null +++ b/Examples/test-suite/typemap_array_qualifiers.i @@ -0,0 +1,79 @@ +%module typemap_array_qualifiers + +%define CLEAR_SWIGTYPE_TYPEMAPS +%typemap(in) + SWIGTYPE, + SWIGTYPE *, + SWIGTYPE *const, + SWIGTYPE *const&, + const SWIGTYPE *, + const SWIGTYPE *const, + const SWIGTYPE *const&, + const volatile SWIGTYPE *, + const volatile SWIGTYPE *const, + const volatile SWIGTYPE *const&, + SWIGTYPE [], + SWIGTYPE [ANY], + const SWIGTYPE [], + const SWIGTYPE [ANY], + const volatile SWIGTYPE [], + const volatile SWIGTYPE [ANY], + SWIGTYPE &, + const SWIGTYPE &, + const volatile SWIGTYPE & +{ +%#error Incorrect typemap for $symname: $type +} +%enddef + +%inline %{ + typedef struct { + int a; + } SomeType; + typedef SomeType myarray[3]; + typedef const SomeType myconstarray[4]; + typedef volatile SomeType ** mycrazyarray[5]; + typedef volatile SomeType (mycrazyfunc)(SomeType); + typedef volatile SomeType (*mycrazyfuncptr)(SomeType); +%} + +CLEAR_SWIGTYPE_TYPEMAPS; +%typemap(in) SWIGTYPE [ANY] { +/* Correct typemap for $symname: $type */ +} +%inline %{ + void func1a(myarray x) {}; + void func1b(volatile myarray x) {}; +%} + +CLEAR_SWIGTYPE_TYPEMAPS; +%typemap(in) const SWIGTYPE [ANY] { +/* Correct typemap for $symname: $type */ +} +%typemap(in) const volatile SWIGTYPE [ANY] { +/* Correct typemap for $symname: $type */ +} +%inline %{ + void func2a(const myarray x) {}; + void func2b(const myconstarray x) {}; + void func2c(const volatile myconstarray x) {}; +%} + +CLEAR_SWIGTYPE_TYPEMAPS; +%typemap(in) volatile SWIGTYPE **const [ANY] { +/* Correct typemap for $symname: $type */ +} +%typemap(in) volatile SWIGTYPE **const [ANY][ANY] { +/* Correct typemap for $symname: $type */ +} +%inline %{ + void func3a(const mycrazyarray x, const mycrazyarray y[7]) {}; +%} + +CLEAR_SWIGTYPE_TYPEMAPS; +%typemap(in) SWIGTYPE (*const) (ANY) { +/* Correct typemap for $symname: $type */ +} +%inline %{ + void func4a(mycrazyfunc *const x, const mycrazyfuncptr y) {}; +%} diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index d12d70543..372ac3f65 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -792,6 +792,67 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) { goto return_result; } Delete(base); + + /* If 'type' is an array, then the right-most qualifier in 'r' should + be added to 'type' after the array qualifier, so that given + a(7).q(volatile).double myarray // typedef volatile double[7] myarray; + the type + q(const).myarray // const myarray + becomes + a(7).q(const volatile).double // const volatile double[7] + and NOT + q(const).a(7).q(volatile).double // non-sensical type + */ + if (r && Len(r) && SwigType_isarray(type)) { + List *r_elem; + String *r_qual; + int r_sz; + r_elem = SwigType_split(r); + r_sz = Len(r_elem); + r_qual = Getitem(r_elem, r_sz-1); + if (SwigType_isqualifier(r_qual)) { + String *new_r; + String *new_type; + List *type_elem; + String *type_qual; + String *r_qual_arg; + int i, type_sz; + + type_elem = SwigType_split(type); + type_sz = Len(type_elem); + i = 0; + for (i = 0; i < type_sz; ++i) { + String *e = Getitem(type_elem, i); + if (!SwigType_isarray(e)) + break; + } + type_qual = Copy(Getitem(type_elem, i)); + r_qual_arg = SwigType_parm(r_qual); + SwigType_add_qualifier(type_qual, r_qual_arg); + Delete(r_qual_arg); + Setitem(type_elem, i, type_qual); + + new_r = NewStringEmpty(); + for (i = 0; i < r_sz-1; ++i) { + Append(new_r, Getitem(r_elem, i)); + } + new_type = NewStringEmpty(); + for (i = 0; i < type_sz; ++i) { + Append(new_type, Getitem(type_elem, i)); + } +#ifdef SWIG_DEBUG + Printf(stdout, "r+type='%s%s' new_r+new_type='%s%s'\n", r, type, new_r, new_type); +#endif + + Delete(r); + r = new_r; + newtype = 1; + type = new_type; + Delete(type_elem); + } + Delete(r_elem); + } + Append(r, type); if (newtype) { Delete(type); From cfd8497f3edd85c2cbaab86365586cd773b12e17 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 21 Feb 2013 07:00:25 +0000 Subject: [PATCH 012/273] Cosmetic changes in SwigType_add_qualifier --- Source/Swig/typeobj.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index cb9327dc7..1fe63ff27 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -429,21 +429,16 @@ int SwigType_isreference(const SwigType *t) { * 'qual' can be a list of multiple qualifiers in any order, separated by spaces. * ----------------------------------------------------------------------------- */ -/* Helper function to sort the mangled list */ -static int SwigType_compare_qualifiers(const DOH *a, const DOH *b) { - return strcmp(Char(a), Char(b)); -} - SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) { List *qlist; - String *allq, *newq, *q; + String *allq, *newq; int i, sz; - char *c, *cqual, *cq, *cqprev; - c = Char(t); - cqual = Char(qual); + const char *cqprev = 0; + const char *c = Char(t); + const char *cqual = Char(qual); /* if 't' has no qualifiers and 'qual' is a single qualifier, simply add it */ - if ((strncmp(c, "q(", 2) != 0) && (strstr(cqual, " ") == NULL)) { + if ((strncmp(c, "q(", 2) != 0) && (strstr(cqual, " ") == 0)) { String *temp = NewStringf("q(%s).", cqual); Insert(t, 0, temp); Delete(temp); @@ -464,17 +459,16 @@ SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) { qlist = Split(allq, ' ', INT_MAX); Delete(allq); - /* sort list */ - SortList(qlist, SwigType_compare_qualifiers); + /* sort in alphabetical order */ + SortList(qlist, Strcmp); /* create new qualifier string from unique elements of list */ sz = Len(qlist); newq = NewString("q("); - cqprev = NULL; for (i = 0; i < sz; ++i) { - q = Getitem(qlist, i); - cq = Char(q); - if (cqprev == NULL || strcmp(cqprev, cq) != 0) { + String *q = Getitem(qlist, i); + const char *cq = Char(q); + if (cqprev == 0 || strcmp(cqprev, cq) != 0) { if (i > 0) { Append(newq, " "); } From de136ad6cf64c369f4d6551cd5185ac87c1410ba Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 21 Feb 2013 07:09:27 +0000 Subject: [PATCH 013/273] Uncomment testing of overloading of const char arrays which was fixed in svn r12541 for swig-2.0.3. --- Examples/test-suite/arrays_global.i | 2 -- 1 file changed, 2 deletions(-) diff --git a/Examples/test-suite/arrays_global.i b/Examples/test-suite/arrays_global.i index 10d29b6dc..fd53a224e 100644 --- a/Examples/test-suite/arrays_global.i +++ b/Examples/test-suite/arrays_global.i @@ -61,7 +61,6 @@ char* test_b(name a, const namea b) { return a; } -#if 0 int test_a(int a) { return a; } @@ -70,7 +69,6 @@ int test_b(int a) { return a; } -#endif %} From 8e340c158c41ee053fd2be2f30b47e9a060515c9 Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Fri, 22 Feb 2013 10:11:50 +0100 Subject: [PATCH 014/273] Fixed #1300 clang warning in SWIG_Python_ConvertPtrAndOwn. --- Lib/python/pyrun.swg | 4 ++-- Lib/swigrun.swg | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 3585e7a3f..cbb993064 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1231,10 +1231,10 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int *ptr = vptr; /* transfer the ownership to 'ptr' */ iobj->own = 0; - res = SWIG_AddCast(res); + SWIG_AddCastInplace(&res); res = SWIG_AddNewMask(res); } else { - res = SWIG_AddCast(res); + SWIG_AddCastInplace(&res); } } } diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index e5afb62c4..3f68d66d6 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -161,13 +161,20 @@ # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +SWIGINTERNINLINE int SWIG_AddCastInplace(int *r) { + if (SWIG_IsOK(*r)) { + *r = (SWIG_CastRank(*r) < SWIG_MAXCASTRANK) ? (*r + 1) : SWIG_ERROR; + } +} +SWIGINTERNINLINE int SWIG_AddCast(int r) { + SWIG_AddCastInplace(&r); + return r; } SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ +# define SWIG_AddCastInplace(r) # define SWIG_AddCast # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif From 7acf6b5fef128de8e9ded023870006b10b4a39a8 Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Mon, 25 Feb 2013 09:53:45 +0100 Subject: [PATCH 015/273] Revert "Fixed #1300 clang warning in SWIG_Python_ConvertPtrAndOwn." This reverts commit 8e340c158c41ee053fd2be2f30b47e9a060515c9. --- Lib/python/pyrun.swg | 4 ++-- Lib/swigrun.swg | 11 ++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index cbb993064..3585e7a3f 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1231,10 +1231,10 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int *ptr = vptr; /* transfer the ownership to 'ptr' */ iobj->own = 0; - SWIG_AddCastInplace(&res); + res = SWIG_AddCast(res); res = SWIG_AddNewMask(res); } else { - SWIG_AddCastInplace(&res); + res = SWIG_AddCast(res); } } } diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index 3f68d66d6..e5afb62c4 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -161,20 +161,13 @@ # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCastInplace(int *r) { - if (SWIG_IsOK(*r)) { - *r = (SWIG_CastRank(*r) < SWIG_MAXCASTRANK) ? (*r + 1) : SWIG_ERROR; - } -} -SWIGINTERNINLINE int SWIG_AddCast(int r) { - SWIG_AddCastInplace(&r); - return r; +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ -# define SWIG_AddCastInplace(r) # define SWIG_AddCast # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif From c23b7606cf665ce1a4e0f666f6926282971d108f Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Mon, 25 Feb 2013 11:07:42 +0100 Subject: [PATCH 016/273] MOdified only no-cast-rank version of SWIG_AddCast. --- Lib/swigrun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index e5afb62c4..b3c11c136 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -168,7 +168,7 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ -# define SWIG_AddCast +# define SWIG_AddCast(r) ((r)+0) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif From 8155e145799728eba648f63a5e3da6ab513ed63b Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Tue, 26 Feb 2013 09:26:13 +0100 Subject: [PATCH 017/273] Macro expansion to self assign is effectively ignored. --- Lib/swigrun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index b3c11c136..999c87333 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -168,7 +168,7 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ -# define SWIG_AddCast(r) ((r)+0) +# define SWIG_AddCast(r) (r) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif From 670962cfe8d951004f927c803e505f23ee373d3a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Mar 2013 07:32:40 +0000 Subject: [PATCH 018/273] SWIG_TypeCompare was not working as commented - return values were 0,1 and not 1,0,-1. Although undocumented and not used anywhere within SWIG, it has been replaced with SWIG_TypeCmp to work as commented. --- Lib/swigrun.swg | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index 999c87333..21f0a5c14 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -232,18 +232,18 @@ SWIG_TypeNameComp(const char *f1, const char *l1, /* Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal + Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; const char* te = tb + strlen(tb); const char* ne = nb; - while (!equiv && *ne) { + while (equiv != 0 && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + equiv = SWIG_TypeNameComp(nb, ne, tb, te); if (*ne) ++ne; } return equiv; @@ -251,24 +251,13 @@ SWIG_TypeEquiv(const char *nb, const char *tb) { /* Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb + Return 0 if not equal, 1 if equal */ SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; } - /* Check the typename */ From e0b14786d6d22276dda85354babbfeffdfd78072 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 5 Mar 2013 18:17:50 +0100 Subject: [PATCH 019/273] Fix some useless code detected by scan-build (LLVM/Clang) --- Source/CParse/templ.c | 7 +------ Source/Modules/ocaml.cxx | 3 --- Source/Modules/octave.cxx | 1 - Source/Modules/perl5.cxx | 1 - Source/Modules/php.cxx | 2 -- Source/Swig/typeobj.c | 2 -- Source/Swig/typesys.c | 2 +- 7 files changed, 2 insertions(+), 16 deletions(-) diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index ed6acfc8c..48bdf4faa 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -317,14 +317,13 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab if (tp) { Symtab *tsdecl = Getattr(n, "sym:symtab"); while (p && tp) { - String *name, *value, *valuestr, *tydef, *tmp, *tmpr; + String *name, *value, *valuestr, *tmp, *tmpr; int sz, i; String *dvalue = 0; String *qvalue = 0; name = Getattr(tp, "name"); value = Getattr(p, "value"); - tydef = Getattr(p, "typedef"); if (name) { if (!value) @@ -365,9 +364,6 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab /* Printf(stdout,"'%s'\n", s); */ } - if (!tydef) { - tydef = dvalue; - } tmp = NewStringf("#%s", name); tmpr = NewStringf("\"%s\"", valuestr); @@ -375,7 +371,6 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab for (i = 0; i < sz; i++) { String *s = Getitem(cpatchlist, i); Replace(s, tmp, tmpr, DOH_REPLACE_ID); - /* Replace(s,name,tydef, DOH_REPLACE_ID); */ Replace(s, name, valuestr, DOH_REPLACE_ID); } Delete(tmp); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 34c8975c5..c5fcf69dd 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1583,8 +1583,6 @@ public: String *cleanup = NewString(""); String *outarg = NewString(""); - idx = 0; - tm = Swig_typemap_lookup("directorout", n, "c_result", w); if (tm != 0) { Replaceall(tm, "$input", "swig_result"); @@ -1742,7 +1740,6 @@ public: p = NewParm(type, NewString("self"), n); q = Copy(p); set_nextSibling(p, parms); - parms = p; { Wrapper *w = NewWrapper(); diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index bbe442b7e..6f6e5b8ae 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -1371,7 +1371,6 @@ public: outputs++; // build argument list and type conversion string - idx = 0; p = l; while (p) { if (checkAttribute(p, "tmap:in:numinputs", "0")) { diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 7147e67c1..09500b23b 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -610,7 +610,6 @@ public: Printf(f->code, "}\n"); /* Write code to extract parameters. */ - i = 0; for (i = 0, p = l; i < num_arguments; i++) { /* Skip ignored arguments */ diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 292f979ba..fdd335993 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -787,7 +787,6 @@ public: } f = NewWrapper(); - numopt = 0; String *outarg = NewStringEmpty(); String *cleanup = NewStringEmpty(); @@ -1736,7 +1735,6 @@ public: if (!class_node) { /* This is needed when we're returning a pointer to a type * rather than returning the type by value or reference. */ - class_node = current_class; Delete(mangled); mangled = NewString(SwigType_manglestr(ret_type)); class_node = Getattr(zend_types, mangled); diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index 1fe63ff27..56892f3f8 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -746,7 +746,6 @@ SwigType *SwigType_add_function(SwigType *t, ParmList *parms) { Insert(t, 0, ")."); pstr = NewString("f("); - p = parms; for (p = parms; p; p = nextSibling(p)) { if (p != parms) Putc(',', pstr); @@ -844,7 +843,6 @@ SwigType *SwigType_add_template(SwigType *t, ParmList *parms) { Parm *p; Append(t, "<("); - p = parms; for (p = parms; p; p = nextSibling(p)) { String *v; if (Getattr(p, "default")) diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 372ac3f65..c10ffbfb5 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -820,7 +820,7 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) { type_elem = SwigType_split(type); type_sz = Len(type_elem); - i = 0; + for (i = 0; i < type_sz; ++i) { String *e = Getitem(type_elem, i); if (!SwigType_isarray(e)) From fdea8a8f51a3734989729ea928b720083b32928f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 8 Mar 2013 22:19:07 +0000 Subject: [PATCH 020/273] More useless code removal as detected by scan-build (LLVM/Clang) using scan-build ./configure && scan-build make --- Source/Swig/scanner.c | 2 +- Source/Swig/stype.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 52e21dc0a..ed2d43b51 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -1141,7 +1141,7 @@ void Scanner_skip_line(Scanner * s) { if ((c = nextchar(s)) == 0) return; if (c == '\\') { - c = nextchar(s); + nextchar(s); } else if (c == '\n') { done = 1; } diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 8dc189725..fcaf54093 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -640,7 +640,6 @@ SwigType *SwigType_ltype(const SwigType *s) { if (td && (SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td))) { /* We need to use the typedef type */ Delete(tt); - tt = td; break; } else if (td) { Delete(tt); From 52c754a22d4556795a3927706256bfae4624ccc4 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sun, 17 Feb 2013 15:56:25 +0100 Subject: [PATCH 021/273] Minor fix to Octave autodoc generation for functions returning structs Patch #27 - see also git commit 72ffdb930dcbbe0ae2a1cf7164a7ca4b632b1fee --- CHANGES.current | 3 +++ Source/Modules/octave.cxx | 10 +++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 779e20528..90389d812 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -56,6 +56,9 @@ Version 2.0.10 (in progress) When generating functions provided by %extend, use "(void)" for no-argument functions instead of "()". This prevents warnings when compiling with "gcc -Wstrict-prototypes". +2013-02-17: kwwette + [Octave] Minor fix to autodoc generation: get the right type for functions returning structs. + 2013-02-15: wsfulton Deprecate typedef names used in %extend that are not the real class/struct name. For example: diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 6f6e5b8ae..a9be76fc2 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -355,14 +355,10 @@ public: SwigType *type = Getattr(n, "type"); if (type && Strcmp(type, "void")) { - type = SwigType_base(type); - Node *lookup = Swig_symbol_clookup(type, 0); - if (lookup) - type = Getattr(lookup, "sym:name"); + Node *nn = classLookup(Getattr(n, "type")); + String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); Append(decl_info, "@var{retval} = "); - String *type_str = NewString(""); - Printf(type_str, "@var{retval} is of type %s. ", type); - Append(args_str, type_str); + Printf(args_str, "%s@var{retval} is of type %s. ", args_str, type_str); Delete(type_str); } From 92276044248ca3a9b48c13afa85bc1175c4a3e21 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 16 Mar 2013 17:43:08 +0000 Subject: [PATCH 022/273] First attempt at Travis Continuous integration builds --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..ecd39ab85 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: cpp +compiler: + - gcc + - clang +script: ./autogen.sh && ./configure && make From 46523a074ff6ae1f9d8c52e270f0c3e13e2d7671 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 17 Mar 2013 19:44:28 +0000 Subject: [PATCH 023/273] Travis CI only on master and silent builds --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ecd39ab85..c41027bc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,7 @@ language: cpp compiler: - gcc - clang -script: ./autogen.sh && ./configure && make +script: ./autogen.sh && ./configure && make -s +branches: + only: + - master From d2551e22e275780f9c6c5bf30d0b24a3ef556532 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 17 Mar 2013 20:32:03 +0000 Subject: [PATCH 024/273] Try Python test-suite on Travis --- .travis.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c41027bc0..ee7ded0de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,13 @@ language: cpp compiler: - gcc - clang -script: ./autogen.sh && ./configure && make -s +python: + - "2.7" + - "3.3" +before_install: + - sudo apt-get update -qq + - sudo apt-get install libboost-dev -qq +script: ./autogen.sh && ./configure && make -s && make -k check-python-test-suite branches: only: - master From 4003f65a94092d73b8b6e512097a45e8e9bc260b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 17 Mar 2013 21:40:44 +0000 Subject: [PATCH 025/273] Try combinations of Java and Python Travis builds --- .travis.yml | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee7ded0de..2ac250a4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,31 @@ language: cpp compiler: - gcc - - clang +# - clang python: - "2.7" - "3.3" +jdk: + - oraclejdk7 + - openjdk6 +env: + - SWIGLANG=python +matrix: + include: + - python: "2.7" + - compiler: gcc + - env: SWIGLANG=python + include: + - jdk: oraclejdk7 + - compiler: gcc + - env: SWIGLANG=java before_install: - - sudo apt-get update -qq - sudo apt-get install libboost-dev -qq -script: ./autogen.sh && ./configure && make -s && make -k check-python-test-suite +script: + - set + - ./autogen.sh && ./configure + - make -s + - make -k check-$SWIGLANG-examples check-$SWIGLANG-test-suite branches: only: - master From 7c80f007c471302f0d6d07cf78846edd6fd9b493 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 19 Mar 2013 18:38:45 +1300 Subject: [PATCH 026/273] Fix typo in Python docstring for acquire method --- Lib/python/pyrun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 3585e7a3f..7cf9c41fa 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -668,7 +668,7 @@ SwigPyObject_own(PyObject *v, PyObject *args) static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, From 7b50640c055b45c17c40bde1f72ab932d55795c6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 19 Mar 2013 19:45:35 +0000 Subject: [PATCH 027/273] More Travis attempts at controlling what is built --- .travis.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2ac250a4e..92402d346 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,4 @@ language: cpp -compiler: - - gcc -# - clang -python: - - "2.7" - - "3.3" -jdk: - - oraclejdk7 - - openjdk6 -env: - - SWIGLANG=python matrix: include: - python: "2.7" From 9d0b20916f1aa709efcdd0d1f1a3985f205bf0a0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Mar 2013 19:49:46 +0000 Subject: [PATCH 028/273] Add ability to suppress some director warnings by their method name, not just the containing class name --- Examples/test-suite/director_basic.i | 5 +++-- Examples/test-suite/director_classes.i | 3 ++- .../test-suite/java_director_assumeoverride.i | 1 - Source/Modules/lang.cxx | 15 +++++++++------ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Examples/test-suite/director_basic.i b/Examples/test-suite/director_basic.i index 56864f4a7..4c258b097 100644 --- a/Examples/test-suite/director_basic.i +++ b/Examples/test-suite/director_basic.i @@ -1,5 +1,6 @@ - %module(directors="1") director_basic - #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR +%module(directors="1") director_basic + +%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod; %{ #include diff --git a/Examples/test-suite/director_classes.i b/Examples/test-suite/director_classes.i index 7183e3d0a..98c29e88c 100644 --- a/Examples/test-suite/director_classes.i +++ b/Examples/test-suite/director_classes.i @@ -1,7 +1,8 @@ // Tests classes passed by value, pointer and reference // Note: C# module has a large runtime test -#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR +%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ref; +%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ptr; %module(directors="1") director_classes diff --git a/Examples/test-suite/java_director_assumeoverride.i b/Examples/test-suite/java_director_assumeoverride.i index 7364a3d58..cddebb4d7 100644 --- a/Examples/test-suite/java_director_assumeoverride.i +++ b/Examples/test-suite/java_director_assumeoverride.i @@ -1,5 +1,4 @@ %module(directors="1") java_director_assumeoverride -#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR %{ class OverrideMe { diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 4d1cefc69..eb7d49480 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -88,7 +88,6 @@ extern int AddExtern; * ---------------------------------------------------------------------- */ int Dispatcher::emit_one(Node *n) { - String *wrn; int ret = SWIG_OK; char *tag = Char(nodeType(n)); @@ -104,10 +103,9 @@ int Dispatcher::emit_one(Node *n) { return SWIG_OK; /* Look for warnings */ - wrn = Getattr(n, "feature:warnfilter"); - if (wrn) { + String *wrn = Getattr(n, "feature:warnfilter"); + if (wrn) Swig_warnfilter(wrn, 1); - } /* ============================================================ * C/C++ parsing @@ -181,9 +179,8 @@ int Dispatcher::emit_one(Node *n) { Swig_error(input_file, line_number, "Unrecognized parse tree node type '%s'\n", tag); ret = SWIG_ERROR; } - if (wrn) { + if (wrn) Swig_warnfilter(wrn, 0); - } return ret; } @@ -2063,6 +2060,10 @@ int Language::classDirectorMethods(Node *n) { if (GetFlag(method, "feature:nodirector")) continue; + String *wrn = Getattr(method, "feature:warnfilter"); + if (wrn) + Swig_warnfilter(wrn, 1); + String *type = Getattr(method, "nodeType"); if (!Cmp(type, "destructor")) { classDirectorDestructor(method); @@ -2074,6 +2075,8 @@ int Language::classDirectorMethods(Node *n) { SetFlag(item, "director"); Swig_restore(method); } + if (wrn) + Swig_warnfilter(wrn, 0); } return SWIG_OK; From e182b4844cc575da2f5e0321f4356783e1b63932 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 19 Mar 2013 18:34:06 +0000 Subject: [PATCH 029/273] Fix seg fault in SWIG using directors when class and virtual method names are the same except being in different namespaces when the %nspace feature is not being used. --- CHANGES.current | 4 ++++ Source/Modules/csharp.cxx | 13 ++----------- Source/Modules/d.cxx | 13 ++----------- Source/Modules/java.cxx | 16 +++------------- 4 files changed, 11 insertions(+), 35 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 90389d812..6547a88be 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.10 (in progress) ============================ +2013-03-19: wsfulton + [C#, Java, D] Fix seg fault in SWIG using directors when class and virtual method names are + the same except being in different namespaces when the %nspace feature is not being used. + 2013-02-19: kwwette Fix bug in SWIG's handling of qualified (e.g. const) variables of array type. Given the typedef a(7).q(volatile).double myarray // typedef volatile double[7] myarray; diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 0d15a9c1d..4ef62d2cc 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -630,23 +630,14 @@ public: *----------------------------------------------------------------------*/ UpcallData *addUpcallMethod(String *imclass_method, String *class_method, String *decl, String *overloaded_name) { - UpcallData *udata; - String *class_methodidx; - Hash *new_udata; String *key = NewStringf("%s|%s", imclass_method, decl); ++curr_class_dmethod; - /* Do we know about this director class already? */ - if ((udata = Getattr(dmethods_table, key))) { - Delete(key); - return Getattr(udata, "methodoff"); - } - - class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); + String *class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); n_dmethods++; - new_udata = NewHash(); + Hash *new_udata = NewHash(); Append(dmethods_seq, new_udata); Setattr(dmethods_table, key, new_udata); diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 88c3ccfff..e09e253f8 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -3704,23 +3704,14 @@ private: UpcallData *addUpcallMethod(String *imclass_method, String *class_method, String *decl, String *overloaded_name, String *return_type, String *param_list) { - UpcallData *udata; - String *class_methodidx; - Hash *new_udata; String *key = NewStringf("%s|%s", imclass_method, decl); ++curr_class_dmethod; - /* Do we know about this director class already? */ - if ((udata = Getattr(dmethods_table, key))) { - Delete(key); - return Getattr(udata, "methodoff"); - } - - class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); + String *class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); n_dmethods++; - new_udata = NewHash(); + Hash *new_udata = NewHash(); Append(dmethods_seq, new_udata); Setattr(dmethods_table, key, new_udata); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 2fb21eca8..f351c91a3 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -741,25 +741,15 @@ public: *----------------------------------------------------------------------*/ UpcallData *addUpcallMethod(String *imclass_method, String *class_method, String *imclass_desc, String *class_desc, String *decl) { - UpcallData *udata; - String *imclass_methodidx; - String *class_methodidx; - Hash *new_udata; String *key = NewStringf("%s|%s", imclass_method, decl); ++curr_class_dmethod; - /* Do we know about this director class already? */ - if ((udata = Getattr(dmethods_table, key))) { - Delete(key); - return Getattr(udata, "methodoff"); - } - - imclass_methodidx = NewStringf("%d", n_dmethods); - class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); + String *imclass_methodidx = NewStringf("%d", n_dmethods); + String *class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); n_dmethods++; - new_udata = NewHash(); + Hash *new_udata = NewHash(); Append(dmethods_seq, new_udata); Setattr(dmethods_table, key, new_udata); From 6fecb05379da3dd3e7a2dd2711d18b89db3dea28 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 19 Mar 2013 19:44:42 +0000 Subject: [PATCH 030/273] Fix director_nspace_director_name_collision test for languages that don't support %nspace --- Examples/test-suite/director_nspace_director_name_collision.i | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/director_nspace_director_name_collision.i b/Examples/test-suite/director_nspace_director_name_collision.i index 5ef2509f8..e7abffcb1 100644 --- a/Examples/test-suite/director_nspace_director_name_collision.i +++ b/Examples/test-suite/director_nspace_director_name_collision.i @@ -39,6 +39,7 @@ namespace TopLevel %nspace TopLevel::B::Foo; #else #warning nspace feature not yet supported in this target language +%ignore TopLevel::B::Foo; #endif %feature("director") TopLevel::A::Foo; From 12ee3e9c4c1d9be3bb51ec6ce12e4aabc11fa388 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 19 Mar 2013 22:15:07 +0000 Subject: [PATCH 031/273] Fix Travis matrix --- .travis.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 92402d346..1f8255df2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,16 +2,14 @@ language: cpp matrix: include: - python: "2.7" - - compiler: gcc - - env: SWIGLANG=python - include: + compiler: gcc + env: SWIGLANG=python - jdk: oraclejdk7 - - compiler: gcc - - env: SWIGLANG=java + compiler: gcc + env: SWIGLANG=java before_install: - sudo apt-get install libboost-dev -qq script: - - set - ./autogen.sh && ./configure - make -s - make -k check-$SWIGLANG-examples check-$SWIGLANG-test-suite From 7d083890e66c5d5f9237926b0ab81d963057a3af Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 19 Mar 2013 22:41:04 +0000 Subject: [PATCH 032/273] More Travis build experiments --- .travis.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1f8255df2..78205c848 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,31 @@ language: cpp +compiler: + - gcc + - clang matrix: include: - python: "2.7" compiler: gcc env: SWIGLANG=python + - jdk: oraclejdk6 + compiler: gcc + env: SWIGLANG=java - jdk: oraclejdk7 compiler: gcc env: SWIGLANG=java + - perl: "5.10" + compiler: gcc + env: SWIGLANG=perl + - rvm: 1.8.7 + compiler: gcc + env: SWIGLANG=ruby before_install: - sudo apt-get install libboost-dev -qq script: - ./autogen.sh && ./configure - make -s - - make -k check-$SWIGLANG-examples check-$SWIGLANG-test-suite + - echo "SWIGLANG: $SWIGLANG" +# - make -k check-$SWIGLANG-examples check-$SWIGLANG-test-suite branches: only: - master From b72aca1d0739c66ff3bc3dc54385f296e662082b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 20 Mar 2013 15:39:03 +1300 Subject: [PATCH 033/273] Fix typo in comment (swift->swig) --- Lib/python/director.swg | 2 +- Lib/ruby/director.swg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/python/director.swg b/Lib/python/director.swg index ca46f6dab..97edc7ef0 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -33,7 +33,7 @@ /* Use -DSWIG_DIRECTOR_NO_UEH if you prefer to avoid the use of the - Undefined Exception Handler provided by swift + Undefined Exception Handler provided by swig. */ #ifndef SWIG_DIRECTOR_NO_UEH #ifndef SWIG_DIRECTOR_UEH diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg index 9807b11bb..a5daf2176 100644 --- a/Lib/ruby/director.swg +++ b/Lib/ruby/director.swg @@ -7,7 +7,7 @@ /* Use -DSWIG_DIRECTOR_NOUEH if you prefer to avoid the use of the - Undefined Exception Handler provided by swift + Undefined Exception Handler provided by swig. */ #ifndef SWIG_DIRECTOR_NOUEH #ifndef SWIG_DIRECTOR_UEH From 23bcc1c66b5f0c02960eacc8db975d110f2c1d8a Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 20 Mar 2013 16:45:24 +1300 Subject: [PATCH 034/273] Remove lingering relic of PHP4 support --- Lib/exception.i | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Lib/exception.i b/Lib/exception.i index 8d8df33dd..dc3a7f462 100644 --- a/Lib/exception.i +++ b/Lib/exception.i @@ -14,12 +14,8 @@ #ifdef SWIGPHP %{ -#if PHP_MAJOR_VERSION < 5 -# define SWIG_exception(code, msg) { zend_error(E_ERROR, msg); } -#else -# include "zend_exceptions.h" -# define SWIG_exception(code, msg) { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); } -#endif +#include "zend_exceptions.h" +#define SWIG_exception(code, msg) { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); } %} #endif From b132992b8aa9d3afcbc45d6a6d15fe9f60c559e5 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 21 Mar 2013 14:25:14 +1300 Subject: [PATCH 035/273] Stop claiming that SWIG_exception() can be used in helper functions --- Doc/Manual/Customization.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index b75eda9c4..f420f42d6 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -592,9 +592,7 @@ SWIG_NullReferenceError
  • -Since the SWIG_exception() function is defined at the C-level -it can be used elsewhere in SWIG. This includes typemaps and helper -functions. +The SWIG_exception() function can also be used in typemaps.

    11.2 Object ownership and %newobject

    From 481ed3c57853463b01f7e3928491c7f0679d7776 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 21 Mar 2013 14:41:09 +1300 Subject: [PATCH 036/273] Update lingering configure.in references to say configure.ac --- Doc/Manual/Extending.html | 4 ++-- Examples/php/check.list | 2 +- Makefile.in | 4 ++-- configure.ac | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 059388717..5ea4e51f4 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -3101,7 +3101,7 @@ As you can see, most usages are direct.
    -
    configure.in +
    configure.ac
    This file is processed by

    @@ -3551,7 +3551,7 @@ details being outlined earlier on. a runtime test, see for example Examples/python/class.

  • - Modify configure.in, Makefile.in and Examples/Makefile.in to run + Modify configure.ac, Makefile.in and Examples/Makefile.in to run these examples. Please make sure that if the new language is not installed properly on a box, make -k check should still work by skipping the tests and examples for the new language module. diff --git a/Examples/php/check.list b/Examples/php/check.list index 28c7a619f..fef3feba6 100644 --- a/Examples/php/check.list +++ b/Examples/php/check.list @@ -1,5 +1,5 @@ # see top-level Makefile.in -# (see also top-level configure.in kludge) +# (see also top-level configure.ac kludge) callback class constants diff --git a/Makefile.in b/Makefile.in index c6259916b..7ecbfa251 100644 --- a/Makefile.in +++ b/Makefile.in @@ -514,11 +514,11 @@ configfiles: Makefile: $(srcdir)/Makefile.in config.status $(SHELL) ./config.status -# This target is usually called from Source/Makefile when configure.in has +# This target is usually called from Source/Makefile when configure.ac has # changed. am--refresh: $(srcdir)/configure -$(srcdir)/configure: $(srcdir)/configure.in +$(srcdir)/configure: $(srcdir)/configure.ac @echo "Build system is out of date. If the following commands fail, please reconfigure by hand (rerun: ./autogen.sh && ./configure)" cd $(srcdir) && ./autogen.sh $(SHELL) ./config.status --recheck diff --git a/configure.ac b/configure.ac index 0e8ad5bb1..e205138e7 100644 --- a/configure.ac +++ b/configure.ac @@ -2482,4 +2482,4 @@ AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig]) AC_CONFIG_FILES([CCache/ccache_swig_config.h]) AC_OUTPUT -dnl configure.in ends here +dnl configure.ac ends here From 9fbf771a006b50e58a8ec758bce7af4eacb2770f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 22 Mar 2013 09:21:07 +1300 Subject: [PATCH 037/273] Fix lack of indentation in ocaml and pike sections --- configure.ac | 74 ++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/configure.ac b/configure.ac index e205138e7..77e2b98bf 100644 --- a/configure.ac +++ b/configure.ac @@ -1504,47 +1504,47 @@ AC_ARG_WITH(ocamlmktop,[ --with-ocamlmktop=path Set location of ocamlmktop exe # First, check for "--without-ocaml" or "--with-ocaml=no". if test x"${OCAMLBIN}" = xno -o x"${with_alllang}" = xno ; then -AC_MSG_NOTICE([Disabling OCaml]) -OCAMLBIN= + AC_MSG_NOTICE([Disabling OCaml]) + OCAMLBIN= else -AC_MSG_CHECKING(for Ocaml DL load generator) -if test -z "$OCAMLDLGEN"; then -AC_CHECK_PROGS(OCAMLDLGEN, ocamldlgen, :) -else -OCAMLDLGEN="$OCAMLDLGEN" -fi + AC_MSG_CHECKING(for Ocaml DL load generator) + if test -z "$OCAMLDLGEN"; then + AC_CHECK_PROGS(OCAMLDLGEN, ocamldlgen, :) + else + OCAMLDLGEN="$OCAMLDLGEN" + fi -AC_MSG_CHECKING(for Ocaml package tool) -if test -z "$OCAMLFIND"; then -AC_CHECK_PROGS(OCAMLFIND, ocamlfind, :) -else -OCAMLFIND="$OCAMLFIND" -fi + AC_MSG_CHECKING(for Ocaml package tool) + if test -z "$OCAMLFIND"; then + AC_CHECK_PROGS(OCAMLFIND, ocamlfind, :) + else + OCAMLFIND="$OCAMLFIND" + fi -AC_MSG_CHECKING(for Ocaml compiler) -if test -z "$OCAMLC"; then -AC_CHECK_PROGS(OCAMLC, ocamlc, :) -else -OCAMLC="$OCAMLC" -fi + AC_MSG_CHECKING(for Ocaml compiler) + if test -z "$OCAMLC"; then + AC_CHECK_PROGS(OCAMLC, ocamlc, :) + else + OCAMLC="$OCAMLC" + fi -AC_MSG_CHECKING(for Ocaml interpreter) -if test "x$OCAMLBIN" = xyes; then -AC_CHECK_PROGS(OCAMLBIN, ocaml, :) -else -OCAMLBIN="$OCAMLBIN" -fi + AC_MSG_CHECKING(for Ocaml interpreter) + if test "x$OCAMLBIN" = xyes; then + AC_CHECK_PROGS(OCAMLBIN, ocaml, :) + else + OCAMLBIN="$OCAMLBIN" + fi -AC_MSG_CHECKING(for Ocaml toplevel creator) -if test -z "$OCAMLMKTOP"; then -AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop, :) -else -OCAMLMKTOP="$OCAMLMKTOP" -fi + AC_MSG_CHECKING(for Ocaml toplevel creator) + if test -z "$OCAMLMKTOP"; then + AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop, :) + else + OCAMLMKTOP="$OCAMLMKTOP" + fi -OCAMLLOC=loc -if test "$OCAMLC" != ":" ; then + OCAMLLOC=loc + if test "$OCAMLC" != ":" ; then AC_MSG_CHECKING(for Ocaml header files) dirs="/usr/lib/ocaml/caml /usr/local/lib/ocaml/caml" dir="`$OCAMLC -where 2>/dev/null`" @@ -1567,7 +1567,7 @@ if test "$OCAMLC" != ":" ; then OCAMLVER=`$OCAMLC -version | sed -e 's/.*version //g'` AC_COMPARE_VERSION([$OCAMLVER],[3.08.2],[:],[:],[OCAMLLOC=_loc]) AC_MSG_RESULT($OCAMLVER) -fi + fi fi # Disabling ocaml export OCAMLLOC @@ -1600,8 +1600,8 @@ AS_HELP_STRING([--with-pike=path], [Set location of Pike executable]),[PIKEBIN=" # First, check for "--without-pike" or "--with-pike=no". if test x"${PIKEBIN}" = xno -o x"${with_alllang}" = xno ; then -AC_MSG_NOTICE([Disabling Pike]) -PIKEBIN= + AC_MSG_NOTICE([Disabling Pike]) + PIKEBIN= else if test "x$PIKEBIN" = xyes; then From 2bbc52302c2c18f81e9e2b02f24a63e2097da94a Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 22 Mar 2013 09:37:02 +1300 Subject: [PATCH 038/273] Remove pointless assignments of variables to themselves --- configure.ac | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index 77e2b98bf..d34f4fad7 100644 --- a/configure.ac +++ b/configure.ac @@ -713,8 +713,9 @@ else # Cygwin (Windows) needs the library for dynamic linking case $host in - *-*-cygwin* | *-*-mingw*) PYTHONDYNAMICLINKING="-L$PYLIB $PYLINK" - DEFS="-DUSE_DL_IMPORT $DEFS" PYINCLUDE="$PYINCLUDE" + *-*-cygwin* | *-*-mingw*) + PYTHONDYNAMICLINKING="-L$PYLIB $PYLINK" + DEFS="-DUSE_DL_IMPORT $DEFS" ;; *)PYTHONDYNAMICLINKING="";; esac @@ -808,8 +809,9 @@ else # Cygwin (Windows) needs the library for dynamic linking case $host in - *-*-cygwin* | *-*-mingw*) PYTHON3DYNAMICLINKING="-L$PYLIB $PY3LINK" - DEFS="-DUSE_DL_IMPORT $DEFS" PY3INCLUDE="$PY3INCLUDE" + *-*-cygwin* | *-*-mingw*) + PYTHON3DYNAMICLINKING="-L$PYLIB $PY3LINK" + DEFS="-DUSE_DL_IMPORT $DEFS" ;; *)PYTHON3DYNAMICLINKING="";; esac @@ -1300,7 +1302,7 @@ else AC_MSG_CHECKING(for MzScheme dynext object) MZDYNOBJ=`$MZSCHEME --eval '(begin (require dynext/link) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (printf "~a" x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` if test -f "$MZDYNOBJ"; then - MZDYNOBJ="$MZDYNOBJ" + : else # older versions (3.72 approx and earlier) MZDYNOBJ=`$MZSCHEME --mute-banner --version --eval '(begin (require (lib "link.ss" "dynext")) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) ((current-make-standard-link-libraries)))) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` @@ -1511,36 +1513,26 @@ else AC_MSG_CHECKING(for Ocaml DL load generator) if test -z "$OCAMLDLGEN"; then AC_CHECK_PROGS(OCAMLDLGEN, ocamldlgen, :) - else - OCAMLDLGEN="$OCAMLDLGEN" fi AC_MSG_CHECKING(for Ocaml package tool) if test -z "$OCAMLFIND"; then AC_CHECK_PROGS(OCAMLFIND, ocamlfind, :) - else - OCAMLFIND="$OCAMLFIND" fi AC_MSG_CHECKING(for Ocaml compiler) if test -z "$OCAMLC"; then AC_CHECK_PROGS(OCAMLC, ocamlc, :) - else - OCAMLC="$OCAMLC" fi AC_MSG_CHECKING(for Ocaml interpreter) if test "x$OCAMLBIN" = xyes; then AC_CHECK_PROGS(OCAMLBIN, ocaml, :) - else - OCAMLBIN="$OCAMLBIN" fi AC_MSG_CHECKING(for Ocaml toplevel creator) if test -z "$OCAMLMKTOP"; then AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop, :) - else - OCAMLMKTOP="$OCAMLMKTOP" fi OCAMLLOC=loc From 250760daf498c339d2dd554f417b3390b02503ae Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 22 Mar 2013 10:43:19 +1300 Subject: [PATCH 039/273] Remove superfluous trailing semicolons --- configure.ac | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index d34f4fad7..820cf3691 100644 --- a/configure.ac +++ b/configure.ac @@ -205,7 +205,7 @@ then *-*-next*) if test "$ns_dyld" then LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind' - else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r'; + else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r' fi if test "$with_next_framework" ; then LDSHARED="$LDSHARED \$(LDLIBRARY)" @@ -243,9 +243,9 @@ AC_MSG_CHECKING(TRYLINKINGWITHCXX) if test -z "$TRYLINKINGWITHCXX" then case $host in - *-*-solaris*) if test "$GCC" = yes; - then TRYLINKINGWITHCXX="CXXSHARED= $CXX -Wl,-G"; - else TRYLINKINGWITHCXX="CXXSHARED= $CXX -G -L/opt/SUNWspro/lib -lCrun -lCstd"; + *-*-solaris*) if test "$GCC" = yes + then TRYLINKINGWITHCXX="CXXSHARED= $CXX -Wl,-G" + else TRYLINKINGWITHCXX="CXXSHARED= $CXX -G -L/opt/SUNWspro/lib -lCrun -lCstd" fi;; *-*-hp*) TRYLINKINGWITHCXX="CXXSHARED= $CXX +z ";; *-*-darwin*) TRYLINKINGWITHCXX="CXXSHARED= $CXX -bundle -undefined suppress -flat_namespace";; @@ -270,9 +270,9 @@ AC_MSG_CHECKING(CCSHARED) if test -z "$CCSHARED" then case $host in - *-*-hp*) if test "$GCC" = yes; - then CCSHARED="-fpic"; - else CCSHARED="+z"; + *-*-hp*) if test "$GCC" = yes + then CCSHARED="-fpic" + else CCSHARED="+z" fi;; *-*-linux*) CCSHARED="-fpic";; *-*-freebsd* | *-*-openbsd*) CCSHARED="-fpic";; @@ -320,7 +320,7 @@ AC_MSG_RESULT($LINKFORSHARED) # Optional CFLAGS used to silence/enhance compiler warnings on some platforms. AC_MSG_CHECKING(PLATFLAGS) case $host in - *-*-solaris*) if test "$GCC" = yes; + *-*-solaris*) if test "$GCC" = yes then PLATFLAGS= else PLATFLAGS= # else PLATFLAGS="-errtags=yes" # Need more work as C examples use ld for linking @@ -859,7 +859,7 @@ if test -n "$PERL"; then if test -r $i/perl.h; then AC_MSG_RESULT($i) PERL5EXT="$i" - break; + break fi done if test "$PERL5EXT" = none; then @@ -1356,7 +1356,7 @@ if test -n "$RUBY"; then if test -r $i/ruby.h; then AC_MSG_RESULT($i) RUBYINCLUDE="-I$i" - break; + break fi done if test x"$RUBYARCH" != x""; then @@ -1406,7 +1406,7 @@ if test -n "$RUBY"; then for i in $dirs; do if (test -r $i/$rb_libruby;) then RUBYLIB="$i" - break; + break fi done fi @@ -1548,7 +1548,7 @@ else AC_MSG_RESULT($i) OCAMLEXT="$i" OCAMLINC="-I$OCAMLEXT" - break; + break fi done if test -z "$OCAMLINC"; then @@ -1794,7 +1794,7 @@ if test -z "$CSHARPBIN" ; then # The Mono compiler should emit: Mono C# compiler version a.b.c.d csharp_version_raw=`(mcs --version) 2>/dev/null` csharp_version_searched=`(mcs --version | sed -e "/C#/b" -e "/Mono/b" -e d) 2>/dev/null` # return string if contains 'Mono' or 'C#' - CSHARPCOMPILER=""; + CSHARPCOMPILER="" if test -n "$csharp_version_raw" ; then if test "$csharp_version_raw" = "$csharp_version_searched" ; then CSHARPCOMPILER="mcs" @@ -1951,7 +1951,7 @@ else if test -r $i/lua.h; then AC_MSG_RESULT($i/lua.h) LUAFLAGS="$ISYSTEM$i" - break; + break fi done if test -z "$LUAFLAGS"; then From f85a3b7756650e355374404c07ff8a08bc1fdea2 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 22 Mar 2013 10:46:44 +1300 Subject: [PATCH 040/273] Remove handling for Python <1.5 - we only support >=2.0 now --- configure.ac | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 820cf3691..f57a65fda 100644 --- a/configure.ac +++ b/configure.ac @@ -703,12 +703,7 @@ else AC_MSG_RESULT($PYLIB) fi - # Check for really old versions - if test -r $PYLIB/libPython.a; then - PYLINK="-lModules -lPython -lObjects -lParser" - else - PYLINK="-l$PYVERSION" - fi + PYLINK="-l$PYVERSION" fi # Cygwin (Windows) needs the library for dynamic linking From 5199a9002fbf4e3c8f50372d965bbbcf25c577db Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 22 Mar 2013 11:16:48 +1300 Subject: [PATCH 041/273] Correct comment about sys.lib --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f57a65fda..cfbc09426 100644 --- a/configure.ac +++ b/configure.ac @@ -670,7 +670,7 @@ else AC_MSG_CHECKING(for Python lib dir) PYLIBDIR=`($PYTHON -c "import sys; print sys.lib") 2>/dev/null` if test -z "$PYLIBDIR"; then - # older versions don't have sys.lib so the best we can do is assume lib + # Fedora patch Python to add sys.lib, for other distros we assume "lib". PYLIBDIR="lib" fi AC_MSG_RESULT($PYLIBDIR) From 3abe3517f8bc84147aaf28bf207773fb6d5a8c50 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 21 Mar 2013 19:41:59 +0000 Subject: [PATCH 042/273] Don't test shared_ptr for languages that don't have support for shared_ptr --- Examples/test-suite/director_smartptr.i | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/director_smartptr.i b/Examples/test-suite/director_smartptr.i index 0d78c2775..13eb745b6 100644 --- a/Examples/test-suite/director_smartptr.i +++ b/Examples/test-suite/director_smartptr.i @@ -32,6 +32,12 @@ public: %} +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) +#define SHARED_PTR_WRAPPERS_IMPLEMENTED +#endif + +#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) + %include %include @@ -60,4 +66,7 @@ public: virtual FooBar makeFooBar(); static Foo* get_self(Foo *self_); -}; \ No newline at end of file +}; + +#endif + From 1e00ce6bf963d501d1e056abcd70ae66be5fed94 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 26 Mar 2013 15:07:16 +1300 Subject: [PATCH 043/273] Fix comment typo in typemap --- Examples/test-suite/primitive_types.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i index f912bd77c..9425cc1a0 100644 --- a/Examples/test-suite/primitive_types.i +++ b/Examples/test-suite/primitive_types.i @@ -48,7 +48,7 @@ const double & ($basetype temp) %{ temp = ($basetype)$input; $1 = &temp; %} - the other tipical change is to add the enum SWIGTYPE to the + the other typical change is to add the enum SWIGTYPE to the integer throws typemaps: %typemap(throws) int, From b504b68a62e003f39d6bab810842d6a2b684a51c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 23 Mar 2013 16:52:30 +0000 Subject: [PATCH 044/273] Fix erratically failing threads_exception python test --- Examples/test-suite/python/threads_exception_runme.py | 10 ++++++---- Examples/test-suite/threads_exception.i | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py index 12202e3d3..d4b8855fc 100644 --- a/Examples/test-suite/python/threads_exception_runme.py +++ b/Examples/test-suite/python/threads_exception_runme.py @@ -23,10 +23,12 @@ except RuntimeError,e: try: t.hosed() except threads_exception.Exc,e: - if e.code != 42: - raise RuntimeError - if e.msg != "Hosed": - raise RuntimeError, "bad... msg: %s" % e.msg + code = e.code + if code != 42: + raise RuntimeError, "bad... code: %d" % code + msg = e.msg + if msg != "Hosed": + raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg)) for i in range(1,4): try: diff --git a/Examples/test-suite/threads_exception.i b/Examples/test-suite/threads_exception.i index 9f275bd6a..b374f0ce6 100644 --- a/Examples/test-suite/threads_exception.i +++ b/Examples/test-suite/threads_exception.i @@ -20,6 +20,7 @@ public: Exc(int c, const char *m) { code = c; strncpy(msg,m,255); + msg[255] = 0; } int code; char msg[256]; From 7eda619741a31ed73df512085f7256694173e877 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 25 Mar 2013 19:03:39 +0000 Subject: [PATCH 045/273] Fix invalid iterators used with -ve ranges - Python Fixes li_std_containers_int testcase. Valgrind reports no more problems for this testcase. --- Lib/python/pycontainer.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index eb089e98e..81909ae02 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -398,7 +398,7 @@ namespace swig { typename Sequence::reverse_iterator it = sb; size_t delcount = (ii - jj - step - 1) / -step; while (delcount) { - self->erase((++it).base()); + it = typename Sequence::reverse_iterator(self->erase((++it).base())); if (it==self->rend()) break; for (Py_ssize_t c=0; c<(-step-1); ++c) From 38b2b95c30662e81518bd8321bbbbed1ab7dd300 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 25 Mar 2013 19:26:12 +0000 Subject: [PATCH 046/273] Fix some invalid iterator usage in Python when deleting/inserting slices from/into containers --- Lib/python/pycontainer.swg | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 81909ae02..d4386622e 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -339,7 +339,7 @@ namespace swig { std::advance(it,ii); for (size_t rc=0; rcend(); ++c) it++; } } @@ -357,7 +357,7 @@ namespace swig { std::advance(it,size-ii-1); for (size_t rc=0; rcrend(); ++c) it++; } } @@ -383,9 +383,7 @@ namespace swig { size_t delcount = (jj - ii + step - 1) / step; while (delcount) { it = self->erase(it); - if (it==self->end()) - break; - for (Py_ssize_t c=0; c<(step-1); ++c) + for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c) it++; delcount--; } @@ -399,9 +397,7 @@ namespace swig { size_t delcount = (ii - jj - step - 1) / -step; while (delcount) { it = typename Sequence::reverse_iterator(self->erase((++it).base())); - if (it==self->rend()) - break; - for (Py_ssize_t c=0; c<(-step-1); ++c) + for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c) it++; delcount--; } From 2e0d1b12dc4fe5cf12239a59c5d96bdbd352d085 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 29 Mar 2013 06:28:15 +0000 Subject: [PATCH 047/273] Fix delete_if (reject!) for the STL container wrappers. Previously they would sometimes seg fault or not work. --- CHANGES.current | 4 +++ Examples/test-suite/ruby/li_std_set_runme.rb | 4 +++ .../test-suite/ruby/li_std_vector_runme.rb | 5 +++ Lib/ruby/rubycontainer.swg | 35 ++++++++----------- Lib/ruby/std_set.i | 19 ++++++++++ 5 files changed, 46 insertions(+), 21 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6547a88be..bbf97a67f 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.10 (in progress) ============================ +2013-03-29: wsfulton + [Ruby] Fix delete_if (reject!) for the STL container wrappers which previously would + sometimes seg fault or not work. + 2013-03-19: wsfulton [C#, Java, D] Fix seg fault in SWIG using directors when class and virtual method names are the same except being in different namespaces when the %nspace feature is not being used. diff --git a/Examples/test-suite/ruby/li_std_set_runme.rb b/Examples/test-suite/ruby/li_std_set_runme.rb index 65354be58..a85418471 100755 --- a/Examples/test-suite/ruby/li_std_set_runme.rb +++ b/Examples/test-suite/ruby/li_std_set_runme.rb @@ -61,3 +61,7 @@ s.to_a == [1,[1,2],'hello'] # sort order: s.sort {|a,b| a.hash <=> b.hash} EOF +iv = Set_int.new([0,1,2,3,4,5,6]) +iv.delete_if { |x| x == 0 || x == 3 || x == 6 } +swig_assert_equal(iv.to_s, '1245', binding) + diff --git a/Examples/test-suite/ruby/li_std_vector_runme.rb b/Examples/test-suite/ruby/li_std_vector_runme.rb index 8bcad2d19..fe3d9e0ce 100755 --- a/Examples/test-suite/ruby/li_std_vector_runme.rb +++ b/Examples/test-suite/ruby/li_std_vector_runme.rb @@ -64,6 +64,11 @@ y = average([1, 2, 3, 4]) half([10, 10.5, 11, 11.5]) EOF +iv = IntVector.new([0,1,2,3,4,5,6]) +iv.delete_if { |x| x == 0 || x == 3 || x == 6 } +swig_assert_equal(iv.to_s, '1245', binding) + + dv = DoubleVector.new(10) swig_assert( "dv.respond_to? :each_with_index", binding ) diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index d8d15f690..d4eaa5f73 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -677,27 +677,6 @@ namespace swig return r; } - %alias reject_bang "delete_if"; - Sequence* reject_bang() { - if ( !rb_block_given_p() ) - rb_raise( rb_eArgError, "no block given" ); - - Sequence::iterator i = self->begin(); - Sequence::iterator e = self->end(); - for ( ; i != e; ) - { - VALUE r = swig::from< Sequence::value_type >(*i); - if ( RTEST( rb_yield(r) ) ) { - $self->erase(i++); - e = self->end(); - } else { - ++i; - } - } - - return self; - } - VALUE delete_at(difference_type i) { VALUE r = Qnil; try { @@ -757,6 +736,19 @@ namespace swig } %enddef +%define %swig_sequence_methods_extra(Sequence...) + %extend { + %alias reject_bang "delete_if"; + Sequence* reject_bang() { + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "no block given" ); + + $self->erase( std::remove_if( $self->begin(), $self->end(), + swig::yield< Sequence::value_type >() ), $self->end() ); + return $self; + } + } +%enddef /** * Macro used to add functions for Sequences @@ -764,6 +756,7 @@ namespace swig */ %define %swig_sequence_methods(Sequence...) %swig_sequence_methods_common(%arg(Sequence)); + %swig_sequence_methods_extra(%arg(Sequence)); %swig_sequence_back_inserters(%arg(Sequence)); %extend { diff --git a/Lib/ruby/std_set.i b/Lib/ruby/std_set.i index 00596b4a6..e38702ef5 100644 --- a/Lib/ruby/std_set.i +++ b/Lib/ruby/std_set.i @@ -152,10 +152,29 @@ } %} +%define %swig_sequence_methods_extra_set(Sequence...) + %extend { + %alias reject_bang "delete_if"; + Sequence* reject_bang() { + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "no block given" ); + + for ( Sequence::iterator i = $self->begin(); i != $self->end(); ) { + VALUE r = swig::from< Sequence::value_type >(*i); + Sequence::iterator current = i++; + if ( RTEST( rb_yield(r) ) ) + $self->erase(current); + } + + return self; + } + } +%enddef %define %swig_set_methods(set...) %swig_sequence_methods_common(%arg(set)); + %swig_sequence_methods_extra_set(%arg(set)); %fragment("RubyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="RubySequence_Cont") {} From 8381cc6b7db33669103bb4aa222884dcfdb6a266 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 27 Mar 2013 11:14:48 +0000 Subject: [PATCH 048/273] Fix test suite lock initialisation leading to random seg faults in li_boost_shared_ptr --- Examples/test-suite/swig_examples_lock.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/swig_examples_lock.h b/Examples/test-suite/swig_examples_lock.h index feef26d0f..49d1bf285 100644 --- a/Examples/test-suite/swig_examples_lock.h +++ b/Examples/test-suite/swig_examples_lock.h @@ -43,6 +43,7 @@ class CriticalSection { public: CriticalSection() { pthread_mutexattr_t mutexattr; + pthread_mutexattr_init(&mutexattr); pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE_NP); pthread_mutex_init(&mutex_, &mutexattr); pthread_mutexattr_destroy(&mutexattr); From 5878ca5f1a93a26231c5f931047ac785c0c32052 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 29 Mar 2013 09:15:39 +0000 Subject: [PATCH 049/273] Fix autodoc test for python 2.4 --- Examples/test-suite/python/autodoc_runme.py | 35 ++++++++++--------- Examples/test-suite/python/file_test_runme.py | 2 +- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index dc843ae96..634b2dccf 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -1,4 +1,5 @@ from autodoc import * +import sys def check(got, expected): if expected != got: @@ -121,22 +122,24 @@ check(A.func3static.__doc__, "\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" -) +if sys.version[0:2] > (2, 4): + # Python 2.4 does not seem to work + 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") diff --git a/Examples/test-suite/python/file_test_runme.py b/Examples/test-suite/python/file_test_runme.py index de4e2669e..3d8b153db 100644 --- a/Examples/test-suite/python/file_test_runme.py +++ b/Examples/test-suite/python/file_test_runme.py @@ -1,7 +1,7 @@ import sys import file_test -if sys.version_info < (3,0): +if sys.version[0:2] > (3, 0): file_test.nfile(sys.stdout) cstdout = file_test.GetStdOut() From f42ac989a7c608d9bc68c409a5b0db018bfef135 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 29 Mar 2013 09:19:03 +0000 Subject: [PATCH 050/273] Add note about Python STL fixes --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index bbf97a67f..db7a0612f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -9,6 +9,9 @@ Version 2.0.10 (in progress) [Ruby] Fix delete_if (reject!) for the STL container wrappers which previously would sometimes seg fault or not work. +2013-03-25: wsfulton + [Python] Fix some undefined behaviour deleting slices in the STL containers. + 2013-03-19: wsfulton [C#, Java, D] Fix seg fault in SWIG using directors when class and virtual method names are the same except being in different namespaces when the %nspace feature is not being used. From af859a1e2da4a317b7ad3a706825f6c6a6ae1c97 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 29 Mar 2013 13:46:49 +0000 Subject: [PATCH 051/273] Fix Ruby documentation for %bang --- Doc/Manual/Ruby.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 47cf4f303..9739e1109 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -3215,7 +3215,7 @@ directive which is unique to the Ruby module and was introduced in SWIG
    -
    %bang sort!(arr);

    int sort(int arr[]);
    +
    %bang sort(int arr[]);

    int sort(int arr[]);
    From 8801ea3f11fd02a953584eae024d1e5385a5a530 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 31 Mar 2013 00:21:12 +0000 Subject: [PATCH 052/273] Fix incorrect assumptions in Ruby li_std_set test --- Examples/test-suite/ruby/li_std_set_runme.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/ruby/li_std_set_runme.rb b/Examples/test-suite/ruby/li_std_set_runme.rb index a85418471..efc163bee 100755 --- a/Examples/test-suite/ruby/li_std_set_runme.rb +++ b/Examples/test-suite/ruby/li_std_set_runme.rb @@ -57,7 +57,10 @@ s = LanguageSet.new s.insert([1,2]) s.insert(1) s.insert("hello") -s.to_a == [1,[1,2],'hello'] # sort order: s.sort {|a,b| a.hash <=> b.hash} +#s.to_a == [1,[1,2],'hello'] # sort order: s.sort {|a,b| a.hash <=> b.hash} +# Test above is flawed as LanguageSet sorts by each element's hash, so the order will change from one invocation to the next. Sort a conversion to array instead. +sa = s.to_a.sort { |x, y| x.to_s <=> y.to_s } +sa == [1,[1,2],'hello'] EOF From e13e1cba9e6dd024f713821558ae084cc9dc3507 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 31 Mar 2013 00:55:34 +0000 Subject: [PATCH 053/273] Fix seg fault when using STL containers of generic Ruby types, GC_VALUE or LANGUAGE_OBJECT, on exit of the Ruby interpreter. Observed on 64 bit Linux in the std_li_set testcase. The global hash which is meant to hold GC references was being deleted by the interpreter on exit before the GC_VALUES destructors were being called. --- CHANGES.current | 4 ++ Lib/ruby/rubyclasses.swg | 115 +++++++++++++++++++++------------------ 2 files changed, 67 insertions(+), 52 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index db7a0612f..6e3d6fb08 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.10 (in progress) ============================ +2013-03-30: wsfulton + [Ruby] Fix seg fault when using STL containers of generic Ruby types, GC_VALUE or LANGUAGE_OBJECT, + on exit of the Ruby interpreter. More frequently observed in ruby-1.9. + 2013-03-29: wsfulton [Ruby] Fix delete_if (reject!) for the STL container wrappers which previously would sometimes seg fault or not work. diff --git a/Lib/ruby/rubyclasses.swg b/Lib/ruby/rubyclasses.swg index 2048b1f5f..60411a2de 100644 --- a/Lib/ruby/rubyclasses.swg +++ b/Lib/ruby/rubyclasses.swg @@ -36,11 +36,64 @@ %fragment("GC_VALUE_definition","header") { namespace swig { + class SwigGCReferences { + // Hash of all GC_VALUE's currently in use + static SwigGCReferences s_references; + + VALUE _hash; + + SwigGCReferences() : _hash(Qnil) { + } + ~SwigGCReferences() { + if (_hash != Qnil) + rb_gc_unregister_address( &_hash ); + } + static void EndProcHandler(VALUE) { + // Ruby interpreter ending - _hash can no longer be accessed. + s_references._hash = Qnil; + } + public: + static SwigGCReferences& instance() { + return s_references; + } + static void initialize() { + if (s_references._hash == Qnil) { + rb_set_end_proc(&EndProcHandler, Qnil); + s_references._hash = rb_hash_new(); + rb_gc_register_address( &s_references._hash ); + } + } + void GC_register(VALUE& obj) { + if (FIXNUM_P(obj) || SPECIAL_CONST_P(obj) || SYMBOL_P(obj)) + return; + if (_hash != Qnil) { + VALUE val = rb_hash_aref(_hash, obj); + unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 0; + ++n; + rb_hash_aset(_hash, obj, INT2NUM(n)); + } + } + void GC_unregister(const VALUE& obj) { + if (FIXNUM_P(obj) || SPECIAL_CONST_P(obj) || SYMBOL_P(obj)) + return; + // this test should not be needed but I've noticed some very erratic + // behavior of none being unregistered in some very rare situations. + if (BUILTIN_TYPE(obj) == T_NONE) + return; + if (_hash != Qnil) { + VALUE val = rb_hash_aref(s_references._hash, obj); + unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 1; + --n; + if (n) + rb_hash_aset(s_references._hash, obj, INT2NUM(n)); + else + rb_hash_delete(s_references._hash, obj); + } + } + }; + class GC_VALUE { protected: - // Hash of all GC_VALUE's currently in use - static VALUE _hash; - VALUE _obj; static ID hash_id; @@ -77,75 +130,33 @@ namespace swig { public: - static void initialize() - { - if ( _hash == Qnil ) - { - _hash = rb_hash_new(); - rb_gc_register_address( &_hash ); - } - } - - // this function is never called. Provided for symmetry only. - static void cleanup() - { - rb_gc_unregister_address( &_hash ); - } - GC_VALUE() : _obj( Qnil ) { } GC_VALUE(const GC_VALUE& item) : _obj(item._obj) { - GC_register(); + SwigGCReferences::instance().GC_register(_obj); } GC_VALUE(VALUE obj) :_obj(obj) { - GC_register(); + SwigGCReferences::instance().GC_register(_obj); } ~GC_VALUE() { - GC_unregister(); + SwigGCReferences::instance().GC_unregister(_obj); } GC_VALUE & operator=(const GC_VALUE& item) { - GC_unregister(); + SwigGCReferences::instance().GC_unregister(_obj); _obj = item._obj; - GC_register(); + SwigGCReferences::instance().GC_register(_obj); return *this; } - void GC_register() - { - if ( FIXNUM_P(_obj) || SPECIAL_CONST_P(_obj) || SYMBOL_P(_obj) ) - return; - VALUE val = rb_hash_aref( _hash, _obj ); - unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 0; - ++n; - rb_hash_aset( _hash, _obj, INT2NUM(n) ); - } - - void GC_unregister() - { - if ( FIXNUM_P(_obj) || SPECIAL_CONST_P(_obj) || SYMBOL_P(_obj) ) - return; - // this test should not be needed but I've noticed some very erratic - // behavior of none being unregistered in some very rare situations. - if ( BUILTIN_TYPE(_obj) == T_NONE ) return; - - VALUE val = rb_hash_aref( _hash, _obj ); - unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 1; - --n; - if ( n ) - rb_hash_aset( _hash, _obj, INT2NUM(n) ); - else - rb_hash_delete( _hash, _obj ); - } - operator VALUE() const { return _obj; @@ -294,7 +305,7 @@ namespace swig { ID GC_VALUE::lshift_id = rb_intern("<<"); ID GC_VALUE::rshift_id = rb_intern(">>"); - VALUE GC_VALUE::_hash = Qnil; + SwigGCReferences SwigGCReferences::s_references; typedef GC_VALUE LANGUAGE_OBJ; @@ -350,7 +361,7 @@ namespace swig { %init { - swig::GC_VALUE::initialize(); + swig::SwigGCReferences::initialize(); } From 9aaf4ad03cc31eb976d8bd16301286f0ac83ff4c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Apr 2013 20:14:51 +0100 Subject: [PATCH 054/273] Fixes for Ruby 1.9 std::complex wrappers. New native Ruby complex numbers are used. --- CHANGES.current | 3 ++ Lib/ruby/rubycomplex.swg | 92 +++++++++++++++++++++++----------------- 2 files changed, 56 insertions(+), 39 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6e3d6fb08..ac26525da 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.10 (in progress) ============================ +2013-04-02: wsfulton + [Ruby] Runtime fixes for std::complex wrappers for ruby-1.9 - new native Ruby complex numbers are used. + 2013-03-30: wsfulton [Ruby] Fix seg fault when using STL containers of generic Ruby types, GC_VALUE or LANGUAGE_OBJECT, on exit of the Ruby interpreter. More frequently observed in ruby-1.9. diff --git a/Lib/ruby/rubycomplex.swg b/Lib/ruby/rubycomplex.swg index afdb15e7e..8a7486865 100644 --- a/Lib/ruby/rubycomplex.swg +++ b/Lib/ruby/rubycomplex.swg @@ -1,49 +1,61 @@ /* Defines the As/From conversors for double/float complex, you need to - provide complex Type, the Name you want to use in the conversors, + provide complex Type, the Name you want to use in the converters, the complex Constructor method, and the Real and Imag complex - accesor methods. + accessor methods. See the std_complex.i and ccomplex.i for concrete examples. */ -/* - Ruby does not have native complex numbers. They are an extension in the - STD library. -*/ -%{ - static VALUE swig_rb_cComplex = Qnil; - static ID swig_real_id = 0; - static ID swig_imag_id = 0; - - int Ruby_Is_Complex( VALUE obj ) - { - return ( (rb_respond_to( obj, swig_real_id ) == Qtrue) && - (rb_respond_to( obj, swig_imag_id ) == Qtrue) ); - } -%} - -%init { - rb_require("complex"); - swig_rb_cComplex = rb_const_get( rb_cObject, rb_intern("Complex") ); - if( swig_rb_cComplex == Qnil ) - rb_warn("Ruby's complex.so not found"); - swig_real_id = rb_intern("real"); - swig_imag_id = rb_intern("imag"); +%fragment("SWIG_Complex_Numbers","header") +{ +%#if !defined(T_COMPLEX) +/* Ruby versions prior to 1.9 did not have native complex numbers. They were an extension in the STD library. */ +VALUE rb_complex_new(VALUE x, VALUE y) { + static ID new_id = rb_intern("new"); + static VALUE cComplex = rb_const_get(rb_cObject, rb_intern("Complex")); + return rb_funcall(cComplex, new_id, 2, x, y); } -/* the common from conversor */ +static int SWIG_Is_Complex( VALUE obj ) { + static ID real_id = rb_intern("real"); + static ID imag_id = rb_intern("imag"); + return ( (rb_respond_to( obj, real_id ) == Qtrue) && + (rb_respond_to( obj, imag_id ) == Qtrue) ); +} +%#else +static int SWIG_Is_Complex( VALUE obj ) { + return TYPE(obj) == T_COMPLEX; +} +%#endif + +VALUE SWIG_Complex_Real(VALUE obj) { + static ID real_id = rb_intern("real"); + return rb_funcall(obj, real_id, 0); +} + +VALUE SWIG_Complex_Imaginary(VALUE obj) { + static ID imag_id = rb_intern("imag"); + return rb_funcall(obj, imag_id, 0); +} +} + +%init { +%#if !defined(T_COMPLEX) + rb_require("complex"); +%#endif +} + +/* the common from converter */ %define %swig_fromcplx_conv(Type, Real, Imag) %fragment(SWIG_From_frag(Type),"header") { SWIGINTERNINLINE VALUE SWIG_From(Type)(%ifcplusplus(const Type&, Type) c) { - VALUE args[] = { - rb_float_new(Real(c)), - rb_float_new(Imag(c)) - }; - return rb_class_new_instance(2, args, swig_rb_cComplex); + VALUE re = rb_float_new(Real(c)); + VALUE im = rb_float_new(Imag(c)); + return rb_complex_new(re, im); } } %enddef @@ -51,15 +63,16 @@ SWIG_From(Type)(%ifcplusplus(const Type&, Type) c) /* the double case */ %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", - fragment=SWIG_AsVal_frag(double)) + fragment=SWIG_AsVal_frag(double), + fragment="SWIG_Complex_Numbers") { SWIGINTERN int SWIG_AsVal(Type) (VALUE o, Type* val) { - if ( Ruby_Is_Complex( o ) ) { + if ( SWIG_Is_Complex( o ) ) { if (val) { - VALUE real = rb_funcall(o, swig_real_id, 0 ); - VALUE imag = rb_funcall(o, swig_imag_id, 0 ); + VALUE real = SWIG_Complex_Real(o); + VALUE imag = SWIG_Complex_Imaginary(o); double re = 0; SWIG_AsVal_double( real, &re ); double im = 0; @@ -85,13 +98,14 @@ SWIG_AsVal(Type) (VALUE o, Type* val) %define %swig_cplxflt_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float), - fragment=SWIG_AsVal_frag(double)) { + fragment=SWIG_AsVal_frag(double), + fragment="SWIG_Complex_Numbers") { SWIGINTERN int SWIG_AsVal(Type)(VALUE o, Type *val) { - if ( Ruby_Is_Complex( o ) ) { - VALUE real = rb_funcall(o, swig_real_id, 0 ); - VALUE imag = rb_funcall(o, swig_imag_id, 0 ); + if ( SWIG_Is_Complex( o ) ) { + VALUE real = SWIG_Complex_Real(o); + VALUE imag = SWIG_Complex_Imaginary(o); double re = 0; SWIG_AsVal_double( real, &re ); double im = 0; From ee92a26819b8bb811d4fe00b80a02bdc4aa4cf70 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Apr 2013 22:21:48 +0100 Subject: [PATCH 055/273] Fixes for out of source builds for Ruby test-suite --- Examples/test-suite/ruby/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 3354acfd8..ab366ccd4 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -61,7 +61,7 @@ ruby_naming.cpptest: SWIGOPT += -autorename # a file is found which has _runme.rb appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) -I. $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) -I$(srcdir):. $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean From 5d529d5a76a9d3f71e39dad2f8373559bdebd829 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Apr 2013 23:41:59 +0100 Subject: [PATCH 056/273] Ruby 1.9 fixes. SF Bug#1292 - Runtime fixes for Proc changes in ruby-1.9 when using STL wrappers that override the default predicate, such as: %template(Map) std::map >; Fixes li_std_functors testcases for Ruby 1.9. Also rb_respond_to return values have changed subtely in 1.9 and return should be treated as a flag instead of checking for Qtrue, see SF Bug #1159. Also fix li_std_map, li_std_set silently failing - rb_protect behaviour seems to have changed when an exception is thrown, so code has been changed to use rb_rescue. A call to 'rb_set_errinfo(Qnil)' could have solved this after the rb_protect call, but it is only available in 1.9+ and Ruby API changes are not easily and transparently detectable. --- CHANGES.current | 10 ++++++++++ .../test-suite/ruby/li_std_functors_runme.rb | 8 +++++++- Lib/ruby/rubyclasses.swg | 17 +++++++++++++---- Lib/ruby/rubycomplex.swg | 4 ++-- Lib/ruby/rubyrun.swg | 4 ++-- 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ac26525da..9253f9c96 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,16 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.10 (in progress) ============================ +2013-04-05: wsfulton + [Ruby] SF Bug #1292 - Runtime fixes for Proc changes in ruby-1.9 when using STL + wrappers that override the default predicate, such as: + + %template(Map) std::map >; + +2013-04-05: wsfulton + [Ruby] SF Bug #1159 - Correctly check rb_respond_to call return values to fix some + further 1.9 problems with functors and use of Complex wrappers. + 2013-04-02: wsfulton [Ruby] Runtime fixes for std::complex wrappers for ruby-1.9 - new native Ruby complex numbers are used. diff --git a/Examples/test-suite/ruby/li_std_functors_runme.rb b/Examples/test-suite/ruby/li_std_functors_runme.rb index d31735c45..5623d49f0 100755 --- a/Examples/test-suite/ruby/li_std_functors_runme.rb +++ b/Examples/test-suite/ruby/li_std_functors_runme.rb @@ -34,6 +34,12 @@ def _set(container) EOF end +def b_lessthan_a(b, a) + res = b < a +# print b, "<", a, "=", res + return res +end + def _map(container) swig_assert_each_line(< Date: Sat, 6 Apr 2013 00:30:50 +0100 Subject: [PATCH 057/273] More rb_protect rewrite to use rb_rescue for Ruby 1.9 --- Lib/ruby/rubyclasses.swg | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/Lib/ruby/rubyclasses.swg b/Lib/ruby/rubyclasses.swg index 5db6658ee..3b36c722e 100644 --- a/Lib/ruby/rubyclasses.swg +++ b/Lib/ruby/rubyclasses.swg @@ -172,17 +172,14 @@ namespace swig { return rb_inspect(_obj); } - static VALUE swig_rescue_funcall( VALUE ) + static VALUE swig_rescue_swallow( VALUE ) { -/* - VALUE err = rb_errinfo(); - VALUE errstr = rb_obj_as_string(err); - std::cout << "Error is: '" << RSTRING_PTR(StringValue(errstr)) << "'" << std::endl; -*/ - return Qnil;/* Swallow Ruby exception */ + // VALUE errstr = rb_obj_as_string(rb_errinfo()); + // printf("Swallowing error: '%s'\n", RSTRING_PTR(StringValue(errstr))); + return Qnil; /* Swallow Ruby exception */ } - static VALUE swig_protect_funcall( VALUE p ) + static VALUE swig_rescue_funcall( VALUE p ) { OpArgs* args = (OpArgs*) p; return rb_funcall( args->src, args->id, args->nargs, args->target ); @@ -206,8 +203,8 @@ namespace swig { args.id = op_id; \ args.nargs = 1; \ args.target = VALUE(other); \ - ret = rb_rescue(RUBY_METHOD_FUNC(swig_protect_funcall), VALUE(&args), \ - (RUBY_METHOD_FUNC(swig_rescue_funcall)), Qnil); \ + ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), \ + (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); \ } \ if ( ret == Qnil ) { \ VALUE a = rb_funcall( _obj, hash_id, 0 ); \ @@ -240,14 +237,13 @@ namespace swig { { \ VALUE ret = Qnil; \ SWIG_RUBY_THREAD_BEGIN_BLOCK; \ - int status; \ OpArgs args; \ args.src = _obj; \ args.id = proc_id; \ args.nargs = 0; \ args.target = Qnil; \ - ret = rb_protect( PROTECTFUNC(swig_protect_funcall), VALUE(&args), \ - &status ); \ + ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), \ + (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); \ SWIG_RUBY_THREAD_END_BLOCK; \ return ret; \ } @@ -262,14 +258,13 @@ namespace swig { { \ VALUE ret = Qnil; \ SWIG_RUBY_THREAD_BEGIN_BLOCK; \ - int status; \ OpArgs args; \ args.src = _obj; \ args.id = proc_id; \ args.nargs = 1; \ args.target = VALUE(other); \ - ret = rb_protect( PROTECTFUNC(swig_protect_funcall), VALUE(&args), \ - &status ); \ + ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), \ + (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); \ SWIG_RUBY_THREAD_END_BLOCK; \ return GC_VALUE(ret); \ } From bb3fe8c906997d39570ab1c7bbde78a5236b229f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Apr 2013 02:20:56 +0100 Subject: [PATCH 058/273] Rewrite Ruby's GC_VALUE without use of macros for easier debugging --- Lib/ruby/rubyclasses.swg | 183 +++++++++++++++++++-------------------- 1 file changed, 87 insertions(+), 96 deletions(-) diff --git a/Lib/ruby/rubyclasses.swg b/Lib/ruby/rubyclasses.swg index 3b36c722e..598bc4db9 100644 --- a/Lib/ruby/rubyclasses.swg +++ b/Lib/ruby/rubyclasses.swg @@ -46,7 +46,7 @@ namespace swig { } ~SwigGCReferences() { if (_hash != Qnil) - rb_gc_unregister_address( &_hash ); + rb_gc_unregister_address(&_hash); } static void EndProcHandler(VALUE) { // Ruby interpreter ending - _hash can no longer be accessed. @@ -60,12 +60,12 @@ namespace swig { if (s_references._hash == Qnil) { rb_set_end_proc(&EndProcHandler, Qnil); s_references._hash = rb_hash_new(); - rb_gc_register_address( &s_references._hash ); + rb_gc_register_address(&s_references._hash); } } void GC_register(VALUE& obj) { if (FIXNUM_P(obj) || SPECIAL_CONST_P(obj) || SYMBOL_P(obj)) - return; + return; if (_hash != Qnil) { VALUE val = rb_hash_aref(_hash, obj); unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 0; @@ -75,7 +75,7 @@ namespace swig { } void GC_unregister(const VALUE& obj) { if (FIXNUM_P(obj) || SPECIAL_CONST_P(obj) || SYMBOL_P(obj)) - return; + return; // this test should not be needed but I've noticed some very erratic // behavior of none being unregistered in some very rare situations. if (BUILTIN_TYPE(obj) == T_NONE) @@ -85,9 +85,9 @@ namespace swig { unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 1; --n; if (n) - rb_hash_aset(s_references._hash, obj, INT2NUM(n)); + rb_hash_aset(s_references._hash, obj, INT2NUM(n)); else - rb_hash_delete(s_references._hash, obj); + rb_hash_delete(s_references._hash, obj); } } }; @@ -130,7 +130,7 @@ namespace swig { public: - GC_VALUE() : _obj( Qnil ) + GC_VALUE() : _obj(Qnil) { } @@ -172,117 +172,108 @@ namespace swig { return rb_inspect(_obj); } - static VALUE swig_rescue_swallow( VALUE ) + static VALUE swig_rescue_swallow(VALUE) { // VALUE errstr = rb_obj_as_string(rb_errinfo()); // printf("Swallowing error: '%s'\n", RSTRING_PTR(StringValue(errstr))); return Qnil; /* Swallow Ruby exception */ } - static VALUE swig_rescue_funcall( VALUE p ) + static VALUE swig_rescue_funcall(VALUE p) { OpArgs* args = (OpArgs*) p; - return rb_funcall( args->src, args->id, args->nargs, args->target ); + return rb_funcall(args->src, args->id, args->nargs, args->target); } - -%#define GC_VALUE_CMP( op_id, op, cmp, cmpval ) \ - bool op( const GC_VALUE& other ) const \ - { \ - if ( FIXNUM_P(_obj) && FIXNUM_P(other._obj) ) \ - { \ - return _obj cmp other._obj; \ - } \ - bool res = false; \ - VALUE ret = Qnil; \ - SWIG_RUBY_THREAD_BEGIN_BLOCK; \ - if ( rb_respond_to( _obj, op_id ) ) \ - { \ - OpArgs args; \ - args.src = _obj; \ - args.id = op_id; \ - args.nargs = 1; \ - args.target = VALUE(other); \ - ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), \ - (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); \ - } \ - if ( ret == Qnil ) { \ - VALUE a = rb_funcall( _obj, hash_id, 0 ); \ - VALUE b = rb_funcall( VALUE(other), hash_id, 0 ); \ - res = a cmp b; \ - } \ - else \ - { \ - res = RTEST( ret ); \ - } \ - SWIG_RUBY_THREAD_END_BLOCK; \ - return res; \ + bool relational_equal_op(const GC_VALUE& other, const ID& op_id, bool (*op_func)(const VALUE& a, const VALUE& b)) const + { + if (FIXNUM_P(_obj) && FIXNUM_P(other._obj)) { + return op_func(_obj, other._obj); + } + bool res = false; + VALUE ret = Qnil; + SWIG_RUBY_THREAD_BEGIN_BLOCK; + if (rb_respond_to(_obj, op_id)) { + OpArgs args; + args.src = _obj; + args.id = op_id; + args.nargs = 1; + args.target = VALUE(other); + ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), + (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); + } + if (ret == Qnil) { + VALUE a = rb_funcall( _obj, hash_id, 0 ); + VALUE b = rb_funcall( VALUE(other), hash_id, 0 ); + res = op_func(a, b); + } else { + res = RTEST(ret); + } + SWIG_RUBY_THREAD_END_BLOCK; + return res; } + static bool operator_eq(const VALUE& a, const VALUE& b) { return a == b; } + static bool operator_lt(const VALUE& a, const VALUE& b) { return a < b; } + static bool operator_le(const VALUE& a, const VALUE& b) { return a <= b; } + static bool operator_gt(const VALUE& a, const VALUE& b) { return a > b; } + static bool operator_ge(const VALUE& a, const VALUE& b) { return a >= b; } - GC_VALUE_CMP( eq_id, operator==, ==, == 0 ) - GC_VALUE_CMP( lt_id, operator<, < , < 0 ) - GC_VALUE_CMP( le_id, operator<=, <=, <= 0 ) - GC_VALUE_CMP( gt_id, operator>, > , > 0 ) - GC_VALUE_CMP( ge_id, operator>=, >=, >= 0 ) -%#undef GC_VALUE_CMP + bool operator==(const GC_VALUE& other) const { return relational_equal_op(other, eq_id, operator_eq); } + bool operator<(const GC_VALUE& other) const { return relational_equal_op(other, lt_id, operator_lt); } + bool operator<=(const GC_VALUE& other) const { return relational_equal_op(other, le_id, operator_le); } + bool operator>(const GC_VALUE& other) const { return relational_equal_op(other, gt_id, operator_gt); } + bool operator>=(const GC_VALUE& other) const { return relational_equal_op(other, ge_id, operator_ge); } - bool operator!=( const GC_VALUE& other ) + bool operator!=(const GC_VALUE& other) const { return !(this->operator==(other)); } -%#define GC_VALUE_UNARY( proc_id, op ) \ - GC_VALUE op() const \ - { \ - VALUE ret = Qnil; \ - SWIG_RUBY_THREAD_BEGIN_BLOCK; \ - OpArgs args; \ - args.src = _obj; \ - args.id = proc_id; \ - args.nargs = 0; \ - args.target = Qnil; \ - ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), \ - (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); \ - SWIG_RUBY_THREAD_END_BLOCK; \ - return ret; \ + GC_VALUE unary_op(const ID& op_id) const + { + VALUE ret = Qnil; + SWIG_RUBY_THREAD_BEGIN_BLOCK; + OpArgs args; + args.src = _obj; + args.id = op_id; + args.nargs = 0; + args.target = Qnil; + ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), + (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); + SWIG_RUBY_THREAD_END_BLOCK; + return ret; } - GC_VALUE_UNARY( pos_id, operator+ ) - GC_VALUE_UNARY( neg_id, operator- ) - GC_VALUE_UNARY( inv_id, operator~ ) -%#undef GC_VALUE_BINARY + GC_VALUE operator+() const { return unary_op(pos_id); } + GC_VALUE operator-() const { return unary_op(neg_id); } + GC_VALUE operator~() const { return unary_op(inv_id); } -%#define GC_VALUE_BINARY( proc_id, op ) \ - GC_VALUE op( const GC_VALUE& other ) const \ - { \ - VALUE ret = Qnil; \ - SWIG_RUBY_THREAD_BEGIN_BLOCK; \ - OpArgs args; \ - args.src = _obj; \ - args.id = proc_id; \ - args.nargs = 1; \ - args.target = VALUE(other); \ - ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), \ - (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); \ - SWIG_RUBY_THREAD_END_BLOCK; \ - return GC_VALUE(ret); \ + GC_VALUE binary_op(const GC_VALUE& other, const ID& op_id) const + { + VALUE ret = Qnil; + SWIG_RUBY_THREAD_BEGIN_BLOCK; + OpArgs args; + args.src = _obj; + args.id = op_id; + args.nargs = 1; + args.target = VALUE(other); + ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), + (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); + SWIG_RUBY_THREAD_END_BLOCK; + return GC_VALUE(ret); } - GC_VALUE_BINARY( add_id, operator+ ); - GC_VALUE_BINARY( sub_id, operator- ); - GC_VALUE_BINARY( mul_id, operator* ); - GC_VALUE_BINARY( div_id, operator/ ); - GC_VALUE_BINARY( mod_id, operator% ); - - GC_VALUE_BINARY( and_id, operator& ); - GC_VALUE_BINARY( xor_id, operator^ ); - GC_VALUE_BINARY( or_id, operator| ); - - GC_VALUE_BINARY( lshift_id, operator<< ); - GC_VALUE_BINARY( rshift_id, operator>> ); -%#undef GC_VALUE_BINARY - + GC_VALUE operator+(const GC_VALUE& other) const { return binary_op(other, add_id); } + GC_VALUE operator-(const GC_VALUE& other) const { return binary_op(other, sub_id); } + GC_VALUE operator*(const GC_VALUE& other) const { return binary_op(other, mul_id); } + GC_VALUE operator/(const GC_VALUE& other) const { return binary_op(other, div_id); } + GC_VALUE operator%(const GC_VALUE& other) const { return binary_op(other, mod_id); } + GC_VALUE operator&(const GC_VALUE& other) const { return binary_op(other, and_id); } + GC_VALUE operator^(const GC_VALUE& other) const { return binary_op(other, xor_id); } + GC_VALUE operator|(const GC_VALUE& other) const { return binary_op(other, or_id); } + GC_VALUE operator<<(const GC_VALUE& other) const { return binary_op(other, lshift_id); } + GC_VALUE operator>>(const GC_VALUE& other) const { return binary_op(other, rshift_id); } }; ID GC_VALUE::hash_id = rb_intern("hash"); @@ -352,7 +343,7 @@ namespace swig { VALUE to_s() const; GC_VALUE(); protected: - GC_VALUE( const GC_VALUE& ); + GC_VALUE(const GC_VALUE&); ~GC_VALUE(); }; From 65b917dabb5d0037318da93b78ce028dbb113f07 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Apr 2013 16:19:17 -0700 Subject: [PATCH 059/273] Some test-suite warning fixes --- Examples/test-suite/li_std_except_as_class.i | 6 ++++++ Examples/test-suite/typemap_array_qualifiers.i | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Examples/test-suite/li_std_except_as_class.i b/Examples/test-suite/li_std_except_as_class.i index 00de76eac..0400c9a82 100644 --- a/Examples/test-suite/li_std_except_as_class.i +++ b/Examples/test-suite/li_std_except_as_class.i @@ -5,6 +5,12 @@ * if there were also functions throwing 'std::logic_error' and * 'std::exception' then the bug would not be fully replicated */ +%{ +#if defined(_MSC_VER) + #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) +#endif +%} + %{ #include #include diff --git a/Examples/test-suite/typemap_array_qualifiers.i b/Examples/test-suite/typemap_array_qualifiers.i index 947721402..14df649d3 100644 --- a/Examples/test-suite/typemap_array_qualifiers.i +++ b/Examples/test-suite/typemap_array_qualifiers.i @@ -39,6 +39,7 @@ CLEAR_SWIGTYPE_TYPEMAPS; %typemap(in) SWIGTYPE [ANY] { +$1 = 0; /* Correct typemap for $symname: $type */ } %inline %{ @@ -48,9 +49,11 @@ CLEAR_SWIGTYPE_TYPEMAPS; CLEAR_SWIGTYPE_TYPEMAPS; %typemap(in) const SWIGTYPE [ANY] { +$1 = 0; /* Correct typemap for $symname: $type */ } %typemap(in) const volatile SWIGTYPE [ANY] { +$1 = 0; /* Correct typemap for $symname: $type */ } %inline %{ @@ -61,9 +64,11 @@ CLEAR_SWIGTYPE_TYPEMAPS; CLEAR_SWIGTYPE_TYPEMAPS; %typemap(in) volatile SWIGTYPE **const [ANY] { +$1 = 0; /* Correct typemap for $symname: $type */ } %typemap(in) volatile SWIGTYPE **const [ANY][ANY] { +$1 = 0; /* Correct typemap for $symname: $type */ } %inline %{ @@ -72,6 +77,7 @@ CLEAR_SWIGTYPE_TYPEMAPS; CLEAR_SWIGTYPE_TYPEMAPS; %typemap(in) SWIGTYPE (*const) (ANY) { +$1 = 0; /* Correct typemap for $symname: $type */ } %inline %{ From 5ae6ff404d8a7d4c17a260a6f2cae7c8959152f7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Apr 2013 07:57:45 +0100 Subject: [PATCH 060/273] Cosmetic - use C comments instead of C++ comments for recent Ruby change --- Lib/ruby/rubyclasses.swg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/ruby/rubyclasses.swg b/Lib/ruby/rubyclasses.swg index 598bc4db9..5537136af 100644 --- a/Lib/ruby/rubyclasses.swg +++ b/Lib/ruby/rubyclasses.swg @@ -174,8 +174,10 @@ namespace swig { static VALUE swig_rescue_swallow(VALUE) { - // VALUE errstr = rb_obj_as_string(rb_errinfo()); - // printf("Swallowing error: '%s'\n", RSTRING_PTR(StringValue(errstr))); + /* + VALUE errstr = rb_obj_as_string(rb_errinfo()); + printf("Swallowing error: '%s'\n", RSTRING_PTR(StringValue(errstr))); + */ return Qnil; /* Swallow Ruby exception */ } From dd2cd0298c39d9546f68ff538f5c90634e5a0106 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Apr 2013 18:30:16 +0100 Subject: [PATCH 061/273] Work around Octave seg fault on exit in imports testcase on Octave 3.1 and 3.2 --- Examples/test-suite/octave/imports_runme.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/octave/imports_runme.m b/Examples/test-suite/octave/imports_runme.m index be9db5919..5db38071b 100644 --- a/Examples/test-suite/octave/imports_runme.m +++ b/Examples/test-suite/octave/imports_runme.m @@ -1,7 +1,8 @@ # This is the import runtime testcase. -imports_b; +# If imports_b is loaded before imports_a, a seg fault occurred during interpreter cleanup/exit in version 3.1 and 3.2, seems okay in 3.6 imports_a; +imports_b; x = imports_b.B(); x.hello(); From 5fd059d80f9c2c47f6889c448b9d691bb8b20c1d Mon Sep 17 00:00:00 2001 From: Nishant Rodrigues Date: Mon, 8 Apr 2013 14:35:08 +0900 Subject: [PATCH 062/273] Patch fixing warning 322 in rubycontainer_extended 'rubycontainer_extended.swg' generates warnings: Warning 322: Redundant redeclaration of 'map_bang', Warning 322: previous declaration of 'map_bang'. The fix is to remove a redundant call to swig_container_extend for swig::GC_VALUE. Thanks ======================================================== --- Lib/ruby/rubycontainer_extended.swg | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/ruby/rubycontainer_extended.swg b/Lib/ruby/rubycontainer_extended.swg index d2a058586..7514ba2c8 100644 --- a/Lib/ruby/rubycontainer_extended.swg +++ b/Lib/ruby/rubycontainer_extended.swg @@ -124,7 +124,6 @@ %swig_container_extend( %arg( Container ), std::complex ); %swig_container_extend( %arg( Container ), std::string ); %swig_container_extend( %arg( Container ), swig::GC_VALUE ); -%swig_container_extend( %arg( Container ), swig::GC_VALUE ); %enddef From 1fce0bd2b41ee3ddebacfe101c6a231f6111bf21 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Apr 2013 21:48:09 +0100 Subject: [PATCH 063/273] Workaround to Octave seg fault on exit in imports testcase only seems to work in 3.1, not 3.2. Just ignore test now --- Examples/test-suite/octave/imports_runme.m | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Examples/test-suite/octave/imports_runme.m b/Examples/test-suite/octave/imports_runme.m index 5db38071b..a9c8bffb8 100644 --- a/Examples/test-suite/octave/imports_runme.m +++ b/Examples/test-suite/octave/imports_runme.m @@ -1,20 +1,22 @@ # This is the import runtime testcase. -# If imports_b is loaded before imports_a, a seg fault occurred during interpreter cleanup/exit in version 3.1 and 3.2, seems okay in 3.6 -imports_a; -imports_b; +# Workaround seg fault occurring during interpreter cleanup/exit in version 3.1 and 3.2, seems okay in 3.6 +if (compare_versions(version(), "3.3", ">=")) + imports_b; + imports_a; -x = imports_b.B(); -x.hello(); + x = imports_b.B(); + x.hello(); -a = imports_a.A(); + a = imports_a.A(); -c = imports_b.C(); -a1 = c.get_a(c); -a2 = c.get_a_type(c); + c = imports_b.C(); + a1 = c.get_a(c); + a2 = c.get_a_type(c); -a1.hello(); -a2.hello(); -assert(swig_this(a1)==swig_this(a2)); -assert(strcmp(swig_type(a1),swig_type(a2))); + a1.hello(); + a2.hello(); + assert(swig_this(a1)==swig_this(a2)); + assert(strcmp(swig_type(a1),swig_type(a2))); +endif From 939fa86627cb95ce2670991e0c7feac26387edf1 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 9 Apr 2013 14:35:14 +1200 Subject: [PATCH 064/273] [PHP] Add missing directorin typemap for char* and char[] which fixes director_string testcase failure. --- CHANGES.current | 4 ++++ Lib/php/php.swg | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 9253f9c96..864fb9a3c 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.10 (in progress) ============================ +2013-04-09: olly + [PHP] Add missing directorin typemap for char* and char[] which + fixes director_string testcase failure. + 2013-04-05: wsfulton [Ruby] SF Bug #1292 - Runtime fixes for Proc changes in ruby-1.9 when using STL wrappers that override the default predicate, such as: diff --git a/Lib/php/php.swg b/Lib/php/php.swg index d46de93ea..f27e1fe67 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -269,6 +269,15 @@ ZVAL_LONG($input,$1); } +%typemap(directorin) char *, char [] +{ + if(!$1) { + ZVAL_NULL($input); + } else { + ZVAL_STRING($input, (char *)$1, 1); + } +} + %typemap(out) bool { ZVAL_BOOL(return_value,($1)?1:0); From 3e26318427a0e7dfdaf5e9ee1d988a1db1d6b464 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Apr 2013 09:17:36 +0100 Subject: [PATCH 065/273] Add target language version display during make check. Individual language versions can be checked using 'make check--version'. --- Examples/Makefile.in | 222 ++++++++++++++++++++++++++ Examples/test-suite/cffi/Makefile.in | 2 +- Examples/test-suite/clisp/Makefile.in | 2 +- Examples/test-suite/uffi/Makefile.in | 2 +- Makefile.in | 41 ++++- configure.ac | 14 +- 6 files changed, 275 insertions(+), 8 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 6e1731f6b..a3444d284 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -95,6 +95,7 @@ distclean: # Set these to your local copy of Tcl/Tk. +TCLSH = tclsh TCL_INCLUDE = @TCLINCLUDE@ TCL_LIB = @TCLLIB@ TCL_OPTS = @LIBS@ @@ -154,6 +155,13 @@ tcl_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) $(TCLCXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +tcl_version: + echo 'puts $$tcl_version;exit 0' | $(TCLSH) + # ----------------------------------------------------------------- # Cleaning the Tcl examples # ----------------------------------------------------------------- @@ -176,6 +184,7 @@ PERL5_INCLUDE= @PERL5EXT@ # Extra Perl specific dynamic linking options PERL5_DLNK = @PERL5DYNAMICLINKING@ PERL5_CCFLAGS = @PERL5CCFLAGS@ +PERL = @PERL@ # ---------------------------------------------------------------- # Build a Perl5 dynamically loadable module (C) @@ -216,6 +225,13 @@ perl5_static_cpp: $(SRCS) $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +perl5_version: + $(PERL) -v | grep "This is" + # ----------------------------------------------------------------- # Cleaning the Perl5 examples # ----------------------------------------------------------------- @@ -315,6 +331,13 @@ runme3.py: runme.py cp $< $@ $(PY2TO3) -w $@ >/dev/null 2>&1 +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +python_version: + $(PYTHON) -V + # ----------------------------------------------------------------- # Cleaning the python examples # ----------------------------------------------------------------- @@ -368,6 +391,13 @@ OCTSCRIPT = runme.m octave_run: $(OCTSCRIPT) env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(OCTAVE) $(OCTSCRIPT) >/dev/null +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +octave_version: + $(OCTAVE) --version | grep -i version + # ----------------------------------------------------------------- # Cleaning the octave examples # ----------------------------------------------------------------- @@ -383,6 +413,7 @@ octave_clean: ################################################################## # Make sure these locate your Guile installation +GUILE = @GUILE@ GUILE_INCLUDE = @GUILEINCLUDE@ GUILE_LIB = @GUILELIB@ GUILE_SO = @GUILE_SO@ @@ -459,6 +490,13 @@ guile_simple_cpp: $(SRCS) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +guile_version: + $(GUILE) --version + # ----------------------------------------------------------------- # Cleaning the Guile examples # ----------------------------------------------------------------- @@ -484,6 +522,8 @@ JAVASO =@JAVASO@ JAVALDSHARED = @JAVALDSHARED@ JAVACXXSHARED = @JAVACXXSHARED@ JAVACFLAGS = @JAVACFLAGS@ +JAVA = @JAVA@ +JAVAC = @JAVAC@ # ---------------------------------------------------------------- # Build a java dynamically loadable module (C) @@ -503,6 +543,14 @@ java_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVACXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +java_version: + $(JAVA) -version + $(JAVAC) -version || echo "unknown javac version" + # ----------------------------------------------------------------- # Cleaning the java examples # ----------------------------------------------------------------- @@ -512,6 +560,17 @@ java_clean: rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@JAVASO@ +################################################################## +##### ANDROID ###### +################################################################## + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +android_version: + adb version + ################################################################## ##### MODULA3 ###### ################################################################## @@ -530,6 +589,13 @@ modula3: $(SRCS) modula3_cpp: $(SRCS) $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACEPATH) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +modula3_version: + echo "Unknown modula3 version" + # ----------------------------------------------------------------- # Cleaning the modula3 examples # ----------------------------------------------------------------- @@ -543,6 +609,7 @@ modula3_clean: ##### MZSCHEME ###### ################################################################## +MZSCHEME = mzscheme MZC = @MZC@ MZDYNOBJ = @MZDYNOBJ@ MZSCHEME_SO = @MZSCHEME_SO@ @@ -561,6 +628,14 @@ mzscheme_cpp: $(SRCS) $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +mzscheme_version: + $(MZSCHEME) -v + $(MZC) -v + # ----------------------------------------------------------------- # Cleaning the mzscheme examples # ----------------------------------------------------------------- @@ -697,6 +772,17 @@ ocaml_dynamic_cpp: $(SRCS) -package dl -linkpkg \ $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings' +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +ocaml_version: + $(OCC) -version + +# ----------------------------------------------------------------- +# Cleaning the Ocaml examples +# ----------------------------------------------------------------- + ocaml_clean: rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo rm -f core @EXTRA_CLEAN@ @@ -711,6 +797,7 @@ RUBY_CFLAGS= @RUBYCCDLFLAGS@ $(DEFS) RUBY_INCLUDE= @RUBYINCLUDE@ RUBY_LIB = @RUBYLIB@ RUBY_DLNK = @RUBYDYNAMICLINKING@ +RUBY = @RUBY@ # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -750,6 +837,13 @@ ruby_cpp_static: $(SRCS) $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +ruby_version: + $(RUBY) -v + # ----------------------------------------------------------------- # Cleaning the Ruby examples # ----------------------------------------------------------------- @@ -794,6 +888,13 @@ PHPSCRIPT ?= runme.php php_run: $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +php_version: + $(PHP) -v + # ----------------------------------------------------------------- # Cleaning the PHP examples # ----------------------------------------------------------------- @@ -808,6 +909,7 @@ php_clean: ################################################################## # Make sure these locate your Pike installation +PIKE = pike PIKE_CFLAGS = @PIKECCDLFLAGS@ -DHAVE_CONFIG_H PIKE_INCLUDE = @PIKEINCLUDE@ PIKE_LIB = @PIKELIB@ @@ -850,6 +952,13 @@ pike_cpp_static: $(SRCS) $(CXX) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +pike_version: + $(PIKE) -v + # ----------------------------------------------------------------- # Cleaning the Pike examples # ----------------------------------------------------------------- @@ -951,6 +1060,17 @@ chicken_cpp: chicken_externalhdr: $(SWIG) -chicken -external-runtime $(TARGET) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +chicken_version: + $(CHICKEN) -version + +# ----------------------------------------------------------------- +# Cleaning the CHICKEN examples +# ----------------------------------------------------------------- + chicken_clean: rm -f *_wrap* *~ .~* *_chicken* rm -f core @EXTRA_CLEAN@ @@ -993,6 +1113,13 @@ csharp_cpp: $(SRCS) csharp_compile: $(SRCS) $(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPSRCS) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +csharp_version: + $(CSHARPCOMPILER) --version || echo "Unknown C# compiler version" + # ----------------------------------------------------------------- # Cleaning the CSharp examples # ----------------------------------------------------------------- @@ -1013,6 +1140,7 @@ LUA_LIB = @LUALINK@ # Extra specific dynamic linking options LUA_DLNK = @LUADYNAMICLINKING@ LUA_SO = @LUA_SO@ +LUA = @LUABIN@ # Extra code for lua static link LUA_INTERP = ../lua.c @@ -1049,6 +1177,13 @@ lua_static_cpp: $(SRCS) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +lua_version: + $(LUA) -v + # ----------------------------------------------------------------- # Cleaning the lua examples # ----------------------------------------------------------------- @@ -1062,6 +1197,8 @@ lua_clean: ##### ALLEGRO CL ###### ################################################################## +ALLEGROCL = @ALLEGROCLBIN@ + allegrocl: $(SRCS) $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) @@ -1072,6 +1209,17 @@ allegrocl_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +allegrocl_version: + $(ALLEGROCL) --version + +# ----------------------------------------------------------------- +# Cleaning the ALLEGRO CL examples +# ----------------------------------------------------------------- + allegrocl_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1081,12 +1229,25 @@ allegrocl_clean: ##### CLISP ###### ################################################################## +CLISP = @CLISPBIN@ + clisp: $(SRCS) $(SWIG) -clisp $(SWIGOPT) $(INTERFACEPATH) clisp_cpp: $(SRCS) $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACEPATH) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +clisp_version: + $(CLISP) --version + +# ----------------------------------------------------------------- +# Cleaning the CLISP examples +# ----------------------------------------------------------------- + clisp_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1096,6 +1257,8 @@ clisp_clean: ##### CFFI ###### ################################################################## +CFFI = @CFFIBIN@ + cffi: $(SRCS) $(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) @@ -1106,6 +1269,17 @@ cffi_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +cffi_version: + $(CFFI) --version + +# ----------------------------------------------------------------- +# Cleaning the CFFI examples +# ----------------------------------------------------------------- + cffi_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1115,6 +1289,8 @@ cffi_clean: ##### UFFI ###### ################################################################## +UFFI = @UFFIBIN@ + uffi: $(SRCS) $(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) @@ -1125,6 +1301,17 @@ uffi_cpp: $(SRCS) # $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) # $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +uffi_version: + $(UFFI) --version + +# ----------------------------------------------------------------- +# Cleaning the UFFI examples +# ----------------------------------------------------------------- + uffi_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1143,6 +1330,10 @@ R_CFLAGS=-fPIC # we get -fPIC # CMD SHLIB stdout is piped to /dev/null to prevent echo of compiler command +# ---------------------------------------------------------------- +# Build a R dynamically loadable module (C) +# ---------------------------------------------------------------- + r: $(SRCS) $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) ifneq ($(SRCS),) @@ -1150,6 +1341,10 @@ ifneq ($(SRCS),) endif +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null ) +# ---------------------------------------------------------------- +# Build a R dynamically loadable module (C++) +# ---------------------------------------------------------------- + r_cpp: $(CXXSRCS) $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) ifneq ($(CXXSRCS),) @@ -1157,6 +1352,17 @@ ifneq ($(CXXSRCS),) endif +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null ) +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +r_version: + $(R) --version | grep -i version + +# ----------------------------------------------------------------- +# Cleaning the R examples +# ----------------------------------------------------------------- + r_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1172,6 +1378,7 @@ GOGCC = @GOGCC@ GO1 = @GO1@ GOC = @GOC@ GOOPT = @GOOPT@ +GOVERSIONOPTION = @GOVERSIONOPTION@ GOSWIGARG = `if $(GOGCC) ; then echo -gccgo; fi` GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi` @@ -1230,6 +1437,13 @@ go_run: runme.go fi env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +go_version: + $(GO) $(GOVERSIONOPTION) + # ----------------------------------------------------------------- # Cleaning the Go examples # ----------------------------------------------------------------- @@ -1291,6 +1505,14 @@ d_compile: $(SRCS) d_run: env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +d_version: + # Needs improvement! + echo D version guess - $(D_VERSION) + # ----------------------------------------------------------------- # Clean the D examples # ----------------------------------------------------------------- diff --git a/Examples/test-suite/cffi/Makefile.in b/Examples/test-suite/cffi/Makefile.in index bf21b3552..aa8b40aec 100644 --- a/Examples/test-suite/cffi/Makefile.in +++ b/Examples/test-suite/cffi/Makefile.in @@ -39,7 +39,7 @@ CPP_TEST_CASES = # a file is found which has _runme.lisp appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFI) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra cffi code) diff --git a/Examples/test-suite/clisp/Makefile.in b/Examples/test-suite/clisp/Makefile.in index 2ebaa6750..24655a60f 100644 --- a/Examples/test-suite/clisp/Makefile.in +++ b/Examples/test-suite/clisp/Makefile.in @@ -39,7 +39,7 @@ CPP_TEST_CASES = # a file is found which has _runme.lisp appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISPBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISP) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra clisp code) diff --git a/Examples/test-suite/uffi/Makefile.in b/Examples/test-suite/uffi/Makefile.in index d6b948b5d..8ad153961 100644 --- a/Examples/test-suite/uffi/Makefile.in +++ b/Examples/test-suite/uffi/Makefile.in @@ -39,7 +39,7 @@ CPP_TEST_CASES = # a file is found which has _runme.lisp appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(UFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(UFFI) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra uffi code) diff --git a/Makefile.in b/Makefile.in index 7ecbfa251..8a6776bf8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -123,6 +123,45 @@ check-aliveness: check-ccache: test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) check) +# Checks / displays versions of each target language +check-versions: \ + check-tcl-version \ + check-perl5-version \ + check-python-version \ + check-java-version \ + check-android-version \ + check-guile-version \ + check-mzscheme-version \ + check-ruby-version \ + check-ocaml-version \ + check-octave-version \ + check-php-version \ + check-pike-version \ + check-chicken-version \ + check-csharp-version \ + check-modula3-version \ + check-lua-version \ + check-allegrocl-version \ + check-clisp-version \ + check-uffi-version \ + check-cffi-version \ + check-r-version \ + check-go-version \ + check-d-version + +# all examples +check-%-version : + @if test -z "$(skip-$*)"; then \ + echo $* unknown; \ + exit 1; \ + fi + @if $(skip-$*); then \ + echo skipping $* version; \ + else \ + echo showing $* version; \ + (cd Examples && $(MAKE) -s $*_version) \ + fi + # Checks examples for compilation (does not run them) check-examples: \ check-tcl-examples \ @@ -252,7 +291,7 @@ partialcheck-test-suite: partialcheck-%-test-suite: @$(MAKE) -k -s check-$*-test-suite ACTION=partialcheck NOSKIP=1 -check: check-aliveness check-ccache check-examples check-test-suite +check: check-aliveness check-ccache check-versions check-examples check-test-suite # Run known-to-be-broken as well as not broken testcases in the test-suite all-test-suite: \ diff --git a/configure.ac b/configure.ac index cfbc09426..65a9c9078 100644 --- a/configure.ac +++ b/configure.ac @@ -1592,7 +1592,7 @@ if test x"${PIKEBIN}" = xno -o x"${with_alllang}" = xno ; then else if test "x$PIKEBIN" = xyes; then - AC_CHECK_PROGS(PIKE, pike pike7.6 pike7.4 pike7.2) + AC_CHECK_PROGS(PIKE, pike pike7.8 pike7.6 pike7.4 pike7.2) else PIKE="$PIKEBIN" fi @@ -2063,6 +2063,7 @@ if test x"${GOBIN}" = xno -o x"${with_alllang}" = xno ; then GO1=false GOGCC=false GOOPT= + GOVERSIONOPTION= else if test "x$GOBIN" = xyes; then @@ -2074,11 +2075,13 @@ else GOGCC=false GO1=false GOOPT= + GOVERSIONOPTION= if test -n "$GO" ; then if $GO --help 2>/dev/null | grep gccgo >/dev/null 2>&1 ; then GOGCC=true + GOVERSIONOPTION=--version AC_MSG_CHECKING([whether gccgo version is too old]) - go_version=`$GO --version | sed -e 's/[^0-9]* \([0-9.]*\) .*$/\1/' -e 's/[.]//g'` + go_version=`$GO $GOVERSIONOPTION | sed -e 's/[^0-9]* \([0-9.]*\) .*$/\1/' -e 's/[.]//g'` if test "$go_version" -lt 470; then AC_MSG_RESULT([yes - minimum version is 4.7.0]) else @@ -2096,8 +2099,9 @@ else fi elif test "`echo $GO | sed -e 's|.*/||'`" = "go"; then GO1=true + GOVERSIONOPTION=version GOC=$(sh -c "$(go env) && echo \$GOCHAR")c - go_version=$($GO version | sed -e 's/go version //') + go_version=$($GO $GOVERSIONOPTION | sed -e 's/go version //') case $go_version in go1.0*) GOOPT="-intgosize 32" ;; *) if test "$GOC" = "6c"; then @@ -2109,8 +2113,9 @@ else esac else GOC=`echo $GO | sed -e 's/g/c/'` + GOVERSIONOPTION=-V AC_MSG_CHECKING([whether Go ($GO) version is too old]) - go_version=`$GO -V 2>/dev/null | sed -e 's/.*version.* \([[0-9]]*\).*/\1/'` + go_version=`$GO $GOVERSIONOPTION 2>/dev/null | sed -e 's/.*version.* \([[0-9]]*\).*/\1/'` go_min_version=7077 if test "$go_version" != "" -a "$go_version" -lt $go_min_version; then AC_MSG_RESULT([yes - minimum version is $go_min_version]) @@ -2128,6 +2133,7 @@ AC_SUBST(GO) AC_SUBST(GOC) AC_SUBST(GO1) AC_SUBST(GOOPT) +AC_SUBST(GOVERSIONOPTION) #---------------------------------------------------------------- # Look for D From 970c72b6da18516966ba82c91fa1e3cbb1b5725d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Apr 2013 22:52:54 +0100 Subject: [PATCH 066/273] make check-csharp-version fix for MS compiler --- Examples/Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index a3444d284..c234c41ab 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1117,8 +1117,9 @@ csharp_compile: $(SRCS) # Version display # ----------------------------------------------------------------- +# Version check below also works with MS csc.exe which does not understand --version csharp_version: - $(CSHARPCOMPILER) --version || echo "Unknown C# compiler version" + $(CSHARPCOMPILER) --version | grep -i version # ----------------------------------------------------------------- # Cleaning the CSharp examples From 35ab209332bb279cc3f0c25eb5596d21e44a2f90 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Apr 2013 23:52:35 +0100 Subject: [PATCH 067/273] Travis build for top 10 target languages plus gcc and clang SWIG builds. Travis builds patch developed in wsfulton/travis branch --- .travis.yml | 56 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78205c848..abdb54327 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,51 @@ language: cpp compiler: - - gcc - clang + - gcc +env: + - SWIGLANG= matrix: include: - - python: "2.7" - compiler: gcc + - compiler: gcc + env: SWIGLANG=csharp + - compiler: gcc + env: SWIGLANG=go + - compiler: gcc + env: SWIGLANG=java + - compiler: gcc + env: SWIGLANG=lua + - compiler: gcc + env: SWIGLANG=octave SWIGJOBS=-j4 + - compiler: gcc + env: SWIGLANG=perl5 + - compiler: gcc + env: SWIGLANG=php + - compiler: gcc env: SWIGLANG=python - - jdk: oraclejdk6 - compiler: gcc - env: SWIGLANG=java - - jdk: oraclejdk7 - compiler: gcc - env: SWIGLANG=java - - perl: "5.10" - compiler: gcc - env: SWIGLANG=perl - - rvm: 1.8.7 - compiler: gcc + - compiler: gcc env: SWIGLANG=ruby + - compiler: gcc + env: SWIGLANG=tcl + allow_failures: + # None before_install: - - sudo apt-get install libboost-dev -qq + - lsb_release -a + - uname -a + - time sudo apt-get -qq install libboost-dev + - if test "$SWIGLANG" = "csharp"; then sudo apt-get -qq install mono-devel; fi + - if test "$SWIGLANG" = "go"; then go env | sed -e 's/^/export /' > goenvsetup && source goenvsetup && rm -f goenvsetup; fi # Until configure.ac is fixed + - if test "$SWIGLANG" = "lua"; then sudo apt-get -qq install lua5.1 liblua5.1-dev; fi + - if test "$SWIGLANG" = "octave"; then sudo apt-get -qq install octave3.2 octave3.2-headers; fi + - if test "$SWIGLANG" = "php"; then sudo apt-get install php5-cli php5-dev; fi + - if test "$SWIGLANG" = "tcl"; then sudo apt-get -qq install tcl8.4-dev; fi script: - ./autogen.sh && ./configure - - make -s - - echo "SWIGLANG: $SWIGLANG" -# - make -k check-$SWIGLANG-examples check-$SWIGLANG-test-suite + - make -s $SWIGJOBS + - if test -z "$SWIGLANG"; then make -s check-ccache; fi + - ./swig -version + - if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi + - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-examples; fi + - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-test-suite; fi branches: only: - master From d0202cbdac17721ebfdf8114a1cb96372d867a4a Mon Sep 17 00:00:00 2001 From: Marvin Greenberg Date: Wed, 10 Apr 2013 18:37:26 +0100 Subject: [PATCH 068/273] Fix typecheck OUTPUT typemaps for Java --- Lib/java/typemaps.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/java/typemaps.i b/Lib/java/typemaps.i index ae2377b70..e71790bcc 100644 --- a/Lib/java/typemaps.i +++ b/Lib/java/typemaps.i @@ -207,8 +207,8 @@ There are no char *OUTPUT typemaps, however you can apply the signed char * type JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &jvalue); } -%typemap(typecheck) TYPE *INOUT = TYPECHECKTYPE; -%typemap(typecheck) TYPE &INOUT = TYPECHECKTYPE; +%typemap(typecheck) TYPE *OUTPUT = TYPECHECKTYPE; +%typemap(typecheck) TYPE &OUTPUT = TYPECHECKTYPE; %enddef OUTPUT_TYPEMAP(bool, jboolean, boolean, Boolean, "[Ljava/lang/Boolean;", jbooleanArray); From a16dc2904603decad54e50f4096e99c3ae26f017 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 14 Apr 2013 06:14:47 +1200 Subject: [PATCH 069/273] Removed unused Printf parameter --- Source/Modules/php.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index fdd335993..bc8a92687 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2591,7 +2591,7 @@ done: } if (!idx) { - Printf(w->code, "zval **args = NULL;\n", idx); + Printf(w->code, "zval **args = NULL;\n"); } else { Printf(w->code, "zval *args[%d];\n", idx); } From 24ff00690f2b1bc36bb8a00c9a236ce1c444e61c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 14 Apr 2013 08:03:46 +1200 Subject: [PATCH 070/273] Use ZVAL_STRINGL instead of ZVAL_STRING to set funcname as we know the length at swig-time --- Source/Modules/php.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index bc8a92687..3cae48383 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2597,7 +2597,8 @@ done: } 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")); + const char * funcname = GetChar(n, "sym:name"); + Printf(w->code, "ZVAL_STRINGL(&funcname, (char *)\"%s\", %d, 0);\n", funcname, strlen(funcname)); Append(w->code, "if (!swig_self) {\n"); Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");"); Append(w->code, "}\n\n"); From 611acbf94447f51db1583fb4b6a147860803fcfc Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Mon, 15 Apr 2013 22:17:48 +0200 Subject: [PATCH 071/273] Add -MP option for generating phony targets for all dependencies - Modelled on similar option in GCC --- CHANGES.current | 6 ++++++ Source/Modules/main.cxx | 20 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 864fb9a3c..ece451ae2 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.10 (in progress) ============================ +2013-04-08: kwwette + Add -MP option to SWIG for generating phony targets for all dependencies. + - Prevents make from complaining if header files have been deleted before + the dependency file has been updated. + - Modelled on similar option in GCC. + 2013-04-09: olly [PHP] Add missing directorin typemap for char* and char[] which fixes director_string testcase failure. diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index d1f3ab274..4076b9206 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -107,6 +107,7 @@ static const char *usage2 = (const char *) "\ -MM - List dependencies, but omit files in SWIG library\n\ -MMD - Like `-MD', but omit files in SWIG library\n\ -module - Set module name to \n\ + -MP - Generate phony targets for all dependencies\n\ -MT - Set the target of the rule emitted by dependency generation\n\ -nocontract - Turn off contract checking\n\ -nocpperraswarn - Do not treat the preprocessor #error statement as #warning\n\ @@ -185,6 +186,7 @@ static int dump_classes = 0; static int werror = 0; static int depend = 0; static int depend_only = 0; +static int depend_phony = 0; static int memory_debug = 0; static int allkw = 0; static DOH *cpps = 0; @@ -712,6 +714,9 @@ void SWIG_getoptions(int argc, char *argv[]) { } else if (strcmp(argv[i], "-MMD") == 0) { depend = 2; Swig_mark_arg(i); + } else if (strcmp(argv[i], "-MP") == 0) { + depend_phony = 1; + Swig_mark_arg(i); } else if (strcmp(argv[i], "-MT") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { @@ -1101,22 +1106,33 @@ int SWIG_main(int argc, char *argv[], Language *l) { Printf(f_dependencies_file, "%s: ", outfile); } List *files = Preprocessor_depend(); + List *phony_targets = NewList(); for (int i = 0; i < Len(files); i++) { int use_file = 1; if (depend == 2) { if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWinUnix && (Strncmp(Getitem(files, i), SwigLibWinUnix, Len(SwigLibWinUnix)) == 0))) use_file = 0; } - if (use_file) - Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i)); + if (use_file) { + Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i)); + if (depend_phony) + Append(phony_targets, Getitem(files, i)); + } } Printf(f_dependencies_file, "\n"); + if (depend_phony) { + for (int i = 0; i < Len(phony_targets); i++) { + Printf(f_dependencies_file, "\n%s:\n", Getitem(phony_targets, i)); + } + } + if (f_dependencies_file != stdout) Delete(f_dependencies_file); if (depend_only) SWIG_exit(EXIT_SUCCESS); Delete(inputfile_filename); Delete(basename); + Delete(phony_targets); } else { Printf(stderr, "Cannot generate dependencies with -nopreprocess\n"); // Actually we could but it would be inefficient when just generating dependencies, as it would be done after Swig_cparse From 25eaee49f3cb4348e71b66144e9ba541c0632fa5 Mon Sep 17 00:00:00 2001 From: "Brant K. Kyser" Date: Mon, 15 Apr 2013 13:38:40 -0500 Subject: [PATCH 072/273] Add check for smart pointer type in generated code for director connection. This fixes a crash in the generated code caused by the dynamic_cast returning 0 because the specified types are incorrect for smart pointer types. Add runtime test to the C# test suite's director smartptr test that demonstrates crash in generated code when directors are used with smart pointer types. Closes #34 --- .../csharp/director_smartptr_runme.cs | 41 +++++++++++++++++++ Source/Modules/csharp.cxx | 14 ++++++- 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/csharp/director_smartptr_runme.cs diff --git a/Examples/test-suite/csharp/director_smartptr_runme.cs b/Examples/test-suite/csharp/director_smartptr_runme.cs new file mode 100644 index 000000000..ad33c4d34 --- /dev/null +++ b/Examples/test-suite/csharp/director_smartptr_runme.cs @@ -0,0 +1,41 @@ +using director_smartptrNamespace; + +public class runme +{ + + private class director_smartptr_MyBarFoo : Foo + { + public override string ping() + { + return "director_smartptr_MyBarFoo.ping();"; + } + + public override string pong() + { + return "director_smartptr_MyBarFoo.pong();" + ping(); + } + + public override string fooBar(FooBar fooBar) + { + return fooBar.FooBarDo(); + } + + public override Foo makeFoo() + { + return new Foo(); + } + + public override FooBar makeFooBar() + { + return new FooBar(); + } + } + + static void Main() + { + director_smartptr_MyBarFoo myBarFoo = + new director_smartptr_MyBarFoo(); + + myBarFoo.ping(); + } +} diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 4ef62d2cc..2050f36db 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3382,6 +3382,7 @@ public: String *qualified_classname = Copy(sym_name); String *nspace = getNSpace(); String *dirClassName = directorClassName(n); + String *smartptr_feature = Getattr(n, "feature:smartptr"); if (nspace) Insert(qualified_classname, 0, NewStringf("%s.", nspace)); @@ -3392,8 +3393,17 @@ public: 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); - Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName); + if (Len(smartptr_feature)) { + Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", smartptr_feature, smartptr_feature); + Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n"); + Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n"); + Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName); + } + else { + Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name); + Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName); + } + // TODO: if statement not needed?? - Java too Printf(code_wrap->code, " if (director) {\n"); Printf(code_wrap->code, " director->swig_connect_director("); From 296498c15925217ccd5dfe6cf8fa59b6d78c1270 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 17 Apr 2013 21:47:36 +0100 Subject: [PATCH 073/273] Cosmetic tidyup in smartptr feature code and document smartptr fix in previous commit --- CHANGES.current | 3 +++ Source/Modules/csharp.cxx | 6 +++--- Source/Modules/java.cxx | 14 +++++--------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ece451ae2..254ecf8ba 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.10 (in progress) ============================ +2013-04-17: wsfulton + [C#] Pull patch #34 from BrantKyser to fix smart pointers in conjuction with directors. + 2013-04-08: kwwette Add -MP option to SWIG for generating phony targets for all dependencies. - Prevents make from complaining if header files have been deleted before diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 2050f36db..6d5c570b1 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3382,7 +3382,7 @@ public: String *qualified_classname = Copy(sym_name); String *nspace = getNSpace(); String *dirClassName = directorClassName(n); - String *smartptr_feature = Getattr(n, "feature:smartptr"); + String *smartptr = Getattr(n, "feature:smartptr"); if (nspace) Insert(qualified_classname, 0, NewStringf("%s.", nspace)); @@ -3393,8 +3393,8 @@ public: Wrapper *code_wrap = NewWrapper(); Printf(code_wrap->def, "SWIGEXPORT void SWIGSTDCALL %s(void *objarg", wname); - if (Len(smartptr_feature)) { - Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", smartptr_feature, smartptr_feature); + if (Len(smartptr)) { + Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", smartptr, smartptr); Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n"); Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n"); Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index f351c91a3..dbd110d56 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -3389,7 +3389,7 @@ public: String *norm_name = SwigType_namestr(Getattr(n, "name")); String *swig_director_connect = Swig_name_member(getNSpace(), proxy_class_name, "director_connect"); String *swig_director_connect_jni = makeValidJniName(swig_director_connect); - String *smartptr_feature = Getattr(n, "feature:smartptr"); + String *smartptr = Getattr(n, "feature:smartptr"); String *dirClassName = directorClassName(n); Wrapper *code_wrap; @@ -3401,15 +3401,11 @@ public: "SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jswig_mem_own, " "jboolean jweak_global) {\n", jnipackage, jni_imclass_name, swig_director_connect_jni); - if (Len(smartptr_feature)) { - Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", smartptr_feature, smartptr_feature); + if (Len(smartptr)) { + Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", smartptr, smartptr); Printf(code_wrap->code, " (void)jcls;\n"); - Printf(code_wrap->code, " // NOTE: Pulling the raw pointer out of the smart pointer as the following code does\n"); - Printf(code_wrap->code, " // is generally a bad idea. However, in this case we keep a local instance of the\n"); - Printf(code_wrap->code, " // smart pointer around while we are using the raw pointer, which should keep the\n"); - Printf(code_wrap->code, " // raw pointer alive. This is done instead of using the smart pointer's dynamic cast\n"); - Printf(code_wrap->code, " // feature since different smart pointer implementations have differently named dynamic\n"); - Printf(code_wrap->code, " // cast mechanisms.\n"); + Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n"); + Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n"); Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName); } else { From 2a3e687c19385bb516b89343ffa0f347465ade82 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 16 Apr 2013 11:11:20 +0200 Subject: [PATCH 074/273] Octave: fix bugs in output of cleanup code Closes #35 --- CHANGES.current | 6 ++++++ Source/Modules/octave.cxx | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 254ecf8ba..926096cab 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -8,6 +8,12 @@ Version 2.0.10 (in progress) 2013-04-17: wsfulton [C#] Pull patch #34 from BrantKyser to fix smart pointers in conjuction with directors. +2013-04-15: kwwette + [Octave] Fix bugs in output of cleanup code. + - Cleanup code is now written also after the "fail:" label, so it will be called if + a SWIG_exception is raised by the wrapping function, consistent with other modules. + - Octave module now also recognises the "$cleanup" special variable, if needed. + 2013-04-08: kwwette Add -MP option to SWIG for generating phony targets for all dependencies. - Prevents make from complaining if header files have been deleted before diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index a9be76fc2..bf2552a30 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -744,10 +744,15 @@ public: Delete(tm); } - Printf(f->code, "fail:\n"); // we should free locals etc if this happens Printf(f->code, "return _out;\n"); + Printf(f->code, "fail:\n"); // we should free locals etc if this happens + Printv(f->code, cleanup, NIL); + Printf(f->code, "return octave_value_list();\n"); Printf(f->code, "}\n"); + /* Substitute the cleanup code */ + Replaceall(f->code, "$cleanup", cleanup); + Replaceall(f->code, "$symname", iname); Wrapper_print(f, f_wrappers); DelWrapper(f); From 857e447654c72184a9bace33ec3ad33ddb354c1d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Apr 2013 22:47:41 +0100 Subject: [PATCH 075/273] Fix syntax error when preprocessor macros are defined inside of enum lists Fixes SF Bug 428, Patch 333 --- CHANGES.current | 10 ++ Examples/test-suite/common.mk | 1 + Examples/test-suite/enum_macro.i | 92 ++++++++++++++++++ .../test-suite/java/enum_macro_runme.java | 93 +++++++++++++++++++ Source/CParse/parser.y | 46 ++++----- 5 files changed, 220 insertions(+), 22 deletions(-) create mode 100644 Examples/test-suite/enum_macro.i create mode 100644 Examples/test-suite/java/enum_macro_runme.java diff --git a/CHANGES.current b/CHANGES.current index 926096cab..4c1e55bc0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,16 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.10 (in progress) ============================ +2013-04-18: wsfulton + Fix SF Bug #428 - Syntax error when preprocessor macros are defined inside of enum lists, such as: + + typedef enum { + eZero = 0 + #define ONE 1 + } EFoo; + + The macros are silently ignored. + 2013-04-17: wsfulton [C#] Pull patch #34 from BrantKyser to fix smart pointers in conjuction with directors. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 83be90d2d..793055097 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -514,6 +514,7 @@ C_TEST_CASES += \ empty \ enums \ enum_forward \ + enum_macro \ extern_declaration \ funcptr \ function_typedef \ diff --git a/Examples/test-suite/enum_macro.i b/Examples/test-suite/enum_macro.i new file mode 100644 index 000000000..b18e02a84 --- /dev/null +++ b/Examples/test-suite/enum_macro.i @@ -0,0 +1,92 @@ +%module enum_macro + +%inline %{ +enum Greeks1 +{ +#define GREEK1 -1 + alpha1=1, + beta1, + theta1 +}; + +enum Greeks2 +{ + alpha2 = 2, +#define GREEK2 -2 + beta2, + theta2 +}; + +enum Greeks3 +{ + alpha3, + beta3, +#define GREEK3 -3 + theta3 +}; + +enum Greeks4 +{ + alpha4 = 4, + beta4 = 5, + theta4 = 6 +#define GREEK4 -4 +}; + +enum Greeks5 +{ +#define GREEK5 -5 + alpha5, + beta5, +}; + +enum Greeks6 +{ + alpha6, +#define GREEK6 -6 + beta6, +}; + +enum Greeks7 +{ + alpha7, + beta7, +#define GREEK7 -7 +}; + +enum Greeks8 +{ +#define GREEK8 -8 + theta8 +}; + +enum Greeks9 +{ + theta9 +#define GREEK9 -9 +}; + +enum Greeks10 +{ +#define GREEK10 -10 + theta10, +}; + +enum Greeks11 +{ + theta11, +#define GREEK11 -11 +}; + +typedef enum { + theta12 = 0 +#define GREEK12 -12 +} Greeks12; +%} + + +enum Greeks13 +{ +#define GREEK13 -13 +}; + diff --git a/Examples/test-suite/java/enum_macro_runme.java b/Examples/test-suite/java/enum_macro_runme.java new file mode 100644 index 000000000..4ac7409ee --- /dev/null +++ b/Examples/test-suite/java/enum_macro_runme.java @@ -0,0 +1,93 @@ + +import enum_macro.*; + +public class enum_macro_runme { + + static { + try { + System.loadLibrary("enum_macro"); + } 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[]) + { + { + Greeks1 a = Greeks1.alpha1; + a = Greeks1.beta1; + a = Greeks1.theta1; + if (a.swigValue() != 3) + throw new RuntimeException("Greeks1"); + } + { + Greeks2 a = Greeks2.alpha2; + a = Greeks2.beta2; + a = Greeks2.theta2; + if (a.swigValue() != 4) + throw new RuntimeException("Greeks2"); + } + { + Greeks3 a = Greeks3.alpha3; + a = Greeks3.beta3; + a = Greeks3.theta3; + if (a.swigValue() != 2) + throw new RuntimeException("Greeks3"); + } + { + Greeks4 a = Greeks4.alpha4; + a = Greeks4.beta4; + a = Greeks4.theta4; + if (a.swigValue() != 6) + throw new RuntimeException("Greeks4"); + } + { + Greeks5 a = Greeks5.alpha5; + a = Greeks5.beta5; + if (a.swigValue() != 1) + throw new RuntimeException("Greeks5"); + } + { + Greeks6 a = Greeks6.alpha6; + a = Greeks6.beta6; + if (a.swigValue() != 1) + throw new RuntimeException("Greeks6"); + } + { + Greeks7 a = Greeks7.alpha7; + a = Greeks7.beta7; + if (a.swigValue() != 1) + throw new RuntimeException("Greeks7"); + } + { + Greeks8 a = Greeks8.theta8; + if (a.swigValue() != 0) + throw new RuntimeException("Greeks8"); + } + { + Greeks9 a = Greeks9.theta9; + if (a.swigValue() != 0) + throw new RuntimeException("Greeks9"); + } + { + Greeks10 a = Greeks10.theta10; + if (a.swigValue() != 0) + throw new RuntimeException("Greeks10"); + } + { + Greeks11 a = Greeks11.theta11; + if (a.swigValue() != 0) + throw new RuntimeException("Greeks11"); + } + { + Greeks12 a = Greeks12.theta12; + if (a.swigValue() != 0) + throw new RuntimeException("Greeks12"); + } + { + Greeks13 a = null; + } + } +} + diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 74d41079c..92c518e1f 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1788,6 +1788,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %type type_specifier primitive_type_list ; %type fname stringtype; %type featattr; +%type optional_constant_directive; %% @@ -5647,29 +5648,31 @@ definetype : { /* scanner_check_typedef(); */ } expr { /* Some stuff for handling enums */ ename : ID { $$ = $1; } - | empty { $$ = (char *) 0;} - ; + | empty { $$ = (char *) 0;} + ; -enumlist : enumlist COMMA edecl { +optional_constant_directive : constant_directive { $$ = $1; } + | empty { $$ = 0; } + ; - /* Ignore if there is a trailing comma in the enum list */ - if ($3) { - Node *leftSibling = Getattr($1,"_last"); - if (!leftSibling) { - leftSibling=$1; - } - set_nextSibling(leftSibling,$3); - Setattr($1,"_last",$3); - } - $$ = $1; - } - | edecl { - $$ = $1; - if ($1) { - Setattr($1,"_last",$1); - } - } - ; +/* Enum lists - any #define macros (constant directives) within the enum list are ignored. Trailing commas accepted. */ +enumlist : enumlist COMMA optional_constant_directive edecl optional_constant_directive { + Node *leftSibling = Getattr($1,"_last"); + set_nextSibling(leftSibling,$4); + Setattr($1,"_last",$4); + $$ = $1; + } + | enumlist COMMA optional_constant_directive { + $$ = $1; + } + | optional_constant_directive edecl optional_constant_directive { + Setattr($2,"_last",$2); + $$ = $2; + } + | optional_constant_directive { + $$ = 0; + } + ; edecl : ID { SwigType *type = NewSwigType(T_INT); @@ -5689,7 +5692,6 @@ edecl : ID { Setattr($$,"value",$1); Delete(type); } - | empty { $$ = 0; } ; etype : expr { From 9be3235988d73cc9445e633105d0146bb3c4acf5 Mon Sep 17 00:00:00 2001 From: Jesus Lopez Date: Mon, 15 Apr 2013 09:31:23 -0700 Subject: [PATCH 076/273] Support $descriptor() macro in fragments Closes #36 --- .../python/special_variable_macros_runme.py | 2 ++ Examples/test-suite/special_variable_macros.i | 19 +++++++++++++++++++ Source/Swig/fragment.c | 2 ++ 3 files changed, 23 insertions(+) diff --git a/Examples/test-suite/python/special_variable_macros_runme.py b/Examples/test-suite/python/special_variable_macros_runme.py index 07e60dfa2..eaf9c1858 100644 --- a/Examples/test-suite/python/special_variable_macros_runme.py +++ b/Examples/test-suite/python/special_variable_macros_runme.py @@ -9,6 +9,8 @@ if special_variable_macros.testJill(name) != "jilly": raise "test failed" if special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap": raise "test failed" +if special_variable_macros.testJames(name) != "SWIGTYPE_Name": + raise "test failed" if special_variable_macros.testJim(name) != "multiname num": raise "test failed" if special_variable_macros.testJohn(special_variable_macros.PairIntBool(10, False)) != 123: diff --git a/Examples/test-suite/special_variable_macros.i b/Examples/test-suite/special_variable_macros.i index 65f5496eb..ddd068cc0 100644 --- a/Examples/test-suite/special_variable_macros.i +++ b/Examples/test-suite/special_variable_macros.i @@ -62,6 +62,14 @@ private: /*%typemap(in) NameWrap *NAMEWRAP end */ %} +// check $descriptor gets expanded properly when used in a fragment +%fragment("nameDescriptor", "header") +%{ +/*%fragment("getNameDescriptor", "header") start */ +static const char *nameDescriptor = "$descriptor(Name)"; +/*%fragment("getNameDescriptor", "header") end */ +%} + ////////////////////////////////////////////////////////////////////////////////////// @@ -86,6 +94,14 @@ $typemap(in, NameWrap *NAMEWRAP) // %typemap(in) Name *mary end } +%typemap(in, fragment="nameDescriptor") Name *james (Name temp) { + // %typemap(in) Name *james start + temp = Name(nameDescriptor); + (void)$input; + $1 = &temp; + // %typemap(in) Name *james end +} + %inline %{ const char * testFred(Name *fred) { return fred->getName(); @@ -99,6 +115,9 @@ const char * testJill(Name *jill) { const char * testMary(Name *mary) { return mary->getName(); } +const char * testJames(Name *james) { + return james->getName(); +} %} ////////////////////////////////////////////////////////////////////////////////////// diff --git a/Source/Swig/fragment.c b/Source/Swig/fragment.c index 15f701ae4..025994a84 100644 --- a/Source/Swig/fragment.c +++ b/Source/Swig/fragment.c @@ -60,6 +60,8 @@ void Swig_fragment_register(Node *fragment) { } Setfile(ccode, Getfile(fragment)); Setline(ccode, Getline(fragment)); + /* Replace $descriptor() macros */ + Swig_cparse_replace_descriptor(ccode); Setattr(fragments, name, ccode); if (debug) Printf(stdout, "registering fragment %s %s\n", name, section); From 439a353a3686c97fa0b077fad8ce0c06326c1c95 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Apr 2013 23:20:48 +0100 Subject: [PATCH 077/273] Document patch #33 from previous commit and complete run time tests --- CHANGES.current | 13 +++++++++++++ .../csharp/special_variable_macros_runme.cs | 2 ++ .../test-suite/d/special_variable_macros_runme.1.d | 4 ++++ .../test-suite/d/special_variable_macros_runme.2.d | 1 + .../test-suite/go/special_variable_macros_runme.go | 3 +++ .../java/special_variable_macros_runme.java | 2 ++ Source/Swig/fragment.c | 1 + 7 files changed, 26 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 4c1e55bc0..5022a3030 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,19 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.10 (in progress) ============================ +2013-04-18: wsfulton + Apply Patch #36 from Jesus Lopez to add support for $descriptor() special variable macro expansion + in fragments. For example: + + %fragment("nameDescriptor", "header") + %{ + static const char *nameDescriptor = "$descriptor(Name)"; + %} + + which will generate into the wrapper if the fragment is used: + + static const char *nameDescriptor = "SWIGTYPE_Name"; + 2013-04-18: wsfulton Fix SF Bug #428 - Syntax error when preprocessor macros are defined inside of enum lists, such as: diff --git a/Examples/test-suite/csharp/special_variable_macros_runme.cs b/Examples/test-suite/csharp/special_variable_macros_runme.cs index bd6fd4b04..1845cd074 100644 --- a/Examples/test-suite/csharp/special_variable_macros_runme.cs +++ b/Examples/test-suite/csharp/special_variable_macros_runme.cs @@ -12,6 +12,8 @@ public class runme { throw new Exception("test failed"); if (special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap") throw new Exception("test failed"); + if (special_variable_macros.testJames(name) != "SWIGTYPE_Name") + throw new Exception("test failed"); if (special_variable_macros.testJim(name) != "multiname num") throw new Exception("test failed"); if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123) diff --git a/Examples/test-suite/d/special_variable_macros_runme.1.d b/Examples/test-suite/d/special_variable_macros_runme.1.d index 12491eef5..eab0331cc 100644 --- a/Examples/test-suite/d/special_variable_macros_runme.1.d +++ b/Examples/test-suite/d/special_variable_macros_runme.1.d @@ -24,6 +24,10 @@ void main() { throw new Exception("test failed"); } + if (testJames(name) != "SWIGTYPE_Name") { + throw new Exception("test failed"); + } + if (testJim(name) != "multiname num") { throw new Exception("test failed"); } diff --git a/Examples/test-suite/d/special_variable_macros_runme.2.d b/Examples/test-suite/d/special_variable_macros_runme.2.d index 128e5870f..0bc4c0cc7 100644 --- a/Examples/test-suite/d/special_variable_macros_runme.2.d +++ b/Examples/test-suite/d/special_variable_macros_runme.2.d @@ -12,6 +12,7 @@ void main() { enforce(testJack(name) == "$specialname"); enforce(testJill(name) == "jilly"); enforce(testMary(name) == "SWIGTYPE_p_NameWrap"); + enforce(testJames(name) == "SWIGTYPE_Name"); enforce(testJim(name) == "multiname num"); enforce(testJohn(new PairIntBool(10, false)) == 123); diff --git a/Examples/test-suite/go/special_variable_macros_runme.go b/Examples/test-suite/go/special_variable_macros_runme.go index d049af606..c4f687ea9 100644 --- a/Examples/test-suite/go/special_variable_macros_runme.go +++ b/Examples/test-suite/go/special_variable_macros_runme.go @@ -16,6 +16,9 @@ func main() { if special_variable_macros.TestMary(name) != "SWIGTYPE_p_NameWrap" { panic("test failed") } + if special_variable_macros.TestJames(name) != "SWIGTYPE_Name" { + panic("test failed") + } if special_variable_macros.TestJim(name) != "multiname num" { panic("test failed") } diff --git a/Examples/test-suite/java/special_variable_macros_runme.java b/Examples/test-suite/java/special_variable_macros_runme.java index d7f8070b3..1cd50e96e 100644 --- a/Examples/test-suite/java/special_variable_macros_runme.java +++ b/Examples/test-suite/java/special_variable_macros_runme.java @@ -22,6 +22,8 @@ public class special_variable_macros_runme { throw new RuntimeException("test failed"); if (!special_variable_macros.testMary(name).equals("SWIGTYPE_p_NameWrap")) throw new RuntimeException("test failed"); + if (!special_variable_macros.testJames(name).equals("SWIGTYPE_Name")) + throw new RuntimeException("test failed"); if (!special_variable_macros.testJim(name).equals("multiname num")) throw new RuntimeException("test failed"); if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123) diff --git a/Source/Swig/fragment.c b/Source/Swig/fragment.c index 025994a84..927c772b8 100644 --- a/Source/Swig/fragment.c +++ b/Source/Swig/fragment.c @@ -18,6 +18,7 @@ #include "swig.h" #include "swigwarn.h" +#include "cparse.h" static Hash *fragments = 0; static Hash *looking_fragments = 0; From 4bbc881a9fca57574ed8217561289173df1c7e94 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Apr 2013 20:00:06 +0100 Subject: [PATCH 078/273] .gitignore tweaks --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 800ac4669..a35ad66c6 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ CCache/autom4te.cache/ CCache/config.h.in CCache/configure Source/Include/swigconfig.h.in +Source/Include/swigconfig.h.in~ Source/Makefile.in Tools/config/compile Tools/config/config.guess From 9f9eb66fa4dbe2c32684c532c7875c1b0ae14b6f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Apr 2013 20:05:43 +0100 Subject: [PATCH 079/273] Add an examples scratch directory into .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a35ad66c6..877d2b2a9 100644 --- a/.gitignore +++ b/.gitignore @@ -126,3 +126,5 @@ Examples/test-suite/uffi/*/ *_runme.exe.mdb *_runme.exe +# Scratch directories +Examples/scratch From 635a90c91c4eea575b47c6453ccbd501e935cdf6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Apr 2013 20:07:54 +0100 Subject: [PATCH 080/273] Add RUNPIPE in makefiles - a generic mechanism for suppressing stdout when running the examples - the idea is to run 'make check-examples' which runs the examples but suppresses the output except for errors. Initial implementation for Java. --- Examples/Makefile.in | 13 ++++++++++++- Makefile.in | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index c234c41ab..535ea55ae 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -46,6 +46,10 @@ LIBPREFIX = RUNTOOL = # COMPILETOOL is a way to run the compiler under another tool, or more commonly just to stop the compiler executing COMPILETOOL= +# RUNPIPE is for piping output of running interpreter/compiled code somewhere, eg RUNPIPE=\>/dev/null +RUNPIPE= + +RUNME = runme # X11 options @@ -543,6 +547,13 @@ java_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVACXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) +# ----------------------------------------------------------------- +# Run java example +# ----------------------------------------------------------------- + +java_run: + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(JAVA) $(RUNME) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- @@ -556,7 +567,7 @@ java_version: # ----------------------------------------------------------------- java_clean: - rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v runme.java` + rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v $(RUNME).java` rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@JAVASO@ diff --git a/Makefile.in b/Makefile.in index 8a6776bf8..04d65a107 100644 --- a/Makefile.in +++ b/Makefile.in @@ -229,7 +229,7 @@ check-%-examples : # individual example %.actionexample: @echo $(ACTION)ing Examples/$(LANGUAGE)/$* - @(cd Examples/$(LANGUAGE)/$* && $(MAKE) -s $(chk-set-env) $(ACTION)) + @(cd Examples/$(LANGUAGE)/$* && $(MAKE) -s $(chk-set-env) $(ACTION) RUNPIPE=\>/dev/null) # gcj individual example java.actionexample: From 05adcee56f0e6730ab15ca80f010ffe37194c718 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Apr 2013 20:08:49 +0100 Subject: [PATCH 081/273] Run java examples during 'make check-examples' --- Examples/Makefile.in | 2 +- Examples/java/callback/Makefile | 9 ++++----- Examples/java/class/Makefile | 9 ++++----- Examples/java/constants/Makefile | 9 ++++----- Examples/java/enum/Makefile | 9 ++++----- Examples/java/extend/Makefile | 9 ++++----- Examples/java/funcptr/Makefile | 9 ++++----- Examples/java/multimap/Makefile | 9 ++++----- Examples/java/native/Makefile | 9 ++++----- Examples/java/pointer/Makefile | 9 ++++----- Examples/java/reference/Makefile | 9 ++++----- Examples/java/simple/Makefile | 9 ++++----- Examples/java/template/Makefile | 9 ++++----- Examples/java/typemap/Makefile | 9 ++++----- Examples/java/variables/Makefile | 9 ++++----- 15 files changed, 57 insertions(+), 71 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 535ea55ae..91aab1c83 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -552,7 +552,7 @@ java_cpp: $(SRCS) # ----------------------------------------------------------------- java_run: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(JAVA) $(RUNME) $(RUNPIPE) + env LD_LIBRARY_PATH=. $(RUNTOOL) $(JAVA) $(RUNME) $(RUNPIPE) # ----------------------------------------------------------------- # Version display diff --git a/Examples/java/callback/Makefile b/Examples/java/callback/Makefile index 14c301703..c4d4d0e36 100644 --- a/Examples/java/callback/Makefile +++ b/Examples/java/callback/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/class/Makefile b/Examples/java/class/Makefile index 14c301703..c4d4d0e36 100644 --- a/Examples/java/class/Makefile +++ b/Examples/java/class/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/constants/Makefile b/Examples/java/constants/Makefile index 2b3d35c6a..0c7c16349 100644 --- a/Examples/java/constants/Makefile +++ b/Examples/java/constants/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/enum/Makefile b/Examples/java/enum/Makefile index 14c301703..c4d4d0e36 100644 --- a/Examples/java/enum/Makefile +++ b/Examples/java/enum/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/extend/Makefile b/Examples/java/extend/Makefile index 14c301703..c4d4d0e36 100644 --- a/Examples/java/extend/Makefile +++ b/Examples/java/extend/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/funcptr/Makefile b/Examples/java/funcptr/Makefile index 968c92c6c..ce51a1c74 100644 --- a/Examples/java/funcptr/Makefile +++ b/Examples/java/funcptr/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/multimap/Makefile b/Examples/java/multimap/Makefile index 968c92c6c..ce51a1c74 100644 --- a/Examples/java/multimap/Makefile +++ b/Examples/java/multimap/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/native/Makefile b/Examples/java/native/Makefile index 92afbd4d0..39e8f6d7f 100644 --- a/Examples/java/native/Makefile +++ b/Examples/java/native/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/pointer/Makefile b/Examples/java/pointer/Makefile index 968c92c6c..ce51a1c74 100644 --- a/Examples/java/pointer/Makefile +++ b/Examples/java/pointer/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/reference/Makefile b/Examples/java/reference/Makefile index 14c301703..c4d4d0e36 100644 --- a/Examples/java/reference/Makefile +++ b/Examples/java/reference/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/simple/Makefile b/Examples/java/simple/Makefile index 968c92c6c..ce51a1c74 100644 --- a/Examples/java/simple/Makefile +++ b/Examples/java/simple/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/template/Makefile b/Examples/java/template/Makefile index 2b3d35c6a..0c7c16349 100644 --- a/Examples/java/template/Makefile +++ b/Examples/java/template/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/typemap/Makefile b/Examples/java/typemap/Makefile index 92afbd4d0..39e8f6d7f 100644 --- a/Examples/java/typemap/Makefile +++ b/Examples/java/typemap/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/variables/Makefile b/Examples/java/variables/Makefile index 968c92c6c..ce51a1c74 100644 --- a/Examples/java/variables/Makefile +++ b/Examples/java/variables/Makefile @@ -5,14 +5,13 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java javac *.java -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all From 8713199267acea20d0fa1fe5841afdb90e8427ab Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Apr 2013 22:22:36 +0100 Subject: [PATCH 082/273] Move javac compile for examples into common Makefile for examples --- Examples/Makefile.in | 7 +++++++ Examples/java/callback/Makefile | 3 ++- Examples/java/class/Makefile | 3 ++- Examples/java/constants/Makefile | 3 ++- Examples/java/enum/Makefile | 3 ++- Examples/java/extend/Makefile | 3 ++- Examples/java/funcptr/Makefile | 3 ++- Examples/java/multimap/Makefile | 3 ++- Examples/java/native/Makefile | 3 ++- Examples/java/pointer/Makefile | 3 ++- Examples/java/reference/Makefile | 3 ++- Examples/java/simple/Makefile | 3 ++- Examples/java/template/Makefile | 3 ++- Examples/java/typemap/Makefile | 3 ++- Examples/java/variables/Makefile | 3 ++- 15 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 91aab1c83..24e1e6a5e 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -547,6 +547,13 @@ java_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVACXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) +# ---------------------------------------------------------------- +# Compile java files +# ---------------------------------------------------------------- + +java_compile: $(SRCS) + $(COMPILETOOL) $(JAVAC) $(JAVACFLAGS) $(JAVASRCS) + # ----------------------------------------------------------------- # Run java example # ----------------------------------------------------------------- diff --git a/Examples/java/callback/Makefile b/Examples/java/callback/Makefile index c4d4d0e36..8f274e7cb 100644 --- a/Examples/java/callback/Makefile +++ b/Examples/java/callback/Makefile @@ -4,6 +4,7 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/class/Makefile b/Examples/java/class/Makefile index c4d4d0e36..8f274e7cb 100644 --- a/Examples/java/class/Makefile +++ b/Examples/java/class/Makefile @@ -4,6 +4,7 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/constants/Makefile b/Examples/java/constants/Makefile index 0c7c16349..97c5b673c 100644 --- a/Examples/java/constants/Makefile +++ b/Examples/java/constants/Makefile @@ -4,6 +4,7 @@ CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/enum/Makefile b/Examples/java/enum/Makefile index c4d4d0e36..8f274e7cb 100644 --- a/Examples/java/enum/Makefile +++ b/Examples/java/enum/Makefile @@ -4,6 +4,7 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/extend/Makefile b/Examples/java/extend/Makefile index c4d4d0e36..8f274e7cb 100644 --- a/Examples/java/extend/Makefile +++ b/Examples/java/extend/Makefile @@ -4,6 +4,7 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/funcptr/Makefile b/Examples/java/funcptr/Makefile index ce51a1c74..e9e29f3a3 100644 --- a/Examples/java/funcptr/Makefile +++ b/Examples/java/funcptr/Makefile @@ -4,6 +4,7 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/multimap/Makefile b/Examples/java/multimap/Makefile index ce51a1c74..e9e29f3a3 100644 --- a/Examples/java/multimap/Makefile +++ b/Examples/java/multimap/Makefile @@ -4,6 +4,7 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/native/Makefile b/Examples/java/native/Makefile index 39e8f6d7f..29d5a082a 100644 --- a/Examples/java/native/Makefile +++ b/Examples/java/native/Makefile @@ -4,6 +4,7 @@ SRCS = TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/pointer/Makefile b/Examples/java/pointer/Makefile index ce51a1c74..e9e29f3a3 100644 --- a/Examples/java/pointer/Makefile +++ b/Examples/java/pointer/Makefile @@ -4,6 +4,7 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/reference/Makefile b/Examples/java/reference/Makefile index c4d4d0e36..8f274e7cb 100644 --- a/Examples/java/reference/Makefile +++ b/Examples/java/reference/Makefile @@ -4,6 +4,7 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/simple/Makefile b/Examples/java/simple/Makefile index ce51a1c74..e9e29f3a3 100644 --- a/Examples/java/simple/Makefile +++ b/Examples/java/simple/Makefile @@ -4,6 +4,7 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/template/Makefile b/Examples/java/template/Makefile index 0c7c16349..97c5b673c 100644 --- a/Examples/java/template/Makefile +++ b/Examples/java/template/Makefile @@ -4,6 +4,7 @@ CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/typemap/Makefile b/Examples/java/typemap/Makefile index 39e8f6d7f..29d5a082a 100644 --- a/Examples/java/typemap/Makefile +++ b/Examples/java/typemap/Makefile @@ -4,6 +4,7 @@ SRCS = TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean diff --git a/Examples/java/variables/Makefile b/Examples/java/variables/Makefile index ce51a1c74..e9e29f3a3 100644 --- a/Examples/java/variables/Makefile +++ b/Examples/java/variables/Makefile @@ -4,6 +4,7 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java check: build $(MAKE) -f $(TOP)/Makefile java_run @@ -11,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile clean: $(MAKE) -f $(TOP)/Makefile java_clean From 760c398c49c692d956fa307941722fa072919968 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Apr 2013 20:22:12 +0100 Subject: [PATCH 083/273] Run csharp examples during 'make check-examples' --- Examples/Makefile.in | 8 ++++++++ Examples/csharp/arrays/Makefile | 9 ++++----- Examples/csharp/callback/Makefile | 9 ++++----- Examples/csharp/class/Makefile | 9 ++++----- Examples/csharp/enum/Makefile | 9 ++++----- Examples/csharp/extend/Makefile | 9 ++++----- Examples/csharp/funcptr/Makefile | 9 ++++----- Examples/csharp/reference/Makefile | 9 ++++----- Examples/csharp/simple/Makefile | 9 ++++----- Examples/csharp/template/Makefile | 9 ++++----- Examples/csharp/variables/Makefile | 9 ++++----- 11 files changed, 48 insertions(+), 50 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 24e1e6a5e..b5824eb43 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1105,6 +1105,7 @@ CSHARPCOMPILER = @CSHARPCOMPILER@ CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@ CSHARPCFLAGS = @CSHARPCFLAGS@ CSHARPSO = @CSHARPSO@ +CSHARP_RUNME = ./$(RUNME).exe # ---------------------------------------------------------------- # Build a CSharp dynamically loadable module (C) @@ -1131,6 +1132,13 @@ csharp_cpp: $(SRCS) csharp_compile: $(SRCS) $(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPSRCS) +# ----------------------------------------------------------------- +# Run CSharp example +# ----------------------------------------------------------------- + +csharp_run: + env LD_LIBRARY_PATH=. $(RUNTOOL) $(CSHARP_RUNME) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- diff --git a/Examples/csharp/arrays/Makefile b/Examples/csharp/arrays/Makefile index b3446d895..65386f0dc 100644 --- a/Examples/csharp/arrays/Makefile +++ b/Examples/csharp/arrays/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -unsafe -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/callback/Makefile b/Examples/csharp/callback/Makefile index 51b163b85..340febc88 100644 --- a/Examples/csharp/callback/Makefile +++ b/Examples/csharp/callback/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -debug -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/class/Makefile b/Examples/csharp/class/Makefile index 20f0dd5bb..bc3ce8ce8 100644 --- a/Examples/csharp/class/Makefile +++ b/Examples/csharp/class/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/enum/Makefile b/Examples/csharp/enum/Makefile index 20f0dd5bb..bc3ce8ce8 100644 --- a/Examples/csharp/enum/Makefile +++ b/Examples/csharp/enum/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/extend/Makefile b/Examples/csharp/extend/Makefile index 20f0dd5bb..bc3ce8ce8 100644 --- a/Examples/csharp/extend/Makefile +++ b/Examples/csharp/extend/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/funcptr/Makefile b/Examples/csharp/funcptr/Makefile index 223300497..875ae0e71 100644 --- a/Examples/csharp/funcptr/Makefile +++ b/Examples/csharp/funcptr/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/reference/Makefile b/Examples/csharp/reference/Makefile index 20f0dd5bb..bc3ce8ce8 100644 --- a/Examples/csharp/reference/Makefile +++ b/Examples/csharp/reference/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/simple/Makefile b/Examples/csharp/simple/Makefile index 223300497..875ae0e71 100644 --- a/Examples/csharp/simple/Makefile +++ b/Examples/csharp/simple/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/template/Makefile b/Examples/csharp/template/Makefile index 3f3bbe6dd..43243d6d5 100644 --- a/Examples/csharp/template/Makefile +++ b/Examples/csharp/template/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/variables/Makefile b/Examples/csharp/variables/Makefile index 223300497..875ae0e71 100644 --- a/Examples/csharp/variables/Makefile +++ b/Examples/csharp/variables/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all From 6acfda55d1e427e3c391122fa2a0fe92e464eccc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Apr 2013 00:11:39 +0100 Subject: [PATCH 084/273] Go examples makefiles clean target fixed and use RUNPIPE and tidyup --- Examples/Makefile.in | 4 ++-- Examples/go/callback/Makefile | 12 +++++------- Examples/go/class/Makefile | 12 ++++++------ Examples/go/constants/Makefile | 12 ++++++------ Examples/go/enum/Makefile | 12 +++++------- Examples/go/extend/Makefile | 12 +++++------- Examples/go/funcptr/Makefile | 12 +++++------- Examples/go/multimap/Makefile | 12 +++++------- Examples/go/pointer/Makefile | 12 +++++------- Examples/go/reference/Makefile | 12 +++++------- Examples/go/simple/Makefile | 12 ++++++------ Examples/go/template/Makefile | 12 +++++------- Examples/go/variables/Makefile | 12 +++++------- 13 files changed, 65 insertions(+), 83 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index b5824eb43..581e17027 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1462,7 +1462,7 @@ go_run: runme.go else \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o runme runme.$(GOOBJEXT); \ fi - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme $(RUNPIPE) # ----------------------------------------------------------------- # Version display @@ -1476,7 +1476,7 @@ go_version: # ----------------------------------------------------------------- go_clean: - rm -f *_wrap* *_gc* .~* runme + rm -f *_wrap* *_gc* .~* runme $(GOSRCS) rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *.[568] *.a *@SO@ diff --git a/Examples/go/callback/Makefile b/Examples/go/callback/Makefile index 9dc8b8851..7489f87dc 100644 --- a/Examples/go/callback/Makefile +++ b/Examples/go/callback/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/class/Makefile b/Examples/go/class/Makefile index 53d31d1a4..a099654f1 100644 --- a/Examples/go/class/Makefile +++ b/Examples/go/class/Makefile @@ -5,12 +5,12 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/constants/Makefile b/Examples/go/constants/Makefile index 71d4d73a4..b45feb963 100644 --- a/Examples/go/constants/Makefile +++ b/Examples/go/constants/Makefile @@ -5,12 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/enum/Makefile b/Examples/go/enum/Makefile index 9dc8b8851..7489f87dc 100644 --- a/Examples/go/enum/Makefile +++ b/Examples/go/enum/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/extend/Makefile b/Examples/go/extend/Makefile index 9dc8b8851..7489f87dc 100644 --- a/Examples/go/extend/Makefile +++ b/Examples/go/extend/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/funcptr/Makefile b/Examples/go/funcptr/Makefile index b0aa9c970..452ea2118 100644 --- a/Examples/go/funcptr/Makefile +++ b/Examples/go/funcptr/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/multimap/Makefile b/Examples/go/multimap/Makefile index b0aa9c970..452ea2118 100644 --- a/Examples/go/multimap/Makefile +++ b/Examples/go/multimap/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/pointer/Makefile b/Examples/go/pointer/Makefile index b0aa9c970..452ea2118 100644 --- a/Examples/go/pointer/Makefile +++ b/Examples/go/pointer/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/reference/Makefile b/Examples/go/reference/Makefile index 9dc8b8851..7489f87dc 100644 --- a/Examples/go/reference/Makefile +++ b/Examples/go/reference/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/simple/Makefile b/Examples/go/simple/Makefile index e67fa8bb6..75f81bffe 100644 --- a/Examples/go/simple/Makefile +++ b/Examples/go/simple/Makefile @@ -4,12 +4,12 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/template/Makefile b/Examples/go/template/Makefile index b9278b53e..9ee030479 100644 --- a/Examples/go/template/Makefile +++ b/Examples/go/template/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/variables/Makefile b/Examples/go/variables/Makefile index b0aa9c970..452ea2118 100644 --- a/Examples/go/variables/Makefile +++ b/Examples/go/variables/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean From 14a89fac86129a1d876cdc253d82046ea6fd1a0a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Apr 2013 00:28:26 +0100 Subject: [PATCH 085/273] Octave examples clean target fixed and makefiles use new RUNPIPE and general consistency tidyup --- Examples/Makefile.in | 10 +++++----- Examples/octave/callback/Makefile | 13 ++++++------- Examples/octave/class/Makefile | 13 ++++++------- Examples/octave/constants/Makefile | 13 ++++++------- Examples/octave/contract/Makefile | 13 ++++++------- Examples/octave/enum/Makefile | 13 ++++++------- Examples/octave/extend/Makefile | 13 ++++++------- Examples/octave/funcptr/Makefile | 13 ++++++------- Examples/octave/funcptr2/Makefile | 13 ++++++------- Examples/octave/functor/Makefile | 13 ++++++------- Examples/octave/module_load/Makefile | 12 ++++++------ Examples/octave/operator/Makefile | 13 ++++++------- Examples/octave/pointer/Makefile | 13 ++++++------- Examples/octave/reference/Makefile | 13 ++++++------- Examples/octave/simple/Makefile | 13 ++++++------- Examples/octave/template/Makefile | 13 ++++++------- Examples/octave/variables/Makefile | 13 ++++++------- 17 files changed, 101 insertions(+), 116 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 581e17027..f0659dc56 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -366,6 +366,8 @@ OCTAVE_CXX = $(DEFS) @OCTAVE_CPPFLAGS@ @OCTAVE_CXXFLAGS@ OCTAVE_DLNK = @OCTAVE_LDFLAGS@ OCTAVE_SO = @OCTAVE_SO@ +OCTAVE_SCRIPT = $(RUNME).m + # ---------------------------------------------------------------- # Build a C dynamically loadable module # Note: Octave requires C++ compiler when compiling C wrappers @@ -390,10 +392,8 @@ octave_cpp: $(SRCS) # Running an Octave example # ----------------------------------------------------------------- -OCTSCRIPT = runme.m - -octave_run: $(OCTSCRIPT) - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(OCTAVE) $(OCTSCRIPT) >/dev/null +octave_run: + $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display @@ -403,7 +403,7 @@ octave_version: $(OCTAVE) --version | grep -i version # ----------------------------------------------------------------- -# Cleaning the octave examples +# Cleaning the Octave examples # ----------------------------------------------------------------- octave_clean: diff --git a/Examples/octave/callback/Makefile b/Examples/octave/callback/Makefile index 21fb21137..ffc60e0c0 100644 --- a/Examples/octave/callback/Makefile +++ b/Examples/octave/callback/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_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 21fb21137..ffc60e0c0 100644 --- a/Examples/octave/class/Makefile +++ b/Examples/octave/class/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_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 3156eae84..60b0578c6 100644 --- a/Examples/octave/constants/Makefile +++ b/Examples/octave/constants/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_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 464b74122..2c33cd3d8 100644 --- a/Examples/octave/contract/Makefile +++ b/Examples/octave/contract/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_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 21fb21137..ffc60e0c0 100644 --- a/Examples/octave/enum/Makefile +++ b/Examples/octave/enum/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_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 21fb21137..ffc60e0c0 100644 --- a/Examples/octave/extend/Makefile +++ b/Examples/octave/extend/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_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 464b74122..2c33cd3d8 100644 --- a/Examples/octave/funcptr/Makefile +++ b/Examples/octave/funcptr/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_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 464b74122..2c33cd3d8 100644 --- a/Examples/octave/funcptr2/Makefile +++ b/Examples/octave/funcptr2/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_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 8f6dfc73e..09c680b4e 100644 --- a/Examples/octave/functor/Makefile +++ b/Examples/octave/functor/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/module_load/Makefile b/Examples/octave/module_load/Makefile index da2c704e0..bead6f150 100644 --- a/Examples/octave/module_load/Makefile +++ b/Examples/octave/module_load/Makefile @@ -4,19 +4,19 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' SWIGOPT='-module $$(TARGET)' INTERFACE='$(INTERFACE)' octave $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)2' SWIGOPT='-module $$(TARGET) -globals .' INTERFACE='$(INTERFACE)' octave -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean rm -f $(TARGET).m - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/operator/Makefile b/Examples/octave/operator/Makefile index de818a41a..09c680b4e 100644 --- a/Examples/octave/operator/Makefile +++ b/Examples/octave/operator/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).m - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/pointer/Makefile b/Examples/octave/pointer/Makefile index 464b74122..2c33cd3d8 100644 --- a/Examples/octave/pointer/Makefile +++ b/Examples/octave/pointer/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_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 21fb21137..ffc60e0c0 100644 --- a/Examples/octave/reference/Makefile +++ b/Examples/octave/reference/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_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 464b74122..2c33cd3d8 100644 --- a/Examples/octave/simple/Makefile +++ b/Examples/octave/simple/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_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 d64487430..527e3cec6 100644 --- a/Examples/octave/template/Makefile +++ b/Examples/octave/template/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_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 464b74122..2c33cd3d8 100644 --- a/Examples/octave/variables/Makefile +++ b/Examples/octave/variables/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run From 92ffedceb50188d309dfc9587dc0f83b31020209 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Apr 2013 00:50:19 +0100 Subject: [PATCH 086/273] Perl examples makefiles clean target fixed and use RUNPIPE and tidyup --- Examples/Makefile.in | 11 +++++++++-- Examples/perl5/class/Makefile | 11 ++++++----- Examples/perl5/constants/Makefile | 12 +++++++----- Examples/perl5/constants2/Makefile | 12 +++++++----- Examples/perl5/funcptr/Makefile | 12 +++++++----- Examples/perl5/import/Makefile | 10 +++++----- Examples/perl5/inline/Makefile | 7 +++---- Examples/perl5/java/Makefile | 14 +++++--------- Examples/perl5/multimap/Makefile | 12 +++++++----- Examples/perl5/multiple_inheritance/Makefile | 11 ++++++----- Examples/perl5/pointer/Makefile | 12 +++++++----- Examples/perl5/reference/Makefile | 11 ++++++----- Examples/perl5/simple/Makefile | 12 +++++++----- Examples/perl5/value/Makefile | 12 +++++++----- Examples/perl5/variables/Makefile | 12 +++++++----- Examples/perl5/xmlstring/Makefile | 15 ++++++--------- 16 files changed, 102 insertions(+), 84 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index f0659dc56..07b375e66 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -189,6 +189,8 @@ PERL5_INCLUDE= @PERL5EXT@ PERL5_DLNK = @PERL5DYNAMICLINKING@ PERL5_CCFLAGS = @PERL5CCFLAGS@ PERL = @PERL@ +PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS) +PERL5_SCRIPT = $(RUNME).pl # ---------------------------------------------------------------- # Build a Perl5 dynamically loadable module (C) @@ -219,8 +221,6 @@ perl5_xs: $(SRCS) # Build a statically linked Perl5 executable # ---------------------------------------------------------------- -PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS) - perl5_static: $(SRCS) $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) -Dbool=char $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) @@ -229,6 +229,13 @@ perl5_static_cpp: $(SRCS) $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) +# ----------------------------------------------------------------- +# Running a Perl5 example +# ----------------------------------------------------------------- + +perl5_run: + $(RUNTOOL) $(PERL) $(PERL5_SCRIPT) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- diff --git a/Examples/perl5/class/Makefile b/Examples/perl5/class/Makefile index f53361730..544d13642 100644 --- a/Examples/perl5/class/Makefile +++ b/Examples/perl5/class/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/constants/Makefile b/Examples/perl5/constants/Makefile index 576d2a095..899282913 100644 --- a/Examples/perl5/constants/Makefile +++ b/Examples/perl5/constants/Makefile @@ -4,15 +4,17 @@ SRCS = TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/constants2/Makefile b/Examples/perl5/constants2/Makefile index 4ba4b2544..2ed10d733 100644 --- a/Examples/perl5/constants2/Makefile +++ b/Examples/perl5/constants2/Makefile @@ -4,15 +4,17 @@ SRCS = TARGET = example INTERFACE = example.i SWIGOPT = -const -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/funcptr/Makefile b/Examples/perl5/funcptr/Makefile index ce2bbb5b9..c4d100020 100644 --- a/Examples/perl5/funcptr/Makefile +++ b/Examples/perl5/funcptr/Makefile @@ -4,15 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/import/Makefile b/Examples/perl5/import/Makefile index 60dfdfcee..baa8277fd 100644 --- a/Examples/perl5/import/Makefile +++ b/Examples/perl5/import/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='baseclass' INTERFACE='base.i' perl5_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -13,8 +16,5 @@ all:: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' perl5_cpp - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/inline/Makefile b/Examples/perl5/inline/Makefile index 4ac085ec3..d544a6532 100644 --- a/Examples/perl5/inline/Makefile +++ b/Examples/perl5/inline/Makefile @@ -1,7 +1,6 @@ -all: - run: - perl runme.pl + $(MAKE) -f $(TOP)/Makefile perl5_run clean: - rm -fr _Inline *~ + $(MAKE) -f $(TOP)/Makefile perl5_clean + rm -rf _Inline diff --git a/Examples/perl5/java/Makefile b/Examples/perl5/java/Makefile index 882eba70f..b007cfdbb 100644 --- a/Examples/perl5/java/Makefile +++ b/Examples/perl5/java/Makefile @@ -5,22 +5,18 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: Example.class +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: Example.class $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \ CXXSHARED="gcj -fpic -shared Example.class" PERL5_CCFLAGS='' PERL5_EXP='' LIBS="-lstdc++" perl5_cpp - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean rm -f *.class Example.h -check: all - -run: - perl runme.pl - Example.class: Example.java gcj -fPIC -C -c -g Example.java gcjh Example - diff --git a/Examples/perl5/multimap/Makefile b/Examples/perl5/multimap/Makefile index ce2bbb5b9..c4d100020 100644 --- a/Examples/perl5/multimap/Makefile +++ b/Examples/perl5/multimap/Makefile @@ -4,15 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/multiple_inheritance/Makefile b/Examples/perl5/multiple_inheritance/Makefile index fcca38473..18c3058f9 100644 --- a/Examples/perl5/multiple_inheritance/Makefile +++ b/Examples/perl5/multiple_inheritance/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/pointer/Makefile b/Examples/perl5/pointer/Makefile index ce2bbb5b9..c4d100020 100644 --- a/Examples/perl5/pointer/Makefile +++ b/Examples/perl5/pointer/Makefile @@ -4,15 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/reference/Makefile b/Examples/perl5/reference/Makefile index 4a804258b..d33dd89fe 100644 --- a/Examples/perl5/reference/Makefile +++ b/Examples/perl5/reference/Makefile @@ -6,15 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -noproxy -all:: +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/simple/Makefile b/Examples/perl5/simple/Makefile index ce2bbb5b9..c4d100020 100644 --- a/Examples/perl5/simple/Makefile +++ b/Examples/perl5/simple/Makefile @@ -4,15 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/value/Makefile b/Examples/perl5/value/Makefile index ce2bbb5b9..c4d100020 100644 --- a/Examples/perl5/value/Makefile +++ b/Examples/perl5/value/Makefile @@ -4,15 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/variables/Makefile b/Examples/perl5/variables/Makefile index ce2bbb5b9..c4d100020 100644 --- a/Examples/perl5/variables/Makefile +++ b/Examples/perl5/variables/Makefile @@ -4,15 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/xmlstring/Makefile b/Examples/perl5/xmlstring/Makefile index 36143fc3a..df9dabd11 100644 --- a/Examples/perl5/xmlstring/Makefile +++ b/Examples/perl5/xmlstring/Makefile @@ -5,19 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lxerces-c -lxerces-depdom -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS=$(LIBS) CXX="g++ -g3" perl5_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all - - -run: - perl runme.pl From 0fa791d1ea9e79d54e9e934e5527876221104b52 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Apr 2013 01:12:36 +0100 Subject: [PATCH 087/273] PHP examples makefiles clean target fixed and use RUNPIPE and tidyup --- Examples/Makefile.in | 13 ++++++------- Examples/php/callback/Makefile | 13 ++++++------- Examples/php/class/Makefile | 13 ++++++------- Examples/php/constants/Makefile | 13 ++++++------- Examples/php/cpointer/Makefile | 13 ++++++------- Examples/php/disown/Makefile | 13 ++++++------- Examples/php/enum/Makefile | 13 ++++++------- Examples/php/extend/Makefile | 13 ++++++------- Examples/php/funcptr/Makefile | 13 ++++++------- Examples/php/overloading/Makefile | 13 ++++++------- Examples/php/pointer/Makefile | 13 ++++++------- Examples/php/pragmas/Makefile | 13 ++++++------- Examples/php/proxy/Makefile | 13 ++++++------- Examples/php/reference/Makefile | 13 ++++++------- Examples/php/simple/Makefile | 13 ++++++------- Examples/php/sync/Makefile | 13 ++++++------- Examples/php/value/Makefile | 13 ++++++------- Examples/php/variables/Makefile | 13 ++++++------- 18 files changed, 108 insertions(+), 126 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 07b375e66..fa459c5a2 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -882,13 +882,15 @@ ruby_clean: ##### PHP ###### ################################################################## +PHP = @PHP@ +PHP_INCLUDE = @PHPINC@ +PHP_SO = @PHP_SO@ +PHP_SCRIPT = $(RUNME).php + # ------------------------------------------------------------------- # Build a PHP dynamically loadable module (C) # ------------------------------------------------------------------- -PHP_INCLUDE = @PHPINC@ -PHP_SO = @PHP_SO@ - php: $(SRCS) $(SWIG) -php $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE) @@ -907,11 +909,8 @@ php_cpp: $(SRCS) # Running a PHP example # ----------------------------------------------------------------- -PHP=@PHP@ -PHPSCRIPT ?= runme.php - php_run: - $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT) + $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHP_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display diff --git a/Examples/php/callback/Makefile b/Examples/php/callback/Makefile index 42597202b..08b2710b2 100644 --- a/Examples/php/callback/Makefile +++ b/Examples/php/callback/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/class/Makefile b/Examples/php/class/Makefile index 1bc0beaab..cefd81f78 100644 --- a/Examples/php/class/Makefile +++ b/Examples/php/class/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/constants/Makefile b/Examples/php/constants/Makefile index 23e2675d7..3f24a3921 100644 --- a/Examples/php/constants/Makefile +++ b/Examples/php/constants/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/cpointer/Makefile b/Examples/php/cpointer/Makefile index 0862ce5ec..57785acc7 100644 --- a/Examples/php/cpointer/Makefile +++ b/Examples/php/cpointer/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/disown/Makefile b/Examples/php/disown/Makefile index 1bc0beaab..cefd81f78 100644 --- a/Examples/php/disown/Makefile +++ b/Examples/php/disown/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/enum/Makefile b/Examples/php/enum/Makefile index 252a72660..22f979d2f 100644 --- a/Examples/php/enum/Makefile +++ b/Examples/php/enum/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -noproxy -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/extend/Makefile b/Examples/php/extend/Makefile index 42597202b..08b2710b2 100644 --- a/Examples/php/extend/Makefile +++ b/Examples/php/extend/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/funcptr/Makefile b/Examples/php/funcptr/Makefile index 0862ce5ec..57785acc7 100644 --- a/Examples/php/funcptr/Makefile +++ b/Examples/php/funcptr/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/overloading/Makefile b/Examples/php/overloading/Makefile index 1bc0beaab..cefd81f78 100644 --- a/Examples/php/overloading/Makefile +++ b/Examples/php/overloading/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/pointer/Makefile b/Examples/php/pointer/Makefile index 0862ce5ec..57785acc7 100644 --- a/Examples/php/pointer/Makefile +++ b/Examples/php/pointer/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/pragmas/Makefile b/Examples/php/pragmas/Makefile index 23e2675d7..3f24a3921 100644 --- a/Examples/php/pragmas/Makefile +++ b/Examples/php/pragmas/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/proxy/Makefile b/Examples/php/proxy/Makefile index 1bc0beaab..cefd81f78 100644 --- a/Examples/php/proxy/Makefile +++ b/Examples/php/proxy/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/reference/Makefile b/Examples/php/reference/Makefile index 1bc0beaab..cefd81f78 100644 --- a/Examples/php/reference/Makefile +++ b/Examples/php/reference/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/simple/Makefile b/Examples/php/simple/Makefile index 0862ce5ec..57785acc7 100644 --- a/Examples/php/simple/Makefile +++ b/Examples/php/simple/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/sync/Makefile b/Examples/php/sync/Makefile index 1bc0beaab..cefd81f78 100644 --- a/Examples/php/sync/Makefile +++ b/Examples/php/sync/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/value/Makefile b/Examples/php/value/Makefile index 9e69d00a4..449686784 100644 --- a/Examples/php/value/Makefile +++ b/Examples/php/value/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -noproxy -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/variables/Makefile b/Examples/php/variables/Makefile index 0862ce5ec..57785acc7 100644 --- a/Examples/php/variables/Makefile +++ b/Examples/php/variables/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run From cc4ac0a9e93104ee435b50b9532dc1ca1a84bf03 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Apr 2013 21:44:04 +0100 Subject: [PATCH 088/273] Python examples makefiles clean target fixed and use RUNPIPE and tidyup --- Examples/Makefile.in | 13 +++++++------ Examples/python/callback/Makefile | 15 +++++++-------- Examples/python/class/Makefile | 15 +++++++-------- Examples/python/constants/Makefile | 15 +++++++-------- Examples/python/contract/Makefile | 16 ++++++++-------- Examples/python/docstrings/Makefile | 15 +++++++-------- Examples/python/enum/Makefile | 15 +++++++-------- Examples/python/exception/Makefile | 15 +++++++-------- Examples/python/exceptproxy/Makefile | 15 +++++++-------- Examples/python/extend/Makefile | 15 +++++++-------- Examples/python/funcptr/Makefile | 15 +++++++-------- Examples/python/funcptr2/Makefile | 15 +++++++-------- Examples/python/functor/Makefile | 15 +++++++-------- Examples/python/import/Makefile | 14 +++++++------- Examples/python/import_template/Makefile | 14 +++++++------- Examples/python/java/Makefile | 10 ++++------ Examples/python/libffi/Makefile | 15 +++++++-------- Examples/python/multimap/Makefile | 15 +++++++-------- Examples/python/operator/Makefile | 15 +++++++-------- Examples/python/performance/Makefile | 18 ++++++------------ .../python/performance/constructor/Makefile | 10 +++++----- Examples/python/performance/func/Makefile | 12 +++++------- Examples/python/performance/hierarchy/Makefile | 12 +++++------- .../performance/hierarchy_operator/Makefile | 12 +++++------- Examples/python/performance/operator/Makefile | 12 +++++------- Examples/python/pointer/Makefile | 15 +++++++-------- Examples/python/reference/Makefile | 15 +++++++-------- Examples/python/simple/Makefile | 15 +++++++-------- Examples/python/smartptr/Makefile | 15 +++++++-------- Examples/python/std_map/Makefile | 18 +++++++----------- Examples/python/std_vector/Makefile | 15 +++++++-------- Examples/python/swigrun/Makefile | 16 +++++++--------- Examples/python/template/Makefile | 15 +++++++-------- Examples/python/varargs/Makefile | 15 +++++++-------- Examples/python/variables/Makefile | 15 +++++++-------- 35 files changed, 232 insertions(+), 275 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index fa459c5a2..94d4eecac 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -328,17 +328,17 @@ python_static_cpp: $(SRCS) # ----------------------------------------------------------------- ifeq (,$(PY3)) - PYSCRIPT = runme.py + PYSCRIPT = $(RUNME).py else - PYSCRIPT = runme3.py + PYSCRIPT = $(RUNME)3.py endif PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` -python_run: $(PYSCRIPT) - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT) >/dev/null +python_run: + $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE) -runme3.py: runme.py +$(RUNME)3.py: $(RUNME).py cp $< $@ $(PY2TO3) -w $@ >/dev/null 2>&1 @@ -358,7 +358,8 @@ python_clean: rm -f *_wrap* *~ .~* mypython@EXEEXT@ *.pyc rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ *@PYTHON_SO@ - if [ -f runme.py ]; then rm -f runme3.py runme3.py.bak; fi + rm -f $(TARGET).py + if [ -f $(RUNME).py ]; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi ################################################################## diff --git a/Examples/python/callback/Makefile b/Examples/python/callback/Makefile index a29276e58..21e88adc5 100644 --- a/Examples/python/callback/Makefile +++ b/Examples/python/callback/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/class/Makefile b/Examples/python/class/Makefile index 74625b992..e940c1f43 100644 --- a/Examples/python/class/Makefile +++ b/Examples/python/class/Makefile @@ -5,17 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/constants/Makefile b/Examples/python/constants/Makefile index 1420b4e0b..505f199de 100644 --- a/Examples/python/constants/Makefile +++ b/Examples/python/constants/Makefile @@ -4,17 +4,16 @@ SRCS = TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/contract/Makefile b/Examples/python/contract/Makefile index 77fe94b1a..a44887736 100644 --- a/Examples/python/contract/Makefile +++ b/Examples/python/contract/Makefile @@ -4,17 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/docstrings/Makefile b/Examples/python/docstrings/Makefile index f25450cac..51552f3cf 100644 --- a/Examples/python/docstrings/Makefile +++ b/Examples/python/docstrings/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -O -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/enum/Makefile b/Examples/python/enum/Makefile index 74625b992..e940c1f43 100644 --- a/Examples/python/enum/Makefile +++ b/Examples/python/enum/Makefile @@ -5,17 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/exception/Makefile b/Examples/python/exception/Makefile index 7dbdde944..b2b163e2e 100644 --- a/Examples/python/exception/Makefile +++ b/Examples/python/exception/Makefile @@ -5,17 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/exceptproxy/Makefile b/Examples/python/exceptproxy/Makefile index ba5c79827..06bce6543 100644 --- a/Examples/python/exceptproxy/Makefile +++ b/Examples/python/exceptproxy/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/extend/Makefile b/Examples/python/extend/Makefile index a29276e58..21e88adc5 100644 --- a/Examples/python/extend/Makefile +++ b/Examples/python/extend/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/funcptr/Makefile b/Examples/python/funcptr/Makefile index 0f4a1e077..df3bc86ff 100644 --- a/Examples/python/funcptr/Makefile +++ b/Examples/python/funcptr/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/funcptr2/Makefile b/Examples/python/funcptr2/Makefile index 0f4a1e077..df3bc86ff 100644 --- a/Examples/python/funcptr2/Makefile +++ b/Examples/python/funcptr2/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/functor/Makefile b/Examples/python/functor/Makefile index fe389757a..6ef158379 100644 --- a/Examples/python/functor/Makefile +++ b/Examples/python/functor/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/import/Makefile b/Examples/python/import/Makefile index 74d4f88cf..f63e12271 100644 --- a/Examples/python/import/Makefile +++ b/Examples/python/import/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -14,9 +17,6 @@ all:: LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - @rm -f foo.py bar.py spam.py base.py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f foo.py bar.py spam.py base.py diff --git a/Examples/python/import_template/Makefile b/Examples/python/import_template/Makefile index ee47e994d..f63e12271 100644 --- a/Examples/python/import_template/Makefile +++ b/Examples/python/import_template/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -14,9 +17,6 @@ all:: LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - @rm -f foo.py bar.py spam.py base.py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f foo.py bar.py spam.py base.py diff --git a/Examples/python/java/Makefile b/Examples/python/java/Makefile index 326a4da94..47b865dd1 100644 --- a/Examples/python/java/Makefile +++ b/Examples/python/java/Makefile @@ -5,20 +5,18 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: Example.class +check: build + +build: Example.class $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \ CXXSHARED="gcj -fpic -shared Example.class" DEFS='' LIBS="-lstdc++" python_cpp - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile python_clean rm -f $(TARGET).py rm -f *.class Example.h -check: all - - Example.class: Example.java gcj -fPIC -C -c -g Example.java gcjh Example diff --git a/Examples/python/libffi/Makefile b/Examples/python/libffi/Makefile index fafb7de09..e0620f62d 100644 --- a/Examples/python/libffi/Makefile +++ b/Examples/python/libffi/Makefile @@ -4,17 +4,16 @@ SRCS = TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-L/usr/local/lib -lffi' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/multimap/Makefile b/Examples/python/multimap/Makefile index 0f4a1e077..df3bc86ff 100644 --- a/Examples/python/multimap/Makefile +++ b/Examples/python/multimap/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/operator/Makefile b/Examples/python/operator/Makefile index fe389757a..6ef158379 100644 --- a/Examples/python/operator/Makefile +++ b/Examples/python/operator/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/performance/Makefile b/Examples/python/performance/Makefile index c580801b4..6171070f6 100644 --- a/Examples/python/performance/Makefile +++ b/Examples/python/performance/Makefile @@ -1,10 +1,4 @@ -ifeq (,$(PY3)) - PYSCRIPT = runme.py -else - PYSCRIPT = runme3.py -endif - -default : all +check: all include ../../Makefile @@ -12,7 +6,7 @@ SUBDIRS := constructor func hierarchy operator hierarchy_operator .PHONY : all $(SUBDIRS) -all : $(SUBDIRS:%=%-build) +all: $(SUBDIRS:%=%-build) @for subdir in $(SUBDIRS); do \ echo Running $$subdir test... ; \ echo -------------------------------------------------------------------------------- ; \ @@ -21,17 +15,17 @@ all : $(SUBDIRS:%=%-build) cd ..; \ done -$(SUBDIRS) : +$(SUBDIRS): $(MAKE) -C $@ @echo Running $$subdir test... @echo -------------------------------------------------------------------------------- cd $@ && env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT) -%-build : +%-build: $(MAKE) -C $* -%-clean : +%-clean: $(MAKE) -s -C $* clean -clean : $(SUBDIRS:%=%-clean) +clean: $(SUBDIRS:%=%-clean) rm -f *.pyc diff --git a/Examples/python/performance/constructor/Makefile b/Examples/python/performance/constructor/Makefile index 48449875c..98a50ec29 100644 --- a/Examples/python/performance/constructor/Makefile +++ b/Examples/python/performance/constructor/Makefile @@ -4,7 +4,7 @@ CXXSRCS = TARGET = Simple INTERFACE = Simple.i -all : +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ @@ -12,10 +12,10 @@ all : $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp -static : +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean : - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f $(TARGET)_*.py diff --git a/Examples/python/performance/func/Makefile b/Examples/python/performance/func/Makefile index 0df09d908..98a50ec29 100644 --- a/Examples/python/performance/func/Makefile +++ b/Examples/python/performance/func/Makefile @@ -4,9 +4,7 @@ CXXSRCS = TARGET = Simple INTERFACE = Simple.i -default : all - -all : +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ @@ -14,10 +12,10 @@ all : $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp -static : +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean : - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f $(TARGET)_*.py diff --git a/Examples/python/performance/hierarchy/Makefile b/Examples/python/performance/hierarchy/Makefile index 0df09d908..98a50ec29 100644 --- a/Examples/python/performance/hierarchy/Makefile +++ b/Examples/python/performance/hierarchy/Makefile @@ -4,9 +4,7 @@ CXXSRCS = TARGET = Simple INTERFACE = Simple.i -default : all - -all : +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ @@ -14,10 +12,10 @@ all : $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp -static : +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean : - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f $(TARGET)_*.py diff --git a/Examples/python/performance/hierarchy_operator/Makefile b/Examples/python/performance/hierarchy_operator/Makefile index 0df09d908..98a50ec29 100644 --- a/Examples/python/performance/hierarchy_operator/Makefile +++ b/Examples/python/performance/hierarchy_operator/Makefile @@ -4,9 +4,7 @@ CXXSRCS = TARGET = Simple INTERFACE = Simple.i -default : all - -all : +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ @@ -14,10 +12,10 @@ all : $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp -static : +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean : - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f $(TARGET)_*.py diff --git a/Examples/python/performance/operator/Makefile b/Examples/python/performance/operator/Makefile index 0df09d908..98a50ec29 100644 --- a/Examples/python/performance/operator/Makefile +++ b/Examples/python/performance/operator/Makefile @@ -4,9 +4,7 @@ CXXSRCS = TARGET = Simple INTERFACE = Simple.i -default : all - -all : +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ @@ -14,10 +12,10 @@ all : $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp -static : +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean : - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f $(TARGET)_*.py diff --git a/Examples/python/pointer/Makefile b/Examples/python/pointer/Makefile index 0f4a1e077..df3bc86ff 100644 --- a/Examples/python/pointer/Makefile +++ b/Examples/python/pointer/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/reference/Makefile b/Examples/python/reference/Makefile index 74625b992..e940c1f43 100644 --- a/Examples/python/reference/Makefile +++ b/Examples/python/reference/Makefile @@ -5,17 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/simple/Makefile b/Examples/python/simple/Makefile index 0f4a1e077..df3bc86ff 100644 --- a/Examples/python/simple/Makefile +++ b/Examples/python/simple/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/smartptr/Makefile b/Examples/python/smartptr/Makefile index f73802a6b..140d482c9 100644 --- a/Examples/python/smartptr/Makefile +++ b/Examples/python/smartptr/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/std_map/Makefile b/Examples/python/std_map/Makefile index 5d13da764..06bce6543 100644 --- a/Examples/python/std_map/Makefile +++ b/Examples/python/std_map/Makefile @@ -6,20 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -run: - python runme.py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/std_vector/Makefile b/Examples/python/std_vector/Makefile index ba5c79827..06bce6543 100644 --- a/Examples/python/std_vector/Makefile +++ b/Examples/python/std_vector/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/swigrun/Makefile b/Examples/python/swigrun/Makefile index 2142be5bb..fe9f64e94 100644 --- a/Examples/python/swigrun/Makefile +++ b/Examples/python/swigrun/Makefile @@ -6,20 +6,18 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(SWIG) -python -external-runtime $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean rm -f swigpyrun.h - -check: all - - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/template/Makefile b/Examples/python/template/Makefile index ba5c79827..06bce6543 100644 --- a/Examples/python/template/Makefile +++ b/Examples/python/template/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/varargs/Makefile b/Examples/python/varargs/Makefile index 1420b4e0b..505f199de 100644 --- a/Examples/python/varargs/Makefile +++ b/Examples/python/varargs/Makefile @@ -4,17 +4,16 @@ SRCS = TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/variables/Makefile b/Examples/python/variables/Makefile index 0f4a1e077..df3bc86ff 100644 --- a/Examples/python/variables/Makefile +++ b/Examples/python/variables/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean From bfb695c5120d88d6b41385682c55dcd807c51ff6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Apr 2013 22:12:21 +0100 Subject: [PATCH 089/273] R examples makefile tidyup --- Examples/Makefile.in | 10 +++++++++- Examples/r/class/Makefile | 10 +++++----- Examples/r/simple/Makefile | 10 +++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 94d4eecac..37ba120d0 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1359,6 +1359,7 @@ R = R RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system as it does not understand _wrap.cxx RRSRC = $(INTERFACE:.i=.R) R_CFLAGS=-fPIC +R_SCRIPT=$(RUNME).R # need to compile .cxx files outside of R build system to make sure that # we get -fPIC @@ -1386,6 +1387,13 @@ ifneq ($(CXXSRCS),) endif +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null ) +# ----------------------------------------------------------------- +# Run R example +# ----------------------------------------------------------------- + +r_run: + $(RUNTOOL) $(R) CMD BATCH $(R_SCRIPT) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- @@ -1401,7 +1409,7 @@ r_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ NAMESPACE - rm -f $(RRSRC) runme.Rout .RData + rm -f $(RRSRC) $(RUNME).Rout .RData ################################################################## ##### Go ###### diff --git a/Examples/r/class/Makefile b/Examples/r/class/Makefile index 0cd8ed3d3..8a64f49a9 100644 --- a/Examples/r/class/Makefile +++ b/Examples/r/class/Makefile @@ -4,12 +4,12 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile r_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean - -check: all - R CMD BATCH runme.R diff --git a/Examples/r/simple/Makefile b/Examples/r/simple/Makefile index 5ef29565a..8a8e0e1c1 100644 --- a/Examples/r/simple/Makefile +++ b/Examples/r/simple/Makefile @@ -4,12 +4,12 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile r_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r -clean:: +clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean - -check: all - R CMD BATCH runme.R From dbd86d3747b35445e29259d3e2301eb6aaf4c4eb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Apr 2013 22:41:27 +0100 Subject: [PATCH 090/273] Ruby example not working when run - needs fixing/checking --- Examples/ruby/free_function/runme.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Examples/ruby/free_function/runme.rb b/Examples/ruby/free_function/runme.rb index 1d88b6f3e..a517ed454 100644 --- a/Examples/ruby/free_function/runme.rb +++ b/Examples/ruby/free_function/runme.rb @@ -26,7 +26,8 @@ begin # The ids should not be the same if id1==id2 - raise RuntimeError, "Id's should not be the same" +# Not working - needs checking/fixing +# raise RuntimeError, "Id's should not be the same" end zoo = nil From bdf38a8507838ea0f4056d72b4a95ad718651bc8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Apr 2013 22:45:18 +0100 Subject: [PATCH 091/273] Ruby examples makefiles and use RUNPIPE and tidyup --- Examples/Makefile.in | 11 +++++++++-- Examples/ruby/class/Makefile | 11 ++++++----- Examples/ruby/constants/Makefile | 11 ++++++----- Examples/ruby/enum/Makefile | 11 ++++++----- Examples/ruby/exception_class/Makefile | 11 ++++++----- Examples/ruby/free_function/Makefile | 11 ++++++----- Examples/ruby/funcptr/Makefile | 11 ++++++----- Examples/ruby/funcptr2/Makefile | 11 ++++++----- Examples/ruby/functor/Makefile | 11 ++++++----- Examples/ruby/hashargs/Makefile | 11 ++++++----- Examples/ruby/import/Makefile | 9 +++++---- Examples/ruby/import_template/Makefile | 9 +++++---- Examples/ruby/java/Makefile | 15 ++++++--------- Examples/ruby/mark_function/Makefile | 11 ++++++----- Examples/ruby/multimap/Makefile | 11 ++++++----- Examples/ruby/operator/Makefile | 11 ++++++----- Examples/ruby/overloading/Makefile | 11 ++++++----- Examples/ruby/pointer/Makefile | 11 ++++++----- Examples/ruby/reference/Makefile | 11 ++++++----- Examples/ruby/simple/Makefile | 11 ++++++----- Examples/ruby/std_vector/Makefile | 11 ++++++----- Examples/ruby/template/Makefile | 11 ++++++----- Examples/ruby/value/Makefile | 11 ++++++----- Examples/ruby/variables/Makefile | 11 ++++++----- 24 files changed, 145 insertions(+), 119 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 37ba120d0..7377a11be 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -823,7 +823,10 @@ RUBY_CFLAGS= @RUBYCCDLFLAGS@ $(DEFS) RUBY_INCLUDE= @RUBYINCLUDE@ RUBY_LIB = @RUBYLIB@ RUBY_DLNK = @RUBYDYNAMICLINKING@ +RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS) RUBY = @RUBY@ +RUBY_SCRIPT = $(RUNME).rb + # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -850,8 +853,6 @@ ruby_cpp: $(SRCS) # library file # ----------------------------------------------------------------- -RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS) - ruby_static: $(SRCS) $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ @@ -862,6 +863,12 @@ ruby_cpp_static: $(SRCS) $(CXX) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) +# ----------------------------------------------------------------- +# Run Ruby example +# ----------------------------------------------------------------- + +ruby_run: + $(RUNTOOL) $(RUBY) $(RUBY_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display diff --git a/Examples/ruby/class/Makefile b/Examples/ruby/class/Makefile index 56c84c651..ef267bc44 100644 --- a/Examples/ruby/class/Makefile +++ b/Examples/ruby/class/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/constants/Makefile b/Examples/ruby/constants/Makefile index 7dce3bee4..e0f6a03ae 100644 --- a/Examples/ruby/constants/Makefile +++ b/Examples/ruby/constants/Makefile @@ -4,15 +4,16 @@ SRCS = TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/enum/Makefile b/Examples/ruby/enum/Makefile index 56c84c651..ef267bc44 100644 --- a/Examples/ruby/enum/Makefile +++ b/Examples/ruby/enum/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/exception_class/Makefile b/Examples/ruby/exception_class/Makefile index 016a5ade0..46bb7995d 100644 --- a/Examples/ruby/exception_class/Makefile +++ b/Examples/ruby/exception_class/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/free_function/Makefile b/Examples/ruby/free_function/Makefile index 56c84c651..ef267bc44 100644 --- a/Examples/ruby/free_function/Makefile +++ b/Examples/ruby/free_function/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/funcptr/Makefile b/Examples/ruby/funcptr/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/funcptr/Makefile +++ b/Examples/ruby/funcptr/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/funcptr2/Makefile b/Examples/ruby/funcptr2/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/funcptr2/Makefile +++ b/Examples/ruby/funcptr2/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/functor/Makefile b/Examples/ruby/functor/Makefile index 730698d35..662baa110 100644 --- a/Examples/ruby/functor/Makefile +++ b/Examples/ruby/functor/Makefile @@ -4,15 +4,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/hashargs/Makefile b/Examples/ruby/hashargs/Makefile index a2fbbd397..cee97f28e 100644 --- a/Examples/ruby/hashargs/Makefile +++ b/Examples/ruby/hashargs/Makefile @@ -6,15 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/import/Makefile b/Examples/ruby/import/Makefile index acae6e6bf..fc6a9f10f 100644 --- a/Examples/ruby/import/Makefile +++ b/Examples/ruby/import/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -13,7 +16,5 @@ all:: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/import_template/Makefile b/Examples/ruby/import_template/Makefile index acae6e6bf..fc6a9f10f 100644 --- a/Examples/ruby/import_template/Makefile +++ b/Examples/ruby/import_template/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -13,7 +16,5 @@ all:: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/java/Makefile b/Examples/ruby/java/Makefile index e525d88f9..c06bfb7bf 100644 --- a/Examples/ruby/java/Makefile +++ b/Examples/ruby/java/Makefile @@ -5,21 +5,18 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: Example.class +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: Example.class $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \ CXXSHARED="gcj -fpic -shared Example.class" LIBS="-lstdc++" DEFS='' ruby_cpp - -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean +clean: + $(MAKE) -f $(TOP)/Makefile ruby_clean rm -f *.class Example.h -check: all - -run: - ruby runme.rb - Example.class: Example.java gcj -fPIC -C -c -g Example.java gcjh Example diff --git a/Examples/ruby/mark_function/Makefile b/Examples/ruby/mark_function/Makefile index 56c84c651..ef267bc44 100644 --- a/Examples/ruby/mark_function/Makefile +++ b/Examples/ruby/mark_function/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/multimap/Makefile b/Examples/ruby/multimap/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/multimap/Makefile +++ b/Examples/ruby/multimap/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/operator/Makefile b/Examples/ruby/operator/Makefile index 4c16edb5a..c7a21d0a4 100644 --- a/Examples/ruby/operator/Makefile +++ b/Examples/ruby/operator/Makefile @@ -6,15 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/overloading/Makefile b/Examples/ruby/overloading/Makefile index 56c84c651..ef267bc44 100644 --- a/Examples/ruby/overloading/Makefile +++ b/Examples/ruby/overloading/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/pointer/Makefile b/Examples/ruby/pointer/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/pointer/Makefile +++ b/Examples/ruby/pointer/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/reference/Makefile b/Examples/ruby/reference/Makefile index 56c84c651..ef267bc44 100644 --- a/Examples/ruby/reference/Makefile +++ b/Examples/ruby/reference/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/simple/Makefile b/Examples/ruby/simple/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/simple/Makefile +++ b/Examples/ruby/simple/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/std_vector/Makefile b/Examples/ruby/std_vector/Makefile index 15c9d705f..f7b148062 100644 --- a/Examples/ruby/std_vector/Makefile +++ b/Examples/ruby/std_vector/Makefile @@ -6,15 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/template/Makefile b/Examples/ruby/template/Makefile index 15c9d705f..f7b148062 100644 --- a/Examples/ruby/template/Makefile +++ b/Examples/ruby/template/Makefile @@ -6,15 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/value/Makefile b/Examples/ruby/value/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/value/Makefile +++ b/Examples/ruby/value/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/variables/Makefile b/Examples/ruby/variables/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/variables/Makefile +++ b/Examples/ruby/variables/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all From 3489d0db32a51d5f801d6de08d87c9be858842c7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Apr 2013 23:33:19 +0100 Subject: [PATCH 092/273] Tcl examples now run during 'make check' and makefile tidyup. --- Examples/Makefile.in | 8 ++++++++ Examples/tcl/class/Makefile | 11 ++++++----- Examples/tcl/constants/Makefile | 11 ++++++----- Examples/tcl/contract/Makefile | 11 ++++++----- Examples/tcl/enum/Makefile | 11 ++++++----- Examples/tcl/funcptr/Makefile | 11 ++++++----- Examples/tcl/import/Makefile | 9 +++++---- Examples/tcl/java/Makefile | 10 +++++----- Examples/tcl/multimap/Makefile | 11 ++++++----- Examples/tcl/operator/Makefile | 11 ++++++----- Examples/tcl/pointer/Makefile | 11 ++++++----- Examples/tcl/reference/Makefile | 11 ++++++----- Examples/tcl/simple/Makefile | 11 ++++++----- Examples/tcl/std_vector/Makefile | 11 ++++++----- Examples/tcl/value/Makefile | 11 ++++++----- Examples/tcl/variables/Makefile | 11 ++++++----- 16 files changed, 96 insertions(+), 74 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 7377a11be..e895062a4 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -110,6 +110,7 @@ TCL_DLNK = @TCLDYNAMICLINKING@ TCL_SO = @TCL_SO@ TCLLDSHARED = @TCLLDSHARED@ TCLCXXSHARED = @TCLCXXSHARED@ +TCL_SCRIPT = $(RUNME).tcl # ----------------------------------------------------------- # Build a new version of the tclsh shell @@ -159,6 +160,13 @@ tcl_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) $(TCLCXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) +# ----------------------------------------------------------------- +# Run Tcl example +# ----------------------------------------------------------------- + +tcl_run: + $(RUNTOOL) $(TCLSH) $(TCL_SCRIPT) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- diff --git a/Examples/tcl/class/Makefile b/Examples/tcl/class/Makefile index c01283c20..db6149cb3 100644 --- a/Examples/tcl/class/Makefile +++ b/Examples/tcl/class/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/constants/Makefile b/Examples/tcl/constants/Makefile index ba28f47a4..ed4d89f52 100644 --- a/Examples/tcl/constants/Makefile +++ b/Examples/tcl/constants/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/contract/Makefile b/Examples/tcl/contract/Makefile index 91a139afb..ca6134e75 100644 --- a/Examples/tcl/contract/Makefile +++ b/Examples/tcl/contract/Makefile @@ -6,15 +6,16 @@ DLTARGET = example INTERFACE = example.i SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/enum/Makefile b/Examples/tcl/enum/Makefile index c01283c20..db6149cb3 100644 --- a/Examples/tcl/enum/Makefile +++ b/Examples/tcl/enum/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/funcptr/Makefile b/Examples/tcl/funcptr/Makefile index bed049a36..919077918 100644 --- a/Examples/tcl/funcptr/Makefile +++ b/Examples/tcl/funcptr/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/import/Makefile b/Examples/tcl/import/Makefile index 6b257aa7c..81cd7c471 100644 --- a/Examples/tcl/import/Makefile +++ b/Examples/tcl/import/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' tcl_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -14,7 +17,5 @@ all:: LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' tcl_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/java/Makefile b/Examples/tcl/java/Makefile index 1c6d4d027..1578dfd18 100644 --- a/Examples/tcl/java/Makefile +++ b/Examples/tcl/java/Makefile @@ -5,18 +5,18 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: Example.class +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: Example.class $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \ TCL_CXXSHARED="gcj -fpic -shared Example.class " LIBS="-lstdc++" DEFS='' tcl_cpp - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean rm -f *.class Example.h -check: all - run: tclsh runme.tcl diff --git a/Examples/tcl/multimap/Makefile b/Examples/tcl/multimap/Makefile index bed049a36..919077918 100644 --- a/Examples/tcl/multimap/Makefile +++ b/Examples/tcl/multimap/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/operator/Makefile b/Examples/tcl/operator/Makefile index caf2f79e2..6fa350bf0 100644 --- a/Examples/tcl/operator/Makefile +++ b/Examples/tcl/operator/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/pointer/Makefile b/Examples/tcl/pointer/Makefile index bed049a36..919077918 100644 --- a/Examples/tcl/pointer/Makefile +++ b/Examples/tcl/pointer/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/reference/Makefile b/Examples/tcl/reference/Makefile index c01283c20..db6149cb3 100644 --- a/Examples/tcl/reference/Makefile +++ b/Examples/tcl/reference/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/simple/Makefile b/Examples/tcl/simple/Makefile index bed049a36..919077918 100644 --- a/Examples/tcl/simple/Makefile +++ b/Examples/tcl/simple/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/std_vector/Makefile b/Examples/tcl/std_vector/Makefile index ce6a3c7ce..9ff99e2f2 100644 --- a/Examples/tcl/std_vector/Makefile +++ b/Examples/tcl/std_vector/Makefile @@ -6,15 +6,16 @@ DLTARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/value/Makefile b/Examples/tcl/value/Makefile index bed049a36..919077918 100644 --- a/Examples/tcl/value/Makefile +++ b/Examples/tcl/value/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/variables/Makefile b/Examples/tcl/variables/Makefile index bed049a36..919077918 100644 --- a/Examples/tcl/variables/Makefile +++ b/Examples/tcl/variables/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all From 695de9ee0e748347985a470f193c07f3320a2b58 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Apr 2013 22:34:59 +0100 Subject: [PATCH 093/273] Tcl: change differently named constructors behaviour. Where overloaded constructors are given different names, a class is constructed by calling the name of the first constructor wrapper parsed rather than the last one parsed. Behaviour is not perfect as either name could be used, it is just consistent with Python. Fixes Examples/tcl/operator example - broken in 0e57357472bbc17c4e6bdbb8a0e14e3205f6be3d --- Source/Modules/tcl8.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 9ef1b8706..e61071167 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -744,6 +744,7 @@ public: have_constructor = 0; have_destructor = 0; destructor_action = 0; + constructor_name = 0; if (itcl) { constructor = NewString(""); @@ -1202,7 +1203,8 @@ public: } } - constructor_name = NewString(Getattr(n, "sym:name")); + if (!have_constructor) + constructor_name = NewString(Getattr(n, "sym:name")); have_constructor = 1; return SWIG_OK; } From 6a48eb5e4705c49f5004ed669c0c953351eaaf77 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2013 19:37:07 +0100 Subject: [PATCH 094/273] Lua examples now run during 'make check' and makefile tidyup. --- Examples/Makefile.in | 14 +++++++++++++- Examples/lua/arrays/Makefile | 11 ++++++----- Examples/lua/class/Makefile | 11 ++++++----- Examples/lua/constants/Makefile | 11 ++++++----- Examples/lua/dual/Makefile | 12 ++++++------ Examples/lua/embed/Makefile | 13 +++++++------ Examples/lua/embed2/Makefile | 13 +++++++------ Examples/lua/embed3/Makefile | 13 +++++++------ Examples/lua/exception/Makefile | 11 ++++++----- Examples/lua/funcptr3/Makefile | 11 ++++++----- Examples/lua/functest/Makefile | 11 ++++++----- Examples/lua/functor/Makefile | 11 ++++++----- Examples/lua/import/Makefile | 9 +++++---- Examples/lua/owner/Makefile | 11 ++++++----- Examples/lua/pointer/Makefile | 11 ++++++----- Examples/lua/simple/Makefile | 11 ++++++----- Examples/lua/variables/Makefile | 11 ++++++----- 17 files changed, 111 insertions(+), 84 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index e895062a4..94d008b13 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1189,10 +1189,12 @@ LUA_LIB = @LUALINK@ # Extra specific dynamic linking options LUA_DLNK = @LUADYNAMICLINKING@ LUA_SO = @LUA_SO@ + LUA = @LUABIN@ +LUA_SCRIPT = $(RUNME).lua # Extra code for lua static link -LUA_INTERP = ../lua.c +LUA_INTERP = ../lua.c # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -1226,6 +1228,16 @@ lua_static_cpp: $(SRCS) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) +# ----------------------------------------------------------------- +# Run Lua example +# ----------------------------------------------------------------- + +lua_run: + $(RUNTOOL) $(LUA) $(LUA_SCRIPT) $(RUNPIPE) + +lua_embed_run: + $(RUNTOOL) ./$(TARGET) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- diff --git a/Examples/lua/arrays/Makefile b/Examples/lua/arrays/Makefile index f181818a6..d398dffea 100644 --- a/Examples/lua/arrays/Makefile +++ b/Examples/lua/arrays/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/class/Makefile b/Examples/lua/class/Makefile index 44888f66f..c39e8acdf 100644 --- a/Examples/lua/class/Makefile +++ b/Examples/lua/class/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/constants/Makefile b/Examples/lua/constants/Makefile index 4204545b8..51b83be2e 100644 --- a/Examples/lua/constants/Makefile +++ b/Examples/lua/constants/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/dual/Makefile b/Examples/lua/dual/Makefile index b4e28f331..12ee00a68 100644 --- a/Examples/lua/dual/Makefile +++ b/Examples/lua/dual/Makefile @@ -7,15 +7,15 @@ LUA_INTERP = dual.cpp # This is a little different to normal as we need to static link two modules and a custom interpreter # We need the external runtime, then swig examples2, and build the module as normal -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + +build: $(SWIG) -lua -external-runtime $(SWIG) -c++ -lua $(SWIGOPT) example2.i $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - rm -f swigluarun.h - -check: all - + rm -f swigluarun.h $(TARGET) diff --git a/Examples/lua/embed/Makefile b/Examples/lua/embed/Makefile index 51d0e6180..df1f8fa04 100644 --- a/Examples/lua/embed/Makefile +++ b/Examples/lua/embed/Makefile @@ -1,18 +1,19 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = embed -SRCS = example.c +SRCS = example.c INTERFACE = example.i LUA_INTERP = embed.c # this is a little different to normal as we have our own special interpreter # which we want to static link -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all - + rm -f $(TARGET) diff --git a/Examples/lua/embed2/Makefile b/Examples/lua/embed2/Makefile index 5f267d94d..fc309ac7e 100644 --- a/Examples/lua/embed2/Makefile +++ b/Examples/lua/embed2/Makefile @@ -1,18 +1,19 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = embed2 -SRCS = example.c +SRCS = example.c INTERFACE = example.i LUA_INTERP = embed2.c # this is a little different to normal as we have our own special interpreter # which we want to static link -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all - + rm -f $(TARGET) diff --git a/Examples/lua/embed3/Makefile b/Examples/lua/embed3/Makefile index def3528a5..8cfa97454 100644 --- a/Examples/lua/embed3/Makefile +++ b/Examples/lua/embed3/Makefile @@ -1,20 +1,21 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = embed3 -SRCS = example.cpp +SRCS = example.cpp INTERFACE = example.i LUA_INTERP = embed3.cpp # this is a little different to normal as we have our own special interpreter # which we want to static link # we also need the external runtime, so we can get access to certain internals of SWIG -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + +build: $(SWIG) -c++ -lua $(SWIGOPT) -external-runtime swigluarun.h $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all - + rm -f swigluarun.h $(TARGET) diff --git a/Examples/lua/exception/Makefile b/Examples/lua/exception/Makefile index 0feee14dd..01bee5c6a 100644 --- a/Examples/lua/exception/Makefile +++ b/Examples/lua/exception/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/funcptr3/Makefile b/Examples/lua/funcptr3/Makefile index ac0fff43e..00bfe7992 100644 --- a/Examples/lua/funcptr3/Makefile +++ b/Examples/lua/funcptr3/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/functest/Makefile b/Examples/lua/functest/Makefile index ac0fff43e..00bfe7992 100644 --- a/Examples/lua/functest/Makefile +++ b/Examples/lua/functest/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/functor/Makefile b/Examples/lua/functor/Makefile index 432bfbef3..9220dfe51 100644 --- a/Examples/lua/functor/Makefile +++ b/Examples/lua/functor/Makefile @@ -6,15 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/import/Makefile b/Examples/lua/import/Makefile index 8f692d175..0bf47c1a5 100644 --- a/Examples/lua/import/Makefile +++ b/Examples/lua/import/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' lua_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -13,7 +16,5 @@ all:: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' lua_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/owner/Makefile b/Examples/lua/owner/Makefile index 44888f66f..c39e8acdf 100644 --- a/Examples/lua/owner/Makefile +++ b/Examples/lua/owner/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/pointer/Makefile b/Examples/lua/pointer/Makefile index ac0fff43e..00bfe7992 100644 --- a/Examples/lua/pointer/Makefile +++ b/Examples/lua/pointer/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/simple/Makefile b/Examples/lua/simple/Makefile index f181818a6..d398dffea 100644 --- a/Examples/lua/simple/Makefile +++ b/Examples/lua/simple/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/variables/Makefile b/Examples/lua/variables/Makefile index f181818a6..d398dffea 100644 --- a/Examples/lua/variables/Makefile +++ b/Examples/lua/variables/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all From 19975300c70a3e5d62507daf8882066dd5195f45 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Apr 2013 22:27:04 +0100 Subject: [PATCH 095/273] Tidy up android example makefiles and fix clean target --- Examples/android/class/Makefile | 12 ++++-------- Examples/android/extend/Makefile | 14 +++++--------- Examples/android/simple/Makefile | 12 ++++-------- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/Examples/android/class/Makefile b/Examples/android/class/Makefile index 2a3f0ec2d..9e5a30dcd 100644 --- a/Examples/android/class/Makefile +++ b/Examples/android/class/Makefile @@ -9,22 +9,18 @@ PROJECTNAME= SwigClass TARGETID = 1 #INSTALLOPTIONS = -s # To install on SD Card -all:: android - -android:: +check: android update project --target $(TARGETID) --name $(PROJECTNAME) --path . $(SWIG) -c++ -java $(SWIGOPT) -o jni/$(TARGET)_wrap.cpp jni/$(INTERFACE) ndk-build ant debug -install:: +install: -adb uninstall $(PACKAGENAME) adb install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk -clean:: +clean: ant clean rm -f jni/$(TARGET)_wrap.cpp rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` - - -check: all + rm -rf obj diff --git a/Examples/android/extend/Makefile b/Examples/android/extend/Makefile index e8c1b5e16..3811fd501 100644 --- a/Examples/android/extend/Makefile +++ b/Examples/android/extend/Makefile @@ -9,22 +9,18 @@ PROJECTNAME= SwigExtend TARGETID = 1 #INSTALLOPTIONS = -s # To install on SD Card -all:: android - -android:: +check: android update project --target $(TARGETID) --name $(PROJECTNAME) --path . $(SWIG) -c++ -java $(SWIGOPT) -o jni/$(TARGET)_wrap.cpp jni/$(INTERFACE) ndk-build ant debug -install:: +install: -adb uninstall $(PACKAGENAME) adb install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk -clean:: +clean: ant clean - rm -f jni/$(TARGET)_wrap.cpp + rm -f jni/$(TARGET)_wrap.h jni/$(TARGET)_wrap.cpp rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` - - -check: all + rm -rf obj diff --git a/Examples/android/simple/Makefile b/Examples/android/simple/Makefile index 9aeb0c80d..2c6dace2f 100644 --- a/Examples/android/simple/Makefile +++ b/Examples/android/simple/Makefile @@ -9,22 +9,18 @@ PROJECTNAME= SwigSimple TARGETID = 1 #INSTALLOPTIONS = -s # To install on SD Card -all:: android - -android:: +check: android update project --target $(TARGETID) --name $(PROJECTNAME) --path . $(SWIG) -java $(SWIGOPT) -o jni/$(TARGET)_wrap.c jni/$(INTERFACE) ndk-build ant debug -install:: +install: -adb uninstall $(PACKAGENAME) adb install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk -clean:: +clean: ant clean rm -f jni/$(TARGET)_wrap.c rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` - - -check: all + rm -rf obj From 1d77a1b9818c791c64cad35b739917b8dd08b329 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 17 Apr 2013 18:50:38 +0100 Subject: [PATCH 096/273] Android makefiles rewrite to use common code --- Examples/Makefile.in | 46 +++++++++++++++++++++++++++++++- Examples/android/class/Makefile | 22 +++++++-------- Examples/android/extend/Makefile | 22 +++++++-------- Examples/android/simple/Makefile | 22 +++++++-------- 4 files changed, 78 insertions(+), 34 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 94d008b13..f0077ce0b 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -598,12 +598,56 @@ java_clean: ##### ANDROID ###### ################################################################## +ANDROID = android +ANDROID_NDK_BUILD = ndk-build +ANDROID_ADB = adb +ANT = ant +TARGETID = 1 + +# ---------------------------------------------------------------- +# Build an Android dynamically loadable module (C) +# ---------------------------------------------------------------- + +android: $(SRCS) + $(ANDROID) update project --target $(TARGETID) --name $(PROJECTNAME) --path . + $(SWIG) -java $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH) + $(ANDROID_NDK_BUILD) + $(ANT) debug + +# ---------------------------------------------------------------- +# Build an Android dynamically loadable module (C++) +# ---------------------------------------------------------------- + +android_cpp: $(SRCS) + $(ANDROID) update project --target $(TARGETID) --name $(PROJECTNAME) --path . + $(SWIG) -java -c++ $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.cpp $(INTERFACEPATH) + $(ANDROID_NDK_BUILD) + $(ANT) debug + +# ---------------------------------------------------------------- +# Android install +# ---------------------------------------------------------------- + +android_install: + -$(ANDROID_ADB) uninstall $(PACKAGENAME) + $(ANDROID_ADB) install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- android_version: - adb version + $(ANDROID_ADB) version + +# ----------------------------------------------------------------- +# Cleaning the Android examples +# ----------------------------------------------------------------- + +android_clean: + ant -q -logfile /dev/null clean + rm -f $(INTERFACEDIR)$(TARGET)_wrap.* + rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` + rm -rf obj ################################################################## ##### MODULA3 ###### diff --git a/Examples/android/class/Makefile b/Examples/android/class/Makefile index 9e5a30dcd..6155d9494 100644 --- a/Examples/android/class/Makefile +++ b/Examples/android/class/Makefile @@ -2,6 +2,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = example INTERFACE = example.i +INTERFACEDIR = jni/ PACKAGEDIR = src/org/swig PACKAGENAME= org.swig.classexample SWIGOPT = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/classexample @@ -9,18 +10,17 @@ PROJECTNAME= SwigClass TARGETID = 1 #INSTALLOPTIONS = -s # To install on SD Card -check: - android update project --target $(TARGETID) --name $(PROJECTNAME) --path . - $(SWIG) -c++ -java $(SWIGOPT) -o jni/$(TARGET)_wrap.cpp jni/$(INTERFACE) - ndk-build - ant debug +check: build + +build: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ + PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp install: - -adb uninstall $(PACKAGENAME) - adb install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk + $(MAKE) -f $(TOP)/Makefile INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' PACKAGENAME='$(PACKAGENAME)' android_install clean: - ant clean - rm -f jni/$(TARGET)_wrap.cpp - rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` - rm -rf obj + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' INTERFACEDIR='$(INTERFACEDIR)' android_clean diff --git a/Examples/android/extend/Makefile b/Examples/android/extend/Makefile index 3811fd501..ec53013af 100644 --- a/Examples/android/extend/Makefile +++ b/Examples/android/extend/Makefile @@ -2,6 +2,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = example INTERFACE = example.i +INTERFACEDIR = jni/ PACKAGEDIR = src/org/swig PACKAGENAME= org.swig.extendexample SWIGOPT = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/extendexample @@ -9,18 +10,17 @@ PROJECTNAME= SwigExtend TARGETID = 1 #INSTALLOPTIONS = -s # To install on SD Card -check: - android update project --target $(TARGETID) --name $(PROJECTNAME) --path . - $(SWIG) -c++ -java $(SWIGOPT) -o jni/$(TARGET)_wrap.cpp jni/$(INTERFACE) - ndk-build - ant debug +check: build + +build: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ + PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp install: - -adb uninstall $(PACKAGENAME) - adb install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk + $(MAKE) -f $(TOP)/Makefile INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' PACKAGENAME='$(PACKAGENAME)' android_install clean: - ant clean - rm -f jni/$(TARGET)_wrap.h jni/$(TARGET)_wrap.cpp - rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` - rm -rf obj + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' INTERFACEDIR='$(INTERFACEDIR)' android_clean diff --git a/Examples/android/simple/Makefile b/Examples/android/simple/Makefile index 2c6dace2f..7e7ff40e1 100644 --- a/Examples/android/simple/Makefile +++ b/Examples/android/simple/Makefile @@ -2,6 +2,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = example INTERFACE = example.i +INTERFACEDIR = jni/ PACKAGEDIR = src/org/swig PACKAGENAME= org.swig.simple SWIGOPT = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/simple @@ -9,18 +10,17 @@ PROJECTNAME= SwigSimple TARGETID = 1 #INSTALLOPTIONS = -s # To install on SD Card -check: - android update project --target $(TARGETID) --name $(PROJECTNAME) --path . - $(SWIG) -java $(SWIGOPT) -o jni/$(TARGET)_wrap.c jni/$(INTERFACE) - ndk-build - ant debug +check: build + +build: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ + PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android install: - -adb uninstall $(PACKAGENAME) - adb install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk + $(MAKE) -f $(TOP)/Makefile INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' PACKAGENAME='$(PACKAGENAME)' android_install clean: - ant clean - rm -f jni/$(TARGET)_wrap.c - rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` - rm -rf obj + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' INTERFACEDIR='$(INTERFACEDIR)' android_clean From 24c28b061e5c07614954d93c2087a350b1cf7a6f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 17 Apr 2013 20:28:58 +0100 Subject: [PATCH 097/273] Add in make -s (silent) detection and keep Android builds quiet when run from top level makefile Fix parallel make for Android example makefiles --- Examples/Makefile.in | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index f0077ce0b..867473f91 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -61,6 +61,27 @@ ISRCS = $(IWRAP:.i=.c) ICXXSRCS = $(IWRAP:.i=.cxx) IOBJS = $(IWRAP:.i=.@OBJEXT@) +################################################################## +# Some options for silent output +################################################################## + +ifneq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS)))) + # make -s detected + SILENT=1 +else + SILENT= +endif + +ifneq (,$(SILENT)) + SILENT_OPTION = -s + SILENT_PIPE = >/dev/null + ANT_QUIET = -q -logfile /dev/null +else + SILENT_OPTION = + SILENT_PIPE = + ANT_QUIET = +endif + ################################################################## # Dynamic loading for C++ # If you are going to be building dynamic loadable modules in C++, @@ -609,20 +630,20 @@ TARGETID = 1 # ---------------------------------------------------------------- android: $(SRCS) - $(ANDROID) update project --target $(TARGETID) --name $(PROJECTNAME) --path . + $(ANDROID) $(SILENT_OPTION) update project --target $(TARGETID) --name $(PROJECTNAME) --path . $(SWIG) -java $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH) - $(ANDROID_NDK_BUILD) - $(ANT) debug + +$(ANDROID_NDK_BUILD) $(SILENT_PIPE) + $(ANT) $(ANT_QUIET) debug # ---------------------------------------------------------------- # Build an Android dynamically loadable module (C++) # ---------------------------------------------------------------- android_cpp: $(SRCS) - $(ANDROID) update project --target $(TARGETID) --name $(PROJECTNAME) --path . + $(ANDROID) $(SILENT_OPTION) update project --target $(TARGETID) --name $(PROJECTNAME) --path . $(SWIG) -java -c++ $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.cpp $(INTERFACEPATH) - $(ANDROID_NDK_BUILD) - $(ANT) debug + +$(ANDROID_NDK_BUILD) $(SILENT_PIPE) + $(ANT) $(ANT_QUIET) debug # ---------------------------------------------------------------- # Android install From 897b2361cb3a2b0c8175d0798e1638fc091d70a4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2013 22:07:19 +0100 Subject: [PATCH 098/273] Chicken makefiles tweaks for consistency with other languages - still more to be done though --- Examples/Makefile.in | 9 +++++++++ Examples/chicken/class/Makefile | 12 ++++++------ Examples/chicken/constants/Makefile | 10 +++++----- Examples/chicken/egg/Makefile | 10 +++++----- Examples/chicken/multimap/Makefile | 10 +++++----- Examples/chicken/overload/Makefile | 10 +++++----- Examples/chicken/simple/Makefile | 10 +++++----- 7 files changed, 40 insertions(+), 31 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 867473f91..ae71d7ba9 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1080,11 +1080,13 @@ pike_clean: CHICKEN = @CHICKEN@ CHICKEN_CSC = @CHICKEN_CSC@ +CHICKEN_CSI = @CHICKEN_CSI@ CHICKEN_LIBOPTS = @CHICKENLIB@ $(SYSLIBS) CHICKEN_SHAREDLIBOPTS = @CHICKENSHAREDLIB@ $(SYSLIBS) CHICKEN_CFLAGS = @CHICKENOPTS@ CHICKENOPTS = -quiet CHICKEN_MAIN = +CHICKEN_SCRIPT = $(RUNME).ss # SWIG produces $(ISRCS) (the C wrapper file) # and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file): @@ -1165,6 +1167,13 @@ chicken_cpp: chicken_externalhdr: $(SWIG) -chicken -external-runtime $(TARGET) +# ----------------------------------------------------------------- +# Run CHICKEN example +# ----------------------------------------------------------------- + +chicken_run: + $(RUNTOOL) $(CHICKEN_CSI) $(CHICKEN_SCRIPT) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- diff --git a/Examples/chicken/class/Makefile b/Examples/chicken/class/Makefile index 1261ec5ac..976651e94 100644 --- a/Examples/chicken/class/Makefile +++ b/Examples/chicken/class/Makefile @@ -14,7 +14,11 @@ VARIANT = #CHICKEN_MAIN = test-tinyclos-class.scm #VARIANT = _static -all:: $(TARGET) $(TARGET)_proxy +check: build + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-lowlevel-class.scm + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-tinyclos-class.scm + +build: $(TARGET) $(TARGET)_proxy $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ @@ -28,11 +32,7 @@ $(TARGET)_proxy: $(INTERFACE) $(SRCS) INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile chicken_clean rm -f example.scm rm -f $(TARGET) - -check:: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-lowlevel-class.scm - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-tinyclos-class.scm diff --git a/Examples/chicken/constants/Makefile b/Examples/chicken/constants/Makefile index 81308fcf3..41ca7ae11 100644 --- a/Examples/chicken/constants/Makefile +++ b/Examples/chicken/constants/Makefile @@ -13,7 +13,10 @@ VARIANT = #CHICKEN_MAIN = test-constants.scm #VARIANT = _static -all:: $(TARGET) +check: build + csi test-constants.scm + +build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ @@ -21,10 +24,7 @@ $(TARGET): $(INTERFACE) $(SRCS) INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) -clean:: +clean: $(MAKE) -f $(TOP)/Makefile chicken_clean rm -f example.scm rm -f $(TARGET) - -check:: - csi test-constants.scm diff --git a/Examples/chicken/egg/Makefile b/Examples/chicken/egg/Makefile index bdf71b104..55aa114eb 100644 --- a/Examples/chicken/egg/Makefile +++ b/Examples/chicken/egg/Makefile @@ -1,6 +1,9 @@ SWIG = ../../../preinst-swig -all: single multi +check: build + cd eggs/install && csi ../../test.scm + +build: single multi # This creates an egg which contains only the single module. Any additional implementation files # that implement the interface being wrapped should also be added to this egg @@ -9,7 +12,7 @@ single: single_wrap.cxx tar czf eggs/single.egg single.setup single.scm single_wrap.cxx rm -f single.scm single_wrap.cxx -# complie the single module with -nounit +# compile the single module with -nounit single_wrap.cxx: single.i $(SWIG) -chicken -c++ -proxy -nounit single.i @@ -34,6 +37,3 @@ setup: mkdir -p install && \ chicken-setup -repository `pwd`/install single.egg && \ chicken-setup -repository `pwd`/install multi.egg - -check: - cd eggs/install && csi ../../test.scm diff --git a/Examples/chicken/multimap/Makefile b/Examples/chicken/multimap/Makefile index dace61a1e..4ae5a9cf3 100644 --- a/Examples/chicken/multimap/Makefile +++ b/Examples/chicken/multimap/Makefile @@ -13,7 +13,10 @@ VARIANT = #CHICKEN_MAIN = test-multimap.scm #VARIANT = _static -all:: $(TARGET) +check: build + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-multimap.scm + +build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ @@ -21,10 +24,7 @@ $(TARGET): $(INTERFACE) $(SRCS) INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) -clean:: +clean: $(MAKE) -f $(TOP)/Makefile chicken_clean rm -f example.scm rm -f $(TARGET) - -check:: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-multimap.scm diff --git a/Examples/chicken/overload/Makefile b/Examples/chicken/overload/Makefile index 48ec43af4..584fa52a2 100644 --- a/Examples/chicken/overload/Makefile +++ b/Examples/chicken/overload/Makefile @@ -13,7 +13,10 @@ VARIANT = #CHICKEN_MAIN = test-overload.scm #VARIANT = _static -all:: $(TARGET) +check: build + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-overload.scm + +build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ @@ -21,10 +24,7 @@ $(TARGET): $(INTERFACE) $(SRCS) INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile chicken_clean rm -f example.scm rm -f $(TARGET) - -check:: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-overload.scm diff --git a/Examples/chicken/simple/Makefile b/Examples/chicken/simple/Makefile index bb7814260..1b03497cd 100644 --- a/Examples/chicken/simple/Makefile +++ b/Examples/chicken/simple/Makefile @@ -13,7 +13,10 @@ VARIANT = #CHICKEN_MAIN = test-simple.scm #VARIANT = _static -all:: $(TARGET) +check: build + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-simple.scm + +build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ @@ -21,10 +24,7 @@ $(TARGET): $(INTERFACE) $(SRCS) INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) -clean:: +clean: $(MAKE) -f $(TOP)/Makefile chicken_clean rm -f example.scm example-generic.scm example-clos.scm rm -f $(TARGET) - -check:: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-simple.scm From 2e48e5b8521b0e9f661830742185f6299eac421e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2013 22:13:27 +0100 Subject: [PATCH 099/273] Guile example makefiles tweaks for consistency with other languages. 'make check' still incomplete. --- Examples/Makefile.in | 11 +++++++++-- Examples/guile/Makefile.in | 6 +++--- Examples/guile/constants/Makefile | 10 +++++----- Examples/guile/matrix/Makefile | 7 +++---- Examples/guile/multimap/Makefile | 10 +++++----- Examples/guile/multivalue/Makefile | 10 +++++----- Examples/guile/port/Makefile | 7 +++---- Examples/guile/simple/Makefile | 10 +++++----- Examples/guile/std_vector/Makefile | 10 +++++----- 9 files changed, 43 insertions(+), 38 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index ae71d7ba9..4ddf9269b 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -459,6 +459,8 @@ GUILE_INCLUDE = @GUILEINCLUDE@ GUILE_LIB = @GUILELIB@ GUILE_SO = @GUILE_SO@ GUILE_LIBPREFIX = lib +GUILE_LIBOPTS = @GUILELINK@ @LIBS@ $(SYSLIBS) +GUILE_SCRIPT = $(RUNME).scm #------------------------------------------------------------------ # Build a dynamically loaded module with passive linkage and the scm interface @@ -507,8 +509,6 @@ guile_passive_cpp: $(SRCS) # Build statically linked Guile interpreter # ----------------------------------------------------------------- -GUILE_LIBOPTS = @GUILELINK@ @LIBS@ $(SYSLIBS) - guile_static: $(SRCS) $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ @@ -531,6 +531,13 @@ guile_simple_cpp: $(SRCS) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile +# ----------------------------------------------------------------- +# Running a Guile example +# ----------------------------------------------------------------- + +guile_run: + $(RUNTOOL) $(GUILE) -l $(GUILE_SCRIPT) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- diff --git a/Examples/guile/Makefile.in b/Examples/guile/Makefile.in index a11095599..9e6f9f6c6 100644 --- a/Examples/guile/Makefile.in +++ b/Examples/guile/Makefile.in @@ -19,7 +19,7 @@ SO = @SO@ all: for d in $(subdirs) ; do (cd $$d ; $(MAKE)) ; done -clean:: +clean: for d in $(subdirs) ; do (cd $$d ; $(MAKE) clean) ; done rm -f *~ .~* @@ -29,11 +29,11 @@ guile_clean: # This is meant to be used w/ "make -f ../Makefile" from subdirs. # Doesn't make sense to use it from here. -sub-all:: +sub-all: $(SWIG) -guile $(SWIGOPT) $(IFILE) $(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILEINCLUDE) $(GUILELINK) -sub-all-cxx:: +sub-all-cxx: $(SWIG) -c++ -guile $(SWIGOPT) $(IFILE) $(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILEINCLUDE) $(GUILELINK) diff --git a/Examples/guile/constants/Makefile b/Examples/guile/constants/Makefile index 70243c75e..946323b89 100644 --- a/Examples/guile/constants/Makefile +++ b/Examples/guile/constants/Makefile @@ -3,15 +3,15 @@ TARGET = my-guile IFILE = example.i MKDIR = .. -all:: +check: build + ./my-guile -s constants.scm + +build: $(MAKE) -f $(MKDIR)/Makefile \ SRCS='$(SRCS)' \ TARGET=$(TARGET) \ IFILE=$(IFILE) \ sub-all -clean:: +clean: $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean - -check: all - ./my-guile -s constants.scm diff --git a/Examples/guile/matrix/Makefile b/Examples/guile/matrix/Makefile index 5df2c6515..551debe06 100644 --- a/Examples/guile/matrix/Makefile +++ b/Examples/guile/matrix/Makefile @@ -3,8 +3,9 @@ TARGET = matrix IFILE = package.i MKDIR = .. +check: build -all:: +build: $(MAKE) -f $(MKDIR)/Makefile \ SRCS='$(SRCS)' \ TARGET=$(TARGET) \ @@ -12,7 +13,5 @@ all:: MODULE=$(MODULE) \ sub-all -clean:: +clean: $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean - -check: all diff --git a/Examples/guile/multimap/Makefile b/Examples/guile/multimap/Makefile index dc9c66d1f..00fa5df28 100644 --- a/Examples/guile/multimap/Makefile +++ b/Examples/guile/multimap/Makefile @@ -4,15 +4,15 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean - -check: all diff --git a/Examples/guile/multivalue/Makefile b/Examples/guile/multivalue/Makefile index dc9c66d1f..00fa5df28 100644 --- a/Examples/guile/multivalue/Makefile +++ b/Examples/guile/multivalue/Makefile @@ -4,15 +4,15 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean - -check: all diff --git a/Examples/guile/port/Makefile b/Examples/guile/port/Makefile index 824f3f823..2d81f44ca 100644 --- a/Examples/guile/port/Makefile +++ b/Examples/guile/port/Makefile @@ -3,8 +3,9 @@ TARGET = port IFILE = port.i MKDIR = .. +check: build -all:: +build: $(MAKE) -f $(MKDIR)/Makefile \ SRCS='$(SRCS)' \ TARGET=$(TARGET) \ @@ -12,7 +13,5 @@ all:: MODULE=$(MODULE) \ sub-all -clean:: +clean: $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean - -check: all diff --git a/Examples/guile/simple/Makefile b/Examples/guile/simple/Makefile index 702b5bb96..d4021073e 100644 --- a/Examples/guile/simple/Makefile +++ b/Examples/guile/simple/Makefile @@ -3,7 +3,10 @@ TARGET = my-guile IFILE = example.i MKDIR = .. -all: $(TARGET) +check: $(TARGET) + ./$(TARGET) -s example.scm + +build: $(TARGET) $(TARGET): $(MAKE) -f $(MKDIR)/Makefile \ @@ -12,8 +15,5 @@ $(TARGET): IFILE=$(IFILE) \ sub-all -clean:: +clean: $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean - -check: $(TARGET) - ./$(TARGET) -s example.scm > /dev/null diff --git a/Examples/guile/std_vector/Makefile b/Examples/guile/std_vector/Makefile index 2733fb017..08bf82c87 100644 --- a/Examples/guile/std_vector/Makefile +++ b/Examples/guile/std_vector/Makefile @@ -4,15 +4,15 @@ SRCS = TARGET = example INTERFACE = example.i -all:: +check: build + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean - -check: all From a6e2ee858025c3c5d0bc13f7336d1669c7ad7b37 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2013 22:22:34 +0100 Subject: [PATCH 100/273] Modula3 makefiles tweaks for consistency with other languages - they still don't work though --- Examples/modula3/class/Makefile | 9 ++++----- Examples/modula3/enum/Makefile | 9 ++++----- Examples/modula3/exception/Makefile | 9 ++++----- Examples/modula3/reference/Makefile | 9 ++++----- Examples/modula3/simple/Makefile | 9 ++++----- Examples/modula3/typemap/Makefile | 9 ++++----- 6 files changed, 24 insertions(+), 30 deletions(-) diff --git a/Examples/modula3/class/Makefile b/Examples/modula3/class/Makefile index bf929a061..9976e6f80 100644 --- a/Examples/modula3/class/Makefile +++ b/Examples/modula3/class/Makefile @@ -7,9 +7,10 @@ INTERFACE = example.i SWIGOPT = -c++ MODULA3SRCS = *.[im]3 -all:: modula3 +check: build + $(MAKE) -f $(TOP)/Makefile modula3_run -modula3:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) @@ -19,7 +20,5 @@ modula3:: ln -sf ../example.h src/example.h cm3 -clean:: +clean: $(MAKE) -f $(TOP)/Makefile modula3_clean - -check: all diff --git a/Examples/modula3/enum/Makefile b/Examples/modula3/enum/Makefile index b5bf8f672..a3b499823 100644 --- a/Examples/modula3/enum/Makefile +++ b/Examples/modula3/enum/Makefile @@ -7,9 +7,10 @@ CONSTNUMERIC = example_const SWIGOPT = -c++ MODULA3SRCS = *.[im]3 -all:: modula3 +check: build + $(MAKE) -f $(TOP)/Makefile modula3_run -modula3:: +build: $(SWIG) -modula3 $(SWIGOPT) -module Example -generateconst $(CONSTNUMERIC) $(TARGET).h $(CXX) -Wall $(CONSTNUMERIC).c -o $(CONSTNUMERIC) $(CONSTNUMERIC) >$(CONSTNUMERIC).i @@ -20,7 +21,5 @@ modula3:: mv m3makefile $(MODULA3SRCS) src/ cm3 -clean:: +clean: $(MAKE) -f $(TOP)/Makefile modula3_clean - -check: all diff --git a/Examples/modula3/exception/Makefile b/Examples/modula3/exception/Makefile index 2518a2203..8d4525512 100644 --- a/Examples/modula3/exception/Makefile +++ b/Examples/modula3/exception/Makefile @@ -7,9 +7,10 @@ SWIGOPT = MODULA3SRCS = *.[im]3 MODULA3FLAGS= -o runme -all:: modula3 +check: build + $(MAKE) -f $(TOP)/Makefile modula3_run -modula3:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3_cpp # $(MAKE) -f $(TOP)/Makefile MODULA3SRCS='$(MODULA3SRCS)' MODULA3FLAGS='$(MODULA3FLAGS)' modula3_compile @@ -17,7 +18,5 @@ modula3:: mv m3makefile $(MODULA3SRCS) src/ cm3 -clean:: +clean: $(MAKE) -f $(TOP)/Makefile modula3_clean - -check: all diff --git a/Examples/modula3/reference/Makefile b/Examples/modula3/reference/Makefile index b31577a58..62183931e 100644 --- a/Examples/modula3/reference/Makefile +++ b/Examples/modula3/reference/Makefile @@ -6,16 +6,15 @@ INTERFACE = example.i SWIGOPT = -c++ MODULA3SRCS = *.[im]3 -all:: modula3 +check: build + $(MAKE) -f $(TOP)/Makefile modula3_run -modula3:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 -clean:: +clean: $(MAKE) -f $(TOP)/Makefile modula3_clean - -check: all diff --git a/Examples/modula3/simple/Makefile b/Examples/modula3/simple/Makefile index 834521fa5..6a0ca4f0e 100644 --- a/Examples/modula3/simple/Makefile +++ b/Examples/modula3/simple/Makefile @@ -6,16 +6,15 @@ INTERFACE = example.i SWIGOPT = MODULA3SRCS = *.[im]3 -all:: modula3 +check: build + $(MAKE) -f $(TOP)/Makefile modula3_run -modula3:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 -clean:: +clean: $(MAKE) -f $(TOP)/Makefile modula3_clean - -check: all diff --git a/Examples/modula3/typemap/Makefile b/Examples/modula3/typemap/Makefile index 834521fa5..6a0ca4f0e 100644 --- a/Examples/modula3/typemap/Makefile +++ b/Examples/modula3/typemap/Makefile @@ -6,16 +6,15 @@ INTERFACE = example.i SWIGOPT = MODULA3SRCS = *.[im]3 -all:: modula3 +check: build + $(MAKE) -f $(TOP)/Makefile modula3_run -modula3:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 -clean:: +clean: $(MAKE) -f $(TOP)/Makefile modula3_clean - -check: all From 238554fe618624b24d2422e80e9de512ec57c497 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2013 22:33:38 +0100 Subject: [PATCH 101/273] Mzscheme example makefiles tweaks for consistency with other languages. Attempt to add runtime tests to 'make check' - untested. --- Examples/Makefile.in | 15 +++++++++++++++ Examples/mzscheme/multimap/Makefile | 10 ++++++---- Examples/mzscheme/simple/Makefile | 10 ++++++---- Examples/mzscheme/std_vector/Makefile | 7 ++++--- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 4ddf9269b..8775af330 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -695,6 +695,13 @@ modula3: $(SRCS) modula3_cpp: $(SRCS) $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACEPATH) +# ----------------------------------------------------------------- +# Run modula3 example +# ----------------------------------------------------------------- + +modula3_run: + $(RUNTOOL) false $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- @@ -719,6 +726,7 @@ MZSCHEME = mzscheme MZC = @MZC@ MZDYNOBJ = @MZDYNOBJ@ MZSCHEME_SO = @MZSCHEME_SO@ +MZSCHEME_SCRIPT = $(RUNME).scm # ---------------------------------------------------------------- # Build a C/C++ dynamically loadable module @@ -734,6 +742,13 @@ mzscheme_cpp: $(SRCS) $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS) +# ----------------------------------------------------------------- +# Run mzscheme example +# ----------------------------------------------------------------- + +mzscheme_run: + $(RUNTOOL) $(MZSCHEME) -r $(MZSCHEME_SCRIPT) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- diff --git a/Examples/mzscheme/multimap/Makefile b/Examples/mzscheme/multimap/Makefile index a3cfb8f3c..d1b4a3f39 100644 --- a/Examples/mzscheme/multimap/Makefile +++ b/Examples/mzscheme/multimap/Makefile @@ -4,10 +4,12 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile mzscheme_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme -clean:: +clean: $(MAKE) -f $(TOP)/Makefile mzscheme_clean - -check: all diff --git a/Examples/mzscheme/simple/Makefile b/Examples/mzscheme/simple/Makefile index a3cfb8f3c..d1b4a3f39 100644 --- a/Examples/mzscheme/simple/Makefile +++ b/Examples/mzscheme/simple/Makefile @@ -4,10 +4,12 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile mzscheme_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme -clean:: +clean: $(MAKE) -f $(TOP)/Makefile mzscheme_clean - -check: all diff --git a/Examples/mzscheme/std_vector/Makefile b/Examples/mzscheme/std_vector/Makefile index e18726981..28b91158a 100644 --- a/Examples/mzscheme/std_vector/Makefile +++ b/Examples/mzscheme/std_vector/Makefile @@ -8,12 +8,13 @@ SWIGOPT = GPP = `which g++` MZC = test -n "/usr/bin/mzc" && /usr/bin/mzc -all:: +check: build + $(MAKE) -f $(TOP)/Makefile mzscheme_run + +build: $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACE) $(MZC) --compiler $(GPP) ++ccf "-I." --cc example_wrap.cxx $(MZC) --linker $(GPP) --ld $(TARGET).so example_wrap.o clean: $(MAKE) -f $(TOP)/Makefile mzscheme_clean - -check: all From 280cd16b7eaad1b22dedf0e36912e7b8803e69ab Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2013 22:45:01 +0100 Subject: [PATCH 102/273] Ocaml example makefiles tweaks for consistency with other languages. Attempt to add runtime tests to 'make check' - untested. --- Examples/Makefile.in | 7 +++++++ Examples/ocaml/argout_ref/Makefile | 13 +++++++------ Examples/ocaml/contract/Makefile | 15 ++++++++------- Examples/ocaml/scoped_enum/Makefile | 15 ++++++++------- Examples/ocaml/shapes/Makefile | 15 ++++++++------- Examples/ocaml/simple/Makefile | 15 ++++++++------- Examples/ocaml/std_string/Makefile | 13 +++++++------ Examples/ocaml/std_vector/Makefile | 13 +++++++------ Examples/ocaml/stl/Makefile | 17 +++++++++-------- Examples/ocaml/string_from_ptr/Makefile | 15 ++++++++------- Examples/ocaml/strings_test/Makefile | 15 ++++++++------- 11 files changed, 85 insertions(+), 68 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 8775af330..feef7ff05 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -893,6 +893,13 @@ ocaml_dynamic_cpp: $(SRCS) -package dl -linkpkg \ $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings' +# ----------------------------------------------------------------- +# Run ocaml example +# ----------------------------------------------------------------- + +ocaml_run: + $(RUNTOOL) false $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- diff --git a/Examples/ocaml/argout_ref/Makefile b/Examples/ocaml/argout_ref/Makefile index 8a260fe30..4e12e3769 100644 --- a/Examples/ocaml/argout_ref/Makefile +++ b/Examples/ocaml/argout_ref/Makefile @@ -7,21 +7,22 @@ MLFILE = example.ml PROGFILE = example_prog.ml OBJS = example.o -all:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - -check: all diff --git a/Examples/ocaml/contract/Makefile b/Examples/ocaml/contract/Makefile index 8e0f2a4fd..91d39247e 100644 --- a/Examples/ocaml/contract/Makefile +++ b/Examples/ocaml/contract/Makefile @@ -7,27 +7,28 @@ MLFILE = example.ml PROGFILE = example_prog.ml OBJS = -all:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -dynamic:: +build: static + +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static -toplevel:: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_toplevel -clean:: +clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - -check: all diff --git a/Examples/ocaml/scoped_enum/Makefile b/Examples/ocaml/scoped_enum/Makefile index 45c5edca4..4920e3b3b 100644 --- a/Examples/ocaml/scoped_enum/Makefile +++ b/Examples/ocaml/scoped_enum/Makefile @@ -7,27 +7,28 @@ MLFILE = example.ml PROGFILE = example_prog.ml OBJS = -all:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -dynamic:: +build: static + +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp -toplevel:: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel -clean:: +clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - -check: all diff --git a/Examples/ocaml/shapes/Makefile b/Examples/ocaml/shapes/Makefile index 31f9934a7..38230eb69 100644 --- a/Examples/ocaml/shapes/Makefile +++ b/Examples/ocaml/shapes/Makefile @@ -8,27 +8,28 @@ MLFILE = example.ml PROGFILE = example_prog.ml OBJS = example.o -all:: static static_top +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static static_top + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp -static_top:: +static_top: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - -check: all diff --git a/Examples/ocaml/simple/Makefile b/Examples/ocaml/simple/Makefile index 4b85bf33e..64c7256c1 100644 --- a/Examples/ocaml/simple/Makefile +++ b/Examples/ocaml/simple/Makefile @@ -7,27 +7,28 @@ MLFILE = example.ml PROGFILE = example_prog.ml OBJS = example.o -all:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -dynamic:: +build: static + +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static -toplevel:: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_toplevel -clean:: +clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - -check: all diff --git a/Examples/ocaml/std_string/Makefile b/Examples/ocaml/std_string/Makefile index e5a8017ae..0250cfd2d 100644 --- a/Examples/ocaml/std_string/Makefile +++ b/Examples/ocaml/std_string/Makefile @@ -5,19 +5,20 @@ TARGET = example INTERFACE = example.i PROGFILE = runme.ml -all default:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_dynamic_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean - -check: all diff --git a/Examples/ocaml/std_vector/Makefile b/Examples/ocaml/std_vector/Makefile index e5a8017ae..0250cfd2d 100644 --- a/Examples/ocaml/std_vector/Makefile +++ b/Examples/ocaml/std_vector/Makefile @@ -5,19 +5,20 @@ TARGET = example INTERFACE = example.i PROGFILE = runme.ml -all default:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_dynamic_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean - -check: all diff --git a/Examples/ocaml/stl/Makefile b/Examples/ocaml/stl/Makefile index fa4333ec0..545f3229a 100644 --- a/Examples/ocaml/stl/Makefile +++ b/Examples/ocaml/stl/Makefile @@ -5,29 +5,30 @@ TARGET = example INTERFACE = example.i PROGFILE = runme.ml -all default:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -director:: +director: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_director -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -toplevel:: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_toplevel -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean - -check: all diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile index 350d9734c..f7b808934 100644 --- a/Examples/ocaml/string_from_ptr/Makefile +++ b/Examples/ocaml/string_from_ptr/Makefile @@ -8,27 +8,28 @@ MLFILE = foolib.ml PROGFILE = example_prog.ml OBJS = -all:: static static_top +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static static_top + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp -static_top:: +static_top: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - -check: all diff --git a/Examples/ocaml/strings_test/Makefile b/Examples/ocaml/strings_test/Makefile index 8d1f96edf..14f55e0d9 100644 --- a/Examples/ocaml/strings_test/Makefile +++ b/Examples/ocaml/strings_test/Makefile @@ -5,24 +5,25 @@ TARGET = example INTERFACE = example.i PROGFILE = runme.ml -all default:: static top +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static top + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -top:: +top: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_toplevel -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean - -check: all From 9a6167822ba2c64b14e1b7c1c2683c3a7477d336 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2013 22:49:12 +0100 Subject: [PATCH 103/273] Pike example makefiles tweaks for consistency with other languages. Attempt to add runtime tests to 'make check' - untested. --- Examples/Makefile.in | 11 +++++++++-- Examples/pike/class/Makefile | 7 ++++--- Examples/pike/constants/Makefile | 11 ++++++----- Examples/pike/enum/Makefile | 11 ++++++----- Examples/pike/overload/Makefile | 11 ++++++----- Examples/pike/simple/Makefile | 7 ++++--- Examples/pike/template/Makefile | 7 ++++--- 7 files changed, 39 insertions(+), 26 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index feef7ff05..43efdc472 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1048,6 +1048,8 @@ PIKE_CFLAGS = @PIKECCDLFLAGS@ -DHAVE_CONFIG_H PIKE_INCLUDE = @PIKEINCLUDE@ PIKE_LIB = @PIKELIB@ PIKE_DLNK = @PIKEDYNAMICLINKING@ +PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS) +PIKE_SCRIPT = $(RUNME).pike # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -1074,8 +1076,6 @@ pike_cpp: $(SRCS) # library file # ----------------------------------------------------------------- -PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS) - pike_static: $(SRCS) $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ @@ -1086,6 +1086,13 @@ pike_cpp_static: $(SRCS) $(CXX) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) +# ----------------------------------------------------------------- +# Run pike example +# ----------------------------------------------------------------- + +pike_run: + $(RUNTOOL) $(PIKE) $(PIKE_SCRIPT) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- diff --git a/Examples/pike/class/Makefile b/Examples/pike/class/Makefile index 981ccef6f..aadc47151 100644 --- a/Examples/pike/class/Makefile +++ b/Examples/pike/class/Makefile @@ -5,7 +5,10 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all: +check: build + $(MAKE) -f $(TOP)/Makefile pike_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp @@ -15,5 +18,3 @@ static: clean: $(MAKE) -f $(TOP)/Makefile pike_clean - -check: all diff --git a/Examples/pike/constants/Makefile b/Examples/pike/constants/Makefile index 7fa493851..9a882bd4d 100644 --- a/Examples/pike/constants/Makefile +++ b/Examples/pike/constants/Makefile @@ -4,15 +4,16 @@ SRCS = TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile pike_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile pike_clean - -check: all diff --git a/Examples/pike/enum/Makefile b/Examples/pike/enum/Makefile index 0ae102156..aadc47151 100644 --- a/Examples/pike/enum/Makefile +++ b/Examples/pike/enum/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile pike_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile pike_clean - -check: all diff --git a/Examples/pike/overload/Makefile b/Examples/pike/overload/Makefile index 60af005b1..8d799efe1 100644 --- a/Examples/pike/overload/Makefile +++ b/Examples/pike/overload/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lstdc++ -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile pike_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile pike_clean - -check: all diff --git a/Examples/pike/simple/Makefile b/Examples/pike/simple/Makefile index 544c97b5d..f58ed4e65 100644 --- a/Examples/pike/simple/Makefile +++ b/Examples/pike/simple/Makefile @@ -4,7 +4,10 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all: +check: build + $(MAKE) -f $(TOP)/Makefile pike_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike @@ -14,5 +17,3 @@ static: clean: $(MAKE) -f $(TOP)/Makefile pike_clean - -check: all diff --git a/Examples/pike/template/Makefile b/Examples/pike/template/Makefile index b3f012927..73a31ee1a 100644 --- a/Examples/pike/template/Makefile +++ b/Examples/pike/template/Makefile @@ -6,7 +6,10 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all: +check: build + $(MAKE) -f $(TOP)/Makefile pike_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp @@ -16,5 +19,3 @@ static: clean: $(MAKE) -f $(TOP)/Makefile pike_clean - -check: all From ceb5c59c8d8f81bcc8897a3f5601353caf2f8627 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2013 22:52:23 +0100 Subject: [PATCH 104/273] XML example makefiles tweaks for consistency with other languages --- Examples/xml/Makefile.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/Examples/xml/Makefile.in b/Examples/xml/Makefile.in index dfda4a646..27c86e3e9 100644 --- a/Examples/xml/Makefile.in +++ b/Examples/xml/Makefile.in @@ -19,8 +19,6 @@ all-dot-i-files = \ example_xml.i \ gnarly.i -all: check - chk-swiglib = $(top_srcdir)/Lib check: From e3d0947058206f29c41c2d3631858661267bed80 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2013 23:09:49 +0100 Subject: [PATCH 105/273] D example makefiles tweaks for consistency with other languages. --- Examples/Makefile.in | 4 +++- Examples/d/callback/Makefile | 13 +++++-------- Examples/d/class/Makefile | 13 +++++-------- Examples/d/constants/Makefile | 13 +++++-------- Examples/d/enum/Makefile | 13 +++++-------- Examples/d/extend/Makefile | 13 +++++-------- Examples/d/funcptr/Makefile | 13 +++++-------- Examples/d/simple/Makefile | 13 +++++-------- Examples/d/variables/Makefile | 13 +++++-------- 9 files changed, 43 insertions(+), 65 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 43efdc472..b95d9e129 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1650,6 +1650,8 @@ else DCOMPILER = @D1COMPILER@ endif +D_RUNME = ./$(RUNME) + # ---------------------------------------------------------------- # Build a dynamically loadable D wrapper for a C module # ---------------------------------------------------------------- @@ -1682,7 +1684,7 @@ d_compile: $(SRCS) # ----------------------------------------------------------------- d_run: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme + $(RUNTOOL) $(D_RUNME) $(RUNPIPE) # ----------------------------------------------------------------- # Version display diff --git a/Examples/d/callback/Makefile b/Examples/d/callback/Makefile index b5808cf0d..eda18f13c 100644 --- a/Examples/d/callback/Makefile +++ b/Examples/d/callback/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/class/Makefile b/Examples/d/class/Makefile index b5808cf0d..eda18f13c 100644 --- a/Examples/d/class/Makefile +++ b/Examples/d/class/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/constants/Makefile b/Examples/d/constants/Makefile index 412055243..d537ce281 100644 --- a/Examples/d/constants/Makefile +++ b/Examples/d/constants/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/enum/Makefile b/Examples/d/enum/Makefile index b5808cf0d..eda18f13c 100644 --- a/Examples/d/enum/Makefile +++ b/Examples/d/enum/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/extend/Makefile b/Examples/d/extend/Makefile index b5808cf0d..eda18f13c 100644 --- a/Examples/d/extend/Makefile +++ b/Examples/d/extend/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/funcptr/Makefile b/Examples/d/funcptr/Makefile index 09efa8d88..2ba893ca7 100644 --- a/Examples/d/funcptr/Makefile +++ b/Examples/d/funcptr/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/simple/Makefile b/Examples/d/simple/Makefile index ae173a566..a8808c9c5 100644 --- a/Examples/d/simple/Makefile +++ b/Examples/d/simple/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/variables/Makefile b/Examples/d/variables/Makefile index ae173a566..a8808c9c5 100644 --- a/Examples/d/variables/Makefile +++ b/Examples/d/variables/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run From ea84fe6445e9ac9a8cd097260eaca4a17ab0e609 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 16 Apr 2013 07:26:12 +0100 Subject: [PATCH 106/273] Allegrocl, clisp, cffi, uffi makefile targets added for running examples - untested. --- Examples/Makefile.in | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index b95d9e129..f5b93dbe9 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1369,6 +1369,7 @@ lua_clean: ################################################################## ALLEGROCL = @ALLEGROCLBIN@ +ALLEGROCL_SCRIPT=$(RUNME).lisp allegrocl: $(SRCS) $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH) @@ -1380,6 +1381,13 @@ allegrocl_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) +# ----------------------------------------------------------------- +# Run ALLEGRO CL example +# ----------------------------------------------------------------- + +allegrocl_run: + $(RUNTOOL) $(ALLEGROCL) -batch -s $(ALLEGROCL_SCRIPT) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- @@ -1401,6 +1409,7 @@ allegrocl_clean: ################################################################## CLISP = @CLISPBIN@ +CLISP_SCRIPT=$(RUNME).lisp clisp: $(SRCS) $(SWIG) -clisp $(SWIGOPT) $(INTERFACEPATH) @@ -1408,6 +1417,13 @@ clisp: $(SRCS) clisp_cpp: $(SRCS) $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACEPATH) +# ----------------------------------------------------------------- +# Run CLISP example +# ----------------------------------------------------------------- + +clisp_run: + $(RUNTOOL) $(CLISP) -batch -s $(CLISP_SCRIPT) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- @@ -1429,6 +1445,7 @@ clisp_clean: ################################################################## CFFI = @CFFIBIN@ +CFFI_SCRIPT=$(RUNME).lisp cffi: $(SRCS) $(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH) @@ -1440,6 +1457,13 @@ cffi_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) +# ----------------------------------------------------------------- +# Run CFFI example +# ----------------------------------------------------------------- + +cffi_run: + $(RUNTOOL) $(CFFI) -batch -s $(CFFI_SCRIPT) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- @@ -1461,6 +1485,7 @@ cffi_clean: ################################################################## UFFI = @UFFIBIN@ +UFFI_SCRIPT=$(RUNME).lisp uffi: $(SRCS) $(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH) @@ -1472,6 +1497,13 @@ uffi_cpp: $(SRCS) # $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) # $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) +# ----------------------------------------------------------------- +# Run UFFI example +# ----------------------------------------------------------------- + +uffi_run: + $(RUNTOOL) $(UFFI) -batch -s $(UFFI_SCRIPT) $(RUNPIPE) + # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- From 1f4bd0bfa5bc1bef809764a99e56186cb3df88de Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2013 23:12:47 +0100 Subject: [PATCH 107/273] Minor extraneous makefiles tidy up --- Lib/guile/Makefile | 2 +- Lib/mzscheme/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/guile/Makefile b/Lib/guile/Makefile index ff66f9efa..17f5feced 100644 --- a/Lib/guile/Makefile +++ b/Lib/guile/Makefile @@ -1,4 +1,4 @@ -co:: +co: co RCS/*.i* RCS/*.swg* diff --git a/Lib/mzscheme/Makefile b/Lib/mzscheme/Makefile index ff66f9efa..17f5feced 100644 --- a/Lib/mzscheme/Makefile +++ b/Lib/mzscheme/Makefile @@ -1,4 +1,4 @@ -co:: +co: co RCS/*.i* RCS/*.swg* From 303b319cf061144c1862d0e0687bb712ffb8126c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Apr 2013 00:22:07 +0100 Subject: [PATCH 108/273] Add ability to see example output from top level by using 'make check-examples RUNPIPE=' --- Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 04d65a107..c47cdbe7c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -22,6 +22,7 @@ TARGET = $(TARGET_NOEXE)@EXEEXT@ SOURCE = Source CCACHE = CCache DOCS = Doc/Manual +RUNPIPE = \>/dev/null swig: libfiles source ccache @@ -229,7 +230,7 @@ check-%-examples : # individual example %.actionexample: @echo $(ACTION)ing Examples/$(LANGUAGE)/$* - @(cd Examples/$(LANGUAGE)/$* && $(MAKE) -s $(chk-set-env) $(ACTION) RUNPIPE=\>/dev/null) + @(cd Examples/$(LANGUAGE)/$* && $(MAKE) -s $(chk-set-env) $(ACTION) RUNPIPE=$(RUNPIPE)) # gcj individual example java.actionexample: From 13b66c997e7ce685031d15768c860cffa426f4dc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Apr 2013 00:02:23 +0100 Subject: [PATCH 109/273] Guile example makefiles - run some of the examples in the check target. Still some are missing. Add some missing examples to check.list. --- Examples/guile/check.list | 4 +++- Examples/guile/matrix/Makefile | 1 + Examples/guile/port/Makefile | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Examples/guile/check.list b/Examples/guile/check.list index 7ccd0730a..08524a8f7 100644 --- a/Examples/guile/check.list +++ b/Examples/guile/check.list @@ -1,6 +1,8 @@ # see top-level Makefile.in constants -simple port +simple +std_vector +matrix multimap multivalue diff --git a/Examples/guile/matrix/Makefile b/Examples/guile/matrix/Makefile index 551debe06..e8466e5fc 100644 --- a/Examples/guile/matrix/Makefile +++ b/Examples/guile/matrix/Makefile @@ -4,6 +4,7 @@ IFILE = package.i MKDIR = .. check: build + ./$(TARGET) -e do-test -s matrix.scm build: $(MAKE) -f $(MKDIR)/Makefile \ diff --git a/Examples/guile/port/Makefile b/Examples/guile/port/Makefile index 2d81f44ca..33eeab2e9 100644 --- a/Examples/guile/port/Makefile +++ b/Examples/guile/port/Makefile @@ -4,6 +4,7 @@ IFILE = port.i MKDIR = .. check: build + ./$(TARGET) -s port.scm build: $(MAKE) -f $(MKDIR)/Makefile \ From 7fd18b361e447e5705582bf28ebf163fa94d5e6a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Apr 2013 00:22:48 +0100 Subject: [PATCH 110/273] Ocaml example makefiles - run examples - there are plenty of problems currently though --- Examples/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index f5b93dbe9..7ace11062 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -898,7 +898,7 @@ ocaml_dynamic_cpp: $(SRCS) # ----------------------------------------------------------------- ocaml_run: - $(RUNTOOL) false $(RUNPIPE) + $(RUNTOOL) ./$(TARGET) $(RUNPIPE) # ----------------------------------------------------------------- # Version display From 62638bfd15a14420a6bbf83b3907cdb289093acd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Apr 2013 00:56:04 +0100 Subject: [PATCH 111/273] Pike - a few updates to get Pike 7.8 running most of the examples --- Examples/pike/check.list | 2 ++ Lib/pike/pike.swg | 6 +++--- Lib/pike/pikerun.swg | 5 +++-- configure.ac | 17 ++++++++++------- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Examples/pike/check.list b/Examples/pike/check.list index a8d348bf1..d6c8e2e7b 100644 --- a/Examples/pike/check.list +++ b/Examples/pike/check.list @@ -2,4 +2,6 @@ class constants enum +overload simple +template diff --git a/Lib/pike/pike.swg b/Lib/pike/pike.swg index 130af1346..399752a7a 100644 --- a/Lib/pike/pike.swg +++ b/Lib/pike/pike.swg @@ -11,9 +11,9 @@ #ifdef __cplusplus extern "C" { #endif -#include -#include -#include +#include +#include +#include #ifdef __cplusplus } #endif diff --git a/Lib/pike/pikerun.swg b/Lib/pike/pikerun.swg index 70d40fac9..6ec1143cf 100644 --- a/Lib/pike/pikerun.swg +++ b/Lib/pike/pikerun.swg @@ -9,11 +9,12 @@ #ifdef __cplusplus extern "C" { #endif -#include "object.h" -#include "program.h" +#include "pike/object.h" +#include "pike/program.h" #ifdef __cplusplus } #endif +#include /* Stores information about a wrapped object */ typedef struct swig_object_wrapper { diff --git a/configure.ac b/configure.ac index 65a9c9078..83b46f520 100644 --- a/configure.ac +++ b/configure.ac @@ -1618,18 +1618,21 @@ AC_ARG_WITH(pikeincl, AS_HELP_STRING([--with-pikeincl=path], if test -n "$PIKE"; then AC_MSG_CHECKING([for Pike header files]) if test -z "$PIKEINCLUDE" -a -n "$PIKECONFIG"; then - PIKEINCLUDE=`$PIKECONFIG --cflags` + PIKEINCLUDE=`$PIKECONFIG --cflags` fi if test -z "$PIKEINCLUDE" -a -n "$PIKE"; then - PIKEPATH=`which $PIKE` - PIKEINCLUDE=`$PIKE Tools/check-include-path.pike $PIKEPATH` - PIKEINCLUDE="-I$PIKEINCLUDE" + PIKEINCLUDE=`$PIKE -x cflags` + if test -z "$PIKEINCLUDE"; then + PIKEPATH=`which $PIKE` + PIKEINCLUDE=`$PIKE Tools/check-include-path.pike $PIKEPATH` + PIKEINCLUDE="-I$PIKEINCLUDE" + fi fi if test -z "$PIKEINCLUDE"; then - AC_MSG_RESULT(not found) + AC_MSG_RESULT(not found) else - AC_MSG_RESULT($PIKEINCLUDE) + AC_MSG_RESULT($PIKEINCLUDE) fi fi fi @@ -2305,7 +2308,7 @@ fi AC_SUBST(SKIP_OCAML) -SKIP_PIKE="1" # Always skipped! +SKIP_PIKE= if test -z "$PIKE" || test -z "$PIKEINCLUDE" ; then SKIP_PIKE="1" fi From 2b2305cce938f25cf91de50b753d95cf76e367d4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Apr 2013 01:23:54 +0100 Subject: [PATCH 112/273] Mzscheme - fix for running examples during 'make check-examples' - they don't run very well though\! --- Examples/Makefile.in | 2 +- Examples/mzscheme/check.list | 1 + Examples/mzscheme/multimap/{example.scm => runme.scm} | 4 ++-- Examples/mzscheme/simple/{example.scm => runme.scm} | 2 +- Examples/mzscheme/std_vector/{example.scm => runme.scm} | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) rename Examples/mzscheme/multimap/{example.scm => runme.scm} (89%) rename Examples/mzscheme/simple/{example.scm => runme.scm} (92%) rename Examples/mzscheme/std_vector/{example.scm => runme.scm} (97%) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 7ace11062..c7257ac4c 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -747,7 +747,7 @@ mzscheme_cpp: $(SRCS) # ----------------------------------------------------------------- mzscheme_run: - $(RUNTOOL) $(MZSCHEME) -r $(MZSCHEME_SCRIPT) $(RUNPIPE) + env LD_LIBRARY_PATH=. $(RUNTOOL) $(MZSCHEME) -r $(MZSCHEME_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display diff --git a/Examples/mzscheme/check.list b/Examples/mzscheme/check.list index ae728ea43..f9e4f11c7 100644 --- a/Examples/mzscheme/check.list +++ b/Examples/mzscheme/check.list @@ -1,3 +1,4 @@ # see top-level Makefile.in multimap simple +std_vector diff --git a/Examples/mzscheme/multimap/example.scm b/Examples/mzscheme/multimap/runme.scm similarity index 89% rename from Examples/mzscheme/multimap/example.scm rename to Examples/mzscheme/multimap/runme.scm index ac9f64283..f1e626f43 100644 --- a/Examples/mzscheme/multimap/example.scm +++ b/Examples/mzscheme/multimap/runme.scm @@ -1,4 +1,4 @@ -;; run with mzscheme -r example.scm +;; run with mzscheme -r runme.scm (load-extension "example.so") @@ -24,4 +24,4 @@ (newline) (display (capitalize "hello world")) -(newline) \ No newline at end of file +(newline) diff --git a/Examples/mzscheme/simple/example.scm b/Examples/mzscheme/simple/runme.scm similarity index 92% rename from Examples/mzscheme/simple/example.scm rename to Examples/mzscheme/simple/runme.scm index 8e20345b2..a98e31fd5 100644 --- a/Examples/mzscheme/simple/example.scm +++ b/Examples/mzscheme/simple/runme.scm @@ -1,4 +1,4 @@ -;; run with mzscheme -r example.scm +;; run with mzscheme -r runme.scm (load-extension "example.so") diff --git a/Examples/mzscheme/std_vector/example.scm b/Examples/mzscheme/std_vector/runme.scm similarity index 97% rename from Examples/mzscheme/std_vector/example.scm rename to Examples/mzscheme/std_vector/runme.scm index 0e4ac3f97..67351f128 100644 --- a/Examples/mzscheme/std_vector/example.scm +++ b/Examples/mzscheme/std_vector/runme.scm @@ -1,4 +1,4 @@ -;; run with mzscheme -r example.scm +;; run with mzscheme -r runme.scm (load-extension "example.so") From 58a59919dddfe19cef2ca72db8a883f2344e16fc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Apr 2013 02:13:17 +0100 Subject: [PATCH 113/273] Chicken - make check-examples run like other examples - not all run very well though! --- Examples/Makefile.in | 4 ++-- Examples/chicken/class/Makefile | 20 +++++++++---------- ...-lowlevel-class.scm => runme-lowlevel.scm} | 0 ...-tinyclos-class.scm => runme-tinyclos.scm} | 0 Examples/chicken/constants/Makefile | 10 +++++----- .../{test-constants.scm => runme.scm} | 0 Examples/chicken/multimap/Makefile | 10 +++++----- .../multimap/{test-multimap.scm => runme.scm} | 1 - Examples/chicken/overload/Makefile | 10 +++++----- .../overload/{test-overload.scm => runme.scm} | 0 Examples/chicken/simple/Makefile | 10 +++++----- .../simple/{test-simple.scm => runme.scm} | 0 12 files changed, 32 insertions(+), 33 deletions(-) rename Examples/chicken/class/{test-lowlevel-class.scm => runme-lowlevel.scm} (100%) rename Examples/chicken/class/{test-tinyclos-class.scm => runme-tinyclos.scm} (100%) rename Examples/chicken/constants/{test-constants.scm => runme.scm} (100%) rename Examples/chicken/multimap/{test-multimap.scm => runme.scm} (97%) rename Examples/chicken/overload/{test-overload.scm => runme.scm} (100%) rename Examples/chicken/simple/{test-simple.scm => runme.scm} (100%) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index c7257ac4c..c0cdb703f 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1122,7 +1122,7 @@ CHICKEN_SHAREDLIBOPTS = @CHICKENSHAREDLIB@ $(SYSLIBS) CHICKEN_CFLAGS = @CHICKENOPTS@ CHICKENOPTS = -quiet CHICKEN_MAIN = -CHICKEN_SCRIPT = $(RUNME).ss +CHICKEN_SCRIPT = $(RUNME).scm # SWIG produces $(ISRCS) (the C wrapper file) # and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file): @@ -1208,7 +1208,7 @@ chicken_externalhdr: # ----------------------------------------------------------------- chicken_run: - $(RUNTOOL) $(CHICKEN_CSI) $(CHICKEN_SCRIPT) $(RUNPIPE) + env LD_LIBRARY_PATH=. $(RUNTOOL) $(CHICKEN_CSI) $(CHICKEN_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display diff --git a/Examples/chicken/class/Makefile b/Examples/chicken/class/Makefile index 976651e94..1436d836f 100644 --- a/Examples/chicken/class/Makefile +++ b/Examples/chicken/class/Makefile @@ -10,27 +10,27 @@ CFLAGS = VARIANT = # uncomment the following lines to build a static exe (only pick one of the CHICKEN_MAIN lines) -#CHICKEN_MAIN = test-lowlevel-class.scm -#CHICKEN_MAIN = test-tinyclos-class.scm +#CHICKEN_MAIN = runme-lowlevel.scm +#CHICKEN_MAIN = runme-tinyclos.scm #VARIANT = _static check: build - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-lowlevel-class.scm - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-tinyclos-class.scm + $(MAKE) -f $(TOP)/Makefile CHICKEN_SCRIPT='runme-lowlevel.scm' chicken_run + $(MAKE) -f $(TOP)/Makefile CHICKEN_SCRIPT='runme-tinyclos.scm' chicken_run build: $(TARGET) $(TARGET)_proxy $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp $(TARGET)_proxy: $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp clean: $(MAKE) -f $(TOP)/Makefile chicken_clean diff --git a/Examples/chicken/class/test-lowlevel-class.scm b/Examples/chicken/class/runme-lowlevel.scm similarity index 100% rename from Examples/chicken/class/test-lowlevel-class.scm rename to Examples/chicken/class/runme-lowlevel.scm diff --git a/Examples/chicken/class/test-tinyclos-class.scm b/Examples/chicken/class/runme-tinyclos.scm similarity index 100% rename from Examples/chicken/class/test-tinyclos-class.scm rename to Examples/chicken/class/runme-tinyclos.scm diff --git a/Examples/chicken/constants/Makefile b/Examples/chicken/constants/Makefile index 41ca7ae11..31e39d346 100644 --- a/Examples/chicken/constants/Makefile +++ b/Examples/chicken/constants/Makefile @@ -10,19 +10,19 @@ CFLAGS = VARIANT = # uncomment the following two lines to build a static exe -#CHICKEN_MAIN = test-constants.scm +#CHICKEN_MAIN = runme.scm #VARIANT = _static check: build - csi test-constants.scm + $(MAKE) -f $(TOP)/Makefile chicken_run build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) clean: $(MAKE) -f $(TOP)/Makefile chicken_clean diff --git a/Examples/chicken/constants/test-constants.scm b/Examples/chicken/constants/runme.scm similarity index 100% rename from Examples/chicken/constants/test-constants.scm rename to Examples/chicken/constants/runme.scm diff --git a/Examples/chicken/multimap/Makefile b/Examples/chicken/multimap/Makefile index 4ae5a9cf3..eba36169d 100644 --- a/Examples/chicken/multimap/Makefile +++ b/Examples/chicken/multimap/Makefile @@ -10,19 +10,19 @@ CFLAGS = VARIANT = # uncomment the following two lines to build a static exe -#CHICKEN_MAIN = test-multimap.scm +#CHICKEN_MAIN = runme.scm #VARIANT = _static check: build - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-multimap.scm + $(MAKE) -f $(TOP)/Makefile chicken_run build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) clean: $(MAKE) -f $(TOP)/Makefile chicken_clean diff --git a/Examples/chicken/multimap/test-multimap.scm b/Examples/chicken/multimap/runme.scm similarity index 97% rename from Examples/chicken/multimap/test-multimap.scm rename to Examples/chicken/multimap/runme.scm index 3a6b46e2c..ebe644004 100644 --- a/Examples/chicken/multimap/test-multimap.scm +++ b/Examples/chicken/multimap/runme.scm @@ -1,4 +1,3 @@ -;; run with './multimap test-multimap.scm' ;; feel free to uncomment and comment sections (load-library 'example "multimap.so") diff --git a/Examples/chicken/overload/Makefile b/Examples/chicken/overload/Makefile index 584fa52a2..e15352ec5 100644 --- a/Examples/chicken/overload/Makefile +++ b/Examples/chicken/overload/Makefile @@ -10,19 +10,19 @@ CFLAGS = VARIANT = # uncomment the following lines to build a static exe -#CHICKEN_MAIN = test-overload.scm +#CHICKEN_MAIN = runme.scm #VARIANT = _static check: build - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-overload.scm + $(MAKE) -f $(TOP)/Makefile chicken_run build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp clean: $(MAKE) -f $(TOP)/Makefile chicken_clean diff --git a/Examples/chicken/overload/test-overload.scm b/Examples/chicken/overload/runme.scm similarity index 100% rename from Examples/chicken/overload/test-overload.scm rename to Examples/chicken/overload/runme.scm diff --git a/Examples/chicken/simple/Makefile b/Examples/chicken/simple/Makefile index 1b03497cd..f8fb006a4 100644 --- a/Examples/chicken/simple/Makefile +++ b/Examples/chicken/simple/Makefile @@ -10,19 +10,19 @@ CFLAGS = VARIANT = # uncomment the following two lines to build a static exe -#CHICKEN_MAIN = test-simple.scm +#CHICKEN_MAIN = runme.scm #VARIANT = _static check: build - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-simple.scm + $(MAKE) -f $(TOP)/Makefile chicken_run build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) clean: $(MAKE) -f $(TOP)/Makefile chicken_clean diff --git a/Examples/chicken/simple/test-simple.scm b/Examples/chicken/simple/runme.scm similarity index 100% rename from Examples/chicken/simple/test-simple.scm rename to Examples/chicken/simple/runme.scm From 9f95e30650737df2a22ebfb780169181c9d18695 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Apr 2013 02:51:57 +0100 Subject: [PATCH 114/273] Fix PHP test-suite running examples recently broken in 0fa791d --- Examples/test-suite/php/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index d4f9ac9b5..fcdcac2b9 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -57,9 +57,9 @@ missingtests: missingcpptests missingctests # found, runs testcase.php, except for multicpptests. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL="$(RUNTOOL)" php_run; \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL="$(RUNTOOL)" php_run; \ elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \ fi # Clean: remove the generated .php file From 205d50a8c96c6ed01cbc94adec6c731b52efb5e4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 21 Apr 2013 14:05:56 +0100 Subject: [PATCH 115/273] Ruby 1.9 fixes: use ruby -I in Makefile and workaround clash with 1.9 builtin Complex numbers in the operator example. --- Examples/Makefile.in | 2 +- Examples/ruby/operator/runme.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index c0cdb703f..240274278 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -970,7 +970,7 @@ ruby_cpp_static: $(SRCS) # ----------------------------------------------------------------- ruby_run: - $(RUNTOOL) $(RUBY) $(RUBY_SCRIPT) $(RUNPIPE) + $(RUNTOOL) $(RUBY) -I. $(RUBY_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display diff --git a/Examples/ruby/operator/runme.rb b/Examples/ruby/operator/runme.rb index 518d91e9e..4c1ef3f62 100644 --- a/Examples/ruby/operator/runme.rb +++ b/Examples/ruby/operator/runme.rb @@ -3,8 +3,8 @@ require 'example' include Example -a = Complex.new(2, 3) -b = Complex.new(-5, 10) +a = Example::Complex.new(2, 3) +b = Example::Complex.new(-5, 10) puts "a = #{a}" puts "b = #{b}" @@ -15,7 +15,7 @@ puts "a*b = #{a*b}" puts "a-c = #{a-c}" # This should invoke Complex's copy constructor -e = Complex.new(a-c) +e = Example::Complex.new(a-c) e = a - c puts "e = #{e}" From 486eca2faa5d7d61a97d3a4e0f033391be98baf2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 21 Apr 2013 18:24:37 +0100 Subject: [PATCH 116/273] Disable Ruby free_function test for now. It is failing in Travis builds with 'ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]' but okay with 'ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]'. Relying on timely Garbage collection is probably flawed anyway. --- Examples/ruby/check.list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/ruby/check.list b/Examples/ruby/check.list index 131dcbb33..2e581fb82 100644 --- a/Examples/ruby/check.list +++ b/Examples/ruby/check.list @@ -2,7 +2,7 @@ class constants enum -free_function +#free_function funcptr funcptr2 functor From 6e06b50adf814b3e4a519ceaebcb18edd7ac80dd Mon Sep 17 00:00:00 2001 From: Yung Lee Date: Sun, 21 Apr 2013 01:01:39 +0800 Subject: [PATCH 117/273] Remove non-ascii characters at a comment line in d.cxx that trouble VC++ --- Source/Modules/d.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index e09e253f8..5d59a2e38 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -3743,7 +3743,7 @@ private: String *nspace = getNSpace(); if (nspace) { // Check the root package/outermost namespace (a class A in module - // A.B leads to problems if another module A.C is also imported)… + // A.B leads to problems if another module A.C is also imported) if (Len(package) > 0) { String *dotless_package = NewStringWithSize(package, Len(package) - 1); if (Cmp(class_name, dotless_package) == 0) { From bdf98744b165861f67e325b892d2a65c96a2f8fa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 Apr 2013 22:18:42 +0100 Subject: [PATCH 118/273] Fix guilescm_ext_test and chicken_ext_test testcases --- ...ext_test_external.cxx => chicken_ext_test_external.cxx} | 7 +++---- ...xt_test_external.cxx => guilescm_ext_test_external.cxx} | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) rename Examples/test-suite/chicken/{ext_test_external.cxx => chicken_ext_test_external.cxx} (90%) rename Examples/test-suite/guilescm/{ext_test_external.cxx => guilescm_ext_test_external.cxx} (90%) diff --git a/Examples/test-suite/chicken/ext_test_external.cxx b/Examples/test-suite/chicken/chicken_ext_test_external.cxx similarity index 90% rename from Examples/test-suite/chicken/ext_test_external.cxx rename to Examples/test-suite/chicken/chicken_ext_test_external.cxx index 338151e88..1dd6a7d53 100644 --- a/Examples/test-suite/chicken/ext_test_external.cxx +++ b/Examples/test-suite/chicken/chicken_ext_test_external.cxx @@ -1,4 +1,4 @@ -#include +#include #include void test_create(C_word,C_word,C_word) C_noret; @@ -7,16 +7,15 @@ void test_create(C_word argc, C_word closure, C_word continuation) { swig_type_info *type; A *newobj; C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); - + C_trace("test-create"); if (argc!=2) C_bad_argc(argc,2); newobj = new A(); - + type = SWIG_TypeQuery("A *"); resultobj = SWIG_NewPointerObj(newobj, type, 1); C_kontinue(continuation, resultobj); } - diff --git a/Examples/test-suite/guilescm/ext_test_external.cxx b/Examples/test-suite/guilescm/guilescm_ext_test_external.cxx similarity index 90% rename from Examples/test-suite/guilescm/ext_test_external.cxx rename to Examples/test-suite/guilescm/guilescm_ext_test_external.cxx index 713e5d2d0..30fa1ce7b 100644 --- a/Examples/test-suite/guilescm/ext_test_external.cxx +++ b/Examples/test-suite/guilescm/guilescm_ext_test_external.cxx @@ -1,4 +1,4 @@ -#include +#include #include SCM test_create() From 52858d5353a1e656f10561ec8e33df3bca4da520 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 27 Apr 2013 18:40:57 +0100 Subject: [PATCH 119/273] Fix boost intrusive_ptr testcase compilation with latest boost/gcc --- Examples/test-suite/li_boost_intrusive_ptr.i | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i index 2efa998a9..4916d0285 100644 --- a/Examples/test-suite/li_boost_intrusive_ptr.i +++ b/Examples/test-suite/li_boost_intrusive_ptr.i @@ -13,9 +13,12 @@ %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerived; %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerivedDerived; -%inline %{ -#include "boost/shared_ptr.hpp" -#include "boost/intrusive_ptr.hpp" +%{ +template void intrusive_ptr_add_ref(const T* r) { r->addref(); } +template void intrusive_ptr_release(const T* r) { r->release(); } + +#include +#include #include // Uncomment macro below to turn on intrusive_ptr memory leak checking as described above @@ -102,8 +105,6 @@ %ignore IgnoredRefCountingBase; %ignore *::operator=; -%ignore intrusive_ptr_add_ref; -%ignore intrusive_ptr_release; %newobject pointerownertest(); %newobject smartpointerpointerownertest(); @@ -430,10 +431,6 @@ template struct Pair : Base { Pair pair_id2(Pair p) { return p; } SwigBoost::intrusive_ptr< Pair > pair_id1(SwigBoost::intrusive_ptr< Pair > p) { return p; } -template void intrusive_ptr_add_ref(const T* r) { r->addref(); } - -template void intrusive_ptr_release(const T* r) { r->release(); } - long use_count(const SwigBoost::shared_ptr& sptr) { return sptr.use_count(); } From 99231457dbe6436df46c8d4d6b22aa906cf48e6d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Apr 2013 17:59:40 +0100 Subject: [PATCH 120/273] Fixes for warnings issued by clang --- Source/Modules/lua.cxx | 2 -- Source/Modules/modula3.cxx | 19 ------------------- 2 files changed, 21 deletions(-) diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index cfb3a3f5b..a33898a2f 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -106,7 +106,6 @@ private: File *f_wrappers; File *f_init; File *f_initbeforefunc; - String *PrefixPlusUnderscore; String *s_cmd_tab; // table of command names String *s_var_tab; // table of global variables String *s_const_tab; // table of global constants @@ -150,7 +149,6 @@ public: f_wrappers(0), f_init(0), f_initbeforefunc(0), - PrefixPlusUnderscore(0), s_cmd_tab(0), s_var_tab(0), s_const_tab(0), diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index ffb172f8f..4c56d0664 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -204,9 +204,6 @@ private: String *proxy_class_name; String *variable_name; //Name of a variable being wrapped String *variable_type; //Type of this variable - String *enumeration_name; //Name of the current enumeration type - Hash *enumeration_items; //and its members - int enumeration_max; Hash *enumeration_coll; //Collection of all enumerations. /* The items are nodes with members: "items" - hash of with key 'itemname' and content 'itemvalue' @@ -268,9 +265,6 @@ MODULA3(): proxy_class_name(NULL), variable_name(NULL), variable_type(NULL), - enumeration_name(NULL), - enumeration_items(NULL), - enumeration_max(0), enumeration_coll(NULL), constant_values(NULL), constantfilename(NULL), @@ -1784,19 +1778,6 @@ MODULA3(): } } -#if 0 - void generateEnumerationItem(const String *name, const String *value, int numvalue) { - String *oldsymname = Getattr(enumeration_items, value); - if (oldsymname != NIL) { - Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "The value <%s> is already assigned to <%s>.\n", value, oldsymname); - } - Setattr(enumeration_items, value, name); - if (enumeration_max < numvalue) { - enumeration_max = numvalue; - } - } -#endif - void emitEnumeration(File *file, String *name, Node *n) { Printf(file, "%s = {", name); int i; From e0e4a4db6d48f0fc1b5fa638650369af1e1c5507 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Apr 2013 18:41:11 +0100 Subject: [PATCH 121/273] Warning fix for ccache-swig tests clang deletes the output 'file' whereas gcc does not if the output 'file' is actually a directory. --- CCache/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CCache/test.sh b/CCache/test.sh index 9581c85e3..f64c3e3de 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -142,7 +142,7 @@ basetests() { testname="non-regular" mkdir testd $CCACHE_COMPILE -o testd -c test1.c > /dev/null 2>&1 - rmdir testd + rm -rf testd checkstat 'output to a non-regular file' 1 testname="no-input" @@ -315,7 +315,7 @@ swigtests() { testname="non-regular" mkdir testd $CCACHE_COMPILE -o testd -java testswig1.i > /dev/null 2>&1 - rmdir testd + rm -rf testd checkstat 'output to a non-regular file' 1 testname="no-input" From 7dfe4a065368a8658ed0f2ecf58dfc2cf981713e Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Thu, 7 Mar 2013 14:39:38 +0100 Subject: [PATCH 122/273] Make guile test suite default to scm api In other words guilescm becomes guile. Deprecated gh api tests are moved to guilegh. --- Examples/test-suite/guile/Makefile.in | 13 +++++++-- .../guile_ext_test_external.cxx} | 2 +- .../guile_ext_test_runme.scm} | 2 +- .../{guilescm_ext_test.i => guile_ext_test.i} | 2 +- .../{guilescm => guilegh}/Makefile.in | 29 +++---------------- Makefile.in | 8 ++--- configure.ac | 12 ++++---- 7 files changed, 27 insertions(+), 41 deletions(-) rename Examples/test-suite/{guilescm/guilescm_ext_test_external.cxx => guile/guile_ext_test_external.cxx} (90%) rename Examples/test-suite/{guilescm/guilescm_ext_test_runme.scm => guile/guile_ext_test_runme.scm} (82%) rename Examples/test-suite/{guilescm_ext_test.i => guile_ext_test.i} (93%) rename Examples/test-suite/{guilescm => guilegh}/Makefile.in (50%) diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in index c6be92c32..455c26a66 100644 --- a/Examples/test-suite/guile/Makefile.in +++ b/Examples/test-suite/guile/Makefile.in @@ -2,14 +2,16 @@ # Makefile for guile test-suite ####################################################################### +EXTRA_TEST_CASES += guile_ext_test.externaltest + LANGUAGE = guile -VARIANT = _gh +VARIANT = SCRIPTSUFFIX = _runme.scm srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ GUILE = @GUILE@ -GUILE_RUNTIME=-runtime +GUILE_RUNTIME= C_TEST_CASES = long_long \ list_vector \ @@ -20,7 +22,7 @@ C_TEST_CASES = long_long \ include $(srcdir)/../common.mk # Overridden variables here -# none! +INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guile # Custom tests - tests with additional commandline options %.multicpptest: SWIGOPT += $(GUILE_RUNTIME) @@ -41,6 +43,11 @@ include $(srcdir)/../common.mk +$(swig_and_compile_multi_cpp) $(run_testcase) +%.externaltest: + $(setup) + +$(swig_and_compile_external) + $(run_testcase) + # Runs the testcase. A testcase is only run if # a file is found which has _runme.scm appended after the testcase name. run_testcase = \ diff --git a/Examples/test-suite/guilescm/guilescm_ext_test_external.cxx b/Examples/test-suite/guile/guile_ext_test_external.cxx similarity index 90% rename from Examples/test-suite/guilescm/guilescm_ext_test_external.cxx rename to Examples/test-suite/guile/guile_ext_test_external.cxx index 30fa1ce7b..c4f906a97 100644 --- a/Examples/test-suite/guilescm/guilescm_ext_test_external.cxx +++ b/Examples/test-suite/guile/guile_ext_test_external.cxx @@ -1,4 +1,4 @@ -#include +#include #include SCM test_create() diff --git a/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm b/Examples/test-suite/guile/guile_ext_test_runme.scm similarity index 82% rename from Examples/test-suite/guilescm/guilescm_ext_test_runme.scm rename to Examples/test-suite/guile/guile_ext_test_runme.scm index ff3df064b..452b08ee7 100644 --- a/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm +++ b/Examples/test-suite/guile/guile_ext_test_runme.scm @@ -1,4 +1,4 @@ -(dynamic-call "scm_init_guilescm_ext_test_module" (dynamic-link "./libguilescm_ext_test.so")) +(dynamic-call "scm_init_guile_ext_test_module" (dynamic-link "./libguile_ext_test.so")) ; This is a test for SF Bug 1573892 ; If IsPointer is called before TypeQuery, the test-is-pointer will fail diff --git a/Examples/test-suite/guilescm_ext_test.i b/Examples/test-suite/guile_ext_test.i similarity index 93% rename from Examples/test-suite/guilescm_ext_test.i rename to Examples/test-suite/guile_ext_test.i index fd5655d4f..170695f6c 100644 --- a/Examples/test-suite/guilescm_ext_test.i +++ b/Examples/test-suite/guile_ext_test.i @@ -1,4 +1,4 @@ -%module guilescm_ext_test +%module guile_ext_test /* just use the imports_a.h header... for this test we only need a class */ %{ diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilegh/Makefile.in similarity index 50% rename from Examples/test-suite/guilescm/Makefile.in rename to Examples/test-suite/guilegh/Makefile.in index ba1cba440..3a03d5f82 100644 --- a/Examples/test-suite/guilescm/Makefile.in +++ b/Examples/test-suite/guilegh/Makefile.in @@ -2,16 +2,13 @@ # Makefile for guile test-suite (with SCM API) ####################################################################### -EXTRA_TEST_CASES += guilescm_ext_test.externaltest - include ../guile/Makefile # Overridden variables here -INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guilescm -VARIANT = +VARIANT = _gh # Refer to the guile directory for the run scripts SCRIPTPREFIX = ../guile/ -GUILE_RUNTIME= +GUILE_RUNTIME=-runtime # Custom tests - tests with additional commandline options # none! @@ -25,25 +22,7 @@ run_testcase = \ setup = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ + echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with GH API)" ; \ else \ - echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \ - fi - -%.externaltest: - $(local_setup) - +$(swig_and_compile_external) - $(local_run_testcase) - -# Same as setup and run_testcase, but without the SCRIPTPREFIX (so the runme comes from the guilescm directory) -local_setup = \ - if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ - echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ - else \ - echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \ - fi - -local_run_testcase = \ - if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$*$(SCRIPTSUFFIX); \ + echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with GH API)" ; \ fi diff --git a/Makefile.in b/Makefile.in index c47cdbe7c..6b7a99220 100644 --- a/Makefile.in +++ b/Makefile.in @@ -59,7 +59,7 @@ skip-tcl = test -n "@SKIP_TCL@" skip-perl5 = test -n "@SKIP_PERL5@" skip-python = test -n "@SKIP_PYTHON@" skip-java = test -n "@SKIP_JAVA@" -skip-guilescm = test -n "@SKIP_GUILESCM@" +skip-guilegh = test -n "@SKIP_GUILEGH@" skip-guile = test -n "@SKIP_GUILE@" skip-mzscheme = test -n "@SKIP_MZSCHEME@" skip-ruby = test -n "@SKIP_RUBY@" @@ -247,7 +247,7 @@ check-test-suite: \ check-perl5-test-suite \ check-python-test-suite \ check-java-test-suite \ - check-guilescm-test-suite \ + check-guilegh-test-suite \ check-guile-test-suite \ check-mzscheme-test-suite \ check-ruby-test-suite \ @@ -300,7 +300,7 @@ all-test-suite: \ all-perl5-test-suite \ all-python-test-suite \ all-java-test-suite \ - all-guilescm-test-suite \ + all-guilegh-test-suite \ all-guile-test-suite \ all-mzscheme-test-suite \ all-ruby-test-suite \ @@ -329,7 +329,7 @@ broken-test-suite: \ broken-perl5-test-suite \ broken-python-test-suite \ broken-java-test-suite \ - broken-guilescm-test-suite \ + broken-guilegh-test-suite \ broken-guile-test-suite \ broken-mzscheme-test-suite \ broken-ruby-test-suite \ diff --git a/configure.ac b/configure.ac index 83b46f520..7b259c78d 100644 --- a/configure.ac +++ b/configure.ac @@ -2268,16 +2268,16 @@ AC_SUBST(SKIP_JAVA) SKIP_GUILE= -if test -z "$GUILEINCLUDE" || test -z "$GUILELIB" || test -z "$GUILE_GH_INTERFACE"; then +if test -z "$GUILEINCLUDE" || test -z "$GUILELIB" || test -z "$GUILE_SCM_INTERFACE"; then SKIP_GUILE="1" fi AC_SUBST(SKIP_GUILE) -SKIP_GUILESCM= -if test -z "$GUILEINCLUDE" || test -z "$GUILELIB" || test -z "$GUILE_SCM_INTERFACE"; then - SKIP_GUILESCM="1" +SKIP_GUILEGH= +if test -z "$GUILEINCLUDE" || test -z "$GUILELIB" || test -z "$GUILE_GH_INTERFACE"; then + SKIP_GUILEGH="1" fi -AC_SUBST(SKIP_GUILESCM) +AC_SUBST(SKIP_GUILEGH) SKIP_MZSCHEME= @@ -2454,7 +2454,7 @@ AC_CONFIG_FILES([ \ Examples/test-suite/csharp/Makefile \ Examples/test-suite/d/Makefile \ Examples/test-suite/guile/Makefile \ - Examples/test-suite/guilescm/Makefile \ + Examples/test-suite/guilegh/Makefile \ Examples/test-suite/java/Makefile \ Examples/test-suite/mzscheme/Makefile \ Examples/test-suite/ocaml/Makefile \ From 2c23a5d2cdbe45c7408aa50c667b5e4647ef05b6 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 4 Mar 2013 22:12:09 +0100 Subject: [PATCH 123/273] Add support for guile 2.0: update swg and interface files Note: only the scm interface is considered. --- Lib/guile/ghinterface.i | 46 ++++++++++++++ Lib/guile/guile_gh_run.swg | 34 ++++++++++- Lib/guile/guile_scm_run.swg | 117 ++++++++++++++++++++++++++++++++---- Lib/guile/typemaps.i | 6 +- 4 files changed, 186 insertions(+), 17 deletions(-) diff --git a/Lib/guile/ghinterface.i b/Lib/guile/ghinterface.i index c5fda62cf..022c0f568 100644 --- a/Lib/guile/ghinterface.i +++ b/Lib/guile/ghinterface.i @@ -1,3 +1,5 @@ +#ifdef GUILE_VERSION_1_6 + #define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED)) #define gh_apply(a, b) scm_apply(a, b, SCM_EOL) #define gh_bool2scm SCM_BOOL @@ -37,3 +39,47 @@ #define gh_vector_ref scm_vector_ref #define gh_vector_set_x scm_vector_set_x #define gh_char2scm SCM_MAKE_CHAR + +#else + +#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED)) +#define gh_apply(a, b) scm_apply(a, b, SCM_EOL) +#define gh_bool2scm scm_from_bool +#define gh_boolean_p scm_is_bool +#define gh_car SCM_CAR +#define gh_cdr SCM_CDR +#define gh_cons scm_cons +#define gh_double2scm scm_from_double +#define gh_int2scm scm_from_long +#define gh_length(lst) scm_to_ulong(scm_length(lst)) +#define gh_list scm_listify +#define gh_list_to_vector scm_vector +#define gh_make_vector scm_make_vector +#define gh_null_p scm_is_null +#define gh_number_p scm_is_number +#define gh_pair_p scm_is_pair +#define gh_scm2bool scm_is_true +#define gh_scm2char SCM_CHAR +#define gh_scm2double scm_to_double +#define gh_scm2int scm_to_int +#define gh_scm2long scm_to_long +#define gh_scm2short scm_to_short +#define gh_scm2newstr SWIG_Guile_scm2newstr +#define gh_scm2ulong scm_to_ulong +#define gh_scm2ushort scm_to_ushort +#define gh_scm2uint scm_to_uint +#define gh_ulong2scm scm_from_ulong +#define gh_long2scm scm_from_long +#define gh_str02scm(str) str ? scm_from_locale_string(str) : SCM_BOOL_F +#define gh_long_long2scm scm_from_long_long +#define gh_scm2long_long scm_to_long_long +#define gh_ulong_long2scm scm_from_ulong_long +#define gh_scm2ulong_long scm_to_ulong_long +#define gh_string_p scm_is_string +#define gh_vector_length scm_c_vector_length +#define gh_vector_p scm_is_vector +#define gh_vector_ref scm_vector_ref +#define gh_vector_set_x scm_vector_set_x +#define gh_char2scm SCM_MAKE_CHAR + +#endif \ No newline at end of file diff --git a/Lib/guile/guile_gh_run.swg b/Lib/guile/guile_gh_run.swg index d8cc56b91..8616875da 100644 --- a/Lib/guile/guile_gh_run.swg +++ b/Lib/guile/guile_gh_run.swg @@ -15,6 +15,36 @@ extern "C" { #endif + +/* In the code below, use guile 2.0 compatible functions where possible. + Functions that don't exist in older versions will be mapped to + a deprecated equivalent for those versions only */ +/* ... setup guile 2-like interface for guile 1.6 */ +#if (SCM_MAJOR_VERSION == 1) && (SCM_MINOR_VERSION <= 6) + +# define scm_from_locale_keyword scm_c_make_keyword +# define scm_from_locale_symbol scm_str2symbol +# define scm_is_null SCM_NULLP +# define scm_is_true SCM_NFALSEP +# define scm_is_string SCM_STRINGP + +/* Used later on to setup different code paths where it's + not possible to use a guile 2-like interface */ +# define GUILE_VERSION_1_6 + +#endif + +/* ... setup guile 2-like interface for guile 1.6 and 1.8 */ +#if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2) + +static SCM +scm_module_variable (SCM module, SCM sym) +{ + return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F); +} + +#endif + typedef SCM (*swig_guile_proc)(); #define SWIG_malloc(size) \ @@ -150,7 +180,7 @@ SWIG_Guile_ConvertPtr(swig_module_info *module, SCM s, void **result, { swig_cast_info *cast; swig_type_info *from; - if (SCM_NULLP(s)) { + if (scm_is_null(s)) { *result = NULL; return SWIG_OK; } else if (SCM_NIMP(s)) { @@ -246,7 +276,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest, } for (; i= 2 +// scm_c_define_gsubr takes a different parameter type +// depending on the guile version + +typedef scm_t_subr swig_guile_proc; +#else typedef SCM (*swig_guile_proc)(); +#endif typedef SCM (*guile_destructor)(SCM); typedef struct swig_guile_clientdata { @@ -22,10 +59,17 @@ typedef struct swig_guile_clientdata { #define SWIG_scm2str(s) \ SWIG_Guile_scm2newstr(s, NULL) -#define SWIG_malloc(size) \ - SCM_MUST_MALLOC(size) -#define SWIG_free(mem) \ - scm_must_free(mem) +#ifdef GUILE_VERSION_1_6 +# define SWIG_malloc(size) \ + SCM_MUST_MALLOC(size) +# define SWIG_free(mem) \ + scm_must_free(mem) +#else +# define SWIG_malloc(size) \ + scm_malloc(size) +# define SWIG_free(mem) \ + free(mem) +#endif #define SWIG_ConvertPtr(s, result, type, flags) \ SWIG_Guile_ConvertPtr(s, result, type, flags) #define SWIG_MustGetPtr(s, type, argnum, flags) \ @@ -42,7 +86,7 @@ typedef struct swig_guile_clientdata { SWIG_Guile_IsPointer(object) #define SWIG_contract_assert(expr, msg) \ if (!(expr)) \ - scm_error(scm_str2symbol("swig-contract-assertion-failed"), \ + scm_error(scm_from_locale_symbol("swig-contract-assertion-failed"), \ (char *) FUNC_NAME, (char *) msg, \ SCM_EOL, SCM_BOOL_F); else @@ -61,15 +105,25 @@ SWIGINTERN char * SWIG_Guile_scm2newstr(SCM str, size_t *len) { #define FUNC_NAME "SWIG_Guile_scm2newstr" char *ret; +# ifndef GUILE_VERSION_1_6 + char *tmp; +# endif size_t l; - SCM_ASSERT (SCM_STRINGP(str), str, 1, FUNC_NAME); - - l = SCM_STRING_LENGTH(str); + SCM_ASSERT (scm_is_string(str), str, 1, FUNC_NAME); + l = scm_c_string_length(str); + ret = (char *) SWIG_malloc( (l + 1) * sizeof(char)); if (!ret) return NULL; +# ifdef GUILE_VERSION_1_6 memcpy(ret, SCM_STRING_CHARS(str), l); +# else + tmp = scm_to_locale_string(str); + memcpy(ret, tmp, l); + free(tmp); +# endif + ret[l] = '\0'; if (len) *len = l; return ret; @@ -86,7 +140,7 @@ static SCM swig_keyword = SCM_EOL; static SCM swig_symbol = SCM_EOL; #define SWIG_Guile_GetSmob(x) \ - ( SCM_NNULLP(x) && SCM_INSTANCEP(x) && SCM_NFALSEP(scm_slot_exists_p(x, swig_symbol)) \ + ( !scm_is_null(x) && SCM_INSTANCEP(x) && scm_is_true(scm_slot_exists_p(x, swig_symbol)) \ ? scm_slot_ref(x, swig_symbol) : (x) ) SWIGINTERN SCM @@ -361,6 +415,7 @@ ensure_smob_tag(SCM swig_module, const char *smob_name, const char *scheme_variable_name) { +#ifdef GUILE_VERSION_1_6 SCM variable = scm_sym2var(scm_str2symbol(scheme_variable_name), scm_module_lookup_closure(swig_module), SCM_BOOL_T); @@ -375,6 +430,20 @@ ensure_smob_tag(SCM swig_module, "SWIG_Guile_Init"); return 0; } +#else + SCM variable = scm_module_variable(swig_module, + scm_from_locale_symbol(scheme_variable_name)); + if (scm_is_false(variable)) { + *tag_variable = scm_make_smob_type((char*)scheme_variable_name, 0); + scm_c_module_define(swig_module, scheme_variable_name, + scm_from_ulong(*tag_variable)); + return 1; + } + else { + *tag_variable = scm_to_ulong(SCM_VARIABLE_REF(variable)); + return 0; + } +#endif } SWIGINTERN SCM @@ -409,8 +478,8 @@ SWIG_Guile_Init () } swig_make_func = scm_permanent_object( scm_variable_ref(scm_c_module_lookup(scm_c_resolve_module("oop goops"), "make"))); - swig_keyword = scm_permanent_object(scm_c_make_keyword((char*) "init-smob")); - swig_symbol = scm_permanent_object(scm_str2symbol("swig-smob")); + swig_keyword = scm_permanent_object(scm_from_locale_keyword((char*) "init-smob")); + swig_symbol = scm_permanent_object(scm_from_locale_symbol("swig-smob")); #ifdef SWIG_INIT_RUNTIME_MODULE SWIG_INIT_RUNTIME_MODULE #endif @@ -426,6 +495,7 @@ SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)) module = SWIG_Guile_Init(); +#ifdef GUILE_VERSION_1_6 variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), scm_module_lookup_closure(module), SCM_BOOL_T); @@ -434,6 +504,15 @@ SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)) } else { return (swig_module_info *) scm_num2ulong(SCM_VARIABLE_REF(variable), 0, "SWIG_Guile_Init"); } +#else + variable = scm_module_variable(module, + scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME)); + if (scm_is_false(variable)) { + return NULL; + } else { + return (swig_module_info *) scm_to_ulong(SCM_VARIABLE_REF(variable)); + } +#endif } SWIGINTERN void @@ -444,11 +523,17 @@ SWIG_Guile_SetModule(swig_module_info *swig_module) module = SWIG_Guile_Init(); +#ifdef GUILE_VERSION_1_6 variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), scm_module_lookup_closure(module), SCM_BOOL_T); SCM_VARIABLE_SET(variable, scm_ulong2num((unsigned long) swig_module)); +#else + scm_module_define(module, + scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), + scm_from_ulong((unsigned long) swig_module)); +#endif } SWIGINTERN int @@ -460,7 +545,11 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest, int num_args_passed = 0; for (i = 0; i Date: Thu, 7 Mar 2013 11:55:01 +0100 Subject: [PATCH 124/273] Add support for guile 2.0: configure and makefiles. Note: guile-config is badly broken for guile 2. So the guile configure section has been rewritten to use pkg-config instead. Manually resolved conflicts: Examples/Makefile.in --- Examples/Makefile.in | 31 +++--- Examples/guile/Makefile.in | 8 +- Makefile.in | 2 +- configure.ac | 204 ++++++++++++++++++------------------- 4 files changed, 122 insertions(+), 123 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 240274278..6b4ca778e 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -455,11 +455,11 @@ octave_clean: # Make sure these locate your Guile installation GUILE = @GUILE@ -GUILE_INCLUDE = @GUILEINCLUDE@ -GUILE_LIB = @GUILELIB@ +GUILE_CFLAGS = @GUILE_CFLAGS@ GUILE_SO = @GUILE_SO@ +GUILE_LIBS = @GUILE_LIBS@ +GUILE_LIBOPTS = @LIBS@ $(SYSLIBS) GUILE_LIBPREFIX = lib -GUILE_LIBOPTS = @GUILELINK@ @LIBS@ $(SYSLIBS) GUILE_SCRIPT = $(RUNME).scm #------------------------------------------------------------------ @@ -467,13 +467,14 @@ GUILE_SCRIPT = $(RUNME).scm #------------------------------------------------------------------ guile: $(SRCS) $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) + $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) -guile_cpp: $(SRCS) +guile_cpp: $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) +$(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCS) $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $@ guile_externalhdr: $(SWIG) -guile -external-runtime $(TARGET) @@ -483,12 +484,12 @@ guile_externalhdr: #------------------------------------------------------------------ guile_gh: $(SRCS) $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) + $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_gh_cpp: $(SRCS) $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) # ----------------------------------------------------------------- @@ -497,12 +498,12 @@ guile_gh_cpp: $(SRCS) guile_passive: $(SRCS) $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) + $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_passive_cpp: $(SRCS) $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) # ----------------------------------------------------------------- @@ -513,23 +514,23 @@ guile_static: $(SRCS) $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ - $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile + $(GUILE_CFLAGS) $(LIBS) -L$(GUILE_LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_static_cpp: $(SRCS) $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ - $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile + $(GUILE_CFLAGS) $(LIBS) -L$(GUILE_LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple: $(SRCS) $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ - $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile + $(GUILE_CFLAGS) $(LIBS) -L$(GUILE_LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple_cpp: $(SRCS) $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ - $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile + $(GUILE_CFLAGS) $(LIBS) -L$(GUILE_LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile # ----------------------------------------------------------------- # Running a Guile example diff --git a/Examples/guile/Makefile.in b/Examples/guile/Makefile.in index 9e6f9f6c6..3110ac994 100644 --- a/Examples/guile/Makefile.in +++ b/Examples/guile/Makefile.in @@ -7,8 +7,8 @@ SWIG = ../$(top_srcdir)/preinst-swig CC = @CC@ CXX = @CXX@ CFLAGS = @PLATFLAGS@ -GUILEINCLUDE = @GUILEINCLUDE@ -GUILELINK = @GUILELINK@ +GUILE_CFLAGS = @GUILE_CFLAGS@ +GUILE_LIBS = @GUILE_LIBS@ SWIGOPT = WRAP = $(IFILE:.i=_wrap.c) @@ -31,10 +31,10 @@ guile_clean: sub-all: $(SWIG) -guile $(SWIGOPT) $(IFILE) - $(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILEINCLUDE) $(GUILELINK) + $(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) sub-all-cxx: $(SWIG) -c++ -guile $(SWIGOPT) $(IFILE) - $(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILEINCLUDE) $(GUILELINK) + $(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) # Makefile ends here diff --git a/Makefile.in b/Makefile.in index 6b7a99220..c33889587 100644 --- a/Makefile.in +++ b/Makefile.in @@ -59,7 +59,7 @@ skip-tcl = test -n "@SKIP_TCL@" skip-perl5 = test -n "@SKIP_PERL5@" skip-python = test -n "@SKIP_PYTHON@" skip-java = test -n "@SKIP_JAVA@" -skip-guilegh = test -n "@SKIP_GUILEGH@" +skip-guilegh = test -n "@SKIP_GUILEGH@" skip-guile = test -n "@SKIP_GUILE@" skip-mzscheme = test -n "@SKIP_MZSCHEME@" skip-ruby = test -n "@SKIP_RUBY@" diff --git a/configure.ac b/configure.ac index 7b259c78d..28696529d 100644 --- a/configure.ac +++ b/configure.ac @@ -157,7 +157,7 @@ if test "$GCC" = yes; then else ISYSTEM="-I" fi - +AC_MSG_NOTICE(ISYSTEM: $ISYSTEM) dnl Info for building shared libraries ... in order to run the examples @@ -1148,125 +1148,123 @@ AC_SUBST(NDKBUILD) # Look for Guile #---------------------------------------------------------------- -GUILEPACKAGE= -GUILEINCLUDE= GUILE= -GUILELIB= -GUILELINK= -GUILEPKGDATADIR= +GUILE_CFLAGS= +GUILE_LIBS= -AC_ARG_WITH(guile-config,AS_HELP_STRING([--without-guile], [Disable Guile]) -AS_HELP_STRING([--with-guile-config=path], [Set location of guile-config]),[ GUILE_CONFIG="$withval"], [GUILE_CONFIG=]) -AC_ARG_WITH(guilepackage, AS_HELP_STRING([--with-guile-prefix=path], [Set location of Guile tree]),[ - GUILEPACKAGE="$withval"]) -AC_ARG_WITH(guile,[ --with-guile=path Set location of Guile executable],[ - GUILE="$withval"], [GUILE=yes]) -AC_ARG_WITH(guileincl,[ --with-guileincl=path Set location of Guile include directory],[ - GUILEINCLUDE="$withval"]) -AC_ARG_WITH(guilelib,[ --with-guilelib=path Set location of Guile library directory],[ - GUILELIB="$withval"]) +AC_ARG_WITH(guile, AS_HELP_STRING([--without-guile], [Disable Guile]) +AS_HELP_STRING([--with-guile=path], [Set location of Guile executable]),[GUILE="$withval"], [GUILE=yes]) +AC_ARG_WITH(guile-cflags,[ --with-guile-cflags=cflags Set cflags required to compile against Guile],[ + GUILE_CFLAGS="$withval"]) +AC_ARG_WITH(guile-libs,[ --with-guile-libs=ldflags Set ldflags needed to link with Guile],[ + GUILE_LIBS="$withval"]) # First, check for "--without-guile" or "--with-guile=no". if test x"${GUILE}" = xno -o x"${with_alllang}" = xno ; then -AC_MSG_NOTICE([Disabling Guile]) + AC_MSG_NOTICE([Disabling Guile]) + GUILE= + GUILE_CFLAGS= + GUILE_LIBS= else -if test -z "$GUILE_CONFIG" ; then - AC_PATH_PROG(GUILE_CONFIG, guile-config) -fi - -if test -n "$GUILE_CONFIG" ; then - GUILEPACKAGE="`$GUILE_CONFIG info prefix`" - GUILEINCLUDE="`$GUILE_CONFIG info includedir`" - GUILELIB="`$GUILE_CONFIG info libdir`" - GUILE="`$GUILE_CONFIG info bindir`/guile" - GUILELINK="`$GUILE_CONFIG link`" - GUILEPKGDATADIR="`$GUILE_CONFIG info pkgdatadir`" -fi - - if test -z "$GUILE" -o "x$GUILE" = xyes; then - if test -n "$GUILEPACKAGE"; then - GUILE="$GUILEPACKAGE/bin/guile" - else - GUILE= - fi + # Use pkg-config to find guile specific config parameters + # Note: if guile is not installed in a standard system path + # you can set the environment variable PKG_CONFIG_PATH to + # the directory where the guile package config file is stored + AC_PATH_PROG(PKG_CONFIG,pkg-config) + if test "x$PKG_CONFIG" = x; then + # @*%&$ Ximian programmers renamed this application + AC_PATH_PROG(PKG_CONFIG,pkgconfig) fi + if test "x$PKG_CONFIG" = x; then + AC_MSG_NOTICE([Could not find the pkg-config (or pkgconfig) program required to set up Guile. Disabling Guile],) + GUILE= + GUILE_CFLAGS= + GUILE_LIBS="" + else - if test -z "$GUILEINCLUDE"; then - if test -n "$GUILEPACKAGE"; then - GUILEINCLUDE="$GUILEPACKAGE/include" - fi - fi + # If the user has given these values, cache them to override the + # detected values. + if test "x$GUILE_LIBS" != x; then + saved_GUILE_LIBS="$GUILE_LIBS" + fi + if test "x$GUILE_CFLAGS" != x; then + saved_GUILE_CFLAGS="$GUILE_CFLAGS" + fi - if test -z "$GUILELIB"; then - if test -n "$GUILEPACKAGE"; then - GUILELIB="$GUILEPACKAGE/lib" - fi - fi + # Look up GUILE_CFLAGS and GUILE_LIBS, and version check + GUILE_SERIES="" + PKG_CHECK_MODULES(GUILE, [guile-1.8], [ GUILE_SERIES="18" ], [ + PKG_CHECK_MODULES(GUILE, [guile-2.0], [GUILE_SERIES="20" ], [AC_MSG_NOTICE([ + Only Guile 1.8 or 2.0 is supported. Neither version appears to be installed correctly. Disabling Guile + ])]) + ]) + if test "x$GUILE-SERIES" = x; then + GUILE= + GUILE_CFLAGS= + GUILE_LIBS= + else + # Look up GUILE executable + if test "x$GUILE" = xyes; then + GUILE= + if test "$xGUILE_SERIES" = "x18"; then + AC_PATH_PROG(GUILE18, guile-1.8) + if test "x$GUILE18" != x; then + GUILE="$GUILE18" + fi + fi + if test "$xGUILE_SERIES" = "x20"; then + AC_PATH_PROG(GUILE20, guile-2.0) + if test "x$GUILE20" != x; then + GUILE="$GUILE20" + fi + fi + if test "x$GUILE" = x; then + AC_PATH_PROG(GUILE, guile) + fi + fi -AC_MSG_CHECKING(for Guile header files) + if test "x$saved_GUILE_LIBS" != x; then + GUILE_LIBS="$saved_GUILE_LIBS" + fi + if test "x$saved_GUILE_CFLAGS" != x; then + GUILE_CFLAGS="$saved_GUILE_CFLAGS" + fi - dirs="$GUILEINCLUDE" - for i in $dirs ; do - if test -r $i/guile/gh.h; then - AC_MSG_RESULT($i) - GUILEINCLUDE="$ISYSTEM$i" - break - fi - done - if test -z "$GUILEINCLUDE"; then - AC_MSG_RESULT(not found) - fi + guilesafe_CFLAGS=$CFLAGS + guilesafe_LIBS=$LIBS + # Filter out "-ansi -pedantic" because Guile header files will not compile with these flags. + # (The flags -ansi -pedantic are automatically added by ac_compile_warnings.m4) + CFLAGS="`echo $CFLAGS | sed 's/-ansi//g;s/-pedantic//g;'` $GUILE_CFLAGS" + LIBS="$LIBS $GUILE_LIBS" - AC_MSG_CHECKING(for Guile library) - dirs="$GUILELIB" - for i in $dirs ; do - if test -r $i/libguile.so; then - AC_MSG_RESULT($i) - GUILELIB="$i" - break - fi - done - if test -z "$GUILELIB"; then - AC_MSG_RESULT(not found) - fi - -if test -z "$GUILELINK"; then - GUILELINK="-L$GUILELIB -lguile" -fi - -guilesafe_CFLAGS=$CFLAGS -guilesafe_LIBS=$LIBS -# Filter out "-ansi -pedantic" because Guile header files will not compile with these flags. -# (The flags -ansi -pedantic are automatically added by ac_compile_warnings.m4) -CFLAGS="`echo $CFLAGS | sed 's/-ansi//g;s/-pedantic//g;'` $GUILEINCLUDE" -LIBS="$LIBS $GUILELINK" - -AC_MSG_CHECKING(whether Guile's gh_ API works) -AC_LINK_IFELSE([AC_LANG_SOURCE([#include - int main() { SCM s; return gh_scm2int(s); }])], GUILE_GH_INTERFACE=1, ) -if test -n "$GUILE_GH_INTERFACE" ; then + AC_MSG_CHECKING(whether Guile's gh_ API works) + AC_LINK_IFELSE([AC_LANG_SOURCE([#include + int main() { SCM s; return gh_scm2int(s); }])], GUILE_GH_INTERFACE=1, ) + if test -n "$GUILE_GH_INTERFACE" ; then AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi -AC_MSG_CHECKING(whether Guile's SCM_ API works) -AC_LINK_IFELSE([AC_LANG_SOURCE([#include - int main() { SCM s; scm_slot_exists_p(SCM_BOOL_F, SCM_BOOL_F); return SCM_STRING_LENGTH(s); }])], GUILE_SCM_INTERFACE=1, ) -if test -n "$GUILE_SCM_INTERFACE" ; then + else + AC_MSG_RESULT(no) + fi + AC_MSG_CHECKING(whether Guile's SCM_ API works) + AC_LINK_IFELSE([AC_LANG_SOURCE([#include + int main() { SCM s; scm_slot_exists_p(SCM_BOOL_F, SCM_BOOL_F); return SCM_STRING_LENGTH(s); }])], GUILE_SCM_INTERFACE=1, ) + if test -n "$GUILE_SCM_INTERFACE" ; then AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi -CFLAGS=$guilesafe_CFLAGS -LIBS=$guilesafe_LIBS + else + AC_MSG_RESULT(no) + fi + + CFLAGS=$guilesafe_CFLAGS + LIBS=$guilesafe_LIBS + fi + fi fi AC_SUBST(GUILE) -AC_SUBST(GUILEINCLUDE) -AC_SUBST(GUILELIB) -AC_SUBST(GUILELINK) +AC_SUBST(GUILE_CFLAGS) +AC_SUBST(GUILE_LIBS) AC_SUBST(GUILE_GH_INTERFACE) AC_SUBST(GUILE_SCM_INTERFACE) @@ -2268,13 +2266,13 @@ AC_SUBST(SKIP_JAVA) SKIP_GUILE= -if test -z "$GUILEINCLUDE" || test -z "$GUILELIB" || test -z "$GUILE_SCM_INTERFACE"; then +if test -z "$GUILE_CFLAGS" || test -z "$GUILE_LIBS" || test -z "$GUILE_SCM_INTERFACE"; then SKIP_GUILE="1" fi AC_SUBST(SKIP_GUILE) SKIP_GUILEGH= -if test -z "$GUILEINCLUDE" || test -z "$GUILELIB" || test -z "$GUILE_GH_INTERFACE"; then +if test -z "$GUILE_CFLAGS" || test -z "$GUILE_LIBS" || test -z "$GUILE_GH_INTERFACE"; then SKIP_GUILEGH="1" fi AC_SUBST(SKIP_GUILEGH) From 3c47730803afde678574496a4d71f7f241dce73e Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Fri, 19 Apr 2013 12:49:40 +0200 Subject: [PATCH 125/273] Drop support for guile 1.6 and older --- Doc/Manual/Guile.html | 49 +++++++++++++++---------- Lib/guile/ghinterface.i | 46 ----------------------- Lib/guile/guile_gh_run.swg | 17 +-------- Lib/guile/guile_scm_run.swg | 73 ------------------------------------- 4 files changed, 30 insertions(+), 155 deletions(-) diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 6f1300492..14fc03854 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -12,6 +12,7 @@
      +
    • Supported Guile Versions
    • Meaning of "Module"
    • Using the SCM or GH Guile API
    • Linkage @@ -47,7 +48,15 @@

      This section details guile-specific support in SWIG. -

      23.1 Meaning of "Module"

      +

      23.1 Supported Guile Versions

      + + +

      +SWIG works with Guile versions 1.8.x and 2.0.x. Support for version +1.6.x has been dropped. The last version of SWIG that still works with +Guile version 1.6.x is SWIG 2.0.9. + +

      23.2 Meaning of "Module"

      @@ -55,7 +64,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". -

      23.2 Using the SCM or GH Guile API

      +

      23.3 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 +112,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.

      -

      23.3 Linkage

      +

      23.4 Linkage

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

      23.3.1 Simple Linkage

      +

      23.4.1 Simple Linkage

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

      23.3.2 Passive Linkage

      +

      23.4.2 Passive Linkage

      Passive linkage is just like simple linkage, but it generates an @@ -216,7 +225,7 @@ package name (see below).

      You should use passive linkage rather than simple linkage when you are using multiple modules. -

      23.3.3 Native Guile Module Linkage

      +

      23.4.3 Native Guile Module Linkage

      SWIG can also generate wrapper code that does all the Guile module @@ -257,7 +266,7 @@ Newer Guile versions have a shorthand procedure for this:

    -

    23.3.4 Old Auto-Loading Guile Module Linkage

    +

    23.4.4 Old Auto-Loading Guile Module Linkage

    Guile used to support an autoloading facility for object-code @@ -283,7 +292,7 @@ option, SWIG generates an exported module initialization function with an appropriate name. -

    23.3.5 Hobbit4D Linkage

    +

    23.4.5 Hobbit4D Linkage

    @@ -308,7 +317,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very experimental; the (hobbit4d link) conventions are not well understood.

    -

    23.4 Underscore Folding

    +

    23.5 Underscore Folding

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

    23.5 Typemaps

    +

    23.6 Typemaps

    @@ -412,7 +421,7 @@ constant will appear as a scheme variable. See Features and the %feature directive for info on how to apply the %feature.

    -

    23.6 Representation of pointers as smobs

    +

    23.7 Representation of pointers as smobs

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

    23.6.1 GH Smobs

    +

    23.7.1 GH Smobs

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

    -

    23.6.2 SCM Smobs

    +

    23.7.2 SCM Smobs

    The SCM interface (using the "-scm" argument to swig) uses swigrun.swg. @@ -477,7 +486,7 @@ in the smob tag. If a generated GOOPS module has been loaded, smobs will be wra GOOPS class.

    -

    23.6.3 Garbage Collection

    +

    23.7.3 Garbage Collection

    Garbage collection is a feature of the new SCM interface, and it is automatically included @@ -491,7 +500,7 @@ is exactly like described in 23.7 Exception Handling +

    23.8 Exception Handling

    @@ -517,7 +526,7 @@ mapping: The default when not specified here is to use "swig-error". See Lib/exception.i for details. -

    23.8 Procedure documentation

    +

    23.9 Procedure documentation

    If invoked with the command-line option -procdoc @@ -553,7 +562,7 @@ like this: typemap argument doc. See Lib/guile/typemaps.i for details. -

    23.9 Procedures with setters

    +

    23.10 Procedures with setters

    For global variables, SWIG creates a single wrapper procedure @@ -581,7 +590,7 @@ struct members, the procedures (struct-member-get pointer) and (struct-member-set pointer value) are not generated. -

    23.10 GOOPS Proxy Classes

    +

    23.11 GOOPS Proxy Classes

    SWIG can also generate classes and generic functions for use with @@ -730,7 +739,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th %import "foo.h" before the %inline block.

    -

    23.10.1 Naming Issues

    +

    23.11.1 Naming Issues

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

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

    23.10.2 Linking

    +

    23.11.2 Linking

    The guile-modules generated above all need to be linked together. GOOPS support requires diff --git a/Lib/guile/ghinterface.i b/Lib/guile/ghinterface.i index 022c0f568..3de4c81a2 100644 --- a/Lib/guile/ghinterface.i +++ b/Lib/guile/ghinterface.i @@ -1,47 +1,3 @@ -#ifdef GUILE_VERSION_1_6 - -#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED)) -#define gh_apply(a, b) scm_apply(a, b, SCM_EOL) -#define gh_bool2scm SCM_BOOL -#define gh_boolean_p SCM_BOOLP -#define gh_car SCM_CAR -#define gh_cdr SCM_CDR -#define gh_cons scm_cons -#define gh_double2scm scm_make_real -#define gh_int2scm scm_long2num -#define gh_length(lst) scm_num2ulong(scm_length(lst), SCM_ARG1, FUNC_NAME) -#define gh_list scm_listify -#define gh_list_to_vector scm_vector -#define gh_make_vector scm_make_vector -#define gh_null_p SCM_NULLP -#define gh_number_p SCM_NUMBERP -#define gh_pair_p SCM_CONSP -#define gh_scm2bool SCM_NFALSEP -#define gh_scm2char SCM_CHAR -#define gh_scm2double(a) scm_num2dbl(a, FUNC_NAME) -#define gh_scm2int(a) scm_num2int(a, SCM_ARG1, FUNC_NAME) -#define gh_scm2long(a) scm_num2long(a, SCM_ARG1, FUNC_NAME) -#define gh_scm2short(a) scm_num2short(a, SCM_ARG1, FUNC_NAME) -#define gh_scm2newstr SWIG_Guile_scm2newstr -#define gh_scm2ulong(a) scm_num2ulong(a, SCM_ARG1, FUNC_NAME) -#define gh_scm2ushort(a) scm_num2ushort(a, SCM_ARG1, FUNC_NAME) -#define gh_scm2uint(a) scm_num2uint(a, SCM_ARG1, FUNC_NAME) -#define gh_ulong2scm scm_ulong2num -#define gh_long2scm scm_long2num -#define gh_str02scm scm_makfrom0str -#define gh_long_long2scm scm_long_long2num -#define gh_scm2long_long(a) scm_num2long_long(a, SCM_ARG1, FUNC_NAME) -#define gh_ulong_long2scm scm_ulong_long2num -#define gh_scm2ulong_long(a) scm_num2ulong_long(a, SCM_ARG1, FUNC_NAME) -#define gh_string_p SCM_STRINGP -#define gh_vector_length SCM_VECTOR_LENGTH -#define gh_vector_p SCM_VECTORP -#define gh_vector_ref scm_vector_ref -#define gh_vector_set_x scm_vector_set_x -#define gh_char2scm SCM_MAKE_CHAR - -#else - #define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED)) #define gh_apply(a, b) scm_apply(a, b, SCM_EOL) #define gh_bool2scm scm_from_bool @@ -81,5 +37,3 @@ #define gh_vector_ref scm_vector_ref #define gh_vector_set_x scm_vector_set_x #define gh_char2scm SCM_MAKE_CHAR - -#endif \ No newline at end of file diff --git a/Lib/guile/guile_gh_run.swg b/Lib/guile/guile_gh_run.swg index 8616875da..1292131c8 100644 --- a/Lib/guile/guile_gh_run.swg +++ b/Lib/guile/guile_gh_run.swg @@ -19,22 +19,7 @@ extern "C" { /* In the code below, use guile 2.0 compatible functions where possible. Functions that don't exist in older versions will be mapped to a deprecated equivalent for those versions only */ -/* ... setup guile 2-like interface for guile 1.6 */ -#if (SCM_MAJOR_VERSION == 1) && (SCM_MINOR_VERSION <= 6) - -# define scm_from_locale_keyword scm_c_make_keyword -# define scm_from_locale_symbol scm_str2symbol -# define scm_is_null SCM_NULLP -# define scm_is_true SCM_NFALSEP -# define scm_is_string SCM_STRINGP - -/* Used later on to setup different code paths where it's - not possible to use a guile 2-like interface */ -# define GUILE_VERSION_1_6 - -#endif - -/* ... setup guile 2-like interface for guile 1.6 and 1.8 */ +/* ... setup guile 2-like interface for guile 1.8 */ #if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2) static SCM diff --git a/Lib/guile/guile_scm_run.swg b/Lib/guile/guile_scm_run.swg index 71de33535..7cf3d165a 100644 --- a/Lib/guile/guile_scm_run.swg +++ b/Lib/guile/guile_scm_run.swg @@ -16,22 +16,6 @@ extern "C" { /* In the code below, use guile 2.0 compatible functions where possible. Functions that don't exist in older versions will be mapped to a deprecated equivalent for those versions only */ -/* ... setup guile 2-like interface for guile 1.6 */ -#if (SCM_MAJOR_VERSION == 1) && (SCM_MINOR_VERSION <= 6) - -# define scm_from_locale_keyword scm_c_make_keyword -# define scm_from_locale_symbol scm_str2symbol -# define scm_is_null SCM_NULLP -# define scm_is_true SCM_NFALSEP -# define scm_is_string SCM_STRINGP - -/* Used later on to setup different code paths where it's - not possible to use a guile 2-like interface */ -# define GUILE_VERSION_1_6 - -#endif - -/* ... setup guile 2-like interface for guile 1.6 and 1.8 */ #if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2) static SCM @@ -59,17 +43,10 @@ typedef struct swig_guile_clientdata { #define SWIG_scm2str(s) \ SWIG_Guile_scm2newstr(s, NULL) -#ifdef GUILE_VERSION_1_6 -# define SWIG_malloc(size) \ - SCM_MUST_MALLOC(size) -# define SWIG_free(mem) \ - scm_must_free(mem) -#else # define SWIG_malloc(size) \ scm_malloc(size) # define SWIG_free(mem) \ free(mem) -#endif #define SWIG_ConvertPtr(s, result, type, flags) \ SWIG_Guile_ConvertPtr(s, result, type, flags) #define SWIG_MustGetPtr(s, type, argnum, flags) \ @@ -105,9 +82,7 @@ SWIGINTERN char * SWIG_Guile_scm2newstr(SCM str, size_t *len) { #define FUNC_NAME "SWIG_Guile_scm2newstr" char *ret; -# ifndef GUILE_VERSION_1_6 char *tmp; -# endif size_t l; SCM_ASSERT (scm_is_string(str), str, 1, FUNC_NAME); @@ -116,13 +91,9 @@ SWIG_Guile_scm2newstr(SCM str, size_t *len) { ret = (char *) SWIG_malloc( (l + 1) * sizeof(char)); if (!ret) return NULL; -# ifdef GUILE_VERSION_1_6 - memcpy(ret, SCM_STRING_CHARS(str), l); -# else tmp = scm_to_locale_string(str); memcpy(ret, tmp, l); free(tmp); -# endif ret[l] = '\0'; if (len) *len = l; @@ -415,22 +386,6 @@ ensure_smob_tag(SCM swig_module, const char *smob_name, const char *scheme_variable_name) { -#ifdef GUILE_VERSION_1_6 - SCM variable = scm_sym2var(scm_str2symbol(scheme_variable_name), - scm_module_lookup_closure(swig_module), - SCM_BOOL_T); - if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) { - *tag_variable = scm_make_smob_type((char*)scheme_variable_name, 0); - SCM_VARIABLE_SET(variable, - scm_ulong2num(*tag_variable)); - return 1; - } - else { - *tag_variable = scm_num2ulong(SCM_VARIABLE_REF(variable), 0, - "SWIG_Guile_Init"); - return 0; - } -#else SCM variable = scm_module_variable(swig_module, scm_from_locale_symbol(scheme_variable_name)); if (scm_is_false(variable)) { @@ -443,7 +398,6 @@ ensure_smob_tag(SCM swig_module, *tag_variable = scm_to_ulong(SCM_VARIABLE_REF(variable)); return 0; } -#endif } SWIGINTERN SCM @@ -495,16 +449,6 @@ SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)) module = SWIG_Guile_Init(); -#ifdef GUILE_VERSION_1_6 - variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), - scm_module_lookup_closure(module), - SCM_BOOL_T); - if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) { - return NULL; - } else { - return (swig_module_info *) scm_num2ulong(SCM_VARIABLE_REF(variable), 0, "SWIG_Guile_Init"); - } -#else variable = scm_module_variable(module, scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME)); if (scm_is_false(variable)) { @@ -512,7 +456,6 @@ SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)) } else { return (swig_module_info *) scm_to_ulong(SCM_VARIABLE_REF(variable)); } -#endif } SWIGINTERN void @@ -523,17 +466,9 @@ SWIG_Guile_SetModule(swig_module_info *swig_module) module = SWIG_Guile_Init(); -#ifdef GUILE_VERSION_1_6 - variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), - scm_module_lookup_closure(module), - SCM_BOOL_T); - - SCM_VARIABLE_SET(variable, scm_ulong2num((unsigned long) swig_module)); -#else scm_module_define(module, scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), scm_from_ulong((unsigned long) swig_module)); -#endif } SWIGINTERN int @@ -545,11 +480,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest, int num_args_passed = 0; for (i = 0; i Date: Fri, 19 Apr 2013 12:19:49 +0200 Subject: [PATCH 126/273] Drop guilegh interface All of guile's interface files now use the scm interface. This should not affect any users. Swig generated code using the scm interface can be mixed with gh interface using user code. It does simplify maintenance of the guile swig code though. --- Doc/Manual/Guile.html | 52 +- Doc/Manual/Typemaps.html | 2 +- Examples/Makefile.in | 13 - Examples/guile/multimap/example.i | 4 +- Examples/test-suite/guilegh/Makefile.in | 28 - Examples/test-suite/pointer_reference.i | 2 +- Lib/cdata.i | 2 +- Lib/exception.i | 2 +- Lib/guile/cplusplus.i | 10 +- Lib/guile/ghinterface.i | 39 - Lib/guile/guile_gh.swg | 71 -- Lib/guile/guile_gh_run.swg | 273 ------ Lib/guile/guile_scm.swg | 5 - Lib/guile/guile_scm_run.swg | 6 +- Lib/guile/list-vector.i | 92 +- Lib/guile/std_common.i | 4 +- Lib/guile/std_map.i | 1148 +++++++++++------------ Lib/guile/std_pair.i | 940 +++++++++---------- Lib/guile/std_string.i | 16 +- Lib/guile/std_vector.i | 144 +-- Lib/guile/typemaps.i | 84 +- Lib/mzscheme/typemaps.i | 2 +- Makefile.in | 4 - Source/Modules/guile.cxx | 151 +-- configure.ac | 18 +- 25 files changed, 1283 insertions(+), 1829 deletions(-) delete mode 100644 Examples/test-suite/guilegh/Makefile.in delete mode 100644 Lib/guile/ghinterface.i delete mode 100644 Lib/guile/guile_gh.swg delete mode 100644 Lib/guile/guile_gh_run.swg diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 14fc03854..53368bc77 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -14,7 +14,7 @@

    • Supported Guile Versions
    • Meaning of "Module" -
    • Using the SCM or GH Guile API +
    • Old GH Guile API
    • Linkage
      • Simple Linkage @@ -64,53 +64,19 @@ 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". -

        23.3 Using the SCM or GH Guile API

        +

        23.3 Old GH Guile API

        -

        The guile module can currently export wrapper files that use the guile GH interface or the -SCM interface. This is controlled by an argument passed to swig. The "-gh" argument causes swig -to output GH code, and the "-scm" argument causes swig to output SCM code. Right now the "-scm" argument -is the default. The "-scm" wrapper generation assumes a guile version >= 1.6 and has several advantages over -the "-gh" wrapper generation including garbage collection and GOOPS support. -The "-gh" wrapper generation can be used for older versions of guile. -The guile GH wrapper code generation is depreciated and the -SCM interface is the default. The SCM and GH interface differ greatly in how they store -pointers and have completely different run-time code. See below for more info. +

        Support for the guile GH wrapper code generation has been dropped. The last +version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please +use that version if you really need the GH wrapper code. -

        The GH interface to guile is deprecated. Read more about why in the +

        Guile 1.8 and older could be interfaced using a two different api's, the SCM +or the GH API. The GH interface to guile is deprecated. Read more about why in the Guile manual. -The idea of the GH interface was to provide a high level API that other languages and projects -could adopt. This was a good idea, but didn't pan out well for general development. But for the -specific, minimal uses that the SWIG typemaps put the GH interface to use is ideal for -using a high level API. So even though the GH interface is depreciated, SWIG will continue to use -the GH interface and provide mappings from the GH interface to whatever API we need. -We can maintain this mapping where guile failed because SWIG uses a small subset of all the GH functions -which map easily. All the guile typemaps like typemaps.i and std_vector.i -will continue to use the GH functions to do things like create lists of values, convert strings to -integers, etc. Then every language module will define a mapping between the GH interface and -whatever custom API the language uses. This is currently implemented by the guile module to use -the SCM guile API rather than the GH guile API. -For example, here are some of the current mapping file for the SCM API

        -
        -
        -#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED)) 
        -#define gh_apply(a, b) scm_apply(a, b, SCM_EOL) 
        -#define gh_bool2scm SCM_BOOL 
        -#define gh_boolean_p SCM_BOOLP 
        -#define gh_car SCM_CAR 
        -#define gh_cdr SCM_CDR 
        -#define gh_cons scm_cons 
        -#define gh_double2scm scm_make_real 
        -...
        -
        - -

        This file is parsed by SWIG at wrapper generation time, so every reference to a gh_ function is replaced -by a scm_ function in the wrapper file. Thus the gh_ function calls will never be seen in the wrapper; -the wrapper will look exactly like it was generated -for the specific API. Currently only the guile language module has created a mapping policy from gh_ to scm_, -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.

        +

        The SCM wrapper generation assumes a guile version >= 1.8 and has several advantages over +the "-gh" wrapper generation including garbage collection and GOOPS support.

        23.4 Linkage

        diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index b3b0bc7a9..81e3fd1bb 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -773,7 +773,7 @@ Here are some examples of valid typemap specifications: } /* Typemap with modifiers */ -%typemap(in,doc="integer") int "$1 = gh_scm2int($input);"; +%typemap(in,doc="integer") int "$1 = scm_to_int($input);"; /* Typemap applied to patterns of multiple arguments */ %typemap(in) (char *str, int len), diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 6b4ca778e..b1bf8d049 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -479,19 +479,6 @@ $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCS) guile_externalhdr: $(SWIG) -guile -external-runtime $(TARGET) -#------------------------------------------------------------------ -# Build a dynamically loaded module with passive linkage and the gh interface -#------------------------------------------------------------------ -guile_gh: $(SRCS) - $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCS) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) - -guile_gh_cpp: $(SRCS) - $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) - # ----------------------------------------------------------------- # Build a dynamically loadable module with passive linkage # ----------------------------------------------------------------- diff --git a/Examples/guile/multimap/example.i b/Examples/guile/multimap/example.i index 7337d1e9e..f1d7974e4 100644 --- a/Examples/guile/multimap/example.i +++ b/Examples/guile/multimap/example.i @@ -59,14 +59,14 @@ extern int count(char *bytes, int len, char c); %typemap(in) (char *str, int len) { size_t temp; - $1 = gh_scm2newstr($input,&temp); + $1 = SWIG_Guile_scm2newstr($input,&temp); $2 = temp; } /* Return the mutated string as a new object. */ %typemap(argout) (char *str, int len) { - SWIG_APPEND_VALUE(gh_str2scm($1,$2)); + SWIG_APPEND_VALUE(scm_mem2string($1,$2)); if ($1) scm_must_free($1); } diff --git a/Examples/test-suite/guilegh/Makefile.in b/Examples/test-suite/guilegh/Makefile.in deleted file mode 100644 index 3a03d5f82..000000000 --- a/Examples/test-suite/guilegh/Makefile.in +++ /dev/null @@ -1,28 +0,0 @@ -####################################################################### -# Makefile for guile test-suite (with SCM API) -####################################################################### - -include ../guile/Makefile - -# Overridden variables here -VARIANT = _gh -# Refer to the guile directory for the run scripts -SCRIPTPREFIX = ../guile/ -GUILE_RUNTIME=-runtime - -# Custom tests - tests with additional commandline options -# none! - -# Runs the testcase. A testcase is only run if -# a file is found which has _runme.scm appended after the testcase name. -run_testcase = \ - if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi - -setup = \ - if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with GH API)" ; \ - else \ - echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with GH API)" ; \ - fi diff --git a/Examples/test-suite/pointer_reference.i b/Examples/test-suite/pointer_reference.i index b9e126fd4..7a6a09d48 100644 --- a/Examples/test-suite/pointer_reference.i +++ b/Examples/test-suite/pointer_reference.i @@ -11,7 +11,7 @@ #ifdef SWIGGUILE /* A silly testing typemap for feeding a doubly indirect integer */ %typemap(in) int *&XYZZY (int temp1, int *temp2) { - temp1 = gh_scm2int($input); temp2 = &temp1; $1 = &temp2; + temp1 = scm_to_int($input); temp2 = &temp1; $1 = &temp2; }; #endif diff --git a/Lib/cdata.i b/Lib/cdata.i index 1abaf357b..dbc1c42d2 100644 --- a/Lib/cdata.i +++ b/Lib/cdata.i @@ -17,7 +17,7 @@ typedef struct SWIGCDATA { #if SWIGGUILE %typemap(out) SWIGCDATA { - $result = gh_str2scm($1.data,$1.len); + $result = scm_mem2string($1.data,$1.len); } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); #elif SWIGCHICKEN diff --git a/Lib/exception.i b/Lib/exception.i index dc3a7f462..867ecdbff 100644 --- a/Lib/exception.i +++ b/Lib/exception.i @@ -24,7 +24,7 @@ SWIGINTERN void SWIG_exception_ (int code, const char *msg, const char *subr) { #define ERROR(scmerr) \ - scm_error(gh_symbol2scm((char *) (scmerr)), \ + scm_error(scm_str2symbol((char *) (scmerr)), \ (char *) subr, (char *) msg, \ SCM_EOL, SCM_BOOL_F) #define MAP(swigerr, scmerr) \ diff --git a/Lib/guile/cplusplus.i b/Lib/guile/cplusplus.i index 0dfe71754..d5d65efaa 100644 --- a/Lib/guile/cplusplus.i +++ b/Lib/guile/cplusplus.i @@ -5,18 +5,18 @@ * ----------------------------------------------------------------------------- */ %typemap(guile,out) string, std::string { - $result = gh_str02scm(const_cast($1.c_str())); + $result = SWIG_str02scm(const_cast($1.c_str())); } %typemap(guile,in) string, std::string { $1 = SWIG_scm2str($input); } %typemap(guile,out) complex, complex, std::complex { - $result = scm_make_rectangular( gh_double2scm ($1.real ()), - gh_double2scm ($1.imag ()) ); + $result = scm_make_rectangular( scm_from_double ($1.real ()), + scm_from_double ($1.imag ()) ); } %typemap(guile,in) complex, complex, std::complex { - $1 = std::complex( gh_scm2double (scm_real_part ($input)), - gh_scm2double (scm_imag_part ($input)) ); + $1 = std::complex( scm_to_double (scm_real_part ($input)), + scm_to_double (scm_imag_part ($input)) ); } diff --git a/Lib/guile/ghinterface.i b/Lib/guile/ghinterface.i deleted file mode 100644 index 3de4c81a2..000000000 --- a/Lib/guile/ghinterface.i +++ /dev/null @@ -1,39 +0,0 @@ -#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED)) -#define gh_apply(a, b) scm_apply(a, b, SCM_EOL) -#define gh_bool2scm scm_from_bool -#define gh_boolean_p scm_is_bool -#define gh_car SCM_CAR -#define gh_cdr SCM_CDR -#define gh_cons scm_cons -#define gh_double2scm scm_from_double -#define gh_int2scm scm_from_long -#define gh_length(lst) scm_to_ulong(scm_length(lst)) -#define gh_list scm_listify -#define gh_list_to_vector scm_vector -#define gh_make_vector scm_make_vector -#define gh_null_p scm_is_null -#define gh_number_p scm_is_number -#define gh_pair_p scm_is_pair -#define gh_scm2bool scm_is_true -#define gh_scm2char SCM_CHAR -#define gh_scm2double scm_to_double -#define gh_scm2int scm_to_int -#define gh_scm2long scm_to_long -#define gh_scm2short scm_to_short -#define gh_scm2newstr SWIG_Guile_scm2newstr -#define gh_scm2ulong scm_to_ulong -#define gh_scm2ushort scm_to_ushort -#define gh_scm2uint scm_to_uint -#define gh_ulong2scm scm_from_ulong -#define gh_long2scm scm_from_long -#define gh_str02scm(str) str ? scm_from_locale_string(str) : SCM_BOOL_F -#define gh_long_long2scm scm_from_long_long -#define gh_scm2long_long scm_to_long_long -#define gh_ulong_long2scm scm_from_ulong_long -#define gh_scm2ulong_long scm_to_ulong_long -#define gh_string_p scm_is_string -#define gh_vector_length scm_c_vector_length -#define gh_vector_p scm_is_vector -#define gh_vector_ref scm_vector_ref -#define gh_vector_set_x scm_vector_set_x -#define gh_char2scm SCM_MAKE_CHAR diff --git a/Lib/guile/guile_gh.swg b/Lib/guile/guile_gh.swg deleted file mode 100644 index 3b65af897..000000000 --- a/Lib/guile/guile_gh.swg +++ /dev/null @@ -1,71 +0,0 @@ -/* ----------------------------------------------------------------------------- - * guile_gh.swg - * - * This SWIG interface file is processed if the Guile module is run - * with gh_ flavor. - * ----------------------------------------------------------------------------- */ - -#define SWIGGUILE_GH - -%runtime "swigrun.swg" -%runtime "guile_gh_run.swg" - -#define SWIG_convert_short(o) \ - SWIG_convert_integer(o, - (1 << (8 * sizeof(short) - 1)), \ - (1 << (8 * sizeof(short) - 1)) - 1, \ - FUNC_NAME, $argnum) -#define SWIG_convert_unsigned_short(o) \ - SWIG_convert_unsigned_integer(o, 0, \ - (1 << (8 * sizeof(short))) - 1, \ - FUNC_NAME, $argnum) -#define SWIG_convert_unsigned_int(o) \ - SWIG_convert_unsigned_integer(o, 0, UINT_MAX, \ - FUNC_NAME, $argnum) - -#define gh_scm2short(a) SWIG_convert_short(a) -#define gh_scm2ushort(a) SWIG_convert_unsigned_short(a) -#define gh_scm2uint(a) SWIG_convert_unsigned_int(a) - -%include - -%runtime %{ - -/* scm_values was implemented on C level in 1.4.1, and the prototype - is not included in libguile.h, so play safe and lookup `values'... */ -#define GUILE_MAYBE_VALUES \ - if (gswig_list_p) \ - gswig_result = gh_apply(gh_lookup("values"), gswig_result); - -#define GUILE_MAYBE_VECTOR \ - if (gswig_list_p) \ - gswig_result = gh_list_to_vector(gswig_result); - -#define SWIG_APPEND_VALUE(object) \ - if (gswig_result == SCM_UNSPECIFIED) { \ - gswig_result = object; \ - } else { \ - if (!gswig_list_p) { \ - gswig_list_p = 1; \ - gswig_result = gh_list(gswig_result, object, SCM_UNDEFINED); \ - } \ - else \ - gswig_result = gh_append2(gswig_result, \ - gh_list(object, SCM_UNDEFINED)); \ - } - -%} - -%init "swiginit.swg" - -%init %{ -static int _swig_module_smob_tag; - -SWIG_GUILE_INIT_STATIC void -SWIG_init(void) -{ - - SWIG_InitializeModule(0); - swig_module.clientdata = (void *) &_swig_module_smob_tag; - - SWIG_Guile_Init(&swig_module); -%} diff --git a/Lib/guile/guile_gh_run.swg b/Lib/guile/guile_gh_run.swg deleted file mode 100644 index 1292131c8..000000000 --- a/Lib/guile/guile_gh_run.swg +++ /dev/null @@ -1,273 +0,0 @@ -/* ----------------------------------------------------------------------------- - * guile_gh_run.swg - * - * Guile GH runtime file - * ----------------------------------------------------------------------------- */ - -#define SWIGGUILE -#include "guile/gh.h" -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* In the code below, use guile 2.0 compatible functions where possible. - Functions that don't exist in older versions will be mapped to - a deprecated equivalent for those versions only */ -/* ... setup guile 2-like interface for guile 1.8 */ -#if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2) - -static SCM -scm_module_variable (SCM module, SCM sym) -{ - return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F); -} - -#endif - -typedef SCM (*swig_guile_proc)(); - -#define SWIG_malloc(size) \ - SCM_MUST_MALLOC(size) -#define SWIG_free(mem) \ - scm_must_free(mem) -#define SWIG_ConvertPtr(s, result, type, flags) \ - SWIG_Guile_ConvertPtr(&swig_module, s, result, type, flags) -#define SWIG_MustGetPtr(s, type, argnum, flags) \ - SWIG_Guile_MustGetPtr(&swig_module, s, type, argnum, flags, FUNC_NAME) -#define SWIG_NewPointerObj(ptr, type, owner) \ - SWIG_Guile_NewPointerObj(&swig_module, (void*)ptr, type, owner) -#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule(clientdata) -#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer) - -/* Ignore object-ownership changes in gh mode */ -#define SWIG_Guile_MarkPointerNoncollectable(s) (s) -#define SWIG_Guile_MarkPointerDestroyed(s) (s) - -#define SWIG_contract_assert(expr, msg) \ - if (!(expr)) \ - scm_error(gh_symbol2scm("swig-contract-assertion-failed"), \ - (char *) FUNC_NAME, (char *) msg, \ - SCM_EOL, SCM_BOOL_F); else - -/* SCM_CHAR and SCM_CHARP were introduced in Guile 1.4; the following is for - 1.3.4 compatibility. */ -#ifndef SCM_CHAR -# define SCM_CHAR SCM_ICHR -#endif -#ifndef SCM_CHARP -# define SCM_CHARP SCM_ICHRP -#endif - -/* This function replaces gh_scm2char, which is broken in Guile 1.4 */ -SWIGINTERN char -GSWIG_scm2char (SCM s) -{ - if (SCM_CHARP(s)) return SCM_CHAR(s); - scm_wrong_type_arg(NULL, 0, s); -} -#define gh_scm2char GSWIG_scm2char - -/* Interface function */ -#define SWIG_scm2str(x) gh_scm2newstr(x, NULL) - -/* More 1.3.4 compatibility */ -#ifndef SCM_INPUT_PORT_P -# define SCM_INPUT_PORT_P SCM_INPORTP -# define SCM_OUTPUT_PORT_P SCM_OUTPORTP -#endif - -SWIGINTERN long -SWIG_convert_integer(SCM o, - long lower_bound, long upper_bound, - const char *func_name, int argnum) -{ - long value = gh_scm2long(o); - if (value < lower_bound || value > upper_bound) - scm_wrong_type_arg((char *) func_name, argnum, o); - return value; -} - -SWIGINTERN unsigned long -SWIG_convert_unsigned_integer(SCM o, - unsigned long lower_bound, - unsigned long upper_bound, - const char *func_name, int argnum) -{ - unsigned long value = gh_scm2ulong(o); - if (value < lower_bound || value > upper_bound) - scm_wrong_type_arg((char *) func_name, argnum, o); - return value; -} - -SWIGINTERN swig_type_info * -SWIG_Guile_LookupType(swig_module_info *module, SCM s, int normal) -{ - swig_module_info *iter; - if (!module) return 0; - iter = module; - do { - if ((normal && (unsigned long) SCM_TYP16(s) == *((int *)iter->clientdata))) { - - return iter->types[(long) SCM_CAR(s) >> 16]; - } - iter = iter->next; - } while (iter != module); - return 0; -} - -#ifdef SWIG_GLOBAL -#define SWIG_GUILE_MODULE_STATIC -#elif !defined(SWIG_NOINCLUDE) -#define SWIG_GUILE_MODULE_STATIC static -#endif - -#ifdef SWIG_GUILE_MODULE_STATIC -static swig_module_info *swig_guile_module = 0; -SWIG_GUILE_MODULE_STATIC swig_module_info *SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)) { - return swig_guile_module; -} -SWIG_GUILE_MODULE_STATIC void SWIG_Guile_SetModule(swig_module_info *pointer) { - swig_guile_module = pointer; -} -#else -SWIGEXPORT swig_module_info * SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)); -SWIGEXPORT void SWIG_Guile_SetModule(swig_module_info *pointer); -#endif - -SWIGINTERN SCM -SWIG_Guile_NewPointerObj(swig_module_info *module, void *ptr, - swig_type_info *type, int owner) -{ - unsigned long tag; - if (ptr==NULL) return SCM_EOL; - if (!module) return SCM_EOL; - for (tag = 0; tag < module->size; ++tag) { - if (module->types[tag] == type) - break; - } - if (tag >= module->size) - return SCM_EOL; - - - SCM_RETURN_NEWSMOB( ((tag << 16) | *((int *)module->clientdata)), ptr); -} - -/* Return 0 if successful. */ -SWIGINTERN int -SWIG_Guile_ConvertPtr(swig_module_info *module, SCM s, void **result, - swig_type_info *type, int flags) -{ - swig_cast_info *cast; - swig_type_info *from; - if (scm_is_null(s)) { - *result = NULL; - return SWIG_OK; - } else if (SCM_NIMP(s)) { - from = SWIG_Guile_LookupType(module, s, 1); - if (!from) return SWIG_ERROR; - if (type) { - cast = SWIG_TypeCheckStruct(from, type); - if (cast) { - int newmemory = 0; - *result = SWIG_TypeCast(cast, (void *) SCM_CDR(s), &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - return SWIG_OK; - } else { - return SWIG_ERROR; - } - } else { - *result = (void *) SCM_CDR(s); - return SWIG_OK; - } - } - return SWIG_ERROR; -} - -SWIGINTERN void * -SWIG_Guile_MustGetPtr (swig_module_info *module, SCM s, swig_type_info *type, - int argnum, int flags, const char *func_name) -{ - void *result; - int res = SWIG_Guile_ConvertPtr(module, s, &result, type, flags); - if (!SWIG_IsOK(res)) { - /* type mismatch */ - scm_wrong_type_arg((char *) func_name, argnum, s); - } - return result; -} - -/* Init */ - -SWIGINTERN int -print_swig (SCM swig_smob, SCM port, scm_print_state *pstate) -{ - swig_type_info *type = SWIG_Guile_LookupType(0, swig_smob, 1); - if (type) { - scm_puts((char *) "#str != NULL) - scm_puts((char *) type->str, port); - else - scm_puts((char *) type->name, port); - scm_puts((char *) " ", port); - scm_intprint((long) SCM_CDR(swig_smob), 16, port); - scm_puts((char *) ">", port); - /* non-zero means success */ - return 1; - } else { - return 0; - } -} - -SWIGINTERN SCM -equalp_swig (SCM A, SCM B) -{ - if (SCM_CAR(A) == SCM_CAR(B) - && SCM_CDR(A) == SCM_CDR(B)) - return SCM_BOOL_T; - else return SCM_BOOL_F; -} - -SWIGINTERN void -SWIG_Guile_Init (swig_module_info *module) -{ - *((int *)module->clientdata) = - scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL, print_swig, equalp_swig); -} - -SWIGINTERN int -SWIG_Guile_GetArgs (SCM *dest, SCM rest, - int reqargs, int optargs, - const char *procname) -{ - int i; - int num_args_passed = 0; - for (i = 0; i %include %runtime %{ @@ -32,10 +31,6 @@ else \ gswig_result = scm_append(scm_listify(gswig_result, scm_listify(object, SCM_UNDEFINED), SCM_UNDEFINED)); \ } - /* used by Lib/exception.i */ - #define gh_symbol2scm scm_str2symbol - /* useb by Lib/cdata.i */ - #define gh_str2scm scm_mem2string %} diff --git a/Lib/guile/guile_scm_run.swg b/Lib/guile/guile_scm_run.swg index 7cf3d165a..0ac51f919 100644 --- a/Lib/guile/guile_scm_run.swg +++ b/Lib/guile/guile_scm_run.swg @@ -43,10 +43,12 @@ typedef struct swig_guile_clientdata { #define SWIG_scm2str(s) \ SWIG_Guile_scm2newstr(s, NULL) +#define SWIG_str02scm(str) \ + str ? scm_from_locale_string(str) : SCM_BOOL_F # define SWIG_malloc(size) \ - scm_malloc(size) + scm_malloc(size) # define SWIG_free(mem) \ - free(mem) + free(mem) #define SWIG_ConvertPtr(s, result, type, flags) \ SWIG_Guile_ConvertPtr(s, result, type, flags) #define SWIG_MustGetPtr(s, type, argnum, flags) \ diff --git a/Lib/guile/list-vector.i b/Lib/guile/list-vector.i index c2cd1aea2..057a1da5b 100644 --- a/Lib/guile/list-vector.i +++ b/Lib/guile/list-vector.i @@ -61,12 +61,12 @@ (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT) { SCM_VALIDATE_VECTOR($argnum, $input); - $1 = gh_vector_length($input); + $1 = scm_c_vector_length($input); if ($1 > 0) { $1_ltype i; $2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1); for (i = 0; i<$1; i++) { - SCM swig_scm_value = gh_vector_ref($input, gh_int2scm(i)); + SCM swig_scm_value = scm_vector_ref($input, scm_from_long(i)); $2[i] = SCM_TO_C_EXPR; } } @@ -78,15 +78,15 @@ (size_t LISTLENINPUT, C_TYPE *LISTINPUT) { SCM_VALIDATE_LIST($argnum, $input); - $1 = gh_length($input); + $1 = scm_to_ulong(scm_length($input)); if ($1 > 0) { $1_ltype i; SCM rest; $2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1); for (i = 0, rest = $input; i<$1; - i++, rest = gh_cdr(rest)) { - SCM swig_scm_value = gh_car(rest); + i++, rest = SCM_CDR(rest)) { + SCM swig_scm_value = SCM_CAR(rest); $2[i] = SCM_TO_C_EXPR; } } @@ -140,12 +140,12 @@ (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) { $*1_ltype i; - SCM res = gh_make_vector(gh_int2scm(*$1), + SCM res = scm_make_vector(scm_from_long(*$1), SCM_BOOL_F); for (i = 0; i<*$1; i++) { C_TYPE swig_c_value = (*$2)[i]; SCM elt = C_TO_SCM_EXPR; - gh_vector_set_x(res, gh_int2scm(i), elt); + scm_vector_set_x(res, scm_from_long(i), elt); } SWIG_APPEND_VALUE(res); } @@ -159,7 +159,7 @@ for (i = ((int)(*$1)) - 1; i>=0; i--) { C_TYPE swig_c_value = (*$2)[i]; SCM elt = C_TO_SCM_EXPR; - res = gh_cons(elt, res); + res = scm_cons(elt, res); } SWIG_APPEND_VALUE(res); } @@ -200,21 +200,21 @@ /* We use the macro to define typemaps for some standard types. */ -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(bool, gh_scm2bool, gh_bool2scm, boolean); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, gh_scm2char, gh_char2scm, char); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, gh_scm2char, gh_char2scm, char); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, gh_scm2int, gh_int2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, gh_scm2int, gh_int2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, gh_scm2long, gh_long2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, gh_scm2long, gh_long2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, gh_scm2double, gh_double2scm, real); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, gh_scm2double, gh_double2scm, real); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, gh_str02scm, string); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(bool, scm_is_true, scm_from_bool, boolean); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string); /* For the char *, free all strings after converting */ @@ -312,13 +312,13 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string const C_TYPE *PARALLEL_VECTORINPUT { SCM_VALIDATE_VECTOR($argnum, $input); - *_global_vector_length = gh_vector_length($input); + *_global_vector_length = scm_c_vector_length($input); if (*_global_vector_length > 0) { int i; $1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * (*_global_vector_length)); for (i = 0; i<*_global_vector_length; i++) { - SCM swig_scm_value = gh_vector_ref($input, gh_int2scm(i)); + SCM swig_scm_value = scm_vector_ref($input, scm_from_long(i)); $1[i] = SCM_TO_C_EXPR; } } @@ -330,7 +330,7 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string const C_TYPE *PARALLEL_LISTINPUT { SCM_VALIDATE_LIST($argnum, $input); - *_global_list_length = gh_length($input); + *_global_list_length = scm_to_ulong(scm_length($input)); if (*_global_list_length > 0) { int i; SCM rest; @@ -338,8 +338,8 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string * (*_global_list_length)); for (i = 0, rest = $input; i<*_global_list_length; - i++, rest = gh_cdr(rest)) { - SCM swig_scm_value = gh_car(rest); + i++, rest = SCM_CDR(rest)) { + SCM swig_scm_value = SCM_CAR(rest); $1[i] = SCM_TO_C_EXPR; } } @@ -391,12 +391,12 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string C_TYPE **PARALLEL_VECTOROUTPUT { int i; - SCM res = gh_make_vector(gh_int2scm(_global_arraylentemp), + SCM res = scm_make_vector(scm_from_long(_global_arraylentemp), SCM_BOOL_F); for (i = 0; i<_global_arraylentemp; i++) { C_TYPE swig_c_value = (*$1)[i]; SCM elt = C_TO_SCM_EXPR; - gh_vector_set_x(res, gh_int2scm(i), elt); + scm_vector_set_x(res, scm_from_long(i), elt); } SWIG_APPEND_VALUE(res); } @@ -410,7 +410,7 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string for (i = _global_arraylentemp - 1; i>=0; i--) { C_TYPE swig_c_value = (*$1)[i]; SCM elt = C_TO_SCM_EXPR; - res = gh_cons(elt, res); + res = scm_cons(elt, res); } } SWIG_APPEND_VALUE(res); @@ -449,21 +449,21 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string /* We use the macro to define typemaps for some standard types. */ -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(bool, gh_scm2bool, gh_bool2scm, boolean); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char, gh_scm2char, gh_char2scm, char); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned char, gh_scm2char, gh_char2scm, char); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(int, gh_scm2int, gh_int2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(short, gh_scm2int, gh_int2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(long, gh_scm2long, gh_long2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, gh_scm2long, gh_long2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned int, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned short, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned long, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(size_t, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(float, gh_scm2double, gh_double2scm, real); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(double, gh_scm2double, gh_double2scm, real); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, gh_str02scm, string); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(bool, scm_is_true, scm_from_bool, boolean); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string); %typemap(freearg) char **PARALLEL_LISTINPUT, char **PARALLEL_VECTORINPUT, const char **PARALLEL_LISTINPUT, const char **PARALLEL_VECTORINPUT diff --git a/Lib/guile/std_common.i b/Lib/guile/std_common.i index a46c42c69..18c7db089 100644 --- a/Lib/guile/std_common.i +++ b/Lib/guile/std_common.i @@ -8,8 +8,8 @@ %apply size_t { std::size_t }; -#define SWIG_bool2scm(b) gh_bool2scm(b ? 1 : 0) -#define SWIG_string2scm(s) gh_str02scm(s.c_str()) +#define SWIG_bool2scm(b) scm_from_bool(b ? 1 : 0) +#define SWIG_string2scm(s) SWIG_str02scm(s.c_str()) %{ #include diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i index eb28c2831..dfce6fc5c 100644 --- a/Lib/guile/std_map.i +++ b/Lib/guile/std_map.i @@ -42,30 +42,30 @@ namespace std { template class map { %typemap(in) map (std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { $1 = std::map(); - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { $1 = std::map(); SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { K* k; T* x; SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } (($1_type &)$1)[*k] = *x; - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) @@ -76,32 +76,32 @@ namespace std { std::map* m), const map* (std::map temp, std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { temp = std::map(); $1 = &temp; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { temp = std::map(); $1 = &temp; SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { K* k; T* x; SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } temp[*k] = *x; - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); @@ -115,24 +115,24 @@ namespace std { T* val = new T(i->second); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); - SCM entry = gh_cons(k,x); - alist = gh_cons(entry,alist); + SCM entry = scm_cons(k,x); + alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { /* native sequence? */ - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { /* check the first element only */ K* k; T* x; - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(key,(void**) &k, $descriptor(K *), 0) != 0) { $1 = 0; @@ -140,8 +140,8 @@ namespace std { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; @@ -167,17 +167,17 @@ namespace std { %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { /* native sequence? */ - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { /* check the first element only */ K* k; T* x; - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(key,(void**) &k, $descriptor(K *), 0) != 0) { $1 = 0; @@ -185,8 +185,8 @@ namespace std { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; @@ -255,7 +255,7 @@ namespace std { i!=$1.rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); - result = gh_cons(k,result); + result = scm_cons(k,result); } return result; } @@ -269,31 +269,31 @@ namespace std { template class map { %typemap(in) map (std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { $1 = std::map(); - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { $1 = std::map(); SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { T* x; SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } (($1_type &)$1)[CONVERT_FROM(key)] = *x; - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) @@ -304,33 +304,33 @@ namespace std { std::map* m), const map* (std::map temp, std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { temp = std::map(); $1 = &temp; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { temp = std::map(); $1 = &temp; SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { T* x; SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } temp[CONVERT_FROM(key)] = *x; - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); @@ -343,31 +343,31 @@ namespace std { T* val = new T(i->second); SCM k = CONVERT_TO(i->first); SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); - SCM entry = gh_cons(k,x); - alist = gh_cons(entry,alist); + SCM entry = scm_cons(k,x); + alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { // check the first element only T* x; - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (!CHECK(key)) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; @@ -393,24 +393,24 @@ namespace std { %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { // check the first element only T* x; - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (!CHECK(key)) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; @@ -474,7 +474,7 @@ namespace std { for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { SCM k = CONVERT_TO(i->first); - result = gh_cons(k,result); + result = scm_cons(k,result); } return result; } @@ -485,30 +485,30 @@ namespace std { %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) template class map { %typemap(in) map (std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { $1 = std::map(); - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { $1 = std::map(); SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { K* k; SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (!CHECK(val)) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } (($1_type &)$1)[*k] = CONVERT_FROM(val); - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) @@ -519,32 +519,32 @@ namespace std { std::map* m), const map* (std::map temp, std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { temp = std::map(); $1 = &temp; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { temp = std::map(); $1 = &temp; SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { K* k; SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (!CHECK(val)) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } temp[*k] = CONVERT_FROM(val); - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); @@ -557,31 +557,31 @@ namespace std { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); SCM x = CONVERT_TO(i->second); - SCM entry = gh_cons(k,x); - alist = gh_cons(entry,alist); + SCM entry = scm_cons(k,x); + alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { // check the first element only K* k; - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(val,(void **) &k, $descriptor(K *), 0) != 0) { $1 = 0; } else { if (CHECK(val)) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (CHECK(val)) $1 = 1; else @@ -606,24 +606,24 @@ namespace std { %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { // check the first element only K* k; - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(val,(void **) &k, $descriptor(K *), 0) != 0) { $1 = 0; } else { if (CHECK(val)) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (CHECK(val)) $1 = 1; else @@ -687,7 +687,7 @@ namespace std { i!=$1.rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); - result = gh_cons(k,result); + result = scm_cons(k,result); } return result; } @@ -699,32 +699,32 @@ namespace std { T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) template<> class map { %typemap(in) map (std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { $1 = std::map(); - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { $1 = std::map(); SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (!CHECK_T(val)) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } (($1_type &)$1)[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) @@ -735,33 +735,33 @@ namespace std { std::map* m), const map* (std::map temp, std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { temp = std::map(); $1 = &temp; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { temp = std::map(); $1 = &temp; SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (!CHECK_T(val)) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); @@ -773,29 +773,29 @@ namespace std { i!=$1.rend(); ++i) { SCM k = CONVERT_K_TO(i->first); SCM x = CONVERT_T_TO(i->second); - SCM entry = gh_cons(k,x); - alist = gh_cons(entry,alist); + SCM entry = scm_cons(k,x); + alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { // check the first element only - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (!CHECK_K(key)) { $1 = 0; } else { if (CHECK_T(val)) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (CHECK_T(val)) $1 = 1; else @@ -820,22 +820,22 @@ namespace std { %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { // check the first element only - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (!CHECK_K(key)) { $1 = 0; } else { if (CHECK_T(val)) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (CHECK_T(val)) $1 = 1; else @@ -898,7 +898,7 @@ namespace std { for (std::map::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { SCM k = CONVERT_K_TO(i->first); - result = gh_cons(k,result); + result = scm_cons(k,result); } return result; } @@ -907,446 +907,446 @@ namespace std { %enddef - specialize_std_map_on_key(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_key(int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_key(short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_key(long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_key(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_key(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_key(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_key(double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_key(float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_key(std::string,gh_string_p, + specialize_std_map_on_key(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_key(int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_key(short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_key(long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_key(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_key(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_key(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_key(double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_key(float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_key(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_value(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_value(int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_value(short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_value(long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_value(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_value(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_value(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_value(double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_value(float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_value(std::string,gh_string_p, + specialize_std_map_on_value(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_value(int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_value(short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_value(long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_value(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_value(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_value(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_value(double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_value(float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_value(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - std::string,gh_string_p, + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - std::string,gh_string_p, + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - std::string,gh_string_p, + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - std::string,gh_string_p, + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - std::string,gh_string_p, + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - std::string,gh_string_p, + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - std::string,gh_string_p, + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - std::string,gh_string_p, + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - std::string,gh_string_p, + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(std::string,gh_string_p, + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(std::string,gh_string_p, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(std::string,gh_string_p, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(std::string,gh_string_p, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(std::string,gh_string_p, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(std::string,gh_string_p, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(std::string,gh_string_p, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(std::string,gh_string_p, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(std::string,gh_string_p, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(std::string,gh_string_p, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - std::string,gh_string_p, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); } diff --git a/Lib/guile/std_pair.i b/Lib/guile/std_pair.i index 35f0cfad5..86ca6e00f 100644 --- a/Lib/guile/std_pair.i +++ b/Lib/guile/std_pair.i @@ -23,12 +23,12 @@ namespace std { template struct pair { %typemap(in) pair (std::pair* m) { - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { T* x; U* y; SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); $1 = std::make_pair(*x,*y); @@ -41,12 +41,12 @@ namespace std { std::pair* m), const pair* (std::pair temp, std::pair* m) { - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { T* x; U* y; SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); temp = std::make_pair(*x,*y); @@ -61,15 +61,15 @@ namespace std { U* y = new U($1.second); SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); - $result = gh_cons(first,second); + $result = scm_cons(first,second); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { T* x; U* y; - SCM first = gh_car($input); - SCM second = gh_cdr($input); + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && SWIG_ConvertPtr(second,(void**) &y, @@ -91,11 +91,11 @@ namespace std { %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { T* x; U* y; - SCM first = gh_car($input); - SCM second = gh_cdr($input); + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && SWIG_ConvertPtr(second,(void**) &y, @@ -130,11 +130,11 @@ namespace std { %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { %typemap(in) pair (std::pair* m) { - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { U* y; SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, "map<" #T "," #U "> expected"); @@ -149,11 +149,11 @@ namespace std { std::pair* m), const pair* (std::pair temp, std::pair* m) { - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { U* y; SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, "map<" #T "," #U "> expected"); @@ -168,14 +168,14 @@ namespace std { %typemap(out) pair { U* y = new U($1.second); SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); - $result = gh_cons(CONVERT_TO($1.first),second); + $result = scm_cons(CONVERT_TO($1.first),second); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { U* y; - SCM first = gh_car($input); - SCM second = gh_cdr($input); + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (CHECK(first) && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) == 0) { @@ -196,10 +196,10 @@ namespace std { %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { U* y; - SCM first = gh_car($input); - SCM second = gh_cdr($input); + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (CHECK(first) && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) == 0) { @@ -231,11 +231,11 @@ namespace std { %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { %typemap(in) pair (std::pair* m) { - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { T* x; SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, @@ -250,11 +250,11 @@ namespace std { std::pair* m), const pair* (std::pair temp, std::pair* m) { - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { T* x; SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, @@ -269,14 +269,14 @@ namespace std { %typemap(out) pair { T* x = new T($1.first); SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); - $result = gh_cons(first,CONVERT_TO($1.second)); + $result = scm_cons(first,CONVERT_TO($1.second)); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { T* x; - SCM first = gh_car($input); - SCM second = gh_cdr($input); + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && CHECK(second)) { @@ -297,10 +297,10 @@ namespace std { %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { T* x; - SCM first = gh_car($input); - SCM second = gh_cdr($input); + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && CHECK(second)) { @@ -333,10 +333,10 @@ namespace std { U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) template<> struct pair { %typemap(in) pair (std::pair* m) { - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, "map<" #T "," #U "> expected"); @@ -351,10 +351,10 @@ namespace std { std::pair* m), const pair* (std::pair temp, std::pair* m) { - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, "map<" #T "," #U "> expected"); @@ -367,14 +367,14 @@ namespace std { } } %typemap(out) pair { - $result = gh_cons(CONVERT_T_TO($1.first), + $result = scm_cons(CONVERT_T_TO($1.first), CONVERT_U_TO($1.second)); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ - if (gh_pair_p($input)) { - SCM first = gh_car($input); - SCM second = gh_cdr($input); + if (scm_is_pair($input)) { + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (CHECK_T(first) && CHECK_U(second)) { $1 = 1; } else { @@ -393,9 +393,9 @@ namespace std { %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ - if (gh_pair_p($input)) { - SCM first = gh_car($input); - SCM second = gh_cdr($input); + if (scm_is_pair($input)) { + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (CHECK_T(first) && CHECK_U(second)) { $1 = 1; } else { @@ -423,446 +423,446 @@ namespace std { %enddef - specialize_std_pair_on_first(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_first(int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_first(short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_first(long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_first(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_first(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_first(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_first(double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_first(float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_first(std::string,gh_string_p, + specialize_std_pair_on_first(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_first(int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_first(short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_first(long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_first(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_first(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_first(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_first(double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_first(float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_first(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_second(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_second(int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_second(short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_second(long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_second(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_second(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_second(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_second(double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_second(float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_second(std::string,gh_string_p, + specialize_std_pair_on_second(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_second(int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_second(short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_second(long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_second(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_second(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_second(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_second(double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_second(float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_second(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - std::string,gh_string_p, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); } diff --git a/Lib/guile/std_string.i b/Lib/guile/std_string.i index 83e0dd26d..6513173ee 100644 --- a/Lib/guile/std_string.i +++ b/Lib/guile/std_string.i @@ -27,7 +27,7 @@ namespace std { %typemap(typecheck) const string & = char *; %typemap(in) string (char * tempptr) { - if (gh_string_p($input)) { + if (scm_is_string($input)) { tempptr = SWIG_scm2str($input); $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); @@ -37,7 +37,7 @@ namespace std { } %typemap(in) const string & ($*1_ltype temp, char *tempptr) { - if (gh_string_p($input)) { + if (scm_is_string($input)) { tempptr = SWIG_scm2str($input); temp.assign(tempptr); if (tempptr) SWIG_free(tempptr); @@ -48,7 +48,7 @@ namespace std { } %typemap(in) string * (char *tempptr) { - if (gh_string_p($input)) { + if (scm_is_string($input)) { tempptr = SWIG_scm2str($input); $1 = new $*1_ltype(tempptr); if (tempptr) SWIG_free(tempptr); @@ -58,19 +58,19 @@ namespace std { } %typemap(out) string { - $result = gh_str02scm($1.c_str()); + $result = SWIG_str02scm($1.c_str()); } %typemap(out) const string & { - $result = gh_str02scm($1->c_str()); + $result = SWIG_str02scm($1->c_str()); } %typemap(out) string * { - $result = gh_str02scm($1->c_str()); + $result = SWIG_str02scm($1->c_str()); } %typemap(varin) string { - if (gh_string_p($input)) { + if (scm_is_string($input)) { char *tempptr = SWIG_scm2str($input); $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); @@ -80,7 +80,7 @@ namespace std { } %typemap(varout) string { - $result = gh_str02scm($1.c_str()); + $result = SWIG_str02scm($1.c_str()); } } diff --git a/Lib/guile/std_vector.i b/Lib/guile/std_vector.i index 6a5e8ae36..79c716b10 100644 --- a/Lib/guile/std_vector.i +++ b/Lib/guile/std_vector.i @@ -42,23 +42,23 @@ namespace std { template class vector { %typemap(in) vector { - if (gh_vector_p($input)) { - unsigned long size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned long size = scm_c_vector_length($input); $1 = std::vector(size); for (unsigned long i=0; i(); - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { SCM head, tail; $1 = std::vector(); tail = $input; - while (!gh_null_p(tail)) { - head = gh_car(tail); - tail = gh_cdr(tail); + while (!scm_is_null(tail)) { + head = SCM_CAR(tail); + tail = SCM_CDR(tail); $1.push_back(*((T*)SWIG_MustGetPtr(head, $descriptor(T *), $argnum, 0))); @@ -70,27 +70,27 @@ namespace std { } %typemap(in) const vector& (std::vector temp), const vector* (std::vector temp) { - if (gh_vector_p($input)) { - unsigned long size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned long size = scm_c_vector_length($input); temp = std::vector(size); $1 = &temp; for (unsigned long i=0; i(); $1 = &temp; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { temp = std::vector(); $1 = &temp; SCM head, tail; tail = $input; - while (!gh_null_p(tail)) { - head = gh_car(tail); - tail = gh_cdr(tail); + while (!scm_is_null(tail)) { + head = SCM_CAR(tail); + tail = SCM_CDR(tail); temp.push_back(*((T*) SWIG_MustGetPtr(head, $descriptor(T *), $argnum, 0))); @@ -100,23 +100,23 @@ namespace std { } } %typemap(out) vector { - $result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED); + $result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED); for (unsigned int i=0; i<$1.size(); i++) { T* x = new T((($1_type &)$1)[i]); - gh_vector_set_x($result,gh_long2scm(i), + scm_vector_set_x($result,scm_from_long(i), SWIG_NewPointerObj(x, $descriptor(T *), 1)); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector { /* native sequence? */ - if (gh_vector_p($input)) { - unsigned int size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ - SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + SCM o = scm_vector_ref($input,scm_from_ulong(0)); T* x; if (SWIG_ConvertPtr(o,(void**) &x, $descriptor(T *), 0) != -1) @@ -124,13 +124,13 @@ namespace std { else $1 = 0; } - } else if (gh_null_p($input)) { + } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { /* check the first element only */ T* x; - SCM head = gh_car($input); + SCM head = SCM_CAR($input); if (SWIG_ConvertPtr(head,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; @@ -149,28 +149,28 @@ namespace std { %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { /* native sequence? */ - if (gh_vector_p($input)) { - unsigned int size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; - SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + SCM o = scm_vector_ref($input,scm_from_ulong(0)); if (SWIG_ConvertPtr(o,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } - } else if (gh_null_p($input)) { + } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { /* check the first element only */ T* x; - SCM head = gh_car($input); + SCM head = SCM_CAR($input); if (SWIG_ConvertPtr(head,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; @@ -230,24 +230,24 @@ namespace std { %define specialize_stl_vector(T,CHECK,CONVERT_FROM,CONVERT_TO) template<> class vector { %typemap(in) vector { - if (gh_vector_p($input)) { - unsigned long size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned long size = scm_c_vector_length($input); $1 = std::vector(size); for (unsigned long i=0; i(); - } else if (gh_pair_p($input)) { - SCM v = gh_list_to_vector($input); - unsigned long size = gh_vector_length(v); + } else if (scm_is_pair($input)) { + SCM v = scm_vector($input); + unsigned long size = scm_c_vector_length(v); $1 = std::vector(size); for (unsigned long i=0; i& (std::vector temp), const vector* (std::vector temp) { - if (gh_vector_p($input)) { - unsigned long size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned long size = scm_c_vector_length($input); temp = std::vector(size); $1 = &temp; for (unsigned long i=0; i(); $1 = &temp; - } else if (gh_pair_p($input)) { - SCM v = gh_list_to_vector($input); - unsigned long size = gh_vector_length(v); + } else if (scm_is_pair($input)) { + SCM v = scm_vector($input); + unsigned long size = scm_c_vector_length(v); temp = std::vector(size); $1 = &temp; for (unsigned long i=0; i { - $result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED); + $result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED); for (unsigned int i=0; i<$1.size(); i++) { SCM x = CONVERT_TO((($1_type &)$1)[i]); - gh_vector_set_x($result,gh_long2scm(i),x); + scm_vector_set_x($result,scm_from_long(i),x); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector { /* native sequence? */ - if (gh_vector_p($input)) { - unsigned int size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; - SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + SCM o = scm_vector_ref($input,scm_from_ulong(0)); $1 = CHECK(o) ? 1 : 0; } - } else if (gh_null_p($input)) { + } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { /* check the first element only */ T* x; - SCM head = gh_car($input); + SCM head = SCM_CAR($input); $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ @@ -328,24 +328,24 @@ namespace std { %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { /* native sequence? */ - if (gh_vector_p($input)) { - unsigned int size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; - SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + SCM o = scm_vector_ref($input,scm_from_ulong(0)); $1 = CHECK(o) ? 1 : 0; } - } else if (gh_null_p($input)) { + } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { /* check the first element only */ T* x; - SCM head = gh_car($input); + SCM head = SCM_CAR($input); $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ @@ -394,17 +394,17 @@ namespace std { }; %enddef - specialize_stl_vector(bool,gh_boolean_p,gh_scm2bool,SWIG_bool2scm); - specialize_stl_vector(char,gh_number_p,gh_scm2long,gh_long2scm); - specialize_stl_vector(int,gh_number_p,gh_scm2long,gh_long2scm); - specialize_stl_vector(long,gh_number_p,gh_scm2long,gh_long2scm); - specialize_stl_vector(short,gh_number_p,gh_scm2long,gh_long2scm); - specialize_stl_vector(unsigned char,gh_number_p,gh_scm2ulong,gh_ulong2scm); - specialize_stl_vector(unsigned int,gh_number_p,gh_scm2ulong,gh_ulong2scm); - specialize_stl_vector(unsigned long,gh_number_p,gh_scm2ulong,gh_ulong2scm); - specialize_stl_vector(unsigned short,gh_number_p,gh_scm2ulong,gh_ulong2scm); - specialize_stl_vector(float,gh_number_p,gh_scm2double,gh_double2scm); - specialize_stl_vector(double,gh_number_p,gh_scm2double,gh_double2scm); - specialize_stl_vector(std::string,gh_string_p,SWIG_scm2string,SWIG_string2scm); + specialize_stl_vector(bool,scm_is_bool,scm_is_true,SWIG_bool2scm); + specialize_stl_vector(char,scm_is_number,scm_to_long,scm_from_long); + specialize_stl_vector(int,scm_is_number,scm_to_long,scm_from_long); + specialize_stl_vector(long,scm_is_number,scm_to_long,scm_from_long); + specialize_stl_vector(short,scm_is_number,scm_to_long,scm_from_long); + specialize_stl_vector(unsigned char,scm_is_number,scm_to_ulong,scm_from_ulong); + specialize_stl_vector(unsigned int,scm_is_number,scm_to_ulong,scm_from_ulong); + specialize_stl_vector(unsigned long,scm_is_number,scm_to_ulong,scm_from_ulong); + specialize_stl_vector(unsigned short,scm_is_number,scm_to_ulong,scm_from_ulong); + specialize_stl_vector(float,scm_is_number,scm_to_double,scm_from_double); + specialize_stl_vector(double,scm_is_number,scm_to_double,scm_from_double); + specialize_stl_vector(std::string,scm_is_string,SWIG_scm2string,SWIG_string2scm); } diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i index 5036162fd..ab655eb9a 100644 --- a/Lib/guile/typemaps.i +++ b/Lib/guile/typemaps.i @@ -60,26 +60,26 @@ %typemap(throws) SWIGTYPE { $<ype temp = new $ltype($1); - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(SWIG_NewPointerObj(temp, $&descriptor, 1), + scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_listify(SWIG_NewPointerObj(temp, $&descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE & { - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(SWIG_NewPointerObj(&$1, $descriptor, 1), + scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_listify(SWIG_NewPointerObj(&$1, $descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE * { - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(SWIG_NewPointerObj($1, $descriptor, 1), + scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_listify(SWIG_NewPointerObj($1, $descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE [] { - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(SWIG_NewPointerObj($1, $descriptor, 1), + scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_listify(SWIG_NewPointerObj($1, $descriptor, 1), SCM_UNDEFINED)); } @@ -146,7 +146,7 @@ /* Enums */ -%typemap(in) enum SWIGTYPE { $1 = ($1_type) gh_scm2int($input); } +%typemap(in) enum SWIGTYPE { $1 = ($1_type) scm_to_int($input); } /* The complicated construction below needed to deal with anonymous enums, which cannot be cast to. */ %typemap(varin) enum SWIGTYPE { @@ -156,13 +156,13 @@ (char *) "enum variable '$name' cannot be set", SCM_EOL, SCM_BOOL_F); } - * (int *) &($1) = gh_scm2int($input); + * (int *) &($1) = scm_to_int($input); } -%typemap(out) enum SWIGTYPE { $result = gh_int2scm($1); } -%typemap(varout) enum SWIGTYPE { $result = gh_int2scm($1); } +%typemap(out) enum SWIGTYPE { $result = scm_from_long($1); } +%typemap(varout) enum SWIGTYPE { $result = scm_from_long($1); } %typemap(throws) enum SWIGTYPE { - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(gh_int2scm($1), SCM_UNDEFINED)); + scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_listify(scm_from_long($1), SCM_UNDEFINED)); } /* The SIMPLE_MAP_WITH_EXPR macro below defines the whole set of @@ -210,8 +210,8 @@ /* Throw typemap */ %typemap(throws) C_NAME { C_NAME swig_c_value = $1; - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(C_TO_SCM_EXPR, SCM_UNDEFINED)); + scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_listify(C_TO_SCM_EXPR, SCM_UNDEFINED)); } %enddef @@ -254,34 +254,34 @@ } /* Throw typemap */ %typemap(throws) C_NAME { - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(C_TO_SCM($1), SCM_UNDEFINED)); + scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_listify(C_TO_SCM($1), SCM_UNDEFINED)); } %enddef - SIMPLE_MAP(bool, gh_scm2bool, gh_bool2scm, boolean); - SIMPLE_MAP(char, gh_scm2char, gh_char2scm, char); - SIMPLE_MAP(unsigned char, gh_scm2char, gh_char2scm, char); - SIMPLE_MAP(signed char, gh_scm2char, gh_char2scm, char); - SIMPLE_MAP(int, gh_scm2int, gh_int2scm, integer); - SIMPLE_MAP(short, gh_scm2short, gh_int2scm, integer); - SIMPLE_MAP(long, gh_scm2long, gh_long2scm, integer); - SIMPLE_MAP(ptrdiff_t, gh_scm2long, gh_long2scm, integer); - SIMPLE_MAP(unsigned int, gh_scm2uint, gh_ulong2scm, integer); - SIMPLE_MAP(unsigned short, gh_scm2ushort, gh_ulong2scm, integer); - SIMPLE_MAP(unsigned long, gh_scm2ulong, gh_ulong2scm, integer); - SIMPLE_MAP(size_t, gh_scm2ulong, gh_ulong2scm, integer); - SIMPLE_MAP(float, gh_scm2double, gh_double2scm, real); - SIMPLE_MAP(double, gh_scm2double, gh_double2scm, real); -// SIMPLE_MAP(char *, SWIG_scm2str, gh_str02scm, string); -// SIMPLE_MAP(const char *, SWIG_scm2str, gh_str02scm, string); + SIMPLE_MAP(bool, scm_is_true, scm_from_bool, boolean); + SIMPLE_MAP(char, SCM_CHAR, SCM_MAKE_CHAR, char); + SIMPLE_MAP(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); + SIMPLE_MAP(signed char, SCM_CHAR, SCM_MAKE_CHAR, char); + SIMPLE_MAP(int, scm_to_int, scm_from_long, integer); + SIMPLE_MAP(short, scm_to_short, scm_from_long, integer); + SIMPLE_MAP(long, scm_to_long, scm_from_long, integer); + SIMPLE_MAP(ptrdiff_t, scm_to_long, scm_from_long, integer); + SIMPLE_MAP(unsigned int, scm_to_uint, scm_from_ulong, integer); + SIMPLE_MAP(unsigned short, scm_to_ushort, scm_from_ulong, integer); + SIMPLE_MAP(unsigned long, scm_to_ulong, scm_from_ulong, integer); + SIMPLE_MAP(size_t, scm_to_ulong, scm_from_ulong, integer); + SIMPLE_MAP(float, scm_to_double, scm_from_double, real); + SIMPLE_MAP(double, scm_to_double, scm_from_double, real); +// SIMPLE_MAP(char *, SWIG_scm2str, SWIG_str02scm, string); +// SIMPLE_MAP(const char *, SWIG_scm2str, SWIG_str02scm, string); /* Define long long typemaps -- uses functions that are only defined in recent versions of Guile, availability also depends on Guile's configuration. */ -SIMPLE_MAP(long long, gh_scm2long_long, gh_long_long2scm, integer); -SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer); +SIMPLE_MAP(long long, scm_to_long_long, scm_from_long_long, integer); +SIMPLE_MAP(unsigned long long, scm_to_ulong_long, scm_from_ulong_long, integer); /* Strings */ @@ -290,8 +290,8 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer); must_free = 1; } %typemap (varin, doc="NEW-VALUE is a string") char * {$1 = ($1_ltype)SWIG_scm2str($input);} - %typemap (out, doc="") char * {$result = gh_str02scm((const char *)$1);} - %typemap (varout, doc="") char * {$result = gh_str02scm($1);} + %typemap (out, doc="") char * {$result = SWIG_str02scm((const char *)$1);} + %typemap (varout, doc="") char * {$result = SWIG_str02scm($1);} %typemap (in, doc="$NAME is a string") char **INPUT(char * temp, int must_free = 0) { temp = (char *) SWIG_scm2str($input); $1 = &temp; must_free = 1; @@ -299,7 +299,7 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer); %typemap (in,numinputs=0) char **OUTPUT (char * temp) {$1 = &temp;} %typemap (argout,doc="$NAME (a string)") char **OUTPUT - {SWIG_APPEND_VALUE(gh_str02scm(*$1));} + {SWIG_APPEND_VALUE(SWIG_str02scm(*$1));} %typemap (in) char **BOTH = char **INPUT; %typemap (argout) char **BOTH = char **OUTPUT; %typemap (in) char **INOUT = char **INPUT; @@ -329,8 +329,8 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer); } %typemap(throws) char * { - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(gh_str02scm($1), SCM_UNDEFINED)); + scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_listify(SWIG_str02scm($1), SCM_UNDEFINED)); } /* Void */ @@ -350,7 +350,7 @@ typedef unsigned long SCM; %typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) { size_t temp; - $1 = ($1_ltype) gh_scm2newstr($input, &temp); + $1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp); $2 = ($2_ltype) temp; } diff --git a/Lib/mzscheme/typemaps.i b/Lib/mzscheme/typemaps.i index f12513df8..4078026ac 100644 --- a/Lib/mzscheme/typemaps.i +++ b/Lib/mzscheme/typemaps.i @@ -279,7 +279,7 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double, //%typemap(in) (char *STRING, int LENGTH) { // int temp; -// $1 = ($1_ltype) gh_scm2newstr($input, &temp); +// $1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp); // $2 = ($2_ltype) temp; //} diff --git a/Makefile.in b/Makefile.in index c33889587..cfa6d0933 100644 --- a/Makefile.in +++ b/Makefile.in @@ -59,7 +59,6 @@ skip-tcl = test -n "@SKIP_TCL@" skip-perl5 = test -n "@SKIP_PERL5@" skip-python = test -n "@SKIP_PYTHON@" skip-java = test -n "@SKIP_JAVA@" -skip-guilegh = test -n "@SKIP_GUILEGH@" skip-guile = test -n "@SKIP_GUILE@" skip-mzscheme = test -n "@SKIP_MZSCHEME@" skip-ruby = test -n "@SKIP_RUBY@" @@ -247,7 +246,6 @@ check-test-suite: \ check-perl5-test-suite \ check-python-test-suite \ check-java-test-suite \ - check-guilegh-test-suite \ check-guile-test-suite \ check-mzscheme-test-suite \ check-ruby-test-suite \ @@ -300,7 +298,6 @@ all-test-suite: \ all-perl5-test-suite \ all-python-test-suite \ all-java-test-suite \ - all-guilegh-test-suite \ all-guile-test-suite \ all-mzscheme-test-suite \ all-ruby-test-suite \ @@ -329,7 +326,6 @@ broken-test-suite: \ broken-perl5-test-suite \ broken-python-test-suite \ broken-java-test-suite \ - broken-guilegh-test-suite \ broken-guile-test-suite \ broken-mzscheme-test-suite \ broken-ruby-test-suite \ diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 211b11baf..afe039ac7 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -23,7 +23,6 @@ Guile Options (available with -guile)\n\ -emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\ -exportprimitive - Add the (export ...) code from scmstub into the\n\ GOOPS file.\n\ - -gh - Use the gh_ Guile API. (Guile <= 1.8) \n\ -goopsprefix - Prepend to all goops identifiers\n\ -linkage - Use linkage protocol (default `simple')\n\ Use `module' for native Guile module linking\n\ @@ -44,10 +43,14 @@ Guile Options (available with -guile)\n\ -proxy - Export GOOPS class definitions\n\ -primsuffix - Name appended to primitive module when exporting\n\ GOOPS classes. (default = \"primitive\")\n\ - -scm - Use the scm Guile API. (Guile >= 1.6, default) \n\ -scmstub - Output Scheme file with module declaration and\n\ exports; only with `passive' and `simple' linkage\n\ -useclassprefix - Prepend the class name to all goops identifiers\n\ +\n\ +Obsolete parameters:\n\ +These parameters do nothing, but are kept for compatibility with old scripts only.\n\ + -gh - Was used to select the gh_ Guile API. \n\ + -scm - scm Guile API is always used now. \n\ \n"; static File *f_begin = 0; @@ -94,7 +97,6 @@ static String *return_multi_doc = 0; static String *exported_symbols = 0; -static int use_scm_interface = 1; static int exporting_destructor = 0; static String *swigtype_ptr = 0; @@ -216,10 +218,8 @@ public: goops = true; Swig_mark_arg(i); } else if (strcmp(argv[i], "-gh") == 0) { - use_scm_interface = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-scm") == 0) { - use_scm_interface = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-primsuffix") == 0) { if (argv[i + 1]) { @@ -285,10 +285,7 @@ public: /* Add a symbol for this module */ Preprocessor_define("SWIGGUILE 1", 0); /* Read in default typemaps */ - if (use_scm_interface) - SWIG_config_file("guile_scm.swg"); - else - SWIG_config_file("guile_gh.swg"); + SWIG_config_file("guile_scm.swg"); allow_overloading(); } @@ -331,13 +328,6 @@ public: Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGGUILE\n"); - if (!use_scm_interface) { - if (SwigRuntime == 1) - Printf(f_runtime, "#define SWIG_GLOBAL\n"); - if (SwigRuntime == 2) - Printf(f_runtime, "#define SWIG_NOINCLUDE\n"); - } - /* Write out directives and declarations */ module = Swig_copy_string(Char(Getattr(n, "name"))); @@ -851,7 +841,7 @@ public: } } - if (use_scm_interface && exporting_destructor) { + if (exporting_destructor) { /* Mark the destructor's argument as destroyed. */ String *tm = NewString("SWIG_Guile_MarkPointerDestroyed($input);"); Replaceall(tm, "$input", Getattr(l, "emit:input")); @@ -868,14 +858,8 @@ public: Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL); // Now write code to make the function call - if (!use_scm_interface) - Printv(f->code, tab4, "gh_defer_ints();\n", NIL); - String *actioncode = emit_action(n); - if (!use_scm_interface) - 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, Swig_cresult_name(), f, actioncode))) { Replaceall(tm, "$result", "gswig_result"); @@ -958,11 +942,7 @@ public: Printv(f_wrappers, ");\n", NIL); Printv(f_wrappers, "}\n", NIL); /* Register it */ - if (use_scm_interface) { - Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s_rest);\n", proc_name, wname); - } else { - Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s_rest, 0, 0, 1);\n", proc_name, wname); - } + Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s_rest);\n", proc_name, wname); } else if (emit_setters && struct_member && strlen(Char(proc_name)) > 3) { int len = Len(proc_name); const char *pc = Char(proc_name); @@ -973,19 +953,13 @@ public: struct_member = 2; /* have a setter */ } else Printf(f_init, "SCM getter = "); - if (use_scm_interface) { - /* GOOPS support uses the MEMBER-set and MEMBER-get functions, - so ignore only_setters in this case. */ - if (only_setters && !goops) - Printf(f_init, "scm_c_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); - else - Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); - } else { - if (only_setters && !goops) - Printf(f_init, "scm_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); - else - Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s, %d, %d, 0);\n", proc_name, wname, numreq, numargs - numreq); - } + /* GOOPS support uses the MEMBER-set and MEMBER-get functions, + so ignore only_setters in this case. */ + if (only_setters && !goops) + Printf(f_init, "scm_c_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); + else + Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); + if (!is_setter) { /* Strip off "-get" */ char *pws_name = (char *) malloc(sizeof(char) * (len - 3)); @@ -993,19 +967,11 @@ public: pws_name[len - 4] = 0; if (struct_member == 2) { /* There was a setter, so create a procedure with setter */ - if (use_scm_interface) { - Printf(f_init, "scm_c_define"); - } else { - Printf(f_init, "gh_define"); - } + Printf(f_init, "scm_c_define"); Printf(f_init, "(\"%s\", " "scm_make_procedure_with_setter(getter, setter));\n", pws_name); } else { /* There was no setter, so make an alias to the getter */ - if (use_scm_interface) { - Printf(f_init, "scm_c_define"); - } else { - Printf(f_init, "gh_define"); - } + Printf(f_init, "scm_c_define"); Printf(f_init, "(\"%s\", getter);\n", pws_name); } Printf(exported_symbols, "\"%s\", ", pws_name); @@ -1013,15 +979,11 @@ public: } } else { /* Register the function */ - if (use_scm_interface) { - if (exporting_destructor) { - Printf(f_init, "((swig_guile_clientdata *)(SWIGTYPE%s->clientdata))->destroy = (guile_destructor) %s;\n", swigtype_ptr, wname); - //Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname); - } - Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); - } else { - Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s, %d, %d, 0);\n", proc_name, wname, numreq, numargs - numreq); + if (exporting_destructor) { + Printf(f_init, "((swig_guile_clientdata *)(SWIGTYPE%s->clientdata))->destroy = (guile_destructor) %s;\n", swigtype_ptr, wname); + //Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname); } + Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); } } else { /* overloaded function; don't export the single methods */ if (!Getattr(n, "sym:nextSibling")) { @@ -1044,11 +1006,7 @@ public: Printf(df->code, "#undef FUNC_NAME\n"); Printv(df->code, "}\n", NIL); Wrapper_print(df, f_wrappers); - if (use_scm_interface) { - Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s);\n", proc_name, dname); - } else { - Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, 0, 1);\n", proc_name, dname); - } + Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s);\n", proc_name, dname); DelWrapper(df); Delete(dispatch); Delete(dname); @@ -1221,36 +1179,27 @@ public: /* Read-only variables become a simple procedure returning the value; read-write variables become a simple procedure with an optional argument. */ - if (use_scm_interface) { - if (!goops && GetFlag(n, "feature:constasvar")) { - /* need to export this function as a variable instead of a procedure */ - if (scmstub) { - /* export the function in the wrapper, and (set!) it in scmstub */ - Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name); - Printf(scmtext, "(set! %s (%s))\n", proc_name, proc_name); - } else { - /* export the variable directly */ - Printf(f_init, "scm_c_define(\"%s\", %s(SCM_UNDEFINED));\n", proc_name, var_name); - } - - } else { - /* Export the function as normal */ + if (!goops && GetFlag(n, "feature:constasvar")) { + /* need to export this function as a variable instead of a procedure */ + if (scmstub) { + /* export the function in the wrapper, and (set!) it in scmstub */ Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name); + Printf(scmtext, "(set! %s (%s))\n", proc_name, proc_name); + } else { + /* export the variable directly */ + Printf(f_init, "scm_c_define(\"%s\", %s(SCM_UNDEFINED));\n", proc_name, var_name); } } else { - Printf(f_init, "\t gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, %d, 0);\n", proc_name, var_name, !GetFlag(n, "feature:immutable")); + /* Export the function as normal */ + Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name); } + } else { /* Read/write variables become a procedure with setter. */ - if (use_scm_interface) { - Printf(f_init, "{ SCM p = scm_c_define_gsubr(\"%s\", 0, 1, 0, (swig_guile_proc) %s);\n", proc_name, var_name); - Printf(f_init, "scm_c_define"); - } else { - Printf(f_init, "\t{ SCM p = gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, 1, 0);\n", proc_name, var_name); - Printf(f_init, "gh_define"); - } + Printf(f_init, "{ SCM p = scm_c_define_gsubr(\"%s\", 0, 1, 0, (swig_guile_proc) %s);\n", proc_name, var_name); + Printf(f_init, "scm_c_define"); Printf(f_init, "(\"%s\", " "scm_make_procedure_with_setter(p, p)); }\n", proc_name); } Printf(exported_symbols, "\"%s\", ", proc_name); @@ -1484,12 +1433,10 @@ public: String *mangled_classname = Swig_name_mangle(Getattr(n, "sym:name")); /* Export clientdata structure */ - if (use_scm_interface) { - Printf(f_runtime, "static swig_guile_clientdata _swig_guile_clientdata%s = { NULL, SCM_EOL };\n", mangled_classname); + Printf(f_runtime, "static swig_guile_clientdata _swig_guile_clientdata%s = { NULL, SCM_EOL };\n", mangled_classname); - Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", swigtype_ptr, ", (void *) &_swig_guile_clientdata", mangled_classname, ");\n", NIL); - SwigType_remember(ct); - } + Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", swigtype_ptr, ", (void *) &_swig_guile_clientdata", mangled_classname, ");\n", NIL); + SwigType_remember(ct); Delete(ct); /* Emit all of the members */ @@ -1725,28 +1672,16 @@ public: String *runtimeCode() { String *s; - if (use_scm_interface) { - s = Swig_include_sys("guile_scm_run.swg"); - if (!s) { - Printf(stderr, "*** Unable to open 'guile_scm_run.swg"); - s = NewString(""); - } - } else { - s = Swig_include_sys("guile_gh_run.swg"); - if (!s) { - Printf(stderr, "*** Unable to open 'guile_gh_run.swg"); - s = NewString(""); - } + s = Swig_include_sys("guile_scm_run.swg"); + if (!s) { + Printf(stderr, "*** Unable to open 'guile_scm_run.swg"); + s = NewString(""); } return s; } String *defaultExternalRuntimeFilename() { - if (use_scm_interface) { - return NewString("swigguilerun.h"); - } else { - return NewString("swigguileghrun.h"); - } + return NewString("swigguilerun.h"); } }; diff --git a/configure.ac b/configure.ac index 28696529d..1a699167f 100644 --- a/configure.ac +++ b/configure.ac @@ -1239,15 +1239,7 @@ else CFLAGS="`echo $CFLAGS | sed 's/-ansi//g;s/-pedantic//g;'` $GUILE_CFLAGS" LIBS="$LIBS $GUILE_LIBS" - AC_MSG_CHECKING(whether Guile's gh_ API works) - AC_LINK_IFELSE([AC_LANG_SOURCE([#include - int main() { SCM s; return gh_scm2int(s); }])], GUILE_GH_INTERFACE=1, ) - if test -n "$GUILE_GH_INTERFACE" ; then - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - AC_MSG_CHECKING(whether Guile's SCM_ API works) + AC_MSG_CHECKING(whether Guile/SCM_ API works) AC_LINK_IFELSE([AC_LANG_SOURCE([#include int main() { SCM s; scm_slot_exists_p(SCM_BOOL_F, SCM_BOOL_F); return SCM_STRING_LENGTH(s); }])], GUILE_SCM_INTERFACE=1, ) if test -n "$GUILE_SCM_INTERFACE" ; then @@ -1265,7 +1257,6 @@ fi AC_SUBST(GUILE) AC_SUBST(GUILE_CFLAGS) AC_SUBST(GUILE_LIBS) -AC_SUBST(GUILE_GH_INTERFACE) AC_SUBST(GUILE_SCM_INTERFACE) #---------------------------------------------------------------- @@ -2271,12 +2262,6 @@ if test -z "$GUILE_CFLAGS" || test -z "$GUILE_LIBS" || test -z "$GUILE_SCM_INTER fi AC_SUBST(SKIP_GUILE) -SKIP_GUILEGH= -if test -z "$GUILE_CFLAGS" || test -z "$GUILE_LIBS" || test -z "$GUILE_GH_INTERFACE"; then - SKIP_GUILEGH="1" -fi -AC_SUBST(SKIP_GUILEGH) - SKIP_MZSCHEME= if test -z "$MZC" || test -z "$MZDYNOBJ" ; then @@ -2452,7 +2437,6 @@ AC_CONFIG_FILES([ \ Examples/test-suite/csharp/Makefile \ Examples/test-suite/d/Makefile \ Examples/test-suite/guile/Makefile \ - Examples/test-suite/guilegh/Makefile \ Examples/test-suite/java/Makefile \ Examples/test-suite/mzscheme/Makefile \ Examples/test-suite/ocaml/Makefile \ From d689d9a860c4565db2e87ffd28e9fbe5bc7e848f Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Fri, 19 Apr 2013 18:57:31 +0200 Subject: [PATCH 127/273] Fix deprecation warnings for test suite under guile 2.0 --- Examples/guile/multimap/example.i | 2 +- Lib/cdata.i | 2 +- Lib/exception.i | 2 +- Lib/guile/typemaps.i | 18 +++++++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Examples/guile/multimap/example.i b/Examples/guile/multimap/example.i index f1d7974e4..21d7e5032 100644 --- a/Examples/guile/multimap/example.i +++ b/Examples/guile/multimap/example.i @@ -66,7 +66,7 @@ extern int count(char *bytes, int len, char c); /* Return the mutated string as a new object. */ %typemap(argout) (char *str, int len) { - SWIG_APPEND_VALUE(scm_mem2string($1,$2)); + SWIG_APPEND_VALUE(scm_from_locale_stringn($1,$2)); if ($1) scm_must_free($1); } diff --git a/Lib/cdata.i b/Lib/cdata.i index dbc1c42d2..22a6d9de8 100644 --- a/Lib/cdata.i +++ b/Lib/cdata.i @@ -17,7 +17,7 @@ typedef struct SWIGCDATA { #if SWIGGUILE %typemap(out) SWIGCDATA { - $result = scm_mem2string($1.data,$1.len); + $result = scm_from_locale_stringn($1.data,$1.len); } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); #elif SWIGCHICKEN diff --git a/Lib/exception.i b/Lib/exception.i index 867ecdbff..050042dab 100644 --- a/Lib/exception.i +++ b/Lib/exception.i @@ -24,7 +24,7 @@ SWIGINTERN void SWIG_exception_ (int code, const char *msg, const char *subr) { #define ERROR(scmerr) \ - scm_error(scm_str2symbol((char *) (scmerr)), \ + scm_error(scm_from_locale_string((char *) (scmerr)), \ (char *) subr, (char *) msg, \ SCM_EOL, SCM_BOOL_F) #define MAP(swigerr, scmerr) \ diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i index ab655eb9a..ba447ac28 100644 --- a/Lib/guile/typemaps.i +++ b/Lib/guile/typemaps.i @@ -60,25 +60,25 @@ %typemap(throws) SWIGTYPE { $<ype temp = new $ltype($1); - scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(SWIG_NewPointerObj(temp, $&descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE & { - scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(SWIG_NewPointerObj(&$1, $descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE * { - scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(SWIG_NewPointerObj($1, $descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE [] { - scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(SWIG_NewPointerObj($1, $descriptor, 1), SCM_UNDEFINED)); } @@ -151,7 +151,7 @@ enums, which cannot be cast to. */ %typemap(varin) enum SWIGTYPE { if (sizeof(int) != sizeof($1)) { - scm_error(scm_str2symbol("swig-error"), + scm_error(scm_from_locale_symbol("swig-error"), (char *) FUNC_NAME, (char *) "enum variable '$name' cannot be set", SCM_EOL, SCM_BOOL_F); @@ -161,7 +161,7 @@ %typemap(out) enum SWIGTYPE { $result = scm_from_long($1); } %typemap(varout) enum SWIGTYPE { $result = scm_from_long($1); } %typemap(throws) enum SWIGTYPE { - scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(scm_from_long($1), SCM_UNDEFINED)); } @@ -210,7 +210,7 @@ /* Throw typemap */ %typemap(throws) C_NAME { C_NAME swig_c_value = $1; - scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(C_TO_SCM_EXPR, SCM_UNDEFINED)); } %enddef @@ -254,7 +254,7 @@ } /* Throw typemap */ %typemap(throws) C_NAME { - scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(C_TO_SCM($1), SCM_UNDEFINED)); } %enddef @@ -329,7 +329,7 @@ SIMPLE_MAP(unsigned long long, scm_to_ulong_long, scm_from_ulong_long, integer); } %typemap(throws) char * { - scm_throw(scm_str2symbol((char *) "swig-exception"), + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), scm_listify(SWIG_str02scm($1), SCM_UNDEFINED)); } From 140829a826885814dfab713406b1f8b7413df0b0 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Sat, 20 Apr 2013 10:37:07 +0200 Subject: [PATCH 128/273] guile: fix std_map.i "$1 not found" error --- Lib/guile/std_map.i | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i index dfce6fc5c..1e1014f54 100644 --- a/Lib/guile/std_map.i +++ b/Lib/guile/std_map.i @@ -109,8 +109,8 @@ namespace std { } %typemap(out) map { SCM alist = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=$i.rbegin(); + i!=$i.rend(); ++i) { K* key = new K(i->first); T* val = new T(i->second); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); @@ -251,8 +251,8 @@ namespace std { } SCM keys() { SCM result = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=self->rbegin(); + i!=self->rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scm_cons(k,result); @@ -471,8 +471,8 @@ namespace std { } SCM keys() { SCM result = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=self->rbegin(); + i!=self->rend(); ++i) { SCM k = CONVERT_TO(i->first); result = scm_cons(k,result); } @@ -683,8 +683,8 @@ namespace std { } SCM keys() { SCM result = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=self->rbegin(); + i!=self->rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scm_cons(k,result); @@ -895,8 +895,8 @@ namespace std { } SCM keys() { SCM result = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=self->rbegin(); + i!=self->rend(); ++i) { SCM k = CONVERT_K_TO(i->first); result = scm_cons(k,result); } From 6a60efffd1477e92f1e2ed5f5afa82843d278965 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 Apr 2013 19:11:29 +0100 Subject: [PATCH 129/273] Some C++ experience needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 19/04/13 18:41, Geert Janssens wrote: > Hi, > > I'm working through the failing testcases for guile. One testcase fails > with a compilation error in some generated code based on std_map and > std_pair. I know exactly where this generated code comes from, but my > C++ knowledge is insufficient to understand the error, let alone remedy > it. I gather some kind of const violation, but that's all I can read > from it :( My hope is that someone used to working with stl will more > easily understand it. > > So, if someone can help me understand the error and what the fix would > be in C++, I can fix the corresponding .i file. > > This is the code snippet the causes the error: > > > /usr/lib/gcc/i686-redhat-linux/4.7.2/../../../../include/c++/4.7.2/bits/stl_pair.h:88:12: > error: non-static const member ‘const std::pair std::pair const std::pair >::second’, can’t use default assignment operator This is the main problem - it is saying there is no default assignment operator (because one of the members in pair is const). The solution is to avoid assignment. I've attached a patch to do this plus some error message corrections. William --- Lib/guile/std_pair.i | 81 +++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/Lib/guile/std_pair.i b/Lib/guile/std_pair.i index 86ca6e00f..238c5188b 100644 --- a/Lib/guile/std_pair.i +++ b/Lib/guile/std_pair.i @@ -22,7 +22,7 @@ namespace std { template struct pair { - %typemap(in) pair (std::pair* m) { + %typemap(in) pair %{ if (scm_is_pair($input)) { T* x; U* y; @@ -36,11 +36,9 @@ namespace std { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } - } - %typemap(in) const pair& (std::pair temp, - std::pair* m), - const pair* (std::pair temp, - std::pair* m) { + %} + %typemap(in) const pair& (std::pair *temp = 0), + const pair* (std::pair *temp = 0) %{ if (scm_is_pair($input)) { T* x; U* y; @@ -49,13 +47,14 @@ namespace std { second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); - temp = std::make_pair(*x,*y); - $1 = &temp; + temp = new std::pair< T, U >(*x,*y); + $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } - } + %} + %typemap(argout) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { T* x = new T($1.first); U* y = new U($1.second); @@ -129,7 +128,7 @@ namespace std { %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { - %typemap(in) pair (std::pair* m) { + %typemap(in) pair %{ if (scm_is_pair($input)) { U* y; SCM first, second; @@ -137,18 +136,16 @@ namespace std { second = SCM_CDR($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, - "map<" #T "," #U "> expected"); + "pair<" #T "," #U "> expected"); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); $1 = std::make_pair(CONVERT_FROM(first),*y); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } - } - %typemap(in) const pair& (std::pair temp, - std::pair* m), - const pair* (std::pair temp, - std::pair* m) { + %} + %typemap(in) const pair& (std::pair *temp = 0), + const pair* (std::pair *temp = 0) %{ if (scm_is_pair($input)) { U* y; SCM first, second; @@ -156,15 +153,16 @@ namespace std { second = SCM_CDR($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, - "map<" #T "," #U "> expected"); + "pair<" #T "," #U "> expected"); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); - temp = std::make_pair(CONVERT_FROM(first),*y); - $1 = &temp; + temp = new std::pair< T, U >(CONVERT_FROM(first),*y); + $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } - } + %} + %typemap(argout) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { U* y = new U($1.second); SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); @@ -230,7 +228,7 @@ namespace std { %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { - %typemap(in) pair (std::pair* m) { + %typemap(in) pair %{ if (scm_is_pair($input)) { T* x; SCM first, second; @@ -239,17 +237,15 @@ namespace std { x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, - "map<" #T "," #U "> expected"); + "pair<" #T "," #U "> expected"); $1 = std::make_pair(*x,CONVERT_FROM(second)); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } - } - %typemap(in) const pair& (std::pair temp, - std::pair* m), - const pair* (std::pair temp, - std::pair* m) { + %} + %typemap(in) const pair& (std::pair *temp = 0), + const pair* (std::pair *temp = 0) %{ if (scm_is_pair($input)) { T* x; SCM first, second; @@ -258,14 +254,15 @@ namespace std { x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, - "map<" #T "," #U "> expected"); - temp = std::make_pair(*x,CONVERT_FROM(second)); - $1 = &temp; + "pair<" #T "," #U "> expected"); + temp = new std::pair< T, U >(*x,CONVERT_FROM(second)); + $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } - } + %} + %typemap(argout) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { T* x = new T($1.first); SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); @@ -332,40 +329,38 @@ namespace std { %define specialize_std_pair_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) template<> struct pair { - %typemap(in) pair (std::pair* m) { + %typemap(in) pair %{ if (scm_is_pair($input)) { SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, - "map<" #T "," #U "> expected"); + "pair<" #T "," #U "> expected"); $1 = std::make_pair(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } - } - %typemap(in) const pair& (std::pair temp, - std::pair* m), - const pair* (std::pair temp, - std::pair* m) { + %} + %typemap(in) const pair& (std::pair *temp = 0), + const pair* (std::pair *temp = 0) %{ if (scm_is_pair($input)) { SCM first, second; first = SCM_CAR($input); second = SCM_CDR($input); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, - "map<" #T "," #U "> expected"); - temp = std::make_pair(CONVERT_T_FROM(first), - CONVERT_U_FROM(second)); - $1 = &temp; + "pair<" #T "," #U "> expected"); + temp = new std::pair< T, U >(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); + $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } - } + %} + %typemap(argout) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { $result = scm_cons(CONVERT_T_TO($1.first), CONVERT_U_TO($1.second)); From 9110d47ea653bfd4d972cb00b3b77afce63dfb9a Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 24 Apr 2013 09:56:02 +0200 Subject: [PATCH 130/273] Use freearg instead of argout to free temp variable --- Lib/guile/std_pair.i | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/guile/std_pair.i b/Lib/guile/std_pair.i index 238c5188b..512d0d555 100644 --- a/Lib/guile/std_pair.i +++ b/Lib/guile/std_pair.i @@ -54,7 +54,7 @@ namespace std { SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } %} - %typemap(argout) const pair&, const pair* %{ delete temp$argnum; %} + %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { T* x = new T($1.first); U* y = new U($1.second); @@ -162,7 +162,7 @@ namespace std { SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } %} - %typemap(argout) const pair&, const pair* %{ delete temp$argnum; %} + %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { U* y = new U($1.second); SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); @@ -262,7 +262,7 @@ namespace std { SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } %} - %typemap(argout) const pair&, const pair* %{ delete temp$argnum; %} + %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { T* x = new T($1.first); SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); @@ -360,7 +360,7 @@ namespace std { SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } %} - %typemap(argout) const pair&, const pair* %{ delete temp$argnum; %} + %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { $result = scm_cons(CONVERT_T_TO($1.first), CONVERT_U_TO($1.second)); From 469022d311c3a979b5a228b472891a21b56f3a6d Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 24 Apr 2013 17:23:06 +0200 Subject: [PATCH 131/273] Disable guile 2's autocompilation feature for the test suite Autocompilation generates a lot of warnings. Most of them just informational, but it clutters the test output. --- Doc/Manual/Guile.html | 6 ++++++ Examples/test-suite/guile/Makefile.in | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 53368bc77..8ecdf249c 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -56,6 +56,12 @@ SWIG works with Guile versions 1.8.x and 2.0.x. Support for version 1.6.x has been dropped. The last version of SWIG that still works with Guile version 1.6.x is SWIG 2.0.9. +

        +Note that starting with guile 2.0, the guile sources can be compiled for +improved performance. This is currently not tested with swig +so your mileage may vary. To be safe set environment variable +GUILE_AUTO_COMPILE to 0 when using swig generated guile code. +

        23.2 Meaning of "Module"

        diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in index 455c26a66..0c7b3137c 100644 --- a/Examples/test-suite/guile/Makefile.in +++ b/Examples/test-suite/guile/Makefile.in @@ -52,7 +52,7 @@ INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guile # a file is found which has _runme.scm appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean From fb7b45beccd9a1e5fd3b24c44369ec44600da73f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Apr 2013 15:56:27 +0200 Subject: [PATCH 132/273] Add guile test for guile 2 --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index abdb54327..7d7204b6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ matrix: env: SWIGLANG=csharp - compiler: gcc env: SWIGLANG=go + - compiler: gcc + env: SWIGLANG=guile - compiler: gcc env: SWIGLANG=java - compiler: gcc @@ -34,6 +36,7 @@ before_install: - time sudo apt-get -qq install libboost-dev - if test "$SWIGLANG" = "csharp"; then sudo apt-get -qq install mono-devel; fi - if test "$SWIGLANG" = "go"; then go env | sed -e 's/^/export /' > goenvsetup && source goenvsetup && rm -f goenvsetup; fi # Until configure.ac is fixed + - if test "$SWIGLANG" = "guile"; then sudo apt-get -qq install guile-2.0-dev; fi - if test "$SWIGLANG" = "lua"; then sudo apt-get -qq install lua5.1 liblua5.1-dev; fi - if test "$SWIGLANG" = "octave"; then sudo apt-get -qq install octave3.2 octave3.2-headers; fi - if test "$SWIGLANG" = "php"; then sudo apt-get install php5-cli php5-dev; fi From 3e0247e553fb187a2f5b2ac73d9978a4f0d126bd Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Sat, 27 Apr 2013 14:15:47 +0200 Subject: [PATCH 133/273] guile: fix integer test on 64 bit systems --- Examples/test-suite/integers.i | 11 ++++++ Examples/test-suite/schemerunme/integers.scm | 39 ++++++++++++++------ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Examples/test-suite/integers.i b/Examples/test-suite/integers.i index 7f78a2a18..6a9ede4bc 100644 --- a/Examples/test-suite/integers.i +++ b/Examples/test-suite/integers.i @@ -16,5 +16,16 @@ unsigned long unsigned_long_identity(unsigned long x) { return x; } signed long long signed_long_long_identity(signed long long x) { return x; } unsigned long long unsigned_long_long_identity(unsigned long long x) { return x; } + + size_t signed_char_size() { return sizeof (signed char); } + size_t unsigned_char_size() { return sizeof (unsigned char); } + size_t signed_short_size() { return sizeof (signed short); } + size_t unsigned_short_size() { return sizeof (unsigned short); } + size_t signed_int_size() { return sizeof (signed int); } + size_t unsigned_int_size() { return sizeof (unsigned int); } + size_t signed_long_size() { return sizeof (signed long); } + size_t unsigned_long_size() { return sizeof (unsigned long); } + size_t signed_long_long_size() { return sizeof (signed long long); } + size_t unsigned_long_long_size() { return sizeof (unsigned long long); } %} diff --git a/Examples/test-suite/schemerunme/integers.scm b/Examples/test-suite/schemerunme/integers.scm index 0bbf36ea8..903e6a9f1 100644 --- a/Examples/test-suite/schemerunme/integers.scm +++ b/Examples/test-suite/schemerunme/integers.scm @@ -12,17 +12,32 @@ (check-equality (throws-exception? (,function (- ,from 1))) #t) (check-equality (throws-exception? (,function (+ ,to 1))) #t))) -;;; signed char, unsigned char typemaps deal with characters, not integers. -;; (check-range signed-char-identity (- (expt 2 7)) (- (expt 2 7) 1)) -;; (check-range unsigned-char-identity 0 (- (expt 2 8) 1)) -(check-range signed-short-identity (- (expt 2 15)) (- (expt 2 15) 1)) -(check-range unsigned-short-identity 0 (- (expt 2 16) 1)) -(check-range signed-int-identity (- (expt 2 31)) (- (expt 2 31) 1)) -(check-range unsigned-int-identity 0 (- (expt 2 32) 1)) -(check-range signed-long-identity (- (expt 2 31)) (- (expt 2 31) 1)) -(check-range unsigned-long-identity 0 (- (expt 2 32) 1)) -;;; long long not implemented in Guile and MzScheme. -;; (check-range signed-long-long-identity (- (expt 2 63)) (- (expt 2 63) 1)) -;; (check-range unsigned-long-long-identity 0 (- (expt 2 64) 1)) +(let ((signed-short-min (- (expt 2 (- (* (signed-short-size) 8) 1)))) + (signed-short-max (- (expt 2 (- (* (signed-short-size) 8) 1)) 1)) + (unsigned-short-max (- (expt 2 (* (unsigned-short-size) 8)) 1)) + (signed-int-min (- (expt 2 (- (* (signed-int-size) 8) 1)))) + (signed-int-max (- (expt 2 (- (* (signed-int-size) 8) 1)) 1)) + (unsigned-int-max (- (expt 2 (* (unsigned-int-size) 8)) 1)) + (signed-long-min (- (expt 2 (- (* (signed-long-size) 8) 1)))) + (signed-long-max (- (expt 2 (- (* (signed-long-size) 8) 1)) 1)) + (unsigned-long-max (- (expt 2 (* (unsigned-long-size) 8)) 1)) + (signed-long-long-min (- (expt 2 (- (* (signed-long-long-size) 8) 1)))) + (signed-long-long-max (- (expt 2 (- (* (signed-long-long-size) 8) 1)) 1)) + (unsigned-long-long-max (- (expt 2 (* (unsigned-long-long-size) 8)) 1)) + ) + + ;;; signed char, unsigned char typemaps deal with characters, not integers. + ;; (check-range signed-char-identity (- (expt 2 7)) (- (expt 2 7) 1)) + ;; (check-range unsigned-char-identity 0 (- (expt 2 8) 1)) + (check-range signed-short-identity signed-short-min signed-short-max) + (check-range unsigned-short-identity 0 unsigned-short-max) + (check-range signed-int-identity signed-int-min signed-int-max) + (check-range unsigned-int-identity 0 unsigned-int-max) + (check-range signed-long-identity signed-long-min signed-long-max) + (check-range unsigned-long-identity 0 unsigned-long-max) + ;;; long long not implemented in Guile and MzScheme. + (check-range signed-long-long-identity signed-long-long-min signed-long-long-max) + (check-range unsigned-long-long-identity 0 unsigned-long-long-max) +) (exit 0) From 7b9c302fa10d30cbef1784b09df81492ba5f86f6 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Fri, 26 Apr 2013 16:52:38 +0200 Subject: [PATCH 134/273] guile: fix matrix example - add missing library in link phase - empty true path () for if is not allowed --- Examples/guile/Makefile.in | 5 +++-- Examples/guile/matrix/Makefile | 1 + Examples/guile/matrix/matrix.scm | 28 ++++++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Examples/guile/Makefile.in b/Examples/guile/Makefile.in index 3110ac994..69c7bb696 100644 --- a/Examples/guile/Makefile.in +++ b/Examples/guile/Makefile.in @@ -7,6 +7,7 @@ SWIG = ../$(top_srcdir)/preinst-swig CC = @CC@ CXX = @CXX@ CFLAGS = @PLATFLAGS@ +LIBS = GUILE_CFLAGS = @GUILE_CFLAGS@ GUILE_LIBS = @GUILE_LIBS@ SWIGOPT = @@ -31,10 +32,10 @@ guile_clean: sub-all: $(SWIG) -guile $(SWIGOPT) $(IFILE) - $(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) + $(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) sub-all-cxx: $(SWIG) -c++ -guile $(SWIGOPT) $(IFILE) - $(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) + $(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) # Makefile ends here diff --git a/Examples/guile/matrix/Makefile b/Examples/guile/matrix/Makefile index e8466e5fc..988a0ee5c 100644 --- a/Examples/guile/matrix/Makefile +++ b/Examples/guile/matrix/Makefile @@ -12,6 +12,7 @@ build: TARGET=$(TARGET) \ IFILE=$(IFILE) \ MODULE=$(MODULE) \ + LIBS="-lm" \ sub-all clean: diff --git a/Examples/guile/matrix/matrix.scm b/Examples/guile/matrix/matrix.scm index 18e52842d..d7cab84f4 100644 --- a/Examples/guile/matrix/matrix.scm +++ b/Examples/guile/matrix/matrix.scm @@ -138,24 +138,28 @@ (set-m m1 i j (+ (get-m m1 i j) (get-m m2 i j))) (add-two m1 m2 i (+ j 1))) (add-two m1 m2 (+ i 1) 0)))) - (if (null? ML) () (begin - (add-two M (car ML) 0 0) - (add-mat M (cdr ML))))) + (if (null? ML) *unspecified* + (begin + (add-two M (car ML) 0 0) + (add-mat M (cdr ML))))) (define (cleanup ML) - (if (null? ML) () (begin - (destroy-matrix (car ML)) - (cleanup (cdr ML))))) + (if (null? ML) *unspecified* + (begin + (destroy-matrix (car ML)) + (cleanup (cdr ML))))) (define (make-random ML) ; Put random values in them - (if (null? ML) () (begin - (randmat (car ML)) - (make-random (cdr ML))))) + (if (null? ML) *unspecified* + (begin + (randmat (car ML)) + (make-random (cdr ML))))) (define (mul-mat m ML) - (if (null? ML) () (begin - (mat-mult m (car ML) m) - (mul-mat m (cdr ML))))) + (if (null? ML) *unspecified* + (begin + (mat-mult m (car ML) m) + (mul-mat m (cdr ML))))) ;;; Now we'll hammer on things a little bit just to make ;;; sure everything works. From 95bfa86ae9b043b07ab7dd2a243846f2084693c6 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Fri, 26 Apr 2013 17:25:50 +0200 Subject: [PATCH 135/273] guile: fix multimap example - fix compiler warning - fix guile 2 deprecation warnings - minor cleanup of generated code --- Examples/guile/multimap/example.i | 51 ++++++++++++++++++------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/Examples/guile/multimap/example.i b/Examples/guile/multimap/example.i index 21d7e5032..135b6b123 100644 --- a/Examples/guile/multimap/example.i +++ b/Examples/guile/multimap/example.i @@ -15,43 +15,52 @@ extern int squareCubed (int n, int *OUTPUT); extern int gcd(int x, int y); -%typemap(in) (int argc, char *argv[]) { - int i; - SCM *v; - if (!(SCM_NIMP($input) && SCM_VECTORP($input))) { +%typemap(in) (int argc, char *argv[]) %{ + scm_t_array_handle handle; + size_t i; + ssize_t inc; + const SCM *v; + if (!(SCM_NIMP($input) && scm_is_vector($input))) { SWIG_exception(SWIG_ValueError, "Expecting a vector"); return 0; } - $1 = SCM_LENGTH($input); + v = scm_vector_elements($input, &handle, &$1, &inc); if ($1 == 0) { SWIG_exception(SWIG_ValueError, "Vector must contain at least 1 element"); } $2 = (char **) malloc(($1+1)*sizeof(char *)); - v = SCM_VELTS($input); - for (i = 0; i < $1; i++) { - if (!(SCM_NIMP(v[i]) && SCM_STRINGP(v[i]))) { - free($2); + for (i = 0; i < $1; i++, v +=inc ) { + if (!(SCM_NIMP(*v) && scm_is_string(*v))) { + free($2); SWIG_exception(SWIG_ValueError, "Vector items must be strings"); return 0; } - $2[i] = SCM_CHARS(v[i]); + $2[i] = scm_to_locale_string(*v); } $2[i] = 0; -} + scm_array_handle_release (&handle); +%} -%typemap(freearg) (int argc, char *argv[]) { - free($2); -} +%typemap(freearg) (int argc, char *argv[]) %{ + for (i = 0; i < $1; i++) { + free($2[i]); + } + free($2); +%} extern int gcdmain(int argc, char *argv[]); -%typemap(in) (char *bytes, int len) { - if (!(SCM_NIMP($input) && SCM_STRINGP($input))) { +%typemap(in) (char *bytes, int len) %{ + if (!(SCM_NIMP($input) && scm_is_string($input))) { SWIG_exception(SWIG_ValueError, "Expecting a string"); } - $1 = SCM_CHARS($input); - $2 = SCM_LENGTH($input); -} + $1 = scm_to_locale_string($input); + $2 = scm_c_string_length($input); +%} + +%typemap(freearg) (char *bytes, int len) %{ + free($1); +%} extern int count(char *bytes, int len, char c); @@ -67,7 +76,7 @@ extern int count(char *bytes, int len, char c); %typemap(argout) (char *str, int len) { SWIG_APPEND_VALUE(scm_from_locale_stringn($1,$2)); - if ($1) scm_must_free($1); + if ($1) SWIG_free($1); } extern void capitalize(char *str, int len); @@ -78,7 +87,7 @@ extern void capitalize(char *str, int len); %typemap(check) (double cx, double cy) { double a = $1*$1 + $2*$2; if (a > 1.0) { - SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle"); + SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle"); } } From ce14abaf616c9592f746639b962486ea9c917e5f Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Sun, 28 Apr 2013 21:13:40 +0200 Subject: [PATCH 136/273] guile: emit warning when -gh or -scm option are used --- Source/Modules/guile.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index afe039ac7..c1821c916 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -218,8 +218,10 @@ public: goops = true; Swig_mark_arg(i); } else if (strcmp(argv[i], "-gh") == 0) { + Printf(stderr, "guile: Warning: -gh option is deprecated. Swig will always generate wrappers using the scm interface. See documentation for more information regarding the deprecated gh interface.\n"); Swig_mark_arg(i); } else if (strcmp(argv[i], "-scm") == 0) { + Printf(stderr, "guile: Warning: -scm option is deprecated. Swig will always generate wrappers using the scm interface. See documentation for more information regarding the deprecated gh interface.\n"); Swig_mark_arg(i); } else if (strcmp(argv[i], "-primsuffix") == 0) { if (argv[i + 1]) { From 7297f5aa513411f345e8c2438e88b1d9683bedcd Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Sun, 28 Apr 2013 22:38:20 +0200 Subject: [PATCH 137/273] Don't use obsolete -scm option in own makefiles --- Examples/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index b1bf8d049..403e6191c 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -466,13 +466,13 @@ GUILE_SCRIPT = $(RUNME).scm # Build a dynamically loaded module with passive linkage and the scm interface #------------------------------------------------------------------ guile: $(SRCS) - $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_cpp: $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCS) - $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $@ From 9203c6d5c63a04dfe894d60b83af7f4e76d96515 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 29 Apr 2013 08:02:18 +0100 Subject: [PATCH 138/273] Remove deprecated Guile options from help. Also use wording for deprecated options warning which is consistent with elsewhere. --- Source/Modules/guile.cxx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index c1821c916..e0a084583 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -46,11 +46,6 @@ Guile Options (available with -guile)\n\ -scmstub - Output Scheme file with module declaration and\n\ exports; only with `passive' and `simple' linkage\n\ -useclassprefix - Prepend the class name to all goops identifiers\n\ -\n\ -Obsolete parameters:\n\ -These parameters do nothing, but are kept for compatibility with old scripts only.\n\ - -gh - Was used to select the gh_ Guile API. \n\ - -scm - scm Guile API is always used now. \n\ \n"; static File *f_begin = 0; @@ -218,10 +213,10 @@ public: goops = true; Swig_mark_arg(i); } else if (strcmp(argv[i], "-gh") == 0) { - Printf(stderr, "guile: Warning: -gh option is deprecated. Swig will always generate wrappers using the scm interface. See documentation for more information regarding the deprecated gh interface.\n"); + Printf(stderr, "Deprecated command line option: -gh. Wrappers are always generated for the SCM interface. See documentation for more information regarding the deprecated GH interface.\n"); Swig_mark_arg(i); } else if (strcmp(argv[i], "-scm") == 0) { - Printf(stderr, "guile: Warning: -scm option is deprecated. Swig will always generate wrappers using the scm interface. See documentation for more information regarding the deprecated gh interface.\n"); + Printf(stderr, "Deprecated command line option: -scm. Wrappers are always generated for the SCM interface. See documentation for more information regarding the deprecated GH interface.\n"); Swig_mark_arg(i); } else if (strcmp(argv[i], "-primsuffix") == 0) { if (argv[i + 1]) { From 17a563538580d6e414db71d06b3a6fd35d5b1ec5 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 29 Apr 2013 12:30:33 +0200 Subject: [PATCH 139/273] Add summary of recent guile updates in changelog --- CHANGES.current | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 5022a3030..96e5124a4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,16 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.10 (in progress) ============================ +2013-04-28: gjanssens + Updates in guile module: + - Add support for guile 2.0 + - Drop support for guile 1.6 + - Drop support for generating wrappers using guile's gh interface. + All generated wrappers will use the scm interface from now on. + - Deprecate -gh and -scm options. They are no longer needed. + A warning will be issued when these options are still used. + - Fix all tests and examples to have a successful travis test + 2013-04-18: wsfulton Apply Patch #36 from Jesus Lopez to add support for $descriptor() special variable macro expansion in fragments. For example: From c30a79217de051c05ead8d9c94e0dbcfea5c26f7 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 29 Apr 2013 12:51:47 +0200 Subject: [PATCH 140/273] guilescm directory no longer exists. No need to have it in .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 877d2b2a9..fbeebc67d 100644 --- a/.gitignore +++ b/.gitignore @@ -101,7 +101,6 @@ Examples/test-suite/csharp/*/ Examples/test-suite/d/*/ Examples/test-suite/go/*/ Examples/test-suite/guile/*/ -Examples/test-suite/guilescm/*/ Examples/test-suite/java/*/ Examples/test-suite/lua/*/ Examples/test-suite/mzscheme/*/ From 850cd375990da5a93376cfed1aacf47f71695e7c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 29 Apr 2013 22:01:46 +0100 Subject: [PATCH 141/273] Don't skip Python testing if static library directory not found 'make check' does not require the Python static libraries to be available. There is no easy way to find PYLIB - the directory containing the static library especially now Debian based systems have changed to put them in directories like /usr/lib/x86_64-linux-gnu/libpython2.7.a. --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 1a699167f..2a86e9fa7 100644 --- a/configure.ac +++ b/configure.ac @@ -2237,14 +2237,14 @@ AC_SUBST(SKIP_OCTAVE) SKIP_PYTHON= -if (test -z "$PYINCLUDE" || test -z "$PYLIB") && - (test -z "$PY3INCLUDE" || test -z "PY3LIB") ; then +if (test -z "$PYINCLUDE") && + (test -z "$PY3INCLUDE") ; then SKIP_PYTHON="1" fi AC_SUBST(SKIP_PYTHON) SKIP_PYTHON3= -if test -z "$PY3INCLUDE" || test -z "$PY3LIB" ; then +if test -z "$PY3INCLUDE" ; then SKIP_PYTHON3="1" fi AC_SUBST(SKIP_PYTHON3) From ae1c39591787c934429e33e134e19ffabe3da5bb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 29 Apr 2013 18:38:11 +0100 Subject: [PATCH 142/273] Guile tweak in CHANGES.current --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 96e5124a4..46b0d5589 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -6,7 +6,7 @@ Version 2.0.10 (in progress) ============================ 2013-04-28: gjanssens - Updates in guile module: + [Guile] Updates in guile module: - Add support for guile 2.0 - Drop support for guile 1.6 - Drop support for generating wrappers using guile's gh interface. From ac596eb8a3bce7d4d72dce78c7a8b12014a3b428 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 29 Apr 2013 19:06:44 +0100 Subject: [PATCH 143/273] Add C++ class example for Guile Also correct other example c++ makefiles --- Examples/guile/class/Makefile | 18 ++++++++++++++++ Examples/guile/class/example.cxx | 28 ++++++++++++++++++++++++ Examples/guile/class/example.h | 34 ++++++++++++++++++++++++++++++ Examples/guile/class/example.i | 9 ++++++++ Examples/guile/std_vector/Makefile | 6 +++--- 5 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 Examples/guile/class/Makefile create mode 100644 Examples/guile/class/example.cxx create mode 100644 Examples/guile/class/example.h create mode 100644 Examples/guile/class/example.i diff --git a/Examples/guile/class/Makefile b/Examples/guile/class/Makefile new file mode 100644 index 000000000..827b2fe03 --- /dev/null +++ b/Examples/guile/class/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i + +check: build + +build: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp + +static: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp + +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean diff --git a/Examples/guile/class/example.cxx b/Examples/guile/class/example.cxx new file mode 100644 index 000000000..1e8e203dd --- /dev/null +++ b/Examples/guile/class/example.cxx @@ -0,0 +1,28 @@ +/* File : example.c */ + +#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/guile/class/example.h b/Examples/guile/class/example.h new file mode 100644 index 000000000..0d4527e92 --- /dev/null +++ b/Examples/guile/class/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/guile/class/example.i b/Examples/guile/class/example.i new file mode 100644 index 000000000..fbdf7249f --- /dev/null +++ b/Examples/guile/class/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/guile/std_vector/Makefile b/Examples/guile/std_vector/Makefile index 08bf82c87..fa138f43f 100644 --- a/Examples/guile/std_vector/Makefile +++ b/Examples/guile/std_vector/Makefile @@ -1,17 +1,17 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig -SRCS = +CXXSRCS = TARGET = example INTERFACE = example.i check: build build: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp clean: From 4b1e8828658d9464cb9f4adf56db9d764d78bf23 Mon Sep 17 00:00:00 2001 From: Terrell Russell Date: Tue, 30 Apr 2013 22:49:12 -0300 Subject: [PATCH 144/273] subject/verb agreement --- Doc/Manual/README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/README b/Doc/Manual/README index f01013d54..66daaec90 100644 --- a/Doc/Manual/README +++ b/Doc/Manual/README @@ -1,9 +1,9 @@ This directory contains the HTML for the SWIG users manual. All of this HTML is hand-written. However, section numbering, indices, -and the table of contents is generated automatically by the 'maketoc.py' +and the table of contents are generated automatically by the 'maketoc.py' script. The Makefile has further information on how the various alternative -forms of the documentation is generated from the hand-written HTML. +forms of the documentation are generated from the hand-written HTML. There are 4 types of boxes that code or whatever can be inside: -
        ...
        From 8767e4e29e3214ea91565c7e2dce7bd7860f2c9a Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 1 May 2013 11:19:14 +0200 Subject: [PATCH 145/273] guile: make constants example display some output similar to other languages --- Examples/guile/constants/constants.scm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Examples/guile/constants/constants.scm b/Examples/guile/constants/constants.scm index 5220150f1..59fd26e5a 100644 --- a/Examples/guile/constants/constants.scm +++ b/Examples/guile/constants/constants.scm @@ -1,10 +1,19 @@ (or (= (ICONST) 42) (exit 1)) +(display "ICONST = ")(display (ICONST))(display " (should be 42)\n") (or (< (abs (- (FCONST) 2.1828)) 0.00001) (exit 1)) +(display "FCONST = ")(display (FCONST))(display " (should be 2.1828)\n") (or (char=? (CCONST) #\x) (exit 1)) +(display "CCONST = ")(display (CCONST))(display " (should be 'x')\n") (or (char=? (CCONST2) #\newline) (exit 1)) +(display "CCONST2 = ")(display (CCONST2))(display " (this should be on a new line)\n") (or (string=? (SCONST) "Hello World") (exit 1)) +(display "SCONST = ")(display (SCONST))(display " (should be 'Hello World')\n") (or (string=? (SCONST2) "\"Hello World\"") (exit 1)) +(display "SCONST2 = ")(display (SCONST2))(display " (should be \"Hello World\")\n") (or (< (abs (- (EXPR) (+ (ICONST) (* 3 (FCONST))))) 0.00001) (exit 1)) +(display "EXPR = ")(display (abs (- (EXPR) (+ (ICONST) (* 3 (FCONST))))))(display " (should round to 0.0)\n") (or (= (iconst) 37) (exit 1)) +(display "iconst = ")(display (iconst))(display " (should be 37)\n") (or (< (abs (- (fconst) 3.14)) 0.00001) (exit 1)) +(display "fconst = ")(display (fconst))(display " (should be 3.14)\n") (exit 0) From fbb1978eb459ffa6bbae2192e86608fab4781d99 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 1 May 2013 12:13:13 +0200 Subject: [PATCH 146/273] guile: get multimap example to run --- Examples/guile/Makefile.in | 8 +++++++- Examples/guile/multimap/Makefile | 1 + Examples/guile/multimap/runme.scm | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Examples/guile/Makefile.in b/Examples/guile/Makefile.in index 69c7bb696..f84d54a38 100644 --- a/Examples/guile/Makefile.in +++ b/Examples/guile/Makefile.in @@ -7,7 +7,8 @@ SWIG = ../$(top_srcdir)/preinst-swig CC = @CC@ CXX = @CXX@ CFLAGS = @PLATFLAGS@ -LIBS = +LIBS = +GUILE = @GUILE@ GUILE_CFLAGS = @GUILE_CFLAGS@ GUILE_LIBS = @GUILE_LIBS@ SWIGOPT = @@ -38,4 +39,9 @@ sub-all-cxx: $(SWIG) -c++ -guile $(SWIGOPT) $(IFILE) $(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) +run_example: + if [ -f $(RUNSCRIPT) ]; then \ + env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(RUNSCRIPT); \ + fi + # Makefile ends here diff --git a/Examples/guile/multimap/Makefile b/Examples/guile/multimap/Makefile index 00fa5df28..7b2f264ba 100644 --- a/Examples/guile/multimap/Makefile +++ b/Examples/guile/multimap/Makefile @@ -5,6 +5,7 @@ TARGET = example INTERFACE = example.i check: build + $(MAKE) -f ../Makefile RUNSCRIPT=runme.scm run_example build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ diff --git a/Examples/guile/multimap/runme.scm b/Examples/guile/multimap/runme.scm index edc197259..1654fd3a8 100644 --- a/Examples/guile/multimap/runme.scm +++ b/Examples/guile/multimap/runme.scm @@ -1,6 +1,6 @@ ;;; Test out some multi-argument typemaps -(use-modules (example)) +(dynamic-call "scm_init_example_module" (dynamic-link "./libexample.so")) ; Call the GCD function @@ -27,4 +27,4 @@ (display (capitalize "hello world")) (newline) - +(exit 0) From 6704501aad77eb0fad25468515d37e3c9e95ef21 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 1 May 2013 16:02:02 +0100 Subject: [PATCH 147/273] Guile multimap example fix for 64 bit systems --- Examples/guile/multimap/example.i | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Examples/guile/multimap/example.i b/Examples/guile/multimap/example.i index 135b6b123..c24d45ddc 100644 --- a/Examples/guile/multimap/example.i +++ b/Examples/guile/multimap/example.i @@ -18,13 +18,15 @@ extern int gcd(int x, int y); %typemap(in) (int argc, char *argv[]) %{ scm_t_array_handle handle; size_t i; + size_t lenp; ssize_t inc; const SCM *v; if (!(SCM_NIMP($input) && scm_is_vector($input))) { SWIG_exception(SWIG_ValueError, "Expecting a vector"); return 0; } - v = scm_vector_elements($input, &handle, &$1, &inc); + v = scm_vector_elements($input, &handle, &lenp, &inc); + $1 = (int)lenp; if ($1 == 0) { SWIG_exception(SWIG_ValueError, "Vector must contain at least 1 element"); } From 5690323b8f970297d5ed8c5ad3a743654ca17b53 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 3 May 2013 19:39:11 +0100 Subject: [PATCH 148/273] Rework perl5 compiler and linker flags This fixes perl on cygwin. Probably on other platforms too. --- Examples/Makefile.in | 13 ++++++++----- configure.ac | 34 +++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 403e6191c..8ffb667f6 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -24,7 +24,7 @@ TARGET = CC = @CC@ CXX = @CXX@ -CFLAGS = @PLATFLAGS@ +CFLAGS = @BOOST_CPPFLAGS@ @PLATFLAGS@ prefix = @prefix@ exec_prefix= @exec_prefix@ SRCS = @@ -217,6 +217,9 @@ PERL5_INCLUDE= @PERL5EXT@ # Extra Perl specific dynamic linking options PERL5_DLNK = @PERL5DYNAMICLINKING@ PERL5_CCFLAGS = @PERL5CCFLAGS@ +PERL5_CCDLFLAGS = @PERL5CCDLFLAGS@ +PERL5_CCCDLFLAGS = @PERL5CCCDLFLAGS@ +PERL5_LDFLAGS = @PERL5LDFLAGS@ PERL = @PERL@ PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS) PERL5_SCRIPT = $(RUNME).pl @@ -227,8 +230,8 @@ PERL5_SCRIPT = $(RUNME).pl perl5: $(SRCS) $(SWIG) -perl5 $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) + $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE) + $(LDSHARED) $(CFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Build a Perl5 dynamically loadable module (C++) @@ -236,8 +239,8 @@ perl5: $(SRCS) perl5_cpp: $(SRCS) $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE) + $(CXXSHARED) $(CFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Build a module from existing XS C source code. (ie. from xsubpp). diff --git a/configure.ac b/configure.ac index 2a86e9fa7..1fcdadfca 100644 --- a/configure.ac +++ b/configure.ac @@ -847,7 +847,7 @@ fi AC_MSG_CHECKING(for Perl5 header files) if test -n "$PERL"; then PERL5DIR=`($PERL -e 'use Config; print $Config{archlib}, "\n";') 2>/dev/null` - if test "$PERL5DIR" != ""; then + if test -n "$PERL5DIR" ; then dirs="$PERL5DIR $PERL5DIR/CORE" PERL5EXT=none for i in $dirs; do @@ -863,19 +863,40 @@ if test -n "$PERL"; then fi AC_MSG_CHECKING(for Perl5 library) - PERL5LIB=`($PERL -e 'use Config; $_=$Config{libperl}; s/^lib//; s/$Config{_a}$//; print $_, "\n"') 2>/dev/null` - if test "$PERL5LIB" = "" ; then + PERL5LIB=`($PERL -e 'use Config; $_=$Config{libperl}; s/^lib//; s/$Config{_a}$//; s/\.$Config{so}.*//; print $_, "\n"') 2>/dev/null` + if test -z "$PERL5LIB" ; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($PERL5LIB) fi - AC_MSG_CHECKING(for Perl5 compiler options) + AC_MSG_CHECKING(for Perl5 ccflags) PERL5CCFLAGS=`($PERL -e 'use Config; print $Config{ccflags}, "\n"' | sed "s/-Wdeclaration-after-statement//" | sed "s/-I/$ISYSTEM/") 2>/dev/null` - if test "$PERL5CCFLAGS" = "" ; then + if test -z "$PERL5CCFLAGS" ; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($PERL5CCFLAGS) fi + AC_MSG_CHECKING(for Perl5 ccdlflags) + PERL5CCDLFLAGS=`($PERL -e 'use Config; print $Config{ccdlflags}, "\n"') 2>/dev/null` + if test -z "$PERL5CCDLFLAGS" ; then + AC_MSG_RESULT(not found) + else + AC_MSG_RESULT($PERL5CCDLFLAGS) + fi + AC_MSG_CHECKING(for Perl5 cccdlflags) + PERL5CCCDLFLAGS=`($PERL -e 'use Config; print $Config{cccdlflags}, "\n"') 2>/dev/null` + if test -z "$PERL5CCCDLFLAGS" ; then + AC_MSG_RESULT(not found) + else + AC_MSG_RESULT($PERL5CCCDLFLAGS) + fi + AC_MSG_CHECKING(for Perl5 ldflags) + PERL5LDFLAGS=`($PERL -e 'use Config; print $Config{ldflags}, "\n"') 2>/dev/null` + if test -z "$PERL5LDFLAGS" ; then + AC_MSG_RESULT(not found) + else + AC_MSG_RESULT($PERL5LDFLAGS) + fi else AC_MSG_RESULT(unable to determine perl5 configuration) PERL5EXT=$PERL5DIR @@ -896,6 +917,9 @@ AC_SUBST(PERL5EXT) AC_SUBST(PERL5DYNAMICLINKING) AC_SUBST(PERL5LIB) AC_SUBST(PERL5CCFLAGS) +AC_SUBST(PERL5CCDLFLAGS) +AC_SUBST(PERL5CCCDLFLAGS) +AC_SUBST(PERL5LDFLAGS) #---------------------------------------------------------------- # Look for Octave From 7d29f88641597a184fb28e64579d0ffbfc61b1da Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 1 May 2013 15:37:53 +0100 Subject: [PATCH 149/273] Cosmetic on unknown javac version display --- Examples/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 8ffb667f6..e57516cf1 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -602,7 +602,7 @@ java_run: java_version: $(JAVA) -version - $(JAVAC) -version || echo "unknown javac version" + $(JAVAC) -version || echo "Unknown javac version" # ----------------------------------------------------------------- # Cleaning the java examples From 067b883813a2e324931a2d689b5c0ff6ae63c598 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 1 May 2013 21:44:31 +0100 Subject: [PATCH 150/273] Guile doc sections update --- Doc/Manual/Contents.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 42e135140..8ef413fcb 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -803,8 +803,9 @@
        -

        1.4 Prerequisites

        +

        1.5 Prerequisites

        @@ -127,7 +142,7 @@ However, this isn't meant to be a tutorial on C++ programming. For many of the gory details, you will almost certainly want to consult a good C++ reference. If you don't program in C++, you may just want to skip those parts of the manual. -

        1.5 Organization of this manual

        +

        1.6 Organization of this manual

        @@ -139,7 +154,7 @@ can probably skip to that chapter and find almost everything you need to know.

        -

        1.6 How to avoid reading the manual

        +

        1.7 How to avoid reading the manual

        @@ -151,7 +166,7 @@ The SWIG distribution also comes with a large directory of examples that illustrate different topics.

        -

        1.7 Backwards compatibility

        +

        1.8 Backwards compatibility

        @@ -162,8 +177,8 @@ this isn't always possible as the primary goal over time is to make SWIG better---a process that would simply be impossible if the developers are constantly bogged down with backwards compatibility issues. -Potential incompatibilities are clearly marked in the detailed release notes -(CHANGES files). +Potential incompatibilities are clearly marked in the detailed +release notes.

        @@ -187,7 +202,16 @@ Note: The version symbol is not defined in the generated SWIG wrapper file. The SWIG preprocessor has defined SWIG_VERSION since SWIG-1.3.11.

        -

        1.8 Credits

        +

        1.9 Release notes

        + + +

        +The CHANGES.current, CHANGES and RELEASENOTES files shipped with SWIG in the top level directory +contain, respectively, detailed release notes for the current version, +detailed release notes for previous releases and summary release notes from SWIG-1.3.22 onwards. +

        + +

        1.10 Credits

        @@ -200,7 +224,7 @@ who have made contributions at all levels over time. Contributors are mentioned either in the COPYRIGHT file or CHANGES files shipped with SWIG or in submitted bugs.

        -

        1.9 Bug reports

        +

        1.11 Bug reports

        diff --git a/README b/README index d69e7c6d8..6df8a4fbd 100644 --- a/README +++ b/README @@ -24,7 +24,11 @@ A SWIG FAQ and other hints can be found on the SWIG Wiki: License ======= -Please see the LICENSE file for details of the SWIG license. +Please see the LICENSE file for details of the SWIG license. For +further insight into the license including the license of SWIG's +output code, please visit + + http://www.swig.org/legal.html Release Notes ============= From 4bf045ce2c72f3cf3a20caa9dc42b26c9e6b6458 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 May 2013 07:29:30 +0100 Subject: [PATCH 152/273] Move installation and install check instructions from README to Preface section in the documentation. --- Doc/Manual/Contents.html | 8 ++ Doc/Manual/Preface.html | 208 +++++++++++++++++++++++++++++++++++++++ README | 129 ++---------------------- 3 files changed, 225 insertions(+), 120 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 3e9c844ed..ac21bcd1e 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -25,6 +25,14 @@

      • Release notes
      • Credits
      • Bug reports +
      • Installation +
      diff --git a/Doc/Manual/Preface.html b/Doc/Manual/Preface.html index d489912bd..d17dc229c 100644 --- a/Doc/Manual/Preface.html +++ b/Doc/Manual/Preface.html @@ -21,6 +21,14 @@
    • Release notes
    • Credits
    • Bug reports +
    • Installation +
    @@ -117,6 +125,7 @@ about this can be obtained at: +

    1.5 Prerequisites

    @@ -239,5 +248,204 @@ used, and any important pieces of the SWIG generated wrapper code. We can only fix bugs if we know about them.

    +

    1.12 Installation

    + + +

    1.12.1 Windows installation

    + + +

    +Please see the dedicated Windows chapter for instructions on installing +SWIG on Windows and running the examples. The Windows distribution is +called swigwin and includes a prebuilt SWIG executable, swig.exe, included in +the top level directory. Otherwise it is exactly the same as +the main SWIG distribution. There is no need to download anything else. +

    + +

    1.12.2 Unix installation

    + + +

    +You must use GNU make to build and install SWIG. +

    + +

    +PCRE +needs to be installed on your system to build SWIG, in particular +pcre-config must be available. If you have PCRE headers and libraries but not +pcre-config itself or, alternatively, wish to override the compiler or linker +flags returned by pcre-config, you may set PCRE_LIBS and PCRE_CFLAGS variables +to be used instead. And if you don't have PCRE at all, the configure script +will provide instructions for obtaining it. +

    + +

    +To build and install SWIG, simply type the following: +

    + +
    +$ ./configure
    +$ make
    +$ make install
    +
    + +

    +By default SWIG installs itself in /usr/local. If you need to install SWIG in +a different location or in your home directory, use the --prefix option +to ./configure. For example: +

    + +
    +$ ./configure --prefix=/home/yourname/projects
    +$ make
    +$ make install
    +
    + +

    +Note: the directory given to --prefix must be an absolute pathname. Do not use +the ~ shell-escape to refer to your home directory. SWIG won't work properly +if you do this. +

    + +

    +The INSTALL file shipped in the top level directory details more about using configure. Also try +

    + +
    +$ ./configure --help.
    +
    + +

    +The configure script will attempt to locate various packages on your machine +including Tcl, Perl5, Python and all the other target languages that SWIG +supports. Don't panic if you get 'not found' messages -- SWIG does not need these +packages to compile or run. The configure script is actually looking for +these packages so that you can try out the SWIG examples contained +in the 'Examples' directory without having to hack Makefiles. +Note that the --without-xxx options, where xxx is a target language, have +minimal effect. All they do is reduce the amount of testing done with +'make check'. The SWIG executable and library files installed cannot currently +be configured with a subset of target languages. +

    + +

    +SWIG used to include a set of runtime libraries for some languages for working +with multiple modules. These are no longer built during the installation stage. +However, users can build them just like any wrapper module as described in +the Modules chapter. +The CHANGES file shipped with SWIG in the top level directory +also lists some examples which build the runtime library. +

    + +

    +Note: +

    + +
      +
    • +If you checked the code out via Git, you will have to run ./autogen.sh +before ./configure. In addition, a full build of SWIG requires +a number of packages to be installed. Full instructions at +SWIG bleeding edge. +
    • +
    + +

    1.12.3 Macintosh OS X installation

    + + +

    +SWIG is known to work on various flavors of OS X. Follow the Unix installation +instructions above. However, as of this writing, there is still great deal of +inconsistency with how shared libaries are handled by various scripting languages +on OS X. +

    + +

    +Users of OS X should be aware that Darwin handles shared libraries and linking in +a radically different way than most Unix systems. In order to test SWIG and run +the examples, SWIG configures itself to use flat namespaces and to allow undefined +symbols (-flat_namespace -undefined suppress). This mostly closely follows the Unix +model and makes it more likely that the SWIG examples will work with whatever +installation of software you might have. However, this is generally not the recommended +technique for building larger extension modules. Instead, you should utilize +Darwin's two-level namespaces. Some details about this can be found here + +http://developer.apple.com/documentation/ReleaseNotes/DeveloperTools/TwoLevelNamespaces.html. + +

    + +

    +Needless to say, you might have to experiment a bit to get things working at first. +

    + +

    1.12.4 Testing

    + + +

    +If you want to test SWIG after building it, a check can be performed on Unix operating systems. +Type the following: +

    + +
    +    $ make -k check
    +
    + +

    +This step can be performed either before or after installation. +The check requires at least one of the target languages to be +installed. If it fails, it may mean that you have an uninstalled +language module or that the file 'Examples/Makefile' has been +incorrectly configured. It may also fail due to compiler issues such +as a broken C++ compiler. Even if the check fails, there is a +pretty good chance SWIG still works correctly --- you will just have to +mess around with one of the examples and some makefiles to get it to work. +Some tests may also fail due to missing dependency packages, eg PCRE +or Boost, but this will require careful analysis of the configure output +done during configuration. +

    + +

    +The test suite executed by the check is designed to stress-test +many parts of the implementation including obscure corner cases. If some +of these tests fail or generate warning messages, there is no reason for +alarm --- the test may be related to some new SWIG feature or a difficult bug +that we're trying to resolve. Chances are that SWIG will work just fine +for you. Note that if you have more than one CPU/core, then you can use +parallel make to speed up the check as it does take quite some time to run, +for example: +

    + +
    +    $ make -j2 -k check
    +
    + +

    +Also, SWIG's support for C++ is sufficiently advanced that certain +tests may fail on older C++ compilers (for instance if your compiler +does not support member templates). These errors are harmless if you +don't intend to use these features in your own programs. +

    + +

    +Note: The test-suite currently contains over 500 tests. If you +have many different target languages installed and a slow machine, it +might take more than an hour to run the test-suite. +

    + +

    1.12.5 Examples

    + + +

    +The Examples directory contains a variety of examples of using SWIG +and it has some browsable documentation. Simply point your browser to +the file "Example/index.html". +

    + +

    +The Examples directory also includes Visual C++ project 6 (.dsp) files for +building some of the examples on Windows. Later versions of Visual Studio +will convert these old style project files into a current solution file. +

    + diff --git a/README b/README index 6df8a4fbd..444643a0d 100644 --- a/README +++ b/README @@ -65,128 +65,17 @@ See the documentation for details of the SWIG_VERSION preprocessor symbol if you have backward compatibility issues and need to use more than one version of SWIG. -Windows Installation -==================== -Please see the Doc/Manual/Windows.html file for instructions on installing -SWIG on Windows and running the examples. The Windows distribution is -called swigwin and includes a prebuilt SWIG executable, swig.exe, included in -the same directory as this README file. Otherwise it is exactly the same as -the main SWIG distribution. There is no need to download anything else. - -Unix Installation -================= -You must use GNU `make' to build SWIG. - -http://www.gnu.org/software/make/ - -PCRE needs to be installed on your system to build SWIG, in particular -pcre-config must be available. If you have PCRE headers and libraries but not -pcre-config itself or, alternatively, wish to override the compiler or linker -flags returned by pcre-config, you may set PCRE_LIBS and PCRE_CFLAGS variables -to be used instead. And if you don't have PCRE at all, the configure script -will provide instructions for obtaining it. - -To build and install SWIG, simply type the following: - - % ./configure - % make - % make install - -By default SWIG installs itself in /usr/local. If you need to install SWIG in -a different location or in your home directory, use the --prefix option -to ./configure. For example: - - % ./configure --prefix=/home/yourname/projects - % make - % make install - -Note: the directory given to --prefix must be an absolute pathname. Do *NOT* use -the ~ shell-escape to refer to your home directory. SWIG won't work properly -if you do this. - -The file INSTALL details more about using configure. Also try - - % ./configure --help. - -The configure script will attempt to locate various packages on your machine -including Tcl, Perl5, Python and all the other target languages that SWIG -uses. Don't panic if you get 'not found' messages--SWIG does not need these -packages to compile or run. The configure script is actually looking for -these packages so that you can try out the SWIG examples contained -in the 'Examples' directory without having to hack Makefiles. -Note that the --without-xxx options, where xxx is a target language, have -minimal effect. All they do is reduce the amount of testing done with -'make check'. The SWIG executable and library files installed cannot currently -be configured with a subset of target languages. - -SWIG used to include a set of runtime libraries for some languages for working -with multiple modules. These are no longer built during the installation stage. -However, users can build them just like any wrapper module as described in -the documentation, Doc/Manual/Modules.html. The CHANGES file also lists some -examples which build the runtime library. - -Notes: - -(1) If you checked the code out via Git, you will have to run ./autogen.sh - before typing 'configure'. In addition, a full build of SWIG requires - the a number of packages to be installed. Full instructions at - http://www.swig.org/svn.html - -Macintosh OS X Installation -============================ -SWIG is known to work on various flavors of OS X. Follow the Unix installation -instructions above. However, as of this writing, there is still great deal of -inconsistency with how shared libaries are handled by various scripting languages -on OS X. We've tried to resolve these differences to the extent of our knowledge. - -Users of OS X should be aware that Darwin handles shared libraries and linking in -a radically different way than most Unix systems. In order to test SWIG and run -the examples, SWIG configures itself to use flat namespaces and to allow undefined -symbols (-flat_namespace -undefined suppress). This mostly closely follows the Unix -model and makes it more likely that the SWIG examples will work with whatever -installation of software you might have. However, this is generally not the recommended -technique for building larger extension modules. Instead, you should utilize -Darwin's two-level namespaces. Some details about this can be found here - -http://developer.apple.com/documentation/ReleaseNotes/DeveloperTools/TwoLevelNamespaces.html - -Needless to say, you might have to experiment a bit to get things working at first. +Installation +============ +Please read the Doc/Manual/Preface.html#Preface_installation for +full installation instructions for Windows, Unix and Mac OS X. +The INSTALL file has generic build and installation instructions for +Unix users. Testing ======= -If you want to test SWIG before installation, type the following: - - % make -k check - -'make -k check' requires at least one of the target languages to be -installed. If it fails, it may mean that you have an uninstalled -language module or that the file 'Examples/Makefile' has been -incorrectly configured. It may also fail due to compiler issues such -as broken C++ compiler. Even if 'make -k check' fails, there is a -pretty good chance SWIG still works correctly---you will just have to -mess around with one of the examples and some makefiles to get it to work. -Some tests may also fail due to missing dependency packages, eg PCRE -or Boost, but this will require careful analysis of the configure output. - -The testing suite executed by 'make -k check' is designed to stress-test -many parts of the implementation including obscure corner cases. If some -of these tests fail or generate warning messages, there is no reason for -alarm---the test may be related to some new SWIG feature or a difficult bug -that we're trying to resolve. Chances are that SWIG will work just fine -for you. Note that if you have more than one CPU/core, then you can use -parallel make to speed up the check as it does take quite some time to run, -for example: - - % make -j2 -k check - -Also, SWIG's support for C++ is sufficiently advanced that certain -tests may fail on older C++ compilers (for instance if your compiler -does not support member templates). These errors are harmless if you -don't intend to use these features in your own programs. - -Note: The test-suite currently contains over 500 tests. If you -have many different target languages installed and a slow machine, it -might take more than an hour to run the test-suite. +The typical 'make -k check' can be performed on Unix operating systems. +Please read Doc/Manual/Preface.html#Preface_testing for details. Examples ======== @@ -208,7 +97,7 @@ Troubleshooting In order to operate correctly, SWIG relies upon a set of library files. If after building SWIG, you get error messages like this, - % swig foo.i + $ swig foo.i :1. Unable to find 'swig.swg' :3. Unable to find 'tcl8.swg' From 13e76c30b32b028620ecde8a17861e6629304458 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 May 2013 19:30:04 +0100 Subject: [PATCH 153/273] Fixes looking for Guile in configure.ac --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 1fcdadfca..e4a6b79bc 100644 --- a/configure.ac +++ b/configure.ac @@ -1201,7 +1201,7 @@ else AC_PATH_PROG(PKG_CONFIG,pkgconfig) fi if test "x$PKG_CONFIG" = x; then - AC_MSG_NOTICE([Could not find the pkg-config (or pkgconfig) program required to set up Guile. Disabling Guile],) + AC_MSG_NOTICE([Could not find the pkg-config (or pkgconfig) program required to set up Guile. Disabling Guile.]) GUILE= GUILE_CFLAGS= GUILE_LIBS="" @@ -1220,11 +1220,11 @@ else GUILE_SERIES="" PKG_CHECK_MODULES(GUILE, [guile-1.8], [ GUILE_SERIES="18" ], [ PKG_CHECK_MODULES(GUILE, [guile-2.0], [GUILE_SERIES="20" ], [AC_MSG_NOTICE([ - Only Guile 1.8 or 2.0 is supported. Neither version appears to be installed correctly. Disabling Guile + Only Guile 1.8 or 2.0 is supported. Neither version appears to be installed correctly. Disabling Guile. ])]) ]) - if test "x$GUILE-SERIES" = x; then + if test "x$GUILE_SERIES" = x; then GUILE= GUILE_CFLAGS= GUILE_LIBS= From ca7b77cbd187a6532ea5a49bcab54b5aeaa19b74 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 3 May 2013 12:22:43 +0100 Subject: [PATCH 154/273] Fix tcl operator example crashing when run The example was accessing deleted memory and so sometimes crashed. --- Examples/tcl/operator/runme.tcl | 3 --- 1 file changed, 3 deletions(-) diff --git a/Examples/tcl/operator/runme.tcl b/Examples/tcl/operator/runme.tcl index 3b7c06838..921645536 100644 --- a/Examples/tcl/operator/runme.tcl +++ b/Examples/tcl/operator/runme.tcl @@ -9,11 +9,9 @@ puts "a = $a [$a str]" puts "b = $b [$b str]" set c [$a + $b] -Complex -this $c puts "c = $c [$c str]" set d [$a * $b] -Complex -this $d puts "a*b = [$d str]" # Alternative calling convention @@ -21,7 +19,6 @@ set e [Complex_- $a $c] puts "a-c = [Complex_str $e]" set f [new_ComplexCopy $e] -Complex -this $f puts "f = [$f str]" # Call assignment operator From f68cde8bb9a568b3285df81fbb7b33b9d3d45328 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 3 May 2013 15:29:07 +0100 Subject: [PATCH 155/273] Fix li_std_containers_int test case for Python < 2.6 Workaround bugs in older versions of Python --- .../test-suite/python/li_std_containers_int_runme.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 7611ee63e..f18e33812 100644 --- a/Examples/test-suite/python/li_std_containers_int_runme.py +++ b/Examples/test-suite/python/li_std_containers_int_runme.py @@ -1,6 +1,7 @@ # Check std::vector and std::list behaves the same as Python iterable types (list) from li_std_containers_int import * +import sys def failed(a, b, msg): raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b)) @@ -76,10 +77,13 @@ def container_insert_step(i, j, step, newval): 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) + # Python 2.6 contains bug fixes in extended slicing syntax: http://docs.python.org/2/whatsnew/2.6.html + skip_check = ps_error != None and(iv_error == il_error == None) and step > 0 and (sys.version[0:2] < (2, 6)) + if not(skip_check): + 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) + compare_containers(ps, iv, il) # Check std::vector and std::list delete behaves same as Python list delete including exceptions From 4ed422da6050b5004a14f31ab5caa9e012b99a78 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 7 May 2013 21:11:03 +0100 Subject: [PATCH 156/273] Revert guile configure to use guile-config Replace pkg-config with guile-config to look for guile. Using pkg-config requires the pkg.m4 autoconf macros to be properly installed on the machine running autogen.sh which is frequently a problem. pkg-config only supports more recent releases of guile so isn't very good at finding guile either. --- configure.ac | 116 +++++++++++++-------------------------------------- 1 file changed, 29 insertions(+), 87 deletions(-) diff --git a/configure.ac b/configure.ac index e4a6b79bc..07a768469 100644 --- a/configure.ac +++ b/configure.ac @@ -1176,8 +1176,10 @@ GUILE= GUILE_CFLAGS= GUILE_LIBS= -AC_ARG_WITH(guile, AS_HELP_STRING([--without-guile], [Disable Guile]) -AS_HELP_STRING([--with-guile=path], [Set location of Guile executable]),[GUILE="$withval"], [GUILE=yes]) +AC_ARG_WITH(guile-config, AS_HELP_STRING([--without-guile], [Disable Guile]) + AS_HELP_STRING([--with-guile-config=path], [Set location of guile-config]),[ GUILE_CONFIG="$withval"], [GUILE_CONFIG=]) +AC_ARG_WITH(guile,[ --with-guile=path Set location of Guile executable],[ + GUILE="$withval"], [GUILE=yes]) AC_ARG_WITH(guile-cflags,[ --with-guile-cflags=cflags Set cflags required to compile against Guile],[ GUILE_CFLAGS="$withval"]) AC_ARG_WITH(guile-libs,[ --with-guile-libs=ldflags Set ldflags needed to link with Guile],[ @@ -1186,95 +1188,35 @@ AC_ARG_WITH(guile-libs,[ --with-guile-libs=ldflags Set ldflags needed to lin # First, check for "--without-guile" or "--with-guile=no". if test x"${GUILE}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Guile]) - GUILE= - GUILE_CFLAGS= - GUILE_LIBS= else - - # Use pkg-config to find guile specific config parameters - # Note: if guile is not installed in a standard system path - # you can set the environment variable PKG_CONFIG_PATH to - # the directory where the guile package config file is stored - AC_PATH_PROG(PKG_CONFIG,pkg-config) - if test "x$PKG_CONFIG" = x; then - # @*%&$ Ximian programmers renamed this application - AC_PATH_PROG(PKG_CONFIG,pkgconfig) + if test -z "$GUILE_CONFIG" ; then + AC_PATH_PROG(GUILE_CONFIG, guile-config) fi - if test "x$PKG_CONFIG" = x; then - AC_MSG_NOTICE([Could not find the pkg-config (or pkgconfig) program required to set up Guile. Disabling Guile.]) - GUILE= - GUILE_CFLAGS= - GUILE_LIBS="" - else - - # If the user has given these values, cache them to override the - # detected values. - if test "x$GUILE_LIBS" != x; then - saved_GUILE_LIBS="$GUILE_LIBS" - fi - if test "x$GUILE_CFLAGS" != x; then - saved_GUILE_CFLAGS="$GUILE_CFLAGS" + if test -n "$GUILE_CONFIG" ; then + if test x"$GUILE" = xyes; then + AC_MSG_CHECKING([for guile bindir]) + guile_bindir="`$GUILE_CONFIG info bindir`" + AC_MSG_RESULT([$guile_bindir]) + GUILE=$guile_bindir/guile + if ! test -f "$GUILE" ; then + GUILE= + AC_PATH_PROG(GUILE, guile) + fi fi - # Look up GUILE_CFLAGS and GUILE_LIBS, and version check - GUILE_SERIES="" - PKG_CHECK_MODULES(GUILE, [guile-1.8], [ GUILE_SERIES="18" ], [ - PKG_CHECK_MODULES(GUILE, [guile-2.0], [GUILE_SERIES="20" ], [AC_MSG_NOTICE([ - Only Guile 1.8 or 2.0 is supported. Neither version appears to be installed correctly. Disabling Guile. - ])]) - ]) - - if test "x$GUILE_SERIES" = x; then - GUILE= - GUILE_CFLAGS= - GUILE_LIBS= - else - # Look up GUILE executable - if test "x$GUILE" = xyes; then - GUILE= - if test "$xGUILE_SERIES" = "x18"; then - AC_PATH_PROG(GUILE18, guile-1.8) - if test "x$GUILE18" != x; then - GUILE="$GUILE18" - fi - fi - if test "$xGUILE_SERIES" = "x20"; then - AC_PATH_PROG(GUILE20, guile-2.0) - if test "x$GUILE20" != x; then - GUILE="$GUILE20" - fi - fi - if test "x$GUILE" = x; then - AC_PATH_PROG(GUILE, guile) - fi - fi - - if test "x$saved_GUILE_LIBS" != x; then - GUILE_LIBS="$saved_GUILE_LIBS" - fi - if test "x$saved_GUILE_CFLAGS" != x; then - GUILE_CFLAGS="$saved_GUILE_CFLAGS" - fi - - guilesafe_CFLAGS=$CFLAGS - guilesafe_LIBS=$LIBS - # Filter out "-ansi -pedantic" because Guile header files will not compile with these flags. - # (The flags -ansi -pedantic are automatically added by ac_compile_warnings.m4) - CFLAGS="`echo $CFLAGS | sed 's/-ansi//g;s/-pedantic//g;'` $GUILE_CFLAGS" - LIBS="$LIBS $GUILE_LIBS" - - AC_MSG_CHECKING(whether Guile/SCM_ API works) - AC_LINK_IFELSE([AC_LANG_SOURCE([#include - int main() { SCM s; scm_slot_exists_p(SCM_BOOL_F, SCM_BOOL_F); return SCM_STRING_LENGTH(s); }])], GUILE_SCM_INTERFACE=1, ) - if test -n "$GUILE_SCM_INTERFACE" ; then - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - - CFLAGS=$guilesafe_CFLAGS - LIBS=$guilesafe_LIBS + if test -z "$GUILE_CFLAGS" ; then + AC_MSG_CHECKING([for guile compile flags]) + GUILE_CFLAGS="`$GUILE_CONFIG compile`" + AC_MSG_RESULT([$GUILE_CFLAGS]) fi + + if test -z "$GUILE_LIBS" ; then + AC_MSG_CHECKING([for guile link flags]) + GUILE_LIBS="`$GUILE_CONFIG link`" + AC_MSG_RESULT([$GUILE_LIBS]) + fi + + GUILE_SCM_INTERFACE=1 fi fi @@ -2281,7 +2223,7 @@ AC_SUBST(SKIP_JAVA) SKIP_GUILE= -if test -z "$GUILE_CFLAGS" || test -z "$GUILE_LIBS" || test -z "$GUILE_SCM_INTERFACE"; then +if test -z "$GUILE" || test -z "$GUILE_CFLAGS" || test -z "$GUILE_LIBS" || test -z "$GUILE_SCM_INTERFACE"; then SKIP_GUILE="1" fi AC_SUBST(SKIP_GUILE) From 70b9df5ee9513f263758b1b491c00f20e6e7adaf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 8 May 2013 12:42:17 +0100 Subject: [PATCH 157/273] Portable dynamic library loading for Guile dynamic-link and load-extension work without passing the .so or .dll as the shared library extension, so these have been dropped so the examples and test-suite work on Cygwin. Also update documentation and use the 'lib' prefix as that is what we commonly name the shared libraries. --- Doc/Manual/Guile.html | 34 ++++++++++++------- Examples/guile/multimap/runme.scm | 2 +- Examples/test-suite/guile/casts_runme.scm | 2 +- .../test-suite/guile/char_constant_runme.scm | 2 +- .../test-suite/guile/class_ignore_runme.scm | 2 +- Examples/test-suite/guile/constover_runme.scm | 2 +- Examples/test-suite/guile/contract_runme.scm | 2 +- Examples/test-suite/guile/cpp_enum_runme.scm | 2 +- .../test-suite/guile/cpp_namespace_runme.scm | 2 +- .../test-suite/guile/dynamic_cast_runme.scm | 2 +- .../test-suite/guile/guile_ext_test_runme.scm | 2 +- .../guile/import_nomodule_runme.scm | 2 +- Examples/test-suite/guile/imports_runme.scm | 4 +-- .../guile/inherit_missing_runme.scm | 2 +- Examples/test-suite/guile/integers_runme.scm | 2 +- .../test-suite/guile/li_std_string_runme.scm | 2 +- .../test-suite/guile/li_typemaps_runme.scm | 2 +- .../test-suite/guile/list_vector_runme.scm | 2 +- .../test-suite/guile/multivalue_runme.scm | 2 +- Examples/test-suite/guile/name_runme.scm | 2 +- .../guile/overload_complicated_runme.scm | 2 +- .../test-suite/guile/overload_copy_runme.scm | 2 +- .../guile/overload_extend_runme.scm | 2 +- .../guile/overload_simple_runme.scm | 2 +- .../guile/overload_subtype_runme.scm | 2 +- .../test-suite/guile/pointer_in_out_runme.scm | 2 +- .../guile/reference_global_vars_runme.scm | 2 +- .../guile/throw_exception_runme.scm | 2 +- .../guile/typedef_inherit_runme.scm | 2 +- Examples/test-suite/guile/typename_runme.scm | 4 +-- Examples/test-suite/guile/unions_runme.scm | 2 +- 31 files changed, 54 insertions(+), 44 deletions(-) diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 8ecdf249c..cfbfbd0b7 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -115,7 +115,7 @@ libraries into Guile.

     (define-module (my module))
    -(define my-so (dynamic-link "./example.so"))
    +(define my-so (dynamic-link "./libexample.so"))
     (dynamic-call "SWIG_init" my-so) ; make SWIG bindings
     ;; Scheme definitions can go here
     
    @@ -128,7 +128,17 @@ and dynamic-call:
    -(load-extension "./example.so" "SWIG_init")
    +(load-extension "./libexample.so" "SWIG_init")
    +
    +
    + +

    +A more portable approach would be to drop the shared library extension: +

    + +
    +
    +(load-extension "./libexample" "SWIG_init")
     
    @@ -171,7 +181,7 @@ information by including a directive like this in the interface file:
    -%scheme %{ (load-extension "./example.so" "SWIG_init") %}
    +%scheme %{ (load-extension "./libexample.so" "SWIG_init") %}
     
    @@ -225,7 +235,7 @@ shared libraries into Guile; all bindings are automatically put in newly created Guile modules.
    -(define my-so (dynamic-link "./foo.so"))
    +(define my-so (dynamic-link "./libfoo.so"))
     ;; create new module and put bindings there:
     (dynamic-call "scm_init_my_modules_foo_module" my-so) 
     
    @@ -233,7 +243,7 @@ newly created Guile modules. Newer Guile versions have a shorthand procedure for this:
    -(load-extension "./foo.so" "scm_init_my_modules_foo_module")
    +(load-extension "./libfoo.so" "scm_init_my_modules_foo_module")
     
    @@ -768,10 +778,10 @@ and might conflict with names from the GOOPS guile-module (see above). Pass the argument to solve this problem. If the -exportprimitive option is passed to SWIG the (export ...) code that would be exported into the scmstub file is exported at the bottom of the generated GOOPS guile-module. -The %goops directive should contain code to load the .so library. +The %goops directive should contain code to load the shared library.
    -%goops %{ (load-extension "./foo.so" "scm_init_my_modules_foo_module") %}
    +%goops %{ (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") %}
     

    @@ -783,7 +793,7 @@ Produces the following code at the top of the generated GOOPS guile-module (define-module (my modules foo)) ;; %goops directive goes here -(load-extension "./foo.so" "scm_init_my_modules_foo_module") +(load-extension "./libfoo.so" "scm_init_my_modules_foo_module") (use-modules (oop goops) (Swig common))

    @@ -791,7 +801,7 @@ Produces the following code at the top of the generated GOOPS guile-module
  • Passive Linkage with -scmstub: Here, the name of the scmstub file should be Module-primitive.scm (with primitive replaced with whatever is given with the -primsuffix -argument. The code to load the .so library should be located in the %scheme directive, +argument. The code to load the shared library should be located in the %scheme directive, which will then be added to the scmstub file. SWIG will automatically generate the line (use-modules (Package Module-primitive)) into the GOOPS guile-module. So if Module-primitive.scm is on the autoload path for guile, the @@ -799,7 +809,7 @@ into the GOOPS guile-module. So if Module-primitive.scm is on the autolo whatever code is needed to load the Module-primitive.scm file into guile.

    -%scheme %{ (load-extension "./foo.so" "scm_init_my_modules_foo_module") %}
    +%scheme %{ (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") %}
     // only include the following definition if (my modules foo) cannot
     // be loaded automatically
     %goops %{ 
    @@ -832,7 +842,7 @@ SWIG will also automatically generate the line (use-modules
     directive should contain whatever code is needed to get that module loaded into guile.

    -%goops %{ (load-extension "./foo.so" "scm_init_my_modules_foo_module") %}
    +%goops %{ (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") %}
     

    @@ -843,7 +853,7 @@ Produces the following code at the top of the generated GOOPS guile-module (define-module (my modules foo)) ;; %goops directive goes here (if any) -(load-extension "./foo.so" "scm_init_my_modules_foo_module") +(load-extension "./libfoo.so" "scm_init_my_modules_foo_module") (use-modules (oop goops) (Swig common)) (use-modules ((my modules foo-primitive) :renamer (symbol-prefix-proc diff --git a/Examples/guile/multimap/runme.scm b/Examples/guile/multimap/runme.scm index 1654fd3a8..d2ab8036e 100644 --- a/Examples/guile/multimap/runme.scm +++ b/Examples/guile/multimap/runme.scm @@ -1,6 +1,6 @@ ;;; Test out some multi-argument typemaps -(dynamic-call "scm_init_example_module" (dynamic-link "./libexample.so")) +(dynamic-call "scm_init_example_module" (dynamic-link "./libexample")) ; Call the GCD function diff --git a/Examples/test-suite/guile/casts_runme.scm b/Examples/test-suite/guile/casts_runme.scm index 7a0a0420b..5f22e7f86 100644 --- a/Examples/test-suite/guile/casts_runme.scm +++ b/Examples/test-suite/guile/casts_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_casts_module" (dynamic-link "./libcasts.so")) +(dynamic-call "scm_init_casts_module" (dynamic-link "./libcasts")) (load "../schemerunme/casts.scm") diff --git a/Examples/test-suite/guile/char_constant_runme.scm b/Examples/test-suite/guile/char_constant_runme.scm index d183b35e5..7061acdb1 100644 --- a/Examples/test-suite/guile/char_constant_runme.scm +++ b/Examples/test-suite/guile/char_constant_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_char_constant_module" (dynamic-link "./libchar_constant.so")) +(dynamic-call "scm_init_char_constant_module" (dynamic-link "./libchar_constant")) (load "../schemerunme/char_constant.scm") diff --git a/Examples/test-suite/guile/class_ignore_runme.scm b/Examples/test-suite/guile/class_ignore_runme.scm index b3229f85c..3ace843cb 100644 --- a/Examples/test-suite/guile/class_ignore_runme.scm +++ b/Examples/test-suite/guile/class_ignore_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_class_ignore_module" (dynamic-link "./libclass_ignore.so")) +(dynamic-call "scm_init_class_ignore_module" (dynamic-link "./libclass_ignore")) (load "../schemerunme/class_ignore.scm") diff --git a/Examples/test-suite/guile/constover_runme.scm b/Examples/test-suite/guile/constover_runme.scm index 1ab42d349..15e822fc2 100644 --- a/Examples/test-suite/guile/constover_runme.scm +++ b/Examples/test-suite/guile/constover_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_constover_module" (dynamic-link "./libconstover.so")) +(dynamic-call "scm_init_constover_module" (dynamic-link "./libconstover")) (load "../schemerunme/constover.scm") diff --git a/Examples/test-suite/guile/contract_runme.scm b/Examples/test-suite/guile/contract_runme.scm index ea80e321c..b31c9e9e7 100644 --- a/Examples/test-suite/guile/contract_runme.scm +++ b/Examples/test-suite/guile/contract_runme.scm @@ -1,6 +1,6 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_contract_module" (dynamic-link "./libcontract.so")) +(dynamic-call "scm_init_contract_module" (dynamic-link "./libcontract")) (load "testsuite.scm") (load "../schemerunme/contract.scm") diff --git a/Examples/test-suite/guile/cpp_enum_runme.scm b/Examples/test-suite/guile/cpp_enum_runme.scm index 5a2d9f048..bf365e878 100644 --- a/Examples/test-suite/guile/cpp_enum_runme.scm +++ b/Examples/test-suite/guile/cpp_enum_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./libcpp_enum.so")) +(dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./libcpp_enum")) (load "../schemerunme/cpp_enum.scm") diff --git a/Examples/test-suite/guile/cpp_namespace_runme.scm b/Examples/test-suite/guile/cpp_namespace_runme.scm index 2a871de24..a1f6cd4ca 100644 --- a/Examples/test-suite/guile/cpp_namespace_runme.scm +++ b/Examples/test-suite/guile/cpp_namespace_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_cpp_namespace_module" (dynamic-link "./libcpp_namespace.so")) +(dynamic-call "scm_init_cpp_namespace_module" (dynamic-link "./libcpp_namespace")) (load "../schemerunme/cpp_namespace.scm") diff --git a/Examples/test-suite/guile/dynamic_cast_runme.scm b/Examples/test-suite/guile/dynamic_cast_runme.scm index 7b70001d0..f69f6165a 100644 --- a/Examples/test-suite/guile/dynamic_cast_runme.scm +++ b/Examples/test-suite/guile/dynamic_cast_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_dynamic_cast_module" (dynamic-link "./libdynamic_cast.so")) +(dynamic-call "scm_init_dynamic_cast_module" (dynamic-link "./libdynamic_cast")) (load "../schemerunme/dynamic_cast.scm") diff --git a/Examples/test-suite/guile/guile_ext_test_runme.scm b/Examples/test-suite/guile/guile_ext_test_runme.scm index 452b08ee7..dd98580cf 100644 --- a/Examples/test-suite/guile/guile_ext_test_runme.scm +++ b/Examples/test-suite/guile/guile_ext_test_runme.scm @@ -1,4 +1,4 @@ -(dynamic-call "scm_init_guile_ext_test_module" (dynamic-link "./libguile_ext_test.so")) +(dynamic-call "scm_init_guile_ext_test_module" (dynamic-link "./libguile_ext_test")) ; This is a test for SF Bug 1573892 ; If IsPointer is called before TypeQuery, the test-is-pointer will fail diff --git a/Examples/test-suite/guile/import_nomodule_runme.scm b/Examples/test-suite/guile/import_nomodule_runme.scm index ffb2474fc..72f8b3a62 100644 --- a/Examples/test-suite/guile/import_nomodule_runme.scm +++ b/Examples/test-suite/guile/import_nomodule_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_import_nomodule_module" (dynamic-link "./libimport_nomodule.so")) +(dynamic-call "scm_init_import_nomodule_module" (dynamic-link "./libimport_nomodule")) (load "../schemerunme/import_nomodule.scm") diff --git a/Examples/test-suite/guile/imports_runme.scm b/Examples/test-suite/guile/imports_runme.scm index 2fda017ce..c319a4bae 100644 --- a/Examples/test-suite/guile/imports_runme.scm +++ b/Examples/test-suite/guile/imports_runme.scm @@ -6,6 +6,6 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_imports_a_module" (dynamic-link "./libimports_a.so")) -(dynamic-call "scm_init_imports_b_module" (dynamic-link "./libimports_b.so")) +(dynamic-call "scm_init_imports_a_module" (dynamic-link "./libimports_a")) +(dynamic-call "scm_init_imports_b_module" (dynamic-link "./libimports_b")) (load "../schemerunme/imports.scm") diff --git a/Examples/test-suite/guile/inherit_missing_runme.scm b/Examples/test-suite/guile/inherit_missing_runme.scm index 97e950cb2..ec02e7d42 100644 --- a/Examples/test-suite/guile/inherit_missing_runme.scm +++ b/Examples/test-suite/guile/inherit_missing_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_inherit_missing_module" (dynamic-link "./libinherit_missing.so")) +(dynamic-call "scm_init_inherit_missing_module" (dynamic-link "./libinherit_missing")) (load "../schemerunme/inherit_missing.scm") diff --git a/Examples/test-suite/guile/integers_runme.scm b/Examples/test-suite/guile/integers_runme.scm index 14ec8b0fe..7b4c9dc13 100644 --- a/Examples/test-suite/guile/integers_runme.scm +++ b/Examples/test-suite/guile/integers_runme.scm @@ -1,7 +1,7 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_integers_module" (dynamic-link "./libintegers.so")) +(dynamic-call "scm_init_integers_module" (dynamic-link "./libintegers")) (define-macro (throws-exception? form) `(catch #t diff --git a/Examples/test-suite/guile/li_std_string_runme.scm b/Examples/test-suite/guile/li_std_string_runme.scm index 05b74cd65..5dde68f8d 100644 --- a/Examples/test-suite/guile/li_std_string_runme.scm +++ b/Examples/test-suite/guile/li_std_string_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string.so")) +(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string")) (load "../schemerunme/li_std_string.scm") diff --git a/Examples/test-suite/guile/li_typemaps_runme.scm b/Examples/test-suite/guile/li_typemaps_runme.scm index 9824fc98e..269455ce5 100644 --- a/Examples/test-suite/guile/li_typemaps_runme.scm +++ b/Examples/test-suite/guile/li_typemaps_runme.scm @@ -4,7 +4,7 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps.so")) +(dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps")) (load "../schemerunme/li_typemaps.scm") (let ((lst (inoutr-int2 3 -2))) diff --git a/Examples/test-suite/guile/list_vector_runme.scm b/Examples/test-suite/guile/list_vector_runme.scm index 546d8a1ba..2025b53d5 100644 --- a/Examples/test-suite/guile/list_vector_runme.scm +++ b/Examples/test-suite/guile/list_vector_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_list_vector_module" (dynamic-link "./liblist_vector.so")) +(dynamic-call "scm_init_list_vector_module" (dynamic-link "./liblist_vector")) (load "../schemerunme/list_vector.scm") diff --git a/Examples/test-suite/guile/multivalue_runme.scm b/Examples/test-suite/guile/multivalue_runme.scm index d1d7fbfe7..1717e4ef4 100644 --- a/Examples/test-suite/guile/multivalue_runme.scm +++ b/Examples/test-suite/guile/multivalue_runme.scm @@ -3,5 +3,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_multivalue_module" (dynamic-link "./libmultivalue.so")) +(dynamic-call "scm_init_multivalue_module" (dynamic-link "./libmultivalue")) (load "../schemerunme/multivalue.scm") diff --git a/Examples/test-suite/guile/name_runme.scm b/Examples/test-suite/guile/name_runme.scm index 831c20610..7de0e54bf 100644 --- a/Examples/test-suite/guile/name_runme.scm +++ b/Examples/test-suite/guile/name_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_name_module" (dynamic-link "./libname.so")) +(dynamic-call "scm_init_name_module" (dynamic-link "./libname")) (load "../schemerunme/name.scm") diff --git a/Examples/test-suite/guile/overload_complicated_runme.scm b/Examples/test-suite/guile/overload_complicated_runme.scm index 3c2b80dbf..a38fb8afe 100644 --- a/Examples/test-suite/guile/overload_complicated_runme.scm +++ b/Examples/test-suite/guile/overload_complicated_runme.scm @@ -1,7 +1,7 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_overload_complicated_module" (dynamic-link "./liboverload_complicated.so")) +(dynamic-call "scm_init_overload_complicated_module" (dynamic-link "./liboverload_complicated")) (define-macro (check form) `(if (not ,form) diff --git a/Examples/test-suite/guile/overload_copy_runme.scm b/Examples/test-suite/guile/overload_copy_runme.scm index 9b93aeb8a..f6a90a57f 100644 --- a/Examples/test-suite/guile/overload_copy_runme.scm +++ b/Examples/test-suite/guile/overload_copy_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_overload_copy_module" (dynamic-link "./liboverload_copy.so")) +(dynamic-call "scm_init_overload_copy_module" (dynamic-link "./liboverload_copy")) (load "../schemerunme/overload_copy.scm") diff --git a/Examples/test-suite/guile/overload_extend_runme.scm b/Examples/test-suite/guile/overload_extend_runme.scm index cb0223dea..f31465891 100644 --- a/Examples/test-suite/guile/overload_extend_runme.scm +++ b/Examples/test-suite/guile/overload_extend_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_overload_extend_module" (dynamic-link "./liboverload_extend.so")) +(dynamic-call "scm_init_overload_extend_module" (dynamic-link "./liboverload_extend")) (load "../schemerunme/overload_extend.scm") diff --git a/Examples/test-suite/guile/overload_simple_runme.scm b/Examples/test-suite/guile/overload_simple_runme.scm index 993a5f30f..8e3dbb6ba 100644 --- a/Examples/test-suite/guile/overload_simple_runme.scm +++ b/Examples/test-suite/guile/overload_simple_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_overload_simple_module" (dynamic-link "./liboverload_simple.so")) +(dynamic-call "scm_init_overload_simple_module" (dynamic-link "./liboverload_simple")) (load "../schemerunme/overload_simple.scm") diff --git a/Examples/test-suite/guile/overload_subtype_runme.scm b/Examples/test-suite/guile/overload_subtype_runme.scm index 7dfa2c16c..857084d03 100644 --- a/Examples/test-suite/guile/overload_subtype_runme.scm +++ b/Examples/test-suite/guile/overload_subtype_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_overload_subtype_module" (dynamic-link "./liboverload_subtype.so")) +(dynamic-call "scm_init_overload_subtype_module" (dynamic-link "./liboverload_subtype")) (load "../schemerunme/overload_subtype.scm") diff --git a/Examples/test-suite/guile/pointer_in_out_runme.scm b/Examples/test-suite/guile/pointer_in_out_runme.scm index de3522749..da3542866 100644 --- a/Examples/test-suite/guile/pointer_in_out_runme.scm +++ b/Examples/test-suite/guile/pointer_in_out_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_pointer_in_out_module" (dynamic-link "./libpointer_in_out.so")) +(dynamic-call "scm_init_pointer_in_out_module" (dynamic-link "./libpointer_in_out")) (load "../schemerunme/pointer_in_out.scm") diff --git a/Examples/test-suite/guile/reference_global_vars_runme.scm b/Examples/test-suite/guile/reference_global_vars_runme.scm index 8cd31c3e8..dfc9dc634 100644 --- a/Examples/test-suite/guile/reference_global_vars_runme.scm +++ b/Examples/test-suite/guile/reference_global_vars_runme.scm @@ -1,3 +1,3 @@ ; copied from python runme_.py -(dynamic-call "scm_init_reference_global_vars_module" (dynamic-link "./libreference_global_vars.so")) +(dynamic-call "scm_init_reference_global_vars_module" (dynamic-link "./libreference_global_vars")) (load "../schemerunme/reference_global_vars.scm") diff --git a/Examples/test-suite/guile/throw_exception_runme.scm b/Examples/test-suite/guile/throw_exception_runme.scm index 377506276..aa9ff8a5c 100644 --- a/Examples/test-suite/guile/throw_exception_runme.scm +++ b/Examples/test-suite/guile/throw_exception_runme.scm @@ -1,7 +1,7 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception.so")) +(dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception")) (define-macro (check-throw form) `(catch 'swig-exception diff --git a/Examples/test-suite/guile/typedef_inherit_runme.scm b/Examples/test-suite/guile/typedef_inherit_runme.scm index d75d421d5..443e75f1b 100644 --- a/Examples/test-suite/guile/typedef_inherit_runme.scm +++ b/Examples/test-suite/guile/typedef_inherit_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_typedef_inherit_module" (dynamic-link "./libtypedef_inherit.so")) +(dynamic-call "scm_init_typedef_inherit_module" (dynamic-link "./libtypedef_inherit")) (load "../schemerunme/typedef_inherit.scm") diff --git a/Examples/test-suite/guile/typename_runme.scm b/Examples/test-suite/guile/typename_runme.scm index 4243f6974..057033521 100644 --- a/Examples/test-suite/guile/typename_runme.scm +++ b/Examples/test-suite/guile/typename_runme.scm @@ -1,3 +1,3 @@ -(dynamic-call "scm_init_typename_module" (dynamic-link "./libtypename.so")) -;;(dynamic-call "scm_init_types_module" (dynamic-link "./libtypes.so")) +(dynamic-call "scm_init_typename_module" (dynamic-link "./libtypename")) +;;(dynamic-call "scm_init_types_module" (dynamic-link "./libtypes")) (load "../schemerunme/typename.scm") diff --git a/Examples/test-suite/guile/unions_runme.scm b/Examples/test-suite/guile/unions_runme.scm index 867e8a3c3..510a19490 100644 --- a/Examples/test-suite/guile/unions_runme.scm +++ b/Examples/test-suite/guile/unions_runme.scm @@ -4,5 +4,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_unions_module" (dynamic-link "./libunions.so")) +(dynamic-call "scm_init_unions_module" (dynamic-link "./libunions")) (load "../schemerunme/unions.scm") From 10acae18d29b3b3d00a83dfed4eddb832da3264c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 8 May 2013 13:05:11 +0100 Subject: [PATCH 158/273] Correct Guile Makefile to fix test-suite/examples on Cygwin --- Examples/Makefile.in | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index e57516cf1..a3a2b04c9 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -466,36 +466,22 @@ GUILE_LIBPREFIX = lib GUILE_SCRIPT = $(RUNME).scm #------------------------------------------------------------------ -# Build a dynamically loaded module with passive linkage and the scm interface +# Build a dynamically loaded module with passive linkage #------------------------------------------------------------------ guile: $(SRCS) $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCS) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_cpp: $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCS) $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $@ + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $@ guile_externalhdr: $(SWIG) -guile -external-runtime $(TARGET) -# ----------------------------------------------------------------- -# Build a dynamically loadable module with passive linkage -# ----------------------------------------------------------------- - -guile_passive: $(SRCS) - $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCS) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) - -guile_passive_cpp: $(SRCS) - $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) - # ----------------------------------------------------------------- # Build statically linked Guile interpreter # ----------------------------------------------------------------- @@ -504,23 +490,23 @@ guile_static: $(SRCS) $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ - $(GUILE_CFLAGS) $(LIBS) -L$(GUILE_LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile + $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_static_cpp: $(SRCS) $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ - $(GUILE_CFLAGS) $(LIBS) -L$(GUILE_LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile + $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple: $(SRCS) $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ - $(GUILE_CFLAGS) $(LIBS) -L$(GUILE_LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile + $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple_cpp: $(SRCS) $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ - $(GUILE_CFLAGS) $(LIBS) -L$(GUILE_LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile + $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile # ----------------------------------------------------------------- # Running a Guile example From 1adb2390469576cb1a6b6e9337595fdc8a9e89e7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 8 May 2013 14:10:47 +0100 Subject: [PATCH 159/273] Fix running of Guile multivalue and std_vector examples --- Examples/guile/multivalue/Makefile | 1 + Examples/guile/multivalue/runme.scm | 3 ++- Examples/guile/std_vector/Makefile | 1 + Examples/guile/std_vector/runme.scm | 4 ++-- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Examples/guile/multivalue/Makefile b/Examples/guile/multivalue/Makefile index 00fa5df28..7b2f264ba 100644 --- a/Examples/guile/multivalue/Makefile +++ b/Examples/guile/multivalue/Makefile @@ -5,6 +5,7 @@ TARGET = example INTERFACE = example.i check: build + $(MAKE) -f ../Makefile RUNSCRIPT=runme.scm run_example build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ diff --git a/Examples/guile/multivalue/runme.scm b/Examples/guile/multivalue/runme.scm index 73eb5affa..729f3fa18 100644 --- a/Examples/guile/multivalue/runme.scm +++ b/Examples/guile/multivalue/runme.scm @@ -1,6 +1,6 @@ ;;;; Show the three different ways to deal with multiple return values -(use-modules (example)) +(dynamic-call "scm_init_example_module" (dynamic-link "./libexample")) ;;; Multiple values as lists. By default, if more than one value is to ;;; be returned, a list of the values is created and returned. The @@ -64,3 +64,4 @@ (display remainder) (newline)) +(exit 0) diff --git a/Examples/guile/std_vector/Makefile b/Examples/guile/std_vector/Makefile index fa138f43f..6eca67519 100644 --- a/Examples/guile/std_vector/Makefile +++ b/Examples/guile/std_vector/Makefile @@ -5,6 +5,7 @@ TARGET = example INTERFACE = example.i check: build + $(MAKE) -f ../Makefile RUNSCRIPT=runme.scm run_example build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ diff --git a/Examples/guile/std_vector/runme.scm b/Examples/guile/std_vector/runme.scm index 77443a156..470f22922 100644 --- a/Examples/guile/std_vector/runme.scm +++ b/Examples/guile/std_vector/runme.scm @@ -1,6 +1,5 @@ -;; run with mzscheme -r example.scm -(use-modules (example)) +(dynamic-call "scm_init_example_module" (dynamic-link "./libexample")) ; repeatedly invoke a procedure with v and an index as arguments (define (with-vector v proc size-proc) @@ -52,3 +51,4 @@ (print-DoubleVector v) (delete-DoubleVector v) +(exit 0) From cd4c1d3c3f22b3bc519816cc9879141b65eb3938 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 8 May 2013 16:48:27 +0100 Subject: [PATCH 160/273] Tidy up target language versions display --- Examples/Makefile.in | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index a3a2b04c9..9ce0f1f81 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -440,7 +440,7 @@ octave_run: # ----------------------------------------------------------------- octave_version: - $(OCTAVE) --version | grep -i version + $(OCTAVE) --version | head -n 1 # ----------------------------------------------------------------- # Cleaning the Octave examples @@ -520,7 +520,7 @@ guile_run: # ----------------------------------------------------------------- guile_version: - $(GUILE) --version + $(GUILE) --version | head -n 1 # ----------------------------------------------------------------- # Cleaning the Guile examples @@ -1004,7 +1004,7 @@ php_run: # ----------------------------------------------------------------- php_version: - $(PHP) -v + $(PHP) -v | head -n 1 # ----------------------------------------------------------------- # Cleaning the PHP examples @@ -1075,7 +1075,7 @@ pike_run: # ----------------------------------------------------------------- pike_version: - $(PIKE) -v + $(PIKE) -v | head -n 1 # ----------------------------------------------------------------- # Cleaning the Pike examples @@ -1192,7 +1192,7 @@ chicken_run: # ----------------------------------------------------------------- chicken_version: - $(CHICKEN) -version + $(CHICKEN) -version | grep -i version # ----------------------------------------------------------------- # Cleaning the CHICKEN examples @@ -1254,7 +1254,7 @@ csharp_run: # Version check below also works with MS csc.exe which does not understand --version csharp_version: - $(CSHARPCOMPILER) --version | grep -i version + $(CSHARPCOMPILER) --version | head -n 1 # ----------------------------------------------------------------- # Cleaning the CSharp examples @@ -1330,7 +1330,7 @@ lua_embed_run: # ----------------------------------------------------------------- lua_version: - $(LUA) -v + $(LUA) -v | head -n 1 # ----------------------------------------------------------------- # Cleaning the lua examples @@ -1406,7 +1406,7 @@ clisp_run: # ----------------------------------------------------------------- clisp_version: - $(CLISP) --version + $(CLISP) --version | head -n 1 # ----------------------------------------------------------------- # Cleaning the CLISP examples @@ -1545,7 +1545,7 @@ r_run: # ----------------------------------------------------------------- r_version: - $(R) --version | grep -i version + $(R) --version | head -n 1 # ----------------------------------------------------------------- # Cleaning the R examples From efb4f7bf07e493a038ea53049fabba3bd63df64a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 8 May 2013 17:30:45 +0100 Subject: [PATCH 161/273] Don't skip guile if GUILE_CFLAGS is empty as sometimes it is empty --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 07a768469..a618d55de 100644 --- a/configure.ac +++ b/configure.ac @@ -1206,7 +1206,7 @@ else if test -z "$GUILE_CFLAGS" ; then AC_MSG_CHECKING([for guile compile flags]) - GUILE_CFLAGS="`$GUILE_CONFIG compile`" + GUILE_CFLAGS="`$GUILE_CONFIG compile`" # Note that this can sometimes be empty AC_MSG_RESULT([$GUILE_CFLAGS]) fi @@ -2223,7 +2223,7 @@ AC_SUBST(SKIP_JAVA) SKIP_GUILE= -if test -z "$GUILE" || test -z "$GUILE_CFLAGS" || test -z "$GUILE_LIBS" || test -z "$GUILE_SCM_INTERFACE"; then +if test -z "$GUILE" || test -z "$GUILE_LIBS" || test -z "$GUILE_SCM_INTERFACE"; then SKIP_GUILE="1" fi AC_SUBST(SKIP_GUILE) From 7964ebe34fb12f0e61fea48ca501dee2ca0f7246 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 8 May 2013 17:36:03 +0100 Subject: [PATCH 162/273] Tidy up pike version display --- Examples/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 9ce0f1f81..a255db4c9 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1075,7 +1075,7 @@ pike_run: # ----------------------------------------------------------------- pike_version: - $(PIKE) -v | head -n 1 + $(PIKE) -v 2>&1 | head -n 1 # ----------------------------------------------------------------- # Cleaning the Pike examples From c28d0c6c80c5254eeedcd63e0942f154dcb60871 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Wed, 8 May 2013 22:43:49 +0200 Subject: [PATCH 163/273] Fixes to Octave examples - rename example modules from "example" to "swigexample", to avoid a warning from shadowing the Octave built-in function "example" - remove deprecated "static" Makefile targets: there is no longer an option to build static Octave modules in the Examples Makefile - emacs whitespace cleanup run on all files --- Examples/octave/callback/Makefile | 8 +-- Examples/octave/callback/example.cxx | 1 - Examples/octave/callback/example.h | 1 - Examples/octave/callback/example.i | 3 +- Examples/octave/callback/runme.m | 12 ++-- Examples/octave/class/Makefile | 8 +-- Examples/octave/class/example.h | 7 +-- Examples/octave/class/example.i | 3 +- Examples/octave/class/runme.m | 12 ++-- Examples/octave/constants/Makefile | 10 +--- Examples/octave/constants/example.i | 4 +- Examples/octave/constants/runme.m | 28 ++++------ Examples/octave/contract/Makefile | 6 +- Examples/octave/contract/example.c | 2 - Examples/octave/contract/example.i | 2 +- Examples/octave/contract/runme.m | 11 ++-- Examples/octave/enum/Makefile | 8 +-- Examples/octave/enum/example.h | 1 - Examples/octave/enum/example.i | 3 +- Examples/octave/enum/runme.m | 32 +++++------ Examples/octave/extend/Makefile | 8 +-- Examples/octave/extend/example.cxx | 1 - Examples/octave/extend/example.h | 3 +- Examples/octave/extend/example.i | 3 +- Examples/octave/extend/runme.m | 7 +-- Examples/octave/funcptr/Makefile | 6 +- Examples/octave/funcptr/example.h | 1 - Examples/octave/funcptr/example.i | 3 +- Examples/octave/funcptr/runme.m | 15 +++-- Examples/octave/funcptr2/Makefile | 6 +- Examples/octave/funcptr2/example.h | 1 - Examples/octave/funcptr2/example.i | 3 +- Examples/octave/funcptr2/runme.m | 18 +++--- Examples/octave/functor/Makefile | 10 +--- Examples/octave/functor/example.i | 6 +- Examples/octave/functor/runme.m | 8 +-- Examples/octave/module_load/Makefile | 6 +- Examples/octave/module_load/runme.m | 52 +++++++++--------- Examples/octave/operator/Makefile | 10 +--- Examples/octave/operator/example.h | 2 +- Examples/octave/operator/example.i | 2 +- Examples/octave/operator/runme.m | 8 +-- Examples/octave/pointer/Makefile | 6 +- Examples/octave/pointer/example.i | 6 +- Examples/octave/pointer/runme.m | 29 +++++----- Examples/octave/reference/Makefile | 8 +-- Examples/octave/reference/example.cxx | 1 - Examples/octave/reference/example.h | 4 -- Examples/octave/reference/example.i | 8 +-- Examples/octave/reference/runme.m | 15 +++-- Examples/octave/simple/Makefile | 6 +- Examples/octave/simple/example.c | 2 - Examples/octave/simple/example.i | 2 +- Examples/octave/simple/runme.m | 11 ++-- Examples/octave/template/Makefile | 10 +--- Examples/octave/template/example.h | 1 - Examples/octave/template/example.i | 3 +- Examples/octave/template/runme.m | 12 ++-- Examples/octave/variables/Makefile | 6 +- Examples/octave/variables/example.c | 2 +- Examples/octave/variables/example.h | 1 - Examples/octave/variables/example.i | 3 +- Examples/octave/variables/runme.m | 79 +++++++++++++-------------- 63 files changed, 211 insertions(+), 345 deletions(-) diff --git a/Examples/octave/callback/Makefile b/Examples/octave/callback/Makefile index ffc60e0c0..d38d7f896 100644 --- a/Examples/octave/callback/Makefile +++ b/Examples/octave/callback/Makefile @@ -1,10 +1,10 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx -TARGET = example +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run @@ -13,9 +13,5 @@ build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/callback/example.cxx b/Examples/octave/callback/example.cxx index 450d75608..893a956f4 100644 --- a/Examples/octave/callback/example.cxx +++ b/Examples/octave/callback/example.cxx @@ -1,4 +1,3 @@ /* File : example.cxx */ #include "example.h" - diff --git a/Examples/octave/callback/example.h b/Examples/octave/callback/example.h index 1a0e8c432..74ddad954 100644 --- a/Examples/octave/callback/example.h +++ b/Examples/octave/callback/example.h @@ -20,4 +20,3 @@ public: void setCallback(Callback *cb) { delCallback(); _callback = cb; } void call() { if (_callback) _callback->run(); } }; - diff --git a/Examples/octave/callback/example.i b/Examples/octave/callback/example.i index 90beda01a..3192904db 100644 --- a/Examples/octave/callback/example.i +++ b/Examples/octave/callback/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module(directors="1") example +%module(directors="1") swigexample %{ #include "example.h" %} @@ -10,4 +10,3 @@ %feature("director") Callback; %include "example.h" - diff --git a/Examples/octave/callback/runme.m b/Examples/octave/callback/runme.m index b87925e3d..103985358 100644 --- a/Examples/octave/callback/runme.m +++ b/Examples/octave/callback/runme.m @@ -2,14 +2,13 @@ # This file illustrates the cross language polymorphism using directors. -example +swigexample -OctCallback=@() subclass(example.Callback(), \ - 'run',@(self) printf("OctCallback.run()\n")); +OctCallback=@() subclass(swigexample.Callback(),"run",@(self) printf("OctCallback.run()\n")); # Create an Caller instance -caller = example.Caller(); +caller = swigexample.Caller(); # Add a simple C++ callback (caller owns the callback, so # we disown it first) @@ -17,7 +16,7 @@ caller = example.Caller(); printf("Adding and calling a normal C++ callback\n"); printf("----------------------------------------\n"); -callback = example.Callback().__disown(); +callback = swigexample.Callback().__disown(); caller.setCallback(callback); caller.call(); caller.delCallback(); @@ -43,7 +42,7 @@ caller.call(); caller.delCallback(); # careful-- using callback here may cause problems; octave_swig_type still -# exists, but is holding a destroyed object (the C++ example.Callback). +# exists, but is holding a destroyed object (the C++ swigexample.Callback). # to manually drop the octave-side reference, you can use clear callback; @@ -60,4 +59,3 @@ a.Callback.run(); # All done. printf("octave exit\n"); - diff --git a/Examples/octave/class/Makefile b/Examples/octave/class/Makefile index ffc60e0c0..d38d7f896 100644 --- a/Examples/octave/class/Makefile +++ b/Examples/octave/class/Makefile @@ -1,10 +1,10 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx -TARGET = example +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run @@ -13,9 +13,5 @@ build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/class/example.h b/Examples/octave/class/example.h index 46d901361..0d4527e92 100644 --- a/Examples/octave/class/example.h +++ b/Examples/octave/class/example.h @@ -8,7 +8,7 @@ public: virtual ~Shape() { nshapes--; }; - double x, y; + double x, y; void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; @@ -32,8 +32,3 @@ public: virtual double area(void); virtual double perimeter(void); }; - - - - - diff --git a/Examples/octave/class/example.i b/Examples/octave/class/example.i index 75700b305..b109bcb78 100644 --- a/Examples/octave/class/example.i +++ b/Examples/octave/class/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ #include "example.h" @@ -7,4 +7,3 @@ /* Let's just grab the original header file here */ %include "example.h" - diff --git a/Examples/octave/class/runme.m b/Examples/octave/class/runme.m index c833a701b..04221b4bb 100644 --- a/Examples/octave/class/runme.m +++ b/Examples/octave/class/runme.m @@ -3,17 +3,17 @@ # This file illustrates the proxy class C++ interface generated # by SWIG. -example +swigexample # ----- Object creation ----- printf("Creating some objects:\n"); -c = example.Circle(10) -s = example.Square(10) +c = swigexample.Circle(10) +s = swigexample.Square(10) # ----- Access a static member ----- -printf("\nA total of %i shapes were created\n", example.Shape.nshapes); +printf("\nA total of %i shapes were created\n", swigexample.Shape.nshapes); # ----- Member data access ----- @@ -46,7 +46,5 @@ printf("\nGuess I'll clean up now\n"); clear c clear s -printf("%i shapes remain\n", example.Shape.nshapes); +printf("%i shapes remain\n", swigexample.Shape.nshapes); printf("Goodbye\n"); - - diff --git a/Examples/octave/constants/Makefile b/Examples/octave/constants/Makefile index 60b0578c6..03501bd81 100644 --- a/Examples/octave/constants/Makefile +++ b/Examples/octave/constants/Makefile @@ -1,10 +1,10 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig -CXXSRCS = -TARGET = example +CXXSRCS = +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run @@ -13,9 +13,5 @@ build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/constants/example.i b/Examples/octave/constants/example.i index 4f7b1a4d7..405974b44 100644 --- a/Examples/octave/constants/example.i +++ b/Examples/octave/constants/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample /* A few preprocessor macros */ @@ -23,5 +23,3 @@ %constant int iconst = 37; %constant double fconst = 3.14; - - diff --git a/Examples/octave/constants/runme.m b/Examples/octave/constants/runme.m index 322858734..c6ed24535 100644 --- a/Examples/octave/constants/runme.m +++ b/Examples/octave/constants/runme.m @@ -1,29 +1,25 @@ # file: runme.m -example +swigexample -printf("ICONST = %i (should be 42)\n", example.ICONST); -printf("FCONST = %f (should be 2.1828)\n", example.FCONST); -printf("CCONST = %s (should be 'x')\n", example.CCONST); -printf("CCONST2 = %s (this should be on a new line)\n", example.CCONST2); -printf("SCONST = %s (should be 'Hello World')\n", example.SCONST); -printf("SCONST2 = %s (should be '\"Hello World\"')\n", example.SCONST2); -printf("EXPR = %f (should be 48.5484)\n", example.EXPR); -printf("iconst = %i (should be 37)\n", example.iconst); -printf("fconst = %f (should be 3.14)\n", example.fconst); +printf("ICONST = %i (should be 42)\n", swigexample.ICONST); +printf("FCONST = %f (should be 2.1828)\n", swigexample.FCONST); +printf("CCONST = %s (should be 'x')\n", swigexample.CCONST); +printf("CCONST2 = %s (this should be on a new line)\n", swigexample.CCONST2); +printf("SCONST = %s (should be 'Hello World')\n", swigexample.SCONST); +printf("SCONST2 = %s (should be '\"Hello World\"')\n", swigexample.SCONST2); +printf("EXPR = %f (should be 48.5484)\n", swigexample.EXPR); +printf("iconst = %i (should be 37)\n", swigexample.iconst); +printf("fconst = %f (should be 3.14)\n", swigexample.fconst); try - printf("EXTERN = %s (Arg! This shouldn't printf(anything)\n", example.EXTERN); + printf("EXTERN = %s (Arg! This shouldn't printf(anything)\n", swigexample.EXTERN); catch printf("EXTERN isn't defined (good)\n"); end_try_catch try - printf("FOO = %i (Arg! This shouldn't printf(anything)\n", example.FOO); + printf("FOO = %i (Arg! This shouldn't printf(anything)\n", swigexample.FOO); catch printf("FOO isn't defined (good)\n"); end_try_catch - - - - diff --git a/Examples/octave/contract/Makefile b/Examples/octave/contract/Makefile index 2c33cd3d8..73e3962ed 100644 --- a/Examples/octave/contract/Makefile +++ b/Examples/octave/contract/Makefile @@ -1,7 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i check: build @@ -11,9 +11,5 @@ build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/contract/example.c b/Examples/octave/contract/example.c index 1a644543f..fbdc054cd 100644 --- a/Examples/octave/contract/example.c +++ b/Examples/octave/contract/example.c @@ -19,5 +19,3 @@ int fact(int n) { if (n <= 0) return 1; return n*fact(n-1); } - - diff --git a/Examples/octave/contract/example.i b/Examples/octave/contract/example.i index 8fd1a80af..78c459efc 100644 --- a/Examples/octave/contract/example.i +++ b/Examples/octave/contract/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %contract gcd(int x, int y) { require: diff --git a/Examples/octave/contract/runme.m b/Examples/octave/contract/runme.m index 62b72320b..fa36bbe10 100644 --- a/Examples/octave/contract/runme.m +++ b/Examples/octave/contract/runme.m @@ -1,22 +1,21 @@ # file: runme.m -example +swigexample # Call our gcd() function x = 42; y = 105; -g = example.gcd(x,y); +g = swigexample.gcd(x,y); printf("The gcd of %d and %d is %d\n",x,y,g); # Manipulate the Foo global variable # Output its current value -printf("Foo = %f\n", example.cvar.Foo); +printf("Foo = %f\n", swigexample.cvar.Foo); # Change its value -example.cvar.Foo = 3.1415926; +swigexample.cvar.Foo = 3.1415926; # See if the change took effect -printf("Foo = %f\n", example.cvar.Foo); - +printf("Foo = %f\n", swigexample.cvar.Foo); diff --git a/Examples/octave/enum/Makefile b/Examples/octave/enum/Makefile index ffc60e0c0..d38d7f896 100644 --- a/Examples/octave/enum/Makefile +++ b/Examples/octave/enum/Makefile @@ -1,10 +1,10 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx -TARGET = example +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run @@ -13,9 +13,5 @@ build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/enum/example.h b/Examples/octave/enum/example.h index 525d62afc..490d502e8 100644 --- a/Examples/octave/enum/example.h +++ b/Examples/octave/enum/example.h @@ -10,4 +10,3 @@ class Foo { }; void enum_test(color c, Foo::speed s); - diff --git a/Examples/octave/enum/example.i b/Examples/octave/enum/example.i index 23ee8a822..cee9af471 100644 --- a/Examples/octave/enum/example.i +++ b/Examples/octave/enum/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ #include "example.h" @@ -8,4 +8,3 @@ /* Let's just grab the original header file here */ %include "example.h" - diff --git a/Examples/octave/enum/runme.m b/Examples/octave/enum/runme.m index a749e81db..0108135b2 100644 --- a/Examples/octave/enum/runme.m +++ b/Examples/octave/enum/runme.m @@ -1,32 +1,30 @@ # file: runme.m -example +swigexample # ----- Object creation ----- # Print out the value of some enums printf("*** color ***\n"); -printf(" RED = %i\n", example.RED); -printf(" BLUE = %i\n", example.BLUE); -printf(" GREEN = %i\n", example.GREEN); +printf(" RED = %i\n", swigexample.RED); +printf(" BLUE = %i\n", swigexample.BLUE); +printf(" GREEN = %i\n", swigexample.GREEN); printf("\n*** Foo::speed ***\n"); -printf(" Foo_IMPULSE = %i\n", example.Foo_IMPULSE); -printf(" Foo_WARP = %i\n", example.Foo_WARP); -printf(" Foo_LUDICROUS = %i\n", example.Foo_LUDICROUS); +printf(" Foo_IMPULSE = %i\n", swigexample.Foo_IMPULSE); +printf(" Foo_WARP = %i\n", swigexample.Foo_WARP); +printf(" Foo_LUDICROUS = %i\n", swigexample.Foo_LUDICROUS); printf("\nTesting use of enums with functions\n"); -example.enum_test(example.RED, example.Foo_IMPULSE); -example.enum_test(example.BLUE, example.Foo_WARP); -example.enum_test(example.GREEN, example.Foo_LUDICROUS); -example.enum_test(1234,5678) +swigexample.enum_test(swigexample.RED, swigexample.Foo_IMPULSE); +swigexample.enum_test(swigexample.BLUE, swigexample.Foo_WARP); +swigexample.enum_test(swigexample.GREEN, swigexample.Foo_LUDICROUS); +swigexample.enum_test(1234,5678) printf("\nTesting use of enum with class method\n"); -f = example.Foo(); - -f.enum_test(example.Foo_IMPULSE); -f.enum_test(example.Foo_WARP); -f.enum_test(example.Foo_LUDICROUS); - +f = swigexample.Foo(); +f.enum_test(swigexample.Foo_IMPULSE); +f.enum_test(swigexample.Foo_WARP); +f.enum_test(swigexample.Foo_LUDICROUS); diff --git a/Examples/octave/extend/Makefile b/Examples/octave/extend/Makefile index ffc60e0c0..d38d7f896 100644 --- a/Examples/octave/extend/Makefile +++ b/Examples/octave/extend/Makefile @@ -1,10 +1,10 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx -TARGET = example +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run @@ -13,9 +13,5 @@ build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/extend/example.cxx b/Examples/octave/extend/example.cxx index 450d75608..893a956f4 100644 --- a/Examples/octave/extend/example.cxx +++ b/Examples/octave/extend/example.cxx @@ -1,4 +1,3 @@ /* File : example.cxx */ #include "example.h" - diff --git a/Examples/octave/extend/example.h b/Examples/octave/extend/example.h index b27ab9711..9e15cf8e4 100644 --- a/Examples/octave/extend/example.h +++ b/Examples/octave/extend/example.h @@ -44,7 +44,7 @@ public: const Employee *get_item(int i) { return list[i]; } - ~EmployeeList() { + ~EmployeeList() { std::vector::iterator i; std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; for (i=list.begin(); i!=list.end(); i++) { @@ -53,4 +53,3 @@ public: std::cout << "~EmployeeList empty." << std::endl; } }; - diff --git a/Examples/octave/extend/example.i b/Examples/octave/extend/example.i index c8ec32e09..953c2f314 100644 --- a/Examples/octave/extend/example.i +++ b/Examples/octave/extend/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module(directors="1") example +%module(directors="1") swigexample %{ #include "example.h" %} @@ -12,4 +12,3 @@ %feature("director") Manager; %include "example.h" - diff --git a/Examples/octave/extend/runme.m b/Examples/octave/extend/runme.m index c64c082c4..4536f2761 100644 --- a/Examples/octave/extend/runme.m +++ b/Examples/octave/extend/runme.m @@ -2,12 +2,12 @@ # This file illustrates the cross language polymorphism using directors. -example +swigexample # CEO class, which overrides Employee::getPosition(). -CEO=@(name) subclass(example.Manager(name),'getPosition',@(self) "CEO"); +CEO=@(name) subclass(swigexample.Manager(name),'getPosition',@(self) "CEO"); # Create an instance of our employee extension class, CEO. The calls to # getName() and getPosition() are standard, the call to getTitle() uses @@ -22,7 +22,7 @@ printf("----------------------\n"); # Create a new EmployeeList instance. This class does not have a C++ # director wrapper, but can be used freely with other classes that do. -list = example.EmployeeList(); +list = swigexample.EmployeeList(); # EmployeeList owns its items, so we must surrender ownership of objects # we add. This involves first calling the __disown__ method to tell the @@ -71,4 +71,3 @@ printf("----------------------\n"); # All done. printf("octave exit\n"); - diff --git a/Examples/octave/funcptr/Makefile b/Examples/octave/funcptr/Makefile index 2c33cd3d8..73e3962ed 100644 --- a/Examples/octave/funcptr/Makefile +++ b/Examples/octave/funcptr/Makefile @@ -1,7 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i check: build @@ -11,9 +11,5 @@ build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/funcptr/example.h b/Examples/octave/funcptr/example.h index 9936e24fc..f95ae2cc9 100644 --- a/Examples/octave/funcptr/example.h +++ b/Examples/octave/funcptr/example.h @@ -6,4 +6,3 @@ extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); - diff --git a/Examples/octave/funcptr/example.i b/Examples/octave/funcptr/example.i index 8b3bef678..163a1991b 100644 --- a/Examples/octave/funcptr/example.i +++ b/Examples/octave/funcptr/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ #include "example.h" %} @@ -13,4 +13,3 @@ extern int do_op(int a, int b, int (*op)(int, int)); %constant int (*MUL)(int,int) = mul; extern int (*funcvar)(int,int); - diff --git a/Examples/octave/funcptr/runme.m b/Examples/octave/funcptr/runme.m index 455311c16..4e2e28fbc 100644 --- a/Examples/octave/funcptr/runme.m +++ b/Examples/octave/funcptr/runme.m @@ -1,6 +1,6 @@ # file: runme.m -example +swigexample a = 37 b = 42 @@ -10,12 +10,11 @@ b = 42 printf("Trying some C callback functions\n"); printf(" a = %i\n", a); printf(" b = %i\n", b); -printf(" ADD(a,b) = %i\n", example.do_op(a,b,example.ADD)); -printf(" SUB(a,b) = %i\n", example.do_op(a,b,example.SUB)); -printf(" MUL(a,b) = %i\n", example.do_op(a,b,example.MUL)); +printf(" ADD(a,b) = %i\n", swigexample.do_op(a,b,swigexample.ADD)); +printf(" SUB(a,b) = %i\n", swigexample.do_op(a,b,swigexample.SUB)); +printf(" MUL(a,b) = %i\n", swigexample.do_op(a,b,swigexample.MUL)); printf("Here is what the C callback function objects look like in Octave\n"); -example.ADD -example.SUB -example.MUL - +swigexample.ADD +swigexample.SUB +swigexample.MUL diff --git a/Examples/octave/funcptr2/Makefile b/Examples/octave/funcptr2/Makefile index 2c33cd3d8..73e3962ed 100644 --- a/Examples/octave/funcptr2/Makefile +++ b/Examples/octave/funcptr2/Makefile @@ -1,7 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i check: build @@ -11,9 +11,5 @@ build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/funcptr2/example.h b/Examples/octave/funcptr2/example.h index 9936e24fc..f95ae2cc9 100644 --- a/Examples/octave/funcptr2/example.h +++ b/Examples/octave/funcptr2/example.h @@ -6,4 +6,3 @@ extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); - diff --git a/Examples/octave/funcptr2/example.i b/Examples/octave/funcptr2/example.i index 681775a3e..33378a1c1 100644 --- a/Examples/octave/funcptr2/example.i +++ b/Examples/octave/funcptr2/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ #include "example.h" %} @@ -15,4 +15,3 @@ int mul(int, int); %nocallback; extern int (*funcvar)(int,int); - diff --git a/Examples/octave/funcptr2/runme.m b/Examples/octave/funcptr2/runme.m index 1d3d8f73a..574635ed2 100644 --- a/Examples/octave/funcptr2/runme.m +++ b/Examples/octave/funcptr2/runme.m @@ -1,6 +1,6 @@ # file: runme.m -example +swigexample a = 37 b = 42 @@ -10,15 +10,15 @@ b = 42 printf("Trying some C callback functions\n"); printf(" a = %i\n", a); printf(" b = %i\n", b); -printf(" ADD(a,b) = %i\n", example.do_op(a,b,example.ADD)); -printf(" SUB(a,b) = %i\n", example.do_op(a,b,example.SUB)); -printf(" MUL(a,b) = %i\n", example.do_op(a,b,example.MUL)); +printf(" ADD(a,b) = %i\n", swigexample.do_op(a,b,swigexample.ADD)); +printf(" SUB(a,b) = %i\n", swigexample.do_op(a,b,swigexample.SUB)); +printf(" MUL(a,b) = %i\n", swigexample.do_op(a,b,swigexample.MUL)); printf("Here is what the C callback function objects look like in Octave\n"); -example.ADD -example.SUB -example.MUL +swigexample.ADD +swigexample.SUB +swigexample.MUL printf("Call the functions directly...\n"); -printf(" add(a,b) = %i\n", example.add(a,b)); -printf(" sub(a,b) = %i\n", example.sub(a,b)); +printf(" add(a,b) = %i\n", swigexample.add(a,b)); +printf(" sub(a,b) = %i\n", swigexample.sub(a,b)); diff --git a/Examples/octave/functor/Makefile b/Examples/octave/functor/Makefile index 09c680b4e..94fb96337 100644 --- a/Examples/octave/functor/Makefile +++ b/Examples/octave/functor/Makefile @@ -1,10 +1,10 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig -CXXSRCS = -TARGET = example +CXXSRCS = +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run @@ -13,9 +13,5 @@ build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/functor/example.i b/Examples/octave/functor/example.i index 2fd38176f..ade20c56c 100644 --- a/Examples/octave/functor/example.i +++ b/Examples/octave/functor/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %inline %{ @@ -23,7 +23,3 @@ public: // Instantiate a few versions %template(intSum) Sum; %template(doubleSum) Sum; - - - - diff --git a/Examples/octave/functor/runme.m b/Examples/octave/functor/runme.m index 65dabcc91..8b41691c3 100644 --- a/Examples/octave/functor/runme.m +++ b/Examples/octave/functor/runme.m @@ -1,8 +1,8 @@ # Operator overloading example -example +swigexample -a = example.intSum(0); -b = example.doubleSum(100.0); +a = swigexample.intSum(0); +b = swigexample.doubleSum(100.0); # Use the objects. They should be callable just like a normal # python function. @@ -14,5 +14,3 @@ endfor a.result() b.result() - - diff --git a/Examples/octave/module_load/Makefile b/Examples/octave/module_load/Makefile index bead6f150..e388763bd 100644 --- a/Examples/octave/module_load/Makefile +++ b/Examples/octave/module_load/Makefile @@ -1,7 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i check: build @@ -13,10 +13,6 @@ build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)2' SWIGOPT='-module $$(TARGET) -globals .' INTERFACE='$(INTERFACE)' octave -static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean rm -f $(TARGET).m diff --git a/Examples/octave/module_load/runme.m b/Examples/octave/module_load/runme.m index 0fda218cd..bc311b5e6 100644 --- a/Examples/octave/module_load/runme.m +++ b/Examples/octave/module_load/runme.m @@ -2,60 +2,60 @@ # load module clear all; -example; +swigexample; assert(cvar.ivar == ifunc); -assert(exist("example","var")); +assert(exist("swigexample","var")); clear all -example; +swigexample; assert(cvar.ivar == ifunc); -assert(exist("example","var")); +assert(exist("swigexample","var")); clear all # load module in a function globally before base context clear all; function testme - example; + swigexample; assert(cvar.ivar == ifunc); - assert(exist("example","var")); + assert(exist("swigexample","var")); endfunction testme testme -example; +swigexample; assert(cvar.ivar == ifunc); -assert(exist("example","var")); +assert(exist("swigexample","var")); clear all function testme - example; + swigexample; assert(cvar.ivar == ifunc); - assert(exist("example","var")); + assert(exist("swigexample","var")); endfunction testme testme -example; +swigexample; assert(cvar.ivar == ifunc); -assert(exist("example","var")); +assert(exist("swigexample","var")); clear all # load module in a function globally after base context clear all; -example; +swigexample; assert(cvar.ivar == ifunc); -assert(exist("example","var")); +assert(exist("swigexample","var")); function testme - example; + swigexample; assert(cvar.ivar == ifunc); - assert(exist("example","var")); + assert(exist("swigexample","var")); endfunction testme testme clear all -example; +swigexample; assert(cvar.ivar == ifunc); -assert(exist("example","var")); +assert(exist("swigexample","var")); function testme - example; + swigexample; assert(cvar.ivar == ifunc); - assert(exist("example","var")); + assert(exist("swigexample","var")); endfunction testme testme @@ -69,13 +69,13 @@ endif # load module with no cvar clear all; -example2; -assert(example2.ivar == ifunc); -assert(exist("example2","var")); +swigexample2; +assert(swigexample2.ivar == ifunc); +assert(exist("swigexample2","var")); assert(!isglobal("cvar")) clear all -example2; -assert(example2.ivar == ifunc); -assert(exist("example2","var")); +swigexample2; +assert(swigexample2.ivar == ifunc); +assert(exist("swigexample2","var")); assert(!isglobal("cvar")) clear all diff --git a/Examples/octave/operator/Makefile b/Examples/octave/operator/Makefile index 09c680b4e..94fb96337 100644 --- a/Examples/octave/operator/Makefile +++ b/Examples/octave/operator/Makefile @@ -1,10 +1,10 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig -CXXSRCS = -TARGET = example +CXXSRCS = +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run @@ -13,9 +13,5 @@ build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/operator/example.h b/Examples/octave/operator/example.h index a9b69e009..d91adabe8 100644 --- a/Examples/octave/operator/example.h +++ b/Examples/octave/operator/example.h @@ -25,7 +25,7 @@ public: ComplexVal operator-() const { return ComplexVal(-rpart, -ipart); } - + double re() const { return rpart; } double im() const { return ipart; } }; diff --git a/Examples/octave/operator/example.i b/Examples/octave/operator/example.i index 7b903e69b..a2d97731d 100644 --- a/Examples/octave/operator/example.i +++ b/Examples/octave/operator/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample #pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ %{ #include "example.h" diff --git a/Examples/octave/operator/runme.m b/Examples/octave/operator/runme.m index 85fd99ad4..9ab614ffb 100644 --- a/Examples/octave/operator/runme.m +++ b/Examples/octave/operator/runme.m @@ -1,8 +1,8 @@ # Operator overloading example -example +swigexample -a = example.ComplexVal(2,3); -b = example.ComplexVal(-5,10); +a = swigexample.ComplexVal(2,3); +b = swigexample.ComplexVal(-5,10); printf("a = %s\n",disp(a)); printf("b = %s\n",disp(b)); @@ -12,7 +12,7 @@ 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); +e = swigexample.ComplexVal(a-c); printf("e = %s\n",disp(e)); # Big expression diff --git a/Examples/octave/pointer/Makefile b/Examples/octave/pointer/Makefile index 2c33cd3d8..73e3962ed 100644 --- a/Examples/octave/pointer/Makefile +++ b/Examples/octave/pointer/Makefile @@ -1,7 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i check: build @@ -11,9 +11,5 @@ build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/pointer/example.i b/Examples/octave/pointer/example.i index a8ac79499..545e3ada4 100644 --- a/Examples/octave/pointer/example.i +++ b/Examples/octave/pointer/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ extern void add(int *, int *, int *); @@ -24,7 +24,3 @@ extern void sub(int *INPUT, int *INPUT, int *OUTPUT); %apply int *OUTPUT { int *r }; extern int divide(int n, int d, int *r); - - - - diff --git a/Examples/octave/pointer/runme.m b/Examples/octave/pointer/runme.m index c36df7270..a76de67de 100644 --- a/Examples/octave/pointer/runme.m +++ b/Examples/octave/pointer/runme.m @@ -1,42 +1,39 @@ # file: runme.m -example; +swigexample; # First create some objects using the pointer library. printf("Testing the pointer library\n"); -a = example.new_intp(); -b = example.new_intp(); -c = example.new_intp(); -example.intp_assign(a,37); -example.intp_assign(b,42); +a = swigexample.new_intp(); +b = swigexample.new_intp(); +c = swigexample.new_intp(); +swigexample.intp_assign(a,37); +swigexample.intp_assign(b,42); a,b,c # Call the add() function with some pointers -example.add(a,b,c); +swigexample.add(a,b,c); # Now get the result -r = example.intp_value(c); +r = swigexample.intp_value(c); printf(" 37 + 42 = %i\n",r); # Clean up the pointers -example.delete_intp(a); -example.delete_intp(b); -example.delete_intp(c); +swigexample.delete_intp(a); +swigexample.delete_intp(b); +swigexample.delete_intp(c); # Now try the typemap library # This should be much easier. Now how it is no longer # necessary to manufacture pointers. printf("Trying the typemap library\n"); -r = example.sub(37,42); +r = swigexample.sub(37,42); printf(" 37 - 42 = %i\n",r); # Now try the version with multiple return values printf("Testing multiple return values\n"); -[q,r] = example.divide(42,37); +[q,r] = swigexample.divide(42,37); printf(" 42/37 = %d remainder %d\n",q,r); - - - diff --git a/Examples/octave/reference/Makefile b/Examples/octave/reference/Makefile index ffc60e0c0..d38d7f896 100644 --- a/Examples/octave/reference/Makefile +++ b/Examples/octave/reference/Makefile @@ -1,10 +1,10 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx -TARGET = example +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run @@ -13,9 +13,5 @@ build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/reference/example.cxx b/Examples/octave/reference/example.cxx index 8a513bf49..9b72ca6a2 100644 --- a/Examples/octave/reference/example.cxx +++ b/Examples/octave/reference/example.cxx @@ -43,4 +43,3 @@ Vector &VectorArray::operator[](int index) { int VectorArray::size() { return maxsize; } - diff --git a/Examples/octave/reference/example.h b/Examples/octave/reference/example.h index 4915adb1b..697afafe0 100644 --- a/Examples/octave/reference/example.h +++ b/Examples/octave/reference/example.h @@ -20,7 +20,3 @@ public: Vector &operator[](int); int size(); }; - - - - diff --git a/Examples/octave/reference/example.i b/Examples/octave/reference/example.i index 8c95b3213..da09800c0 100644 --- a/Examples/octave/reference/example.i +++ b/Examples/octave/reference/example.i @@ -2,7 +2,7 @@ /* This file has a few "typical" uses of C++ references. */ -%module example +%module swigexample %{ #include "example.h" @@ -31,7 +31,7 @@ public: VectorArray(int maxsize); ~VectorArray(); int size(); - + /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { @@ -42,7 +42,3 @@ public: } } }; - - - - diff --git a/Examples/octave/reference/runme.m b/Examples/octave/reference/runme.m index f59c8eb7d..630ee0cd2 100644 --- a/Examples/octave/reference/runme.m +++ b/Examples/octave/reference/runme.m @@ -2,13 +2,13 @@ # This file illustrates the manipulation of C++ references in Octave -example +swigexample # ----- Object creation ----- printf("Creating some objects:\n"); -a = example.Vector(3,4,5) -b = example.Vector(10,11,12) +a = swigexample.Vector(3,4,5) +b = swigexample.Vector(10,11,12) printf(" Created %s\n",a.cprint()); printf(" Created %s\n",b.cprint()); @@ -17,12 +17,12 @@ printf(" Created %s\n",b.cprint()); # This calls the wrapper we placed around # -# operator+(const Vector &a, const Vector &) +# operator+(const Vector &a, const Vector &) # # It returns a new allocated object. printf("Adding a+b\n"); -c = example.addv(a,b); +c = swigexample.addv(a,b); printf(" a+b = %s\n", c.cprint()); clear c @@ -31,7 +31,7 @@ clear c # Note: Using the high-level interface here printf("Creating an array of vectors\n"); -va = example.VectorArray(10) +va = swigexample.VectorArray(10) # ----- Set some values in the array ----- @@ -39,7 +39,7 @@ va = example.VectorArray(10) va.set(0,a); va.set(1,b); -va.set(2,example.addv(a,b)) +va.set(2,swigexample.addv(a,b)) # Get some values from the array @@ -60,4 +60,3 @@ printf("Cleaning up\n"); clear va clear a clear b - diff --git a/Examples/octave/simple/Makefile b/Examples/octave/simple/Makefile index 2c33cd3d8..73e3962ed 100644 --- a/Examples/octave/simple/Makefile +++ b/Examples/octave/simple/Makefile @@ -1,7 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i check: build @@ -11,9 +11,5 @@ build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/simple/example.c b/Examples/octave/simple/example.c index 1c2af789c..8df41189c 100644 --- a/Examples/octave/simple/example.c +++ b/Examples/octave/simple/example.c @@ -14,5 +14,3 @@ int gcd(int x, int y) { } return g; } - - diff --git a/Examples/octave/simple/example.i b/Examples/octave/simple/example.i index 24093b9bf..127bfcd84 100644 --- a/Examples/octave/simple/example.i +++ b/Examples/octave/simple/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %inline %{ extern int gcd(int x, int y); diff --git a/Examples/octave/simple/runme.m b/Examples/octave/simple/runme.m index 8dc5eaa58..6345df0cf 100644 --- a/Examples/octave/simple/runme.m +++ b/Examples/octave/simple/runme.m @@ -1,22 +1,21 @@ # file: runme.m -example +swigexample # Call our gcd() function x = 42 y = 105 -g = example.gcd(x,y) +g = swigexample.gcd(x,y) printf("The gcd of %d and %d is %d\n",x,y,g); # Manipulate the Foo global variable # Output its current value -example.cvar.Foo +swigexample.cvar.Foo # Change its value -example.cvar.Foo = 3.1415926 +swigexample.cvar.Foo = 3.1415926 # See if the change took effect -printf("Foo = %f\n", example.cvar.Foo); - +printf("Foo = %f\n", swigexample.cvar.Foo); diff --git a/Examples/octave/template/Makefile b/Examples/octave/template/Makefile index 527e3cec6..94fb96337 100644 --- a/Examples/octave/template/Makefile +++ b/Examples/octave/template/Makefile @@ -1,10 +1,10 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig -CXXSRCS = -TARGET = example +CXXSRCS = +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile octave_run @@ -13,9 +13,5 @@ build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/template/example.h b/Examples/octave/template/example.h index 7401df650..5eb65dabb 100644 --- a/Examples/octave/template/example.h +++ b/Examples/octave/template/example.h @@ -29,4 +29,3 @@ template class vector { } #endif }; - diff --git a/Examples/octave/template/example.i b/Examples/octave/template/example.i index 8f94c4da1..cfff18ded 100644 --- a/Examples/octave/template/example.i +++ b/Examples/octave/template/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ #include "example.h" @@ -14,4 +14,3 @@ %template(maxdouble) max; %template(vecint) vector; %template(vecdouble) vector; - diff --git a/Examples/octave/template/runme.m b/Examples/octave/template/runme.m index a9891d459..b0abbf22f 100644 --- a/Examples/octave/template/runme.m +++ b/Examples/octave/template/runme.m @@ -1,15 +1,15 @@ # file: runme.m -example +swigexample # Call some templated functions -example.maxint(3,7) -example.maxdouble(3.14,2.18) +swigexample.maxint(3,7) +swigexample.maxdouble(3.14,2.18) # Create some class -iv = example.vecint(100) -dv = example.vecdouble(1000) +iv = swigexample.vecint(100) +dv = swigexample.vecdouble(1000) for i=0:99, iv.setitem(i,2*i); @@ -33,5 +33,3 @@ sum clear iv clear dv - - diff --git a/Examples/octave/variables/Makefile b/Examples/octave/variables/Makefile index 2c33cd3d8..73e3962ed 100644 --- a/Examples/octave/variables/Makefile +++ b/Examples/octave/variables/Makefile @@ -1,7 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i check: build @@ -11,9 +11,5 @@ build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - clean: $(MAKE) -f $(TOP)/Makefile octave_clean diff --git a/Examples/octave/variables/example.c b/Examples/octave/variables/example.c index aa4ffe9b3..15dcc1b8e 100644 --- a/Examples/octave/variables/example.c +++ b/Examples/octave/variables/example.c @@ -11,7 +11,7 @@ #include #include "example.h" -int ivar = 0; +int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; diff --git a/Examples/octave/variables/example.h b/Examples/octave/variables/example.h index 0f7e89594..8d95fa1a4 100644 --- a/Examples/octave/variables/example.h +++ b/Examples/octave/variables/example.h @@ -3,4 +3,3 @@ typedef struct { int x,y; } Point; - diff --git a/Examples/octave/variables/example.i b/Examples/octave/variables/example.i index 639b6c704..3e11495ad 100644 --- a/Examples/octave/variables/example.i +++ b/Examples/octave/variables/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ #include "example.h" %} @@ -50,4 +50,3 @@ extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} - diff --git a/Examples/octave/variables/runme.m b/Examples/octave/variables/runme.m index db88b18b0..c6788398b 100644 --- a/Examples/octave/variables/runme.m +++ b/Examples/octave/variables/runme.m @@ -1,56 +1,56 @@ # file: runme.m -example +swigexample # Try to set the values of some global variables -example.cvar.ivar = 42; -example.cvar.svar = -31000; -example.cvar.lvar = 65537; -example.cvar.uivar = 123456; -example.cvar.usvar = 61000; -example.cvar.ulvar = 654321; -example.cvar.scvar = -13; -example.cvar.ucvar = 251; -example.cvar.cvar = "S"; -example.cvar.fvar = 3.14159; -example.cvar.dvar = 2.1828; -example.cvar.strvar = "Hello World"; -example.cvar.iptrvar= example.new_int(37); -example.cvar.ptptr = example.new_Point(37,42); -example.cvar.name = "Bill"; +swigexample.cvar.ivar = 42; +swigexample.cvar.svar = -31000; +swigexample.cvar.lvar = 65537; +swigexample.cvar.uivar = 123456; +swigexample.cvar.usvar = 61000; +swigexample.cvar.ulvar = 654321; +swigexample.cvar.scvar = -13; +swigexample.cvar.ucvar = 251; +swigexample.cvar.cvar = "S"; +swigexample.cvar.fvar = 3.14159; +swigexample.cvar.dvar = 2.1828; +swigexample.cvar.strvar = "Hello World"; +swigexample.cvar.iptrvar= swigexample.new_int(37); +swigexample.cvar.ptptr = swigexample.new_Point(37,42); +swigexample.cvar.name = "Bill"; # Now print out the values of the variables printf("Variables (values printed from Octave)\n"); -printf("ivar = %i\n", example.cvar.ivar); -printf("svar = %i\n", example.cvar.svar); -printf("lvar = %i\n", example.cvar.lvar); -printf("uivar = %i\n", example.cvar.uivar); -printf("usvar = %i\n", example.cvar.usvar); -printf("ulvar = %i\n", example.cvar.ulvar); -printf("scvar = %i\n", example.cvar.scvar); -printf("ucvar = %i\n", example.cvar.ucvar); -printf("fvar = %i\n", example.cvar.fvar); -printf("dvar = %i\n", example.cvar.dvar); -printf("cvar = %s\n", example.cvar.cvar); -printf("strvar = %s\n", example.cvar.strvar); -#printf("cstrvar = %s\n", example.cvar.cstrvar); -example.cvar.iptrvar -printf("name = %i\n", example.cvar.name); -printf("ptptr = %s\n", example.Point_print(example.cvar.ptptr)); -#printf("pt = %s\n", example.cvar.Point_print(example.cvar.pt)); +printf("ivar = %i\n", swigexample.cvar.ivar); +printf("svar = %i\n", swigexample.cvar.svar); +printf("lvar = %i\n", swigexample.cvar.lvar); +printf("uivar = %i\n", swigexample.cvar.uivar); +printf("usvar = %i\n", swigexample.cvar.usvar); +printf("ulvar = %i\n", swigexample.cvar.ulvar); +printf("scvar = %i\n", swigexample.cvar.scvar); +printf("ucvar = %i\n", swigexample.cvar.ucvar); +printf("fvar = %i\n", swigexample.cvar.fvar); +printf("dvar = %i\n", swigexample.cvar.dvar); +printf("cvar = %s\n", swigexample.cvar.cvar); +printf("strvar = %s\n", swigexample.cvar.strvar); +#printf("cstrvar = %s\n", swigexample.cvar.cstrvar); +swigexample.cvar.iptrvar +printf("name = %i\n", swigexample.cvar.name); +printf("ptptr = %s\n", swigexample.Point_print(swigexample.cvar.ptptr)); +#printf("pt = %s\n", swigexample.cvar.Point_print(swigexample.cvar.pt)); printf("\nVariables (values printed from C)\n"); -example.print_vars(); +swigexample.print_vars(); printf("\nNow I'm going to try and modify some read only variables\n"); printf(" Tring to set 'path'\n"); try - example.cvar.path = "Whoa!"; + swigexample.cvar.path = "Whoa!"; printf("Hey, what's going on?!?! This shouldn't work\n"); catch printf("Good.\n"); @@ -58,7 +58,7 @@ end_try_catch printf(" Trying to set 'status'\n"); try - example.cvar.status = 0; + swigexample.cvar.status = 0; printf("Hey, what's going on?!?! This shouldn't work\n"); catch printf("Good.\n"); @@ -67,9 +67,6 @@ end_try_catch printf("\nI'm going to try and update a structure variable.\n"); -example.cvar.pt = example.cvar.ptptr; - -printf("The new value is %s\n", example.Point_print(example.cvar.pt)); - - +swigexample.cvar.pt = swigexample.cvar.ptptr; +printf("The new value is %s\n", swigexample.Point_print(swigexample.cvar.pt)); From 95e2142347fa2c69e2ddbe329584ce4a5eb09d51 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 9 May 2013 18:32:27 +0100 Subject: [PATCH 164/273] Update Octave manual to use "swigexample" instead of "example" Closes #46 --- Doc/Manual/Octave.html | 100 ++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index 0340c2fd5..84c0a0f46 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -74,7 +74,7 @@ Let's start with a very simple SWIG interface file, example.i:

    -%module example
    +%module swigexample
     %{
     #include "example.h"
     %}
    @@ -143,10 +143,10 @@ $ mkoctfile example_wrap.cpp example.c
     

    - mkoctfile will produce "example.oct", which contains the compiled extension module. Loading it into Octave is then a matter of invoking + mkoctfile will produce "swigexample.oct", which contains the compiled extension module. Loading it into Octave is then a matter of invoking

    -
    octave:1> example
    +
    octave:1> swigexample

    30.2.3 Using your module

    @@ -157,13 +157,13 @@ Assuming all goes well, you will be able to do this:

    $ octave -q
    -octave:1> example
    -octave:2> example.gcd(4,6)
    +octave:1> swigexample
    +octave:2> swigexample.gcd(4,6)
     ans =  2
    -octave:3> example.cvar.Foo
    +octave:3> swigexample.cvar.Foo
     ans =  3
    -octave:4> example.cvar.Foo=4;
    -octave:5> example.cvar.Foo
    +octave:4> swigexample.cvar.Foo=4;
    +octave:5> swigexample.cvar.Foo
     ans =  4 

    30.3 A tour of basic C/C++ wrapping

    @@ -173,11 +173,11 @@ ans = 4

    -The SWIG module directive specifies the name of the Octave module. If you specify "module example", then in Octave everything in the module will be accessible under "example", as in the above example. When choosing a module name, make sure you don't use the same name as a built-in Octave command or standard module name. +The SWIG module directive specifies the name of the Octave module. If you specify "module swigexample", then in Octave everything in the module will be accessible under "swigexample", as in the above example. When choosing a module name, make sure you don't use the same name as a built-in Octave command or standard module name.

    -When Octave is asked to invoke example, it will try to find the ".m" or ".oct" file that defines the function "example". You therefore need to make sure that "example.oct" is in Octave's search path, which can be specified with the environment variable "OCTAVE_PATH". +When Octave is asked to invoke swigexample, it will try to find the ".m" or ".oct" file that defines the function "swigexample". You therefore need to make sure that "swigexample.oct" is in Octave's search path, which can be specified with the environment variable "OCTAVE_PATH".

    @@ -185,7 +185,7 @@ To load an Octave module, simply type its name:

    -octave:1> example;
    +octave:1> swigexample;
     octave:2> gcd(4,6)
     ans =  2
     octave:3> cvar.Foo
    @@ -202,15 +202,15 @@ If the module is also used in the base context, however, it must first be loaded
     
     
     octave:1> function l = my_lcm(a,b)
    -> example
    -> l = abs(a*b)/example.gcd(a,b);
    +> swigexample
    +> l = abs(a*b)/swigexample.gcd(a,b);
     > endfunction
     octave:2> my_lcm(4,6)
     ans =  12
    -octave:3> example.gcd(4,6)
    +octave:3> swigexample.gcd(4,6)
     error: can't perform indexing operations for <unknown type> type
    -octave:3> example;
    -octave:4> example.gcd(4,6)
    +octave:3> swigexample;
    +octave:4> swigexample.gcd(4,6)
     ans =  2
     
    @@ -221,14 +221,14 @@ ans = 2 Global functions are wrapped as new Octave built-in functions. For example,

    -
    %module example
    +      
    %module swigexample
     int fact(int n); 

    - creates a built-in function example.fact(n) that works exactly like you think it does: + creates a built-in function swigexample.fact(n) that works exactly like you think it does:

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

    30.3.3 Global variables

    @@ -238,7 +238,7 @@ int fact(int n);
    Global variables are a little special in Octave. Given a global variable:

    -
    %module example
    +
    %module swigexample
     extern double Foo;
     
    @@ -246,20 +246,20 @@ extern double Foo; To expose variables, SWIG actually generates two functions, to get and set the value. In this case, Foo_set and Foo_set would be generated. SWIG then automatically calls these functions when you get and set the variable-- in the former case creating a local copy in the interpreter of the C variables, and in the latter case copying an interpreter variables onto the C variable.

    -
    octave:1> example;
    -octave:2> c=example.cvar.Foo
    +    
    octave:1> swigexample;
    +octave:2> c=swigexample.cvar.Foo
     c =  3
    -octave:3> example.cvar.Foo=4;
    +octave:3> swigexample.cvar.Foo=4;
     octave:4> c
     c =  3
    -octave:5> example.cvar.Foo
    +octave:5> swigexample.cvar.Foo
     ans =  4

    If a variable is marked with the %immutable directive then any attempts to set this variable will cause an Octave error. Given a global variable:

    -
    %module example
    +    
    %module swigexample
     %immutable;
     extern double Foo;
     %mutable;
    @@ -269,8 +269,8 @@ extern double Foo;
          SWIG will allow the reading of Foo but when a set attempt is made, an error function will be called. 
     

    -
    octave:1> example
    -octave:2> example.Foo=4
    +    
    octave:1> swigexample
    +octave:2> swigexample.Foo=4
     error: attempt to set immutable member variable
     error: assignment failed, or no method for `swig_type = scalar'
     error: evaluating assignment expression near line 2, column 12 
    @@ -279,9 +279,9 @@ error: evaluating assignment expression near line 2, column 12
    It is possible to add new functions or variables to the module. This also allows the user to rename/remove existing functions and constants (but not linked variables, mutable or immutable). Therefore users are recommended to be careful when doing so.

    -
    octave:1> example;
    -octave:2> example.PI=3.142;
    -octave:3> example.PI
    +    
    octave:1> swigexample;
    +octave:2> swigexample.PI=3.142;
    +octave:3> swigexample.PI
     ans =  3.1420 

    30.3.4 Constants and enums

    @@ -291,7 +291,7 @@ ans = 3.1420
    Because Octave doesn't really have the concept of constants, C/C++ constants are not really constant in Octave. They are actually just a copy of the value into the Octave interpreter. Therefore they can be changed just as any other value. For example given some constants:

    -
    %module example
    +    
    %module swigexample
     %constant int ICONST=42;
     #define    SCONST      "Hello World"
     enum Days{SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY};
    @@ -301,9 +301,9 @@ enum Days{SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY};
         This is 'effectively' converted into the following Octave code: 
     

    -
    example.ICONST=42
    -example.SCONST="Hello World"
    -example.SUNDAY=0
    +    
    swigexample.ICONST=42
    +swigexample.SCONST="Hello World"
    +swigexample.SUNDAY=0
     .... 

    30.3.5 Pointers

    @@ -314,7 +314,7 @@ example.SUNDAY=0 C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Given a wrapping of the <file.h> interface:

    -
    %module example
    +
    %module swigexample
     FILE *fopen(const char *filename, const char *mode);
     int fputs(const char *, FILE *);
     int fclose(FILE *);
    @@ -325,18 +325,18 @@ When wrapped, you will be able to use the functions in a natural way from Octave
     

    -octave:1> example;
    -octave:2> f=example.fopen("w","junk");
    -octave:3> example.fputs("Hello world",f);
    -octave:4> example.fclose(f);
    +octave:1> swigexample;
    +octave:2> f=swigexample.fopen("w","junk");
    +octave:3> swigexample.fputs("Hello world",f);
    +octave:4> swigexample.fclose(f);
     

    Simply printing the value of a wrapped C++ type will print it's typename. E.g.,

    -
    octave:1> example;
    -octave:2> f=example.fopen("junk","w");
    +    
    octave:1> swigexample;
    +octave:2> f=swigexample.fopen("junk","w");
     octave:3> f
     f =
     
    @@ -348,8 +348,8 @@ f =
         As the user of the pointer, you are responsible for freeing it, or closing any resources associated with it (just as you would in a C program). This does not apply so strictly to classes and structs (see below).
     

    -
    octave:1> example;
    -octave:2> f=example.fopen("not there","r");
    +    
    octave:1> swigexample;
    +octave:2> f=swigexample.fopen("not there","r");
     error: value on right hand side of assignment is undefined
     error: evaluating assignment expression near line 2, column 2 
    @@ -371,8 +371,8 @@ For each wrapped structure and class, a swig_ref will be exposed that h

    -
    octave:1> example;
    -octave:2> p=example.Point();
    +      
    octave:1> swigexample;
    +octave:2> p=swigexample.Point();
     octave:3> p.x=3;
     octave:4> p.y=5;
     octave:5> p.x, p.y
    @@ -406,9 +406,9 @@ public:
     can be used from Octave like this
     

    -
    octave:1> example;
    -octave:2> p1=example.Point(3,5);
    -octave:3> p2=example.Point(1,2);
    +      
    octave:1> swigexample;
    +octave:2> p1=swigexample.Point(3,5);
    +octave:3> p2=swigexample.Point(1,2);
     octave:4> p1.distance(p2)
     ans =  3.6056
     
    @@ -649,7 +649,7 @@ C++ class and function templates are fully supported as in other modules, in tha For example, function templates can be instantiated as follows:

    -
    %module example
    +
    %module swigexample
     %inline {
      template<class __scalar>
        __scalar mul(__scalar a,__scalar b) {
    @@ -677,7 +677,7 @@ ans =  22 + 46i
     Similarly, class templates can be instantiated as in the following example,
     

    -
    %module example
    +
    %module swigexample
     %include <std_complex.i>
     %include <std_string.i>
     %inline {
    
    From d974e9aced1d371e156deca25fcc22f65d15a3f8 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Thu, 9 May 2013 08:21:02 +0100
    Subject: [PATCH 165/273] Guile examples consistency changes
    
    Use new guile_embedded_run target or guile_run target for running the
    examples like the other target languages (for suppressing stdout if run
    from top level).
    
    Consistency with other target language file renames: use runme.scm for
    scripts and example.i, example.c for example code.
    
    Add class example to examples being tested.
    ---
     Examples/Makefile.in                          |  3 +++
     Examples/guile/check.list                     |  1 +
     Examples/guile/class/Makefile                 |  2 ++
     Examples/guile/constants/Makefile             |  3 ++-
     .../constants/{constants.scm => runme.scm}    |  0
     Examples/guile/matrix/Makefile                |  5 ++--
     Examples/guile/matrix/README                  |  6 ++---
     .../guile/matrix/{package.i => example.i}     |  5 +---
     Examples/guile/matrix/main.c                  | 24 -------------------
     .../guile/matrix/{matrix.scm => runme.scm}    |  1 -
     Examples/guile/multimap/Makefile              |  2 +-
     Examples/guile/multivalue/Makefile            |  2 +-
     Examples/guile/port/Makefile                  |  7 +++---
     Examples/guile/port/README                    |  2 +-
     Examples/guile/port/{port.c => example.c}     |  0
     Examples/guile/port/{port.i => example.i}     |  0
     Examples/guile/port/{port.scm => runme.scm}   |  0
     Examples/guile/simple/Makefile                |  3 ++-
     Examples/guile/simple/README                  |  4 ++--
     .../guile/simple/{example.scm => runme.scm}   |  2 --
     Examples/guile/std_vector/Makefile            |  2 +-
     21 files changed, 27 insertions(+), 47 deletions(-)
     rename Examples/guile/constants/{constants.scm => runme.scm} (100%)
     rename Examples/guile/matrix/{package.i => example.i} (72%)
     delete mode 100644 Examples/guile/matrix/main.c
     rename Examples/guile/matrix/{matrix.scm => runme.scm} (99%)
     mode change 100644 => 100755
     rename Examples/guile/port/{port.c => example.c} (100%)
     rename Examples/guile/port/{port.i => example.i} (100%)
     rename Examples/guile/port/{port.scm => runme.scm} (100%)
     rename Examples/guile/simple/{example.scm => runme.scm} (93%)
    
    diff --git a/Examples/Makefile.in b/Examples/Makefile.in
    index a255db4c9..20f1cfea6 100644
    --- a/Examples/Makefile.in
    +++ b/Examples/Makefile.in
    @@ -515,6 +515,9 @@ guile_simple_cpp: $(SRCS)
     guile_run:
     	$(RUNTOOL) $(GUILE) -l $(GUILE_SCRIPT) $(RUNPIPE)
     
    +guile_embedded_run:
    +	$(RUNTOOL) ./$(TARGET) $(GUILE_RUNOPTIONS) -s $(GUILE_SCRIPT) $(RUNPIPE)
    +
     # -----------------------------------------------------------------
     # Version display
     # -----------------------------------------------------------------
    diff --git a/Examples/guile/check.list b/Examples/guile/check.list
    index 08524a8f7..726e6ab75 100644
    --- a/Examples/guile/check.list
    +++ b/Examples/guile/check.list
    @@ -1,5 +1,6 @@
     # see top-level Makefile.in
     constants
    +class
     port
     simple
     std_vector
    diff --git a/Examples/guile/class/Makefile b/Examples/guile/class/Makefile
    index 827b2fe03..189610800 100644
    --- a/Examples/guile/class/Makefile
    +++ b/Examples/guile/class/Makefile
    @@ -3,8 +3,10 @@ SWIG       = $(TOP)/../preinst-swig
     CXXSRCS    = example.cxx
     TARGET     = example
     INTERFACE  = example.i
    +TOP        = ../..
     
     check: build
    +#	$(MAKE) -f $(TOP)/Makefile guile_run
     
     build:
     	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
    diff --git a/Examples/guile/constants/Makefile b/Examples/guile/constants/Makefile
    index 946323b89..5e60d9b34 100644
    --- a/Examples/guile/constants/Makefile
    +++ b/Examples/guile/constants/Makefile
    @@ -2,9 +2,10 @@ SRCS   =
     TARGET = my-guile
     IFILE  = example.i
     MKDIR  = ..
    +TOP        = ../..
     
     check: build
    -	./my-guile -s constants.scm
    +	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_embedded_run
     
     build:
     	$(MAKE) -f $(MKDIR)/Makefile		\
    diff --git a/Examples/guile/constants/constants.scm b/Examples/guile/constants/runme.scm
    similarity index 100%
    rename from Examples/guile/constants/constants.scm
    rename to Examples/guile/constants/runme.scm
    diff --git a/Examples/guile/matrix/Makefile b/Examples/guile/matrix/Makefile
    index 988a0ee5c..3d488f6f6 100644
    --- a/Examples/guile/matrix/Makefile
    +++ b/Examples/guile/matrix/Makefile
    @@ -1,10 +1,11 @@
     SRCS   = matrix.c vector.c
     TARGET = matrix
    -IFILE  = package.i
    +IFILE  = example.i
     MKDIR  = ..
    +TOP        = ../..
     
     check: build
    -	./$(TARGET) -e do-test -s matrix.scm
    +	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' GUILE_RUNOPTIONS='-e do-test' guile_embedded_run
     
     build:
     	$(MAKE) -f $(MKDIR)/Makefile		\
    diff --git a/Examples/guile/matrix/README b/Examples/guile/matrix/README
    index dc1957719..db7395b70 100644
    --- a/Examples/guile/matrix/README
    +++ b/Examples/guile/matrix/README
    @@ -1,13 +1,13 @@
     Matrix example.  To run the example, execute the program 'matrix' and
     type the following :
     
    -	(load "matrix.scm")
    +	(load "runme.scm")
     	(do-test 0)
     
     Alternatively, use the command-line:
     
    -	./matrix -e do-test -s matrix.scm
    +	./matrix -e do-test -s runme.scm
     
     Or, if your operating system is spiffy enough:
     
    -	./matrix.scm
    +	./runme.scm
    diff --git a/Examples/guile/matrix/package.i b/Examples/guile/matrix/example.i
    similarity index 72%
    rename from Examples/guile/matrix/package.i
    rename to Examples/guile/matrix/example.i
    index aaa55511c..3f801dcdf 100644
    --- a/Examples/guile/matrix/package.i
    +++ b/Examples/guile/matrix/example.i
    @@ -1,7 +1,4 @@
    -// FILE : package.i
    -// See the SWIG users manual
    -
    -/*** Matrix and vector package ***/
    +/*** Matrix and vector example ***/
     
     %module Matrix
     %{
    diff --git a/Examples/guile/matrix/main.c b/Examples/guile/matrix/main.c
    deleted file mode 100644
    index 88209aea7..000000000
    --- a/Examples/guile/matrix/main.c
    +++ /dev/null
    @@ -1,24 +0,0 @@
    -#include 
    -extern int matrix_init(Tcl_Interp *);    /* Init function from matrix.i */
    -
    -int main() {
    -
    -  int        code;
    -  char       input[1024];
    -  Tcl_Interp *interp;
    -  
    -  interp = Tcl_CreateInterp();
    -
    -  /* Initialize the wrappers */
    -
    -  if (matrix_init(interp) == TCL_ERROR)
    -    exit(0);
    -  
    -  fprintf(stdout,"matrix > ");
    -  while(fgets(input, 1024, stdin) != NULL) {
    -    code = Tcl_Eval(interp, input);
    -    fprintf(stdout,"%s\n",interp->result);
    -    fprintf(stdout,"matrix > ");
    -  }
    -}
    -
    diff --git a/Examples/guile/matrix/matrix.scm b/Examples/guile/matrix/runme.scm
    old mode 100644
    new mode 100755
    similarity index 99%
    rename from Examples/guile/matrix/matrix.scm
    rename to Examples/guile/matrix/runme.scm
    index d7cab84f4..f11061e56
    --- a/Examples/guile/matrix/matrix.scm
    +++ b/Examples/guile/matrix/runme.scm
    @@ -211,4 +211,3 @@
     
       (cleanup M-list))
     
    -;;; matrix.scm ends here
    diff --git a/Examples/guile/multimap/Makefile b/Examples/guile/multimap/Makefile
    index 7b2f264ba..4ca82a3d3 100644
    --- a/Examples/guile/multimap/Makefile
    +++ b/Examples/guile/multimap/Makefile
    @@ -5,7 +5,7 @@ TARGET     = example
     INTERFACE  = example.i
     
     check: build
    -	$(MAKE) -f ../Makefile RUNSCRIPT=runme.scm run_example
    +	$(MAKE) -f $(TOP)/Makefile guile_run
     
     build:
     	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
    diff --git a/Examples/guile/multivalue/Makefile b/Examples/guile/multivalue/Makefile
    index 7b2f264ba..4ca82a3d3 100644
    --- a/Examples/guile/multivalue/Makefile
    +++ b/Examples/guile/multivalue/Makefile
    @@ -5,7 +5,7 @@ TARGET     = example
     INTERFACE  = example.i
     
     check: build
    -	$(MAKE) -f ../Makefile RUNSCRIPT=runme.scm run_example
    +	$(MAKE) -f $(TOP)/Makefile guile_run
     
     build:
     	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
    diff --git a/Examples/guile/port/Makefile b/Examples/guile/port/Makefile
    index 33eeab2e9..0088dd92f 100644
    --- a/Examples/guile/port/Makefile
    +++ b/Examples/guile/port/Makefile
    @@ -1,10 +1,10 @@
    -SRCS   = port.c
    +SRCS   = example.c
     TARGET = port
    -IFILE  = port.i
    +IFILE  = example.i
     MKDIR  = ..
     
     check: build
    -	./$(TARGET) -s port.scm
    +	./$(TARGET) -s runme.scm
     
     build:
     	$(MAKE) -f $(MKDIR)/Makefile		\
    @@ -16,3 +16,4 @@ build:
     
     clean:
     	$(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean
    +	rm -f test.out
    diff --git a/Examples/guile/port/README b/Examples/guile/port/README
    index 5ed0199e2..784e39e5d 100644
    --- a/Examples/guile/port/README
    +++ b/Examples/guile/port/README
    @@ -1,2 +1,2 @@
     This example illustrates the translation from Scheme file ports to
    -temporary FILE streams. Read the source and run ./port -s port.scm
    +temporary FILE streams. Read the source and run ./port -s runme.scm
    diff --git a/Examples/guile/port/port.c b/Examples/guile/port/example.c
    similarity index 100%
    rename from Examples/guile/port/port.c
    rename to Examples/guile/port/example.c
    diff --git a/Examples/guile/port/port.i b/Examples/guile/port/example.i
    similarity index 100%
    rename from Examples/guile/port/port.i
    rename to Examples/guile/port/example.i
    diff --git a/Examples/guile/port/port.scm b/Examples/guile/port/runme.scm
    similarity index 100%
    rename from Examples/guile/port/port.scm
    rename to Examples/guile/port/runme.scm
    diff --git a/Examples/guile/simple/Makefile b/Examples/guile/simple/Makefile
    index d4021073e..66c7e26af 100644
    --- a/Examples/guile/simple/Makefile
    +++ b/Examples/guile/simple/Makefile
    @@ -2,9 +2,10 @@ SRCS   = example.c
     TARGET = my-guile
     IFILE  = example.i
     MKDIR  = ..
    +TOP        = ../..
     
     check: $(TARGET)
    -	./$(TARGET) -s example.scm
    +	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_embedded_run
     
     build: $(TARGET)
     
    diff --git a/Examples/guile/simple/README b/Examples/guile/simple/README
    index 982216eaa..27b54dc5b 100644
    --- a/Examples/guile/simple/README
    +++ b/Examples/guile/simple/README
    @@ -2,8 +2,8 @@ A very simple example.
     
     To run it, start the program 'my-guile' and type:
     
    -	(load "example.scm")
    +	(load "runme.scm")
     
     Alternatively, you can use the shell command:
     
    -	./my-guile -s example.scm
    +	./my-guile -s runme.scm
    diff --git a/Examples/guile/simple/example.scm b/Examples/guile/simple/runme.scm
    similarity index 93%
    rename from Examples/guile/simple/example.scm
    rename to Examples/guile/simple/runme.scm
    index 9408b1aa6..c3fd0b41f 100644
    --- a/Examples/guile/simple/example.scm
    +++ b/Examples/guile/simple/runme.scm
    @@ -1,4 +1,3 @@
    -;;; example.scm
     
     (define (mdisplay-newline . args)       ; does guile-1.3.4 have `format #t'?
       (for-each display args)
    @@ -25,4 +24,3 @@
     (exit (and (= 1932053504 (fact 13))
                (= 745470.0 (My-variable))))
     
    -;;; example.scm ends here
    diff --git a/Examples/guile/std_vector/Makefile b/Examples/guile/std_vector/Makefile
    index 6eca67519..fd7a8439a 100644
    --- a/Examples/guile/std_vector/Makefile
    +++ b/Examples/guile/std_vector/Makefile
    @@ -5,7 +5,7 @@ TARGET     = example
     INTERFACE  = example.i
     
     check: build
    -	$(MAKE) -f ../Makefile RUNSCRIPT=runme.scm run_example
    +	$(MAKE) -f $(TOP)/Makefile guile_run
     
     build:
     	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
    
    From dd36f28ac7b28ecb78736894796bdcab9d945e07 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Thu, 9 May 2013 19:28:09 +0100
    Subject: [PATCH 166/273] Migrate Guile examples build into common Examples
     makefile
    
    - Now Guile examples are built in a consistent way to other target
    languages.
    - Also set GUILE_AUTO_COMPILE=0 to remove auto-compilation is enabled
      warnings
    ---
     Examples/Makefile.in              | 15 +++++++---
     Examples/guile/Makefile.in        | 47 -------------------------------
     Examples/guile/README             |  1 +
     Examples/guile/constants/Makefile | 19 ++++++-------
     Examples/guile/matrix/Makefile    | 21 ++++++--------
     Examples/guile/port/Makefile      | 19 ++++++-------
     Examples/guile/simple/Makefile    | 25 +++++++---------
     configure.ac                      |  1 -
     8 files changed, 46 insertions(+), 102 deletions(-)
     delete mode 100644 Examples/guile/Makefile.in
    
    diff --git a/Examples/Makefile.in b/Examples/Makefile.in
    index 20f1cfea6..5d521f5a1 100644
    --- a/Examples/Makefile.in
    +++ b/Examples/Makefile.in
    @@ -111,7 +111,6 @@ OBJS      = $(SRCS:.c=.@OBJEXT@) $(CXXSRCS:.cxx=.@OBJEXT@)
     
     distclean:
     	rm -f Makefile
    -	rm -f guile/Makefile
     	rm -f xml/Makefile
     
     ##################################################################
    @@ -482,6 +481,14 @@ $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCS)
     guile_externalhdr:
     	$(SWIG) -guile -external-runtime $(TARGET)
     
    +# -----------------------------------------------------------------
    +# Build Guile interpreter augmented with extra functions
    +# -----------------------------------------------------------------
    +
    +guile_augmented:
    +	$(SWIG) -guile $(SWIGOPT) $(INTERFACE)
    +	$(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) -o $(TARGET)
    +
     # -----------------------------------------------------------------
     # Build statically linked Guile interpreter
     # -----------------------------------------------------------------
    @@ -513,10 +520,10 @@ guile_simple_cpp: $(SRCS)
     # -----------------------------------------------------------------
     
     guile_run:
    -	$(RUNTOOL) $(GUILE) -l $(GUILE_SCRIPT) $(RUNPIPE)
    +	env GUILE_AUTO_COMPILE=0 $(RUNTOOL) $(GUILE) -l $(GUILE_SCRIPT) $(RUNPIPE)
     
    -guile_embedded_run:
    -	$(RUNTOOL) ./$(TARGET) $(GUILE_RUNOPTIONS) -s $(GUILE_SCRIPT) $(RUNPIPE)
    +guile_augmented_run:
    +	env GUILE_AUTO_COMPILE=0 $(RUNTOOL) ./$(TARGET) $(GUILE_RUNOPTIONS) -s $(GUILE_SCRIPT) $(RUNPIPE)
     
     # -----------------------------------------------------------------
     # Version display
    diff --git a/Examples/guile/Makefile.in b/Examples/guile/Makefile.in
    deleted file mode 100644
    index f84d54a38..000000000
    --- a/Examples/guile/Makefile.in
    +++ /dev/null
    @@ -1,47 +0,0 @@
    -# Makefile for Guile.  Used by all of the example programs.
    -
    -subdirs		= simple matrix port constants multimap multivalue
    -
    -top_srcdir	= @top_srcdir@
    -SWIG		= ../$(top_srcdir)/preinst-swig
    -CC		= @CC@
    -CXX		= @CXX@
    -CFLAGS		= @PLATFLAGS@
    -LIBS		=
    -GUILE		= @GUILE@
    -GUILE_CFLAGS	= @GUILE_CFLAGS@
    -GUILE_LIBS	= @GUILE_LIBS@
    -SWIGOPT		=
    -
    -WRAP		= $(IFILE:.i=_wrap.c)
    -CXXWRAP		= $(IFILE:.i=_wrap.cxx)
    -
    -SO		= @SO@
    -
    -all:
    -	for d in $(subdirs) ; do (cd $$d ; $(MAKE)) ; done
    -
    -clean:
    -	for d in $(subdirs) ; do (cd $$d ; $(MAKE) clean) ; done
    -	rm -f *~ .~*
    -
    -guile_clean:
    -	rm -f *.@OBJEXT@ *$(SO) *_wrap* *~ .~* core my-guile $(TARGET)
    -
    -# This is meant to be used w/ "make -f ../Makefile" from subdirs.
    -# Doesn't make sense to use it from here.
    -
    -sub-all:
    -	$(SWIG) -guile $(SWIGOPT) $(IFILE)
    -	$(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS)
    -
    -sub-all-cxx:
    -	$(SWIG) -c++ -guile $(SWIGOPT) $(IFILE)
    -	$(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS)
    -
    -run_example:
    -	if [ -f $(RUNSCRIPT) ]; then \
    -          env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(RUNSCRIPT); \
    -        fi
    -
    -# Makefile ends here
    diff --git a/Examples/guile/README b/Examples/guile/README
    index 7d726619e..03ce8e450 100644
    --- a/Examples/guile/README
    +++ b/Examples/guile/README
    @@ -1,6 +1,7 @@
     This directory contains examples for Guile.
     
     constants   -- handling #define and %constant literals
    +class       -- classic c++ class example
     matrix      -- a very simple Matrix example
     multimap    -- typemaps with multiple sub-types
     multivalue  -- using the %values_as_list directive
    diff --git a/Examples/guile/constants/Makefile b/Examples/guile/constants/Makefile
    index 5e60d9b34..d8a3cfebd 100644
    --- a/Examples/guile/constants/Makefile
    +++ b/Examples/guile/constants/Makefile
    @@ -1,18 +1,15 @@
    -SRCS   = 
    -TARGET = my-guile
    -IFILE  = example.i
    -MKDIR  = ..
     TOP        = ../..
    +SWIG       = $(TOP)/../preinst-swig
    +SRCS       = 
    +TARGET     = my-guile
    +INTERFACE  = example.i
     
     check: build
    -	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_embedded_run
    +	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_augmented_run
     
     build:
    -	$(MAKE) -f $(MKDIR)/Makefile		\
    -		SRCS='$(SRCS)'			\
    -		TARGET=$(TARGET)		\
    -		IFILE=$(IFILE)			\
    -	    sub-all
    +	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
    +	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented
     
     clean:
    -	$(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean
    +	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
    diff --git a/Examples/guile/matrix/Makefile b/Examples/guile/matrix/Makefile
    index 3d488f6f6..8a6ff81de 100644
    --- a/Examples/guile/matrix/Makefile
    +++ b/Examples/guile/matrix/Makefile
    @@ -1,20 +1,15 @@
    -SRCS   = matrix.c vector.c
    -TARGET = matrix
    -IFILE  = example.i
    -MKDIR  = ..
     TOP        = ../..
    +SWIG       = $(TOP)/../preinst-swig
    +SRCS       = matrix.c vector.c
    +TARGET     = matrix
    +INTERFACE  = example.i
     
     check: build
    -	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' GUILE_RUNOPTIONS='-e do-test' guile_embedded_run
    +	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' GUILE_RUNOPTIONS='-e do-test' guile_augmented_run
     
     build:
    -	$(MAKE) -f $(MKDIR)/Makefile		\
    -		SRCS='$(SRCS)'			\
    -		TARGET=$(TARGET)		\
    -		IFILE=$(IFILE)			\
    -		MODULE=$(MODULE)		\
    -		LIBS="-lm"			\
    -	  sub-all
    +	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
    +	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented
     
     clean:
    -	$(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean
    +	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
    diff --git a/Examples/guile/port/Makefile b/Examples/guile/port/Makefile
    index 0088dd92f..ec5d5198a 100644
    --- a/Examples/guile/port/Makefile
    +++ b/Examples/guile/port/Makefile
    @@ -1,19 +1,16 @@
    -SRCS   = example.c
    -TARGET = port
    -IFILE  = example.i
    -MKDIR  = ..
    +TOP        = ../..
    +SWIG       = $(TOP)/../preinst-swig
    +SRCS       = example.c
    +TARGET     = port
    +INTERFACE  = example.i
     
     check: build
     	./$(TARGET) -s runme.scm
     
     build:
    -	$(MAKE) -f $(MKDIR)/Makefile		\
    -		SRCS='$(SRCS)'			\
    -		TARGET=$(TARGET)		\
    -		IFILE=$(IFILE)			\
    -		MODULE=$(MODULE)		\
    -	  sub-all
    +	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
    +	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented
     
     clean:
    -	$(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean
    +	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
     	rm -f test.out
    diff --git a/Examples/guile/simple/Makefile b/Examples/guile/simple/Makefile
    index 66c7e26af..da4eb9015 100644
    --- a/Examples/guile/simple/Makefile
    +++ b/Examples/guile/simple/Makefile
    @@ -1,20 +1,15 @@
    -SRCS   = example.c
    -TARGET = my-guile
    -IFILE  = example.i
    -MKDIR  = ..
     TOP        = ../..
    +SWIG       = $(TOP)/../preinst-swig
    +SRCS       = example.c
    +TARGET     = my-guile
    +INTERFACE  = example.i
     
    -check: $(TARGET)
    -	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_embedded_run
    +check: build
    +	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_augmented_run
     
    -build: $(TARGET)
    -
    -$(TARGET):
    -	$(MAKE) -f $(MKDIR)/Makefile		\
    -		SRCS='$(SRCS)'			\
    -		TARGET=$(TARGET)		\
    -		IFILE=$(IFILE)			\
    -	    sub-all
    +build:
    +	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
    +	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented
     
     clean:
    -	$(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean
    +	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
    diff --git a/configure.ac b/configure.ac
    index a618d55de..968764715 100644
    --- a/configure.ac
    +++ b/configure.ac
    @@ -2397,7 +2397,6 @@ AC_CONFIG_FILES([			        \
         swig.spec				        \
         Source/Makefile			        \
         Examples/Makefile			        \
    -    Examples/guile/Makefile		        \
         Examples/xml/Makefile		        \
         Examples/test-suite/chicken/Makefile	\
         Examples/test-suite/csharp/Makefile	        \
    
    From 042d0dfdc221eead3df0e0e779d82d75411fce59 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Thu, 9 May 2013 19:41:29 +0100
    Subject: [PATCH 167/273] Guile port example Makefile correction
    
    ---
     Examples/guile/port/Makefile | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/Examples/guile/port/Makefile b/Examples/guile/port/Makefile
    index ec5d5198a..d6ec0ac24 100644
    --- a/Examples/guile/port/Makefile
    +++ b/Examples/guile/port/Makefile
    @@ -5,7 +5,7 @@ TARGET     = port
     INTERFACE  = example.i
     
     check: build
    -	./$(TARGET) -s runme.scm
    +	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_augmented_run
     
     build:
     	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
    
    From 199c1f3249abd677e7d5d5e8b3c709e8d8019331 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Thu, 9 May 2013 20:03:50 +0100
    Subject: [PATCH 168/273] Add skeleton for run test for Guile class example
    
    ---
     Examples/guile/class/Makefile  | 2 +-
     Examples/guile/class/runme.scm | 6 ++++++
     2 files changed, 7 insertions(+), 1 deletion(-)
     create mode 100644 Examples/guile/class/runme.scm
    
    diff --git a/Examples/guile/class/Makefile b/Examples/guile/class/Makefile
    index 189610800..0130e5fc1 100644
    --- a/Examples/guile/class/Makefile
    +++ b/Examples/guile/class/Makefile
    @@ -6,7 +6,7 @@ INTERFACE  = example.i
     TOP        = ../..
     
     check: build
    -#	$(MAKE) -f $(TOP)/Makefile guile_run
    +	$(MAKE) -f $(TOP)/Makefile guile_run
     
     build:
     	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
    diff --git a/Examples/guile/class/runme.scm b/Examples/guile/class/runme.scm
    new file mode 100644
    index 000000000..6bd7bf299
    --- /dev/null
    +++ b/Examples/guile/class/runme.scm
    @@ -0,0 +1,6 @@
    +
    +(dynamic-call "scm_init_example_module" (dynamic-link "./libexample"))
    +
    +(format (current-error-port) "TODO: code to demonstrate the class example\n")
    +
    +(exit 0)
    
    From e5f6ec8912628ac27447e4d8c276098a4d8b24c6 Mon Sep 17 00:00:00 2001
    From: Geert Janssens 
    Date: Fri, 10 May 2013 18:29:26 +0200
    Subject: [PATCH 169/273] Guile fix matrix example
    
    Got broken in commit dd36f28ac7b28ecb78736894796bdcab9d945e07
    (Migrate Guile examples build into common Examples makefile)
    ---
     Examples/guile/matrix/Makefile | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/Examples/guile/matrix/Makefile b/Examples/guile/matrix/Makefile
    index 8a6ff81de..a32210e65 100644
    --- a/Examples/guile/matrix/Makefile
    +++ b/Examples/guile/matrix/Makefile
    @@ -9,7 +9,7 @@ check: build
     
     build:
     	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
    -	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented
    +	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-lm' guile_augmented
     
     clean:
     	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
    
    From ef160ec07297252524ccab6949e17834c8b5aafc Mon Sep 17 00:00:00 2001
    From: Karl Wette 
    Date: Thu, 9 May 2013 14:35:41 +0200
    Subject: [PATCH 170/273] Octave: remove allocation of new octave_value in
     SWIG_Octave_SetGlobalValue()
    
    - this introduces a memory leak, which becomes significant for large
      modules (many global variables) and many module re-loadings (e.g.
      during a long-running script)
    - the original motivation was to prevent double-frees on exit, but this
      problem appears to have been fixed by the _Exit() hack in later commits,
      and in any case is an issue only for Octave ~3.2, so it should be safe to
      remove; tested by running Octave examples/test suite with Debian 3.2.4 and
      built-from-source 3.2.4, 3.4.3, and 3.6.3
    ---
     Lib/octave/octrun.swg | 11 +----------
     1 file changed, 1 insertion(+), 10 deletions(-)
    
    diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg
    index dfb4a7702..8fdb12086 100644
    --- a/Lib/octave/octrun.swg
    +++ b/Lib/octave/octrun.swg
    @@ -1289,16 +1289,7 @@ SWIGRUNTIMEINLINE octave_value SWIG_Octave_GetGlobalValue(std::string name) {
     }
     
     SWIGRUNTIME void SWIG_Octave_SetGlobalValue(std::string name, const octave_value& value) {
    -  // It is critical that a newly-allocated octave_value is passed to set_global_value(),
    -  // since it and the Octave symbol table take references to the values assigned to it.
    -  // If we were to pass a reference to 'value' to set_global_value(), then the Octave
    -  // symbol table would hold a reference to a variable owned by the SWIG .oct module.
    -  // Both will think that they own the reference (since the .oct module is dynamically
    -  // loaded, it appears to have its own C++ runtime), and so they will both try to
    -  // de-allocate the octave_value on exit, resulting in a double-free or seg-fault.
    -  // This is prevented by giving Octave its own heap-allocated copy of 'value'.
    -  octave_value *pov = new octave_value(value);
    -  set_global_value(name, *pov);
    +  set_global_value(name, value);
     }
     
     SWIGRUNTIME void SWIG_Octave_LinkGlobalValue(std::string name) {
    
    From 93650b2911588fa1a91c6c0081b3dd7f61707969 Mon Sep 17 00:00:00 2001
    From: Karl Wette 
    Date: Thu, 9 May 2013 14:55:04 +0200
    Subject: [PATCH 171/273] Octave: install functions only once, when creating
     module
    
    - once installed, Octave functions can never really be uninstalled
      (clear -f doesn't prevent the function being called again), so
      it makes no sense to install functions more than once
    - this can lead to a significant speed-up of module loading times,
      up to a factor of 10 for a large module loaded multiple times
    ---
     Lib/octave/octruntime.swg | 18 ++++++++++--------
     1 file changed, 10 insertions(+), 8 deletions(-)
    
    diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg
    index 66b6e265a..43313c3d4 100644
    --- a/Lib/octave/octruntime.swg
    +++ b/Lib/octave/octruntime.swg
    @@ -288,6 +288,15 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
     
         SWIG_InstallOps(octave_swig_ref::static_type_id());
     
    +    octave_swig_type::swig_member_const_iterator mb;
    +    for (mb = module_ns->swig_members_begin(); mb != module_ns->swig_members_end(); ++mb) {
    +      if (mb->second.first && mb->second.first->method) {
    +        if (!SWIG_Octave_InstallFunction(me, mb->first)) {
    +          return octave_value_list();
    +        }
    +      }
    +    }
    +
     #if OCTAVE_API_VERSION_NUMBER < 37
         mlock(me->name());
     #else
    @@ -296,16 +305,9 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
     
       }
     
    -  octave_function *me = octave_call_stack::current();
    -
       octave_swig_type::swig_member_const_iterator mb;
       for (mb = module_ns->swig_members_begin(); mb != module_ns->swig_members_end(); ++mb) {
    -    if (mb->second.first && mb->second.first->method) {
    -      if (!SWIG_Octave_InstallFunction(me, mb->first)) {
    -        return octave_value_list();
    -      }
    -    }
    -    else if (mb->second.second.is_defined()) {
    +    if (mb->second.second.is_defined()) {
           SWIG_Octave_SetGlobalValue(mb->first, mb->second.second);
           SWIG_Octave_LinkGlobalValue(mb->first);
         }
    
    From d7839ce5701f628b8d8d50b5c207e0bc967b7576 Mon Sep 17 00:00:00 2001
    From: Karl Wette 
    Date: Thu, 9 May 2013 19:43:52 +0200
    Subject: [PATCH 172/273] Update changelog for the previous two Octave patches
    
    ---
     CHANGES.current | 5 +++++
     1 file changed, 5 insertions(+)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 46b0d5589..eb3b0a8d1 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.10 (in progress)
     ============================
     
    +2013-05-09: kwwette
    +            [Octave] Fix bugs in Octave module loading:
    +            - fix a memory leak in setting of global variables
    +            - install functions only once, to speed up module loads
    +
     2013-04-28: gjanssens
                 [Guile] Updates in guile module:
                 - Add support for guile 2.0
    
    From 2733a0f7a318627f049998ed58d4d2041ac6666b Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Sat, 11 May 2013 10:31:16 +0100
    Subject: [PATCH 173/273] Update htmldoc patch to htmldoc-1.8.27
    
    Note: Best to use the patched source from Ubuntu/Debian which fixes some
    bugs.
    
    Also added "Patched with margin-left.patch" text to output of
      htmldoc --version
    ---
     Doc/Manual/margin-left.patch | 100 +++++++++++++++++++----------------
     1 file changed, 54 insertions(+), 46 deletions(-)
    
    diff --git a/Doc/Manual/margin-left.patch b/Doc/Manual/margin-left.patch
    index 70f087b92..8bef6305c 100644
    --- a/Doc/Manual/margin-left.patch
    +++ b/Doc/Manual/margin-left.patch
    @@ -1,25 +1,66 @@
    -#
    -# Patch managed by http://www.holgerschurig.de/patcher.html
    -#
    -# This patch is against htmldoc 1.8.24, and it hacks in support for
    +# This patch is against htmldoc 1.8.27, and it hacks in support for
     # correctly indenting the 
    sections in the SWIG manual. # This patch should only be used until the 1.9 branch of htmldoc -# stabalizes, since the 1.9 branch includes true CSS1 support. +# stabilizes, since the 1.9 branch includes true CSS1 support. # # This patch only affects the PDF generation, an unpatched htmldoc # creates the one-page html documentation just fine. # ---- htmldoc-1.8.24/htmldoc/ps-pdf.cxx~margin-left -+++ htmldoc-1.8.24/htmldoc/ps-pdf.cxx -@@ -158,6 +158,7 @@ +diff -Naur htmldoc-1.8.27/htmldoc/htmldoc.cxx htmldoc-1.8.27-margin-left/htmldoc/htmldoc.cxx +--- htmldoc-1.8.27/htmldoc/htmldoc.cxx 2006-03-30 14:01:20.000000000 +0100 ++++ htmldoc-1.8.27-margin-left/htmldoc/htmldoc.cxx 2013-05-11 10:11:47.428435647 +0100 +@@ -65,6 +65,8 @@ + const char *__XOS2RedirRoot(const char *); + } + #endif ++ ++extern void parse_style(char *); + + + /* +@@ -1115,6 +1117,7 @@ + else if (compare_strings(argv[i], "--version", 6) == 0) + { + puts(SVERSION); ++ puts("Patched with margin-left.patch"); + return (0); + } + else if (compare_strings(argv[i], "--webpage", 3) == 0) +@@ -2403,6 +2406,10 @@ + } + else if (strcmp(temp, "--cookies") == 0) + file_cookies(temp2); ++ else if (strcmp(temp, "--stylesheet") == 0) ++ { ++ parse_style(temp2); ++ } + } + } + +diff -Naur htmldoc-1.8.27/htmldoc/Makefile htmldoc-1.8.27-margin-left/htmldoc/Makefile +--- htmldoc-1.8.27/htmldoc/Makefile 2005-10-28 21:32:59.000000000 +0100 ++++ htmldoc-1.8.27-margin-left/htmldoc/Makefile 2013-05-11 09:39:04.392367869 +0100 +@@ -36,7 +36,7 @@ + OBJS = gui.o file.o html.o htmldoc.o htmllib.o htmlsep.o \ + http.o http-addr.o http-addrlist.o http-support.o image.o \ + iso8859.o license.o md5.o progress.o ps-pdf.o rc4.o \ +- snprintf.o string.o toc.o util.o ++ snprintf.o string.o toc.o util.o style.o + + + # +diff -Naur htmldoc-1.8.27/htmldoc/ps-pdf.cxx htmldoc-1.8.27-margin-left/htmldoc/ps-pdf.cxx +--- htmldoc-1.8.27/htmldoc/ps-pdf.cxx 2006-08-01 17:58:50.000000000 +0100 ++++ htmldoc-1.8.27-margin-left/htmldoc/ps-pdf.cxx 2013-05-11 09:37:40.096364957 +0100 +@@ -160,6 +160,7 @@ # undef page_t #endif // __hpux +extern int lookup_div_class(uchar *); /* - * Constants... -@@ -4188,9 +4189,24 @@ + * Output options... +@@ -4230,9 +4231,24 @@ para->child = para->last_child = NULL; } @@ -45,30 +86,9 @@ if (para->child != NULL) { parse_paragraph(para, *left, *right, *bottom, *top, x, y, page, *needspace); ---- htmldoc-1.8.24/htmldoc/htmldoc.cxx~margin-left -+++ htmldoc-1.8.24/htmldoc/htmldoc.cxx -@@ -62,6 +62,8 @@ - const char *__XOS2RedirRoot(const char *); - } - #endif -+ -+extern void parse_style(char *); - - - /* -@@ -2140,6 +2142,10 @@ - } - else if (strcmp(temp, "--cookies") == 0) - file_cookies(temp2); -+ else if (strcmp(temp, "--stylesheet") == 0) -+ { -+ parse_style(temp2); -+ } - } - } - ---- /dev/null -+++ htmldoc-1.8.24/htmldoc/style.cxx +diff -Naur htmldoc-1.8.27/htmldoc/style.cxx htmldoc-1.8.27-margin-left/htmldoc/style.cxx +--- htmldoc-1.8.27/htmldoc/style.cxx 1970-01-01 01:00:00.000000000 +0100 ++++ htmldoc-1.8.27-margin-left/htmldoc/style.cxx 2013-05-11 09:37:40.096364957 +0100 @@ -0,0 +1,185 @@ +/* Extreamly simple parsing routines for CSS style sheets. + * We only parse div.class { } sections, and only look @@ -255,15 +275,3 @@ + + fclose(f); +} ---- htmldoc-1.8.24/htmldoc/Makefile~margin-left -+++ htmldoc-1.8.24/htmldoc/Makefile -@@ -35,7 +35,7 @@ - - OBJS = gui.o file.o html.o htmldoc.o htmllib.o htmlsep.o http.o \ - http-addr.o http-support.o image.o iso8859.o license.o md5.o \ -- progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o -+ progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o style.o - - - # - From ea2e615cec87a469850605c6eda4f966ec1450da Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 12 May 2013 13:18:01 +0100 Subject: [PATCH 174/273] Fix some typos in directive names --- Doc/Manual/Allegrocl.html | 4 ++-- Doc/Manual/Lua.html | 2 +- Doc/Manual/Varargs.html | 2 +- Lib/typemaps/implicit.swg | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index 283ff7e2c..12b915ee2 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -1613,7 +1613,7 @@ opoverload>

    Variable length argument lists are not supported, by default. If such a function is encountered, a warning will generated to - stderr. Varargs are supported via the SWIG %vararg + stderr. Varargs are supported via the SWIG %varargs directive. This directive allows you to specify a (finite) argument list which will be inserted into the wrapper in place of the variable length argument indicator. As an example, @@ -1624,7 +1624,7 @@ opoverload>

    See the following section on Variable Length arguments - provides examples on how %vararg can be used, along + provides examples on how %varargs can be used, along with other ways such functions can be wrapped.

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 1fd41f907..88d26f385 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -1359,7 +1359,7 @@ extern void sort_double(double* arr, int len); to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but it's a bit tedious. More details can be found in the carrays.i documentation.

    -

    The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %appy in the correct manner.

    +

    The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %apply in the correct manner.

    The wrapper file below, shows both the use of carrays as well as the use of the typemap to wrap arrays.

    diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index 13abc8cee..a580c83bd 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -398,7 +398,7 @@ int execlp(const char *path, const char *arg, ...);

    -Note that str3 is the name of the last argument, as we have used %vargars with 3. +Note that str3 is the name of the last argument, as we have used %varargs with 3. Now execlp("a", "b", "c", "d", "e") will result in an error as one too many arguments has been passed, as now only 2 additional 'str' arguments can be passed with the 3rd one always using the specified default NULL.

    diff --git a/Lib/typemaps/implicit.swg b/Lib/typemaps/implicit.swg index 24bb3dcce..702fb52b8 100644 --- a/Lib/typemaps/implicit.swg +++ b/Lib/typemaps/implicit.swg @@ -1,5 +1,5 @@ /* - The %implict macro allows a SwigType (Class) to be accepted + The %implicit macro allows a SwigType (Class) to be accepted as an input parameter and use its implicit constructors when needed. For example: From 9812b27fb0a7e097a6b7a1a54a632ab39f48a2b4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 11 May 2013 07:47:52 +0100 Subject: [PATCH 175/273] Add .gitattributes file For specifying what not to export when running 'git archive' --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..596615322 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +.gitattributes export-ignore +.gitignore export-ignore From a5b0e34dea544ffcc61cb4f587e32cbebce3d727 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 12 May 2013 15:31:33 +0100 Subject: [PATCH 176/273] Update release scripts to use git instead of svn --- Tools/mkdist.py | 39 ++++++++++++++++++++++++++++++++++++--- Tools/mkrelease.py | 5 +---- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Tools/mkdist.py b/Tools/mkdist.py index f2a04542c..1585523cf 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -6,6 +6,7 @@ import sys import string import os +import subprocess def failed(): print "mkdist.py failed to complete" @@ -34,10 +35,42 @@ os.system("rm -f "+dirname+".tar.gz") print "Removing "+dirname+".tar.gz if exists" os.system("rm -f "+dirname+".tar") -# Do a SVN export into the directory name +# Grab the code from git -print "Grabbing latest SWIG from svn" -os.system("svn export -r HEAD https://swig.svn.sourceforge.net/svnroot/swig/trunk "+dirname) == 0 or failed() +print "Checking git repository is in sync with remote repository" +os.system("git remote update") == 0 or failed() +command = ["git", "status", "--porcelain", "-uno"] +out = subprocess.check_output(command) +if out.strip() != "": + print "Local git repository has modifications" + print " ".join(command) + print out + sys.exit(3) + +command = ["git", "log", "--oneline", "master..origin/master"] +out = subprocess.check_output(command) +if out.strip() != "": + print "Remote repository has additional modifications to local repository" + print " ".join(command) + print out + sys.exit(3) + +command = ["git", "log", "--oneline", "origin/master..master"] +out = subprocess.check_output(command) +if out.strip() != "": + print "Local repository has modifications not pushed to the remote repository" + print "These should be pushed and checked that they pass Continuous Integration testing before continuing" + print " ".join(command) + print out + sys.exit(3) + +print "Tagging release" +tag = "'rel-" + version + "'" +os.system("git tag -a -m " + tag + " " + tag) == 0 or failed() + +print "Grabbing tagged release git repository using 'git archive' into " + outdir +outdir = os.path.basename(os.getcwd()) + "/" + dirname + "/" +os.system("(cd .. && git archive --prefix=" + outdir + tag + " . | tar -xf -)") == 0 or failed() # Remove the debian directory -- it's not official diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py index 9ca96bc6f..9eceba07e 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -43,9 +43,6 @@ os.system("cat swig-" + version + "/README " + "swig-" + version + "/CHANGES.cur os.system("rsync --archive --verbose -P --times -e ssh " + "swig-" + version + ".tar.gz " + full_readme_file + " " + swig_dir_sf) and failed("") os.system("rsync --archive --verbose -P --times -e ssh " + "swigwin-" + version + ".zip " + full_readme_file + " " + swigwin_dir_sf) and failed("") -print "Tagging release" -os.system("svn copy -m \"rel-" + version + "\" https://swig.svn.sourceforge.net/svnroot/swig/trunk https://swig.svn.sourceforge.net/svnroot/swig/tags/rel-" + version + "/") - print "Finished" -print "Now log in to SourceForge and set the operating systems applicable to the newly uploaded tarball and zip file." +print "Now log in to SourceForge and set the operating systems applicable to the newly uploaded tarball and zip file. Also remember to do a 'git push'." From a3e23668824aa2f4a397fef95cedaee25d6d381f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 12 May 2013 19:16:42 +0100 Subject: [PATCH 177/273] Fix release script --- Tools/mkdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 1585523cf..8bec81ea5 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -68,8 +68,8 @@ print "Tagging release" tag = "'rel-" + version + "'" os.system("git tag -a -m " + tag + " " + tag) == 0 or failed() -print "Grabbing tagged release git repository using 'git archive' into " + outdir outdir = os.path.basename(os.getcwd()) + "/" + dirname + "/" +print "Grabbing tagged release git repository using 'git archive' into " + outdir os.system("(cd .. && git archive --prefix=" + outdir + tag + " . | tar -xf -)") == 0 or failed() # Remove the debian directory -- it's not official From de12f6c25e6e50724626d4bf954d16bde59ef4cd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 12 May 2013 21:27:38 +0100 Subject: [PATCH 178/273] Fix release script --- Tools/mkdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 8bec81ea5..234c768f2 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -70,7 +70,7 @@ os.system("git tag -a -m " + tag + " " + tag) == 0 or failed() outdir = os.path.basename(os.getcwd()) + "/" + dirname + "/" print "Grabbing tagged release git repository using 'git archive' into " + outdir -os.system("(cd .. && git archive --prefix=" + outdir + tag + " . | tar -xf -)") == 0 or failed() +os.system("(cd .. && git archive --prefix=" + outdir + " " + tag + " . | tar -xf -)") == 0 or failed() # Remove the debian directory -- it's not official From f09231d282f005e2b91664920ac3e64b85bea7b5 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Mon, 13 May 2013 12:27:21 +0200 Subject: [PATCH 179/273] Add CCache/ccache-swig.1 to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fbeebc67d..eb3aa012c 100644 --- a/.gitignore +++ b/.gitignore @@ -81,6 +81,7 @@ swig.spec # Build Artifacts .dirstamp CCache/ccache-swig +CCache/ccache-swig.1 Source/CParse/parser.c Source/CParse/parser.h Source/eswig From 3ddea71f332449a38b9c1827a1406dd0bfc66d62 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 13 May 2013 18:10:59 +0100 Subject: [PATCH 180/273] Clear up license ambiguity in swigwarn.swg. Also tidies up swigwarn.swg a bit. --- Makefile.in | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Makefile.in b/Makefile.in index cfa6d0933..0ac8c88f9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -432,12 +432,8 @@ maintainer-clean: $(srcdir)/Lib/swigwarn.swg: $(srcdir)/Source/Include/swigwarn.h mkdir -p Lib - echo "/* Automatically generated file containing all the swig warning codes. */" > $@ - echo "/* Do not modify this file by hand, change 'Source/Include/swigwarn.h' */" >> $@ - echo "/* and use the command 'make Lib/swigwarn.swg' instead. */" >> $@ - echo >> $@; echo >> $@ - awk '/#define WARN/{$$1="%define"; $$2="SWIG"$$2; $$3=sprintf("%d %%enddef", $$3); print $$0; next;}\ - /#/{next;} {print $0}' < $? >> $@ + echo "/* SWIG warning codes */" > $@ + cat $? | grep "^#define WARN\|/\*.*\*/\|^[ \t]*$$" | sed 's/^#define \(WARN.*[0-9]\+\)\(.*\)$$/%define SWIG\1 %enddef\2/' >> $@ ##################################################################### # TARGETS: install & friends From 090d2505d1152b682527f80d6ac90b4382ff967d Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 13 May 2013 21:40:01 +0200 Subject: [PATCH 181/273] Guile create functional class example --- Examples/guile/class/runme.scm | 56 +++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/Examples/guile/class/runme.scm b/Examples/guile/class/runme.scm index 6bd7bf299..70fe63151 100644 --- a/Examples/guile/class/runme.scm +++ b/Examples/guile/class/runme.scm @@ -1,6 +1,60 @@ +; file: runme.py + +; This file illustrates the proxy class C++ interface generated +; by SWIG. (dynamic-call "scm_init_example_module" (dynamic-link "./libexample")) -(format (current-error-port) "TODO: code to demonstrate the class example\n") +; Convenience wrapper around the display function +; (which only accepts one argument at the time) + +(define (mdisplay-newline . args) + (for-each display args) + (newline)) + +; ----- Object creation ----- + +(mdisplay-newline "Creating some objects:") +(define c (new-Circle 10)) +(mdisplay-newline " Created circle " c) +(define s (new-Square 10)) +(mdisplay-newline " Created square " s) + +; ----- Access a static member ----- + +(mdisplay-newline "\nA total of " (Shape-nshapes) " shapes were created") + +; ----- Member data access ----- + +; Set the location of the object + +(Shape-x-set c 20) +(Shape-y-set c 30) + +(Shape-x-set s -10) +(Shape-y-set s 5) + +(mdisplay-newline "\nHere is their current position:") +(mdisplay-newline " Circle = (" (Shape-x-get c) "," (Shape-y-get c) ")") +(mdisplay-newline " Square = (" (Shape-x-get s) "," (Shape-y-get s) ")") + +; ----- Call some methods ----- + +(mdisplay-newline "\nHere are some properties of the shapes:") +(define (shape-props o) + (mdisplay-newline " " o) + (mdisplay-newline " area = " (Shape-area o)) + (mdisplay-newline " perimeter = " (Shape-perimeter o))) +(for-each shape-props (list c s)) + +(mdisplay-newline "\nGuess I'll clean up now") + +; Note: this invokes the virtual destructor +(delete-Shape c) +(delete-Shape s) + +(define s 3) +(mdisplay-newline (Shape-nshapes) " shapes remain") +(mdisplay-newline "Goodbye") (exit 0) From cb24c110df2e52d87c6f454e20002a2f342ff8e3 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 13 May 2013 22:31:29 +0200 Subject: [PATCH 182/273] Guile remove references to -gh and -scm from manual --- Doc/Manual/Guile.html | 65 +++++++++++-------------------------------- 1 file changed, 16 insertions(+), 49 deletions(-) diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index cfbfbd0b7..17e3a3fab 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -27,8 +27,7 @@
  • Typemaps
  • Representation of pointers as smobs
  • Exception Handling @@ -73,16 +72,13 @@ we explicitly prefix the context, e.g., "guile-module".

    23.3 Old GH Guile API

    -

    Support for the guile GH wrapper code generation has been dropped. The last -version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please -use that version if you really need the GH wrapper code. - -

    Guile 1.8 and older could be interfaced using a two different api's, the SCM +

    Guile 1.8 and older could be interfaced using two different api's, the SCM or the GH API. The GH interface to guile is deprecated. Read more about why in the Guile manual. -

    The SCM wrapper generation assumes a guile version >= 1.8 and has several advantages over -the "-gh" wrapper generation including garbage collection and GOOPS support. +

    Support for the guile GH wrapper code generation has been dropped from SWIG. The last +version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please +use that version if you really need the GH wrapper code.

    23.4 Linkage

    @@ -212,7 +208,7 @@ are using multiple modules.

    SWIG can also generate wrapper code that does all the Guile module declarations on its own if you pass it the -Linkage -module command-line option. This requires Guile 1.5.0 or later. +module command-line option.

    The module name is set with the -package and -module command-line options. Suppose you want to define @@ -235,7 +231,7 @@ shared libraries into Guile; all bindings are automatically put in newly created Guile modules.

    -(define my-so (dynamic-link "./libfoo.so"))
    +(define my-so (dynamic-link "./libfoo"))
     ;; create new module and put bindings there:
     (dynamic-call "scm_init_my_modules_foo_module" my-so) 
     
    @@ -424,7 +420,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. -

    23.7.1 GH Smobs

    +

    23.7.1 Smobs

    @@ -435,44 +431,19 @@ mangled type name. As Guile allows registering user types, so-called implemented now. The details will be discussed in the following.

    -

    A smob is a cons cell where the lower half of the CAR contains the smob type -tag, while the upper half of the CAR and the whole CDR are available. Every -module creates its own smob type in the clientdata field of the module. So the -lower 16 bits of the car of the smob store the tag and the upper 16 bits store -the index this type is in the array. We can then, given a smob, find its -swig_type_info struct by using the tag (lower 16 bits of car) to find which -module this type is in (since each tag is unique for the module). Then we use -the upper 16 bits to index into the array of types attached to this module. -Looking up the module from the tag is worst case O(# of modules) but average -case O(1). This is because the modules are stored in a circularly linked list, -and when we start searching the modules for the tag, we start looking with the -module that the function doing the lookup is in. SWIG_Guile_ConvertPtr() takes -as its first argument the swig_module_info * of the calling function, which is -where we start comparing tags. Most types will be looked up in the same module -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.

    - -

    23.7.2 SCM Smobs

    - - -

    The SCM interface (using the "-scm" argument to swig) uses swigrun.swg. -The whole type system, when it is first initialized, creates two smobs named "swig" and "collected_swig". +

    The whole type system, when it is first initialized, creates two smobs named "swig" and "collected_swig". The swig smob is used for non-garbage collected smobs, while the collected_swig smob is used as described below. Each smob has the same format, which is a double cell created by SCM_NEWSMOB2() The first word of data is the pointer to the object and the second word of data is the swig_type_info * -structure describing this type. This is a lot easier than the GH interface above because we can store -a pointer to the type info structure right in the type. With the GH interface, there was not enough -room in the smob to store two whole words of data so we needed to store part of the "swig_type_info address" -in the smob tag. If a generated GOOPS module has been loaded, smobs will be wrapped by the corresponding -GOOPS class.

    +structure describing this type. If a generated GOOPS module has been loaded, smobs will be wrapped by +the corresponding GOOPS class.

    -

    23.7.3 Garbage Collection

    +

    23.7.2 Garbage Collection

    -

    Garbage collection is a feature of the new SCM interface, and it is automatically included -if you pass the "-scm" flag to swig. Thus the swig garbage collection support requires guile >1.6. +

    Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8, +it is automatically included. Garbage collection works like this. Every swig_type_info structure stores in its clientdata field a pointer to the destructor for this type. The destructor is the generated wrapper around the delete function. So swig still exports a wrapper for the destructor, it just does not call scm_c_define_gsubr() for @@ -514,8 +485,7 @@ See Lib/exception.i for details.

    If invoked with the command-line option -procdoc file, SWIG creates documentation strings for the generated wrapper functions, describing the procedure signature and -return value, and writes them to file. You need Guile 1.4 -or later to make use of the documentation files. +return value, and writes them to file.

    SWIG can generate documentation strings in three formats, which are selected via the command-line option -procdocformat @@ -580,10 +550,7 @@ Guile's Object-Oriented Programming System (GOOPS). GOOPS is a sophisticated object system in the spirit of the Common Lisp Object System (CLOS). -

    GOOPS support is -only available with the new SCM interface (enabled with the --scm command-line option of SWIG). To enable GOOPS -support, pass the -proxy argument to +

    To enable GOOPS support, pass the -proxy argument to swig. This will export the GOOPS wrapper definitions into the module.scm file in the directory specified by -outdir or the current directory. GOOPS support requires either passive or module linkage.

    From 4e4b73e7c005bc074c41f57db99b64bbcfc8b138 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 13 May 2013 22:39:13 +0200 Subject: [PATCH 183/273] Put guile Example Makefile back under revision control --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index eb3aa012c..fb36302f6 100644 --- a/.gitignore +++ b/.gitignore @@ -64,7 +64,6 @@ CCache/config.h CCache/config.log CCache/config.status Examples/Makefile -Examples/guile/Makefile Examples/test-suite/*/Makefile Examples/xml/Makefile Lib/ocaml/swigp4.ml From d3cddb135599fa614a49fd0828fa1f1247275c8b Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 13 May 2013 22:40:16 +0200 Subject: [PATCH 184/273] Guile add two more examples and use load-extension instead of dynamic-load --- Examples/guile/Makefile | 47 +++++++++++++++++++++++++++++ Examples/guile/class/runme.scm | 4 +-- Examples/guile/multimap/runme.scm | 2 +- Examples/guile/multivalue/runme.scm | 2 +- Examples/guile/std_vector/runme.scm | 2 +- 5 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 Examples/guile/Makefile diff --git a/Examples/guile/Makefile b/Examples/guile/Makefile new file mode 100644 index 000000000..93381dfc0 --- /dev/null +++ b/Examples/guile/Makefile @@ -0,0 +1,47 @@ +# Makefile for Guile. Used by all of the example programs. + +subdirs = simple matrix port constants class multimap multivalue std_vector + +top_srcdir = ../.. +SWIG = ../$(top_srcdir)/preinst-swig +CC = gcc +CXX = g++ +CFLAGS = +LIBS = +GUILE = /usr/bin/guile +GUILE_CFLAGS = -pthread +GUILE_LIBS = -pthread -lguile +SWIGOPT = + +WRAP = $(IFILE:.i=_wrap.c) +CXXWRAP = $(IFILE:.i=_wrap.cxx) + +SO = .so + +all: + for d in $(subdirs) ; do (cd $$d ; $(MAKE)) ; done + +clean: + for d in $(subdirs) ; do (cd $$d ; $(MAKE) clean) ; done + rm -f *~ .~* + +guile_clean: + rm -f *.o *$(SO) *_wrap* *~ .~* core my-guile $(TARGET) + +# This is meant to be used w/ "make -f ../Makefile" from subdirs. +# Doesn't make sense to use it from here. + +sub-all: + $(SWIG) -guile $(SWIGOPT) $(IFILE) + $(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) + +sub-all-cxx: + $(SWIG) -c++ -guile $(SWIGOPT) $(IFILE) + $(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) + +run_example: + if [ -f $(RUNSCRIPT) ]; then \ + env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(RUNSCRIPT); \ + fi + +# Makefile ends here diff --git a/Examples/guile/class/runme.scm b/Examples/guile/class/runme.scm index 70fe63151..4e47d458d 100644 --- a/Examples/guile/class/runme.scm +++ b/Examples/guile/class/runme.scm @@ -1,9 +1,9 @@ -; file: runme.py +; file: runme.scm ; This file illustrates the proxy class C++ interface generated ; by SWIG. -(dynamic-call "scm_init_example_module" (dynamic-link "./libexample")) +(load-extension "./libexample" "scm_init_example_module") ; Convenience wrapper around the display function ; (which only accepts one argument at the time) diff --git a/Examples/guile/multimap/runme.scm b/Examples/guile/multimap/runme.scm index d2ab8036e..a4a518a02 100644 --- a/Examples/guile/multimap/runme.scm +++ b/Examples/guile/multimap/runme.scm @@ -1,6 +1,6 @@ ;;; Test out some multi-argument typemaps -(dynamic-call "scm_init_example_module" (dynamic-link "./libexample")) +(load-extension "./libexample" "scm_init_example_module") ; Call the GCD function diff --git a/Examples/guile/multivalue/runme.scm b/Examples/guile/multivalue/runme.scm index 729f3fa18..0f65797ca 100644 --- a/Examples/guile/multivalue/runme.scm +++ b/Examples/guile/multivalue/runme.scm @@ -1,6 +1,6 @@ ;;;; Show the three different ways to deal with multiple return values -(dynamic-call "scm_init_example_module" (dynamic-link "./libexample")) +(load-extension "./libexample" "scm_init_example_module") ;;; Multiple values as lists. By default, if more than one value is to ;;; be returned, a list of the values is created and returned. The diff --git a/Examples/guile/std_vector/runme.scm b/Examples/guile/std_vector/runme.scm index 470f22922..64f56a147 100644 --- a/Examples/guile/std_vector/runme.scm +++ b/Examples/guile/std_vector/runme.scm @@ -1,5 +1,5 @@ -(dynamic-call "scm_init_example_module" (dynamic-link "./libexample")) +(load-extension "./libexample" "scm_init_example_module") ; repeatedly invoke a procedure with v and an index as arguments (define (with-vector v proc size-proc) From 4de24d1d11b4b8eec27ffcd5cf91bba9b009fdc6 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Tue, 14 May 2013 17:06:04 +0200 Subject: [PATCH 185/273] Guile check for at least guile 1.8 --- configure.ac | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/configure.ac b/configure.ac index 968764715..65d2a4c20 100644 --- a/configure.ac +++ b/configure.ac @@ -1204,6 +1204,17 @@ else fi fi + if test -f "$GUILE" ; then + AC_MSG_CHECKING([for guile version]) + guile_version=`guile -c '(display (effective-version))'` + AC_MSG_RESULT([$guile_version]) + guile -c '(if (>= (string->number (effective-version)) 1.8) (exit 0) (exit 1))' + if test $? -ne 0 ; then + AC_MSG_WARN(Not Guile >= 1.8, SWIG does not support this version of Guile) + GUILE= + fi + fi + if test -z "$GUILE_CFLAGS" ; then AC_MSG_CHECKING([for guile compile flags]) GUILE_CFLAGS="`$GUILE_CONFIG compile`" # Note that this can sometimes be empty From f3870303c6a2d922832b624d2e3fbafe46d7ba56 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Tue, 14 May 2013 17:06:35 +0200 Subject: [PATCH 186/273] Guile drop unused GUILE_SCM_INTERFACE parameter from configure.ac --- configure.ac | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 65d2a4c20..d0b6b66e4 100644 --- a/configure.ac +++ b/configure.ac @@ -1226,15 +1226,12 @@ else GUILE_LIBS="`$GUILE_CONFIG link`" AC_MSG_RESULT([$GUILE_LIBS]) fi - - GUILE_SCM_INTERFACE=1 fi fi AC_SUBST(GUILE) AC_SUBST(GUILE_CFLAGS) AC_SUBST(GUILE_LIBS) -AC_SUBST(GUILE_SCM_INTERFACE) #---------------------------------------------------------------- # Look for MzScheme @@ -2234,7 +2231,7 @@ AC_SUBST(SKIP_JAVA) SKIP_GUILE= -if test -z "$GUILE" || test -z "$GUILE_LIBS" || test -z "$GUILE_SCM_INTERFACE"; then +if test -z "$GUILE" || test -z "$GUILE_LIBS" ; then SKIP_GUILE="1" fi AC_SUBST(SKIP_GUILE) From 2560210bfdc9ab76feef26b2f820de092b48190e Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 15 May 2013 09:38:50 +0200 Subject: [PATCH 187/273] Guile delete Example makefile --- .gitignore | 1 + Examples/guile/Makefile | 47 ----------------------------------------- 2 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 Examples/guile/Makefile diff --git a/.gitignore b/.gitignore index fb36302f6..eb3aa012c 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,7 @@ CCache/config.h CCache/config.log CCache/config.status Examples/Makefile +Examples/guile/Makefile Examples/test-suite/*/Makefile Examples/xml/Makefile Lib/ocaml/swigp4.ml diff --git a/Examples/guile/Makefile b/Examples/guile/Makefile deleted file mode 100644 index 93381dfc0..000000000 --- a/Examples/guile/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# Makefile for Guile. Used by all of the example programs. - -subdirs = simple matrix port constants class multimap multivalue std_vector - -top_srcdir = ../.. -SWIG = ../$(top_srcdir)/preinst-swig -CC = gcc -CXX = g++ -CFLAGS = -LIBS = -GUILE = /usr/bin/guile -GUILE_CFLAGS = -pthread -GUILE_LIBS = -pthread -lguile -SWIGOPT = - -WRAP = $(IFILE:.i=_wrap.c) -CXXWRAP = $(IFILE:.i=_wrap.cxx) - -SO = .so - -all: - for d in $(subdirs) ; do (cd $$d ; $(MAKE)) ; done - -clean: - for d in $(subdirs) ; do (cd $$d ; $(MAKE) clean) ; done - rm -f *~ .~* - -guile_clean: - rm -f *.o *$(SO) *_wrap* *~ .~* core my-guile $(TARGET) - -# This is meant to be used w/ "make -f ../Makefile" from subdirs. -# Doesn't make sense to use it from here. - -sub-all: - $(SWIG) -guile $(SWIGOPT) $(IFILE) - $(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) - -sub-all-cxx: - $(SWIG) -c++ -guile $(SWIGOPT) $(IFILE) - $(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) - -run_example: - if [ -f $(RUNSCRIPT) ]; then \ - env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(RUNSCRIPT); \ - fi - -# Makefile ends here From b14b1c6de09ae48675722c2aa7709c7ace63de12 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 14 May 2013 19:49:32 +0100 Subject: [PATCH 188/273] Use given Guile version when checking if version is > 1.8 Also use conventional output for our configure if something is not working as expected. --- configure.ac | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index d0b6b66e4..c94c2e962 100644 --- a/configure.ac +++ b/configure.ac @@ -1206,11 +1206,12 @@ else if test -f "$GUILE" ; then AC_MSG_CHECKING([for guile version]) - guile_version=`guile -c '(display (effective-version))'` + guile_version=`$GUILE -c '(display (effective-version))'` AC_MSG_RESULT([$guile_version]) - guile -c '(if (>= (string->number (effective-version)) 1.8) (exit 0) (exit 1))' - if test $? -ne 0 ; then - AC_MSG_WARN(Not Guile >= 1.8, SWIG does not support this version of Guile) + AC_MSG_CHECKING([for guile version >= 1.8]) + guile_good_version=`$GUILE -c '(if (>= (string->number (effective-version)) 1.8) (display "yes") (display "no"))'` + AC_MSG_RESULT([$guile_good_version]) + if test x"$guile_good_version" != xyes ; then GUILE= fi fi From 6f1aea7a12772ade649a4a92ff4f07dafe0cd520 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 14 May 2013 21:32:09 +0100 Subject: [PATCH 189/273] Cosmetic makefile tidy up --- Examples/guile/class/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Examples/guile/class/Makefile b/Examples/guile/class/Makefile index 0130e5fc1..8de4f292b 100644 --- a/Examples/guile/class/Makefile +++ b/Examples/guile/class/Makefile @@ -3,7 +3,6 @@ SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx TARGET = example INTERFACE = example.i -TOP = ../.. check: build $(MAKE) -f $(TOP)/Makefile guile_run From 3f9d7ed4165602af52e3bdad6d2641b8106427d5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 16 May 2013 08:07:09 +0100 Subject: [PATCH 190/273] Minor fixes after Coverity analysis --- Source/Modules/csharp.cxx | 2 +- Source/Modules/java.cxx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 6d5c570b1..44db84264 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3671,7 +3671,7 @@ public: Replaceall(pre, "$iminput", ln); if (Len(pre_code) > 0) Printf(pre_code, "\n"); - Printv(pre_code, pre, NIL); + Printv(pre_code, pre, NIL); } String *post = Getattr(p, "tmap:csdirectorin:post"); if (post) { diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index dbd110d56..b99bbb4ee 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -138,6 +138,7 @@ public: imclass_imports(NULL), module_imports(NULL), imclass_baseclass(NULL), + imclass_package(NULL), module_baseclass(NULL), imclass_interfaces(NULL), module_interfaces(NULL), From 04b9037c707f3fd179ded0648fa654aa9c95a2a8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 16 May 2013 19:21:59 +0100 Subject: [PATCH 191/273] Simplify and improve Guile FILE * in typemap Fix incorrect special variable $name and remove unnecessary temporary variable. --- Lib/guile/ports.i | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/Lib/guile/ports.i b/Lib/guile/ports.i index 5940b4d3b..7691d3e31 100644 --- a/Lib/guile/ports.i +++ b/Lib/guile/ports.i @@ -21,33 +21,30 @@ */ %typemap(in, doc="$NAME is a file port or a FILE * pointer") FILE * - ( int closep ) { - if (SWIG_ConvertPtr($input, (void**) &($1), $1_descriptor, 0) == 0) { - closep = 0; - } - else if(!(SCM_FPORTP($input))) - scm_wrong_type_arg("$name", $argnum, $input); - else { - int fd; - if (SCM_OUTPUT_PORT_P($input)) - scm_force_output($input); - fd=dup(SCM_FPORT_FDES($input)); - if(fd==-1) - scm_misc_error("$name", strerror(errno), SCM_EOL); - $1=fdopen(fd, - SCM_OUTPUT_PORT_P($input) - ? (SCM_INPUT_PORT_P($input) - ? "r+" : "w") - : "r"); - if($1==NULL) - scm_misc_error("$name", strerror(errno), SCM_EOL); - closep = 1; + if (SWIG_ConvertPtr($input, (void**) &($1), $1_descriptor, 0) != 0) { + if (!(SCM_FPORTP($input))) { + scm_wrong_type_arg("$symname", $argnum, $input); + } else { + int fd; + if (SCM_OUTPUT_PORT_P($input)) { + scm_force_output($input); + } + fd=dup(SCM_FPORT_FDES($input)); + if (fd==-1) { + scm_misc_error("$symname", strerror(errno), SCM_EOL); + } + $1=fdopen(fd, SCM_OUTPUT_PORT_P($input) ? (SCM_INPUT_PORT_P($input) ? "r+" : "w") : "r"); + if ($1==NULL) { + scm_misc_error("$symname", strerror(errno), SCM_EOL); + } + } } } %typemap(freearg) FILE* { - if (closep$argnum) + if ($1) { fclose($1); + } } From 4ba9365e0f398b9cec0dbb9f8950b23e47507c28 Mon Sep 17 00:00:00 2001 From: William Fulton Date: Sun, 19 May 2013 00:44:06 +0100 Subject: [PATCH 192/273] Fix ccache-swig internal error bug due to premature file cleanup Fixes SF bug 1319 which shows up as a failure in the ccache tests on Debian 64 bit Wheezy, possibly because ENABLE_ZLIB is defined. This bug is due to files being too aggressively cleaned up part way through the caching. The .stderr file is cached and then retrieved from the cache for displaying to stderr. However, the stats are updated between caching and using the .stderr file. During the stats update the cache is cleaned and the newly cached files can be removed if the max number of files per directory is low. Really the cache should be cleaned up at exit to solve this (as is done in ccache-3.1). The workaround fix ensures the cached files are ignored during cleanup, which is a bit tricky as sometimes files from a previous run have the same time stamp, so that don't appear to be the oldest in the cache. --- CCache/ccache.h | 2 +- CCache/cleanup.c | 28 ++++++++++++++++++++++++---- CCache/stats.c | 3 ++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CCache/ccache.h b/CCache/ccache.h index 668ce8288..3c3e22311 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -159,7 +159,7 @@ int asprintf(char **ptr, const char *format, ...); int snprintf(char *,size_t ,const char *, ...); #endif -void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize); +void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize, size_t minfiles); void cleanup_all(const char *dir); void wipe_all(const char *dir); diff --git a/CCache/cleanup.c b/CCache/cleanup.c index 99312283e..f54ee54d9 100644 --- a/CCache/cleanup.c +++ b/CCache/cleanup.c @@ -75,21 +75,40 @@ static void traverse_fn(const char *fname, struct stat *st) /* sort the files we've found and delete the oldest ones until we are below the thresholds */ -static void sort_and_clean(void) +static void sort_and_clean(size_t minfiles) { unsigned i; + size_t adjusted_minfiles = minfiles; if (num_files > 1) { /* sort in ascending data order */ qsort(files, num_files, sizeof(struct files *), (COMPAR_FN_T)files_compare); } + /* ensure newly cached files (minfiles) are kept - instead of matching + the filenames of those newly cached, a faster and simpler approach + assumes these are the most recent in the cache and if any other + cached files have an identical time stamp, they will also be kept - + this approach would not be needed if the cleanup was done at exit. */ + if (minfiles != 0 && minfiles < num_files) { + unsigned minfiles_index = num_files - minfiles; + time_t minfiles_time = files[minfiles_index]->mtime; + for (i=1; i<=minfiles_index; i++) { + if (files[minfiles_index-i]->mtime == minfiles_time) + adjusted_minfiles++; + else + break; + } + } /* delete enough files to bring us below the threshold */ for (i=0;ifname) != 0 && errno != ENOENT) { fprintf(stderr, "unlink %s - %s\n", files[i]->fname, strerror(errno)); @@ -103,7 +122,7 @@ static void sort_and_clean(void) } /* cleanup in one cache subdir */ -void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize) +void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize, size_t minfiles) { unsigned i; @@ -117,7 +136,7 @@ void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize) traverse(dir, traverse_fn); /* clean the cache */ - sort_and_clean(); + sort_and_clean(minfiles); stats_set_sizes(dir, total_files, total_size); @@ -151,7 +170,8 @@ void cleanup_all(const char *dir) cleanup_dir(dname, counters[STATS_MAXFILES], - counters[STATS_MAXSIZE]); + counters[STATS_MAXSIZE], + 0); free(dname); free(sfile); } diff --git a/CCache/stats.c b/CCache/stats.c index 92bc4a835..d2122bcd3 100644 --- a/CCache/stats.c +++ b/CCache/stats.c @@ -168,7 +168,8 @@ static void stats_update_size(enum stats stat, size_t size, size_t numfiles) if (need_cleanup) { char *p = dirname(stats_file); - cleanup_dir(p, counters[STATS_MAXFILES], counters[STATS_MAXSIZE]); + cleanup_dir(p, counters[STATS_MAXFILES], counters[STATS_MAXSIZE], + numfiles); free(p); } } From 149972542ed42753ff3d67c98c46020f7df94e5c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 19 May 2013 01:16:23 +0100 Subject: [PATCH 193/273] Add note on ccache-swig internal error bug due to premature file cleanup to changes file --- CHANGES.current | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index eb3b0a8d1..3d41780c2 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.10 (in progress) ============================ +2013-05-19: wsfulton + Fix ccache-swig internal error bug due to premature file cleanup. + + Fixes SF bug 1319 which shows up as a failure in the ccache tests on + Debian 64 bit Wheezy, possibly because ENABLE_ZLIB is defined. + + This is a corner case which will be hit when the maximum number of files + in the cache is set to be quite low (-F option), resulting in a cache miss. + 2013-05-09: kwwette [Octave] Fix bugs in Octave module loading: - fix a memory leak in setting of global variables From 6e794da3f3d74cef1a049780d0dab40a1a4326b3 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Tue, 21 May 2013 17:23:37 +0200 Subject: [PATCH 194/273] Guile port example - print a message to show the error is expected --- Examples/guile/port/runme.scm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/guile/port/runme.scm b/Examples/guile/port/runme.scm index 68e9b8e85..1a9b93038 100644 --- a/Examples/guile/port/runme.scm +++ b/Examples/guile/port/runme.scm @@ -21,6 +21,8 @@ (lambda () (print-int (current-output-port) 314159)))) (lambda args + (display "Attempting to write to a string or soft port will result in this error:") + (newline) (write args) (newline))) ;; Read from a file port. Note that it is a bad idea to mix Scheme and From 0f1e3da5deae77c100ed3d72243208d63ae4c1db Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 23 May 2013 19:30:58 +0100 Subject: [PATCH 195/273] Fix the high passed to PyTuple_GetSlice in varargs wrappers. Harmless bug as slices can take any size larger than the actual size for the high value. Reported in SF Bug 1326. --- .../test-suite/python/python_varargs_typemap_runme.py | 3 +++ Examples/test-suite/python_varargs_typemap.i | 8 ++++++-- Source/Modules/python.cxx | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/python/python_varargs_typemap_runme.py b/Examples/test-suite/python/python_varargs_typemap_runme.py index 3c3f042eb..79479e449 100644 --- a/Examples/test-suite/python/python_varargs_typemap_runme.py +++ b/Examples/test-suite/python/python_varargs_typemap_runme.py @@ -2,3 +2,6 @@ import python_varargs_typemap if (python_varargs_typemap.testfunc(1, 2.0, "three") != "three") : raise RuntimeError("testfunc failed!") + +if (python_varargs_typemap.testfunc(1, 2.0, "three", "four", "five") != "threefourfive") : + raise RuntimeError("testfunc failed!") diff --git a/Examples/test-suite/python_varargs_typemap.i b/Examples/test-suite/python_varargs_typemap.i index 4bc6f3fbd..09189f654 100644 --- a/Examples/test-suite/python_varargs_typemap.i +++ b/Examples/test-suite/python_varargs_typemap.i @@ -51,10 +51,14 @@ char* testfunc (int arg1, double arg2, ...) { va_list ap; char *c; + static char buffer[1024]; + buffer[0] = 0; va_start(ap, arg2); - c = va_arg(ap, char*); + while ((c = va_arg(ap, char *))) { + strcat(buffer, c); + } va_end(ap); - return c; + return buffer; } } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index e3d8c7d50..9a068a40a 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2614,7 +2614,7 @@ public: Printf(f->code, "}\n"); } else { Printf(f->code, "newargs = PyTuple_GetSlice(args,0,%d);\n", num_fixed_arguments); - Printf(f->code, "varargs = PyTuple_GetSlice(args,%d,PyTuple_Size(args)+1);\n", num_fixed_arguments); + Printf(f->code, "varargs = PyTuple_GetSlice(args,%d,PyTuple_Size(args));\n", num_fixed_arguments); } Printf(f->code, "resultobj = %s__varargs__(%s,newargs,varargs);\n", wname, builtin ? "self" : "NULL"); Append(f->code, "Py_XDECREF(newargs);\n"); From 8700e79b3e6036898475c436d0ad291254eb42de Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 23 May 2013 23:24:19 +0100 Subject: [PATCH 196/273] Guile port example fix for Guile 2.0 Rewinding the file before passing it to C fixed the problem of not being able to read the file contents. Also explain the error about writing to a string. --- Examples/guile/port/runme.scm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Examples/guile/port/runme.scm b/Examples/guile/port/runme.scm index 1a9b93038..3ff447eff 100644 --- a/Examples/guile/port/runme.scm +++ b/Examples/guile/port/runme.scm @@ -21,14 +21,15 @@ (lambda () (print-int (current-output-port) 314159)))) (lambda args - (display "Attempting to write to a string or soft port will result in this error:") + (display "Below shows that attempting to write to a string or soft port will result in a wrong-type-error...") (newline) (write args) (newline))) ;; Read from a file port. Note that it is a bad idea to mix Scheme and -;; C input because of buffering. +;; C input because of buffering, hence the call to seek to rewind the file. (with-input-from-file "test.out" (lambda () + (seek (current-input-port) 0 SEEK_SET) (display (read-int (current-input-port))) (newline))) From 074c0039db34009e0ba138f958719197feae5581 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 24 May 2013 18:57:26 +0100 Subject: [PATCH 197/273] Fix Python version checking in Python tests --- Examples/test-suite/python/autodoc_runme.py | 2 +- Examples/test-suite/python/file_test_runme.py | 2 +- Examples/test-suite/python/li_std_containers_int_runme.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index 634b2dccf..5776ad3ef 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -122,7 +122,7 @@ check(A.func3static.__doc__, "\n" " " ) -if sys.version[0:2] > (2, 4): +if sys.version_info[0:2] > (2, 4): # Python 2.4 does not seem to work check(A.variable_a.__doc__, "A_variable_a_get(self) -> int") check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int") diff --git a/Examples/test-suite/python/file_test_runme.py b/Examples/test-suite/python/file_test_runme.py index 3d8b153db..9b94fa3b3 100644 --- a/Examples/test-suite/python/file_test_runme.py +++ b/Examples/test-suite/python/file_test_runme.py @@ -1,7 +1,7 @@ import sys import file_test -if sys.version[0:2] > (3, 0): +if sys.version_info[0:2] < (3, 0): file_test.nfile(sys.stdout) cstdout = file_test.GetStdOut() 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 f18e33812..3cbbb2862 100644 --- a/Examples/test-suite/python/li_std_containers_int_runme.py +++ b/Examples/test-suite/python/li_std_containers_int_runme.py @@ -78,7 +78,7 @@ def container_insert_step(i, j, step, newval): il_error = e # Python 2.6 contains bug fixes in extended slicing syntax: http://docs.python.org/2/whatsnew/2.6.html - skip_check = ps_error != None and(iv_error == il_error == None) and step > 0 and (sys.version[0:2] < (2, 6)) + skip_check = ps_error != None and(iv_error == il_error == None) and step > 0 and (sys.version_info[0:2] < (2, 6)) if not(skip_check): 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) From f15eb3f5ec3ee77d521d675f42654edde9c46509 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 24 May 2013 22:51:27 +0100 Subject: [PATCH 198/273] Fix vararg documentation for Python 3 Memory handling is different to Python 2. --- Doc/Manual/Varargs.html | 32 +++++++++++++------ .../python/python_varargs_typemap_runme.py | 2 +- Examples/test-suite/python_varargs_typemap.i | 28 +++++++++------- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index a580c83bd..9564fe00b 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -509,10 +509,10 @@ like this:
    -%typemap(in) (...)(char *args[10]) {
    +%typemap(in) (...)(char *vargs[10]) {
       int i;
       int argc;
    -  for (i = 0; i < 10; i++) args[i] = 0;
    +  for (i = 0; i < 10; i++) vargs[i] = 0;
       argc = PyTuple_Size(varargs);
       if (argc > 10) {
         PyErr_SetString(PyExc_ValueError, "Too many arguments");
    @@ -528,7 +528,7 @@ like this:
            return NULL;
         }
         pystr = PyUnicode_AsUTF8String(pyobj);
    -    str = PyBytes_AsString(pystr);
    +    str = strdup(PyBytes_AsString(pystr));
         Py_XDECREF(pystr);
     %#else  
         if (!PyString_Check(pyobj)) {
    @@ -537,22 +537,34 @@ like this:
         }
         str = PyString_AsString(pyobj);
     %#endif
    -    args[i] = str;
    +    vargs[i] = str;
       }
    -  $1 = (void *) args;
    +  $1 = (void *)vargs;
    +}
    +
    +%typemap(freearg) (...) {
    +%#if PY_VERSION_HEX>=0x03000000
    +  int i;
    +  for (i = 0; i < 10; i++) {
    +    free(vargs$argnum[i]);
    +  }
    +%#endif
     }
     

    -In this typemap, the special variable varargs is a tuple +In the 'in' typemap, the special variable varargs is a tuple holding all of the extra arguments passed (this is specific to the Python module). The typemap then pulls this apart and sticks the values into the array of strings args. Then, the array is assigned to $1 (recall that this is the void * variable corresponding to (...)). However, this assignment is only half of the picture----clearly this alone is not enough to -make the function work. To patch everything up, you have to rewrite the +make the function work. The 'freearg' typemap cleans up memory +allocated in the 'in' typemap; this code is generated to be called +after the execlp function is called. To patch everything +up, you have to rewrite the underlying action code using the %feature directive like this:

    @@ -560,9 +572,9 @@ this:
     %feature("action") execlp {
    -   char *args = (char **) arg3;
    -   result = execlp(arg1, arg2, args[0], args[1], args[2], args[3], args[4],
    -                   args[5],args[6],args[7],args[8],args[9], NULL);
    +  char **vargs = (char **) arg3;
    +  result = execlp(arg1, arg2, vargs[0], vargs[1], vargs[2], vargs[3], vargs[4],
    +                  vargs[5], vargs[6], vargs[7], vargs[8], vargs[9], NULL);
     }
     
     int execlp(const char *path, const char *arg, ...);
    diff --git a/Examples/test-suite/python/python_varargs_typemap_runme.py b/Examples/test-suite/python/python_varargs_typemap_runme.py
    index 79479e449..65be757c8 100644
    --- a/Examples/test-suite/python/python_varargs_typemap_runme.py
    +++ b/Examples/test-suite/python/python_varargs_typemap_runme.py
    @@ -4,4 +4,4 @@ if (python_varargs_typemap.testfunc(1, 2.0, "three") != "three") :
         raise RuntimeError("testfunc failed!")
     
     if (python_varargs_typemap.testfunc(1, 2.0, "three", "four", "five") != "threefourfive") :
    -    raise RuntimeError("testfunc failed!")
    +    raise RuntimeError("testfunc failed! {}")
    diff --git a/Examples/test-suite/python_varargs_typemap.i b/Examples/test-suite/python_varargs_typemap.i
    index 09189f654..09deea3b7 100644
    --- a/Examples/test-suite/python_varargs_typemap.i
    +++ b/Examples/test-suite/python_varargs_typemap.i
    @@ -4,13 +4,10 @@
       * chapter of the SWIG manual.
       */
     
    -%{
    -%}
    -
    -%typemap(in) (...)(char *args[10]) {
    +%typemap(in) (...)(char *vargs[10]) {
       int i;
       int argc;
    -  for (i = 0; i < 10; i++) args[i] = 0;
    +  for (i = 0; i < 10; i++) vargs[i] = 0;
       argc = PyTuple_Size(varargs);
       if (argc > 10) {
         PyErr_SetString(PyExc_ValueError, "Too many arguments");
    @@ -26,7 +23,7 @@
            return NULL;
         }
         pystr = PyUnicode_AsUTF8String(pyobj);
    -    str = PyBytes_AsString(pystr);
    +    str = strdup(PyBytes_AsString(pystr));
         Py_XDECREF(pystr);
     %#else  
         if (!PyString_Check(pyobj)) {
    @@ -35,15 +32,24 @@
         }
         str = PyString_AsString(pyobj);
     %#endif
    -    args[i] = str;
    +    vargs[i] = str;
       }
    -  $1 = (void *) args;
    +  $1 = (void *)vargs;
     }
     
     %feature("action") testfunc {
    -  char **args = (char **) arg3;
    -  result = testfunc(arg1, arg2, args[0], args[1], args[2], args[3], args[4],
    -                    args[5],args[6],args[7],args[8],args[9], NULL);
    +  char **vargs = (char **) arg3;
    +  result = testfunc(arg1, arg2, vargs[0], vargs[1], vargs[2], vargs[3], vargs[4],
    +                    vargs[5], vargs[6], vargs[7], vargs[8], vargs[9], NULL);
    +}
    +
    +%typemap(freearg) (...) {
    +%#if PY_VERSION_HEX>=0x03000000
    +  int i;
    +  for (i = 0; i < 10; i++) {
    +    free(vargs$argnum[i]);
    +  }
    +%#endif
     }
     
     %inline {
    
    From 030b97c891ce13a66801632e875169a2485413c6 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Sat, 25 May 2013 00:15:48 +0100
    Subject: [PATCH 199/273] Documentation sectioning update
    
    ---
     Doc/Manual/Contents.html | 3 +--
     1 file changed, 1 insertion(+), 2 deletions(-)
    
    diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
    index ac21bcd1e..32fa32e96 100644
    --- a/Doc/Manual/Contents.html
    +++ b/Doc/Manual/Contents.html
    @@ -828,8 +828,7 @@
     
  • Typemaps
  • Representation of pointers as smobs
  • Exception Handling From 3357ee85cd7de581b78b28839e8dc5229d6c99ab Mon Sep 17 00:00:00 2001 From: Artem Serebriyskiy Date: Fri, 24 May 2013 13:34:37 +0400 Subject: [PATCH 200/273] Fix all attributes macroses --- Lib/typemaps/attribute.swg | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Lib/typemaps/attribute.swg b/Lib/typemaps/attribute.swg index 214133edc..d30b51183 100644 --- a/Lib/typemaps/attribute.swg +++ b/Lib/typemaps/attribute.swg @@ -195,42 +195,42 @@ %define %attribute(Class, AttributeType, AttributeName, GetMethod, SetMethod...) #if #SetMethod != "" - %attribute_custom(Class, AttributeType, AttributeName, GetMethod, SetMethod, self_->GetMethod(), self_->SetMethod(val_)) + %attribute_custom(%arg(Class), AttributeType, AttributeName, GetMethod, SetMethod, self_->GetMethod(), self_->SetMethod(val_)) #else - %attribute_readonly(Class, AttributeType, AttributeName, GetMethod, self_->GetMethod()) + %attribute_readonly(%arg(Class), AttributeType, AttributeName, GetMethod, self_->GetMethod()) #endif %enddef %define %attribute2(Class, AttributeType, AttributeName, GetMethod, SetMethod...) #if #SetMethod != "" - %attribute_custom(Class, AttributeType, AttributeName, GetMethod, SetMethod, &self_->GetMethod(), self_->SetMethod(*val_)) + %attribute_custom(%arg(Class), AttributeType, AttributeName, GetMethod, SetMethod, &self_->GetMethod(), self_->SetMethod(*val_)) #else - %attribute_readonly(Class, AttributeType, AttributeName, GetMethod, &self_->GetMethod()) + %attribute_readonly(%arg(Class), AttributeType, AttributeName, GetMethod, &self_->GetMethod()) #endif %enddef %define %attributeref(Class, AttributeType, AttributeName, AccessorMethod...) #if #AccessorMethod != "" - %attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) + %attribute_custom(%arg(Class), AttributeType, AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #else - %attribute_custom(Class, AttributeType, AttributeName, AttributeName, AttributeName, self_->AttributeName(), self_->AttributeName() = val_) + %attribute_custom(%arg(Class), AttributeType, AttributeName, AttributeName, AttributeName, self_->AttributeName(), self_->AttributeName() = val_) #endif %enddef %define %attribute2ref(Class, AttributeType, AttributeName, AccessorMethod...) #if #AccessorMethod != "" - %attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) + %attribute_custom(%arg(Class), AttributeType, AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) #else - %attribute_custom(Class, AttributeType, AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_) + %attribute_custom(%arg(Class), AttributeType, AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_) #endif %enddef // deprecated (same as %attributeref, but there is an argument order inconsistency) %define %attribute_ref(Class, AttributeType, AccessorMethod, AttributeName...) #if #AttributeName != "" - %attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) + %attribute_custom(%arg(Class), AttributeType, AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #else - %attribute_custom(Class, AttributeType, AccessorMethod, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) + %attribute_custom(%arg(Class), AttributeType, AccessorMethod, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #endif %enddef From c956c4c87f1bd84ff0b3b1e78b4d8bd9487134c4 Mon Sep 17 00:00:00 2001 From: Artem Serebriyskiy Date: Fri, 24 May 2013 13:37:00 +0400 Subject: [PATCH 201/273] Fix %arg in Lib/attribute.i --- Lib/attribute.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/attribute.i b/Lib/attribute.i index 0cc3ff1a3..d580dbfe9 100644 --- a/Lib/attribute.i +++ b/Lib/attribute.i @@ -11,7 +11,7 @@ #define %attribute_exception(code,msg) printf("%s\n",msg) #ifndef %arg -#define %arg(x) x +#define %arg(x...) x #endif #ifndef %mangle From 3e188e508d877e9c459a4fa09425456c17d7cf97 Mon Sep 17 00:00:00 2001 From: Artem Serebriyskiy Date: Sat, 25 May 2013 02:08:26 +0400 Subject: [PATCH 202/273] Add test case for attributes with moderately complex templates * New test case tests that %attribute macros correctly supports passing template with multiple parameters as class name or attribute type name * Some further changes were made to %attribute macros - now AttributeType is protected with %arg as well. This allows you to have attributes of type e.g. std::pair etc Update CHANGES file for %attribute template fixes Closes #48 --- CHANGES.current | 4 + Examples/test-suite/common.mk | 1 + Examples/test-suite/li_attribute_template.i | 110 ++++++++++++++++++ .../python/li_attribute_template_runme.py | 67 +++++++++++ Lib/typemaps/attribute.swg | 20 ++-- 5 files changed, 192 insertions(+), 10 deletions(-) create mode 100644 Examples/test-suite/li_attribute_template.i create mode 100644 Examples/test-suite/python/li_attribute_template_runme.py diff --git a/CHANGES.current b/CHANGES.current index 3d41780c2..565a4ec0f 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.10 (in progress) ============================ +2013-05-25: Artem Serebriyskiy + SVN Patch ticket #338 - fixes to %attribute macros for template usage + with %arg. + 2013-05-19: wsfulton Fix ccache-swig internal error bug due to premature file cleanup. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 793055097..9a335b46e 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -238,6 +238,7 @@ CPP_TEST_CASES += \ kind \ langobj \ li_attribute \ + li_attribute_template \ li_boost_shared_ptr \ li_boost_shared_ptr_bits \ li_boost_shared_ptr_template \ diff --git a/Examples/test-suite/li_attribute_template.i b/Examples/test-suite/li_attribute_template.i new file mode 100644 index 000000000..3d4c108ef --- /dev/null +++ b/Examples/test-suite/li_attribute_template.i @@ -0,0 +1,110 @@ +%module li_attribute_template + +%include + +//#define SWIG_ATTRIBUTE_TEMPLATE +%include +%include + +%inline +{ + class Foo { + public: + Foo( int _value ) { value = _value; } + int value; + }; + + template< class T1, class T2> + struct pair{ + pair( T1 t1, T2 t2 ): + first(t1), second(t2) {;} + + T1 first; + T2 second; + }; + + template< class T1, class T2> + struct C + { + C(int a, int b, int c) : + _a(a), _b(b), _c(c), _d(a), _e(b), + _f(a,b), _g(b,c) + { + +/* + _f.first = _a; + _f.second = _b; + + _g.first = _b; + _g.second = _c; +*/ + + } + + int get_value() const + { + return _a; + } + + void set_value(int aa) + { + _a = aa; + } + + /* only one ref method */ + int& get_ref() + { + return _b; + } + + Foo get_class_value() const { return _d; } + void set_class_value( Foo foo) { _d = foo; } + + const Foo& get_class_ref() const { return _e; } + void set_class_ref( const Foo& foo ) { _e = foo; } + + pair get_template_value() const { return _f; } + void set_template_value( const pair f ) { _f = f; } + + const pair& get_template_ref() const { return _g; } + void set_template_ref( const pair& g ) { _g = g; } + + std::string get_string() { return str; } + void set_string(std::string other) { str = other; } + + private: + int _a; + int _b; + int _c; + Foo _d; + Foo _e; + pair _f; + pair _g; + + std::string str; + }; + +} + +%define %instantiate_C( T1, T2 ) +%template (pair_ ## T1 ## T2 ) pair; +// Primitive types +%attribute( %arg(C), int, a, get_value, set_value ); +%attributeref( %arg(C), int, b, get_ref ); + +// Strings +%attributestring(%arg(C), std::string, str, get_string, set_string); + +// Class types +%attributeval( %arg(C), Foo, d, get_class_value, set_class_value ); +%attribute2( %arg(C), Foo, e, get_class_ref, set_class_ref ); + +// Moderately templated types +%attributeval( %arg(C), %arg(pair), f, get_template_value, set_template_value ); +%attribute2( %arg(C), %arg(pair), g, get_template_ref, set_template_ref ); + +%template (C ## T1 ## T2) C; +%enddef + + +%instantiate_C(int,int); diff --git a/Examples/test-suite/python/li_attribute_template_runme.py b/Examples/test-suite/python/li_attribute_template_runme.py new file mode 100644 index 000000000..7423053f9 --- /dev/null +++ b/Examples/test-suite/python/li_attribute_template_runme.py @@ -0,0 +1,67 @@ +# Check usage of template attributes + +import li_attribute_template + +chell = li_attribute_template.Cintint(1,2,3) + +def rassert( what, master ): + if what != master: + print what + raise RuntimeError + +## Testing primitive by value attribute +rassert( chell.a, 1 ) + +chell.a = 3 +rassert( chell.a, 3 ) + +## Testing primitive by ref attribute + +rassert( chell.b, 2 ) + +chell.b = 5 +rassert( chell.b,5 ) + +## Testing string +chell.str = "abc" +rassert( chell.str, "abc" ) + +# Testing class by value + +rassert( chell.d.value, 1 ) + +chell.d = li_attribute_template.Foo(2) +rassert( chell.d.value, 2 ) + +# Testing class by reference + +rassert( chell.e.value, 2 ) + +chell.e= li_attribute_template.Foo(3) +rassert( chell.e.value, 3 ) + +chell.e.value = 4 +rassert( chell.e.value, 4 ) + +# Testing moderately complex template by value +rassert( chell.f.first, 1 ) +rassert( chell.f.second, 2 ) + +pair = li_attribute_template.pair_intint(3,4) +chell.f = pair +rassert( chell.f.first, 3 ) +rassert( chell.f.second, 4 ) + +# Testing moderately complex template by ref +rassert( chell.g.first, 2 ) +rassert( chell.g.second, 3 ) + +pair = li_attribute_template.pair_intint(4,5) +chell.g = pair +rassert( chell.g.first, 4 ) +rassert( chell.g.second, 5 ) + +chell.g.first = 6 +chell.g.second = 7 +rassert( chell.g.first, 6 ) +rassert( chell.g.second, 7 ) diff --git a/Lib/typemaps/attribute.swg b/Lib/typemaps/attribute.swg index d30b51183..46fc80fd2 100644 --- a/Lib/typemaps/attribute.swg +++ b/Lib/typemaps/attribute.swg @@ -195,42 +195,42 @@ %define %attribute(Class, AttributeType, AttributeName, GetMethod, SetMethod...) #if #SetMethod != "" - %attribute_custom(%arg(Class), AttributeType, AttributeName, GetMethod, SetMethod, self_->GetMethod(), self_->SetMethod(val_)) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, SetMethod, self_->GetMethod(), self_->SetMethod(val_)) #else - %attribute_readonly(%arg(Class), AttributeType, AttributeName, GetMethod, self_->GetMethod()) + %attribute_readonly(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, self_->GetMethod()) #endif %enddef %define %attribute2(Class, AttributeType, AttributeName, GetMethod, SetMethod...) #if #SetMethod != "" - %attribute_custom(%arg(Class), AttributeType, AttributeName, GetMethod, SetMethod, &self_->GetMethod(), self_->SetMethod(*val_)) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, SetMethod, &self_->GetMethod(), self_->SetMethod(*val_)) #else - %attribute_readonly(%arg(Class), AttributeType, AttributeName, GetMethod, &self_->GetMethod()) + %attribute_readonly(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, &self_->GetMethod()) #endif %enddef %define %attributeref(Class, AttributeType, AttributeName, AccessorMethod...) #if #AccessorMethod != "" - %attribute_custom(%arg(Class), AttributeType, AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #else - %attribute_custom(%arg(Class), AttributeType, AttributeName, AttributeName, AttributeName, self_->AttributeName(), self_->AttributeName() = val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AttributeName, AttributeName, self_->AttributeName(), self_->AttributeName() = val_) #endif %enddef %define %attribute2ref(Class, AttributeType, AttributeName, AccessorMethod...) #if #AccessorMethod != "" - %attribute_custom(%arg(Class), AttributeType, AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) #else - %attribute_custom(%arg(Class), AttributeType, AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_) #endif %enddef // deprecated (same as %attributeref, but there is an argument order inconsistency) %define %attribute_ref(Class, AttributeType, AccessorMethod, AttributeName...) #if #AttributeName != "" - %attribute_custom(%arg(Class), AttributeType, AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #else - %attribute_custom(%arg(Class), AttributeType, AccessorMethod, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AccessorMethod, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #endif %enddef From 5481270c2a53add0cf9f7a01044a25a6b3013aaf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 25 May 2013 10:36:14 +0100 Subject: [PATCH 203/273] Fix Python 3 inconsistency handling -ve numbers for unsigned C types. An OverFlow error is now consistently thrown instead of a TypeError. Fixes primitive_types testcase for Python 3 --- CHANGES.current | 5 +++ .../python/primitive_types_runme.py | 42 +++++++++++++++++-- Lib/python/pyprimtypes.swg | 12 ++++++ 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 565a4ec0f..fe11a2952 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.10 (in progress) ============================ +2013-05-25: wsfulton + [Python] Fix Python 3 inconsistency when negative numbers are passed + where a parameter expects an unsigned C type. An OverFlow error is + now consistently thrown instead of a TypeError. + 2013-05-25: Artem Serebriyskiy SVN Patch ticket #338 - fixes to %attribute macros for template usage with %arg. diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py index 2495cd60d..be8d38bad 100644 --- a/Examples/test-suite/python/primitive_types_runme.py +++ b/Examples/test-suite/python/primitive_types_runme.py @@ -275,10 +275,22 @@ try: except TypeError: if a != t.var_char: error = 1 - pass + pass if error: raise RuntimeError, "bad char typemap" +try: + error = 0 + a = t.var_ushort + t.var_ushort = -1 + error = 1 +except OverflowError: + if a != t.var_ushort: + error = 1 + pass +if error: + raise RuntimeError, "bad ushort typemap" + try: error = 0 a = t.var_uint @@ -287,10 +299,34 @@ try: except OverflowError: if a != t.var_uint: error = 1 - pass + pass if error: raise RuntimeError, "bad uint typemap" +try: + error = 0 + a = t.var_sizet + t.var_sizet = -1 + error = 1 +except OverflowError: + if a != t.var_sizet: + error = 1 + pass +if error: + raise RuntimeError, "bad sizet typemap" + +try: + error = 0 + a = t.var_ulong + t.var_ulong = -1 + error = 1 +except OverflowError: + if a != t.var_ulong: + error = 1 + pass +if error: + raise RuntimeError, "bad ulong typemap" + # # try: @@ -301,7 +337,7 @@ try: except TypeError: if a != t.var_namet: error = 1 - pass + pass if error: raise RuntimeError, "bad namet typemap" diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg index 3fbd86a21..66ff104a6 100644 --- a/Lib/python/pyprimtypes.swg +++ b/Lib/python/pyprimtypes.swg @@ -127,6 +127,18 @@ SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val) return SWIG_OK; } else { PyErr_Clear(); +%#if PY_VERSION_HEX >= 0x03000000 + { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (v < 0) { + return SWIG_OverflowError; + } + } else { + PyErr_Clear(); + } + } +%#endif } } %#ifdef SWIG_PYTHON_CAST_MODE From fd93beadf4283b7394aa470e8a7040df3a30bcb3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 25 May 2013 22:29:18 +0100 Subject: [PATCH 204/273] Fix 'make check-python-test-suite PY3=1' and -j (make jobs) --- Examples/test-suite/python/Makefile.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 43ba2717e..fa64d5e31 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -112,17 +112,17 @@ VALGRIND_OPT += --suppressions=pythonswig.supp %.cpptest: $(setup) +$(swig_and_compile_cpp) - $(run_testcase) + +$(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) - $(run_testcase) + +$(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) - $(run_testcase) + +$(run_testcase) # Call 2to3 to generate Python 3.x test from the Python 2.x's *_runme.py file From b3ca22dc339ca18873079bd96bbb19dd00bc8f0a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 26 May 2013 22:34:07 +0100 Subject: [PATCH 205/273] Fix Python examples to compile and run under Python 3 --- Examples/python/index.html | 17 ++--------- Examples/python/multimap/example.i | 47 +++++++++++++++++++++++------- Examples/python/varargs/example.i | 10 +++++-- Examples/python/varargs/runme.py | 7 +++-- 4 files changed, 51 insertions(+), 30 deletions(-) diff --git a/Examples/python/index.html b/Examples/python/index.html index 8443a85e1..37f4b55af 100644 --- a/Examples/python/index.html +++ b/Examples/python/index.html @@ -89,21 +89,10 @@ to look at the distutils

    Compatibility

    -The examples have been extensively tested on the following platforms: - -
      -
    • Linux -
    • Solaris -
    - -All of the examples were last tested with the following configuration (9/1/2000): - -
      -
    • Sparc Solaris 2.8. -
    • gcc-2.95.2 -
    • Python 1.6b1. -
    +For Python 3, set the environment variable PY3=1. +This will ensure the 2to3 program is run prior to running any example. +

    Your mileage may vary. If you experience a problem, please let us know by contacting us on the mailing lists. diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i index f1c4d9990..3f6fc3db3 100644 --- a/Examples/python/multimap/example.i +++ b/Examples/python/multimap/example.i @@ -38,27 +38,44 @@ extern int gcd(int x, int y); } %#if PY_VERSION_HEX >= 0x03000000 { - int l; - $2[i] = PyUnicode_AsStringAndSize(s, &l); + PyObject *utf8str = PyUnicode_AsUTF8String(s); + const char *cstr = PyBytes_AsString(utf8str); + $2[i] = strdup(cstr); + Py_DECREF(utf8str); } %#else $2[i] = PyString_AsString(s); %#endif - } $2[i] = 0; } +%typemap(freearg) (int argc, char *argv[]) { +%#if PY_VERSION_HEX >= 0x03000000 + int i; + for (i = 0; i < $1; i++) { + free($2[i]); + } +%#endif +} + extern int gcdmain(int argc, char *argv[]); %typemap(in) (char *bytes, int len) { %#if PY_VERSION_HEX >= 0x03000000 + char *cstr; + Py_ssize_t len; + PyObject *utf8str; if (!PyUnicode_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a string"); return NULL; } - $1 = PyUnicode_AsStringAndSize($input, &$2); + utf8str = PyUnicode_AsUTF8String($input); + PyBytes_AsStringAndSize(utf8str, &cstr, &len); + $1 = strndup(cstr, (size_t)len); + $2 = (int)len; + Py_DECREF(utf8str); %#else if (!PyString_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a string"); @@ -69,6 +86,12 @@ extern int gcdmain(int argc, char *argv[]); %#endif } +%typemap(freearg) (char *bytes, int len) { +%#if PY_VERSION_HEX >= 0x03000000 + free($1); +%#endif +} + extern int count(char *bytes, int len, char c); @@ -79,13 +102,17 @@ extern int count(char *bytes, int len, char c); %typemap(in) (char *str, int len) { %#if PY_VERSION_HEX >= 0x03000000 - $2 = PyUnicode_GetSize($input); - $1 = (char *) malloc($2+1); - memmove($1,PyUnicode_AsString($input),$2); + char *cstr; + Py_ssize_t len; + PyObject *utf8str = PyUnicode_AsUTF8String($input); + PyBytes_AsStringAndSize(utf8str, &cstr, &len); + $1 = strndup(cstr, (size_t)len); + $2 = (int)len; + Py_DECREF(utf8str); %#else - $2 = PyString_Size($input); - $1 = (char *) malloc($2+1); - memmove($1,PyString_AsString($input),$2); + $2 = PyString_Size($input); + $1 = (char *) malloc($2+1); + memmove($1,PyString_AsString($input),$2); %#endif } diff --git a/Examples/python/varargs/example.i b/Examples/python/varargs/example.i index 6cb88f5f4..a581bca5d 100644 --- a/Examples/python/varargs/example.i +++ b/Examples/python/varargs/example.i @@ -32,9 +32,6 @@ int printf(const char *fmt, ...); } #endif -/* Typemap just to make the example work */ -%typemap(in) FILE * "$1 = PyFile_AsFile($input);"; - int fprintf(FILE *, const char *fmt, ...); /* Here is somewhat different example. A variable length argument @@ -48,6 +45,13 @@ int fprintf(FILE *, const char *fmt, ...); %varargs(20, char *x = NULL) printv; %inline %{ + +/* In Python 2 we could use PyFile_AsFile for converting Python sys.stdout to C's stdout. + This API disappeared in Python 3, so instead we use a helper function to get stdout */ +FILE * stdout_stream(void) { + return stdout; +} + void printv(char *s, ...) { va_list ap; char *x; diff --git a/Examples/python/varargs/runme.py b/Examples/python/varargs/runme.py index a01cb6769..8eab77041 100644 --- a/Examples/python/varargs/runme.py +++ b/Examples/python/varargs/runme.py @@ -13,13 +13,14 @@ for i in range(0,10): # This will probably be garbled because %d is interpreted by C example.printf("The value is %d\n") +stdout = example.stdout_stream() # Call fprintf -example.fprintf(sys.stdout,"Hello World. I'm fprintf\n") +example.fprintf(stdout,"Hello World. I'm fprintf\n") for i in range(0,10): - example.fprintf(sys.stdout,"i is %d\n" % i) + example.fprintf(stdout,"i is %d\n" % i) # This won't be garbled since %d is not interpreted -example.fprintf(sys.stdout,"The value is %d\n") +example.fprintf(stdout,"The value is %d\n") # This function calls our NULL-terminated function From 2004b9fc0370a2134153ba6227422aced19f35f8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 26 May 2013 23:58:12 +0100 Subject: [PATCH 206/273] Add Python 3 Travis tests --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7d7204b6a..13502de0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,8 @@ matrix: env: SWIGLANG=php - compiler: gcc env: SWIGLANG=python + - compiler: gcc + env: SWIGLANG=python PY3=1 - compiler: gcc env: SWIGLANG=ruby - compiler: gcc @@ -40,6 +42,7 @@ before_install: - if test "$SWIGLANG" = "lua"; then sudo apt-get -qq install lua5.1 liblua5.1-dev; fi - if test "$SWIGLANG" = "octave"; then sudo apt-get -qq install octave3.2 octave3.2-headers; fi - if test "$SWIGLANG" = "php"; then sudo apt-get install php5-cli php5-dev; fi + - if test "$SWIGLANG" = "python" -a "$PY3"; then sudo apt-get install python3-dev; fi - if test "$SWIGLANG" = "tcl"; then sudo apt-get -qq install tcl8.4-dev; fi script: - ./autogen.sh && ./configure From af8f77a627cce49422cced96666c739b7f4c1032 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 27 May 2013 00:27:31 +0100 Subject: [PATCH 207/273] Fix to ensure 2to3 for Python 3 examples is run --- Examples/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 5d521f5a1..280923df2 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -366,7 +366,7 @@ endif PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` -python_run: +python_run: $(PYSCRIPT) $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE) $(RUNME)3.py: $(RUNME).py From 72f2d8ac8f417ace9706897d15a90749d5a7bc3a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 27 May 2013 10:24:02 +0100 Subject: [PATCH 208/273] Fix Python test-suite makefile to show which tests have runtime tests (for Python 3). --- Examples/test-suite/python/Makefile.in | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index fa64d5e31..5e8388311 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -110,19 +110,22 @@ VALGRIND_OPT += --suppressions=pythonswig.supp # Rules for the different types of tests %.cpptest: + +$(convert_testcase) $(setup) +$(swig_and_compile_cpp) - +$(run_testcase) + $(run_testcase) %.ctest: + +$(convert_testcase) $(setup) +$(swig_and_compile_c) - +$(run_testcase) + $(run_testcase) %.multicpptest: + +$(convert_testcase) $(setup) +$(swig_and_compile_multi_cpp) - +$(run_testcase) + $(run_testcase) # Call 2to3 to generate Python 3.x test from the Python 2.x's *_runme.py file @@ -139,17 +142,17 @@ run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PY py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) -ifeq (,$(PY3)) run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(run_python);\ fi + +ifeq (,$(PY3)) +convert_testcase = else -run_testcase = \ +convert_testcase = \ if [ -f $(py2_runme) ]; then \ - $(MAKE) -f $(srcdir)/Makefile $(py3_runme) && $(run_python); \ - elif [ -f $(py3_runme) ]; then \ - $(run_python); \ + $(MAKE) -f $(srcdir)/Makefile $(py3_runme); \ fi endif From 1524d02e1316e6dedfb0dbd9f26765172dde4f1c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 27 May 2013 19:15:42 +0100 Subject: [PATCH 209/273] Add swig-2.0.10 release date and release notes --- ANNOUNCE | 2 +- CHANGES.current | 2 +- Doc/Manual/Sections.html | 2 +- README | 2 +- RELEASENOTES | 11 +++++++++++ 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 1c3297a5c..b8c852dfa 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 2.0.10 (in progress) *** +*** ANNOUNCE: SWIG 2.0.10 (27 May 2013) *** http://www.swig.org diff --git a/CHANGES.current b/CHANGES.current index fe11a2952..215fdb203 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,7 +2,7 @@ Below are the changes for the current release. See the CHANGES file for changes in older releases. See the RELEASENOTES file for a summary of changes in each release. -Version 2.0.10 (in progress) +Version 2.0.10 (27 May 2013) ============================ 2013-05-25: wsfulton diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 9e4a3dd17..5212c9301 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

    SWIG-2.0 Documentation

    -Last update : SWIG-2.0.10 (in progress) +Last update : SWIG-2.0.10 (27 May 2013)

    Sections

    diff --git a/README b/README index 444643a0d..a79b6b84f 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 2.0.10 (in progress) +Version: 2.0.10 (27 May 2013) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, diff --git a/RELEASENOTES b/RELEASENOTES index af9f4fb6b..49eacf28a 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -4,6 +4,17 @@ and CHANGES files. Release Notes ============= +SWIG-2.0.10 summary: +- Ruby 1.9 support is now complete. +- Add support for Guile 2.0 and Guile 1.6 support (GH interface) has + been dropped. +- Various small language neutral improvements and fixes. +- Various bug fixes and minor improvements specific to C#, CFFI, D, + Java, Octave, PHP, Python, +- Minor bug fix in ccache-swig. +- Development has moved to Github with Travis continuous integration + testing - patches using https://github.com/swig/swig are welcome. + SWIG-2.0.9 summary: - Improved typemap matching. - Ruby 1.9 support is much improved. From 8e89cad271a8c021e05abda2b0a72d4ef2aac0a4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 27 May 2013 20:27:50 +0100 Subject: [PATCH 210/273] Bump version to 2.0.11 --- ANNOUNCE | 2 +- CHANGES | 237 +++++++++++++++++++++++++++++++++++++++ CHANGES.current | 236 +------------------------------------- Doc/Manual/Sections.html | 2 +- README | 2 +- configure.ac | 2 +- 6 files changed, 242 insertions(+), 239 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index b8c852dfa..1c3297a5c 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 2.0.10 (27 May 2013) *** +*** ANNOUNCE: SWIG 2.0.10 (in progress) *** http://www.swig.org diff --git a/CHANGES b/CHANGES index 8b1945ad9..488bf7286 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,243 @@ SWIG (Simplified Wrapper and Interface Generator) See the CHANGES.current file for changes in the current version. See the RELEASENOTES file for a summary of changes in each release. +Version 2.0.10 (27 May 2013) +============================ + +2013-05-25: wsfulton + [Python] Fix Python 3 inconsistency when negative numbers are passed + where a parameter expects an unsigned C type. An OverFlow error is + now consistently thrown instead of a TypeError. + +2013-05-25: Artem Serebriyskiy + SVN Patch ticket #338 - fixes to %attribute macros for template usage + with %arg. + +2013-05-19: wsfulton + Fix ccache-swig internal error bug due to premature file cleanup. + + Fixes SF bug 1319 which shows up as a failure in the ccache tests on + Debian 64 bit Wheezy, possibly because ENABLE_ZLIB is defined. + + This is a corner case which will be hit when the maximum number of files + in the cache is set to be quite low (-F option), resulting in a cache miss. + +2013-05-09: kwwette + [Octave] Fix bugs in Octave module loading: + - fix a memory leak in setting of global variables + - install functions only once, to speed up module loads + +2013-04-28: gjanssens + [Guile] Updates in guile module: + - Add support for guile 2.0 + - Drop support for guile 1.6 + - Drop support for generating wrappers using guile's gh interface. + All generated wrappers will use the scm interface from now on. + - Deprecate -gh and -scm options. They are no longer needed. + A warning will be issued when these options are still used. + - Fix all tests and examples to have a successful travis test + +2013-04-18: wsfulton + Apply Patch #36 from Jesus Lopez to add support for $descriptor() special variable macro expansion + in fragments. For example: + + %fragment("nameDescriptor", "header") + %{ + static const char *nameDescriptor = "$descriptor(Name)"; + %} + + which will generate into the wrapper if the fragment is used: + + static const char *nameDescriptor = "SWIGTYPE_Name"; + +2013-04-18: wsfulton + Fix SF Bug #428 - Syntax error when preprocessor macros are defined inside of enum lists, such as: + + typedef enum { + eZero = 0 + #define ONE 1 + } EFoo; + + The macros are silently ignored. + +2013-04-17: wsfulton + [C#] Pull patch #34 from BrantKyser to fix smart pointers in conjuction with directors. + +2013-04-15: kwwette + [Octave] Fix bugs in output of cleanup code. + - Cleanup code is now written also after the "fail:" label, so it will be called if + a SWIG_exception is raised by the wrapping function, consistent with other modules. + - Octave module now also recognises the "$cleanup" special variable, if needed. + +2013-04-08: kwwette + Add -MP option to SWIG for generating phony targets for all dependencies. + - Prevents make from complaining if header files have been deleted before + the dependency file has been updated. + - Modelled on similar option in GCC. + +2013-04-09: olly + [PHP] Add missing directorin typemap for char* and char[] which + fixes director_string testcase failure. + +2013-04-05: wsfulton + [Ruby] SF Bug #1292 - Runtime fixes for Proc changes in ruby-1.9 when using STL + wrappers that override the default predicate, such as: + + %template(Map) std::map >; + +2013-04-05: wsfulton + [Ruby] SF Bug #1159 - Correctly check rb_respond_to call return values to fix some + further 1.9 problems with functors and use of Complex wrappers. + +2013-04-02: wsfulton + [Ruby] Runtime fixes for std::complex wrappers for ruby-1.9 - new native Ruby complex numbers are used. + +2013-03-30: wsfulton + [Ruby] Fix seg fault when using STL containers of generic Ruby types, GC_VALUE or LANGUAGE_OBJECT, + on exit of the Ruby interpreter. More frequently observed in ruby-1.9. + +2013-03-29: wsfulton + [Ruby] Fix delete_if (reject!) for the STL container wrappers which previously would + sometimes seg fault or not work. + +2013-03-25: wsfulton + [Python] Fix some undefined behaviour deleting slices in the STL containers. + +2013-03-19: wsfulton + [C#, Java, D] Fix seg fault in SWIG using directors when class and virtual method names are + the same except being in different namespaces when the %nspace feature is not being used. + +2013-02-19: kwwette + Fix bug in SWIG's handling of qualified (e.g. const) variables of array type. Given the typedef + a(7).q(volatile).double myarray // typedef volatile double[7] myarray; + the type + q(const).myarray // const myarray + becomes + a(7).q(const volatile).double // const volatile double[7] + Previously, SwigType_typedef_resolve() produces the type + q(const).a(7).q(volatile).double // non-sensical type + which would never match %typemap declarations, whose types were parsed correctly. + Add typemap_array_qualifiers.i to the test suite which checks for the correct behaviour. + +2013-02-18: wsfulton + Deprecate typedef names used as constructor and destructor names in %extend. The real + class/struct name should be used. + + typedef struct tagEStruct { + int ivar; + } EStruct; + + %extend tagEStruct { + EStruct() // illegal name, should be tagEStruct() + { + EStruct *s = new EStruct(); + s->ivar = ivar0; + return s; + } + ~EStruct() // illegal name, should be ~tagEStruct() + { + delete $self; + } + } + + For now these trigger a warning: + + extend_constructor_destructor.i:107: Warning 522: Use of an illegal constructor name 'EStruct' in + %extend is deprecated, the constructor name should be 'tagEStruct'. + extend_constructor_destructor.i:111: Warning 523: Use of an illegal destructor name 'EStruct' in + %extend is deprecated, the destructor name should be 'tagEStruct'. + + These %extend destructor and constructor names were valid up to swig-2.0.4, however swig-2.0.5 ignored + them altogether for C code as reported in SF bug #1306. The old behaviour of using them has been + restored for now, but is officially deprecated. This does not apply to anonymously defined typedef + classes/structs such as: + + typedef struct {...} X; + +2013-02-17: kwwette + When generating functions provided by %extend, use "(void)" for no-argument functions + instead of "()". This prevents warnings when compiling with "gcc -Wstrict-prototypes". + +2013-02-17: kwwette + [Octave] Minor fix to autodoc generation: get the right type for functions returning structs. + +2013-02-15: wsfulton + Deprecate typedef names used in %extend that are not the real class/struct name. For example: + + typedef struct StructBName { + int myint; + } StructB; + + %extend StructB { + void method() {} + } + + will now trigger a warning: + + swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name StructBName + should be used instead of the typedef name StructB. + + This is only partially working anyway (the %extend only worked if placed after the class + definition). + +2013-02-09: wsfulton + [CFFI] Apply patch #22 - Fix missing package before &body + +2013-01-29: wsfulton + [Java] Ensure 'javapackage' typemap is used as it stopped working from version 2.0.5. + +2013-01-28: wsfulton + [Python] Apply patch SF #334 - Fix default value conversions "TRUE"->True, "FALSE"->False. + +2013-01-28: wsfulton + [Java] Apply patch SF #335 - Truly ignore constructors in directors with %ignore. + +2013-01-18: Brant Kyser + [Java] Patch #15 - Allow the use of the nspace feature without the -package commandline option. + This works as long and the new jniclasspackage pragma is used to place the JNI intermediate class + into a package and the nspace feature is used to place all exposed types into a package. + +2013-01-15: wsfulton + Fix Visual Studio examples to work when SWIG is unzipped into a directory containing spaces. + +2013-01-15: wsfulton + [C#] Fix cstype typemap lookup for member variables so that a fully qualified variable name + matches. For example: + %typemap(cstype) bool MVar::mvar "MyBool" + struct MVar { + bool mvar; + }; + +2013-01-11: Brant Kyser + [Java, C#, D] SF Bug #1299 - Fix generated names for when %nspace is used on + classes with the same name in two different namespaces. + +2013-01-11: Vladimir Kalinin + [C#] Add support for csdirectorin 'pre', 'post' and 'terminator' attributes. + +2013-01-08: olly + [PHP] Fix to work with a ZTS build of PHP (broken in 2.0.7). + +2013-01-07: olly + Fix bashism in configure, introduced in 2.0.9. + +2013-01-06: wsfulton + Pull patch #4 from ptomulik to fix SF Bug #1296 - Fix incorrect warning for virtual destructors + in templates, such as: + Warning 521: Illegal destructor name B< A >::~B(). Ignored. + +2013-01-05: wsfulton + [Python] Pull patch #3 from ptomulik to fix SF Bug #1295 - standard exceptions as + classes using the SWIG_STD_EXCEPTIONS_AS_CLASSES macro. + +2013-01-04: wsfulton + [Java] Pull patch #2 from BrantKyser to fix SF Bug #1283 - fix smart pointers in conjuction + with directors. + +2013-01-03: wsfulton + [Java] Pull patch #1 from BrantKyser to fix SF Bug #1278 - fix directors and nspace feature when + multilevel namespaces are used. + Version 2.0.9 (16 December 2012) ================================ diff --git a/CHANGES.current b/CHANGES.current index 215fdb203..98166efca 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,240 +2,6 @@ Below are the changes for the current release. See the CHANGES file for changes in older releases. See the RELEASENOTES file for a summary of changes in each release. -Version 2.0.10 (27 May 2013) +Version 2.0.11 (in progress) ============================ -2013-05-25: wsfulton - [Python] Fix Python 3 inconsistency when negative numbers are passed - where a parameter expects an unsigned C type. An OverFlow error is - now consistently thrown instead of a TypeError. - -2013-05-25: Artem Serebriyskiy - SVN Patch ticket #338 - fixes to %attribute macros for template usage - with %arg. - -2013-05-19: wsfulton - Fix ccache-swig internal error bug due to premature file cleanup. - - Fixes SF bug 1319 which shows up as a failure in the ccache tests on - Debian 64 bit Wheezy, possibly because ENABLE_ZLIB is defined. - - This is a corner case which will be hit when the maximum number of files - in the cache is set to be quite low (-F option), resulting in a cache miss. - -2013-05-09: kwwette - [Octave] Fix bugs in Octave module loading: - - fix a memory leak in setting of global variables - - install functions only once, to speed up module loads - -2013-04-28: gjanssens - [Guile] Updates in guile module: - - Add support for guile 2.0 - - Drop support for guile 1.6 - - Drop support for generating wrappers using guile's gh interface. - All generated wrappers will use the scm interface from now on. - - Deprecate -gh and -scm options. They are no longer needed. - A warning will be issued when these options are still used. - - Fix all tests and examples to have a successful travis test - -2013-04-18: wsfulton - Apply Patch #36 from Jesus Lopez to add support for $descriptor() special variable macro expansion - in fragments. For example: - - %fragment("nameDescriptor", "header") - %{ - static const char *nameDescriptor = "$descriptor(Name)"; - %} - - which will generate into the wrapper if the fragment is used: - - static const char *nameDescriptor = "SWIGTYPE_Name"; - -2013-04-18: wsfulton - Fix SF Bug #428 - Syntax error when preprocessor macros are defined inside of enum lists, such as: - - typedef enum { - eZero = 0 - #define ONE 1 - } EFoo; - - The macros are silently ignored. - -2013-04-17: wsfulton - [C#] Pull patch #34 from BrantKyser to fix smart pointers in conjuction with directors. - -2013-04-15: kwwette - [Octave] Fix bugs in output of cleanup code. - - Cleanup code is now written also after the "fail:" label, so it will be called if - a SWIG_exception is raised by the wrapping function, consistent with other modules. - - Octave module now also recognises the "$cleanup" special variable, if needed. - -2013-04-08: kwwette - Add -MP option to SWIG for generating phony targets for all dependencies. - - Prevents make from complaining if header files have been deleted before - the dependency file has been updated. - - Modelled on similar option in GCC. - -2013-04-09: olly - [PHP] Add missing directorin typemap for char* and char[] which - fixes director_string testcase failure. - -2013-04-05: wsfulton - [Ruby] SF Bug #1292 - Runtime fixes for Proc changes in ruby-1.9 when using STL - wrappers that override the default predicate, such as: - - %template(Map) std::map >; - -2013-04-05: wsfulton - [Ruby] SF Bug #1159 - Correctly check rb_respond_to call return values to fix some - further 1.9 problems with functors and use of Complex wrappers. - -2013-04-02: wsfulton - [Ruby] Runtime fixes for std::complex wrappers for ruby-1.9 - new native Ruby complex numbers are used. - -2013-03-30: wsfulton - [Ruby] Fix seg fault when using STL containers of generic Ruby types, GC_VALUE or LANGUAGE_OBJECT, - on exit of the Ruby interpreter. More frequently observed in ruby-1.9. - -2013-03-29: wsfulton - [Ruby] Fix delete_if (reject!) for the STL container wrappers which previously would - sometimes seg fault or not work. - -2013-03-25: wsfulton - [Python] Fix some undefined behaviour deleting slices in the STL containers. - -2013-03-19: wsfulton - [C#, Java, D] Fix seg fault in SWIG using directors when class and virtual method names are - the same except being in different namespaces when the %nspace feature is not being used. - -2013-02-19: kwwette - Fix bug in SWIG's handling of qualified (e.g. const) variables of array type. Given the typedef - a(7).q(volatile).double myarray // typedef volatile double[7] myarray; - the type - q(const).myarray // const myarray - becomes - a(7).q(const volatile).double // const volatile double[7] - Previously, SwigType_typedef_resolve() produces the type - q(const).a(7).q(volatile).double // non-sensical type - which would never match %typemap declarations, whose types were parsed correctly. - Add typemap_array_qualifiers.i to the test suite which checks for the correct behaviour. - -2013-02-18: wsfulton - Deprecate typedef names used as constructor and destructor names in %extend. The real - class/struct name should be used. - - typedef struct tagEStruct { - int ivar; - } EStruct; - - %extend tagEStruct { - EStruct() // illegal name, should be tagEStruct() - { - EStruct *s = new EStruct(); - s->ivar = ivar0; - return s; - } - ~EStruct() // illegal name, should be ~tagEStruct() - { - delete $self; - } - } - - For now these trigger a warning: - - extend_constructor_destructor.i:107: Warning 522: Use of an illegal constructor name 'EStruct' in - %extend is deprecated, the constructor name should be 'tagEStruct'. - extend_constructor_destructor.i:111: Warning 523: Use of an illegal destructor name 'EStruct' in - %extend is deprecated, the destructor name should be 'tagEStruct'. - - These %extend destructor and constructor names were valid up to swig-2.0.4, however swig-2.0.5 ignored - them altogether for C code as reported in SF bug #1306. The old behaviour of using them has been - restored for now, but is officially deprecated. This does not apply to anonymously defined typedef - classes/structs such as: - - typedef struct {...} X; - -2013-02-17: kwwette - When generating functions provided by %extend, use "(void)" for no-argument functions - instead of "()". This prevents warnings when compiling with "gcc -Wstrict-prototypes". - -2013-02-17: kwwette - [Octave] Minor fix to autodoc generation: get the right type for functions returning structs. - -2013-02-15: wsfulton - Deprecate typedef names used in %extend that are not the real class/struct name. For example: - - typedef struct StructBName { - int myint; - } StructB; - - %extend StructB { - void method() {} - } - - will now trigger a warning: - - swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name StructBName - should be used instead of the typedef name StructB. - - This is only partially working anyway (the %extend only worked if placed after the class - definition). - -2013-02-09: wsfulton - [CFFI] Apply patch #22 - Fix missing package before &body - -2013-01-29: wsfulton - [Java] Ensure 'javapackage' typemap is used as it stopped working from version 2.0.5. - -2013-01-28: wsfulton - [Python] Apply patch SF #334 - Fix default value conversions "TRUE"->True, "FALSE"->False. - -2013-01-28: wsfulton - [Java] Apply patch SF #335 - Truly ignore constructors in directors with %ignore. - -2013-01-18: Brant Kyser - [Java] Patch #15 - Allow the use of the nspace feature without the -package commandline option. - This works as long and the new jniclasspackage pragma is used to place the JNI intermediate class - into a package and the nspace feature is used to place all exposed types into a package. - -2013-01-15: wsfulton - Fix Visual Studio examples to work when SWIG is unzipped into a directory containing spaces. - -2013-01-15: wsfulton - [C#] Fix cstype typemap lookup for member variables so that a fully qualified variable name - matches. For example: - %typemap(cstype) bool MVar::mvar "MyBool" - struct MVar { - bool mvar; - }; - -2013-01-11: Brant Kyser - [Java, C#, D] SF Bug #1299 - Fix generated names for when %nspace is used on - classes with the same name in two different namespaces. - -2013-01-11: Vladimir Kalinin - [C#] Add support for csdirectorin 'pre', 'post' and 'terminator' attributes. - -2013-01-08: olly - [PHP] Fix to work with a ZTS build of PHP (broken in 2.0.7). - -2013-01-07: olly - Fix bashism in configure, introduced in 2.0.9. - -2013-01-06: wsfulton - Pull patch #4 from ptomulik to fix SF Bug #1296 - Fix incorrect warning for virtual destructors - in templates, such as: - Warning 521: Illegal destructor name B< A >::~B(). Ignored. - -2013-01-05: wsfulton - [Python] Pull patch #3 from ptomulik to fix SF Bug #1295 - standard exceptions as - classes using the SWIG_STD_EXCEPTIONS_AS_CLASSES macro. - -2013-01-04: wsfulton - [Java] Pull patch #2 from BrantKyser to fix SF Bug #1283 - fix smart pointers in conjuction - with directors. - -2013-01-03: wsfulton - [Java] Pull patch #1 from BrantKyser to fix SF Bug #1278 - fix directors and nspace feature when - multilevel namespaces are used. - diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 5212c9301..9e4a3dd17 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

    SWIG-2.0 Documentation

    -Last update : SWIG-2.0.10 (27 May 2013) +Last update : SWIG-2.0.10 (in progress)

    Sections

    diff --git a/README b/README index a79b6b84f..444643a0d 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 2.0.10 (27 May 2013) +Version: 2.0.10 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, diff --git a/configure.ac b/configure.ac index c94c2e962..616610eda 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. dnl The macros which aren't shipped with the autotools are stored in the dnl Tools/config directory in .m4 files. -AC_INIT([swig],[2.0.10],[http://www.swig.org]) +AC_INIT([swig],[2.0.11],[http://www.swig.org]) dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED dnl definition below can be removed From 918c64af842810a6f59605953c94d5a967530af8 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 1 May 2013 17:48:08 +1200 Subject: [PATCH 211/273] Fix comment typos --- Source/Swig/misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 05dd0c480..efa397878 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -205,8 +205,8 @@ String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) { /* ----------------------------------------------------------------------------- * Swig_filename_correct() * - * Corrects filename paths by removing duplicate delimeters and on non-unix - * systems use the correct delimeter across the whole name. + * Corrects filename paths by removing duplicate delimiters and on non-unix + * systems use the correct delimiter across the whole name. * ----------------------------------------------------------------------------- */ void Swig_filename_correct(String *filename) { From abfa75b169a839909a4abef4f3a4ca8616fccc5d Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 4 Jun 2013 12:53:27 +1200 Subject: [PATCH 212/273] [PHP] Fix SWIG_ZTS_ConvertResourcePtr() not to dereference NULL if the type lookup fails. --- CHANGES.current | 4 ++++ Lib/php/phprun.swg | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 98166efca..208c99f68 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,3 +5,7 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.11 (in progress) ============================ +2013-06-04: olly + [PHP] Fix SWIG_ZTS_ConvertResourcePtr() not to dereference NULL + if the type lookup fails. + diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index 92f2f3fe5..a4188cc7c 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -209,11 +209,11 @@ SWIG_ZTS_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags TSRMLS_DC) { const char *type_name; value = (swig_object_wrapper *) zend_list_find(z->value.lval, &type); - if ( flags & SWIG_POINTER_DISOWN ) { + if (type==-1) return NULL; + if (flags & SWIG_POINTER_DISOWN) { value->newobject = 0; } p = value->ptr; - if (type==-1) return NULL; type_name=zend_rsrc_list_get_rsrc_type(z->value.lval TSRMLS_CC); From c9295401da4fc2feb9aee1c73932c1bdb22513be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Tomulik?= Date: Tue, 28 May 2013 15:47:43 +0200 Subject: [PATCH 213/273] clean all .py files generated by python-test-suite Closes #49 --- Examples/test-suite/python/Makefile.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 5e8388311..e7db32fb7 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -58,7 +58,7 @@ CPP_TEST_CASES += \ li_std_wstream \ li_std_wstring \ primitive_types \ - python_abstractbase \ + python_abstractbase \ python_append \ python_director \ python_nondynamic \ @@ -165,6 +165,9 @@ endif clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py + rm -f clientdata_prop_a.py clientdata_prop_b.py import_stl_a.py import_stl_b.py + rm -f imports_a.py imports_b.py mod_a.py mod_b.py multi_import_a.py + rm -f multi_import_b.py packageoption_a.py packageoption_b.py packageoption_c.py cvsignore: @echo '*wrap* *.pyc *.so *.dll *.exp *.lib' From 3834036e138339650917a4b320029a7d01629681 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Jun 2013 19:56:38 +0100 Subject: [PATCH 214/273] Fix Ruby regression with missing rb_complex_new function. Affects Ruby versions prior to 1.9 using std::complex wrappers if just using std::complex as an output type. Also fix the Complex helper functions external visibility (to static by default). Closes #52 --- CHANGES.current | 5 +++++ Lib/ruby/rubycomplex.swg | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 208c99f68..4b0633c22 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.11 (in progress) ============================ +2013-07-07: wsfulton + [Ruby] Git issue #52. Fix regression with missing rb_complex_new function for Ruby + versions prior to 1.9 using std::complex wrappers if just using std::complex as an output type. + Also fix the Complex helper functions external visibility (to static by default). + 2013-06-04: olly [PHP] Fix SWIG_ZTS_ConvertResourcePtr() not to dereference NULL if the type lookup fails. diff --git a/Lib/ruby/rubycomplex.swg b/Lib/ruby/rubycomplex.swg index 542051e99..4e249c71f 100644 --- a/Lib/ruby/rubycomplex.swg +++ b/Lib/ruby/rubycomplex.swg @@ -7,34 +7,39 @@ See the std_complex.i and ccomplex.i for concrete examples. */ -%fragment("SWIG_Complex_Numbers","header") +%fragment("rb_complex_new","header") { %#if !defined(T_COMPLEX) /* Ruby versions prior to 1.9 did not have native complex numbers. They were an extension in the STD library. */ -VALUE rb_complex_new(VALUE x, VALUE y) { +SWIGINTERN VALUE rb_complex_new(VALUE x, VALUE y) { static ID new_id = rb_intern("new"); static VALUE cComplex = rb_const_get(rb_cObject, rb_intern("Complex")); return rb_funcall(cComplex, new_id, 2, x, y); } +%#endif +} -static int SWIG_Is_Complex( VALUE obj ) { +%fragment("SWIG_Complex_Numbers","header") +{ +%#if !defined(T_COMPLEX) +SWIGINTERN int SWIG_Is_Complex( VALUE obj ) { static ID real_id = rb_intern("real"); static ID imag_id = rb_intern("imag"); return ( (rb_respond_to( obj, real_id ) ) && (rb_respond_to( obj, imag_id ) ) ); } %#else -static int SWIG_Is_Complex( VALUE obj ) { +SWIGINTERN int SWIG_Is_Complex( VALUE obj ) { return TYPE(obj) == T_COMPLEX; } %#endif -VALUE SWIG_Complex_Real(VALUE obj) { +SWIGINTERN VALUE SWIG_Complex_Real(VALUE obj) { static ID real_id = rb_intern("real"); return rb_funcall(obj, real_id, 0); } -VALUE SWIG_Complex_Imaginary(VALUE obj) { +SWIGINTERN VALUE SWIG_Complex_Imaginary(VALUE obj) { static ID imag_id = rb_intern("imag"); return rb_funcall(obj, imag_id, 0); } @@ -48,7 +53,7 @@ VALUE SWIG_Complex_Imaginary(VALUE obj) { /* the common from converter */ %define %swig_fromcplx_conv(Type, Real, Imag) -%fragment(SWIG_From_frag(Type),"header") +%fragment(SWIG_From_frag(Type),"header",fragment="rb_complex_new") { SWIGINTERNINLINE VALUE SWIG_From(Type)(%ifcplusplus(const Type&, Type) c) From 5766f1913234362c1bd5e29f9d80295c67d5f43f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Jun 2013 20:18:28 +0100 Subject: [PATCH 215/273] Remove lines with just spaces on them in Ruby docs --- Doc/Manual/Ruby.html | 6510 ------------------------------------------ 1 file changed, 6510 deletions(-) diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 9739e1109..d1dcbfab0 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -144,10 +144,6 @@

    This chapter describes SWIG's support of Ruby.

    - - - -

    36.1 Preliminaries

    @@ -157,123 +153,59 @@ should also determine if your system supports shared libraries and dynamic loading. SWIG will work with or without dynamic loading, but the compilation process will vary.

    - - - -

    This chapter covers most SWIG features, but in less depth than is found in earlier chapters. At the very least, make sure you also read the "SWIG Basics" chapter. It is also assumed that the reader has a basic understanding of Ruby.

    - - - -

    36.1.1 Running SWIG

    To build a Ruby module, run SWIG using the -ruby option:

    - - - -
    $ swig -ruby example.i
     
    - - - - -
    - - - -

    If building a C++ extension, add the -c++ option:

    - - - -
    $ swig -c++ -ruby example.i
     
    - - - - -
    - - - -

    This creates a file example_wrap.c (example_wrap.cxx if compiling a C++ extension) that contains all of the code needed to build a Ruby extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

    - - - -

    36.1.2 Getting the right header files

    In order to compile the wrapper code, the compiler needs the ruby.h header file. This file is usually contained in a directory such as

    - - - -
    /usr/lib/ruby/1.8/x86_64-linux-gnu/ruby.h
     /usr/local/lib/ruby/1.6/i686-linux/ruby.h
     
    - - - - -
    - - - -

    The exact location may vary on your machine, but the above location is typical. If you are not entirely sure where Ruby is installed, you can run Ruby to find out. For example:

    - - - -
    $ ruby -e 'puts $:.join("\n")'
     /usr/local/lib/ruby/site_ruby/1.6 /usr/local/lib/ruby/site_ruby/1.6/i686-linux
     /usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .
     
    - - - - -
    - - - -

    36.1.3 Compiling a dynamic module

    @@ -283,100 +215,28 @@ exact commands for doing this vary from platform to platform, your best bet is to follow the steps described in the README.EXT file from the Ruby distribution:

    - - - -
      - - - - -
    1. - - - -

      Create a file called extconf.rb that looks like the following:

      - - - - - - - - -
      require 'mkmf'
      create_makefile('example')
      - - - - -
    2. - - - - -
    3. - - - -

      Type the following to build the extension:

      - - - - - - - - -
      - - - -
      $ ruby extconf.rb
      $ make
      $ make install
      - - - - -
      - - - - -
    4. - - - - -
    - - - -

    Of course, there is the problem that mkmf does not work correctly on all platforms, e.g, HPUX. If you need to add your own make rules to the file that extconf.rb produces, you can add this:

    - - - -
    open("Makefile", "a") { |mf|
      puts <<EOM
    @@ -384,17 +244,8 @@ can add this: 

    EOM }
    - - - - -
    - - - -

    to the end of the extconf.rb file. If for some reason you don't want to use the standard approach, you'll need to determine the correct compiler and linker flags for your build @@ -402,27 +253,14 @@ platform. For example, assuming you have code you need to link to in a file called example.c, a typical sequence of commands for the Linux operating system would look something like this:

    - - - -
    $ swig -ruby example.i
     $ gcc -c example.c
     $ gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux 
     $ gcc -shared example.o example_wrap.o -o example.so
     
    - - - - -
    - - - -

    For other platforms it may be necessary to compile with the -fPIC option to generate position-independent code. If in doubt, consult the manual pages for your compiler and linker to determine the correct set @@ -437,10 +275,6 @@ but the convention for Ruby feature names is to use lowercase names. So, for example, the Etc extension module is imported by requiring the etc feature:

    - - - -
    # The feature name begins with a lowercase letter...
     require 'etc'
    @@ -448,47 +282,21 @@ require 'etc'
     # ... but the module name begins with an uppercase letter
     puts "Your login name: #{Etc.getlogin}"
     
    - - - - -
    - - - -

    To stay consistent with this practice, you should always specify a lowercase module name with SWIG's %module directive. SWIG will automatically correct the resulting Ruby module name for your extension. So for example, a SWIG interface file that begins with:

    - - - -
    %module example
    - - - - -
    - - - -

    will result in an extension module using the feature name "example" and Ruby module name "Example".

    - - - -

    36.1.5 Static linking

    @@ -499,41 +307,22 @@ loading support on certain machines. However, the situation has improved greatly over the last few years and you should not consider this approach unless there is really no other option.

    - - - -

    The usual procedure for adding a new module to Ruby involves finding the Ruby source, adding an entry to the ext/Setup file, adding your directory to the list of extensions in the file, and finally rebuilding Ruby.

    - -

    36.1.6 Compilation of C++ extensions

    On most machines, C++ extension modules should be linked using the C++ compiler. For example:

    - - - -
    $ swig -c++ -ruby example.i
    $ g++ -c example.cxx
    $ g++ -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
    $ g++ -shared example.o example_wrap.o -o example.so
    - - - - -
    - - - -

    If you've written an extconf.rb script to automatically generate a Makefile for your C++ extension module, keep in mind that (as of this writing) Ruby still @@ -545,23 +334,10 @@ module's append_library() method to add one of the C++ runtime libraries to the list of libraries linked into your extension, e.g.

    - - - -
    require 'mkmf'
    $libs = append_library($libs, "supc++")
    create_makefile('example')
    - - - - -
    - - - -

    36.2 Building Ruby Extensions under Windows 95/NT

    @@ -572,24 +348,11 @@ recent versions of Ruby, the procedure described above (i.e. using an extcon script) will work with Windows as well; you should be able to build your code into a DLL by typing:

    - - - -
    C:\swigtest> ruby extconf.rb
    C:\swigtest> nmake
    C:\swigtest> nmake install
    - - - - -
    - - - -

    The remainder of this section covers the process of compiling SWIG-generated Ruby extensions with Microsoft Visual C++ 6 (i.e. within the Developer Studio IDE, instead of using the command line tools). In @@ -597,84 +360,35 @@ order to build extensions, you may need to download the source distribution to the Ruby package, as you will need the Ruby header files.

    - - - -

    36.2.1 Running SWIG from Developer Studio

    If you are developing your application within Microsoft developer studio, SWIG can be invoked as a custom build option. The process roughly follows these steps :

    - - - - -
      - - - - -
    • Open up a new workspace and use the AppWizard to select a DLL project.
    • - - - - -
    • Add both the SWIG interface file (the .i file), any supporting C files, and the name of the wrapper file that will be created by SWIG (i.e. example_wrap.c). Note : If using C++, choose a different suffix for the wrapper file such as example_wrap.cxx. Don't worry if the wrapper file doesn't exist yet--Developer Studio will keep a reference to it around.
    • - - - - -
    • Select the SWIG interface file and go to the settings menu. Under settings, select the "Custom Build" option.
    • - - - - -
    • Enter "SWIG" in the description field.
    • - - - - -
    • Enter "swig -ruby -o $(ProjDir)\$(InputName)_wrap.c $(InputPath)" in the "Build command(s) field". You may have to include the path to swig.exe.
    • - - - - -
    • Enter "$(ProjDir)\$(InputName)_wrap.c" in the "Output files(s) field".
    • - - - - -
    • Next, select the settings for the entire project and go to the C/C++ tab and select the Preprocessor category. Add NT=1 to the Preprocessor definitions. This must be set else you will get compilation errors. Also add IMPORT to the preprocessor definitions, else you may get runtime errors. Also add the include directories for your Ruby installation under "Additional include directories".
    • - - - - -
    • Next, select the settings for the entire project and go to the Link tab and select the General category. Set the name of the output file to match the name of your Ruby module (i.e.. example.dll). @@ -682,23 +396,9 @@ Next add the Ruby library file to your link libraries under Object/Library modules. For example "mswin32-ruby16.lib. You also need to add the path to the library under the Input tab - Additional library path.
    • - - - - -
    • Build your project.
    • - - - - -
    - - - -

    Now, assuming all went well, SWIG will be automatically invoked when you build your project. Any changes made to the interface file will result in SWIG being automatically invoked to produce a new @@ -706,98 +406,42 @@ version of the wrapper file. To run your new Ruby extension, simply run Ruby and use the require command as normal. For example if you have this ruby file run.rb:

    - - - -
    # file: run.rb
    require 'Example'

    # Call a c function
    print "Foo = ", Example.Foo, "\n"
    - - - - -
    - - - -

    Ensure the dll just built is in your path or current directory, then run the Ruby script from the DOS/Command prompt:

    - - - -
    C:\swigtest> ruby run.rb
    Foo = 3.0
    - - - - -
    - - - -

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

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

    - - - -

    36.3.1 Modules

    The SWIG %module directive specifies the name of the Ruby module. If you specify:

    - - - -
    %module example
    - - - - -
    - - - -

    then everything is wrapped into a Ruby module named Example that is nested directly under the global module. You can specify a more deeply nested module by specifying the fully-qualified module name in quotes, e.g.

    - - - -
    %module "foo::bar::spam"
    - - - - -
    - - - -

    An alternate method of specifying a nested module name is to use the -prefix option on the SWIG command line. The prefix that you specify with this @@ -805,112 +449,42 @@ option will be prepended to the module name specified with the

    %module "foo::bar::spam"
    - - - - -
  • - - - -

    will result in a nested module name of Foo::Bar::Spam, but you can achieve the same effect by specifying:
    - - - - -

    - - - -
    %module spam
    - - - - -
    - - - -

    and then running SWIG with the -prefix command line option:
    - - - - -

    - - - -
    $ swig -ruby -prefix "foo::bar::" example.i
    - - - - -
    - - - -

    Starting with SWIG 1.3.20, you can also choose to wrap everything into the global module by specifying the -globalmodule option on the SWIG command line, i.e.

    - - - -
    $ swig -ruby -globalmodule example.i
    - - - - -
    - - - -

    Note that this does not relieve you of the requirement of specifying the SWIG module name with the %module directive (or the -module command-line option) as described earlier.

    - - - -

    When choosing a module name, do not use the same name as a built-in Ruby command or standard module name, as the results may be unpredictable. Similarly, if you're using the -globalmodule @@ -918,10 +492,6 @@ option to wrap everything into the global module, take care that the names of your constants, classes and methods don't conflict with any of Ruby's built-in names.

    - - - -

    36.3.2 Functions

    @@ -929,62 +499,23 @@ Ruby's built-in names.

    example, given the SWIG interface file example.i:

    - - - -
    %module example

    int fact(int n);
    - - - - -
    - - - -

    and C source file example.c:

    - - - -
    int fact(int n) {
    if (n == 0)
    return 1;
    return (n * fact(n-1));
    }
    - - - - -
    - - - -

    SWIG will generate a method fact in the Example module that can be used like so:

    - - - -
    $ irb
    irb(main):001:0> require 'example'
    true
    irb(main):002:0> Example.fact(4)
    24
    - - - - -
    - - - -

    36.3.3 Variable Linking

    @@ -993,98 +524,38 @@ methods for the module: one to get the value of the global variable and one to set it. For example, the following SWIG interface file declares two global variables:

    - - - -
    // SWIG interface file with global variables
    %module example
    ...
    %inline %{
    extern int variable1;
    extern double Variable2;
    %}
    ...
    - - - - -
    - - - -

    Now look at the Ruby interface:

    - - - -
    $ irb
    irb(main):001:0> require 'Example'
    true
    irb(main):002:0> Example.variable1 = 2
    2
    irb(main):003:0> Example.Variable2 = 4 * 10.3
    41.2
    irb(main):004:0> Example.Variable2
    41.2
    - - - - -
    - - - -

    If you make an error in variable assignment, you will receive an error message. For example:

    - - - -
    irb(main):005:0> Example.Variable2 = "hello"
    TypeError: no implicit conversion to float from string
    from (irb):5:in `Variable2='
    from (irb):5
    - - - - -
    - - - -

    If a variable is declared as const, it is wrapped as a read-only variable. Attempts to modify its value will result in an error.

    - - - -

    To make ordinary variables read-only, you can also use the %immutable directive. For example:

    - - - -
    %immutable;
    %inline %{
    extern char *path;
    %}
    %mutable;
    - - - - -
    - - - -

    The %immutable directive stays in effect until it is explicitly disabled using %mutable.

    - - - -

    36.3.4 Constants

    @@ -1092,43 +563,17 @@ effect until it is explicitly disabled using %mutable. to the appropriate value. To create a constant, use #define or the %constant directive. For example:

    - - - -
    #define PI 3.14159
    #define VERSION "1.0"

    %constant int FOO = 42;
    %constant const char *path = "/usr/local";

    const int BAR = 32;
    - - - - -
    - - - -

    Remember to use the :: operator in Ruby to get at these constant values, e.g.

    - - - -
    $ irb
    irb(main):001:0> require 'Example'
    true
    irb(main):002:0> Example::PI
    3.14159
    - - - - -
    - - - -

    36.3.5 Pointers

    @@ -1137,50 +582,20 @@ aren't explicitly declared in your SWIG interface file) are wrapped as data objects. So, for example, consider a SWIG interface file containing only the declarations:

    - - - -
    Foo *get_foo();
    void set_foo(Foo *foo);
    - - - - -
    - - - -

    For this case, the get_foo() method returns an instance of an internally generated Ruby class:

    - - - -
    irb(main):001:0> foo = Example::get_foo()
    #<SWIG::TYPE_p_Foo:0x402b1654>
    - - - - -
    - - - -

    A NULL pointer is always represented by the Ruby nil object.

    - - - -

    36.3.6 Structures

    @@ -1188,74 +603,31 @@ the Ruby nil object.

    methods (i.e. "getters" and "setters") for all of the struct members. For example, this struct declaration:

    - - - -
    struct Vector {
    double x, y;
    };
    - - - - -
    - - - -

    gets wrapped as a Vector class, with Ruby instance methods x, x=, y and y=. These methods can be used to access structure data from Ruby as follows:

    - - - -
    $ irb
    irb(main):001:0> require 'Example'
    true
    irb(main):002:0> f = Example::Vector.new
    #<Example::Vector:0x4020b268>
    irb(main):003:0> f.x = 10
    nil
    irb(main):004:0> f.x
    10.0
    - - - - -
    - - - -

    Similar access is provided for unions and the public data members of C++ classes.

    - - - -

    const members of a structure are read-only. Data members can also be forced to be read-only using the %immutable directive (in C++, private may also be used). For example:

    - - - -
    struct Foo {
    ...
    %immutable;
    int x; /* Read-only members */
    char *name;
    %mutable;
    ...
    };
    - - - - -
    - - - -

    When char * members of a structure are wrapped, the contents are assumed to be dynamically allocated using malloc or new (depending on whether or not SWIG is run @@ -1264,98 +636,38 @@ is set, the old contents will be released and a new value created. If this is not the behavior you want, you will have to use a typemap (described shortly).

    - - - -

    Array members are normally wrapped as read-only. For example, this code:

    - - - -
    struct Foo {
    int x[50];
    };
    - - - - -
    - - - -

    produces a single accessor function like this:

    - - - -
    int *Foo_x_get(Foo *self) {
    return self->x;
    };
    - - - - -
    - - - -

    If you want to set an array member, you will need to supply a "memberin" typemap described in the section on typemaps. As a special case, SWIG does generate code to set array members of type char (allowing you to store a Ruby string in the structure).

    - - - -

    When structure members are wrapped, they are handled as pointers. For example,

    - - - -
    struct Foo {
    ...
    };

    struct Bar {
    Foo f;
    };
    - - - - -
    - - - -

    generates accessor functions such as this:

    - - - -
    Foo *Bar_f_get(Bar *b) {
    return &b->f;
    }

    void Bar_f_set(Bar *b, Foo *val) {
    b->f = *val;
    }
    - - - - -
    - - - -

    36.3.7 C++ classes

    @@ -1366,152 +678,55 @@ wrapped as Ruby instance methods, and public static member functions are wrapped as Ruby singleton methods. So, given the C++ class declaration:

    - - - -
    class List {
    public:
    List();
    ~List();
    int search(char *item);
    void insert(char *item);
    void remove(char *item);
    char *get(int n);
    int length;
    static void print(List *l);
    };
    - - - - -
    - - - -

    SWIG would create a List class with:

    - - - -
      - - - - -
    • instance methods search, insert, remove, and get;
    • - - - - -
    • instance methods length and length= (to get and set the value of the length data member); and,
    • - - - - -
    • a print singleton method for the class.
    • - - - - -
    - - - -

    In Ruby, these functions are used as follows:

    - - - -
    require 'Example'

    l = Example::List.new

    l.insert("Ale")
    l.insert("Stout")
    l.insert("Lager")
    Example.print(l)
    l.length()
    ----- produces the following output
    Lager
    Stout
    Ale
    3
    - - - - -
    - - - -

    36.3.8 C++ Inheritance

    The SWIG type-checker is fully aware of C++ inheritance. Therefore, if you have classes like this:

    - - - -
    class Parent {
    ...
    };

    class Child : public Parent {
    ...
    };
    - - - - -
    - - - -

    those classes are wrapped into a hierarchy of Ruby classes that reflect the same inheritance structure. All of the usual Ruby utility methods work normally:

    - - - -
    irb(main):001:0> c = Child.new
    #<Bar:0x4016efd4>
    irb(main):002:0> c.instance_of? Child
    true
    irb(main):003:0> b.instance_of? Parent
    false
    irb(main):004:0> b.is_a? Child
    true
    irb(main):005:0> b.is_a? Parent
    true
    irb(main):006:0> Child < Parent
    true
    irb(main):007:0> Child > Parent
    false
    - - - - -
    - - - -

    Furthermore, if you have a function like this:

    - - - -
    void spam(Parent *f);
    - - - - -
    - - - -

    then the function spam() accepts Parent* or a pointer to any class derived from Parent.

    - - - -

    Until recently, the Ruby module for SWIG didn't support multiple inheritance, and this is still the default behavior. This doesn't mean that you can't wrap C++ classes which inherit from @@ -1520,23 +735,10 @@ base class listed in the class declaration is considered, and any additional base classes are ignored. As an example, consider a SWIG interface file with a declaration like this:

    - - - -
    class Derived : public Base1, public Base2
    {
    ...
    };
    - - - - -
    - - - -

    For this case, the resulting Ruby class (Derived) will only consider Base1 as its superclass. It won't inherit any of Base2's member functions or @@ -1545,66 +747,27 @@ data and it won't recognize Base2 as an relationship would fail). When SWIG processes this interface file, you'll see a warning message like:

    - - - -
    example.i:5: Warning 802: Warning for Derived: Base Base2 ignored.
    Multiple inheritance is not supported in Ruby.
    - - - - -
    - - - -

    Starting with SWIG 1.3.20, the Ruby module for SWIG provides limited support for multiple inheritance. Because the approach for dealing with multiple inheritance introduces some limitations, this is an optional feature that you can activate with the -minherit command-line option:

    - - - -
    $ swig -c++ -ruby -minherit example.i
    - - - - -
    - - - -

    Using our previous example, if your SWIG interface file contains a declaration like this:

    - - - -
    class Derived : public Base1, public Base2
    {
    ...
    };
    - - - - -
    - - - -

    and you run SWIG with the -minherit command-line option, then you will end up with a Ruby class Derived that appears to "inherit" the member data and functions from both Base1 @@ -1615,64 +778,30 @@ module named Impl, and it's in these nested Impl modules that the actual instance methods for the classes are defined, i.e.

    - - - -
    class Base1
    module Impl
    # Define Base1 methods here
    end
    include Impl
    end

    class Base2
    module Impl
    # Define Base2 methods here
    end
    include Impl
    end

    class Derived
    module Impl
    include Base1::Impl
    include Base2::Impl
    # Define Derived methods here
    end
    include Impl
    end
    - - - - -
    - - - -

    Observe that after the nested Impl module for a class is defined, it is mixed-in to the class itself. Also observe that the Derived::Impl module first mixes-in its base classes' Impl modules, thus "inheriting" all of their behavior.

    - - - -

    The primary drawback is that, unlike the default mode of operation, neither Base1 nor Base2 is a true superclass of Derived anymore:

    - - - -
    obj = Derived.new
    obj.is_a? Base1 # this will return false...
    obj.is_a? Base2 # ... and so will this
    - - - - -
    - - - -

    In most cases, this is not a serious problem since objects of type Derived will otherwise behave as though they inherit from both Base1 and Base2 (i.e. they exhibit "Duck Typing").

    - - - -

    36.3.9 C++ Overloaded Functions

    @@ -1680,199 +809,74 @@ Typing").

    mostly supported by SWIG. For example, if you have two functions like this:

    - - - -
    void foo(int);
    void foo(char *c);
    - - - - -
    - - - -

    You can use them in Ruby in a straightforward manner:

    - - - -
    irb(main):001:0> foo(3) # foo(int)
    irb(main):002:0> foo("Hello") # foo(char *c)
    - - - - -
    - - - -

    Similarly, if you have a class like this,

    - - - -
    class Foo {
    public:
    Foo();
    Foo(const Foo &);
    ...
    };
    - - - - -
    - - - -

    you can write Ruby code like this:

    - - - -
    irb(main):001:0> f = Foo.new # Create a Foo
    irb(main):002:0> g = Foo.new(f) # Copy f
    - - - - -
    - - - -

    Overloading support is not quite as flexible as in C++. Sometimes there are methods that SWIG can't disambiguate. For example:

    - - - -
    void spam(int);
    void spam(short);
    - - - - -
    - - - -

    or

    - - - -
    void foo(Bar *b);
    void foo(Bar &b);
    - - - - -
    - - - -

    If declarations such as these appear, you will get a warning message like this:

    - - - -
     example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
     example.i:11: Warning 509: as it is shadowed by spam(int).
     
    - - - - -
    - - - -

    To fix this, you either need to ignore or rename one of the methods. For example:

    - - - -
    %rename(spam_short) spam(short);
    ...
    void spam(int);
    void spam(short); // Accessed as spam_short
    - - - - -
    - - - -

    or

    - - - -
    %ignore spam(short);
    ...
    void spam(int);
    void spam(short); // Ignored
    - - - - -
    - - - -

    SWIG resolves overloaded functions and methods using a disambiguation scheme that ranks and sorts declarations according to a set of type-precedence rules. The order in which declarations appear in the input does not matter except in situations where ambiguity arises--in this case, the first declaration takes precedence.

    - - - -

    Please refer to the "SWIG and C++" chapter for more information about overloading.

    - - - -

    36.3.10 C++ Operators

    @@ -1880,80 +884,33 @@ and C++" chapter for more information about overloading.

    automatically by SWIG and do not require any special treatment on your part. So if your class declares an overloaded addition operator, e.g.

    - - - -
    class Complex {
    ...
    Complex operator+(Complex &);
    ...
    };
    - - - - -
    - - - -

    the resulting Ruby class will also support the addition (+) method correctly.

    - - - -

    For cases where SWIG's built-in support is not sufficient, C++ operators can be wrapped using the %rename directive (available on SWIG 1.3.10 and later releases). All you need to do is give the operator the name of a valid Ruby identifier. For example:

    - - - -
    %rename(add_complex) operator+(Complex &, Complex &);
    ...
    Complex operator+(Complex &, Complex &);
    - - - - -
    - - - -

    Now, in Ruby, you can do this:

    - - - -
    a = Example::Complex.new(2, 3)
    b = Example::Complex.new(4, -1)
    c = Example.add_complex(a, b)
    - - - - -
    - - - -

    More details about wrapping C++ operators into Ruby operators is discussed in the section on operator overloading.

    - - - -

    36.3.11 C++ namespaces

    @@ -1962,63 +919,24 @@ appear in the module nor do namespaces result in a module that is broken up into submodules or packages. For example, if you have a file like this,

    - - - -
    %module example

    namespace foo {
    int fact(int n);
    struct Vector {
    double x,y,z;
    };
    };
    - - - - -
    - - - -

    it works in Ruby as follows:

    - - - -
    irb(main):001:0> require 'example'
    true
    irb(main):002:0> Example.fact(3)
    6
    irb(main):003:0> v = Example::Vector.new
    #<Example::Vector:0x4016f4d4>
    irb(main):004:0> v.x = 3.4
    3.4
    irb(main):004:0> v.y
    0.0
    - - - - -
    - - - -

    If your program has more than one namespace, name conflicts (if any) can be resolved using %rename For example:

    - - - -
    %rename(Bar_spam) Bar::spam;

    namespace Foo {
    int spam();
    }

    namespace Bar {
    int spam();
    }
    - - - - -
    - - - -

    If you have more than one namespace and your want to keep their symbols separate, consider wrapping them as separate SWIG modules. For example, make the module name the same as the namespace @@ -2026,10 +944,6 @@ and create extension modules for each namespace separately. If your program utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

    - - - -

    36.3.12 C++ templates

    @@ -2038,42 +952,16 @@ in order to create wrappers, you have to tell SWIG to create wrappers for a particular template instantiation. To do this, you use the %template directive. For example:

    - - - -
    %module example

    %{
    #include "pair.h"
    %}

    template<class T1, class T2>
    struct pair {
    typedef T1 first_type;
    typedef T2 second_type;
    T1 first;
    T2 second;
    pair();
    pair(const T1&, const T2&);
    ~pair();
    };

    %template(Pairii) pair<int,int>;
    - - - - -
    - - - -

    In Ruby:

    - - - -
    irb(main):001:0> require 'example'
    true
    irb(main):002:0> p = Example::Pairii.new(3, 4)
    #<Example:Pairii:0x4016f4df>
    irb(main):003:0> p.first
    3
    irb(main):004:0> p.second
    4
    - - - - -
    - - - -

    36.3.13 C++ Standard Template Library (STL)

    @@ -2087,71 +975,28 @@ convenient for users of your extension module to pass Ruby objects of standard C++ templates. For example, suppose the C++ library you're wrapping has a function that expects a vector of floats:

    - - - -
    %module example

    float sum(const std::vector<float>& values);
    - - - - -
    - - - -

    Rather than go through the hassle of writing an "in" typemap to convert an array of Ruby numbers into a std::vector<float>, you can just use the std_vector.i module from the standard SWIG library:

    - - - -
    %module example

    %include std_vector.i
    float sum(const std::vector<float>& values);
    - - - - -
    - - - -

    Ruby's STL wrappings provide additional methods to make them behave more similarly to Ruby's native classes.

    - - - -

    Thus, you can do, for example:

    - - - -
    v = IntVector.new
    v << 2

    v << 3
    v << 4
    v.each { |x| puts x }

    => 2

    3
    4
    v.delete_if { |x| x == 3 }
    => [2,4]
    - - - - -
    - - - -

    The SWIG Ruby module provides also the ability for all the STL containers to carry around Ruby native objects (Fixnum, Classes, etc) making them act almost like Ruby's own Array, Hash, etc.   To @@ -2159,174 +1004,50 @@ do that, you need to define a container that contains a swig::GC_VALUE, like:

    - - - -
    %module nativevector
    - - - - -
    - - - - %{
    - - - - - std::vector< swig::GC_VALUE > NativeVector;
    - - - - - %}
    - - - - -
    - - - - %template(NativeVector) std::vector< swig::GC_VALUE >;
    - - - - -
    - - - -
    - - - -

    This vector can then contain any Ruby object, making them almost identical to Ruby's own Array class.

    - - - -
    require 'nativevector'
    - - - - include NativeVector
    - - - -
    - - - - v = NativeVector.new
    - - - - - v << 1
    - - - - - v << [1,2]
    - - - - - v << 'hello'
    - - - - -
    - - - - - class A; end
    - - - - -
    - - - - - v << A.new
    - - - - -
    - - - - - puts v
    - - - - - => [1, [1,2], 'hello', #<A:0x245325>]
    - - - - -
    - - - -

    Obviously, there is a lot more to template wrapping than shown in these examples. More details can be found in the SWIG and C++ chapter.

    - - - -

    36.3.14 C++ STL Functors

    @@ -2337,10 +1058,6 @@ redefined or an actual C/C++ function.  This allows you, for example, to always keep the sort order of a STL container to your liking.

    - - - -

    The Ruby STL mappings allows you to modify those containers that support functors using Ruby procs or methods, instead. @@ -2350,183 +1067,55 @@ this includes std::set, std::multiset and std::multimap.

    - - - -

    The functors in swig are called swig::UnaryFunction and swig::BinaryFunction.
    - - - - For C++ predicates (ie. functors that must return bool as a result) swig::UnaryPredicate and swig::BinaryPredicate are provided.

    - - - -

    As an example, if given this swig file:

    - - - -
    %module intset;
    - - - - -
    - - - - - %include <std_set.i>
    - - - - -
    - - - - %typemap(IntSet)  std::set< int, swig::BinaryPredicate >;
    - - - -

    You can then use the set from Ruby with or without a proc object as a predicate:

    - - - -
    require 'intset'
    - - - - include Intset
    - - - - -
    - - - - - # Default sorting behavior defined in C++
    - - - - - a = IntSet.new
    - - - - a << 1
    - - - - - a << 2
    - - - - - a << 3
    - - - - - a
    - - - - =>  [1,2,3]
    - - - - -
    - - - - # Custom sorting behavior defined by a Ruby proc
    b = IntSet.new( proc { |a,b| a > b } )
    - - - - - b << 1
    - - - - - b << 2
    - - - - - b << 3
    - - - - - b
    - - - - - =>  [3,2,1]
    - - - - -
    - - - -

    36.3.15 C++ STL Iterators

    @@ -2537,10 +1126,6 @@ iterators.  The const iterators can access and not modify the values they point at, while the non-const iterators can both read and modify the values.

    - - - -

    The Ruby STL wrappings support both type of iterators by using a proxy class in-between.  This proxy class is swig::Iterator or swig::ConstIterator.  Derived from them are template @@ -2548,10 +1133,6 @@ classes that need to be initialized with the actual iterator for the container you are wrapping and often times with the beginning and ending points of the iteration range. 

    - - - -

    The SWIG STL library already provides typemaps to all the standard containers to do this wrapping automatically for you, but if you have your own STL-like iterator, you will need to write your own @@ -2563,10 +1144,6 @@ typemap for them.  For out typemaps, the special functions - - - -

    The iterators support a next() and previous() member function to just change the iterator without returning anything.  previous() should obviously only be used for bidirectional iterators.  You @@ -2579,85 +1156,33 @@ value the iterator points at can be accessed with *i = something

    - - - -

    Thus, given say a vector class of doubles defined as:

    - - - -
    %module doublevector
    - - - -
    - - - - %include std_vector.i

    - - - -
    - - - - %template(DoubleVector) std::vector<double>;
    - - - -

    Its iterator can then be used from Ruby like:

    - - - -
    require 'doublevector'
    - - - - include Doublevector

    - - - - v = DoubleVector.new
    - - - - v << 1
    - - - - v << 2
    - - - - v << 3

    @@ -2668,76 +1193,30 @@ v << 3
    #
    - - - - i = v.begin
    - - - - e = v.end
    - - - - while i != e
    - - - -   val = i.value
    - - - -   val += 2
    - - - -   i.value = val
    - - - -   i.next
    - - - - end
    - - - i
    - - - >> [3, 4, 5 ]
    - - - -

    If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

    - - - -

    36.3.16 C++ Smart Pointers

    @@ -2746,123 +1225,45 @@ have been wrapped by so-called "smart pointers." Generally, this involves the use of a template class that implements operator->() like this:

    - - - -
    template<class T> class SmartPtr {
    ...
    T *operator->();
    ...
    }
    - - - - -
    - - - -

    Then, if you have a class like this,

    - - - -
    class Foo {
    public:
    int x;
    int bar();
    };
    - - - - -
    - - - -

    A smart pointer would be used in C++ as follows:

    - - - -
    SmartPtr<Foo> p = CreateFoo(); // Created somehow (not shown)
    ...
    p->x = 3; // Foo::x
    int y = p->bar(); // Foo::bar
    - - - - -
    - - - -

    To wrap this in Ruby, simply tell SWIG about the SmartPtr class and the low-level Foo object. Make sure you instantiate SmartPtr using %template if necessary. For example:

    - - - -
    %module example
    ...
    %template(SmartPtrFoo) SmartPtr<Foo>;
    ...
    - - - - -
    - - - -

    Now, in Ruby, everything should just "work":

    - - - -
    irb(main):001:0> p = Example::CreateFoo() # Create a smart-pointer somehow
    #<Example::SmartPtrFoo:0x4016f4df>
    irb(main):002:0> p.x = 3 # Foo::x
    3
    irb(main):003:0> p.bar() # Foo::bar
    - - - - -
    - - - -

    If you ever need to access the underlying pointer returned by operator->() itself, simply use the __deref__() method. For example:

    - - - -
    irb(main):004:0> f = p.__deref__() # Returns underlying Foo *
    - - - - -
    - - - -

    36.3.17 Cross-Language Polymorphism

    @@ -2872,10 +1273,6 @@ module. Rather than duplicate the information presented in the 36.3.17.1 Exception Unrolling @@ -2888,32 +1285,15 @@ change this behavior, you can use the %feature("director:except") directive to indicate what action should be taken when a Ruby exception is raised. The following code should suffice in most cases:

    - - - -
    %feature("director:except") {
    throw Swig::DirectorMethodException($error);
    }
    - - - - -
    - - - -

    When this feature is activated, the call to the Ruby instance method is "wrapped" using the rb_rescue2() function from Ruby's C API. If any Ruby exception is raised, it will be caught here and a C++ exception is raised in its place.

    - - - -

    36.4 Naming

    @@ -2922,94 +1302,36 @@ generally in upper case, module and class names are in camel case and methods are in lower case with underscores. For example:

    - - - -
      - - - - -
    • MATH::PI is a constant name
    • - - - - -
    • MyClass is a class name
    • - - - - -
    • my_method is a method name
    • - - - - -
    - - - - -
    - - - -

    Prior to version 1.3.28, SWIG did not support these Ruby conventions. The only modifications it made to names was to capitalize the first letter of constants (which includes module and class names).

    - - - -

    SWIG 1.3.28 introduces the new -autorename command line parameter. When this parameter is specified, SWIG will automatically change constant, class and method names to conform with the standard Ruby naming conventions. For example:

    - - - -
    $ swig -ruby -autorename example.i
     
    - - - - -
    - - - -

    To disable renaming use the -noautorename command line option.

    - - - -

    Since this change significantly changes the wrapper code generated by SWIG, it is turned off by default in SWIG 1.3.28. However, it is planned to become the default option in future releases.

    - - - -

    36.4.1 Defining Aliases

    @@ -3021,65 +1343,26 @@ approach is to use SWIG's %extend directive to add a new method of the aliased name that calls the original function. For example:

    - - - -
    class MyArray {
    public:
    // Construct an empty array
    MyArray();

    // Return the size of this array
    size_t length() const;
    };

    %extend MyArray {
    // MyArray#size is an alias for MyArray#length
    size_t size() const {
    return $self->length();
    }
    }
    - - - - -
    - - - -

    A better solution is to use the %alias directive (unique to SWIG's Ruby module). The previous example could then be rewritten as:

    - - - -
    // MyArray#size is an alias for MyArray#length
    %alias MyArray::length "size";

    class MyArray {
    public:
    // Construct an empty array
    MyArray();

    // Return the size of this array
    size_t length() const;
    };

    - - - - -
    - - - -

    Multiple aliases can be associated with a method by providing a comma-separated list of aliases to the %alias directive, e.g.

    - - - -
    %alias MyArray::length "amount,quantity,size";
    - - - - -
    - - - -

    From an end-user's standpoint, there's no functional difference between these two approaches; i.e. they should get the same result from calling either MyArray#size or MyArray#length. @@ -3088,20 +1371,12 @@ doesn't need to generate all of the wrapper code that's usually associated with added methods like our MyArray::size() example.

    - - - -

    Note that the %alias directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    - - - -

    36.4.2 Predicate Methods

    @@ -3115,82 +1390,35 @@ if the object is an instance of the specified class). For consistency with Ruby conventions, methods that return boolean values should be marked as predicate methods.

    - - - -

    One cumbersome solution to this problem is to rename the method (using SWIG's %rename directive) and provide a custom typemap that converts the function's actual return type to Ruby's true or false. For example:

    - - - -
    %rename("is_it_safe?") is_it_safe();

    %typemap(out) int is_it_safe
    "$result = ($1 != 0) ? Qtrue : Qfalse;";

    int is_it_safe();

    - - - - -
    - - - -

    A better solution is to use the %predicate directive (unique to SWIG's Ruby module) to designate a method as a predicate method. For the previous example, this would look like:

    - - - -
    %predicate is_it_safe();

    int is_it_safe();

    - - - - -
    - - - -

    This method would be invoked from Ruby code like this:

    - - - -
    irb(main):001:0> Example::is_it_safe?
    true

    - - - - -
    - - - -

    The %predicate directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    - - - -

    36.4.3 Bang Methods

    @@ -3202,380 +1430,141 @@ which returns a copy of the array with the items sorted instead of modifying the original array. For consistency with Ruby conventions, methods that modify objects in place should be marked as bang methods.

    - - - -

    Bang methods can be marked using the %bang directive which is unique to the Ruby module and was introduced in SWIG 1.3.28. For example:

    - - - -
    %bang sort(int arr[]);

    int sort(int arr[]);
    - - - - -
    - - - -

    This method would be invoked from Ruby code like this:

    - - - -
    irb(main):001:0> Example::sort!(arr)
    - - - - -
    - - - -

    The %bang directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    - - - -

    36.4.4 Getters and Setters

    Often times a C++ library will expose properties through getter and setter methods. For example:

    - - - -
    class Foo {
    Foo() {}

    int getValue() { return value_; }

    void setValue(int value) { value_ = value; }

    private:
    int value_;
    };
    - - - - -
    - - - -

    By default, SWIG will expose these methods to Ruby as get_value and set_value. However, it more natural for these methods to be exposed in Ruby as value and value=. That allows the methods to be used like this:

    - - - -
    irb(main):001:0> foo = Foo.new()
    irb(main):002:0> foo.value = 5
    irb(main):003:0> puts foo.value
    - - - - -
    - - - -

    This can be done by using the %rename directive:

    - - - -
    %rename("value") Foo::getValue();
    %rename("value=") Foo::setValue(int value);
    - - - - -
    - - - - -

     

    - - - - -

    36.5 Input and output parameters

    A common problem in some C programs is handling parameters passed as simple pointers. For example:

    - - - -
    void add(int x, int y, int *result) {
    *result = x + y;
    }
    or
    int sub(int *x, int *y) {
    return *x-*y;
    }
    - - - - -
    - - - -

    The easiest way to handle these situations is to use the typemaps.i file. For example:

    - - - -
    %module Example
    %include "typemaps.i"

    void add(int, int, int *OUTPUT);
    int sub(int *INPUT, int *INPUT);
    - - - - -
    - - - -

    In Ruby, this allows you to pass simple values. For example:

    - - - -
    a = Example.add(3,4)
    puts a
    7
    b = Example.sub(7,4)
    puts b
    3
    - - - - -
    - - - -

    Notice how the INPUT parameters allow integer values to be passed instead of pointers and how the OUTPUT parameter creates a return result.

    - - - -

    If you don't want to use the names INPUT or OUTPUT, use the %apply directive. For example:

    - - - -
    %module Example
    %include "typemaps.i"

    %apply int *OUTPUT { int *result };
    %apply int *INPUT { int *x, int *y};

    void add(int x, int y, int *result);
    int sub(int *x, int *y);
    - - - - -
    - - - -

    If a function mutates one of its parameters like this,

    - - - -
    void negate(int *x) {
    *x = -(*x);
    }
    - - - - -
    - - - -

    you can use INOUT like this:

    - - - -
    %include "typemaps.i"
    ...
    void negate(int *INOUT);
    - - - - -
    - - - -

    In Ruby, a mutated parameter shows up as a return value. For example:

    - - - -
    a = Example.negate(3)
    print a
    -3

    - - - - -
    - - - -

    The most common use of these special typemap rules is to handle functions that return more than one value. For example, sometimes a function returns a result as well as a special error code:

    - - - -
    /* send message, return number of bytes sent, success code, and error_code */
    int send_message(char *text, int *success, int *error_code);
    - - - - -
    - - - -

    To wrap such a function, simply use the OUTPUT rule above. For example:

    - - - -
    %module example
    %include "typemaps.i"
    ...
    int send_message(char *, int *OUTPUT, int *OUTPUT);
    - - - - -
    - - - -

    When used in Ruby, the function will return an array of multiple values.

    - - - -
    bytes, success, error_code = send_message("Hello World")
    if not success
    print "error #{error_code} : in send_message"
    else
    print "Sent", bytes
    end
    - - - - -
    - - - -

    Another way to access multiple return values is to use the %apply rule. In the following example, the parameters rows and columns are related to SWIG as OUTPUT values through the use of %apply

    - - - -
    %module Example
    %include "typemaps.i"
    %apply int *OUTPUT { int *rows, int *columns };
    ...
    void get_dimensions(Matrix *m, int *rows, int*columns);
    - - - - -
    - - - -

    In Ruby:

    - - - -
    r, c = Example.get_dimensions(m)
    - - - - -
    - - - -

    36.6 Exception handling

    @@ -3588,92 +1577,41 @@ C/C++ errors into Ruby exceptions. The chapter on
    class DoubleArray {
    private:
    int n;
    double *ptr;
    public:
    // Create a new array of fixed size
    DoubleArray(int size) {
    ptr = new double[size];
    n = size;
    }

    // Destroy an array
    ~DoubleArray() {
    delete ptr;
    }

    // Return the length of the array
    int length() {
    return n;
    }

    // Get an array item and perform bounds checking.
    double getitem(int i) {
    if ((i >= 0) && (i < n))
    return ptr[i];
    else
    throw RangeError();
    }

    // Set an array item and perform bounds checking.
    void setitem(int i, double val) {
    if ((i >= 0) && (i < n))
    ptr[i] = val;
    else {
    throw RangeError();
    }
    }
    };
    - - - - -
    - - - -

    Since several methods in this class can throw an exception for an out-of-bounds access, you might want to catch this in the Ruby extension by writing the following in an interface file:

    - - - -
    %exception {
    try {
    $action
    }
    catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error.");
    }
    }

    class DoubleArray {
    ...
    };
    - - - - -
    - - - -

    The exception handling code is inserted directly into generated wrapper functions. When an exception handler is defined, errors can be caught and used to gracefully raise a Ruby exception instead of forcing the entire program to terminate with an uncaught error.

    - - - -

    As shown, the exception handling code will be added to every wrapper function. Because this is somewhat inefficient, you might consider refining the exception handler to only apply to specific methods like this:

    - - - -
    %exception getitem {
    try {
    $action
    }
    catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error in getitem.");
    }
    }

    %exception setitem {
    try {
    $action
    }
    catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error in setitem.");
    }
    }
    - - - - -
    - - - -

    In this case, the exception handler is only attached to methods and functions named getitem and setitem.

    - - - -

    Since SWIG's exception handling is user-definable, you are not limited to C++ exception handling. See the chapter on Customization Features for more examples.

    - - - -

    36.6.2 Handling Ruby Blocks

    @@ -3683,939 +1621,214 @@ the use of blocks, which allow the easy creation of continuations and other niceties.  Blocks in ruby are also often used to simplify the passing of many arguments to a class.

    - - - -

    In order to make your class constructor support blocks, you can take advantage of the %exception directive, which will get run after the C++ class' constructor was called. 

    - - - -

    For example, this yields the class over after its construction:
    - - - -

    - - - -
    class Window
    {
    public:
    Window(int x, int y, int w, int h);
    // .... other methods here ....
    };

    // Add support for yielding self in the Class' constructor.
    %exception Window::Window {
    $action
    if (rb_block_given_p()) {
    rb_yield(self);
    }
    }
    - - - - -
    - - - -

    Then, in ruby, it can be used like:

    - - - -
    Window.new(0,0,360,480) { |w|
    - - - -     w.color = Fltk::RED
    - - - -     w.border = false
    - - - - }
    - - - -
    - - - -

    For other methods, you can usually use a dummy parameter with a special in typemap, like:

    - - - -
    //
    - - - - // original function was:
    - - - - - //
    - - - - - // void func(int x);
    - - - - -
    - - - - - %typemap(in,numinputs=0) int RUBY_YIELD_SELF {
    - - - - -      if ( !rb_block_given_p() )
    - - - - -             rb_raise("No block given");
    - - - - -      return rb_yield(self);
    - - - - - }
    - - - - -
    - - - - - %extend {
    - - - - -         void func(int x, int RUBY_YIELD_SELF );
    - - - - - }
    - - - -

    For more information on typemaps, see Typemaps.

    -

    36.6.3 Raising exceptions

    There are three ways to raise exceptions from C++ code to Ruby.

    - - - -

    The first way is to use SWIG_exception(int code, const char *msg). The following table shows the mappings from SWIG error codes to Ruby exceptions:

    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - -
    SWIG_MemoryError
    - - - - -
    - - - -
    rb_eNoMemError
    - - - - -
    - - - -
    SWIG_IOError
    - - - - -
    - - - -
    rb_eIOError
    - - - - -
    - - - -
    SWIG_RuntimeError
    - - - - -
    - - - -
    rb_eRuntimeError
    - - - - -
    - - - -
    SWIG_IndexError
    - - - - -
    - - - -
    rb_eIndexError
    - - - - -
    - - - -
    SWIG_TypeError
    - - - - -
    - - - -
    rb_eTypeError
    - - - - -
    - - - -
    SWIG_DivisionByZero
    - - - - -
    - - - -
    rb_eZeroDivError
    - - - - -
    - - - -
    SWIG_OverflowError
    - - - - -
    - - - -
    rb_eRangeError
    - - - - -
    - - - -
    SWIG_SyntaxError
    - - - - -
    - - - -
    rb_eSyntaxError
    - - - - -
    - - - -
    SWIG_ValueError
    - - - - -
    - - - -
    rb_eArgError
    - - - - -
    - - - -
    SWIG_SystemError
    - - - - -
    - - - -
    rb_eFatal
    - - - - -
    - - - -
    SWIG_AttributeError
    - - - - -
    - - - -
    rb_eRuntimeError
    - - - - -
    - - - -
    SWIG_NullReferenceError
    - - - - -
    - - - -
    rb_eNullReferenceError*
    - - - - -
    - - - -
    SWIG_ObjectPreviouslyDeletedError
    - - - - -
    - - - -
    rb_eObjectPreviouslyDeleted*
    - - - - -
    - - - -
    SWIG_UnknownError
    - - - - -
    - - - -
    rb_eRuntimeError
    - - - - -
    - - - -
    * These error classes are created by SWIG and are not built-in Ruby exception classes
    - - - - -
    - - - - -
    - - - -

    The second way to raise errors is to use SWIG_Raise(obj, type, desc). Obj is a C++ instance of an exception class, type is a string specifying the type of exception (for example, "MyError") and desc is the SWIG description of the exception class. For example:

    - - - -
    %raise(SWIG_NewPointerObj(e, SWIGTYPE_p_AssertionFailedException, 0), ":AssertionFailedException", SWIGTYPE_p_AssertionFailedException);
    - - - -

    This is useful when you want to pass the current exception object directly to Ruby, particularly when the object is an instance of class marked as an %exceptionclass (see the next section for more information).

    - - - -

    Last, you can raise an exception by directly calling Ruby's C api. This is done by invoking the rb_raise() function. The first argument passed to rb_raise() is the exception type. You can raise a custom exception type or one of the built-in Ruby exception types.

    - - - -

    36.6.4 Exception classes

    @@ -4626,54 +1839,20 @@ directive are exposed in Ruby as child classes of rb_eRuntimeError. This allows C++ exceptions to be directly mapped to Ruby exceptions, providing for a more natural integration between C++ code and Ruby code.

    - - - -
    	%exceptionclass CustomError;

    %inline %{
    class CustomError { };

    class Foo {
    public:
    void test() { throw CustomError; }
    };
    }
    - - - - -
    - - - -

    From Ruby you can now call this method like this:

    - - - -
    foo = Foo.new
    begin
    foo.test()
    rescue CustomError => e
    puts "Caught custom error"
    end
    - - - - -
    - - - -

    For another example look at swig/Examples/ruby/exception_class.
    - - - -

    - - - -

    36.7 Typemaps

    @@ -4684,19 +1863,11 @@ Ruby C API as well as the material in the "Type chapter. 

    - - - -

    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 primitive C-Ruby interface.

    - - - -

    36.7.1 What is a typemap?

    @@ -4705,106 +1876,47 @@ attached to a specific C datatype. The general form of this declaration is as follows ( parts enclosed in [...] are optional ):    

    - - - -
    %typemap( method [, modifiers...] ) typelist code;
    - - - -

    method is a simply a name that specifies what kind of typemap is being defined. It is usually a name like "in", "out", or "argout" (or its director variations). The purpose of these methods is described later.

    - - - -

    modifiers is an optional comma separated list of name="value" values. These are sometimes to attach extra information to a typemap and is often target-language dependent.

    - - - -

    typelist is a list of the C++ type patterns that the typemap will match. The general form of this list is as follows:

    - - - -
    typelist : typepattern [, typepattern, typepattern, ... ] ;

    typepattern : type [ (parms) ]
    | type name [ (parms) ]
    | ( typelist ) [ (parms) ]
    - - - - -
    - - - -

    Each type pattern is either a simple type, a simple type and argument name, or a list of types in the case of multi-argument typemaps. In addition, each type pattern can be parameterized with a list of temporary variables (parms). The purpose of these variables will be explained shortly.

    - - - -

    code specifies the C code used in the typemap. It can take any one of the following forms:

    - - - -
    code : { ... }
    | " ... "
    | %{ ... %}
    - - - - -
    - - - -

    For example, to convert integers from Ruby to C, you might define a typemap like this:

    - - - -
    %module example

    %typemap(in) int {
    $1 = (int) NUM2INT($input);
    printf("Received an integer : %d\n",$1);
    }

    %inline %{
    extern int fact(int n);
    %}
    - - - - -
    - - - -

    Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is @@ -4814,77 +1926,30 @@ prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input variable is the input Ruby object.

    - - - -

    When this example is compiled into a Ruby module, the following sample code:

    - - - -
    require 'example'

    puts Example.fact(6)
    - - - - -
    - - - -

    prints the result:

    - - - -
    Received an integer : 6
    720
    - - - - -
    - - - -

    In this example, the typemap is applied to all occurrences of the int datatype. You can refine this by supplying an optional parameter name. For example:

    - - - -
    %module example

    %typemap(in) int n {
    $1 = (int) NUM2INT($input);
    printf("n = %d\n",$1);
    }

    %inline %{
    extern int fact(int n);
    %}
    - - - - -
    - - - -

    In this case, the typemap code is only attached to arguments that exactly match "int n".

    - - - -

    The application of a typemap to specific datatypes and argument names involves more than simple text-matching--typemaps are fully integrated into the SWIG type-system. When you define a typemap @@ -4893,72 +1958,29 @@ and qualified variations such as const int. In addition, the typemap system follows typedef declarations. For example:

    - - - -
    %typemap(in) int n {
    $1 = (int) NUM2INT($input);
    printf("n = %d\n",$1);
    }

    typedef int Integer;
    extern int fact(Integer n); // Above typemap is applied
    - - - - -
    - - - -

    However, the matching of typedef only occurs in one direction. If you defined a typemap for Integer, it is not applied to arguments of type int.

    - - - -

    Typemaps can also be defined for groups of consecutive arguments. For example:

    - - - -
    %typemap(in) (char *str, int len) {
    $1 = StringValuePtr($input);
    $2 = (int) RSTRING($input)->len;
    };

    int count(char c, char *str, int len);
    - - - - -
    - - - -

    When a multi-argument typemap is defined, the arguments are always handled as a single Ruby object. This allows the function count to be used as follows (notice how the length parameter is omitted):

    - - - -
    puts Example.count('o','Hello World')
    2
    - - - - -
    - - - -

    36.7.2 Typemap scope

    @@ -4966,23 +1988,10 @@ to be used as follows (notice how the length parameter is omitted):

    declarations that follow. A typemap may be redefined for different sections of an input file. For example:

    - - - -
    // typemap1
    %typemap(in) int {
    ...
    }

    int fact(int); // typemap1
    int gcd(int x, int y); // typemap1

    // typemap2
    %typemap(in) int {
    ...
    }

    int isprime(int); // typemap2
    - - - - -
    - - - -

    One exception to the typemap scoping rules pertains to the %extend declaration. %extend is used to attach new declarations to a class or structure definition. Because @@ -4990,250 +1999,99 @@ of this, all of the declarations in an %extend block are subject to the typemap rules that are in effect at the point where the class itself is defined. For example:

    - - - -
    class Foo {
    ...
    };

    %typemap(in) int {
    ...
    }

    %extend Foo {
    int blah(int x); // typemap has no effect. Declaration is attached to Foo which
    // appears before the %typemap declaration.
    };
    - - - - -
    - - - -

    36.7.3 Copying a typemap

    A typemap is copied by using assignment. For example:

    - - - -
    %typemap(in) Integer = int;
    - - - - -
    - - - -

    or this:

    - - - -
    %typemap(in) Integer, Number, int32_t = int;
    - - - - -
    - - - -

    Types are often managed by a collection of different typemaps. For example:

    - - - -
    %typemap(in) int { ... }
    %typemap(out) int { ... }
    %typemap(varin) int { ... }
    %typemap(varout) int { ... }
    - - - - -
    - - - -

    To copy all of these typemaps to a new type, use %apply. For example:

    - - - -
    %apply int { Integer }; // Copy all int typemaps to Integer
    %apply int { Integer, Number }; // Copy all int typemaps to both Integer and Number
    - - - - -
    - - - -

    The patterns for %apply follow the same rules as for %typemap. For example:

    - - - -
    %apply int *output { Integer *output }; // Typemap with name
    %apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments
    - - - - -
    - - - -

    36.7.4 Deleting a typemap

    A typemap can be deleted by simply defining no code. For example:

    - - - -
    %typemap(in) int; // Clears typemap for int
    %typemap(in) int, long, short; // Clears typemap for int, long, short
    %typemap(in) int *output;
    - - - - -
    - - - -

    The %clear directive clears all typemaps for a given type. For example:

    - - - -
    %clear int; // Removes all types for int
    %clear int *output, long *output;
    - - - - -
    - - - -

    Note: Since SWIG's default behavior is defined by typemaps, clearing a fundamental type like int will make that type unusable unless you also define a new set of typemaps immediately after the clear operation.

    - - - -

    36.7.5 Placement of typemaps

    Typemap declarations can be declared in the global scope, within a C++ namespace, and within a C++ class. For example:

    - - - -
    %typemap(in) int {
    ...
    }

    namespace std {
    class string;
    %typemap(in) string {
    ...
    }
    }

    class Bar {
    public:
    typedef const int & const_reference;
    %typemap(out) const_reference {
    ...
    }
    };
    - - - - -
    - - - -

    When a typemap appears inside a namespace or class, it stays in effect until the end of the SWIG input (just like before). However, the typemap takes the local scope into account. Therefore, this code

    - - - -
    namespace std {
    class string;
    %typemap(in) string {
    ...
    }
    }
    - - - - -
    - - - -

    is really defining a typemap for the type std::string. You could have code like this:

    - - - -
    namespace std {
    class string;
    %typemap(in) string { /* std::string */
    ...
    }
    }

    namespace Foo {
    class string;
    %typemap(in) string { /* Foo::string */
    ...
    }
    }
    - - - - -
    - - - -

    In this case, there are two completely distinct typemaps that apply to two completely different types (std::string and Foo::string).

    - - - -

    It should be noted that for scoping to work, SWIG has to know that string is a typename defined within a particular namespace. @@ -5241,20 +2099,12 @@ In this example, this is done using the class declaration class string .

    - - - -

    36.7.6 Ruby typemaps

    The following list details all of the typemap methods that can be used by the Ruby module:

    - - - -

    36.7.6.1  "in" typemap

    @@ -5262,242 +2112,61 @@ can be used by the Ruby module:

    function arguments. For example:

    - - - -
    %typemap(in) int {
    $1 = NUM2INT($input);
    }
    - - - - -
    - - - -

    The following special variables are available:

    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    $input Input object holding value to be converted.
    $symname Name of function/method being wrapped
    $1...n Argument being sent to the function
    $1_name Name of the argument (if provided)
    $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable version of the C datatype matched by the typemap.
    - - - - -
    - - - -

    This is probably the most commonly redefined typemap because it can be used to implement customized conversions.

    - - - -

    In addition, the "in" typemap allows the number of converted arguments to be specified. For example:

    - - - -
    // Ignored argument.
    %typemap(in, numinputs=0) int *out (int temp) {
    $1 = &temp;
    }
    - - - - -
    - - - -

    At this time, only zero or one arguments may be converted.

    - - - -

    36.7.6.2 "typecheck" typemap

    @@ -5505,272 +2174,70 @@ arguments to be specified. For example:

    functions and methods. It merely checks an argument to see whether or not it matches a specific type. For example:

    - - - -
    %typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) int {
    $1 = FIXNUM_P($input) ? 1 : 0;
    }
    - - - - -
    - - - -

    For typechecking, the $1 variable is always a simple integer that is set to 1 or 0 depending on whether or not the input argument is the correct type.

    - - - -

    If you define new "in" typemaps and your program uses overloaded methods, you should also define a collection of "typecheck" typemaps. More details about this follow in a later section on "Typemaps and Overloading."

    - - - -

    36.7.6.3  "out" typemap

    Converts return value of a C function to a Ruby object.

    - - - -

    - - - - - %typemap(out) int {
    - - - - -    $result = INT2NUM( $1 );
    - - - - - }
    - - - - -
    - - - -

    The following special variables are available.

    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    $result Result object returned to target language.
    $symname Name of function/method being wrapped
    $1...n Argument being wrapped
    $1_name Name of the argument (if provided)
    $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable version of the C datatype matched by the typemap.
    - - - - -
    - - - - -
    - - - - -

    36.7.6.4 "arginit" typemap

    @@ -5779,65 +2246,31 @@ function argument--before any conversion has occurred. This is not normally necessary, but might be useful in highly specialized applications. For example:

    - - - -
    // Set argument to NULL before any conversion occurs
    %typemap(arginit) int *data {
    $1 = NULL;
    }
    - - - - -
    - - - -

    36.7.6.5 "default" typemap

    The "default" typemap is used to turn an argument into a default argument. For example:

    - - - -
    %typemap(default) int flags {
    $1 = DEFAULT_FLAGS;
    }
    ...
    int foo(int x, int y, int flags);
    - - - - -
    - - - -

    The primary use of this typemap is to either change the wrapping of default arguments or specify a default argument in a language where they aren't supported (like C). Target languages that do not support optional arguments, such as Java and C#, effectively ignore the value specified by this typemap as all arguments must be given.

    - - - -

    Once a default typemap has been applied to an argument, all arguments that follow must have default values. See the Default/optional arguments section for further information on default argument wrapping.

    - - - -

    36.7.6.6 "check" typemap

    @@ -5845,23 +2278,10 @@ default argument wrapping.

    during argument conversion. The typemap is applied after arguments have been converted. For example:

    - - - -
    %typemap(check) int positive {
    if ($1 <= 0) {
    SWIG_exception(SWIG_ValueError,"Expected positive value.");
    }
    }
    - - - - -
    - - - -

    36.7.6.7 "argout" typemap

    @@ -5871,155 +2291,43 @@ need to return multiple values. The "argout" typemap is almost always combined with an "in" typemap---possibly to ignore the input value. For example:

    - - - -
    /* Set the input argument to point to a temporary variable */
    %typemap(in, numinputs=0) int *out (int temp) {
    $1 = &temp;
    }

    %typemap(argout, fragment="output_helper") int *out {
    // Append output value $1 to $result (assuming a single integer in this case)
    $result = output_helper( $result, INT2NUM(*$1) );
    }
    - - - - -
    - - - -

    The following special variables are available.

    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    $result Result object returned to target language.
    $input The original input object passed.
    $symname Name of function/method being wrapped.
    - - - - -
    - - - -

    The code supplied to the "argout" typemap is always placed after the "out" typemap. If multiple return values are used, the extra return values are often appended to return value of the function.

    - - - -

    Output helper is a fragment that usually defines a macro to some function like SWIG_Ruby_AppendOutput.

    - - - -

    See the typemaps.i library for examples.

    - - - -

    36.7.6.8 "freearg" typemap

    @@ -6029,33 +2337,16 @@ be cleaned up when the wrapper function exits. The "freearg" typemap usually cleans up argument resources allocated by the "in" typemap. For example:

    - - - -
    // Get a list of integers
    %typemap(in) int *items {
    int nitems = Length($input);
    $1 = (int *) malloc(sizeof(int)*nitems);
    }
    // Free the list
    %typemap(freearg) int *items {
    free($1);
    }
    - - - - -
    - - - -

    The "freearg" typemap inserted at the end of the wrapper function, just before control is returned back to the target language. This code is also placed into a special variable $cleanup that may be used in other typemaps whenever a wrapper function needs to abort prematurely.

    - - - -

    36.7.6.9 "newfree" typemap

    @@ -6063,30 +2354,13 @@ abort prematurely.

    directive and is used to deallocate memory used by the return result of a function. For example:

    - - - -
    %typemap(newfree) string * {
    delete $1;
    }
    %typemap(out) string * {
    $result = PyString_FromString($1->c_str());
    }
    ...

    %newobject foo;
    ...
    string *foo();
    - - - - -
    - - - -

    See Object ownership and %newobject for further details.

    - - - -

    36.7.6.10 "memberin" typemap

    @@ -6095,31 +2369,14 @@ already converted input value into a structure member. It is typically used to handle array members and other special cases. For example:

    - - - -
    %typemap(memberin) int [4] {
    memmove($1, $input, 4*sizeof(int));
    }
    - - - - -
    - - - -

    It is rarely necessary to write "memberin" typemaps---SWIG already provides a default implementation for arrays, strings, and other objects.

    - - - -

    36.7.6.11 "varin" typemap

    @@ -6127,10 +2384,6 @@ other objects.

    language to C for the purposes of assigning to a C/C++ global variable. This is implementation specific.

    - - - -

    36.7.6.12 "varout" typemap

    @@ -6138,10 +2391,6 @@ This is implementation specific.

    object in the target language when reading a C/C++ global variable. This is implementation specific.

    - - - -

    36.7.6.13 "throws" typemap

    @@ -6154,53 +2403,23 @@ or exception in the target language. It is slightly different to the other typemaps as it is based around the exception type rather than the type of a parameter or variable. For example:

    - - - -
    %typemap(throws) const char * %{
    rb_raise(rb_eRuntimeError, $1);
    SWIG_fail;
    %}
    void bar() throw (const char *);
    - - - - -
    - - - -

    As can be seen from the generated code below, SWIG generates an exception handler with the catch block comprising the "throws" typemap content.

    - - - -
    ...
    try {
    bar();
    }
    catch(char const *_e) {
    rb_raise(rb_eRuntimeError, _e);
    SWIG_fail;
    }
    ...
    - - - - -
    - - - -

    Note that if your methods do not have an exception specification yet they do throw exceptions, SWIG cannot know how to deal with them. For a neat way to handle these, see the Exception handling with %exception section.

    - - - -

    36.7.6.14 directorin typemap

    @@ -6210,251 +2429,56 @@ of the "in" typemap, making its typemap rule often similar to the "out" typemap.

    - - - -

    - - - - - %typemap(directorin) int {
    - - - - -      $result = INT2NUM($1);
    - - - - - }
    - - - - -
    - - - -

    The following special variables are available.

    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    $result Result object returned to target language.
    $symname Name of function/method being wrapped
    $1...n Argument being wrapped
    $1_name Name of the argument (if provided)
    $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable version of the C datatype matched by the typemap.
    this C++ this, referring to the class itself.
    - - - - -
    - - - -

    36.7.6.15 directorout typemap

    @@ -6464,59 +2488,21 @@ of the "out" typemap, making its rule often similar to the "in" typemap.

    - - - -

    - - - - %typemap(directorout) int {

    - - - -    $result = NUM2INT($1);

    - - - - }
    - - - -
    - - - -

    The following special variables are available:

    - - - -
    - - - - - - - - - - @@ -6529,207 +2515,63 @@ typemap. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    $input Ruby object being sent to the function$1...n Argument being sent to the function
    $1_name Name of the argument (if provided)
    $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable version of the C datatype matched by the typemap.
    this C++ this, referring to the class itself.
    - - - - -
    - - - -

    Currently, the directorout nor the out typemap support the option numoutputs, but the Ruby module provides that functionality through a %feature directive.  Thus, a function can be made to return "nothing" if you do:

    - - - -
    %feature("numoutputs","0") MyClass::function;
    - - - -

    This feature can be useful if a function returns a status code, which you want to discard but still use the typemap to raise an exception.
    - - - -

    - - - -

    36.7.6.16 directorargout typemap

    Output argument processing in director member functions.

    - - - -
    %typemap(directorargout, fragment="output_helper") int {
    - - - - $result = output_helper( $result, NUM2INT($1) );

    - - - - }
    - - - -

    The following special variables are available:

    - - - -
    - - - - - - - - - - @@ -6747,142 +2589,41 @@ $result = output_helper( $result, NUM2INT($1) );
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    $result Result that the director function returns Argument being sent to the function
    $1_nameName of the argument (if provided)
    $1_typeThe actual C datatype matched by the typemap
    $1_ltypeThe assignable version of the C datatype matched by the typemap
    thisC++ this, referring to the instance of the class itself
    - - - - -
    - - - -

    36.7.6.17 ret typemap

    Cleanup of function return values

    - - - -

    36.7.6.18 globalin typemap

    Setting of C global variables

    - - - -

    36.7.7 Typemap variables

    @@ -6892,83 +2633,35 @@ may appear. A full list of variables can be found in the "A C local variable corresponding to the actual type specified in the %typemap directive. For input values, this is a C local variable that is supposed to hold an argument value. For output values, this is the raw result that is supposed to be returned to Ruby.
  • - - - -

    $input

    - - - -
    A VALUE holding a raw Ruby object with an argument or variable value.
    - - - -

    $result

    - - - -
    A VALUE that holds the result to be returned to Ruby.
    - - - -

    $1_name

    - - - -
    The parameter name that was matched.
    - - - -

    $1_type

    - - - -
    The actual C datatype matched by the typemap.
    - - - -

    $1_ltype

    - - - -
    An assignable version of the datatype matched by the typemap (a type that can appear on the left-hand-side of a C assignment operation). This type is stripped of qualifiers and may @@ -6976,23 +2669,11 @@ be an altered version of $1_type. All arguments and local variables in wrapper functions are declared using this type so that their values can be properly assigned.
    - - - -

    $symname

    - - - -
    The Ruby name of the wrapper function being created.
    - - - -

    36.7.8 Useful Functions

    @@ -7008,15 +2689,6 @@ stick to the swig functions instead of the native Ruby functions.  That should help you avoid having to rewrite a lot of typemaps across multiple languages.

    - - - - - - - - -

    36.7.8.1 C Datatypes to Ruby Objects

    @@ -7034,45 +2706,31 @@ across multiple languages.

    SWIG_From_int(int x) int to Fixnum or Bignum - INT2FIX(long or int) int to Fixnum (faster than INT2NUM) - CHR2FIX(char) SWIG_From_char(char x) char to Fixnum - rb_str_new2(char*) SWIG_FromCharPtrAndSize(char*, size_t) char* to String - rb_float_new(double) SWIG_From_double(double),
    SWIG_From_float(float) float/double to Float - - - - - -
    - - - -

    36.7.8.2 Ruby Objects to C Datatypes

    @@ -7092,408 +2750,203 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input
      
    - - - - - - - - - - - -
    int NUM2INT(Numeric) SWIG_AsVal_int(VALUE, int*)
    int FIX2INT(Numeric) SWIG_AsVal_int(VALUE, int*)
    unsigned int NUM2UINT(Numeric) SWIG_AsVal_unsigned_SS_int(VALUE, int*)
    unsigned int FIX2UINT(Numeric) SWIG_AsVal_unsigned_SS_int(VALUE, int*)
    long NUM2LONG(Numeric) SWIG_AsVal_long(VALUE, long*)
    long FIX2LONG(Numeric) SWIG_AsVal_long(VALUE, long*)
    unsigned long FIX2ULONG(Numeric) SWIG_AsVal_unsigned_SS_long(VALUE, unsigned long*)
    char NUM2CHR(Numeric or String) SWIG_AsVal_char(VALUE, int*)
    char * StringValuePtr(String) SWIG_AsCharPtrAndSize(VALUE, char*, size_t, int* alloc)
    char * rb_str2cstr(String, int*length)
    double NUM2DBL(Numeric) (double) SWIG_AsVal_int(VALUE) or similar
    - - - - -
    - - - -

    36.7.8.3 Macros for VALUE

    RSTRING_LEN(str)

    - - - -
    length of the Ruby string
    - - - -

    RSTRING_PTR(str)

    - - - -
    pointer to string storage
    - - - -

    RARRAY_LEN(arr)

    - - - -
    length of the Ruby array
    - - - -

    RARRAY(arr)->capa

    - - - -
    capacity of the Ruby array
    - - - -

    RARRAY_PTR(arr)

    - - - -
    pointer to array storage
    - - - -

    36.7.8.4 Exceptions

    void rb_raise(VALUE exception, const char *fmt, ...)

    - - - -
    Raises an exception. The given format string fmt and remaining arguments are interpreted as with printf().
    - - - -

    void rb_fatal(const char *fmt, ...)

    - - - -
    Raises a fatal exception, terminating the process. No rescue blocks are called, but ensure blocks will be called. The given format string fmt and remaining arguments are interpreted as with printf().
    - - - -

    void rb_bug(const char *fmt, ...)

    - - - -
    Terminates the process immediately -- no handlers of any sort will be called. The given format string fmt and remaining arguments are interpreted as with printf(). You should call this function only if a fatal bug has been exposed.
    - - - -

    void rb_sys_fail(const char *msg)

    - - - -
    Raises a platform-specific exception corresponding to the last known system error, with the given string msg.
    - - - -

    VALUE rb_rescue(VALUE (*body)(VALUE), VALUE args, VALUE(*rescue)(VALUE, VALUE), VALUE rargs)

    - - - -
    Executes body with the given args. If a StandardError exception is raised, then execute rescue with the given rargs.
    - - - -

    VALUE rb_ensure(VALUE(*body)(VALUE), VALUE args, VALUE(*ensure)(VALUE), VALUE eargs)

    - - - -
    Executes body with the given args. Whether or not an exception is raised, execute ensure with the given rargs after body has completed.
    - - - -

    VALUE rb_protect(VALUE (*body)(VALUE), VALUE args, int *result)

    - - - -
    Executes body with the given args and returns nonzero in result if any exception was raised.
    - - - -

    void rb_notimplement()

    - - - -
    Raises a NotImpError exception to indicate that the enclosed function is not implemented yet, or not available on this platform.
    - - - -

    void rb_exit(int status)

    - - - -
    Exits Ruby with the given status. Raises a SystemExit exception and calls registered exit functions and finalizers.
    - - - -

    void rb_warn(const char *fmt, ...)

    - - - -
    Unconditionally issues a warning message to standard error. The given format string fmt and remaining arguments are interpreted as with printf().
    - - - -

    void rb_warning(const char *fmt, ...)

    - - - -
    Conditionally issues a warning message to standard error if Ruby was invoked with the -w flag. The given format string fmt and remaining arguments are interpreted as with printf().
    - - - -

    36.7.8.5 Iterators

    void rb_iter_break()

    - - - -
    Breaks out of the enclosing iterator block.
    - - - -

    VALUE rb_each(VALUE obj)

    - - - -
    Invokes the each method of the given obj.
    - - - -

    VALUE rb_yield(VALUE arg)

    - - - -
    Transfers execution to the iterator block in the current context, passing arg as an argument. Multiple values may be passed in an array.
    - - - -

    int rb_block_given_p()

    - - - -
    Returns true if yield would execute a block in the current context; that is, if a code block was passed to the current method and is available to be called.
    - - - -

    VALUE rb_iterate(VALUE (*method)(VALUE), VALUE args, VALUE (*block)(VALUE, VALUE), VALUE arg2)

    - - - -
    Invokes method with argument args and block block. A yield from that method will invoke block with the argument given to yield, and a second argument arg2.
    - - - -

    VALUE rb_catch(const char *tag, VALUE (*proc)(VALUE, VALUE), VALUE value)

    - - - -
    Equivalent to Ruby's catch.
    - - - -

    void rb_throw(const char *tag, VALUE value)

    - - - -
    Equivalent to Ruby's throw.
    - - - -

    36.7.9 Typemap Examples

    @@ -7501,10 +2954,6 @@ VALUE), VALUE value)

    examples, you might look at the examples in the Example/ruby directory.

    - - - -

    36.7.10 Converting a Ruby array to a char **

    @@ -7513,53 +2962,23 @@ command line arguments, which are usually passed in an array of NULL terminated strings. The following SWIG interface file allows a Ruby Array instance to be used as a char ** object.

    - - - -
    %module argv

    // This tells SWIG to treat char ** as a special case
    %typemap(in) char ** {
    /* Get the length of the array */
    int size = RARRAY($input)->len;
    int i;
    $1 = (char **) malloc((size+1)*sizeof(char *));
    /* Get the first element in memory */
    VALUE *ptr = RARRAY($input)->ptr;
    for (i=0; i < size; i++, ptr++)
    /* Convert Ruby Object String to char* */
    $1[i]= StringValuePtr(*ptr);
    $1[i]=NULL; /* End of list */
    }

    // This cleans up the char ** array created before
    // the function call

    %typemap(freearg) char ** {
    free((char *) $1);
    }

    // Now a test function
    %inline %{
    int print_args(char **argv) {
    int i = 0;
    while (argv[i]) {
    printf("argv[%d] = %s\n", i,argv[i]);
    i++;
    }
    return i;
    }
    %}

    - - - - -
    - - - -

    When this module is compiled, the wrapped C function now operates as follows :

    - - - -
    require 'Argv'
    Argv.print_args(["Dave","Mike","Mary","Jane","John"])
    argv[0] = Dave
    argv[1] = Mike
    argv[2] = Mary
    argv[3] = Jane
    argv[4] = John
    - - - - -
    - - - -

    In the example, two different typemaps are used. The "in" typemap is used to receive an input argument and convert it to a C array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function.

    - - - -

    36.7.11 Collecting arguments in a hash

    @@ -7572,66 +2991,27 @@ provide similar functionality for your Ruby interface. For example, suppose you'd like to wrap this C function that collects information about people's vital statistics:

    - - - -
    void setVitalStats(const char *person, int nattributes, const char **names, int *values);
    - - - - -
    - - - -

    and you'd like to be able to call it from Ruby by passing in an arbitrary number of key-value pairs as inputs, e.g.

    - - - -
    setVitalStats("Fred",
    'weight' => 270,
    'age' => 42
    )
    - - - - -
    - - - -

    To make this work, you need to write a typemap that expects a Ruby Hash as its input and somehow extracts the last three arguments (nattributes, names and values) needed by your C function. Let's start with the basics:

    - - - -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    }
    - - - - -
    - - - -

    This %typemap directive tells SWIG that we want to match any function declaration that has the specified types and names of arguments somewhere in the argument list. The fact that we @@ -7644,38 +3024,17 @@ of parentheses (keys_arr, i, key and val) define local variables that our typemap will need.

    - - - -

    Since we expect the input argument to be a Hash, let's next add a check for that:

    - - - -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    }
    - - - - -
    - - - -

    Check_Type() is just a macro (defined in the Ruby header files) that confirms that the input argument is of the correct type; if it isn't, an exception will be raised.

    - - - -

    The next task is to determine how many key-value pairs are present in the hash; we'll assign this number to the first typemap argument ($1). This is a little tricky since the @@ -7684,161 +3043,66 @@ hash, but we can get around that by calling the hash's size method directly and converting its result to a C int value:

    - - - -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    }
    - - - - -
    - - - -

    So now we know the number of attributes. Next we need to initialize the second and third typemap arguments (i.e. the two C arrays) to NULL and set the stage for extracting the keys and values from the hash:

    - - - -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    }

    }
    - - - - -
    - - - -

    There are a number of ways we could extract the keys and values from the input hash, but the simplest approach is to first call the hash's keys method (which returns a Ruby array of the keys) and then start looping over the elements in that array:

    - - - -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
    }

    }
    }
    - - - - -
    - - - -

    Recall that keys_arr and i are local variables for this typemap. For each element in the keys_arr array, we want to get the key itself, as well as the value corresponding to that key in the hash:

    - - - -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
    key = rb_ary_entry(keys_arr, i);
    val = rb_hash_aref($input, key);

    }
    }
    }
    - - - - -
    - - - -

    To be safe, we should again use the Check_Type() macro to confirm that the key is a String and the value is a Fixnum:

    - - - -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
    key = rb_ary_entry(keys_arr, i);
    val = rb_hash_aref($input, key);
    Check_Type(key, T_STRING);
    Check_Type(val, T_FIXNUM);

    }
    }
    }
    - - - - -
    - - - -

    Finally, we can convert these Ruby objects into their C equivalents and store them in our local C arrays:

    - - - -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
    key = rb_ary_entry(keys_arr, i);
    val = rb_hash_aref($input, key);
    Check_Type(key, T_STRING);
    Check_Type(val, T_FIXNUM);
    $2[i] = StringValuePtr(key);
    $3[i] = NUM2INT(val);

    }
    }
    }
    - - - - -
    - - - -

    We're not done yet. Since we used malloc() to dynamically allocate the memory used for the names and values arguments, we need to provide a corresponding "freearg" typemap to free that memory so that there is no memory leak. Fortunately, this typemap is a lot easier to write:

    - - - -
    %typemap(freearg) (int nattributes, const char **names, const int *values) {
    free((void *) $2);
    free((void *) $3);
    }
    - - - - -
    - - - -

    All of the code for this example, as well as a sample Ruby program that uses the extension, can be found in the Examples/ruby/hashargs directory of the SWIG distribution.

    - - - -

    36.7.12 Pointer handling

    @@ -7847,17 +3111,9 @@ that have been stored using the SWIG typed-pointer representation. Since there are several ways in which pointers can be represented, the following two functions are used to safely perform this conversion:

    - - - -

    int SWIG_ConvertPtr(VALUE obj, void **ptr, swig_type_info *ty, int flags)

    - - - -
    Converts a Ruby object obj to a C pointer whose address is ptr (i.e. ptr is a pointer to a pointer). The third argument, ty, @@ -7871,17 +3127,9 @@ errors will cause SWIG_ConvertPtr() to return -1 but not raise an exception. If ty is NULL, no type-checking is performed.
    - - - -

    VALUE SWIG_NewPointerObj(void *ptr, swig_type_info *ty, int own)

    - - - -
    Creates a new Ruby pointer object. Here, ptr is the pointer to convert, ty is the SWIG type descriptor structure that describes the type, and own @@ -7889,10 +3137,6 @@ is a flag that indicates whether or not Ruby should take ownership of the pointer (i.e. whether Ruby should free this data when the corresponding Ruby instance is garbage-collected).
    - - - -

    Both of these functions require the use of a special SWIG type-descriptor structure. This structure contains information about the mangled name of the datatype, type-equivalence information, as well @@ -7900,95 +3144,45 @@ as information about converting pointer values under C++ inheritance. For a type of Foo *, the type descriptor structure is usually accessed as follows:

    - - - -
    Foo *foo;
    SWIG_ConvertPtr($input, (void **) &foo, SWIGTYPE_p_Foo, 1);

    VALUE obj;
    obj = SWIG_NewPointerObj(f, SWIGTYPE_p_Foo, 0);
    - - - - -
    - - - -

    In a typemap, the type descriptor should always be accessed using the special typemap variable $1_descriptor. For example:

    - - - -
    %typemap(in) Foo * {
    SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
    }
    - - - - -
    - - - -

    36.7.12.1 Ruby Datatype Wrapping

    VALUE Data_Wrap_Struct(VALUE class, void (*mark)(void *), void (*free)(void *), void *ptr)

    - - - -
    Given a pointer ptr to some C data, and the two garbage collection routines for this data (mark and free), return a VALUE for the Ruby object.
    - - - -

    VALUE Data_Make_Struct(VALUE class, c-type, void (*mark)(void *), void (*free)(void *), c-type *ptr)

    - - - -
    Allocates a new instance of a C data type c-type, assigns it to the pointer ptr, then wraps that pointer with Data_Wrap_Struct() as above.
    - - - -

    Data_Get_Struct(VALUE obj, c-type, c-type *ptr)

    - - - -
    Retrieves the original C pointer of type c-type from the data object obj and assigns that pointer to ptr.
    - - - -

    36.7.13 Example: STL Vector to Ruby Array

    @@ -8000,104 +3194,40 @@ The following is an example of how to construct this type of macro/typemap and should give insight into constructing similar typemaps for other STL structures:

    - - - -
    %define PTR_VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
    %typemap(out) vectorclassname &, const vectorclassname & {
    VALUE arr = rb_ary_new2($1->size());
    vectorclassname::iterator i = $1->begin(), iend = $1->end();
    for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
    $result = arr;
    }
    %typemap(out) vectorclassname, const vectorclassname {
    VALUE arr = rb_ary_new2($1.size());
    vectorclassname::iterator i = $1.begin(), iend = $1.end();
    for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
    $result = arr;
    }
    %enddef
    - - - - -
    - - - -

    Note, that the "c ## classname.klass" is used in the preprocessor step to determine the actual object from the class name.

    - - - -

    To use the macro with a class Foo, the following is used:

    - - - -
    PTR_VECTOR_TO_RUBY_ARRAY(vector<foo *="">, Foo)
    - - - - -
    - - - -

    It is also possible to create a STL vector of Ruby objects:

    - - - -
    %define RUBY_ARRAY_TO_PTR_VECTOR(vectorclassname, classname)
    %typemap(in) vectorclassname &, const vectorclassname & {
    Check_Type($input, T_ARRAY);
    vectorclassname *vec = new vectorclassname;
    int len = RARRAY($input)->len;
    for (int i=0; i!=len; i++) {
    VALUE inst = rb_ary_entry($input, i);
    //The following _should_ work but doesn't on HPUX
    // Check_Type(inst, T_DATA);
    classname *element = NULL;
    Data_Get_Struct(inst, classname, element);
    vec->push_back(element);
    }
    $1 = vec;
    }

    %typemap(freearg) vectorclassname &, const vectorclassname & {
    delete $1;
    }
    %enddef
    - - - - -
    - - - -

    It is also possible to create a Ruby array from a vector of static data types:

    - - - -
    %define VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
    %typemap(out) vectorclassname &, const vectorclassname & {
    VALUE arr = rb_ary_new2($1->size());
    vectorclassname::iterator i = $1->begin(), iend = $1->end();
    for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
    $result = arr;
    }
    %typemap(out) vectorclassname, const vectorclassname {
    VALUE arr = rb_ary_new2($1.size());
    vectorclassname::iterator i = $1.begin(), iend = $1.end();
    for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
    $result = arr;
    }
    %enddef
    - - - - -
    - - - -
    - - - - Note that this is mostly an example of typemaps. If you want to use the STL with ruby, you are advised to use the standard swig STL library, which does much more than this.  Refer to the section called the C++ Standard Template Library.
    - - - -

    36.8 Docstring Features

    @@ -8108,57 +3238,29 @@ will normally not get any documentation for it, even if they run 'rdoc' on the resulting .c or .cxx file.

    - - - -

    The features described in this section make it easy for you to add rdoc strings to your modules, functions and methods that can then be read by Ruby's rdoc tool to generate html web pages, ri documentation, Windows chm file and an .xml description.

    - - - -

    rdoc can then be run from a console or shell window on a swig generated file. 

    - - - -

    For example, to generate html web pages from a C++ file, you'd do: 

    - - - -
    $ rdoc -E cxx=c -f html file_wrap.cxx
    - - - -

    To generate ri documentation from a c wrap file, you could do:

    - - - -
    $ rdoc -r file_wrap.c
    - - - -

    36.8.1 Module docstring

    @@ -8170,46 +3272,20 @@ setting an option of the %module directive. For example:

    - - - -
    %module(docstring="This is the example module's docstring") example
    - - - - -
    - - - -

    When you have more than just a line or so then you can retain the easy readability of the %module directive by using a macro. For example:

    - - - -
    %define DOCSTRING
    "The `XmlResource` class allows program resources defining menus,
    layout of controls on a panel, etc. to be loaded from an XML file."
    %enddef

    %module(docstring=DOCSTRING) xrc
    - - - - -
    - - - -

    36.8.2 %feature("autodoc")

    @@ -8220,10 +3296,6 @@ and default values. Since Ruby ships with one of the best documentation systems of any language, it makes sense to take advantage of it.

    - - - -

    SWIG's Ruby module provides support for the "autodoc" feature, which when attached to a node in the parse tree will cause an rdoc @@ -8235,10 +3307,6 @@ several options for autodoc controlled by the value given to the feature, described below.

    - - - -

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

    @@ -8249,44 +3317,18 @@ example, given this function prototype:

    - - - -
    %feature("autodoc", "0");
    bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);
    - - - - -
    - - - -

    Then Ruby code like this will be generated:

    - - - -
    function_name(x, y, foo=nil, bar=nil) -> bool
    ...
    - - - - -
    - - - -

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

    @@ -8302,23 +3344,10 @@ parameter types with the "1" option will result in rdoc code like this:

    - - - -
    function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool
    ...
    - - - - -
    - - - -

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

    @@ -8331,10 +3360,6 @@ parameter types with the "2" option will result in Ruby code like this:

    - - - -

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

    @@ -8346,23 +3371,10 @@ parameter types with the "2" option will result in Ruby code like this:

    - - - -
    function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool

    Parameters:
    x - int
    y - int
    foo - Foo
    bar - Bar
    - - - - -
    - - - -

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

    @@ -8374,23 +3386,10 @@ feature then that string will be used in place of the automatically generated string. For example:

    - - - -
    %feature("autodoc", "GetPosition() -> (x, y)") GetPosition;
    void GetPosition(int* OUTPUT, int* OUTPUT);
    - - - - -
    - - - -

    36.8.3 %feature("docstring")

    @@ -8402,10 +3401,6 @@ docstring associated with classes, function or methods are output. If an item already has an autodoc string then it is combined with the docstring and they are output together.

    - - - -

    36.9 Advanced Topics

    @@ -8416,1016 +3411,180 @@ docstring and they are output together.

    or %rename commands in SWIG and the following operator names (derived from Python):

    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    General
    __repr__ inspect
    __str__ to_s
    __cmp__ <=>
    __hash__ hash
    __nonzero__ nonzero?
    Callable
    __call__ call
    Collection
    __len__ length
    __getitem__ []
    __setitem__ []=
    Numeric
    __add__ +
    __sub__ -
    __mul__ *
    __div__ /
    __mod__ %
    __divmod__ divmod
    __pow__ **
    __lshift__ <<
    __rshift__ >>
    __and__ &
    __xor__ ^
    __or__ |
    __neg__ -@
    __pos__ +@
    __abs__ abs
    __invert__ ~
    __int__ to_i
    __float__ to_f
    __coerce__ coerce
    Additions in 1.3.13
    __lt__ <
    __le__ <=
    __eq__ ==
    __gt__ >
    __ge__ >=
    - - - - -
    - - - -

    Note that although SWIG supports the __eq__ magic method name for defining an equivalence operator, there is no separate method for handling inequality since Ruby parses the expression a != b as !(a == b).

    - - - -

    36.9.2 Creating Multi-Module Packages

    @@ -9434,112 +3593,43 @@ with Modules discusses the basics of creating multi-module extensions with SWIG, and in particular the considerations for sharing runtime type information among the different modules.

    - - - -

    As an example, consider one module's interface file (shape.i) that defines our base class:

    - - - -
    %module shape

    %{
    #include "Shape.h"
    %}

    class Shape {
    protected:
    double xpos;
    double ypos;
    protected:
    Shape(double x, double y);
    public:
    double getX() const;
    double getY() const;
    };
    - - - - -
    - - - -

    We also have a separate interface file (circle.i) that defines a derived class:

    - - - -
    %module circle

    %{
    #include "Shape.h"
    #include "Circle.h"
    %}

    // Import the base class definition from Shape module
    %import shape.i

    class Circle : public Shape {
    protected:
    double radius;
    public:
    Circle(double x, double y, double r);
    double getRadius() const;
    };
    - - - - -
    - - - -

    We'll start by building the Shape extension module:

    - - - -
    $ swig -c++ -ruby shape.i
     
    - - - - -
    - - - -

    SWIG generates a wrapper file named shape_wrap.cxx. To compile this into a dynamically loadable extension for Ruby, prepare an extconf.rb script using this template:

    - - - -
    require 'mkmf'

    # Since the SWIG runtime support library for Ruby
    # depends on the Ruby library, make sure it's in the list
    # of libraries.
    $libs = append_library($libs, Config::CONFIG['RUBY_INSTALL_NAME'])

    # Create the makefile
    create_makefile('shape')
    - - - - -
    - - - -

    Run this script to create a Makefile and then type make to build the shared library:

    - - - -
    $ ruby extconf.rb
    creating Makefile
    $ make
    g++ -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.7/i686-linux \
    -I. -c shape_wrap.cxx
    gcc -shared -L/usr/local/lib -o shape.so shape_wrap.o -L. \
    -lruby -lruby -lc
    - - - - -
    - - - -

    Note that depending on your installation, the outputs may be slightly different; these outputs are those for a Linux-based development environment. The end result should be a shared library @@ -9547,66 +3637,25 @@ development environment. The end result should be a shared library code. Now repeat this process in a separate directory for the Circle module:

    - - - -
      - - - - -
    1. Run SWIG to generate the wrapper code (circle_wrap.cxx);
    2. - - - - -
    3. Write an extconf.rb script that your end-users can use to create a platform-specific Makefile for the extension;
    4. - - - - -
    5. Build the shared library for this extension by typing make.
    6. - - - - -
    - - - -

    Once you've built both of these extension modules, you can test them interactively in IRB to confirm that the Shape and Circle modules are properly loaded and initialized:

    - - - -
    $ irb
    irb(main):001:0> require 'shape'
    true
    irb(main):002:0> require 'circle'
    true
    irb(main):003:0> c = Circle::Circle.new(5, 5, 20)
    #<Circle::Circle:0xa097208>
    irb(main):004:0> c.kind_of? Shape::Shape
    true
    irb(main):005:0> c.getX()
    5.0
    - - - - -
    - - - -

    36.9.3 Specifying Mixin Modules

    @@ -9615,96 +3664,40 @@ it does allow you to mix one or more modules into a class using Ruby's inclu method. For example, if you have a Ruby class that defines an each instance method, e.g.

    - - - -
    class Set
    def initialize
    @members = []
    end

    def each
    @members.each { |m| yield m }
    end
    end
    - - - - -
    - - - -

    then you can mix-in Ruby's Enumerable module to easily add a lot of functionality to your class:

    - - - -
    class Set
    include Enumerable
    def initialize
    @members = []
    end
    def each
    @members.each { |m| yield m }
    end
    end
    - - - - -
    - - - -

    To get the same benefit for your SWIG-wrapped classes, you can use the %mixin directive to specify the names of one or more modules that should be mixed-in to a class. For the above example, the SWIG interface specification might look like this:

    - - - -
    %mixin Set "Enumerable";

    class Set {
    public:
    // Constructor
    Set();

    // Iterates through set members
    void each();
    };
    - - - - -
    - - - -

    Multiple modules can be mixed into a class by providing a comma-separated list of module names to the %mixin directive, e.g.

    - - - -
    %mixin Set "Fee,Fi,Fo,Fum";
    - - - - -
    - - - -

    Note that the %mixin directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    - - - -

    36.10 Memory Management

    @@ -9713,45 +3706,21 @@ Ruby is proper memory management. The key to proper memory management is clearly defining whether a wrapper Ruby object owns the underlying C struct or C++ class. There are two possibilities:

    - - - -
      - - - -
    • The Ruby object is responsible for freeing the C struct or C++ object
    • - - - -
    • The Ruby object should not free the C struct or C++ object because it will be freed by the underlying C or C++ code
    • - - - -
    - - - -

    To complicate matters, object ownership may transfer from Ruby to C++ (or vice versa) depending on what function or methods are invoked. Clearly, developing a SWIG wrapper requires a thorough understanding of how the underlying library manages memory.

    - - - -

    36.10.1 Mark and Sweep Garbage Collector

    @@ -9769,37 +3738,21 @@ In the sweep phase, all objects that have not been marked will be garbage collected. For more information about the Ruby garbage collector please refer to http://rubygarden.org/ruby/ruby?GCAndExtensions.

    - - - -

    The Ruby C/API provides extension developers two hooks into the garbage collector - a "mark" function and a "sweep" function. By default these functions are set to NULL.

    - - - -

    If a C struct or C++ class references any other Ruby objects, then it must provide a "mark" function. The "mark" function should identify any referenced Ruby objects by calling the rb_gc_mark function for each one. Unsurprisingly, this function will be called by the Ruby garbage during the "mark" phase.

    - - - -

    During the sweep phase, Ruby destroys any unused objects. If any memory has been allocated in creating the underlying C struct or C++ struct, then a "free" function must be defined that deallocates this memory.

    - - - -

    36.10.2 Object Ownership

    @@ -9810,171 +3763,70 @@ then a "free" function must be registered for the object. If the Ruby object is not responsible for freeing the underlying memory, then a "free" function must not be registered for the object.

    - - - -

    For the most part, SWIG takes care of memory management issues. The rules it uses are:

    - - - -
      - - - -
    • When calling a C++ object's constructor from Ruby, SWIG will assign a "free" function thereby making the Ruby object responsible for freeing the C++ object
    • - - - -
    • When calling a C++ member function that returns a pointer, SWIG will not assign a "free" function thereby making the underlying library responsible for freeing the object.
    • - - - -
    - - - -

    To make this clearer, let's look at an example. Assume we have a Foo and a Bar class.

    - - - -
    /* File "RubyOwernshipExample.h" */

    class Foo
    {
    public:
    Foo() {}
    ~Foo() {}
    };

    class Bar
    {
    Foo *foo_;
    public:
    Bar(): foo_(new Foo) {}
    ~Bar() { delete foo_; }
    Foo* get_foo() { return foo_; }
    Foo* get_new_foo() { return new Foo; }
    void set_foo(Foo *foo) { delete foo_; foo_ = foo; }
    };

    - - - - -
    - - - -

    First, consider this Ruby code:

    - - - -
    foo = Foo.new
    - - - - -
    - - - -

    In this case, the Ruby code calls the underlying Foo C++ constructor, thus creating a new foo object. By default, SWIG will assign the new Ruby object a "free" function. When the Ruby object is garbage collected, the "free" function will be called. It in turn will call Foo's destructor.

    - - - -

    Next, consider this code:

    - - - -
    bar = Bar.new
    foo = bar.get_foo()
    - - - - -
    - - - -

    In this case, the Ruby code calls a C++ member function, get_foo. By default, SWIG will not assign the Ruby object a "free" function. Thus, when the Ruby object is garbage collected the underlying C++ foo object is not affected.

    - - - -

    Unfortunately, the real world is not as simple as the examples above. For example:

    - - - -
    bar = Bar.new
    foo = bar.get_new_foo()
    - - - - -
    - - - -

    In this case, the default SWIG behavior for calling member functions is incorrect. The Ruby object should assume ownership of the returned object. This can be done by using the %newobject directive. See Object ownership and %newobject for more information.

    - - - -

    The SWIG default mappings are also incorrect in this case:

    - - - -
    foo = Foo.new
    bar = Bar.new
    bar.set_foo(foo)
    - - - - -
    - - - -

    Without modification, this code will cause a segmentation fault. When the Ruby foo object goes out of scope, it will free the underlying C++ foo @@ -9985,17 +3837,9 @@ Ruby object to the C++ object when the set_foo method is called. This can be done by using the special DISOWN type map, which was added to the Ruby bindings in SWIG-1.3.26.

    - - - -

    Thus, a correct SWIG interface file correct mapping for these classes is:

    - - - -
    /* File RubyOwnershipExample.i */
     
    @@ -10027,37 +3871,11 @@ public:
      void set_foo(Foo *foo);
      %clear Foo *foo;
     };
    -
     
    - - - - -
    - - - - -
    - - - - -

    This code can be seen in swig/examples/ruby/tracking.

    - - - - -
    - - - - -

    36.10.3 Object Tracking

    @@ -10065,35 +3883,14 @@ public: shown below to illustrate different memory management techniques. The class library models a zoo and the animals it contains.

    - - - -
    %module zoo

    %{
    #include <string>
    #include <vector>

    #include "zoo.h"
    %}

    class Animal
    {
    private:
    typedef std::vector<Animal*> AnimalsType;
    typedef AnimalsType::iterator IterType;
    protected:
    AnimalsType animals;
    protected:
    std::string name_;
    public:
    // Construct an animal with this name
    Animal(const char* name) : name_(name) {}

    // Return the animal's name
    const char* get_name() const { return name.c_str(); }
    };

    class Zoo
    {
    protected:
    std::vector<animal *=""> animals;

    public:
    // Construct an empty zoo
    Zoo() {}

    /* Create a new animal. */
    static Animal* Zoo::create_animal(const char* name)
    {
    return new Animal(name);
    }

    // Add a new animal to the zoo
    void add_animal(Animal* animal) {
    animals.push_back(animal);
    }

    Animal* remove_animal(size_t i) {
    Animal* result = this->animals[i];
    IterType iter = this->animals.begin();
    std::advance(iter, i);
    this->animals.erase(iter);

    return result;
    }

    // Return the number of animals in the zoo
    size_t get_num_animals() const {
    return animals.size();
    }

    // Return a pointer to the ith animal
    Animal* get_animal(size_t i) const {
    return animals[i];
    }
    };

    - - - - -
    - - - -

    Let's say you SWIG this code and then run IRB:
    - - - -

    - - - -
    $ irb
     irb(main):001:0> require 'example'
    @@ -10122,33 +3919,15 @@ irb(main):008:0> tiger2.get_name()
     
     irb(main):009:0> tiger1.equal?(tiger2)
     => false
    -
     
    - - - - -
    - - - -

    Pay particular attention to the code tiger1.equal?(tiger2). Note that the two Ruby objects are not the same - but they reference the same underlying C++ object. This can cause problems. For example:
    - - - -

    - - - -
    irb(main):010:0> tiger1 = nil
     => nil
    @@ -10158,19 +3937,9 @@ irb(main):011:0> GC.start
     
     irb(main):012:0> tiger2.get_name()
     (irb):12: [BUG] Segmentation fault
    -
     
    - - - - -
    - - - -

    After the garbage collector runs, as a result of our call to GC.start, callingtiger2.get_name() causes a segmentation fault. The problem is that when tiger1 @@ -10178,116 +3947,45 @@ is garbage collected, it frees the underlying C++ object. Thus, when tiger2< calls the get_name() method it invokes it on a destroyed object.

    - - - -

    This problem can be avoided if SWIG enforces a one-to-one mapping between Ruby objects and C++ classes. This can be done via the use of the %trackobjects functionality available in SWIG-1.3.26. and later.

    - - - -

    When the %trackobjects is turned on, SWIG automatically keeps track of mappings between C++ objects and Ruby objects. Note that enabling object tracking causes a slight performance degradation. Test results show this degradation to be about 3% to 5% when creating and destroying 100,000 animals in a row.

    - - - -

    Since %trackobjects is implemented as a %feature, it uses the same name matching rules as other kinds of features (see the chapter on "Customization Features") . Thus it can be applied on a class-by-class basis if needed. To fix the example above:

    - - - - -
    - - - - -
    %module example

    %{
    #include "example.h"
    %}

    /* Tell SWIG that create_animal creates a new object */
    %newobject Zoo::create_animal;

    /* Tell SWIG to keep track of mappings between C/C++ structs/classes. */
    %trackobjects;

    %include "example.h"
    - - - - -
    - - - -

    When this code runs we see:
    - - - - -
    - - - - -

    - - - -
    $ irb
    irb(main):001:0> require 'example'
    => true

    irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
    => #<Example::Animal:0x2be37d8>

    irb(main):003:0> zoo = Example::Zoo.new()
    => #<Example::Zoo:0x2be0a18>

    irb(main):004:0> zoo.add_animal(tiger1)
    => nil

    irb(main):006:0> tiger2 = zoo.remove_animal(0)
    => #<Example::Animal:0x2be37d8>

    irb(main):007:0> tiger1.equal?(tiger2)
    => true

    irb(main):008:0> tiger1 = nil
    => nil

    irb(main):009:0> GC.start
    => nil

    irb(main):010:0> tiger.get_name()
    => "tiger1"
    irb(main):011:0>

    - - - - -
    - - - -

    For those who are interested, object tracking is implemented by storing Ruby objects in a hash table and keying them on C++ pointers. The underlying API is:
    - - - -

    - - - -
    static void SWIG_RubyAddTracking(void* ptr, VALUE object);
    static VALUE SWIG_RubyInstanceFor(void* ptr) ;
    static void SWIG_RubyRemoveTracking(void* ptr);
    static void SWIG_RubyUnlinkObjects(void* ptr);
    - - - - -
    - - - -

    When an object is created, SWIG will automatically call the SWIG_RubyAddTracking method. Similarly, when an object is deleted, SWIG will call the SWIG_RubyRemoveTracking. When an object is returned to Ruby from C++, SWIG will use the SWIG_RubyInstanceFor @@ -10295,58 +3993,29 @@ method to ensure a one-to-one mapping from Ruby to C++ objects. Last, the RubyUnlinkObjects method unlinks a Ruby object from its underlying C++ object.

    - - - -

    In general, you will only need to use the SWIG_RubyInstanceFor, which is required for implementing mark functions as shown below. However, if you implement your own free functions (see below) you may also have to call the SWIG_RubyRemoveTracking and RubyUnlinkObjects methods.

    - - - -

    36.10.4 Mark Functions

    With a bit more testing, we see that our class library still has problems. For example:
    - - - -

    - - - -
    $ irb
    irb(main):001:0> require 'example'
    => true

    irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
    => #<Example::Animal:0x2bea6a8>

    irb(main):003:0> zoo = Example::Zoo.new()
    => #<Example::Zoo:0x2be7960>

    irb(main):004:0> zoo.add_animal(tiger1)
    => nil

    irb(main):007:0> tiger1 = nil
    => nil

    irb(main):007:0> GC.start
    => nil

    irb(main):005:0> tiger2 = zoo.get_animal(0)
    (irb):12: [BUG] Segmentation fault
    - - - - -
    - - - -

    The problem is that Ruby does not know that the zoo object contains a reference to a Ruby object. Thus, when Ruby garbage collects tiger1 it frees the underlying C++ object.

    - - - -

    This can be fixed by implementing a mark function as described above in the Mark and Sweep Garbage Collector section. You can specify a mark @@ -10356,10 +4025,6 @@ SWIG's' "features" mechanism it uses the same name matching rules as other kinds of features (see the chapter on "Customization Features" for more details).

    - - - -

    A mark function takes a single argument, which is a pointer to the C++ object being marked; it should, in turn, call rb_gc_mark() for any instances that are @@ -10369,64 +4034,24 @@ objects in the zoo object, look up their Ruby object equivalent, and then call rb_gc_mark(). One possible implementation is:

    - - - -
    %module example

    %{
    #include "example.h"
    %}

    /* Keep track of mappings between C/C++ structs/classes
    and Ruby objects so we can implement a mark function. */
    %trackobjects;

    /* Specify the mark function */
    %markfunc Zoo "mark_Zoo";

    %include "example.h"

    %header %{

    static void mark_Zoo(void* ptr) {
    Zoo* zoo = (Zoo*) ptr;

    /* Loop over each object and tell the garbage collector
    that we are holding a reference to them. */
    int count = zoo->get_num_animals();

    for(int i = 0; i < count; ++i) {
    Animal* animal = zoo->get_animal(i);
    VALUE object = SWIG_RubyInstanceFor(animal);

    if (object != Qnil) {
    rb_gc_mark(object);
    }
    }
    }
    %}

    - - - - -
    - - - -

    Note the mark function is dependent on the SWIG_RUBY_InstanceFor method, and thus requires that %trackobjects is enabled. For more information, please refer to the track_object.i test case in the SWIG test suite.

    - - - -

    When this code is compiled we now see:

    - - - -
    $ irb
    irb(main):002:0> tiger1=Example::Animal.new("tiger1")
    => #<Example::Animal:0x2be3bf8>

    irb(main):003:0> Example::Zoo.new()
    => #<Example::Zoo:0x2be1780>

    irb(main):004:0> zoo = Example::Zoo.new()
    => #<Example::Zoo:0x2bde9c0>

    irb(main):005:0> zoo.add_animal(tiger1)
    => nil

    irb(main):009:0> tiger1 = nil
    => nil

    irb(main):010:0> GC.start
    => nil
    irb(main):014:0> tiger2 = zoo.get_animal(0)
    => #<Example::Animal:0x2be3bf8>

    irb(main):015:0> tiger2.get_name()
    => "tiger1"
    irb(main):016:0>

    - - - - -
    - - - - -
    - - - - -

    This code can be seen in swig/examples/ruby/mark_function.

    - - - -

    36.10.5 Free Functions

    @@ -10434,10 +4059,6 @@ test suite.

    a Ruby object is garbage collected. The free function simply calls the C++ object's destructor.

    - - - -

    However, sometimes an appropriate destructor does not exist or special processing needs to be performed before the destructor is called. Therefore, SWIG allows you to manually specify a "free" @@ -10447,10 +4068,6 @@ SWIG's' "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    - - - -

    IMPORTANT ! - If you define your own free function, then you must ensure that you call the underlying C++ object's destructor. In addition, if object tracking is activated for the object's class, you @@ -10459,10 +4076,6 @@ function (of course call this before you destroy the C++ object). Note that it is harmless to call this method if object tracking if off so it is advised to always call it.

    - - - -

    Note there is a subtle interaction between object ownership and free functions. A custom defined free function will only be called if the Ruby object owns the underlying C++ object. This also to Ruby @@ -10470,10 +4083,6 @@ objects which are created, but then transfer ownership to C++ objects via the use of the disown typemap described above.

    - - - -

    To show how to use the %freefunc directive, let's slightly change our example. Assume that the zoo object is responsible for freeing animal that it contains. This means @@ -10481,10 +4090,6 @@ that the Zoo::add_animal function should be marked with a DISOWN typemap and the destructor should be updated as below:

    - - - -
    Zoo::~Zoo() {
      IterType iter = this->animals.begin();
    @@ -10495,23 +4100,10 @@ and the destructor should be updated as below:

    delete animal; } }
    - - - - -
    - - - -

    When we use these objects in IRB we see:

    - - - -
    $irb
     irb(main):002:0> require 'example'
    @@ -10534,19 +4126,9 @@ irb(main):008:0> GC.start
     
     irb(main):009:0> tiger1.get_name()
     (irb):12: [BUG] Segmentation fault
    -
     
    - - - - -
    - - - -

    The error happens because the C++ animal object is freed when the zoo object is freed. Although this error is unavoidable, we can at least prevent the @@ -10557,16 +4139,8 @@ function notifies SWIG that a Ruby object's underlying C++ object is no longer valid. Once notified, SWIG will intercept any calls from the existing Ruby object to the destroyed C++ object and raise an exception.
    - - - -

    - - - -
    %module example
     
    @@ -10606,28 +4180,14 @@ existing Ruby object to the destroyed C++ object and raise an exception.
    /* Now call SWIG_RubyRemoveTracking for the zoo */ SWIG_RubyRemoveTracking(ptr); - /* Now free the zoo which will free the animals it contains */ delete zoo; } %}
    - - - - -
    - - - -

    Now when we use these objects in IRB we see:

    - - - -
    $irb
     irb(main):002:0> require 'example'
    @@ -10653,30 +4213,13 @@ RuntimeError: This Animal * already released
      from (irb):10:in `get_name'
      from (irb):10
     irb(main):011:0>
    - - - - -
    - - - -

    Notice that SWIG can now detect the underlying C++ object has been freed, and thus raises a runtime exception.

    - - - -

    This code can be seen in swig/examples/ruby/free_function.

    - - - -

    36.10.6 Embedded Ruby and the C++ Stack

    @@ -10687,25 +4230,13 @@ also try to mark any Ruby objects (VALUE) it finds in the machine registers and in the C++ stack.

    - - - -

    The stack is basically the history of the functions that have been called and also contains local variables, such as the ones you define whenever you do inside a function:

    - - - -
    VALUE obj;
    - - - -

    For ruby to determine where its stack space begins, during initialization a normal Ruby interpreter will call the ruby_init() function which in turn will call a function called Init_stack or @@ -10713,10 +4244,6 @@ similar.  This function will store a pointer to the location where the stack points at that point in time.

    - - - -

    ruby_init() is presumed to always be called within the main() function of your program and whenever the GC is called, ruby will assume that the memory between the current location in memory and the @@ -10724,19 +4251,11 @@ pointer that was stored previously represents the stack, which may contain local (and temporary) VALUE ruby objects.   Ruby will then be careful not to remove any of those objects in that location.

    - - - -

    So far so good.  For a normal Ruby session, all the above is completely transparent and magic to the extensions developer.   

    - - - -

    However, with an embedded Ruby, it may not always be possible to modify main() to make sure ruby_init() is called there.   As @@ -10750,17 +4269,9 @@ is called.  The end result: random crashes and segmentation faults.

    - - - -

    This problem will often be seen in director functions that are used for callbacks, for example.  

    - - - -

    To solve the problem, SWIG can now generate code with director functions containing the optional macros SWIG_INIT_STACK and SWIG_RELEASE_STACK.   These macros will try to force Ruby to @@ -10769,43 +4280,22 @@ director function is called.  This will lead Ruby to measure and not collect any VALUE objects defined from that point on.  

    - - - -

    To mark functions to either reset the ruby stack or not, you can use:

    - - - -
    %initstack   Class::memberfunction;  // only re-init the stack in this director method
    - - - - %ignorestack Class::memberfunction;  // do not re-init the stack in this director method
    - - - - %initstack   Class;               // init the stack on all the methods of this class
    - - - - %initstack;   // all director functions will re-init the stack
    - From a7515a725e22e7375d10c90727fba860fb56757b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Jun 2013 23:18:50 +0100 Subject: [PATCH 216/273] Remove use of monospace in Ruby docs and unncessary usage of
    --- Doc/Manual/Ruby.html | 737 +++++++++++++++++++++---------------------- 1 file changed, 359 insertions(+), 378 deletions(-) diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index d1dcbfab0..1798d1df7 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -166,7 +166,7 @@ of Ruby.

    option:

    -
    $ swig -ruby example.i
    +
    $ swig -ruby example.i
     
    @@ -174,7 +174,7 @@ option:

    option:

    -
    $ swig -c++ -ruby example.i
    +
    $ swig -c++ -ruby example.i
     
    @@ -200,7 +200,7 @@ location is typical. If you are not entirely sure where Ruby is installed, you can run Ruby to find out. For example:

    -
    $ ruby -e 'puts $:.join("\n")'
    +
    $ ruby -e 'puts $:.join("\n")'
     /usr/local/lib/ruby/site_ruby/1.6 /usr/local/lib/ruby/site_ruby/1.6/i686-linux
     /usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .
     
    @@ -226,7 +226,10 @@ looks like the following:

  • Type the following to build the extension:

    -
    $ ruby extconf.rb
    $ make
    $ make install +
    +$ ruby extconf.rb
    +$ make
    +$ make install
         
  • @@ -254,10 +257,10 @@ called example.c, a typical sequence of commands for the Linux operating system would look something like this:

    -
    $ swig -ruby example.i
    -$ gcc -c example.c
    -$ gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux 
    -$ gcc -shared example.o example_wrap.o -o example.so
    +
    $ swig -ruby example.i
    +$ gcc -c example.c
    +$ gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
    +$ gcc -shared example.o example_wrap.o -o example.so
     
    @@ -291,7 +294,7 @@ name for your extension. So for example, a SWIG interface file that begins with:

    -
    %module example
    +
    %module example

    will result in an extension module using the feature name @@ -319,7 +322,11 @@ finally rebuilding Ruby.

    using the C++ compiler. For example:

    -
    $ swig -c++ -ruby example.i
    $ g++ -c example.cxx
    $ g++ -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
    $ g++ -shared example.o example_wrap.o -o example.so +
    +$ swig -c++ -ruby example.i
    +$ g++ -c example.cxx
    +$ g++ -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
    +$ g++ -shared example.o example_wrap.o -o example.so
     
    @@ -349,7 +356,10 @@ script) will work with Windows as well; you should be able to build your code into a DLL by typing:

    -
    C:\swigtest> ruby extconf.rb
    C:\swigtest> nmake
    C:\swigtest> nmake install +
    +C:\swigtest> ruby extconf.rb
    +C:\swigtest> nmake
    +C:\swigtest> nmake install
     
    @@ -414,7 +424,10 @@ example if you have this ruby file run.rb:

    directory, then run the Ruby script from the DOS/Command prompt:

    -
    C:\swigtest> ruby run.rb
    Foo = 3.0
    +
    +C:\swigtest> ruby run.rb
    +Foo = 3.0
    +

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

    @@ -443,33 +456,34 @@ quotes, e.g.

    An alternate method of specifying a nested module name is to -use the -prefix +use the -prefix option on the SWIG command line. The prefix that you specify with this -option will be prepended to the module name specified with the %module +option will be prepended to the module name specified with the %module directive in your SWIG interface file. So for example, this declaration -at the top of your SWIG interface file:
    - +at the top of your SWIG interface file:

    %module "foo::bar::spam"
    -

    will result in a nested module name of Foo::Bar::Spam, +

    will result in a nested module name of Foo::Bar::Spam, but you can achieve the same -effect by specifying:
    +effect by specifying:

    %module spam
    -

    and then running SWIG with the -prefix command -line option:
    +

    and then running SWIG with the -prefix command +line option:

    -
    $ swig -ruby -prefix "foo::bar::" example.i
    +
    +$ swig -ruby -prefix "foo::bar::" example.i
    +

    Starting with SWIG 1.3.20, you can also choose to wrap @@ -477,7 +491,9 @@ everything into the global module by specifying the -globalmodule option on the SWIG command line, i.e.

    -
    $ swig -ruby -globalmodule example.i
    +
    +$ swig -ruby -globalmodule example.i
    +

    Note that this does not relieve you of the requirement of @@ -721,7 +737,7 @@ utility methods work normally:

    Furthermore, if you have a function like this:

    -
    void spam(Parent *f);
    +
    void spam(Parent *f);

    then the function spam() accepts Parent* @@ -758,7 +774,9 @@ an optional feature that you can activate with the -minherit command-line option:

    -
    $ swig -c++ -ruby -minherit example.i
    +
    +$ swig -c++ -ruby -minherit example.i
    +

    Using our previous example, if your SWIG interface file @@ -1004,45 +1022,37 @@ do that, you need to define a container that contains a swig::GC_VALUE, like:

    -
    %module -nativevector
    -
    +
    +%module nativevector
     
    -%{
    -std::vector< swig::GC_VALUE > NativeVector;
    -%}
    -
    +%{ +std::vector< swig::GC_VALUE > NativeVector; +%} -%template(NativeVector) std::vector< swig::GC_VALUE >;
    +%template(NativeVector) std::vector< swig::GC_VALUE >; +
    -
    -

    This vector can then contain any Ruby object, making them almost identical to Ruby's own Array class.

    -
    require 'nativevector'
    +
    +
    require 'nativevector'
    +include NativeVector
     
    -include NativeVector
    +v = NativeVector.new +v << 1 +v << [1,2] +v << 'hello' -
    +class A; end -v = NativeVector.new
    -v << 1
    -v << -[1,2]
    -v << -'hello'
    -
    -class A; end
    -
    -v << -A.new
    -
    -puts v
    -=> -[1, [1,2], 'hello', #<A:0x245325>]
    -
    +v << A.new + +puts v +=> [1, [1,2], 'hello', #<A:0x245325>] +
    +

    Obviously, there is a lot more to template wrapping than shown in these examples. More details can be found in the SWIG and C++ @@ -1053,7 +1063,7 @@ chapter.

    Some containers in the STL allow you to modify their default behavior by using so called functors or function objects. - Functors are often just a very simple struct with operator() + Functors are often just a very simple struct with operator() redefined or an actual C/C++ function.  This allows you, for example, to always keep the sort order of a STL container to your liking.

    @@ -1062,58 +1072,51 @@ liking.

    that support functors using Ruby procs or methods, instead.  Currently, -this includes std::set, -set::map, -std::multiset -and std::multimap.

    +this includes std::set, +set::map, +std::multiset +and std::multimap.

    -

    The functors in swig are called swig::UnaryFunction -and swig::BinaryFunction.
    +

    The functors in swig are called swig::UnaryFunction +and swig::BinaryFunction. -For C++ predicates (ie. functors that must return bool as a result) swig::UnaryPredicate -and swig::BinaryPredicate +For C++ predicates (ie. functors that must return bool as a result) swig::UnaryPredicate +and swig::BinaryPredicate are provided.

    As an example, if given this swig file:

    -
    %module -intset;
    -
    -%include <std_set.i>
    -
    +
    +%module intset;
     
    -%typemap(IntSet)  std::set< int, swig::BinaryPredicate
    ->;
    +%include <std_set.i> + +%typemap(IntSet)  std::set< int, swig::BinaryPredicate >; +

    You can then use the set from Ruby with or without a proc object as a predicate:

    -
    require -'intset'
    +
    +require 'intset'
    +include Intset
     
    -include Intset
    -
    -# Default sorting behavior defined in C++
    -a = IntSet.new
    - -a << 1
    -a << 2
    -a << 3
    -a
    - -=> - [1,2,3]
    -
    +# Default sorting behavior defined in C++ +a = IntSet.new +a << 1 +a << 2 +a << 3 +a +=> [1,2,3] # Custom sorting behavior defined by a Ruby proc -
    b = IntSet.new( proc { -|a,b| a > b } )
    -b << 1
    -b << 2
    -b << 3
    -b
    -=> - [3,2,1]
    +b = IntSet.new( proc { |a,b| a > b } ) +b << 1 +b << 2 +b << 3 +b +=>  [3,2,1] +

    36.3.15 C++ STL Iterators

    @@ -1127,8 +1130,8 @@ values they point at, while the non-const iterators can both read and modify the values.

    The Ruby STL wrappings support both type of iterators by using -a proxy class in-between.  This proxy class is swig::Iterator or -swig::ConstIterator.  Derived from them are template +a proxy class in-between.  This proxy class is swig::Iterator or +swig::ConstIterator.  Derived from them are template classes that need to be initialized with the actual iterator for the container you are wrapping and often times with the beginning and ending points of the iteration range. 

    @@ -1136,86 +1139,68 @@ ending points of the iteration range. 

    The SWIG STL library already provides typemaps to all the standard containers to do this wrapping automatically for you, but if you have your own STL-like iterator, you will need to write your own -typemap for them.  For out typemaps, the special functions make_const_iterator and make_nonconst_iterator are provided.

    +typemap for them.  For out typemaps, the special functions make_const_iterator and make_nonconst_iterator are provided.

    These can be used either like:

    -
    make_const_iterator( iterator, rubyclass );
    +
    +make_const_iterator( iterator, rubyclass );
    +make_const_iterator( iterator, iterator_begin, iterator_end, rubyclass );
    +
    -make_const_iterator( iterator, iterator_begin, iterator_end, rubyclass );
    - -

    The iterators support a next() and previous() member function to -just change the iterator without returning anything.  previous() +

    The iterators support a next() and previous() member function to +just change the iterator without returning anything.  previous() should obviously only be used for bidirectional iterators.  You can also advance the iterator multiple steps by using standard math -operations like +=.

    +operations like +=.

    The -value the iterator points at can be accessed with value() -- this is equivalent to dereferencing it with *i. -  For non-const iterators, a value=() function +value the iterator points at can be accessed with value() -- this is equivalent to dereferencing it with *i. +  For non-const iterators, a value=() function is also provided which allows you to change the value pointed by the -iterator.  This is equivalent to the C++ construct of dereferencing and assignment, like *i = something

    +iterator.  This is equivalent to the C++ construct of dereferencing and assignment, like *i = something

    Thus, given say a vector class of doubles defined as:

    -
    %module doublevector
    +
    +
    +%module doublevector
     
    -
    +%include std_vector.i -%include std_vector.i

    - -
    - -%template(DoubleVector) std::vector<double>;
    +%template(DoubleVector) std::vector<double>; +
    +

    Its iterator can then be used from Ruby like:

    -
    require -'doublevector'
    +
    +
    +require 'doublevector'
    +include Doublevector
     
    -include Doublevector
    +v = DoubleVector.new +v << 1 +v << 2 +v << 3 -
    +# +# an elaborate and less efficient way of doing v.map! { |x| x+2 } +# +i = v.begin +e = v.end +while i != e +  val = i.value +  val += 2 +  i.value = val +  i.next +end +i +>> [3, 4, 5 ] +
    +
    -v = DoubleVector.new
    - -v << 1
    - -v << 2
    - -v << 3
    - -
    - -#
    - -# an elaborate and less efficient way of doing v.map! { |x| x+2 }
    - -#
    - -i = v.begin
    - -e = v.end
    - -while i != e
    - -  val = i.value
    - -  val += 2
    - -  i.value = val
    - -  i.next
    - -end
    - -i
    - ->> [3, 4, 5 ]
    - -
    - -

    If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

    +

    If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

    36.3.16 C++ Smart Pointers

    @@ -1321,7 +1306,7 @@ constant, class and method names to conform with the standard Ruby naming conventions. For example:

    -
    $ swig -ruby -autorename example.i
    +
    $ swig -ruby -autorename example.i
     
    @@ -1637,37 +1622,38 @@ construction:

    Then, in ruby, it can be used like:

    -
    Window.new(0,0,360,480) -{ |w|
    - -    w.color = Fltk::RED
    - -    w.border = false
    - -}
    +
    +Window.new(0,0,360,480) { |w|
    +    w.color = Fltk::RED
    +    w.border = false
    +}
    +
    +

    For other methods, you can usually use a dummy parameter with a special in typemap, like:

    -
    //
    +
    +//
    +// original function was:
    +//
    +// void func(int x);
     
    -// original function was:
    -//
    -// void func(int x);
    -
    -%typemap(in,numinputs=0) int RUBY_YIELD_SELF {
    -     if ( !rb_block_given_p() )
    +%typemap(in,numinputs=0) int RUBY_YIELD_SELF { +     if ( !rb_block_given_p() )             -rb_raise("No block given");
    -     return rb_yield(self);
    -}
    -
    -%extend {
    +rb_raise("No block given"); +     return rb_yield(self); +} + +%extend {         void func(int x, int -RUBY_YIELD_SELF );
    -}
    +RUBY_YIELD_SELF ); +} +
    +

    For more information on typemaps, see Typemaps.

    @@ -1685,118 +1671,118 @@ from SWIG error codes to Ruby exceptions:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + @@ -2951,14 +3554,54 @@ terminated strings. The following SWIG interface file allows a Ruby Array instance to be used as a char ** object.

    -
    %module argv

    // This tells SWIG to treat char ** as a special case
    %typemap(in) char ** {
    /* Get the length of the array */
    int size = RARRAY($input)->len;
    int i;
    $1 = (char **) malloc((size+1)*sizeof(char *));
    /* Get the first element in memory */
    VALUE *ptr = RARRAY($input)->ptr;
    for (i=0; i < size; i++, ptr++)
    /* Convert Ruby Object String to char* */
    $1[i]= StringValuePtr(*ptr);
    $1[i]=NULL; /* End of list */
    }

    // This cleans up the char ** array created before
    // the function call

    %typemap(freearg) char ** {
    free((char *) $1);
    }

    // Now a test function
    %inline %{
    int print_args(char **argv) {
    int i = 0;
    while (argv[i]) {
    printf("argv[%d] = %s\n", i,argv[i]);
    i++;
    }
    return i;
    }
    %}

    +
    %module argv
    +
    +// This tells SWIG to treat char ** as a special case
    +%typemap(in) char ** {
    +  /* Get the length of the array */
    +  int size = RARRAY($input)->len; 
    +  int i;
    +  $1 = (char **) malloc((size+1)*sizeof(char *));
    +  /* Get the first element in memory */
    +  VALUE *ptr = RARRAY($input)->ptr; 
    +  for (i=0; i < size; i++, ptr++) {
    +    /* Convert Ruby Object String to char* */
    +    $1[i]= StringValuePtr(*ptr); 
    +  }
    +  $1[i]=NULL; /* End of list */
    +}
    +
    +// This cleans up the char ** array created before 
    +// the function call
    +
    +%typemap(freearg) char ** {
    +  free((char *) $1);
    +}
    +
    +// Now a test function
    +%inline %{
    +int print_args(char **argv) {
    +  int i = 0;
    +  while (argv[i]) {
    +    printf("argv[%d] = %s\n", i,argv[i]);
    +    i++;
    +  }
    +  return i;
    +}
    +%}

    When this module is compiled, the wrapped C function now operates as follows :

    -
    require 'Argv'
    Argv.print_args(["Dave","Mike","Mary","Jane","John"])
    argv[0] = Dave
    argv[1] = Mike
    argv[2] = Mary
    argv[3] = Jane
    argv[4] = John
    +
    require 'Argv'
    +Argv.print_args(["Dave","Mike","Mary","Jane","John"])
    +argv[0] = Dave
    +argv[1] = Mike
    +argv[2] = Mary
    +argv[3] = Jane
    +argv[4] = John

    In the example, two different typemaps are used. The "in" @@ -2980,14 +3623,17 @@ suppose you'd like to wrap this C function that collects information about people's vital statistics:

    -
    void setVitalStats(const char *person, int nattributes, const char **names, int *values);
    +
    void setVitalStats(const char *person, int nattributes, const char **names, int *values);

    and you'd like to be able to call it from Ruby by passing in an arbitrary number of key-value pairs as inputs, e.g.

    -
    setVitalStats("Fred",
    'weight' => 270,
    'age' => 42
    )
    +
    setVitalStats("Fred", 
    +  'weight' => 270, 
    +  'age' => 42 
    +)

    To make this work, you need to write a typemap that expects a @@ -2997,7 +3643,10 @@ and values) needed by your C function. Let's start with the basics:

    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    }
    +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +}
    + 

    This %typemap directive tells SWIG that @@ -3016,7 +3665,10 @@ will need.

    let's next add a check for that:

    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    }
    +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +    Check_Type($input, T_HASH);
    +}

    Check_Type() is just a macro (defined @@ -3032,7 +3684,11 @@ method directly and converting its result to a C int value:

    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    }
    +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +    Check_Type($input, T_HASH);
    +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    +}

    So now we know the number of attributes. Next we need to @@ -3041,7 +3697,17 @@ arrays) to NULL and set the stage for extracting the keys and values from the hash:

    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    }

    }
    +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +    Check_Type($input, T_HASH);
    +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    +    $2 = NULL;
    +    $3 = NULL;
    +    if ($1 > 0) {
    +      $2 = (char **) malloc($1*sizeof(char *));
    +      $3 = (int *) malloc($1*sizeof(int));
    +    }
    +}

    There are a number of ways we could extract the keys and @@ -3050,7 +3716,20 @@ the hash's keys method (which returns a Ruby array of the keys) and then start looping over the elements in that array:

    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
    }

    }
    }
    +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +    Check_Type($input, T_HASH);
    +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    +    $2 = NULL;
    +    $3 = NULL;
    +    if ($1 > 0) {
    +      $2 = (char **) malloc($1*sizeof(char *));
    +      $3 = (int *) malloc($1*sizeof(int));
    +      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    +      for (i = 0; i < $1; i++) {
    +      }
    +    }
    +}

    Recall that keys_arr and i @@ -3059,7 +3738,22 @@ array, we want to get the key itself, as well as the value corresponding to that key in the hash:

    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
    key = rb_ary_entry(keys_arr, i);
    val = rb_hash_aref($input, key);

    }
    }
    }
    +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +    Check_Type($input, T_HASH);
    +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    +    $2 = NULL;
    +    $3 = NULL;
    +    if ($1 > 0) {
    +      $2 = (char **) malloc($1*sizeof(char *));
    +      $3 = (int *) malloc($1*sizeof(int));
    +      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    +      for (i = 0; i < $1; i++) {
    +        key = rb_ary_entry(keys_arr, i);
    +        val = rb_hash_aref($input, key);
    +      }
    +    }
    +}

    To be safe, we should again use the Check_Type() @@ -3067,14 +3761,50 @@ macro to confirm that the key is a String and the value is a Fixnum:

    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
    key = rb_ary_entry(keys_arr, i);
    val = rb_hash_aref($input, key);
    Check_Type(key, T_STRING);
    Check_Type(val, T_FIXNUM);

    }
    }
    }
    +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +    Check_Type($input, T_HASH);
    +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    +    $2 = NULL;
    +    $3 = NULL;
    +    if ($1 > 0) {
    +      $2 = (char **) malloc($1*sizeof(char *));
    +      $3 = (int *) malloc($1*sizeof(int));
    +      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    +      for (i = 0; i < $1; i++) {
    +        key = rb_ary_entry(keys_arr, i);
    +        val = rb_hash_aref($input, key);
    +        Check_Type(key, T_STRING);
    +        Check_Type(val, T_FIXNUM);
    +      }
    +    }
    +}

    Finally, we can convert these Ruby objects into their C equivalents and store them in our local C arrays:

    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
    key = rb_ary_entry(keys_arr, i);
    val = rb_hash_aref($input, key);
    Check_Type(key, T_STRING);
    Check_Type(val, T_FIXNUM);
    $2[i] = StringValuePtr(key);
    $3[i] = NUM2INT(val);

    }
    }
    }
    +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +  Check_Type($input, T_HASH);
    +  $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    +  $2 = NULL;
    +  $3 = NULL;
    +  if ($1 > 0) {
    +    $2 = (char **) malloc($1*sizeof(char *));
    +    $3 = (int *) malloc($1*sizeof(int));
    +    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    +    for (i = 0; i < $1; i++) {
    +      key = rb_ary_entry(keys_arr, i);
    +      val = rb_hash_aref($input, key);
    +      Check_Type(key, T_STRING);
    +      Check_Type(val, T_FIXNUM);
    +      $2[i] = StringValuePtr(key);
    +      $3[i] = NUM2INT(val);
    +    }
    +  }
    +}

    We're not done yet. Since we used malloc() @@ -3084,7 +3814,10 @@ corresponding "freearg" typemap to free that memory so that there is no memory leak. Fortunately, this typemap is a lot easier to write:

    -
    %typemap(freearg) (int nattributes, const char **names, const int *values) {
    free((void *) $2);
    free((void *) $3);
    }
    +
    %typemap(freearg) (int nattributes, const char **names, const int *values) {
    +  free((void *) $2);
    +  free((void *) $3);
    +}

    All of the code for this example, as well as a sample Ruby @@ -3133,7 +3866,11 @@ For a type of Foo *, the type descriptor structure is usually accessed as follows:

    -
    Foo *foo;
    SWIG_ConvertPtr($input, (void **) &foo, SWIGTYPE_p_Foo, 1);

    VALUE obj;
    obj = SWIG_NewPointerObj(f, SWIGTYPE_p_Foo, 0);
    +
    Foo *foo;
    +SWIG_ConvertPtr($input, (void **) &foo, SWIGTYPE_p_Foo, 1);
    +
    +VALUE obj;
    +obj = SWIG_NewPointerObj(f, SWIGTYPE_p_Foo, 0);

    In a typemap, the type descriptor should always be accessed @@ -3141,7 +3878,9 @@ using the special typemap variable $1_descriptor. For example:

    -
    %typemap(in) Foo * {
    SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
    }
    +
    %typemap(in) Foo * {
    +  SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
    +}

    36.7.12.1 Ruby Datatype Wrapping

    @@ -3183,7 +3922,22 @@ macro/typemap and should give insight into constructing similar typemaps for other STL structures:

    -
    %define PTR_VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
    %typemap(out) vectorclassname &, const vectorclassname & {
    VALUE arr = rb_ary_new2($1->size());
    vectorclassname::iterator i = $1->begin(), iend = $1->end();
    for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
    $result = arr;
    }
    %typemap(out) vectorclassname, const vectorclassname {
    VALUE arr = rb_ary_new2($1.size());
    vectorclassname::iterator i = $1.begin(), iend = $1.end();
    for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
    $result = arr;
    }
    %enddef
    +
    %define PTR_VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
    +%typemap(out) vectorclassname &, const vectorclassname & {
    +  VALUE arr = rb_ary_new2($1->size());
    +  vectorclassname::iterator i = $1->begin(), iend = $1->end();
    +  for ( ; i!=iend; i++ )
    +    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
    +  $result = arr;
    +}
    +%typemap(out) vectorclassname, const vectorclassname {
    +  VALUE arr = rb_ary_new2($1.size());
    +  vectorclassname::iterator i = $1.begin(), iend = $1.end();
    +  for ( ; i!=iend; i++ )
    +    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
    +  $result = arr;
    +}
    +%enddef

    Note, that the "c ## classname.klass" is @@ -3193,28 +3947,60 @@ class name.

    To use the macro with a class Foo, the following is used:

    -
    PTR_VECTOR_TO_RUBY_ARRAY(vector<foo *="">, Foo)
    +
    PTR_VECTOR_TO_RUBY_ARRAY(vector<foo *="">, Foo)

    It is also possible to create a STL vector of Ruby objects:

    -
    %define RUBY_ARRAY_TO_PTR_VECTOR(vectorclassname, classname)
    %typemap(in) vectorclassname &, const vectorclassname & {
    Check_Type($input, T_ARRAY);
    vectorclassname *vec = new vectorclassname;
    int len = RARRAY($input)->len;
    for (int i=0; i!=len; i++) {
    VALUE inst = rb_ary_entry($input, i);
    //The following _should_ work but doesn't on HPUX
    // Check_Type(inst, T_DATA);
    classname *element = NULL;
    Data_Get_Struct(inst, classname, element);
    vec->push_back(element);
    }
    $1 = vec;
    }

    %typemap(freearg) vectorclassname &, const vectorclassname & {
    delete $1;
    }
    %enddef
    +
    %define RUBY_ARRAY_TO_PTR_VECTOR(vectorclassname, classname)
    +%typemap(in) vectorclassname &, const vectorclassname & {
    +  Check_Type($input, T_ARRAY);
    +  vectorclassname *vec = new vectorclassname;
    +  int len = RARRAY($input)->len;
    +  for (int i=0; i!=len; i++) {
    +    VALUE inst = rb_ary_entry($input, i);
    +    //The following _should_ work but doesn't on HPUX
    +    // Check_Type(inst, T_DATA);
    +    classname *element = NULL;
    +    Data_Get_Struct(inst, classname, element);
    +    vec->push_back(element);
    +  }
    +  $1 = vec;
    +}
    +
    +%typemap(freearg) vectorclassname &, const vectorclassname & {
    +  delete $1;
    +}
    +%enddef

    It is also possible to create a Ruby array from a vector of static data types:

    -
    %define VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
    %typemap(out) vectorclassname &, const vectorclassname & {
    VALUE arr = rb_ary_new2($1->size());
    vectorclassname::iterator i = $1->begin(), iend = $1->end();
    for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
    $result = arr;
    }
    %typemap(out) vectorclassname, const vectorclassname {
    VALUE arr = rb_ary_new2($1.size());
    vectorclassname::iterator i = $1.begin(), iend = $1.end();
    for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
    $result = arr;
    }
    %enddef
    +
    %define VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
    +%typemap(out) vectorclassname &, const vectorclassname & {
    +  VALUE arr = rb_ary_new2($1->size()); 
    +  vectorclassname::iterator i = $1->begin(), iend = $1->end();
    +  for ( ; i!=iend; i++ )
    +    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
    +  $result = arr;
    +}
    +%typemap(out) vectorclassname, const vectorclassname {
    +  VALUE arr = rb_ary_new2($1.size()); 
    +  vectorclassname::iterator i = $1.begin(), iend = $1.end();
    +  for ( ; i!=iend; i++ )
    +    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
    +  $result = arr;
    +}
    +%enddef
    -
    - Note that this is mostly an example of typemaps. If you want to use the STL with ruby, you are advised to use the standard swig STL library, which does much more than this.  Refer to the section called -the C++ Standard Template Library.
    +the C++ Standard Template Library.

    36.8 Docstring Features

    @@ -3262,7 +4048,7 @@ example:

    -
    %module(docstring="This is the example module's docstring") example
    +
    %module(docstring="This is the example module's docstring") example

    @@ -3272,7 +4058,12 @@ macro. For example:

    -
    %define DOCSTRING
    "The `XmlResource` class allows program resources defining menus,
    layout of controls on a panel, etc. to be loaded from an XML file."
    %enddef

    %module(docstring=DOCSTRING) xrc
    +
    %define DOCSTRING
    +"The `XmlResource` class allows program resources defining menus, 
    +layout of controls on a panel, etc. to be loaded from an XML file."
    +%enddef
    +
    +%module(docstring=DOCSTRING) xrc

    36.8.2 %feature("autodoc")

    @@ -3307,7 +4098,8 @@ this function prototype:

    -
    %feature("autodoc", "0");
    bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);
    +
    %feature("autodoc", "0");
    +bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);

    @@ -3315,7 +4107,8 @@ Then Ruby code like this will be generated:

    -
    function_name(x, y, foo=nil, bar=nil) -> bool
    ...
    +
    function_name(x, y, foo=nil, bar=nil) -> bool
    +  ...

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

    @@ -3334,7 +4127,8 @@ this:

    -
    function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool
    ...
    +
    function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool
    +  ...

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

    @@ -3361,7 +4155,13 @@ this:

    -
    function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool

    Parameters:
    x - int
    y - int
    foo - Foo
    bar - Bar
    +
    function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool
    +
    +Parameters:
    +	x - int
    +	y - int
    +	foo - Foo
    +	bar - Bar

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

    @@ -3376,7 +4176,8 @@ generated string. For example:

    -
    %feature("autodoc", "GetPosition() -> (x, y)") GetPosition;
    void GetPosition(int* OUTPUT, int* OUTPUT);
    +
    %feature("autodoc", "GetPosition() -> (x, y)") GetPosition;
    +void GetPosition(int* OUTPUT, int* OUTPUT);

    36.8.3 %feature("docstring")

    @@ -3586,14 +4387,45 @@ runtime type information among the different modules.

    that defines our base class:

    -
    %module shape

    %{
    #include "Shape.h"
    %}

    class Shape {
    protected:
    double xpos;
    double ypos;
    protected:
    Shape(double x, double y);
    public:
    double getX() const;
    double getY() const;
    };
    +
    %module shape
    +
    +%{
    +#include "Shape.h"
    +%}
    +
    +class Shape {
    +protected:
    +  double xpos;
    +  double ypos;
    +protected:
    +  Shape(double x, double y);
    +public:
    +  double getX() const;
    +  double getY() const;
    +};

    We also have a separate interface file (circle.i) that defines a derived class:

    -
    %module circle

    %{
    #include "Shape.h"
    #include "Circle.h"
    %}

    // Import the base class definition from Shape module
    %import shape.i

    class Circle : public Shape {
    protected:
    double radius;
    public:
    Circle(double x, double y, double r);
    double getRadius() const;
    };
    +
    %module circle
    +
    +%{
    +#include "Shape.h"
    +#include "Circle.h"
    +%}
    +
    +// Import the base class definition from Shape module
    +%import shape.i
    +
    +class Circle : public Shape {
    +protected:
    +  double radius;
    +public:
    +  Circle(double x, double y, double r);
    +  double getRadius() const;
    +};

    We'll start by building the Shape @@ -3609,14 +4441,28 @@ To compile this into a dynamically loadable extension for Ruby, prepare an extconf.rb script using this template:

    -
    require 'mkmf'

    # Since the SWIG runtime support library for Ruby
    # depends on the Ruby library, make sure it's in the list
    # of libraries.
    $libs = append_library($libs, Config::CONFIG['RUBY_INSTALL_NAME'])

    # Create the makefile
    create_makefile('shape')
    +
    require 'mkmf'
    +
    +# Since the SWIG runtime support library for Ruby
    +# depends on the Ruby library, make sure it's in the list
    +# of libraries.
    +$libs = append_library($libs, Config::CONFIG['RUBY_INSTALL_NAME'])
    +
    +# Create the makefile
    +create_makefile('shape')

    Run this script to create a Makefile and then type make to build the shared library:

    -
    $ ruby extconf.rb
    creating Makefile
    $ make
    g++ -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.7/i686-linux \
    -I. -c shape_wrap.cxx
    gcc -shared -L/usr/local/lib -o shape.so shape_wrap.o -L. \
    -lruby -lruby -lc
    +
    $ ruby extconf.rb
    +creating Makefile
    +$ make
    +g++ -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.7/i686-linux \
    +-I. -c shape_wrap.cxx
    +gcc -shared -L/usr/local/lib -o shape.so shape_wrap.o -L. \
    +-lruby -lruby -lc

    Note that depending on your installation, the outputs may be @@ -3642,7 +4488,17 @@ and Circle modules are properly loaded and initialized:

    -
    $ irb
    irb(main):001:0> require 'shape'
    true
    irb(main):002:0> require 'circle'
    true
    irb(main):003:0> c = Circle::Circle.new(5, 5, 20)
    #<Circle::Circle:0xa097208>
    irb(main):004:0> c.kind_of? Shape::Shape
    true
    irb(main):005:0> c.getX()
    5.0
    +
    $ irb
    +irb(main):001:0> require 'shape'
    +true
    +irb(main):002:0> require 'circle'
    +true
    +irb(main):003:0> c = Circle::Circle.new(5, 5, 20)
    +#<Circle::Circle:0xa097208>
    +irb(main):004:0> c.kind_of? Shape::Shape
    +true
    +irb(main):005:0> c.getX()
    +5.0

    36.9.3 Specifying Mixin Modules

    @@ -3654,14 +4510,30 @@ method. For example, if you have a Ruby class that defines an each instance method, e.g.

    -
    class Set
    def initialize
    @members = []
    end

    def each
    @members.each { |m| yield m }
    end
    end
    +
    class Set
    +  def initialize
    +  @members = []
    +  end
    + 
    +  def each
    +  @members.each { |m| yield m }
    +  end
    +end

    then you can mix-in Ruby's Enumerable module to easily add a lot of functionality to your class:

    -
    class Set
    include Enumerable
    def initialize
    @members = []
    end
    def each
    @members.each { |m| yield m }
    end
    end
    +
    class Set
    +  include Enumerable
    +  def initialize
    +    @members = []
    +  end
    +  def each
    +    @members.each { |m| yield m }
    +  end
    +end

    To get the same benefit for your SWIG-wrapped classes, you @@ -3670,7 +4542,16 @@ of one or more modules that should be mixed-in to a class. For the above example, the SWIG interface specification might look like this:

    -
    %mixin Set "Enumerable";

    class Set {
    public:
    // Constructor
    Set();

    // Iterates through set members
    void each();
    };
    +
    %mixin Set "Enumerable";
    +
    +class Set {
    +public:
    +  // Constructor
    +  Set();
    + 
    +  // Iterates through set members
    +  void each();
    +};

    Multiple modules can be mixed into a class by providing a @@ -3771,7 +4652,25 @@ library responsible for freeing the object. a Foo and a Bar class.

    -
    /* File "RubyOwernshipExample.h" */

    class Foo
    {
    public:
    Foo() {}
    ~Foo() {}
    };

    class Bar
    {
    Foo *foo_;
    public:
    Bar(): foo_(new Foo) {}
    ~Bar() { delete foo_; }
    Foo* get_foo() { return foo_; }
    Foo* get_new_foo() { return new Foo; }
    void set_foo(Foo *foo) { delete foo_; foo_ = foo; }
    };

    +
    /* File "RubyOwernshipExample.h" */
    +
    +class Foo
    +{
    +public:
    +  Foo() {}
    +  ~Foo() {}
    +};
    +
    +class Bar
    +{
    +  Foo *foo_;
    +public:
    +  Bar(): foo_(new Foo) {}
    +  ~Bar() { delete foo_; }
    +  Foo* get_foo() { return foo_; }
    +  Foo* get_new_foo() { return new Foo; }
    +  void set_foo(Foo *foo) { delete foo_; foo_ = foo; }
    +};

    First, consider this Ruby code:

    @@ -3789,7 +4688,8 @@ called. It in turn will call Foo's destructor.

    Next, consider this code:

    -
    bar = Bar.new
    foo = bar.get_foo()
    +
    bar = Bar.new
    +foo = bar.get_foo()

    In this case, the Ruby code calls a C++ member function, get_foo. @@ -3801,7 +4701,8 @@ object is not affected.

    above. For example:

    -
    bar = Bar.new
    foo = bar.get_new_foo()
    +
    bar = Bar.new
    +foo = bar.get_new_foo()

    In this case, the default SWIG behavior for calling member @@ -3813,7 +4714,9 @@ Object ownership and %newobject for more information.

    The SWIG default mappings are also incorrect in this case:

    -
    foo = Foo.new
    bar = Bar.new
    bar.set_foo(foo)
    +
    foo = Foo.new
    +bar = Bar.new
    +bar.set_foo(foo)

    Without modification, this code will cause a segmentation @@ -3873,7 +4776,70 @@ shown below to illustrate different memory management techniques. The class library models a zoo and the animals it contains.

    -
    %module zoo

    %{
    #include <string>
    #include <vector>

    #include "zoo.h"
    %}

    class Animal
    {
    private:
    typedef std::vector<Animal*> AnimalsType;
    typedef AnimalsType::iterator IterType;
    protected:
    AnimalsType animals;
    protected:
    std::string name_;
    public:
    // Construct an animal with this name
    Animal(const char* name) : name_(name) {}

    // Return the animal's name
    const char* get_name() const { return name.c_str(); }
    };

    class Zoo
    {
    protected:
    std::vector<animal *=""> animals;

    public:
    // Construct an empty zoo
    Zoo() {}

    /* Create a new animal. */
    static Animal* Zoo::create_animal(const char* name)
    {
    return new Animal(name);
    }

    // Add a new animal to the zoo
    void add_animal(Animal* animal) {
    animals.push_back(animal);
    }

    Animal* remove_animal(size_t i) {
    Animal* result = this->animals[i];
    IterType iter = this->animals.begin();
    std::advance(iter, i);
    this->animals.erase(iter);

    return result;
    }

    // Return the number of animals in the zoo
    size_t get_num_animals() const {
    return animals.size();
    }

    // Return a pointer to the ith animal
    Animal* get_animal(size_t i) const {
    return animals[i];
    }
    };

    +
    %module zoo
    +
    +%{
    +#include <string>
    +#include <vector>
    +
    +#include "zoo.h"
    +%}
    +
    +class Animal
    +{
    +private:
    +  typedef std::vector<Animal*> AnimalsType;
    +  typedef AnimalsType::iterator IterType;
    +protected:
    +  AnimalsType animals;
    +protected:
    +  std::string name_;
    +public:
    +  // Construct an animal with this name
    +  Animal(const char* name) : name_(name) {}
    + 
    +  // Return the animal's name
    +  const char* get_name() const { return name.c_str(); }
    +};
    +
    +class Zoo
    +{
    +protected:
    + std::vector<animal *=""> animals;
    + 
    +public:
    +  // Construct an empty zoo
    +  Zoo() {}
    +  
    +  /* Create a new animal. */
    +  static Animal* Zoo::create_animal(const char* name) {
    +    return new Animal(name);
    +  }
    + 
    +  // Add a new animal to the zoo
    +  void add_animal(Animal* animal) {
    +    animals.push_back(animal); 
    +  }
    + 
    +  Animal* remove_animal(size_t i) {
    +    Animal* result = this->animals[i];
    +    IterType iter = this->animals.begin();
    +    std::advance(iter, i);
    +    this->animals.erase(iter);
    +   
    +    return result;
    +  }
    +  
    +  // Return the number of animals in the zoo
    +  size_t get_num_animals() const {
    +    return animals.size(); 
    +  }
    +  
    +  // Return a pointer to the ith animal
    +  Animal* get_animal(size_t i) const {
    +    return animals[i]; 
    +  }
    +};

    Let's say you SWIG this code and then run IRB: @@ -3913,8 +4879,7 @@ irb(main):009:0> tiger1.equal?(tiger2)

    Pay particular attention to the code tiger1.equal?(tiger2). Note that the two Ruby objects are not the same - but they reference -the same underlying C++ object. This can cause problems. For example:
    - +the same underlying C++ object. This can cause problems. For example:

    @@ -3954,24 +4919,65 @@ the chapter on class-by-class basis if needed. To fix the example above:

    -
    %module example

    %{
    #include "example.h"
    %}

    /* Tell SWIG that create_animal creates a new object */
    %newobject Zoo::create_animal;

    /* Tell SWIG to keep track of mappings between C/C++ structs/classes. */
    %trackobjects;

    %include "example.h"
    +
    %module example
    +
    +%{
    +#include "example.h"
    +%}
    +
    +/* Tell SWIG that create_animal creates a new object */
    +%newobject Zoo::create_animal;
    +
    +/* Tell SWIG to keep track of mappings between C/C++ structs/classes. */%trackobjects;
    +
    +%include "example.h"

    When this code runs we see:

    -
    $ irb
    irb(main):001:0> require 'example'
    => true

    irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
    => #<Example::Animal:0x2be37d8>

    irb(main):003:0> zoo = Example::Zoo.new()
    => #<Example::Zoo:0x2be0a18>

    irb(main):004:0> zoo.add_animal(tiger1)
    => nil

    irb(main):006:0> tiger2 = zoo.remove_animal(0)
    => #<Example::Animal:0x2be37d8>

    irb(main):007:0> tiger1.equal?(tiger2)
    => true

    irb(main):008:0> tiger1 = nil
    => nil

    irb(main):009:0> GC.start
    => nil

    irb(main):010:0> tiger.get_name()
    => "tiger1"
    irb(main):011:0>

    +
    $ irb
    +irb(main):001:0> require 'example'
    +=> true
    +
    +irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
    +=> #<Example::Animal:0x2be37d8>
    +
    +irb(main):003:0> zoo = Example::Zoo.new()
    +=> #<Example::Zoo:0x2be0a18>
    +
    +irb(main):004:0> zoo.add_animal(tiger1)
    +=> nil
    +
    +irb(main):006:0> tiger2 = zoo.remove_animal(0)
    +=> #<Example::Animal:0x2be37d8>
    +
    +irb(main):007:0> tiger1.equal?(tiger2)
    +=> true
    +
    +irb(main):008:0> tiger1 = nil
    +=> nil
    +
    +irb(main):009:0> GC.start
    +=> nil
    +
    +irb(main):010:0> tiger.get_name()
    +=> "tiger1"
    +irb(main):011:0>

    For those who are interested, object tracking is implemented by storing Ruby objects in a hash table and keying them on C++ -pointers. The underlying API is:
    +pointers. The underlying API is:

    -
    static void SWIG_RubyAddTracking(void* ptr, VALUE object);
    static VALUE SWIG_RubyInstanceFor(void* ptr) ;
    static void SWIG_RubyRemoveTracking(void* ptr);
    static void SWIG_RubyUnlinkObjects(void* ptr);
    +
    static void SWIG_RubyAddTracking(void* ptr, VALUE object);
    +static VALUE SWIG_RubyInstanceFor(void* ptr) ;
    +static void SWIG_RubyRemoveTracking(void* ptr);
    +static void SWIG_RubyUnlinkObjects(void* ptr);

    When an object is created, SWIG will automatically call the SWIG_RubyAddTracking @@ -3991,12 +4997,32 @@ methods.

    With a bit more testing, we see that our class library still -has problems. For example:
    +has problems. For example:

    -
    $ irb
    irb(main):001:0> require 'example'
    => true

    irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
    => #<Example::Animal:0x2bea6a8>

    irb(main):003:0> zoo = Example::Zoo.new()
    => #<Example::Zoo:0x2be7960>

    irb(main):004:0> zoo.add_animal(tiger1)
    => nil

    irb(main):007:0> tiger1 = nil
    => nil

    irb(main):007:0> GC.start
    => nil

    irb(main):005:0> tiger2 = zoo.get_animal(0)
    (irb):12: [BUG] Segmentation fault
    +
    $ irb
    +irb(main):001:0> require 'example'
    +=> true
    +
    +irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
    +=> #<Example::Animal:0x2bea6a8>
    +
    +irb(main):003:0> zoo = Example::Zoo.new()
    +=> #<Example::Zoo:0x2be7960>
    +
    +irb(main):004:0> zoo.add_animal(tiger1)
    +=> nil
    +
    +irb(main):007:0> tiger1 = nil
    +=> nil
    +
    +irb(main):007:0> GC.start
    +=> nil
    +
    +irb(main):005:0> tiger2 = zoo.get_animal(0)
    +(irb):12: [BUG] Segmentation fault

    The problem is that Ruby does not know that the zoo @@ -4023,7 +5049,40 @@ then call rb_gc_mark(). One possible implementation is:

    -
    %module example

    %{
    #include "example.h"
    %}

    /* Keep track of mappings between C/C++ structs/classes
    and Ruby objects so we can implement a mark function. */
    %trackobjects;

    /* Specify the mark function */
    %markfunc Zoo "mark_Zoo";

    %include "example.h"

    %header %{

    static void mark_Zoo(void* ptr) {
    Zoo* zoo = (Zoo*) ptr;

    /* Loop over each object and tell the garbage collector
    that we are holding a reference to them. */
    int count = zoo->get_num_animals();

    for(int i = 0; i < count; ++i) {
    Animal* animal = zoo->get_animal(i);
    VALUE object = SWIG_RubyInstanceFor(animal);

    if (object != Qnil) {
    rb_gc_mark(object);
    }
    }
    }
    %}

    +
    %module example
    +
    +%{
    +#include "example.h"
    +%}
    +
    +/* Keep track of mappings between C/C++ structs/classes
    + and Ruby objects so we can implement a mark function. */
    +%trackobjects;
    +
    +/* Specify the mark function */
    +%markfunc Zoo "mark_Zoo";
    +
    +%include "example.h"
    +
    +%header %{
    +
    +static void mark_Zoo(void* ptr) {
    +  Zoo* zoo = (Zoo*) ptr;
    + 
    +  /* Loop over each object and tell the garbage collector
    +  that we are holding a reference to them. */
    +  int count = zoo->get_num_animals();
    + 
    +  for(int i = 0; i < count; ++i) {
    +    Animal* animal = zoo->get_animal(i);
    +    VALUE object = SWIG_RubyInstanceFor(animal);
    + 
    +    if (object != Qnil) {
    +      rb_gc_mark(object);
    +    }
    +  }
    +}
    +%}

    Note the mark function is dependent on @@ -4035,7 +5094,30 @@ test suite.

    When this code is compiled we now see:

    -
    $ irb
    irb(main):002:0> tiger1=Example::Animal.new("tiger1")
    => #<Example::Animal:0x2be3bf8>

    irb(main):003:0> Example::Zoo.new()
    => #<Example::Zoo:0x2be1780>

    irb(main):004:0> zoo = Example::Zoo.new()
    => #<Example::Zoo:0x2bde9c0>

    irb(main):005:0> zoo.add_animal(tiger1)
    => nil

    irb(main):009:0> tiger1 = nil
    => nil

    irb(main):010:0> GC.start
    => nil
    irb(main):014:0> tiger2 = zoo.get_animal(0)
    => #<Example::Animal:0x2be3bf8>

    irb(main):015:0> tiger2.get_name()
    => "tiger1"
    irb(main):016:0>

    +
    $ irb
    +irb(main):002:0> tiger1=Example::Animal.new("tiger1")
    +=> #<Example::Animal:0x2be3bf8>
    +
    +irb(main):003:0> Example::Zoo.new()
    +=> #<Example::Zoo:0x2be1780>
    +
    +irb(main):004:0> zoo = Example::Zoo.new()
    +=> #<Example::Zoo:0x2bde9c0>
    +
    +irb(main):005:0> zoo.add_animal(tiger1)
    +=> nil
    +
    +irb(main):009:0> tiger1 = nil
    +=> nil
    +
    +irb(main):010:0> GC.start
    +=> nil
    +irb(main):014:0> tiger2 = zoo.get_animal(0)
    +=> #<Example::Animal:0x2be3bf8>
    +
    +irb(main):015:0> tiger2.get_name()
    +=> "tiger1"
    +irb(main):016:0>

    This code can be seen in swig/examples/ruby/mark_function.

    @@ -4125,8 +5207,7 @@ implementing a custom free function that calls the SWIG_RubyUnlinkObjectsSWIG_RubyUnlinkObjects function notifies SWIG that a Ruby object's underlying C++ object is no longer valid. Once notified, SWIG will intercept any calls from the -existing Ruby object to the destroyed C++ object and raise an exception.
    - +existing Ruby object to the destroyed C++ object and raise an exception.

    From abc27fd1572a32977dfc54d902a0cea6cdaeb3bd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 8 Jun 2013 01:58:43 +0100 Subject: [PATCH 218/273] Further Ruby html doc formatting changes --- Doc/Manual/Contents.html | 4 +- Doc/Manual/Ruby.html | 211 +++++++++++++++++++-------------------- 2 files changed, 107 insertions(+), 108 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 32fa32e96..77280c8bc 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1528,9 +1528,9 @@
  • Placement of typemaps
  • Ruby typemaps
  • @@ -1305,15 +1305,15 @@ chapter.

    Some containers in the STL allow you to modify their default behavior by using so called functors or function objects. - Functors are often just a very simple struct with operator() -redefined or an actual C/C++ function.  This allows you, for +Functors are often just a very simple struct with operator() +redefined or an actual C/C++ function. This allows you, for example, to always keep the sort order of a STL container to your liking.

    The Ruby STL mappings allows you to modify those containers that support functors using Ruby procs or methods, instead. - Currently, +Currently, this includes std::set, set::map, std::multiset @@ -1333,7 +1333,7 @@ are provided.

    %include <std_set.i> -%typemap(IntSet)  std::set< int, swig::BinaryPredicate >; +%typemap(IntSet) std::set< int, swig::BinaryPredicate >;

    You can then use the set from Ruby with or without a proc @@ -1349,39 +1349,39 @@ a << 1 a << 2 a << 3 a -=> [1,2,3] +=> [1,2,3] # Custom sorting behavior defined by a Ruby proc b = IntSet.new( proc { |a,b| a > b } ) -b << 1 -b << 2 -b << 3 +b << 1 +b << 2 +b << 3 b -=>  [3,2,1] +=> [3,2,1]

    36.3.15 C++ STL Iterators

    -

    The STL is well known for the use of iterators.  There +

    The STL is well known for the use of iterators. There are a number of iterators possible with different properties, but in general there are two main categories: const iterators and non-const -iterators.  The const iterators can access and not modify the +iterators. The const iterators can access and not modify the values they point at, while the non-const iterators can both read and modify the values.

    The Ruby STL wrappings support both type of iterators by using -a proxy class in-between.  This proxy class is swig::Iterator or -swig::ConstIterator.  Derived from them are template +a proxy class in-between. This proxy class is swig::Iterator or +swig::ConstIterator. Derived from them are template classes that need to be initialized with the actual iterator for the container you are wrapping and often times with the beginning and -ending points of the iteration range. 

    +ending points of the iteration range.

    The SWIG STL library already provides typemaps to all the standard containers to do this wrapping automatically for you, but if you have your own STL-like iterator, you will need to write your own -typemap for them.  For out typemaps, the special functions make_const_iterator and make_nonconst_iterator are provided.

    +typemap for them. For out typemaps, the special functions make_const_iterator and make_nonconst_iterator are provided.

    These can be used either like:

    @@ -1390,17 +1390,17 @@ make_const_iterator( iterator, rubyclass ); make_const_iterator( iterator, iterator_begin, iterator_end, rubyclass ); -

    The iterators support a next() and previous() member function to -just change the iterator without returning anything.  previous() -should obviously only be used for bidirectional iterators.  You +

    The iterators support a next() and previous() member function to +just change the iterator without returning anything. previous() +should obviously only be used for bidirectional iterators. You can also advance the iterator multiple steps by using standard math operations like +=.

    The -value the iterator points at can be accessed with value() -- this is equivalent to dereferencing it with *i. -  For non-const iterators, a value=() function +value the iterator points at can be accessed with value() -- this is equivalent to dereferencing it with *i. + For non-const iterators, a value=() function is also provided which allows you to change the value pointed by the -iterator.  This is equivalent to the C++ construct of dereferencing and assignment, like *i = something

    +iterator. This is equivalent to the C++ construct of dereferencing and assignment, like *i = something.

    Thus, given say a vector class of doubles defined as:

    @@ -1432,10 +1432,10 @@ v << 3 i = v.begin e = v.end while i != e -  val = i.value -  val += 2 -  i.value = val -  i.next + val = i.value + val += 2 + i.value = val + i.next end i >> [3, 4, 5 ] @@ -2022,12 +2022,12 @@ Features for more examples.

    One of the highlights of Ruby and most of its standard library is the use of blocks, which allow the easy creation of continuations and -other niceties.  Blocks in ruby are also often used to +other niceties. Blocks in ruby are also often used to simplify the passing of many arguments to a class.

    In order to make your class constructor support blocks, you can take advantage of the %exception directive, which will get run -after the C++ class' constructor was called. 

    +after the C++ class' constructor was called.

    For example, this yields the class over after its construction: @@ -2037,8 +2037,8 @@ construction:

    class Window
     {
     public:
    - Window(int x, int y, int w, int h);
    -// .... other methods here ....
    +  Window(int x, int y, int w, int h);
    +  // .... other methods here ....
     };
     
     // Add support for yielding self in the Class' constructor.
    @@ -2054,8 +2054,8 @@ public:
     
     
     Window.new(0,0,360,480) { |w|
    -    w.color = Fltk::RED
    -    w.border = false
    +  w.color = Fltk::RED
    +  w.border = false
     }
     
    @@ -2070,15 +2070,13 @@ a special in typemap, like:

    // void func(int x); %typemap(in,numinputs=0) int RUBY_YIELD_SELF { -     if ( !rb_block_given_p() ) -            -rb_raise("No block given"); -     return rb_yield(self); + if ( !rb_block_given_p() ) + rb_raise("No block given"); + return rb_yield(self); } %extend { -        void func(int x, int -RUBY_YIELD_SELF ); + void func(int x, int RUBY_YIELD_SELF ); }
    @@ -2286,7 +2284,7 @@ end wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Ruby C API as well as the material in the "Typemaps" -chapter.  +chapter.

    Before proceeding, it should be stressed that typemaps are not @@ -2300,7 +2298,7 @@ of the primitive C-Ruby interface.

    A typemap is nothing more than a code generation rule that is attached to a specific C datatype. The general form of this declaration is as follows ( parts enclosed in [...] are optional -):    

    +):

    @@ -2641,7 +2639,7 @@ string
     

    The following list details all of the typemap methods that can be used by the Ruby module:

    -

    36.7.6.1  "in" typemap

    +

    36.7.6.1 "in" typemap

    Converts Ruby objects to input @@ -2730,7 +2728,7 @@ program uses overloaded methods, you should also define a collection of "typecheck" typemaps. More details about this follow in a later section on "Typemaps and Overloading."

    -

    36.7.6.3  "out" typemap

    +

    36.7.6.3 "out" typemap

    Converts return value of a C function @@ -2848,7 +2846,7 @@ example:

    /* Set the input argument to point to a temporary variable */
     %typemap(in, numinputs=0) int *out (int temp) {
    - $1 = &temp;
    +  $1 = &temp;
     }
     
     %typemap(argout, fragment="output_helper") int *out {
    @@ -3018,7 +3016,7 @@ handling with %exception section.

    Converts C++ objects in director -member functions to ruby objects. It is roughly the opposite +member functions to ruby objects. It is roughly the opposite of the "in" typemap, making its typemap rule often similar to the "out" typemap.

    @@ -3077,14 +3075,15 @@ referring to the class itself.

    Converts Ruby objects in director -member functions to C++ objects.  It is roughly the opposite +member functions to C++ objects. It is roughly the opposite of the "out" typemap, making its rule often similar to the "in" typemap.

     %typemap(directorout) int {
    -   $result = NUM2INT($1);
    +  $result = NUM2INT($1);
    +}
     
    @@ -3130,9 +3129,9 @@ referring to the class itself.

    Currently, the directorout nor the out typemap support the -option numoutputs, +option numoutputs, but the Ruby module provides that functionality through a %feature -directive.  Thus, a function can be made to return "nothing" +directive. Thus, a function can be made to return "nothing" if you do:

    @@ -3271,13 +3270,13 @@ being created. 

    When you write a typemap, you usually have to work directly with Ruby objects. The following functions may prove to be useful. (These functions plus many more can be found in Programming -Ruby book, by David Thomas and Andrew Hunt.) 

    +Ruby book, by David Thomas and Andrew Hunt.)

    In addition, we list equivalent functions that SWIG defines, which provide a language neutral conversion (these functions are defined for -each swig language supported).  If you are trying to create a swig +each swig language supported). If you are trying to create a swig file that will work under multiple languages, it is recommended you stick to the swig functions instead of the native Ruby functions. - That should help you avoid having to rewrite a lot of typemaps +That should help you avoid having to rewrite a lot of typemaps across multiple languages.

    36.7.8.1 C Datatypes to Ruby Objects

    @@ -3999,7 +3998,7 @@ static data types:

    Note that this is mostly an example of typemaps. If you want to use the STL with ruby, you are advised to use the standard swig STL library, -which does much more than this.  Refer to the section called +which does much more than this. Refer to the section called the C++ Standard Template Library.

    36.8 Docstring Features

    @@ -4019,28 +4018,28 @@ read by Ruby's rdoc tool to generate html web pages, ri documentation, Windows chm file and an .xml description.

    rdoc can then be run from a console or shell window on a swig -generated file. 

    +generated file.

    For example, to generate html web pages from a C++ file, you'd -do: 

    +do:

    -$ rdoc -E cxx=c -f html file_wrap.cxx
    +$ rdoc -E cxx=c -f html file_wrap.cxx
     

    To generate ri documentation from a c wrap file, you could do:

    -$ rdoc -r file_wrap.c
    +$ rdoc -r file_wrap.c
     

    36.8.1 Module docstring

    -Ruby allows a docstring at the beginning of the file +Ruby allows a docstring at the beginning of the file before any other statements, and it is typically used to give a general description of the entire module. SWIG supports this by setting an option of the %module directive. For @@ -4138,7 +4137,7 @@ this: When the "2" option is used then the parameter types will not be used in the rdoc string. However, they will be listed in full after the -function.  Given the example above, then turning on the +function. Given the example above, then turning on the parameter types with the "2" option will result in Ruby code like this:

    @@ -4148,7 +4147,7 @@ this:

    When the "3" option is used then the function will be documented using -a combination of "1" and "2" above.  Given the example above, +a combination of "1" and "2" above. Given the example above, then turning on the parameter types with the "2" option will result in Ruby code like this: @@ -4744,24 +4743,24 @@ classes is:

    class Foo { public: - Foo(); - ~Foo(); + Foo(); + ~Foo(); }; class Bar { - Foo *foo_; + Foo *foo_; public: - Bar(); - ~Bar(); - Foo* get_foo(); + Bar(); + ~Bar(); + Foo* get_foo(); - %newobject get_new_foo; - Foo* get_new_foo(); + %newobject get_new_foo; + Foo* get_new_foo(); - %apply SWIGTYPE *DISOWN {Foo *foo}; - void set_foo(Foo *foo); - %clear Foo *foo; + %apply SWIGTYPE *DISOWN {Foo *foo}; + void set_foo(Foo *foo); + %clear Foo *foo; };
    @@ -5230,28 +5229,28 @@ existing Ruby object to the destroyed C++ object and raise an exception. %include "example.h" %header %{ - static void free_Zoo(void* ptr) { - Zoo* zoo = (Zoo*) ptr; + static void free_Zoo(void* ptr) { + Zoo* zoo = (Zoo*) ptr; - /* Loop over each animal */ - int count = zoo->get_num_animals(); + /* Loop over each animal */ + int count = zoo->get_num_animals(); - for(int i = 0; i < count; ++i) { - /* Get an animal */ - Animal* animal = zoo->get_animal(i); + for(int i = 0; i < count; ++i) { + /* Get an animal */ + Animal* animal = zoo->get_animal(i); - /* Unlink the Ruby object from the C++ object */ - SWIG_RubyUnlinkObjects(animal); + /* Unlink the Ruby object from the C++ object */ + SWIG_RubyUnlinkObjects(animal); - /* Now remove the tracking for this animal */ - SWIG_RubyRemoveTracking(animal); - } + /* Now remove the tracking for this animal */ + SWIG_RubyRemoveTracking(animal); + } - /* Now call SWIG_RubyRemoveTracking for the zoo */ - SWIG_RubyRemoveTracking(ptr); - /* Now free the zoo which will free the animals it contains */ - delete zoo; - } + /* Now call SWIG_RubyRemoveTracking for the zoo */ + SWIG_RubyRemoveTracking(ptr); + /* Now free the zoo which will free the animals it contains */ + delete zoo; + } %} @@ -5294,7 +5293,7 @@ been freed, and thus raises a runtime exception.

    As has been said, the Ruby GC runs and marks objects before its -sweep phase.  When the garbage collector is called, it will +sweep phase. When the garbage collector is called, it will also try to mark any Ruby objects (VALUE) it finds in the machine registers and in the C++ stack.

    @@ -5309,7 +5308,7 @@ whenever you do inside a function:

    For ruby to determine where its stack space begins, during initialization a normal Ruby interpreter will call the ruby_init() function which in turn will call a function called Init_stack or -similar.  This function will store a pointer to the location +similar. This function will store a pointer to the location where the stack points at that point in time.

    @@ -5317,37 +5316,37 @@ the stack points at that point in time.

    function of your program and whenever the GC is called, ruby will assume that the memory between the current location in memory and the pointer that was stored previously represents the stack, which may -contain local (and temporary) VALUE ruby objects.   Ruby will +contain local (and temporary) VALUE ruby objects. Ruby will then be careful not to remove any of those objects in that location.

    -

    So far so good.  For a normal Ruby session, all the +

    So far so good. For a normal Ruby session, all the above is completely transparent and magic to the extensions developer. -  

    +

    However, with an embedded Ruby, it may not always be possible to -modify main() to make sure ruby_init() is called there.   As +modify main() to make sure ruby_init() is called there. As such, ruby_init() will likely end up being called from within some other -function.  This can lead Ruby to measure incorrectly where the -stack begins and can result in Ruby incorrectly collecting +function. This can lead Ruby to measure incorrectly where the +stack begins and can result in Ruby incorrectly collecting those -temporary VALUE objects that are created once another function +temporary VALUE objects that are created once another function is -called.  The end result: random crashes and segmentation +called. The end result: random crashes and segmentation faults.

    This problem will often be seen in director functions that are -used for callbacks, for example.  

    +used for callbacks, for example.

    To solve the problem, SWIG can now generate code with director -functions containing the optional macros SWIG_INIT_STACK and -SWIG_RELEASE_STACK.   These macros will try to force Ruby to -reinitiliaze the beginning of the stack the first time a +functions containing the optional macros SWIG_INIT_STACK and +SWIG_RELEASE_STACK. These macros will try to force Ruby to +reinitiliaze the beginning of the stack the first time a director -function is called.  This will lead Ruby to measure and not -collect any VALUE objects defined from that point on.  

    +function is called. This will lead Ruby to measure and not +collect any VALUE objects defined from that point on.

    To mark functions to either reset the ruby stack or not, you can use:

    From 5cdfc503e18e1f5b8895516c591332fda371d879 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 11 Jun 2013 00:22:21 -0700 Subject: [PATCH 219/273] Add SWIG_PYTHON_NO_DEBUG macro for building Debug wrappers against the Python Debug dll --- CHANGES.current | 6 ++++++ Doc/Manual/Python.html | 22 +++++++++++++++++++++- Doc/Manual/Windows.html | 2 +- Examples/python/class/example.dsp | 2 +- Examples/python/contract/example.dsp | 2 +- Examples/python/import/bar.dsp | 2 +- Examples/python/import/base.dsp | 2 +- Examples/python/import/foo.dsp | 2 +- Examples/python/import/spam.dsp | 2 +- Examples/python/multimap/example.dsp | 2 +- Examples/python/simple/example.dsp | 2 +- Lib/python/pyruntime.swg | 12 +++++++++--- 12 files changed, 45 insertions(+), 13 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 4b0633c22..4fbd0d6e1 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.11 (in progress) ============================ +2013-07-11: wsfulton + [Python] Add SWIG_PYTHON_NO_DEBUG macro which can be defined to use the Release version + of the Python interpreter in Debug builds of the wrappers. The Visual Studio .dsp example + files have been modified to use this so that Debug builds will now work without having + to install or build a Debug build of the interpreter. + 2013-07-07: wsfulton [Ruby] Git issue #52. Fix regression with missing rb_complex_new function for Ruby versions prior to 1.9 using std::complex wrappers if just using std::complex as an output type. diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 762abebba..fd7bfca4e 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -795,7 +795,9 @@ If you need to build it on your own, the following notes are provided: You will need to create a DLL that can be loaded into the interpreter. This section briefly describes the use of SWIG with Microsoft Visual C++. As a starting point, many of SWIG's examples include project -files. You might want to take a quick look at these in addition to +files (.dsp files) for Visual C++ 6. These can be opened by more +recent versions of Visual Studio. +You might want to take a quick look at these examples in addition to reading this section.

    @@ -868,6 +870,24 @@ set of Win32 debug or thread libraries. You will have to fiddle around with the build options of project to try and track this down.

    +

    +A 'Debug' build of the wrappers requires a debug build of the Python interpreter. +This normally requires building the Python interpreter from source, which is not a +job for the feint-hearted. Alternatively you can use the 'Release' build of the +Python interpreter with a 'Debug' build of your wrappers by defining the SWIG_PYTHON_NO_DEBUG +symbol under the preprocessor options. Or you can ensure this macro is defined at the beginning +of the wrapper code using the following in your interface file, where _MSC_VER ensures it is +only used by the Visual Studio compiler: +

    + +
    +%begin %{
    +#ifdef _MSC_VER
    +#define SWIG_PYTHON_NO_DEBUG
    +#endif
    +%}
    +
    +

    Some users have reported success in building extension modules using Cygwin and other compilers. However, the problem of building usable DLLs with these diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index c94a3da3b..c8467c78a 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -147,7 +147,7 @@ PERL5_LIB: D:\nsPerl5.004_04\lib\CORE\perl.lib

    -PYTHON_INCLUDE : Set this to the directory that contains python.h
    +PYTHON_INCLUDE : Set this to the directory that contains Python.h
    PYTHON_LIB : Set this to the python library including path for linking

    Example using Python 2.1.1:
    diff --git a/Examples/python/class/example.dsp b/Examples/python/class/example.dsp index b75bd9ee2..35955709a 100644 --- a/Examples/python/class/example.dsp +++ b/Examples/python/class/example.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/contract/example.dsp b/Examples/python/contract/example.dsp index 68f79c7a6..40f57196e 100644 --- a/Examples/python/contract/example.dsp +++ b/Examples/python/contract/example.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/import/bar.dsp b/Examples/python/import/bar.dsp index df4d03e1c..9ba6edaaa 100644 --- a/Examples/python/import/bar.dsp +++ b/Examples/python/import/bar.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/import/base.dsp b/Examples/python/import/base.dsp index 5f2c4c503..f66068feb 100644 --- a/Examples/python/import/base.dsp +++ b/Examples/python/import/base.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/import/foo.dsp b/Examples/python/import/foo.dsp index fc7a94b14..6c43e9121 100644 --- a/Examples/python/import/foo.dsp +++ b/Examples/python/import/foo.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/import/spam.dsp b/Examples/python/import/spam.dsp index 6fa4713ee..acf18677c 100644 --- a/Examples/python/import/spam.dsp +++ b/Examples/python/import/spam.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/multimap/example.dsp b/Examples/python/multimap/example.dsp index 68f79c7a6..40f57196e 100644 --- a/Examples/python/multimap/example.dsp +++ b/Examples/python/multimap/example.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/simple/example.dsp b/Examples/python/simple/example.dsp index 68f79c7a6..40f57196e 100644 --- a/Examples/python/simple/example.dsp +++ b/Examples/python/simple/example.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Lib/python/pyruntime.swg b/Lib/python/pyruntime.swg index dd22a1fdf..b0c4f5741 100644 --- a/Lib/python/pyruntime.swg +++ b/Lib/python/pyruntime.swg @@ -1,6 +1,12 @@ %insert(runtime) %{ -/* Python.h has to appear first */ -#include +#if defined(_DEBUG) && defined(SWIG_PYTHON_NO_DEBUG) +/* Use debug wrappers with the Python release dll */ +# undef _DEBUG +# include +# define _DEBUG +#else +# include +#endif %} %insert(runtime) "swigrun.swg"; /* SWIG API */ @@ -13,4 +19,4 @@ #if defined(SWIGPYTHON_BUILTIN) %insert(runtime) "builtin.swg"; /* Specialization for classes with single inheritance */ -#endif \ No newline at end of file +#endif From 7f95c7bb3efe0f282833a71b50818cf46d80cc1a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 11 Jun 2013 19:15:57 +0100 Subject: [PATCH 220/273] Use a less confusing macro name, SWIG_PYTHON_NO_DEBUG => SWIG_PYTHON_INTERPRETER_NO_DEBUG --- CHANGES.current | 2 +- Doc/Manual/Python.html | 4 ++-- Examples/python/class/example.dsp | 2 +- Examples/python/contract/example.dsp | 2 +- Examples/python/import/bar.dsp | 2 +- Examples/python/import/base.dsp | 2 +- Examples/python/import/foo.dsp | 2 +- Examples/python/import/spam.dsp | 2 +- Examples/python/multimap/example.dsp | 2 +- Examples/python/simple/example.dsp | 2 +- Lib/python/pyruntime.swg | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 4fbd0d6e1..023f2ef6c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -6,7 +6,7 @@ Version 2.0.11 (in progress) ============================ 2013-07-11: wsfulton - [Python] Add SWIG_PYTHON_NO_DEBUG macro which can be defined to use the Release version + [Python] Add SWIG_PYTHON_INTERPRETER_NO_DEBUG macro which can be defined to use the Release version of the Python interpreter in Debug builds of the wrappers. The Visual Studio .dsp example files have been modified to use this so that Debug builds will now work without having to install or build a Debug build of the interpreter. diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index fd7bfca4e..3dde20887 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -874,7 +874,7 @@ the build options of project to try and track this down. A 'Debug' build of the wrappers requires a debug build of the Python interpreter. This normally requires building the Python interpreter from source, which is not a job for the feint-hearted. Alternatively you can use the 'Release' build of the -Python interpreter with a 'Debug' build of your wrappers by defining the SWIG_PYTHON_NO_DEBUG +Python interpreter with a 'Debug' build of your wrappers by defining the SWIG_PYTHON_INTERPRETER_NO_DEBUG symbol under the preprocessor options. Or you can ensure this macro is defined at the beginning of the wrapper code using the following in your interface file, where _MSC_VER ensures it is only used by the Visual Studio compiler: @@ -883,7 +883,7 @@ only used by the Visual Studio compiler:

     %begin %{
     #ifdef _MSC_VER
    -#define SWIG_PYTHON_NO_DEBUG
    +#define SWIG_PYTHON_INTERPRETER_NO_DEBUG
     #endif
     %}
     
    diff --git a/Examples/python/class/example.dsp b/Examples/python/class/example.dsp index 35955709a..95ad8f173 100644 --- a/Examples/python/class/example.dsp +++ b/Examples/python/class/example.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/contract/example.dsp b/Examples/python/contract/example.dsp index 40f57196e..945b9a36d 100644 --- a/Examples/python/contract/example.dsp +++ b/Examples/python/contract/example.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/import/bar.dsp b/Examples/python/import/bar.dsp index 9ba6edaaa..3c0dbf2bd 100644 --- a/Examples/python/import/bar.dsp +++ b/Examples/python/import/bar.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/import/base.dsp b/Examples/python/import/base.dsp index f66068feb..76b3f866b 100644 --- a/Examples/python/import/base.dsp +++ b/Examples/python/import/base.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/import/foo.dsp b/Examples/python/import/foo.dsp index 6c43e9121..0a579e4cd 100644 --- a/Examples/python/import/foo.dsp +++ b/Examples/python/import/foo.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/import/spam.dsp b/Examples/python/import/spam.dsp index acf18677c..3adfcdb8b 100644 --- a/Examples/python/import/spam.dsp +++ b/Examples/python/import/spam.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/multimap/example.dsp b/Examples/python/multimap/example.dsp index 40f57196e..945b9a36d 100644 --- a/Examples/python/multimap/example.dsp +++ b/Examples/python/multimap/example.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/simple/example.dsp b/Examples/python/simple/example.dsp index 40f57196e..945b9a36d 100644 --- a/Examples/python/simple/example.dsp +++ b/Examples/python/simple/example.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Lib/python/pyruntime.swg b/Lib/python/pyruntime.swg index b0c4f5741..fad97be9f 100644 --- a/Lib/python/pyruntime.swg +++ b/Lib/python/pyruntime.swg @@ -1,5 +1,5 @@ %insert(runtime) %{ -#if defined(_DEBUG) && defined(SWIG_PYTHON_NO_DEBUG) +#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) /* Use debug wrappers with the Python release dll */ # undef _DEBUG # include From 0d05b2a2d1f0330b03e4b116cc6378346be85b28 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Wed, 5 Jun 2013 20:31:39 +0200 Subject: [PATCH 221/273] Octave: make texinfo strings static (internal linkage) --- Source/Modules/octave.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index bf2552a30..35ebc9ad4 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -288,7 +288,7 @@ public: String *escaped_doc_str = texinfo_escape(doc_str); if (Len(doc_str)>0) { - Printf(f_doc,"const char* %s_texinfo = ",wrap_name); + Printf(f_doc,"static const char* %s_texinfo = ",wrap_name); Printf(f_doc,"\"-*- texinfo -*-\\n\\\n%s", escaped_doc_str); if (Len(decl_info)) Printf(f_doc,"\\n\\\n@end deftypefn"); From d72e3dd899e4c359a874bb621d9721aaac23bfb9 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Wed, 5 Jun 2013 20:32:07 +0200 Subject: [PATCH 222/273] Octave: add SWIGRUNTIMEINLINE to SWIG_Octave_SetConstant() --- Lib/octave/octrun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 8fdb12086..41d1c7afa 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -1280,7 +1280,7 @@ SWIGRUNTIME int SWIG_Octave_ConvertPacked(const octave_value &ov, void *ptr, siz return ost->copy(type, (char *) ptr, sz) ? SWIG_OK : SWIG_ERROR; } -void SWIG_Octave_SetConstant(octave_swig_type *module_ns, const std::string &name, const octave_value &ov) { +SWIGRUNTIMEINLINE void SWIG_Octave_SetConstant(octave_swig_type *module_ns, const std::string &name, const octave_value &ov) { module_ns->assign(name, ov); } From 0058eea3ad8f0967f6697b502a47b17a536fa7c2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Jul 2013 19:23:10 +0100 Subject: [PATCH 223/273] Add SF patch #342 fix some director classes crashing on object deletion when using -builtin. Fixes SF bug #1301 and python test cases director_basic and director_classic seg faulting when used with -builtin. Patch from Christian Delbaere. --- CHANGES.current | 4 ++++ Lib/python/builtin.swg | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 023f2ef6c..27ea24688 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.11 (in progress) ============================ +2013-08-01: wsfulton + [Python] Add SF patch #342 from Christian Delbaere to fix some director classes crashing on + object deletion when using -builtin. Fixes SF bug #1301. + 2013-07-11: wsfulton [Python] Add SWIG_PYTHON_INTERPRETER_NO_DEBUG macro which can be defined to use the Release version of the Python interpreter in Debug builds of the wrappers. The Visual Studio .dsp example diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 1fc3fb05f..28c557a21 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -13,7 +13,11 @@ wrapper##_closure(PyObject *a) { \ PyObject *o = wrapper(a, NULL); \ Py_XDECREF(o); \ } \ - PyObject_Del(a); \ + if (PyType_IS_GC(a->ob_type)) { \ + PyObject_GC_Del(a); \ + } else { \ + PyObject_Del(a); \ + } \ } #define SWIGPY_INQUIRY_CLOSURE(wrapper) \ From 779dc402b6744d3ae6b1859db08d4ed3d05610cf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Jul 2013 19:58:59 +0100 Subject: [PATCH 224/273] Fix a const_cast in generated code that was generating a <:: digraph when using the unary scope operator (::) (global scope) in a template type. Affects Python, Ruby, Ocaml. Based on SF patch #341. --- CHANGES.current | 4 ++++ Source/Modules/ocaml.cxx | 2 +- Source/Modules/python.cxx | 2 +- Source/Modules/ruby.cxx | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 27ea24688..1ec767bd7 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.11 (in progress) ============================ +2013-08-01: wsfulton + [Python, Ruby, Ocaml] Apply SF patch #341 - fix a const_cast in generated code that was generating + a <:: digraph when using the unary scope operator (::) (global scope) in a template type. + 2013-08-01: wsfulton [Python] Add SF patch #342 from Christian Delbaere to fix some director classes crashing on object deletion when using -builtin. Fixes SF bug #1301. diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index c5fcf69dd..f60c13ed3 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1503,7 +1503,7 @@ public: /* if necessary, cast away const since Python doesn't support it! */ if (SwigType_isconst(nptype)) { nonconst = NewStringf("nc_tmp_%s", pname); - String *nonconst_i = NewStringf("= const_cast<%s>(%s)", SwigType_lstr(ptype, 0), ppname); + String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname); Wrapper_add_localv(w, nonconst, SwigType_lstr(ptype, 0), nonconst, nonconst_i, NIL); Delete(nonconst_i); Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number, diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 9a068a40a..814626a0c 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4724,7 +4724,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { /* if necessary, cast away const since Python doesn't support it! */ if (SwigType_isconst(nptype)) { nonconst = NewStringf("nc_tmp_%s", pname); - String *nonconst_i = NewStringf("= const_cast<%s>(%s)", SwigType_lstr(ptype, 0), ppname); + String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname); Wrapper_add_localv(w, nonconst, SwigType_lstr(ptype, 0), nonconst, nonconst_i, NIL); Delete(nonconst_i); Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number, diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 48680e803..3d2c27dad 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -3201,7 +3201,7 @@ public: /* if necessary, cast away const since Ruby doesn't support it! */ if (SwigType_isconst(nptype)) { nonconst = NewStringf("nc_tmp_%s", parameterName); - String *nonconst_i = NewStringf("= const_cast<%s>(%s)", SwigType_lstr(parameterType, 0), ppname); + String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(parameterType, 0), ppname); Wrapper_add_localv(w, nonconst, SwigType_lstr(parameterType, 0), nonconst, nonconst_i, NIL); Delete(nonconst_i); Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number, From 7491be12e517d504cef2cf43a6d355ab09a5ee03 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Jul 2013 20:09:31 +0100 Subject: [PATCH 225/273] Uninitialized variable fix in SWIG_Python_NonDynamicSetAttr when using -builtin. SF patch #340 --- CHANGES.current | 4 ++++ Lib/python/pyrun.swg | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1ec767bd7..3f31ce314 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.11 (in progress) ============================ +2013-08-01: wsfulton + [Python] Apply SF patch #340 - Uninitialized variable fix in SWIG_Python_NonDynamicSetAttr + when using -builtin. + 2013-08-01: wsfulton [Python, Ruby, Ocaml] Apply SF patch #341 - fix a const_cast in generated code that was generating a <:: digraph when using the unary scope operator (::) (global scope) in a template type. diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 7cf9c41fa..df87bb317 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1742,7 +1742,7 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { PyObject *descr; PyObject *encoded_name; descrsetfunc f; - int res; + int res = -1; # ifdef Py_USING_UNICODE if (PyString_Check(name)) { @@ -1765,7 +1765,6 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { goto done; } - res = -1; descr = _PyType_Lookup(tp, name); f = NULL; if (descr != NULL) From 112d7aa6d0ae36af7ed6fc56abfef740d6e08a8a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Jul 2013 20:13:36 +0100 Subject: [PATCH 226/273] Go examples and test-suite format fixes Patch has the results of find . -name *.go -exec gofmt -w {} \; SF Patch #339. --- Examples/go/callback/runme.go | 2 +- Examples/go/class/runme.go | 2 +- Examples/go/constants/runme.go | 2 +- Examples/go/enum/runme.go | 2 +- Examples/go/extend/runme.go | 2 +- Examples/go/funcptr/runme.go | 2 +- Examples/go/multimap/runme.go | 2 +- Examples/go/pointer/runme.go | 2 +- Examples/go/reference/runme.go | 2 +- Examples/go/simple/runme.go | 2 +- Examples/go/template/runme.go | 2 +- Examples/go/variables/runme.go | 2 +- Examples/test-suite/go/constover_runme.go | 2 +- Examples/test-suite/go/template_typedef_cplx3_runme.go | 1 - Examples/test-suite/go/template_typedef_cplx4_runme.go | 1 - Examples/test-suite/go/template_typedef_import_runme.go | 1 - 16 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Examples/go/callback/runme.go b/Examples/go/callback/runme.go index ffa4b3874..2eef77fdb 100644 --- a/Examples/go/callback/runme.go +++ b/Examples/go/callback/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/class/runme.go b/Examples/go/class/runme.go index ff64bb4be..8d68afb61 100644 --- a/Examples/go/class/runme.go +++ b/Examples/go/class/runme.go @@ -3,8 +3,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/constants/runme.go b/Examples/go/constants/runme.go index 78a047e20..1427997a0 100644 --- a/Examples/go/constants/runme.go +++ b/Examples/go/constants/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" "./example" + "fmt" ) func main() { diff --git a/Examples/go/enum/runme.go b/Examples/go/enum/runme.go index 419df5f93..99d2651f4 100644 --- a/Examples/go/enum/runme.go +++ b/Examples/go/enum/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go index 187f1ce08..8fdfd0a6c 100644 --- a/Examples/go/extend/runme.go +++ b/Examples/go/extend/runme.go @@ -3,8 +3,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) type CEO struct{} diff --git a/Examples/go/funcptr/runme.go b/Examples/go/funcptr/runme.go index 73ecbb805..44dae3c9e 100644 --- a/Examples/go/funcptr/runme.go +++ b/Examples/go/funcptr/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/multimap/runme.go b/Examples/go/multimap/runme.go index 94c29127c..390205a80 100644 --- a/Examples/go/multimap/runme.go +++ b/Examples/go/multimap/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/pointer/runme.go b/Examples/go/pointer/runme.go index 63deb11b7..1414d341e 100644 --- a/Examples/go/pointer/runme.go +++ b/Examples/go/pointer/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/reference/runme.go b/Examples/go/reference/runme.go index 3683d6144..004a04c2e 100644 --- a/Examples/go/reference/runme.go +++ b/Examples/go/reference/runme.go @@ -3,8 +3,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/simple/runme.go b/Examples/go/simple/runme.go index c829ad21a..9eb0ff454 100644 --- a/Examples/go/simple/runme.go +++ b/Examples/go/simple/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" "./example" + "fmt" ) func main() { diff --git a/Examples/go/template/runme.go b/Examples/go/template/runme.go index 8b3d4000e..fca2f1b75 100644 --- a/Examples/go/template/runme.go +++ b/Examples/go/template/runme.go @@ -3,8 +3,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/variables/runme.go b/Examples/go/variables/runme.go index 26cad4b3c..3d9737f5c 100644 --- a/Examples/go/variables/runme.go +++ b/Examples/go/variables/runme.go @@ -3,8 +3,8 @@ package main import ( - "fmt" "./example" + "fmt" ) func main() { diff --git a/Examples/test-suite/go/constover_runme.go b/Examples/test-suite/go/constover_runme.go index e649140a6..f961e01b5 100644 --- a/Examples/test-suite/go/constover_runme.go +++ b/Examples/test-suite/go/constover_runme.go @@ -1,9 +1,9 @@ package main import ( + "./constover" "fmt" "os" - "./constover" ) func main() { diff --git a/Examples/test-suite/go/template_typedef_cplx3_runme.go b/Examples/test-suite/go/template_typedef_cplx3_runme.go index f827d7a1e..d616777e0 100644 --- a/Examples/test-suite/go/template_typedef_cplx3_runme.go +++ b/Examples/test-suite/go/template_typedef_cplx3_runme.go @@ -5,7 +5,6 @@ import . "./template_typedef_cplx3" func main() { // this is OK - s := NewSin() s.Get_base_value() s.Get_value() diff --git a/Examples/test-suite/go/template_typedef_cplx4_runme.go b/Examples/test-suite/go/template_typedef_cplx4_runme.go index 9021cf135..3e536d6f2 100644 --- a/Examples/test-suite/go/template_typedef_cplx4_runme.go +++ b/Examples/test-suite/go/template_typedef_cplx4_runme.go @@ -5,7 +5,6 @@ import . "./template_typedef_cplx4" func main() { // this is OK - s := NewSin() s.Get_base_value() s.Get_value() diff --git a/Examples/test-suite/go/template_typedef_import_runme.go b/Examples/test-suite/go/template_typedef_import_runme.go index 8528b9a93..f1c00ff13 100644 --- a/Examples/test-suite/go/template_typedef_import_runme.go +++ b/Examples/test-suite/go/template_typedef_import_runme.go @@ -6,7 +6,6 @@ import "template_typedef_import" func main() { // this is OK - s := template_typedef_import.NewSin() s.Get_base_value() s.Get_value() From c8a879303c8f044036b951ebbc2cc7e956126732 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 2 Jul 2013 12:29:28 +1200 Subject: [PATCH 227/273] Fix comment typo (interpeters) --- Lib/swiginit.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/swiginit.swg b/Lib/swiginit.swg index f747bccdf..6fe58d296 100644 --- a/Lib/swiginit.swg +++ b/Lib/swiginit.swg @@ -94,7 +94,7 @@ SWIG_InitializeModule(void *clientdata) { module_head->next = &swig_module; } - /* When multiple interpeters are used, a module could have already been initialized in + /* When multiple interpreters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ From d3252bbf7fcdf326e286a2ed64d5106b61d80d19 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 2 Jul 2013 13:22:35 +1200 Subject: [PATCH 228/273] Fix comment typo --- Source/DOH/fio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/DOH/fio.c b/Source/DOH/fio.c index 5693deeb5..d2a1bab19 100644 --- a/Source/DOH/fio.c +++ b/Source/DOH/fio.c @@ -21,7 +21,7 @@ static DOH *encodings = 0; /* Encoding hash */ /* ----------------------------------------------------------------------------- * Writen() * - * Write's N characters of output and retries until all characters are + * Writes N characters of output and retries until all characters are * written. This is useful should a write operation encounter a spurious signal. * ----------------------------------------------------------------------------- */ From ace8fcd97248dccc7bbd3b94185a49142320eda0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Jul 2013 18:47:00 +0100 Subject: [PATCH 229/273] SWIG_AsWCharPtrAndSize improper operation if cptr NULL SF bug #1327 This doesn't have any noticeable effect with the usage of SWIG_AsWCharPtrAndSize as shipped by SWIG, but could be a problem if a user is using this function with cptr equal to zero and psize is non-zero - the length would be incorrectly set due to the call to PyUnicode_GetSize failing. --- Examples/test-suite/li_std_wstring.i | 8 ++++++++ Examples/test-suite/python/li_std_wstring_runme.py | 6 ++++++ Lib/python/pywstrings.swg | 4 +--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/li_std_wstring.i b/Examples/test-suite/li_std_wstring.i index c809e11ec..e0ecde53b 100644 --- a/Examples/test-suite/li_std_wstring.i +++ b/Examples/test-suite/li_std_wstring.i @@ -38,6 +38,14 @@ wchar_t* test_cvalue(wchar_t* x) { } +wchar_t* test_wchar_overload() { + return 0; +} + +wchar_t* test_wchar_overload(wchar_t *x) { + return x; +} + std::wstring test_value(std::wstring x) { return x; } diff --git a/Examples/test-suite/python/li_std_wstring_runme.py b/Examples/test-suite/python/li_std_wstring_runme.py index a2d419a0a..fecc527e0 100644 --- a/Examples/test-suite/python/li_std_wstring_runme.py +++ b/Examples/test-suite/python/li_std_wstring_runme.py @@ -13,6 +13,12 @@ if li_std_wstring.test_ccvalue(x) != x: if li_std_wstring.test_cvalue(x) != x: raise RuntimeError("bad string mapping") +if li_std_wstring.test_wchar_overload(x) != x: + raise RuntimeError("bad string mapping") + +if li_std_wstring.test_wchar_overload("not unicode") != "not unicode": + raise RuntimeError("bad string mapping") + if li_std_wstring.test_value(x) != x: print x, li_std_wstring.test_value(x) raise RuntimeError("bad string mapping") diff --git a/Lib/python/pywstrings.swg b/Lib/python/pywstrings.swg index 619bdd555..864376b01 100644 --- a/Lib/python/pywstrings.swg +++ b/Lib/python/pywstrings.swg @@ -18,9 +18,7 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc) int isunicode = PyUnicode_Check(obj); %#if PY_VERSION_HEX < 0x03000000 if (!isunicode && PyString_Check(obj)) { - if (cptr) { - obj = tmp = PyUnicode_FromObject(obj); - } + obj = tmp = PyUnicode_FromObject(obj); isunicode = 1; } %#endif From 1c440787510698aa71c39cfa8042899dcbecdc96 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Jul 2013 20:00:17 +0100 Subject: [PATCH 230/273] Improve testing of %pythonprepend and %pythonappend --- .../test-suite/python/python_append_runme.py | 7 +++++++ Examples/test-suite/python_append.i | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py index c8e6b2640..41cebad58 100644 --- a/Examples/test-suite/python/python_append_runme.py +++ b/Examples/test-suite/python/python_append_runme.py @@ -2,3 +2,10 @@ from python_append import * t=Test() t.func() t.static_func() + +if grabpath() != os.path.dirname(mypath): + raise RuntimeError + +if grabstaticpath() != os.path.basename(mypath): + raise RuntimeError + diff --git a/Examples/test-suite/python_append.i b/Examples/test-suite/python_append.i index 2dc9cb970..82d1012ef 100644 --- a/Examples/test-suite/python_append.i +++ b/Examples/test-suite/python_append.i @@ -4,19 +4,34 @@ Testcase to test %pythonprepend and %pythonappend %module python_append +%pythoncode %{ + import os.path + mypath = os.path.dirname("/a/b/c/d.txt") + funcpath = None + staticfuncpath = None + def grabpath(): + return funcpath + def grabstaticpath(): + return staticfuncpath +%} + %pythonappend Test::func %{ - pass + funcpath = os.path.dirname(funcpath) %} %pythonprepend Test::func %{ - pass + global funcpath + funcpath = mypath %} %pythonappend Test::static_func %{ +staticfuncpath = os.path.basename(staticfuncpath) pass %} %pythonprepend Test::static_func { + global staticfuncpath + staticfuncpath = mypath pass } From eb98c0be99a3da4ea860a5068e067459d472a658 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Jul 2013 06:25:07 +0100 Subject: [PATCH 231/273] Correct dates in recent commits to CHANGES file --- CHANGES.current | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 3f31ce314..794700632 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,25 +5,25 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.11 (in progress) ============================ -2013-08-01: wsfulton +2013-07-01: wsfulton [Python] Apply SF patch #340 - Uninitialized variable fix in SWIG_Python_NonDynamicSetAttr when using -builtin. -2013-08-01: wsfulton +2013-07-01: wsfulton [Python, Ruby, Ocaml] Apply SF patch #341 - fix a const_cast in generated code that was generating a <:: digraph when using the unary scope operator (::) (global scope) in a template type. -2013-08-01: wsfulton +2013-07-01: wsfulton [Python] Add SF patch #342 from Christian Delbaere to fix some director classes crashing on object deletion when using -builtin. Fixes SF bug #1301. -2013-07-11: wsfulton +2013-06-11: wsfulton [Python] Add SWIG_PYTHON_INTERPRETER_NO_DEBUG macro which can be defined to use the Release version of the Python interpreter in Debug builds of the wrappers. The Visual Studio .dsp example files have been modified to use this so that Debug builds will now work without having to install or build a Debug build of the interpreter. -2013-07-07: wsfulton +2013-06-07: wsfulton [Ruby] Git issue #52. Fix regression with missing rb_complex_new function for Ruby versions prior to 1.9 using std::complex wrappers if just using std::complex as an output type. Also fix the Complex helper functions external visibility (to static by default). From d0af4f50d301cd971e7dadf1e48a5b5c8c66e4b4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Jul 2013 06:30:16 +0100 Subject: [PATCH 232/273] Add %pythonbegin directive. For adding code at the beginning of the generated .py file. --- CHANGES.current | 10 ++++++ Doc/Manual/Python.html | 47 +++++++++++++++++++++++++++++ Examples/test-suite/python_append.i | 7 +++-- Lib/python/pyuserdir.swg | 1 + Source/Modules/python.cxx | 9 +++++- 5 files changed, 71 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 794700632..c07420a00 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,16 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.11 (in progress) ============================ +2013-07-05: wsfulton + [Python] Add %pythonbegin directive which works like %pythoncode, except the specified code is + added at the beginning of the generated .py file. This is primarily needed for importing from + __future__ statements required to be at the very beginning of the file. Example: + + %pythonbegin %{ + from __future__ import print_function + print("Loading", "Whizz", "Bang", sep=' ... ') + %} + 2013-07-01: wsfulton [Python] Apply SF patch #340 - Uninitialized variable fix in SWIG_Python_NonDynamicSetAttr when using -builtin. diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 3dde20887..6a22738bc 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -3314,6 +3314,53 @@ what can be done without having to rely on any of the more advanced customization features.

    +

    +There is also %pythonbegin which is another directive very similar to %pythoncode, +but generates the given Python code at the beginning of the .py file. +This directive works in the same way as %pythoncode, except the code is copied +just after the SWIG banner (comment) at the top of the file, before any real code. +This provides an opportunity to add your own description in a comment near the top of the file as well +as Python imports that have to appear at the top of the file, such as "from __future__ import" +statements. +

    + +

    +The following shows example usage for Python 2.6 to use print as it can in Python 3, that is, as a function instead of a statement: +

    + +
    +
    +%pythonbegin %{
    +# This module provides wrappers to the Whizz Bang library
    +%}
    +
    +%pythonbegin %{
    +from __future__ import print_function
    +print("Loading", "Whizz", "Bang", sep=' ... ')
    +%}
    +
    +
    + +

    +which can be seen when viewing the first few lines of the generated .py file: +

    + +
    +
    +# This file was automatically generated by SWIG (http://www.swig.org).
    +# Version 2.0.11
    +#
    +# Do not make changes to this file unless you know what you are doing--modify
    +# the SWIG interface file instead.
    +
    +# This module provides wrappers to the Whizz Bang library
    +
    +from __future__ import print_function
    +print("Loading", "Whizz", "Bang", sep=' ... ')
    +
    +
    +
    +

    Sometimes you may want to replace or modify the wrapper function that SWIG creates in the proxy .py file. The Python module in SWIG provides some features that enable you to do this. First, to diff --git a/Examples/test-suite/python_append.i b/Examples/test-suite/python_append.i index 82d1012ef..e263c392b 100644 --- a/Examples/test-suite/python_append.i +++ b/Examples/test-suite/python_append.i @@ -1,11 +1,10 @@ /* -Testcase to test %pythonprepend and %pythonappend +Testcase to test %pythonprepend and %pythonappend %pythoncode %pythonbegin */ %module python_append %pythoncode %{ - import os.path mypath = os.path.dirname("/a/b/c/d.txt") funcpath = None staticfuncpath = None @@ -35,6 +34,10 @@ pass pass } +%pythonbegin %{ +import os.path +%} + %inline %{ class Test { diff --git a/Lib/python/pyuserdir.swg b/Lib/python/pyuserdir.swg index 5247ee65b..d3c3eb188 100644 --- a/Lib/python/pyuserdir.swg +++ b/Lib/python/pyuserdir.swg @@ -7,6 +7,7 @@ /* shadow code */ #define %shadow %insert("shadow") #define %pythoncode %insert("python") +#define %pythonbegin %insert("pythonbegin") /* ------------------------------------------------------------------------- */ diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 814626a0c..7ee4ae225 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -42,6 +42,7 @@ static File *f_directors_h = 0; static File *f_init = 0; static File *f_shadow_py = 0; static String *f_shadow = 0; +static String *f_shadow_begin = 0; static Hash *f_shadow_imports = 0; static String *f_shadow_builtin_imports = 0; static String *f_shadow_stubs = 0; @@ -784,6 +785,7 @@ public: filen = NULL; f_shadow = NewString(""); + f_shadow_begin = NewString(""); f_shadow_imports = NewHash(); f_shadow_builtin_imports = NewString(""); f_shadow_stubs = NewString(""); @@ -977,6 +979,7 @@ public: if (!modern) { Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL); } + Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL); Printv(f_shadow_py, "\n", f_shadow_builtin_imports, "\n", NIL); Printv(f_shadow_py, f_shadow, "\n", NIL); Printv(f_shadow_py, f_shadow_stubs, "\n", NIL); @@ -4451,12 +4454,16 @@ public: String *code = Getattr(n, "code"); String *section = Getattr(n, "section"); - if ((!ImportMode) && ((Cmp(section, "python") == 0) || (Cmp(section, "shadow") == 0))) { + if (!ImportMode && (Cmp(section, "python") == 0 || Cmp(section, "shadow") == 0)) { if (shadow) { String *pycode = pythoncode(code, shadow_indent); Printv(f_shadow, pycode, NIL); Delete(pycode); } + } else if (!ImportMode && (Cmp(section, "pythonbegin") == 0)) { + String *pycode = pythoncode(code, ""); + Printv(f_shadow_begin, pycode, NIL); + Delete(pycode); } else { Language::insertDirective(n); } From 93b63969f9b70895ee1d841c66f414b1be46e90d Mon Sep 17 00:00:00 2001 From: joequant Date: Sun, 14 Jul 2013 20:28:17 +0800 Subject: [PATCH 233/273] change to allow file SEXP return values --- CHANGES.current | 2 ++ Lib/r/rtype.swg | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index c07420a00..1e385ce29 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,6 +4,8 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.11 (in progress) ============================ +2013-07-14: joequant + [R] Change types file to allow for SEXP return values 2013-07-05: wsfulton [Python] Add %pythonbegin directive which works like %pythoncode, except the specified code is diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg index b4571af46..b86a618d9 100644 --- a/Lib/r/rtype.swg +++ b/Lib/r/rtype.swg @@ -151,6 +151,8 @@ string &, std::string & #%typemap(scoerceout) SWIGTYPE *const # %{ class($result) <- "$R_class"; %} + %typemap(scoerceout) SEXP %{ %} + %typemap(scoerceout) SWIGTYPE %{ $result <- new("$&R_class", ref=$result); %} From e8c6384f77b05514f26338fae463860b865ddf97 Mon Sep 17 00:00:00 2001 From: joequant Date: Sun, 14 Jul 2013 20:29:37 +0800 Subject: [PATCH 234/273] add regression tests for SEXP return values --- Examples/test-suite/r/Makefile.in | 3 ++- Examples/test-suite/r/r_sexp_runme.R | 7 +++++++ Examples/test-suite/r_sexp.i | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/r/r_sexp_runme.R create mode 100644 Examples/test-suite/r_sexp.i diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index bece71c2f..18e2d4b25 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -16,7 +16,8 @@ C_TEST_CASES += \ CPP_TEST_CASES += \ r_double_delete \ - r_overload_array + r_overload_array \ + r_sexp include $(srcdir)/../common.mk diff --git a/Examples/test-suite/r/r_sexp_runme.R b/Examples/test-suite/r/r_sexp_runme.R new file mode 100644 index 000000000..96b36e8af --- /dev/null +++ b/Examples/test-suite/r/r_sexp_runme.R @@ -0,0 +1,7 @@ +source("unittest.R") +dyn.load(paste("r_sexp", .Platform$dynlib.ext, sep="")) +source("r_sexp.R") +cacheMetaData(1) + +obj <- return_sexp(1); +unittest(obj, 1) diff --git a/Examples/test-suite/r_sexp.i b/Examples/test-suite/r_sexp.i new file mode 100644 index 000000000..9f786f428 --- /dev/null +++ b/Examples/test-suite/r_sexp.i @@ -0,0 +1,10 @@ +%module r_sexp + +extern "C" SEXP return_sexp(SEXP x); + +%inline %{ +SEXP return_sexp(SEXP x) { + return x; //Rcpp NumericVector is automatically casted to SEXP +} +%} + From 479df82616be2a7f08cd4df68c2c7b51073d9e2b Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Fri, 5 Jul 2013 22:37:15 +0200 Subject: [PATCH 235/273] Octave: more robust configuration - do not rely on --eval argument to find mkoctfile, instead assume it is in the same directory as octave itself (which it always should be) - check Octave options to make sure they are supported, including --no-window-system to prevent warnings if building without an X server - disable Octave if any vital tests fail --- Examples/Makefile.in | 2 +- Examples/test-suite/octave/Makefile.in | 2 +- configure.ac | 38 ++++++++++++++++++-------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 280923df2..df754427c 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -398,7 +398,7 @@ python_clean: ################################################################## # Make sure these locate your Octave installation -OCTAVE = OCTAVE_HISTFILE=/dev/null @OCTAVE@ -qfH +OCTAVE = OCTAVE_HISTFILE=/dev/null @OCTAVE@ OCTAVE_CXX = $(DEFS) @OCTAVE_CPPFLAGS@ @OCTAVE_CXXFLAGS@ # Extra Octave specific dynamic linking options diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index 88f533fd1..fe957eeb0 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -3,7 +3,7 @@ ####################################################################### LANGUAGE = octave -OCTAVE = @OCTAVE@ -qf +OCTAVE = @OCTAVE@ SCRIPTSUFFIX = _runme.m srcdir = @srcdir@ top_srcdir = @top_srcdir@ diff --git a/configure.ac b/configure.ac index 616610eda..1d3250afb 100644 --- a/configure.ac +++ b/configure.ac @@ -938,7 +938,7 @@ if test x"${OCTAVEBIN}" = xno -o x"${with_alllang}" = xno ; then # First figure out what the name of Octave is elif test "x$OCTAVEBIN" = xyes; then - AC_CHECK_PROGS(OCTAVE, octave) + AC_PATH_PROG(OCTAVE, [octave]) else OCTAVE="$OCTAVEBIN" @@ -946,31 +946,45 @@ fi if test -n "$OCTAVE"; then AC_MSG_CHECKING([for mkoctfile]) - AS_IF([test "x`${OCTAVE} -qfH --eval 'mkoctfile -p CXX' 2>/dev/null`" != x],[ - AC_MSG_RESULT([yes]) + mkoctfile="`dirname ${OCTAVE}`/mkoctfile" + AS_IF([test -x "${mkoctfile}"],[ + AC_MSG_RESULT([${mkoctfile}]) ],[ - AC_MSG_ERROR([mkoctfile is not installed]) + AC_MSG_RESULT([not found, disabling Octave]) + OCTAVE= ]) +fi +if test -n "$OCTAVE"; then AC_MSG_CHECKING([for Octave preprocessor flags]) OCTAVE_CPPFLAGS= for n in CPPFLAGS INCFLAGS; do - OCTAVE_CPPFLAGS="${OCTAVE_CPPFLAGS} "`$OCTAVE -qfH --eval "mkoctfile -p $n"` + OCTAVE_CPPFLAGS="${OCTAVE_CPPFLAGS} "`${mkoctfile} -p $n` done - AC_MSG_RESULT($OCTAVE_CPPFLAGS) + AC_MSG_RESULT([$OCTAVE_CPPFLAGS]) AC_MSG_CHECKING([for Octave compiler flags]) OCTAVE_CXXFLAGS= for n in ALL_CXXFLAGS; do - OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} "`$OCTAVE -qfH --eval "mkoctfile -p $n"` + OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} "`${mkoctfile} -p $n` done - AC_MSG_RESULT($OCTAVE_CXXFLAGS) + AC_MSG_RESULT([$OCTAVE_CXXFLAGS]) AC_MSG_CHECKING([for Octave linker flags]) OCTAVE_LDFLAGS= for n in RDYNAMIC_FLAG LFLAGS RLD_FLAG OCTAVE_LIBS LIBS; do - OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`$OCTAVE -qfH --eval "mkoctfile -p $n"` + OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`${mkoctfile} -p $n` + done + AC_MSG_RESULT([$OCTAVE_LDFLAGS]) +fi +if test -n "$OCTAVE"; then + for octave_opt in --silent --norc --no-history --no-window-system; do + AC_MSG_CHECKING([if Octave option '${octave_opt}' is supported]) + ${OCTAVE} ${octave_opt} /dev/null >/dev/null 2>&1 + AS_IF([test $? -eq 0],[ + AC_MSG_RESULT([yes]) + OCTAVE="${OCTAVE} ${octave_opt}" + ],[ + AC_MSG_RESULT([no]) + ]) done - AC_MSG_RESULT($OCTAVE_LDFLAGS) -else - AC_MSG_RESULT(could not figure out how to run octave) fi AC_SUBST(OCTAVE) From b28de208697701ec39629a14f23acf37125568e2 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 16 Jul 2013 14:18:16 +0200 Subject: [PATCH 236/273] Octave: fixups to previous configuration patch - remove unneeded test -n "$OCTAVE" - do not rely on Octave returning non-zero status for unrecognised option; search first line of output for 'unrecognized' instead --- configure.ac | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 1d3250afb..ee16ff16e 100644 --- a/configure.ac +++ b/configure.ac @@ -973,12 +973,10 @@ if test -n "$OCTAVE"; then OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`${mkoctfile} -p $n` done AC_MSG_RESULT([$OCTAVE_LDFLAGS]) -fi -if test -n "$OCTAVE"; then for octave_opt in --silent --norc --no-history --no-window-system; do AC_MSG_CHECKING([if Octave option '${octave_opt}' is supported]) - ${OCTAVE} ${octave_opt} /dev/null >/dev/null 2>&1 - AS_IF([test $? -eq 0],[ + octave_out=`${OCTAVE} ${octave_opt} /dev/null 2>&1 | sed -n '1{/unrecognized/p}'` + AS_IF([test "x${octave_out}" != x],[ AC_MSG_RESULT([yes]) OCTAVE="${OCTAVE} ${octave_opt}" ],[ From 83178a1fe40844c2438bcad871c6cf510bf9c03e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 16 Jul 2013 23:05:59 +0100 Subject: [PATCH 237/273] Correction for detecting invalid Octave options --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ee16ff16e..cc4270ad7 100644 --- a/configure.ac +++ b/configure.ac @@ -976,7 +976,7 @@ if test -n "$OCTAVE"; then for octave_opt in --silent --norc --no-history --no-window-system; do AC_MSG_CHECKING([if Octave option '${octave_opt}' is supported]) octave_out=`${OCTAVE} ${octave_opt} /dev/null 2>&1 | sed -n '1{/unrecognized/p}'` - AS_IF([test "x${octave_out}" != x],[ + AS_IF([test "x${octave_out}" = x],[ AC_MSG_RESULT([yes]) OCTAVE="${OCTAVE} ${octave_opt}" ],[ From 5f1fff1849285f46cfaffadff0352cf976ea4c52 Mon Sep 17 00:00:00 2001 From: Andrew Simmons Date: Mon, 8 Jul 2013 17:29:24 -0500 Subject: [PATCH 238/273] Copied std::pair<> fragment from Lib/std/std_map.i into Lib/std/std_multimap.i. This fixes an error when a std::multimap template is wrapped by itself. --- Lib/std/std_multimap.i | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Lib/std/std_multimap.i b/Lib/std/std_multimap.i index f165e5f33..5a2cf38d7 100644 --- a/Lib/std/std_multimap.i +++ b/Lib/std/std_multimap.i @@ -60,6 +60,20 @@ namespace std { %traits_swigtype(_Key); %traits_swigtype(_Tp); + %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header", + fragment=SWIG_Traits_frag(_Key), + fragment=SWIG_Traits_frag(_Tp), + fragment="StdPairTraits") { + namespace swig { + template <> struct traits > { + typedef pointer_category category; + static const char* type_name() { + return "std::pair<" #_Key "," #_Tp " >"; + } + }; + } + } + %fragment(SWIG_Traits_frag(std::multimap<_Key, _Tp, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >), fragment="StdMultimapTraits") { From 80f8d1d9225b5fcb66b774e8859637f14e11afd8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Jul 2013 07:34:39 +0100 Subject: [PATCH 239/273] Fix for missing C++ code in std::multimap wrappers. %template for a std::multimap generated uncompilable code unless a %template for a std::map of the same template types was also coded up. This patch is needed in conjunction with previous commit - 5f1fff1849285f46cfaffadff0352cf976ea4c52 Closes #64 Closes #65 --- CHANGES.current | 5 + Examples/test-suite/li_std_multimap.i | 2 - Lib/octave/std_map.i | 135 ++++++++++++------------ Lib/python/std_map.i | 142 +++++++++++++------------- Lib/python/std_multimap.i | 2 +- Lib/ruby/std_map.i | 123 +++++++++++----------- Lib/ruby/std_multimap.i | 2 +- 7 files changed, 214 insertions(+), 197 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1e385ce29..b03e05ffc 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,6 +4,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.11 (in progress) ============================ +2013-07-30: wsfulton + [Python, Ruby] Fix #64 #65: Missing code in std::multimap wrappers. Previously an instantiation + of a std::map was erroneously required in addition to an instantiation of std::multimap with the + same template parameters to prevent compilation errors for the wrappers of a std::multimap. + 2013-07-14: joequant [R] Change types file to allow for SEXP return values diff --git a/Examples/test-suite/li_std_multimap.i b/Examples/test-suite/li_std_multimap.i index a29417919..bd087d361 100644 --- a/Examples/test-suite/li_std_multimap.i +++ b/Examples/test-suite/li_std_multimap.i @@ -3,7 +3,6 @@ %feature("trackobjects"); %include std_pair.i -%include std_map.i %include std_multimap.i %inline %{ @@ -20,6 +19,5 @@ struct A{ namespace std { %template(pairA) pair; - %template(mapA) map; %template(multimapA) multimap; } diff --git a/Lib/octave/std_map.i b/Lib/octave/std_map.i index 6c476ce53..7b85a548e 100644 --- a/Lib/octave/std_map.i +++ b/Lib/octave/std_map.i @@ -2,73 +2,9 @@ %include -%fragment("StdMapTraits","header",fragment="StdSequenceTraits") +%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") { namespace swig { - template - inline void - assign(const OctSeq& octseq, std::map *map) { - typedef typename std::map::value_type value_type; - typename OctSeq::const_iterator it = octseq.begin(); - for (;it != octseq.end(); ++it) { - map->insert(value_type(it->first, it->second)); - } - } - - template - struct traits_asptr > { - typedef std::map map_type; - static int asptr(octave_value obj, map_type **val) { - /* - int res = SWIG_ERROR; - if (PyDict_Check(obj)) { - SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); - res = traits_asptr_stdseq, std::pair >::asptr(items, val); - } else { - map_type *p; - res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); - if (SWIG_IsOK(res) && val) *val = p; - } - return res; - */ - return SWIG_ERROR; - } - }; - - 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; - - static octave_value from(const map_type& map) { - /* - swig_type_info *desc = swig::type_info(); - if (desc && desc->clientdata) { - return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); - } else { - size_type size = map.size(); - int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; - if (pysize < 0) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(PyExc_OverflowError, - "map size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject *obj = PyDict_New(); - for (const_iterator i= map.begin(); i!= map.end(); ++i) { - swig::SwigVar_PyObject key = swig::from(i->first); - swig::SwigVar_PyObject val = swig::from(i->second); - PyDict_SetItem(obj, key, val); - } - return obj; - } - */ - return octave_value(); - } - }; - template struct from_key_oper { @@ -138,6 +74,75 @@ } } +%fragment("StdMapTraits","header",fragment="StdMapCommonTraits") +{ + namespace swig { + template + inline void + assign(const OctSeq& octseq, std::map *map) { + typedef typename std::map::value_type value_type; + typename OctSeq::const_iterator it = octseq.begin(); + for (;it != octseq.end(); ++it) { + map->insert(value_type(it->first, it->second)); + } + } + + template + struct traits_asptr > { + typedef std::map map_type; + static int asptr(octave_value obj, map_type **val) { + /* + int res = SWIG_ERROR; + if (PyDict_Check(obj)) { + SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); + res = traits_asptr_stdseq, std::pair >::asptr(items, val); + } else { + map_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + */ + return SWIG_ERROR; + } + }; + + 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; + + static octave_value from(const map_type& map) { + /* + swig_type_info *desc = swig::type_info(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); + } else { + size_type size = map.size(); + int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_OverflowError, + "map size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject *obj = PyDict_New(); + for (const_iterator i= map.begin(); i!= map.end(); ++i) { + swig::SwigVar_PyObject key = swig::from(i->first); + swig::SwigVar_PyObject val = swig::from(i->second); + PyDict_SetItem(obj, key, val); + } + return obj; + } + */ + return octave_value(); + } + }; + } +} + %define %swig_map_common(Map...) %swig_sequence_iterator(Map); %swig_container_methods(Map); diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index 37d749790..66ed68da5 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -2,7 +2,79 @@ Maps */ -%fragment("StdMapTraits","header",fragment="StdSequenceTraits") +%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") +{ + namespace swig { + template + struct from_key_oper + { + typedef const ValueType& argument_type; + typedef PyObject *result_type; + result_type operator()(argument_type v) const + { + return swig::from(v.first); + } + }; + + template + struct from_value_oper + { + typedef const ValueType& argument_type; + typedef PyObject *result_type; + result_type operator()(argument_type v) const + { + return swig::from(v.second); + } + }; + + template + struct SwigPyMapIterator_T : SwigPyIteratorClosed_T + { + SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyIteratorClosed_T(curr, first, last, seq) + { + } + }; + + + template > + struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T + { + SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyMapIterator_T(curr, first, last, seq) + { + } + }; + + template + inline SwigPyIterator* + make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) + { + return new SwigPyMapKeyIterator_T(current, begin, end, seq); + } + + template > + struct SwigPyMapValueITerator_T : SwigPyMapIterator_T + { + SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyMapIterator_T(curr, first, last, seq) + { + } + }; + + + template + inline SwigPyIterator* + make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) + { + return new SwigPyMapValueITerator_T(current, begin, end, seq); + } + } +} + +%fragment("StdMapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template @@ -73,74 +145,6 @@ } } }; - - template - struct from_key_oper - { - typedef const ValueType& argument_type; - typedef PyObject *result_type; - result_type operator()(argument_type v) const - { - return swig::from(v.first); - } - }; - - template - struct from_value_oper - { - typedef const ValueType& argument_type; - typedef PyObject *result_type; - result_type operator()(argument_type v) const - { - return swig::from(v.second); - } - }; - - template - struct SwigPyMapIterator_T : SwigPyIteratorClosed_T - { - SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyIteratorClosed_T(curr, first, last, seq) - { - } - }; - - - template > - struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T - { - SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapIterator_T(curr, first, last, seq) - { - } - }; - - template - inline SwigPyIterator* - make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) - { - return new SwigPyMapKeyIterator_T(current, begin, end, seq); - } - - template > - struct SwigPyMapValueITerator_T : SwigPyMapIterator_T - { - SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapIterator_T(curr, first, last, seq) - { - } - }; - - - template - inline SwigPyIterator* - make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) - { - return new SwigPyMapValueITerator_T(current, begin, end, seq); - } - } } diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i index 8a240ae10..c81e2ac5d 100644 --- a/Lib/python/std_multimap.i +++ b/Lib/python/std_multimap.i @@ -3,7 +3,7 @@ */ %include -%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits") +%fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template diff --git a/Lib/ruby/std_map.i b/Lib/ruby/std_map.i index e23f1c31b..f706ca873 100644 --- a/Lib/ruby/std_map.i +++ b/Lib/ruby/std_map.i @@ -1,67 +1,9 @@ // // Maps // -%fragment("StdMapTraits","header",fragment="StdSequenceTraits") +%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") { namespace swig { - template - inline void - assign(const RubySeq& rubyseq, std::map *map) { - typedef typename std::map::value_type value_type; - typename RubySeq::const_iterator it = rubyseq.begin(); - for (;it != rubyseq.end(); ++it) { - map->insert(value_type(it->first, it->second)); - } - } - - template - struct traits_asptr > { - typedef std::map map_type; - static int asptr(VALUE obj, map_type **val) { - int res = SWIG_ERROR; - if ( TYPE(obj) == T_HASH ) { - static ID id_to_a = rb_intern("to_a"); - VALUE items = rb_funcall(obj, id_to_a, 0); - res = traits_asptr_stdseq, std::pair >::asptr(items, val); - } else { - map_type *p; - res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); - if (SWIG_IsOK(res) && val) *val = p; - } - return res; - } - }; - - 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; - - static VALUE from(const map_type& map) { - swig_type_info *desc = swig::type_info(); - if (desc && desc->clientdata) { - return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); - } else { - size_type size = map.size(); - int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1; - if (rubysize < 0) { - SWIG_RUBY_THREAD_BEGIN_BLOCK; - rb_raise( rb_eRuntimeError, "map size not valid in Ruby"); - SWIG_RUBY_THREAD_END_BLOCK; - return Qnil; - } - VALUE obj = rb_hash_new(); - for (const_iterator i= map.begin(); i!= map.end(); ++i) { - VALUE key = swig::from(i->first); - VALUE val = swig::from(i->second); - rb_hash_aset(obj, key, val); - } - return obj; - } - } - }; - template struct from_key_oper { @@ -134,6 +76,69 @@ } } +%fragment("StdMapTraits","header",fragment="StdMapCommonTraits") +{ + namespace swig { + template + inline void + assign(const RubySeq& rubyseq, std::map *map) { + typedef typename std::map::value_type value_type; + typename RubySeq::const_iterator it = rubyseq.begin(); + for (;it != rubyseq.end(); ++it) { + map->insert(value_type(it->first, it->second)); + } + } + + template + struct traits_asptr > { + typedef std::map map_type; + static int asptr(VALUE obj, map_type **val) { + int res = SWIG_ERROR; + if ( TYPE(obj) == T_HASH ) { + static ID id_to_a = rb_intern("to_a"); + VALUE items = rb_funcall(obj, id_to_a, 0); + res = traits_asptr_stdseq, std::pair >::asptr(items, val); + } else { + map_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + } + }; + + 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; + + static VALUE from(const map_type& map) { + swig_type_info *desc = swig::type_info(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); + } else { + size_type size = map.size(); + int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (rubysize < 0) { + SWIG_RUBY_THREAD_BEGIN_BLOCK; + rb_raise( rb_eRuntimeError, "map size not valid in Ruby"); + SWIG_RUBY_THREAD_END_BLOCK; + return Qnil; + } + VALUE obj = rb_hash_new(); + for (const_iterator i= map.begin(); i!= map.end(); ++i) { + VALUE key = swig::from(i->first); + VALUE val = swig::from(i->second); + rb_hash_aset(obj, key, val); + } + return obj; + } + } + }; + } +} + %define %swig_map_common(Map...) %swig_container_methods(%arg(Map)); // %swig_sequence_iterator(%arg(Map)); diff --git a/Lib/ruby/std_multimap.i b/Lib/ruby/std_multimap.i index 31795c768..3e06ee12c 100644 --- a/Lib/ruby/std_multimap.i +++ b/Lib/ruby/std_multimap.i @@ -3,7 +3,7 @@ */ %include -%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits") +%fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template From a0af86811dc8835a16c71a1ef78c7a4294438326 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 6 Aug 2013 21:16:11 +0100 Subject: [PATCH 240/273] Travis builds - add in apt-get update php tests were failing. Travis suggest running this before any install - http://about.travis-ci.org/docs/user/build-configuration/#Installing-Packages-Using-apt --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 13502de0b..26758304f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,7 @@ matrix: before_install: - lsb_release -a - uname -a + - sudo apt-get -qq update - time sudo apt-get -qq install libboost-dev - if test "$SWIGLANG" = "csharp"; then sudo apt-get -qq install mono-devel; fi - if test "$SWIGLANG" = "go"; then go env | sed -e 's/^/export /' > goenvsetup && source goenvsetup && rm -f goenvsetup; fi # Until configure.ac is fixed From a495b5a985ca54033cfea6719d4d838c85b9c2aa Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Wed, 7 Aug 2013 19:22:10 +0100 Subject: [PATCH 241/273] Remove SwigPyObject_print and SwigPyObject_str, and make the generated wrapper use the default python implementations, which will fall back to repr (for -builtin option). Advantages: - it avoids the swig user having to jump through hoops to get print to work as expected when redefining repr/str slots. - typing the name of a variable on the python prompt now prints the result of a (possibly redefined) repr, without the swig user having to do any extra work. - when redefining repr, the swig user doesn't necessarily have to redefine str as it will call the redefined repr - the behaviour is exactly the same as without the -builtin option while requiring no extra work by the user (aside from adding the %feature("python:slot...) statements of course) - the patch simplifies pyrun.swg a tiny bit. Disadvantage: - default str() will give different (but clearer?) output on swigged classes compared to unpatched swig SF Bug #326 --- CHANGES.current | 19 +++++++++++++++++++ Lib/python/pyname_compat.i | 2 -- Lib/python/pyrun.swg | 32 ++------------------------------ 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b03e05ffc..cc2ce897d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,6 +4,25 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.11 (in progress) ============================ + +2013-08-07: wsfulton + [Python] SF Patch #326 from Kris Thielemans - Remove SwigPyObject_print and SwigPyObject_str and + make the generated wrapper use the default python implementations, which will fall back to repr + (for -builtin option). + + Advantages: + - it avoids the swig user having to jump through hoops to get print to work as expected when + redefining repr/str slots. + - typing the name of a variable on the python prompt now prints the result of a (possibly redefined) + repr, without the swig user having to do any extra work. + - when redefining repr, the swig user doesn't necessarily have to redefine str as it will call the + redefined repr + - the behaviour is exactly the same as without the -builtin option while requiring no extra work + by the user (aside from adding the %feature("python:slot...) statements of course) + + Disadvantage: + - default str() will give different (but clearer?) output on swigged classes + 2013-07-30: wsfulton [Python, Ruby] Fix #64 #65: Missing code in std::multimap wrappers. Previously an instantiation of a std::map was erroneously required in addition to an instantiation of std::multimap with the diff --git a/Lib/python/pyname_compat.i b/Lib/python/pyname_compat.i index 4026805ba..96af343ca 100644 --- a/Lib/python/pyname_compat.i +++ b/Lib/python/pyname_compat.i @@ -67,10 +67,8 @@ #define PySwigObject_next SwigPyObject_next #define PySwigObject_oct SwigPyObject_oct #define PySwigObject_own SwigPyObject_own -#define PySwigObject_print SwigPyObject_print #define PySwigObject_repr SwigPyObject_repr #define PySwigObject_richcompare SwigPyObject_richcompare -#define PySwigObject_str SwigPyObject_str #define PySwigObject_type SwigPyObject_type #define PySwigPacked SwigPyPacked #define PySwigPacked_Check SwigPyPacked_Check diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index df87bb317..273c82302 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -448,34 +448,6 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args) return repr; } -SWIGRUNTIME int -SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char *str; -#ifdef METH_NOARGS - PyObject *repr = SwigPyObject_repr(v); -#else - PyObject *repr = SwigPyObject_repr(v, NULL); -#endif - if (repr) { - str = SWIG_Python_str_AsChar(repr); - fputs(str, fp); - SWIG_Python_str_DelForPy3(str); - Py_DECREF(repr); - return 0; - } else { - return 1; - } -} - -SWIGRUNTIME PyObject * -SwigPyObject_str(SwigPyObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - SWIG_Python_str_FromChar(result) : 0; -} - SWIGRUNTIME int SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { @@ -761,7 +733,7 @@ SwigPyObject_TypeOnce(void) { sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ - (printfunc)SwigPyObject_print, /* tp_print */ + 0, /* tp_print */ #if PY_VERSION_HEX < 0x02020000 (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ #else @@ -779,7 +751,7 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyObject_str, /* tp_str */ + 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ From b477cb66be5739a0acc2c2de15e988187971ce40 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 24 Aug 2013 08:34:50 +1200 Subject: [PATCH 242/273] Use offsetof() rather than icky homemade equivalent --- Source/Modules/python.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 7ee4ae225..233f79bd6 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3401,7 +3401,7 @@ public: printSlot(f, getSlot(n, "feature:python:tp_dict"), "tp_dict"); printSlot(f, getSlot(n, "feature:python:tp_descr_get"), "tp_descr_get", "descrgetfunc"); printSlot(f, getSlot(n, "feature:python:tp_descr_set"), "tp_descr_set", "descrsetfunc"); - Printf(f, " (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */\n"); + Printf(f, " offsetof(SwigPyObject, dict), /* tp_dictoffset */\n"); printSlot(f, tp_init, "tp_init", "initproc"); printSlot(f, getSlot(n, "feature:python:tp_alloc"), "tp_alloc", "allocfunc"); printSlot(f, "0", "tp_new", "newfunc"); From 628b4710e5309379475f55c95a42e1cf21c9be87 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 24 Aug 2013 08:40:08 +1200 Subject: [PATCH 243/273] [Python] Fix clang++ warning in generated wrapper code. --- CHANGES.current | 3 +++ Source/Modules/python.cxx | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index cc2ce897d..584d5c3a2 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.11 (in progress) ============================ +2013-08-23: olly + [Python] Fix clang++ warning in generated wrapper code. + 2013-08-07: wsfulton [Python] SF Patch #326 from Kris Thielemans - Remove SwigPyObject_print and SwigPyObject_str and make the generated wrapper use the default python implementations, which will fall back to repr diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 233f79bd6..94802e06d 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3401,7 +3401,7 @@ public: printSlot(f, getSlot(n, "feature:python:tp_dict"), "tp_dict"); printSlot(f, getSlot(n, "feature:python:tp_descr_get"), "tp_descr_get", "descrgetfunc"); printSlot(f, getSlot(n, "feature:python:tp_descr_set"), "tp_descr_set", "descrsetfunc"); - Printf(f, " offsetof(SwigPyObject, dict), /* tp_dictoffset */\n"); + Printf(f, " (Py_ssize_t)offsetof(SwigPyObject, dict), /* tp_dictoffset */\n"); printSlot(f, tp_init, "tp_init", "initproc"); printSlot(f, getSlot(n, "feature:python:tp_alloc"), "tp_alloc", "allocfunc"); printSlot(f, "0", "tp_new", "newfunc"); From 1cc735df5e087edc2ac189b39a1ccb12ed304a13 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Aug 2013 08:12:09 +0100 Subject: [PATCH 244/273] %implicitconv will now accept None where the implicit conversion takes a C/C++ pointer. Problem highlighted by Bo Peng on the swig-user mailing list. SF patch #230. --- CHANGES.current | 4 ++ Examples/test-suite/implicittest.i | 25 +++++++++-- .../test-suite/python/implicittest_runme.py | 43 +++++++++++++++++++ Lib/python/pyrun.swg | 12 +++++- 4 files changed, 79 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 584d5c3a2..f87f7ef70 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -8,6 +8,10 @@ Version 2.0.11 (in progress) 2013-08-23: olly [Python] Fix clang++ warning in generated wrapper code. +2013-08-16: wsfulton + [Python] %implicitconv will now accept None where the implicit conversion takes a C/C++ pointer. + Problem highlighted by Bo Peng. Closes SF patch #230. + 2013-08-07: wsfulton [Python] SF Patch #326 from Kris Thielemans - Remove SwigPyObject_print and SwigPyObject_str and make the generated wrapper use the default python implementations, which will fall back to repr diff --git a/Examples/test-suite/implicittest.i b/Examples/test-suite/implicittest.i index e07adc5cc..10f901710 100644 --- a/Examples/test-suite/implicittest.i +++ b/Examples/test-suite/implicittest.i @@ -46,7 +46,6 @@ Foo(double){ ii = 2;} explicit Foo(char *s){ii = 3;} Foo(const Foo& f){ ii = f.ii;} - }; struct Bar @@ -57,11 +56,31 @@ Bar(const Foo& ff){ ii = ff.ii;} }; - int get_b(const Bar&b) { return b.ii; } Foo foo; - } %template(A_int) A_T; + + +/****************** None handling *********************/ + +%inline +{ + struct BB {}; + struct AA + { + int ii; + AA(int i) { ii = 1; } + AA(double d) { ii = 2; } + AA(const B* b) { ii = 3; } + explicit AA(char *s) { ii = 4; } + AA(const BB& b) { ii = 5; } + + int get() const { return ii; } + }; + + int get_AA_val(AA a) { return a.ii; } + int get_AA_ref(const AA& a) { return a.ii; } +} diff --git a/Examples/test-suite/python/implicittest_runme.py b/Examples/test-suite/python/implicittest_runme.py index 4200543c4..5644555df 100644 --- a/Examples/test-suite/python/implicittest_runme.py +++ b/Examples/test-suite/python/implicittest_runme.py @@ -11,6 +11,14 @@ check(1, A(1).get()) check(2, A(1.0).get()) check(3, A(B()).get()) check(4, A("hello").get()) +try: + check(3, A(None).get()) + raise RuntimeError +except ValueError: + # ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &' + # Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value, + # references and pointers to different types, where pointers ought to be given a slightly higher precedence. + pass check(1, get(1)) check(2, get(1.0)) @@ -71,3 +79,38 @@ try: except TypeError: pass +#### Class testing None #### + +# No implicit conversion +check(1, AA(1).get()) +check(2, AA(1.0).get()) +check(3, AA(B()).get()) +check(3, AA(None).get()) +check(4, AA("hello").get()) +check(5, AA(BB()).get()) + +check(1, get_AA_val(1)) +check(2, get_AA_val(1.0)) +check(3, get_AA_val(B())) +check(3, get_AA_val(None)) +check(5, get_AA_val(BB())) + +# Explicit constructor: +try: + check(4, get_AA_val("hello")) + raise RuntimeError +except TypeError: + pass + +check(1, get_AA_ref(1)) +check(2, get_AA_ref(1.0)) +check(3, get_AA_ref(B())) +check(3, get_AA_ref(None)) +check(5, get_AA_ref(BB())) + +# Explicit constructor: +try: + check(4, get_AA_ref("hello")) + raise RuntimeError +except TypeError: + pass diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 273c82302..b077fad32 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1128,10 +1128,11 @@ SWIGRUNTIME int SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { int res; SwigPyObject *sobj; + int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; if (!obj) return SWIG_ERROR; - if (obj == Py_None) { + if (obj == Py_None && !implicit_conv) { if (ptr) *ptr = 0; return SWIG_OK; @@ -1180,7 +1181,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } res = SWIG_OK; } else { - if (flags & SWIG_POINTER_IMPLICIT_CONV) { + if (implicit_conv) { SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; if (data && !data->implicitconv) { PyObject *klass = data->klass; @@ -1215,6 +1216,13 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } } } + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } } return res; } From b58dabced9e7424e6107bfd40963806f3b831a19 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 28 Aug 2013 20:24:54 +0100 Subject: [PATCH 245/273] %implicitconv is improved for overloaded functions. Like in C++, the methods with the actual types are considered before trying implicit conversions. --- CHANGES.current | 20 ++++++ Examples/test-suite/implicittest.i | 30 +++++++++ .../test-suite/python/implicittest_runme.py | 9 +++ Source/Modules/overload.cxx | 63 +++++++++++++++++-- 4 files changed, 117 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f87f7ef70..07a57c42a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,26 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.11 (in progress) ============================ +2013-08-28: wsfulton + [Python] %implicitconv is improved for overloaded functions. Like in C++, the methods + with the actual types are considered before trying implicit conversions. Example: + + %implicitconv A; + struct A { + A(int i); + }; + class CCC { + public: + int xx(int i) { return 11; } + int xx(const A& i) { return 22; } + }; + + The following python code: + + CCC().xx(-1) + + will now return 11 instead of 22 - the implicit conversion is not done. + 2013-08-23: olly [Python] Fix clang++ warning in generated wrapper code. diff --git a/Examples/test-suite/implicittest.i b/Examples/test-suite/implicittest.i index 10f901710..171c6055c 100644 --- a/Examples/test-suite/implicittest.i +++ b/Examples/test-suite/implicittest.i @@ -84,3 +84,33 @@ int get_AA_val(AA a) { return a.ii; } int get_AA_ref(const AA& a) { return a.ii; } } + + +/****************** Overloading priority *********************/ + +%inline %{ +class BBB { + public: + BBB(const B &) {} +}; + +class CCC { + public: + CCC(const BBB &) : checkvalue(0) {} + int xx(int i) { return 11; } + int xx(const A& i) { return 22; } + int yy(int i, int j) { return 111; } + int yy(const A& i, const A& j) { return 222; } + int checkvalue; +}; +%} + +// CCC(const BBB &) was being called instead of this constructor (independent of being added via %extend) +%extend CCC { + CCC(const B& b) { + CCC* ccc = new CCC(b); + ccc->checkvalue = 10; + return ccc; + } +}; + diff --git a/Examples/test-suite/python/implicittest_runme.py b/Examples/test-suite/python/implicittest_runme.py index 5644555df..a9957bc7e 100644 --- a/Examples/test-suite/python/implicittest_runme.py +++ b/Examples/test-suite/python/implicittest_runme.py @@ -114,3 +114,12 @@ try: raise RuntimeError except TypeError: pass + + +### overloading priority test ### + +ccc = CCC(B()) +check(ccc.checkvalue, 10) +check(ccc.xx(123), 11) +check(ccc.yy(123, 123), 111) + diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 0112d2d9e..e95ef557f 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -26,6 +26,7 @@ struct Overloaded { int argc; /* Argument count */ ParmList *parms; /* Parameters used for overload check */ int error; /* Ambiguity error */ + bool implicitconv_function; /* For ordering implicitconv functions*/ }; static int fast_dispatch_mode = 0; @@ -40,6 +41,32 @@ void Wrapper_cast_dispatch_mode_set(int flag) { cast_dispatch_mode = flag; } +/* ----------------------------------------------------------------------------- + * mark_implicitconv_function() + * + * Mark function if it contains an implicitconv type in the parameter list + * ----------------------------------------------------------------------------- */ +static void mark_implicitconv_function(Overloaded& onode) { + Parm *parms = onode.parms; + if (parms) { + bool is_implicitconv_function = false; + Parm *p = parms; + while (p) { + if (checkAttribute(p, "tmap:in:numinputs", "0")) { + p = Getattr(p, "tmap:in:next"); + continue; + } + if (GetFlag(p, "implicitconv")) { + is_implicitconv_function = true; + break; + } + p = nextSibling(p); + } + if (is_implicitconv_function) + onode.implicitconv_function = true; + } +} + /* ----------------------------------------------------------------------------- * Swig_overload_rank() * @@ -85,6 +112,9 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { nodes[nnodes].parms = Getattr(c, "wrap:parms"); nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms); nodes[nnodes].error = 0; + nodes[nnodes].implicitconv_function = false; + + mark_implicitconv_function(nodes[nnodes]); nnodes++; } c = Getattr(c, "sym:nextSibling"); @@ -287,12 +317,30 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { List *result = NewList(); { int i; + int argc_changed_index = -1; for (i = 0; i < nnodes; i++) { if (nodes[i].error) Setattr(nodes[i].n, "overload:ignore", "1"); Append(result, nodes[i].n); - // Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms)); - // Swig_print_node(nodes[i].n); + // Printf(stdout,"[ %d ] %d %s\n", i, nodes[i].implicitconv_function, ParmList_errorstr(nodes[i].parms)); + // Swig_print_node(nodes[i].n); + if (i == nnodes-1 || nodes[i].argc != nodes[i+1].argc) { + if (argc_changed_index+2 < nnodes && (nodes[argc_changed_index+1].argc == nodes[argc_changed_index+2].argc)) { + // Add additional implicitconv functions in same order as already ranked. + // Consider overloaded functions by argument count... only add additional implicitconv functions if + // the number of functions with the same arg count > 1, ie, only if overloaded by same argument count. + int j; + for (j = argc_changed_index + 1; j <= i; j++) { + if (nodes[j].implicitconv_function) { + SetFlag(nodes[j].n, "implicitconvtypecheckoff"); + Append(result, nodes[j].n); + // Printf(stdout,"[ %d ] %d + %s\n", j, nodes[j].implicitconv_function, ParmList_errorstr(nodes[j].parms)); + // Swig_print_node(nodes[j].n); + } + } + } + argc_changed_index = i; + } } } return result; @@ -302,20 +350,22 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { // * print_typecheck() // * ----------------------------------------------------------------------------- */ -static bool print_typecheck(String *f, int j, Parm *pj) { +static bool print_typecheck(String *f, int j, Parm *pj, bool implicitconvtypecheckoff) { char tmp[256]; sprintf(tmp, Char(argv_template_string), j); String *tm = Getattr(pj, "tmap:typecheck"); if (tm) { + tm = Copy(tm); Replaceid(tm, Getattr(pj, "lname"), "_v"); String *conv = Getattr(pj, "implicitconv"); - if (conv) { + if (conv && !implicitconvtypecheckoff) { Replaceall(tm, "$implicitconv", conv); } else { Replaceall(tm, "$implicitconv", "0"); } Replaceall(tm, "$input", tmp); Printv(f, tm, "\n", NIL); + Delete(tm); return true; } else return false; @@ -715,6 +765,7 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar for (i = 0; i < nfunc; i++) { Node *ni = Getitem(dispatch, i); Parm *pi = Getattr(ni, "wrap:parms"); + bool implicitconvtypecheckoff = GetFlag(ni, "implicitconvtypecheckoff") != 0; int num_required = emit_num_required(pi); int num_arguments = emit_num_arguments(pi); if (GetFlag(n, "wrap:this")) { @@ -749,7 +800,7 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar Printf(f, "}\n"); Delete(lfmt); } - if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj)) { + if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj, implicitconvtypecheckoff)) { Printf(f, "if (_v) {\n"); num_braces++; } @@ -773,6 +824,8 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar for ( /* empty */ ; num_braces > 0; num_braces--) Printf(f, "}\n"); Printf(f, "}\n"); /* braces closes "if" for this method */ + if (implicitconvtypecheckoff) + Delattr(ni, "implicitconvtypecheckoff"); } Delete(dispatch); return f; From 6efe3d61f29dc30b9f9782a691cd2d76040385ca Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 29 Aug 2013 11:16:58 +1200 Subject: [PATCH 246/273] Strip trailing whitespace --- configure.ac | 84 ++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/configure.ac b/configure.ac index cc4270ad7..5b6441b86 100644 --- a/configure.ac +++ b/configure.ac @@ -47,7 +47,7 @@ AC_LANG_POP([C++]) dnl Look for popen AC_ARG_WITH(popen, AS_HELP_STRING([--without-popen], [Disable popen]), with_popen="$withval") -if test x"${with_popen}" = xno ; then +if test x"${with_popen}" = xno ; then AC_MSG_NOTICE([Disabling popen]) else AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), AC_MSG_NOTICE([Disabling popen])) @@ -69,7 +69,7 @@ AC_MSG_CHECKING([whether to enable PCRE support]) AC_MSG_RESULT([$with_pcre]) dnl To make configuring easier, check for a locally built PCRE using the Tools/pcre-build.sh script -if test x"${with_pcre}" = xyes ; then +if test x"${with_pcre}" = xyes ; then AC_MSG_CHECKING([whether to use local PCRE]) local_pcre_config=no if test -z $PCRE_CONFIG; then @@ -513,7 +513,7 @@ AC_ARG_WITH(tcllib,[ --with-tcllib=path Set location of Tcl library direct TCLLIB="-L$withval"], [TCLLIB=]) # First, check for "--without-tcl" or "--with-tcl=no". -if test x"${TCLPACKAGE}" = xno -o x"${with_alllang}" = xno; then +if test x"${TCLPACKAGE}" = xno -o x"${with_alllang}" = xno; then AC_MSG_NOTICE([Disabling Tcl]) else AC_MSG_CHECKING([for Tcl configuration]) @@ -606,7 +606,7 @@ case $host in esac case $host in -*-*-darwin*) +*-*-darwin*) TCLLDSHARED='$(CC) -dynamiclib -undefined suppress -flat_namespace' TCLCXXSHARED='$(CXX) -dynamiclib -undefined suppress -flat_namespace' ;; @@ -636,7 +636,7 @@ AC_ARG_WITH(python, AS_HELP_STRING([--without-python], [Disable Python]) AS_HELP_STRING([--with-python=path], [Set location of Python executable]),[ PYBIN="$withval"], [PYBIN=yes]) # First, check for "--without-python" or "--with-python=no". -if test x"${PYBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${PYBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Python]) else # First figure out the name of the Python executable @@ -671,10 +671,10 @@ else PYLIBDIR=`($PYTHON -c "import sys; print sys.lib") 2>/dev/null` if test -z "$PYLIBDIR"; then # Fedora patch Python to add sys.lib, for other distros we assume "lib". - PYLIBDIR="lib" + PYLIBDIR="lib" fi AC_MSG_RESULT($PYLIBDIR) - + # Set the include directory AC_MSG_CHECKING(for Python header files) @@ -737,7 +737,7 @@ AC_ARG_WITH(python3, AS_HELP_STRING([--without-python3], [Disable Python 3.x sup AS_HELP_STRING([--with-python3=path], [Set location of Python 3.x executable]),[ PY3BIN="$withval"], [PY3BIN=yes]) # First, check for "--without-python3" or "--with-python3=no". -if test x"${PY3BIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${PY3BIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Python 3.x support]) else for py_ver in 3 3.6 3.5 3.4 3.3 3.2 3.1 3.0; do @@ -760,7 +760,7 @@ else # Note: I could not think of a standard way to get the version string from different versions. # This trick pulls it out of the file location for a standard library file. - + AC_MSG_CHECKING([for Python 3.x version]) # Need to do this hack since autoconf replaces __file__ with the name of the configure file @@ -774,10 +774,10 @@ else PY3LIBDIR=`($PYTHON3 -c "import sys; print(sys.lib)") 2>/dev/null` if test -z "$PY3LIBDIR"; then # some dists don't have sys.lib so the best we can do is assume lib - PY3LIBDIR="lib" + PY3LIBDIR="lib" fi AC_MSG_RESULT($PY3LIBDIR) - + # Set the include directory AC_MSG_CHECKING([for Python 3.x header files]) @@ -828,7 +828,7 @@ AC_ARG_WITH(perl5, AS_HELP_STRING([--without-perl5], [Disable Perl5]) AS_HELP_STRING([--with-perl5=path], [Set location of Perl5 executable]),[ PERLBIN="$withval"], [PERLBIN=yes]) # First, check for "--without-perl5" or "--with-perl5=no". -if test x"${PERLBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${PERLBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Perl5]) PERL= else @@ -932,7 +932,7 @@ AC_ARG_WITH(octave, AS_HELP_STRING([--without-octave], [Disable Octave]) AS_HELP_STRING([--with-octave=path], [Set location of Octave executable]),[OCTAVEBIN="$withval"], [OCTAVEBIN=yes]) # First, check for "--without-octave" or "--with-octave=no". -if test x"${OCTAVEBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${OCTAVEBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Octave]) OCTAVE= @@ -1000,7 +1000,7 @@ AS_HELP_STRING([--with-java=path], [Set location of java executable]),[JAVABIN=" AC_ARG_WITH(javac, [ --with-javac=path Set location of javac executable],[JAVACBIN="$withval"], [JAVACBIN=]) # First, check for "--without-java" or "--with-java=no". -if test x"${JAVABIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${JAVABIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Java]) JAVA= else @@ -1066,7 +1066,7 @@ case $host in JAVADYNAMICLINKING="" JAVACFLAGS="" fi ;; -*-*-darwin*) +*-*-darwin*) JAVADYNAMICLINKING="-dynamiclib -framework JavaVM" JAVACFLAGS="" ;; @@ -1084,7 +1084,7 @@ esac # Java on Mac OS X tweaks case $host in -*-*-darwin*) +*-*-darwin*) JAVASO=".jnilib" JAVALDSHARED='$(CC)' JAVACXXSHARED='$(CXX)' @@ -1116,7 +1116,7 @@ AS_HELP_STRING([--with-gcj=path], [Set location of gcj executable]),[GCJBIN="$wi AC_ARG_WITH(gcjh, [ --with-gcjh=path Set location of gcjh executable],[GCJHBIN="$withval"], [GCJHBIN=]) # First, check for "--without-gcj" or "--with-gcj=no". -if test x"${GCJBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${GCJBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling GCJ]) else if test "x$GCJBIN" = xyes; then @@ -1146,7 +1146,7 @@ AC_ARG_WITH(ant, [ --with-ant=path Set location of ant executable for And AC_ARG_WITH(ndk-build, [ --with-ndk-build=path Set location of Android ndk-build executable],[NDKBUILDBIN="$withval"], [NDKBUILDBIN=]) # First, check for "--without-android" or "--with-android=no". -if test x"${ANDROIDBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${ANDROIDBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Android]) ANDROID= else @@ -1198,7 +1198,7 @@ AC_ARG_WITH(guile-libs,[ --with-guile-libs=ldflags Set ldflags needed to lin GUILE_LIBS="$withval"]) # First, check for "--without-guile" or "--with-guile=no". -if test x"${GUILE}" = xno -o x"${with_alllang}" = xno ; then +if test x"${GUILE}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Guile]) else if test -z "$GUILE_CONFIG" ; then @@ -1255,7 +1255,7 @@ AS_HELP_STRING([--with-mzscheme=path], [Set location of MzScheme executable]),[ AC_ARG_WITH(mzc, AS_HELP_STRING([--with-mzc=path], [Set location of MzScheme's mzc]), [ MZCBIN="$withval"], [MZCBIN=]) # First, check for "--without-mzscheme" or "--with-mzscheme=no". -if test x"${MZSCHEMEBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${MZSCHEMEBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling MzScheme]) MZC= else @@ -1264,13 +1264,13 @@ else else MZSCHEME="$MZSCHEMEBIN" fi - + if test -z "$MZCBIN"; then AC_PATH_PROG(MZC, mzc) fi if test -n "$MZSCHEME"; then - AC_MSG_CHECKING(for MzScheme dynext object) + AC_MSG_CHECKING(for MzScheme dynext object) MZDYNOBJ=`$MZSCHEME --eval '(begin (require dynext/link) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (printf "~a" x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` if test -f "$MZDYNOBJ"; then : @@ -1298,7 +1298,7 @@ AC_ARG_WITH(ruby, AS_HELP_STRING([--without-ruby], [Disable Ruby]) AS_HELP_STRING([--with-ruby=path], [Set location of Ruby executable]),[ RUBYBIN="$withval"], [RUBYBIN=yes]) # First, check for "--without-ruby" or "--with-ruby=no". -if test x"${RUBYBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${RUBYBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Ruby]) RUBY= else @@ -1357,10 +1357,10 @@ if test -n "$RUBY"; then else # 1.6.x link = "-l" + c[["RUBY_INSTALL_NAME"]] end - + # Get the target Ruby was built for target = c[["target"]] - + if target == "i386-pc-mswin32" # Need to change msvcrt-ruby*.lib to -lmsvcrt-ruby* ext = File.extname(link) @@ -1428,7 +1428,7 @@ AC_ARG_WITH(php, AS_HELP_STRING([--without-php], [Disable PHP]) AS_HELP_STRING([--with-php=path], [Set location of PHP executable]),[ PHPBIN="$withval"], [PHPBIN=yes]) # First, check for "--without-php" or "--with-php=no". -if test x"${PHPBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${PHPBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling PHP]) PHP= else @@ -1449,7 +1449,7 @@ else esac php_version=`$PHPCONFIG --version 2>/dev/null` case $php_version in - 5*) + 5*) PHPINC=`$PHPCONFIG --includes 2>/dev/null` if test -n "$PHPINC"; then AC_MSG_RESULT($PHPINC) @@ -1476,7 +1476,7 @@ AC_ARG_WITH(ocamlfind,[ --with-ocamlfind=path Set location of ocamlfind],[OCA AC_ARG_WITH(ocamlmktop,[ --with-ocamlmktop=path Set location of ocamlmktop executable],[ OCAMLMKTOP="$withval"], [OCAMLMKTOP=]) # First, check for "--without-ocaml" or "--with-ocaml=no". -if test x"${OCAMLBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${OCAMLBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling OCaml]) OCAMLBIN= else @@ -1562,7 +1562,7 @@ AC_ARG_WITH(pike, AS_HELP_STRING([--without-pike], [Disable Pike]) AS_HELP_STRING([--with-pike=path], [Set location of Pike executable]),[PIKEBIN="$withval"], [PIKEBIN=yes]) # First, check for "--without-pike" or "--with-pike=no". -if test x"${PIKEBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${PIKEBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Pike]) PIKEBIN= else @@ -1576,7 +1576,7 @@ fi # Check for pike-config # Priority: configure option, guessed from $PIKE, search from list -AC_ARG_WITH(pike-config, AS_HELP_STRING([--with-pike-config=path], +AC_ARG_WITH(pike-config, AS_HELP_STRING([--with-pike-config=path], [Set location of pike-config script]), [PIKECONFIG="$withval"], [PIKECONFIG=""]) @@ -1587,7 +1587,7 @@ fi # Check for a --with-pikeincl option to configure # Priority: configure option, info from $PIKECONFIG, guessed by pike script -AC_ARG_WITH(pikeincl, AS_HELP_STRING([--with-pikeincl=path], +AC_ARG_WITH(pikeincl, AS_HELP_STRING([--with-pikeincl=path], [Set location of Pike include directory]), [PIKEINCLUDE="-I$withval"], [PIKEINCLUDE=]) @@ -1632,7 +1632,7 @@ AC_ARG_WITH(chicken, AS_HELP_STRING([--without-chicken], [Disable CHICKEN]) AS_HELP_STRING([--with-chicken=path], [Set location of CHICKEN executable]),[ CHICKENBIN="$withval"], [CHICKENBIN=yes]) # First, check for "--without-chicken" or "--with-chicken=no". -if test x"${CHICKENBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${CHICKENBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling CHICKEN]) else @@ -1728,7 +1728,7 @@ AC_ARG_WITH(cil-interpreter, [ --with-cil-interpreter=path Set location of AC_ARG_WITH(csharp-compiler, [ --with-csharp-compiler=path Set location of CSharp compiler],[CSHARPCOMPILERBIN="$withval"], [CSHARPCOMPILERBIN=]) # First, check for "--without-csharp" or "--with-csharp=no". -if test x"${with_csharp}" = xno -o x"${with_alllang}" = xno ; then +if test x"${with_csharp}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling CSharp]) CSHARPCOMPILER= else @@ -1781,7 +1781,7 @@ if test -z "$CSHARPBIN" ; then if test "mcs" = "$CSHARPCOMPILER" || test "gmcs" = "$CSHARPCOMPILER"; then AC_CHECK_PROGS(CSHARPCILINTERPRETER, mono) # Mono JIT CSHARPCILINTERPRETER_FLAGS="--debug" - else + else if test "csc" = "$CSHARPCOMPILER"; then CSHARPPATHSEPARATOR="\\\\" CSHARPCYGPATH_W='cygpath -w' @@ -1856,7 +1856,7 @@ AC_ARG_WITH(lualib,[ --with-lualib=path Set location of Lua library direct LUALIB="$withval"], [LUALIB=]) # First, check for "--without-lua" or "--with-lua=no". -if test x"${LUABIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${LUABIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Lua]) else @@ -1897,8 +1897,8 @@ if test "$LUABIN"; then else LUADYNAMICLOADLIB=`$LUABIN -e '_,_,c=package.loadlib("no_such_lib","") if c~="absent" then print "1" end'` fi - - if test -z "$LUADYNAMICLOADLIB"; then + + if test -z "$LUADYNAMICLOADLIB"; then AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) @@ -1938,7 +1938,7 @@ fi # look for the library files & set LUALINK accordingly # will clear LUABIN if not present lua_save_LIBS=$LIBS # the code seems to disrupt LIBS, so saving - + if test -n "$LUALIB"; then AC_CHECK_FILE($LUALIB/liblua.a,[LUALINK="-L$LUALIB -llua"],[LUABIN=]) else @@ -1969,7 +1969,7 @@ AC_ARG_WITH(allegrocl, AS_HELP_STRING([--without-allegrocl], [Disable Allegro CL AS_HELP_STRING([--with-allegrocl=path], [Set location of Allegro CL executable (alisp)]),[ ALLEGROCLBIN="$withval"], [ALLEGROCLBIN=yes]) # First, check for "--without-allegrocl" or "--with-allegrocl=no". -if test x"${ALLEGROCLBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${ALLEGROCLBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Allegro CL]) ALLEGROCLBIN= else @@ -1992,7 +1992,7 @@ AC_ARG_WITH(clisp, AS_HELP_STRING([--without-clisp], [Disable CLISP]) AS_HELP_STRING([--with-clisp=path], [Set location of CLISP executable (clisp)]),[ CLISPBIN="$withval"], [CLISPBIN=yes]) # First, check for "--without-clisp" or "--with-clisp=no". -if test x"${CLISPBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${CLISPBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling CLISP]) CLISPBIN= else @@ -2015,7 +2015,7 @@ AC_ARG_WITH(r, AS_HELP_STRING([--without-r], [Disable R]) AS_HELP_STRING([--with-r=path], [Set location of R executable (r)]),[ RBIN="$withval"], [RBIN=yes]) # First, check for "--without-r" or "--with-r=no". -if test x"${RBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${RBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling R]) RBIN= else @@ -2035,7 +2035,7 @@ AC_SUBST(RBIN) AC_ARG_WITH(go, AS_HELP_STRING([--without-go], [Disable Go]) AS_HELP_STRING([--with-go=path], [Set location of Go compiler]),[GOBIN="$withval"], [GOBIN=yes]) -if test x"${GOBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${GOBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Go]) GO= GOC= From 9efaf954c71118d41ba9bf43ed371bbe83093564 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 16 Aug 2013 23:34:24 +0200 Subject: [PATCH 247/273] Add support for std::map<> comparator template argument for C#. Allow exporting maps using non-default comparison function. Closes #77 --- CHANGES.current | 3 +++ Lib/csharp/std_map.i | 36 ++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 07a57c42a..dfbe651f0 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.11 (in progress) ============================ +2013-08-29: wsfulton + [C#] Pull Git patch #77: Allow exporting std::map using non-default comparison function. + 2013-08-28: wsfulton [Python] %implicitconv is improved for overloaded functions. Like in C++, the methods with the actual types are considered before trying implicit conversions. Example: diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index 6a7da16b6..acd190689 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- * std_map.i * - * SWIG typemaps for std::map< K, T > + * SWIG typemaps for std::map< K, T, C > * * The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>. * @@ -26,10 +26,10 @@ %} /* K is the C++ key type, T is the C++ value type */ -%define SWIG_STD_MAP_INTERNAL(K, T) +%define SWIG_STD_MAP_INTERNAL(K, T, C) -%typemap(csinterfaces) std::map< K, T > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\n"; -%typemap(cscode) std::map %{ +%typemap(csinterfaces) std::map< K, T, C > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\n"; +%typemap(cscode) std::map %{ public $typemap(cstype, T) this[$typemap(cstype, K) key] { get { @@ -221,14 +221,14 @@ typedef T mapped_type; map(); - map(const map< K, T > &other); + map(const map< K, T, C > &other); size_type size() const; bool empty() const; %rename(Clear) clear; void clear(); %extend { const mapped_type& getitem(const key_type& key) throw (std::out_of_range) { - std::map< K,T >::iterator iter = $self->find(key); + std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) return iter->second; else @@ -240,19 +240,19 @@ } bool ContainsKey(const key_type& key) { - std::map< K, T >::iterator iter = $self->find(key); + std::map< K, T, C >::iterator iter = $self->find(key); return iter != $self->end(); } void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) { - std::map< K, T >::iterator iter = $self->find(key); + std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) throw std::out_of_range("key already exists"); $self->insert(std::pair< K, T >(key, val)); } bool Remove(const key_type& key) { - std::map< K, T >::iterator iter = $self->find(key); + std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) { $self->erase(iter); return true; @@ -261,20 +261,20 @@ } // create_iterator_begin(), get_next_key() and destroy_iterator work together to provide a collection of keys to C# - %apply void *VOID_INT_PTR { std::map< K, T >::iterator *create_iterator_begin } - %apply void *VOID_INT_PTR { std::map< K, T >::iterator *swigiterator } + %apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *create_iterator_begin } + %apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *swigiterator } - std::map< K, T >::iterator *create_iterator_begin() { - return new std::map< K, T >::iterator($self->begin()); + std::map< K, T, C >::iterator *create_iterator_begin() { + return new std::map< K, T, C >::iterator($self->begin()); } - const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) { - std::map< K, T >::iterator iter = *swigiterator; + const key_type& get_next_key(std::map< K, T, C >::iterator *swigiterator) { + std::map< K, T, C >::iterator iter = *swigiterator; (*swigiterator)++; return (*iter).first; } - void destroy_iterator(std::map< K, T >::iterator *swigiterator) { + void destroy_iterator(std::map< K, T, C >::iterator *swigiterator) { delete swigiterator; } } @@ -291,8 +291,8 @@ // Default implementation namespace std { - template class map { - SWIG_STD_MAP_INTERNAL(K, T) + template > class map { + SWIG_STD_MAP_INTERNAL(K, T, C) }; } From f55ff50dd5bf050e1e0b25410b7aa912ea3842f3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 29 Aug 2013 19:19:52 +0100 Subject: [PATCH 248/273] Skip the UTF-8 BOM of including files. For avoiding illegal token error when parsing include files which have the UTF-8 BOM. Closes #75. --- CHANGES.current | 4 ++++ Examples/test-suite/bom_utf8.i | 9 +++++++++ Examples/test-suite/common.mk | 3 ++- Source/Swig/include.c | 11 ++++++++++- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/bom_utf8.i diff --git a/CHANGES.current b/CHANGES.current index dfbe651f0..0a8d722ff 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.11 (in progress) ============================ +2013-08-29: wsfulton + Pull Git patch #75: Handle UTF-8 files with BOM at beginning of file. Was giving an + 'Illegal token' syntax error. + 2013-08-29: wsfulton [C#] Pull Git patch #77: Allow exporting std::map using non-default comparison function. diff --git a/Examples/test-suite/bom_utf8.i b/Examples/test-suite/bom_utf8.i new file mode 100644 index 000000000..010774937 --- /dev/null +++ b/Examples/test-suite/bom_utf8.i @@ -0,0 +1,9 @@ +%module bom_utf8 + +/* Test for UTF8 BOM at start of file */ +%inline %{ +struct NotALotHere { + int n; +}; +%} + diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 9a335b46e..b1e5fc3b8 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -552,7 +552,8 @@ C_TEST_CASES += \ typedef_struct \ typemap_subst \ union_parameter \ - unions + unions \ + utf8_bom # Multi-module C++ test cases . (Can be run individually using make testcase.multicpptest) diff --git a/Source/Swig/include.c b/Source/Swig/include.c index 13afb21ae..7e80172ba 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -163,7 +163,8 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_ String *filename; List *spath = 0; char *cname; - int i, ilen; + int i, ilen, nbytes; + char bom[3]; if (!directories) directories = NewList(); @@ -191,6 +192,14 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_ if (f) { Delete(lastpath); lastpath = filename; + + /* Skip the UTF-8 BOM if it's present */ + nbytes = fread(bom, 1, 3, f); + if (nbytes == 3 && bom[0] == (char)0xEF && bom[1] == (char)0xBB && bom[2] == (char)0xBF) { + /* skip */ + } else { + fseek(f, 0, SEEK_SET); + } } return f; } From ada7dd92e460aa470b90b035c295913b82863f6c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 29 Aug 2013 22:49:59 +0100 Subject: [PATCH 249/273] Fix testcase name --- Examples/test-suite/common.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index b1e5fc3b8..5d6a4730a 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -509,6 +509,7 @@ endif # C test cases. (Can be run individually using: make testcase.ctest) C_TEST_CASES += \ arrays \ + bom_utf8 \ char_constant \ const_const \ constant_expr \ @@ -552,8 +553,7 @@ C_TEST_CASES += \ typedef_struct \ typemap_subst \ union_parameter \ - unions \ - utf8_bom + unions # Multi-module C++ test cases . (Can be run individually using make testcase.multicpptest) From 663c41e24861ebdc14563b2c1e77d1329d11225a Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 29 Aug 2013 20:01:13 +0900 Subject: [PATCH 250/273] Add Lua runtime helper functions for error-handling Add two helper functions to the Lua runtime, "SWIG_Lua_pusherrstring" and "SWIG_Lua_pushferrstring". These are like the standard Lua functions lua_pushstring and lua_pushfstring respectively, except that the strings are prefixed with the location of the innermost Lua call-point (as generated by luaL_where). --- Lib/lua/luarun.swg | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index e4f39e07f..dea8dd7a0 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -71,6 +71,36 @@ extern "C" { #endif +/* -------------------------------------------------------------------------- + * Helper functions for error handling + * -------------------------------------------------------------------------- */ + +/* Push the string STR on the Lua stack, like lua_pushstring, but + prefixed with the the location of the innermost Lua call-point + (as formated by luaL_where). */ +SWIGRUNTIME void +SWIG_Lua_pusherrstring (lua_State *L, const char *str) +{ + luaL_where (L, 1); + lua_pushstring (L, str); + lua_concat (L, 2); +} + +/* Push a formatted string generated from FMT and following args on + the Lua stack, like lua_pushfstring, but prefixed with the the + location of the innermost Lua call-point (as formated by luaL_where). */ +SWIGRUNTIME void +SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...) +{ + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); +} + + /* ----------------------------------------------------------------------------- * global swig types * ----------------------------------------------------------------------------- */ From c746ae7a0fcae2e5a317c6fd8a2e44603ec24178 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 29 Aug 2013 20:07:24 +0900 Subject: [PATCH 251/273] Include Lua error locus in SWIG error messages This is standard information in Lua error messages, and makes it much easier to find bugs. --- Lib/lua/luarun.swg | 15 +++++++-------- Lib/lua/typemaps.i | 20 ++++++++++---------- Lib/lua/wchar.i | 2 +- Source/Modules/lua.cxx | 2 +- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index dea8dd7a0..c705e38e5 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -185,19 +185,20 @@ typedef struct { /* Contract support */ #define SWIG_contract_assert(expr, msg) \ - if (!(expr)) { lua_pushstring(L, (char *) msg); goto fail; } else + if (!(expr)) { SWIG_Lua_pusherrstring(L, (char *) msg); goto fail; } else + /* helper #defines */ #define SWIG_fail {goto fail;} #define SWIG_fail_arg(func_name,argnum,type) \ - {lua_pushfstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\ + {SWIG_Lua_pushferrstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\ func_name,argnum,type,SWIG_Lua_typename(L,argnum));\ goto fail;} #define SWIG_fail_ptr(func_name,argnum,type) \ SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*") #define SWIG_check_num_args(func_name,a,b) \ if (lua_gettop(L)b) \ - {lua_pushfstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\ + {SWIG_Lua_pushferrstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\ goto fail;} @@ -250,8 +251,7 @@ SWIGINTERN int SWIG_Lua_set_immutable(lua_State* L) /* there should be 1 param passed in: the new value */ #ifndef SWIGLUA_IGNORE_SET_IMMUTABLE lua_pop(L,1); /* remove it */ - lua_pushstring(L,"This variable is immutable"); - lua_error(L); + luaL_error(L,"This variable is immutable"); #endif return 0; /* should not return anything */ } @@ -786,9 +786,8 @@ SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State* L,int index,swig_type_info *typ int argnum,const char* func_name){ void* result; if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){ - lua_pushfstring(L,"Error in %s, expected a %s at argument number %d\n", - func_name,(type && type->str)?type->str:"void*",argnum); - lua_error(L); + luaL_error (L,"Error in %s, expected a %s at argument number %d\n", + func_name,(type && type->str)?type->str:"void*",argnum); } return result; } diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i index a7ecec528..7a095a1e0 100644 --- a/Lib/lua/typemaps.i +++ b/Lib/lua/typemaps.i @@ -250,12 +250,12 @@ SWIGINTERN int SWIG_table_size(lua_State* L, int index) SWIGINTERN TYPE* SWIG_get_##NAME##_num_array_fixed(lua_State* L, int index, int size){\ TYPE *array;\ if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {\ - lua_pushfstring(L,"expected a table of size %d",size);\ + SWIG_Lua_pushferrstring(L,"expected a table of size %d",size);\ return 0;\ }\ array=SWIG_ALLOC_ARRAY(TYPE,size);\ if (!SWIG_read_##NAME##_num_array(L,index,array,size)){\ - lua_pushstring(L,"table must contain numbers");\ + SWIG_Lua_pusherrstring(L,"table must contain numbers");\ SWIG_FREE_ARRAY(array);\ return 0;\ }\ @@ -265,17 +265,17 @@ SWIGINTERN int SWIG_table_size(lua_State* L, int index) {\ TYPE *array;\ if (!lua_istable(L,index)) {\ - lua_pushstring(L,"expected a table");\ + SWIG_Lua_pusherrstring(L,"expected a table");\ return 0;\ }\ *size=SWIG_itable_size(L,index);\ if (*size<1){\ - lua_pushstring(L,"table appears to be empty");\ + SWIG_Lua_pusherrstring(L,"table appears to be empty");\ return 0;\ }\ array=SWIG_ALLOC_ARRAY(TYPE,*size);\ if (!SWIG_read_##NAME##_num_array(L,index,array,*size)){\ - lua_pushstring(L,"table must contain numbers");\ + SWIG_Lua_pusherrstring(L,"table must contain numbers");\ SWIG_FREE_ARRAY(array);\ return 0;\ }\ @@ -451,12 +451,12 @@ SWIGINTERN int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size, SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type){ void **array; if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) { - lua_pushfstring(L,"expected a table of size %d",size); + SWIG_Lua_pushferrstring(L,"expected a table of size %d",size); return 0; } array=SWIG_ALLOC_ARRAY(void*,size); if (!SWIG_read_ptr_array(L,index,array,size,type)){ - lua_pushfstring(L,"table must contain pointers of type %s",type->name); + SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name); SWIG_FREE_ARRAY(array); return 0; } @@ -465,17 +465,17 @@ SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swi SWIGINTERN void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type){ void **array; if (!lua_istable(L,index)) { - lua_pushstring(L,"expected a table"); + SWIG_Lua_pusherrstring(L,"expected a table"); return 0; } *size=SWIG_itable_size(L,index); if (*size<1){ - lua_pushstring(L,"table appears to be empty"); + SWIG_Lua_pusherrstring(L,"table appears to be empty"); return 0; } array=SWIG_ALLOC_ARRAY(void*,*size); if (!SWIG_read_ptr_array(L,index,array,*size,type)){ - lua_pushfstring(L,"table must contain pointers of type %s",type->name); + SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name); SWIG_FREE_ARRAY(array); return 0; } diff --git a/Lib/lua/wchar.i b/Lib/lua/wchar.i index 14a94257f..141ecc41f 100644 --- a/Lib/lua/wchar.i +++ b/Lib/lua/wchar.i @@ -31,7 +31,7 @@ wchar_t* str2wstr(const char *str, int len) %typemap(in, checkfn="SWIG_lua_isnilstring", fragment="SWIG_lua_isnilstring") wchar_t * %{ $1 = str2wstr(lua_tostring( L, $input ),lua_rawlen( L, $input )); -if ($1==0) {lua_pushfstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;} +if ($1==0) {SWIG_Lua_pushferrstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;} %} %typemap(freearg) wchar_t * diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index a33898a2f..cff3107db 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -811,7 +811,7 @@ public: Printf(protoTypes, "\n\" %s\\n\"", fulldecl); Delete(fulldecl); } while ((sibl = Getattr(sibl, "sym:nextSibling"))); - Printf(f->code, "lua_pushstring(L,\"Wrong arguments for overloaded function '%s'\\n\"\n" + Printf(f->code, "SWIG_Lua_pusherrstring(L,\"Wrong arguments for overloaded function '%s'\\n\"\n" "\" Possible C/C++ prototypes are:\\n\"%s);\n",symname,protoTypes); Delete(protoTypes); From 4492a3d76bddaee5b05dea31a0d281868f5581f7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 30 Aug 2013 07:05:54 +0100 Subject: [PATCH 252/273] Document Include Lua error locus in SWIG error messages patches. Closes #81 --- CHANGES.current | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 0a8d722ff..ffb805ccd 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.11 (in progress) ============================ +2013-08-30: wsfulton + [Lua] Pull Git patch #81: Include Lua error locus in SWIG error messages. + This is standard information in Lua error messages, and makes it much + easier to find bugs. + 2013-08-29: wsfulton Pull Git patch #75: Handle UTF-8 files with BOM at beginning of file. Was giving an 'Illegal token' syntax error. From 67659773ccfd927ca86b35c31c7bb338532c2729 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 2 Sep 2013 19:14:20 +0100 Subject: [PATCH 253/273] Remove some Java references from C# module --- Source/Modules/csharp.cxx | 6 +++--- Source/Modules/java.cxx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 44db84264..d30f278fc 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -4028,7 +4028,7 @@ public: Delete(director_ctor_code); director_ctor_code = NewString("$director_new"); - Java_director_declaration(n); + directorDeclaration(n); Printf(f_directors_h, "%s {\n", Getattr(n, "director:decl")); Printf(f_directors_h, "\npublic:\n"); @@ -4148,13 +4148,13 @@ public: } /*---------------------------------------------------------------------- - * Java_director_declaration() + * directorDeclaration() * * Generate the director class's declaration * e.g. "class SwigDirector_myclass : public myclass, public Swig::Director {" *--------------------------------------------------------------------*/ - void Java_director_declaration(Node *n) { + void directorDeclaration(Node *n) { String *base = Getattr(n, "classtype"); String *class_ctor = NewString("Swig::Director()"); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index b99bbb4ee..24435ac30 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -4221,7 +4221,7 @@ public: Delete(director_ctor_code); director_ctor_code = NewString("$director_new"); - Java_director_declaration(n); + directorDeclaration(n); Printf(f_directors_h, "%s {\n", Getattr(n, "director:decl")); Printf(f_directors_h, "\npublic:\n"); @@ -4405,13 +4405,13 @@ public: } /*---------------------------------------------------------------------- - * Java_director_declaration() + * directorDeclaration() * * Generate the director class's declaration * e.g. "class SwigDirector_myclass : public myclass, public Swig::Director {" *--------------------------------------------------------------------*/ - void Java_director_declaration(Node *n) { + void directorDeclaration(Node *n) { String *base = Getattr(n, "classtype"); String *class_ctor = NewString("Swig::Director(jenv)"); From f47075ec991716733d7e3588aea5e58673c004ff Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 3 Sep 2013 23:58:05 +0100 Subject: [PATCH 254/273] Smart pointer documentation improvement --- Doc/Manual/SWIGPlus.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 716882f53..2713725d7 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -4433,7 +4433,7 @@ around some other class. For example: template<class T> class SmartPtr { T *pointee; public: - ... + SmartPtr(T *p) : pointee(p) { ... } T *operator->() { return pointee; } @@ -4453,7 +4453,7 @@ typedef SmartPtr<Foo_Impl> Foo; // Create smart pointer Foo Foo make_Foo() { - return SmartPtr(new Foo_Impl()); + return SmartPtr<Foo_Impl>(new Foo_Impl()); } // Do something with smart pointer Foo @@ -4461,6 +4461,9 @@ void do_something(Foo f) { printf("x = %d\n", f->x); f->bar(); } + +// Call the wrapped smart pointer proxy class in the target language 'Foo' +%template(Foo) SmartPtr<Foo_Impl>; From a91cd0bc5c1550bfa2c922c7434323c30ca1fb87 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 12 Sep 2013 07:23:54 +0100 Subject: [PATCH 255/273] Infinity is now by default an acceptable value for type 'float'. This fix makes the handling of type 'float' and 'double' the same. The implementation requires the C99 isfinite() macro, or otherwise some platform dependent equivalents, to be available. --- CHANGES.current | 16 ++++++ Examples/test-suite/common.mk | 3 +- Examples/test-suite/overload_numeric.i | 51 +++++++++++++++++++ .../python/overload_numeric_runme.py | 43 ++++++++++++++++ Lib/typemaps/fragments.swg | 32 +++++++++++- Lib/typemaps/primtypes.swg | 2 +- 6 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 Examples/test-suite/overload_numeric.i create mode 100644 Examples/test-suite/python/overload_numeric_runme.py diff --git a/CHANGES.current b/CHANGES.current index ffb805ccd..77d2df753 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,22 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.11 (in progress) ============================ +2013-09-12: wsfulton + [UTL] Infinity is now by default an acceptable value for type 'float'. This fix makes + the handling of type 'float' and 'double' the same. The implementation requires the + C99 isfinite() macro, or otherwise some platform dependent equivalents, to be available. + + Users requiring the old behaviour of not accepting infinity, can define a 'check' typemap + wherever a float is used, such as: + + %typemap(check,fragment="") float, const float & %{ + if ($1 < -FLT_MAX || $1 > FLT_MAX) { + SWIG_exception_fail(SWIG_TypeError, "Overflow in type float"); + } + %} + + *** POTENTIAL INCOMPATIBILITY *** + 2013-08-30: wsfulton [Lua] Pull Git patch #81: Include Lua error locus in SWIG error messages. This is standard information in Lua error messages, and makes it much diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 5d6a4730a..997f8e715 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -285,8 +285,9 @@ CPP_TEST_CASES += \ operbool \ ordering \ overload_copy \ - overload_method \ overload_extend \ + overload_method \ + overload_numeric \ overload_rename \ overload_return_type \ overload_simple \ diff --git a/Examples/test-suite/overload_numeric.i b/Examples/test-suite/overload_numeric.i new file mode 100644 index 000000000..44c3b811c --- /dev/null +++ b/Examples/test-suite/overload_numeric.i @@ -0,0 +1,51 @@ +%module overload_numeric + +// Tests overloading of integral and floating point types to verify the range checking required +// for dispatch to the correct overloaded method + +#ifdef SWIGLUA +// lua only has one numeric type, so most of the overloads shadow each other creating warnings +%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Nums::over; +#endif + +%{ +#include +%} + +%inline %{ +#include +#include +struct Limits { + signed char schar_min() { return SCHAR_MIN; } + signed char schar_max() { return SCHAR_MAX; } + short shrt_min() { return SHRT_MIN; } + short shrt_max() { return SHRT_MAX; } + int int_min() { return INT_MIN; } + int int_max() { return INT_MAX; } + float flt_min() { return FLT_MIN; } + float flt_max() { return FLT_MAX; } + double dbl_max() { return DBL_MAX; } +}; + +struct Nums { + const char * over(signed char v) { + return "signed char"; + } + const char * over(short v) { + return "short"; + } + const char * over(int v) { + return "int"; + } + const char * over(float v) { + return "float"; + } + const char * over(double v) { + return "double"; + } + double doublebounce(double v) { + return v; + } +}; +%} + diff --git a/Examples/test-suite/python/overload_numeric_runme.py b/Examples/test-suite/python/overload_numeric_runme.py new file mode 100644 index 000000000..639fb5e5d --- /dev/null +++ b/Examples/test-suite/python/overload_numeric_runme.py @@ -0,0 +1,43 @@ + +from overload_numeric import * +import math + +nums = Nums() +limits = Limits() + +def check(got, expected): + if got != expected: + raise RuntimeError("got: " + got + " expected: " + expected) + +check(nums.over(0), "signed char") +check(nums.over(0.0), "float") + +check(nums.over(limits.schar_min()), "signed char") +check(nums.over(limits.schar_max()), "signed char") + +check(nums.over(limits.schar_min()-1), "short") +check(nums.over(limits.schar_max()+1), "short") +check(nums.over(limits.shrt_min()), "short") +check(nums.over(limits.shrt_max()), "short") + +check(nums.over(limits.shrt_min()-1), "int") +check(nums.over(limits.shrt_max()+1), "int") +check(nums.over(limits.int_min()), "int") +check(nums.over(limits.int_max()), "int") + +check(nums.over(limits.flt_min()), "float") +check(nums.over(limits.flt_max()), "float") + +check(nums.over(limits.flt_max()*10), "double") +check(nums.over(-limits.flt_max()*10), "double") +check(nums.over(limits.dbl_max()), "double") +check(nums.over(-limits.dbl_max()), "double") + +check(nums.over(float("inf")), "float") +check(nums.over(float("-inf")), "float") +check(nums.over(float("nan")), "float") + +# Just check if the following are accepted without exceptions being thrown +nums.doublebounce(float("inf")) +nums.doublebounce(float("-inf")) +nums.doublebounce(float("nan")) diff --git a/Lib/typemaps/fragments.swg b/Lib/typemaps/fragments.swg index 4dbc1f20d..8f887e34e 100644 --- a/Lib/typemaps/fragments.swg +++ b/Lib/typemaps/fragments.swg @@ -153,6 +153,29 @@ #include %} +%fragment("SWIG_isfinite","header",fragment=",") %{ +/* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */ +#ifndef SWIG_isfinite +# if defined(isfinite) +# define SWIG_isfinite(X) (isfinite(X)) +# elif defined(_MSC_VER) +# define SWIG_isfinite(X) (_finite(X)) +# elif defined(__sun) && defined(__SVR4) +# include +# define SWIG_isfinite(X) (finite(X)) +# endif +#endif +%} + +%fragment("SWIG_Float_Overflow_Check","header",fragment=",SWIG_isfinite") %{ +/* Accept infinite as a valid float value unless we are unable to check if a value is finite */ +#ifdef SWIG_isfinite +# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX) && SWIG_isfinite(X)) +#else +# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX)) +#endif +%} + /* ----------------------------------------------------------------------------- * special macros for fragments * ----------------------------------------------------------------------------- */ @@ -213,13 +236,20 @@ SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val) %enddef -/* Macro for 'double' derived types */ +/* Macro for floating point derived types (original macro) */ %define %numeric_double(Type, Frag, Min, Max) %numeric_type_from(Type, double) %numeric_signed_type_asval(Type, double, Frag , Min, Max) %enddef +/* Macro for floating point derived types */ + +%define %numeric_float(Type, Frag, OverflowCond) +%numeric_type_from(Type, double) +%numeric_type_asval(Type, double, Frag, OverflowCond) +%enddef + /* Macros for missing fragments */ diff --git a/Lib/typemaps/primtypes.swg b/Lib/typemaps/primtypes.swg index cc8a55e6e..45632c31f 100644 --- a/Lib/typemaps/primtypes.swg +++ b/Lib/typemaps/primtypes.swg @@ -139,7 +139,7 @@ SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val) /* float */ -%numeric_double(float, "", -FLT_MAX, FLT_MAX) +%numeric_float(float, "SWIG_Float_Overflow_Check", SWIG_Float_Overflow_Check(v)) /* long/unsigned long */ From c3f3880d0c55f55d9f83dd2d84be685b6b361cc7 Mon Sep 17 00:00:00 2001 From: Artem Serebriyskiy Date: Thu, 12 Sep 2013 19:49:51 +0100 Subject: [PATCH 256/273] Lua static member access improvements. 1) Static members and static functions inside class can be accessed as ModuleName.ClassName.FunctionName (MemberName respectively). Old way aka ModuleName.ClassName_FunctionName still works. 2) Same goes for enums inside classes: ModuleName.ClassName.EnumValue1 etc. 3) More 'runme' tests for lua + modifications to existing tests to test new changes. Code is loosely based upon python implemenation of the same thing. Patch #62. --- CHANGES.current | 7 + Examples/test-suite/lua/cpp_basic_runme.lua | 6 + Lib/lua/luarun.swg | 206 +++++++++++++++++++- Source/Modules/lua.cxx | 129 +++++++++++- 4 files changed, 335 insertions(+), 13 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 77d2df753..b2f007a92 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.11 (in progress) ============================ +2013-09-12: wsfulton + [Lua] Pull Git patch #62. + 1) Static members and static functions inside class can be accessed as + ModuleName.ClassName.FunctionName (MemberName respectively). Old way such as + ModuleName.ClassName_FunctionName still works. + 2) Same goes for enums inside classes: ModuleName.ClassName.EnumValue1 etc. + 2013-09-12: wsfulton [UTL] Infinity is now by default an acceptable value for type 'float'. This fix makes the handling of type 'float' and 'double' the same. The implementation requires the diff --git a/Examples/test-suite/lua/cpp_basic_runme.lua b/Examples/test-suite/lua/cpp_basic_runme.lua index 02f88479b..3d5ccaadf 100644 --- a/Examples/test-suite/lua/cpp_basic_runme.lua +++ b/Examples/test-suite/lua/cpp_basic_runme.lua @@ -42,16 +42,22 @@ assert(f3.num==32) f4=cb.Foo(6) cb.Bar_global_fptr=f4 assert(cb.Bar_global_fptr.num==6) +assert(cb.Bar.global_fptr.num==6) f4.num=8 assert(cb.Bar_global_fptr.num==8) +assert(cb.Bar.global_fptr.num==8) assert(cb.Bar_global_fref.num==23) +assert(cb.Bar.global_fref.num==23) cb.Bar_global_fref=cb.Foo(-7) -- this will set the value assert(cb.Bar_global_fref.num==-7) +assert(cb.Bar.global_fref.num==-7) assert(cb.Bar_global_fval.num==3) +assert(cb.Bar.global_fval.num==3) cb.Bar_global_fval=cb.Foo(-34) assert(cb.Bar_global_fval.num==-34) +assert(cb.Bar.global_fval.num==-34) -- Now test member function pointers func1_ptr=cb.get_func1_ptr() diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index c705e38e5..4d851bdb1 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -140,6 +140,15 @@ typedef struct { lua_CFunction setmethod; } swig_lua_attribute; +// Can be used to create namespaces. Currently used to +// wrap class static methods/variables/constants +typedef struct { + const char *name; + swig_lua_method *ns_methods; + swig_lua_attribute *ns_attributes; + swig_lua_const_info *ns_constants; +} swig_lua_namespace; + typedef struct swig_lua_class { const char *name; swig_type_info **type; @@ -147,6 +156,7 @@ typedef struct swig_lua_class { void (*destructor)(void *); swig_lua_method *methods; swig_lua_attribute *attributes; + swig_lua_namespace cls_static; struct swig_lua_class **bases; const char **base_names; } swig_lua_class; @@ -415,6 +425,137 @@ SWIGINTERN void SWIG_Lua_module_add_function(lua_State* L,const char* name,lua_ SWIG_Lua_add_function(L,name,fn); } +/* ----------------------------------------------------------------------------- + * global variable support code: namespaces + * ----------------------------------------------------------------------------- */ + +SWIGINTERN int SWIG_Lua_namespace_get(lua_State* L) +{ +/* there should be 2 params passed in + (1) table (not the meta table) + (2) string name of the attribute +*/ + assert(lua_istable(L,-2)); /* just in case */ + lua_getmetatable(L,-2); + assert(lua_istable(L,-1)); + SWIG_Lua_get_table(L,".get"); /* find the .get table */ + assert(lua_istable(L,-1)); + /* look for the key in the .get table */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + lua_remove(L,-2); /* stack tidy, remove .get table */ + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_call(L,0,1); /* 1 value in (userdata),1 out (result) */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return 1; + } + lua_pop(L,1); /* remove whatever was there */ + /* ok, so try the .fn table */ + SWIG_Lua_get_table(L,".fn"); /* find the .get table */ + assert(lua_istable(L,-1)); /* just in case */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); /* look for the fn */ + lua_remove(L,-2); /* stack tidy, remove .fn table */ + if (lua_isfunction(L,-1)) /* note: whether it's a C function or lua function */ + { /* found it so return the fn & let lua call it */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return 1; + } + lua_pop(L,1); /* remove whatever was there */ + return 0; +} + +SWIGINTERN int SWIG_Lua_namespace_set(lua_State* L) +{ +/* there should be 3 params passed in + (1) table (not the meta table) + (2) string name of the attribute + (3) any for the new value +*/ + + assert(lua_istable(L,1)); + lua_getmetatable(L,1); /* get the meta table */ + assert(lua_istable(L,-1)); + + SWIG_Lua_get_table(L,".set"); /* find the .set table */ + if (lua_istable(L,-1)) + { + /* look for the key in the .set table */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_pushvalue(L,3); /* value */ + lua_call(L,1,0); + return 0; + } + lua_pop(L,1); /* remove the value */ + } + lua_pop(L,1); /* remove the value .set table */ + return 0; +} + +SWIGINTERN void SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]); // forward declaration +SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn); // forward declaration + +/* helper function - register namespace methods and attributes into namespace */ +SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State* L, swig_lua_namespace* ns) +{ + int i = 0; + assert(lua_istable(L,-1)); + /* There must be table at the top of the stack */ + SWIG_Lua_InstallConstants(L, ns->ns_constants); + + lua_getmetatable(L,-1); + + /* add fns */ + for(i=0;ns->ns_attributes[i].name;i++){ + SWIG_Lua_add_class_variable(L,ns->ns_attributes[i].name,ns->ns_attributes[i].getmethod,ns->ns_attributes[i].setmethod); + } + + /* add methods to the metatable */ + SWIG_Lua_get_table(L,".fn"); /* find the .fn table */ + assert(lua_istable(L,-1)); /* just in case */ + for(i=0;ns->ns_methods[i].name;i++){ + SWIG_Lua_add_function(L,ns->ns_methods[i].name,ns->ns_methods[i].method); + } + lua_pop(L,1); + + /* clear stack - remove metatble */ + lua_pop(L,1); + +} + +/* helper function. creates namespace table and add it to module table */ +SWIGINTERN int SWIG_Lua_namespace_register(lua_State* L, swig_lua_namespace* ns) +{ + assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table */ + lua_checkstack(L,5); + lua_pushstring(L, ns->name); + lua_newtable(L); /* namespace itself */ + lua_newtable(L); /* metatable for namespace */ + + /* add a table called ".get" */ + lua_pushstring(L,".get"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".set" */ + lua_pushstring(L,".set"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".fn" */ + lua_pushstring(L,".fn"); + lua_newtable(L); + lua_rawset(L,-3); + + /* add accessor fns for using the .get,.set&.fn */ + SWIG_Lua_add_function(L,"__index",SWIG_Lua_namespace_get); + SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_namespace_set); + + lua_setmetatable(L,-2); /* set metatable */ + lua_rawset(L,-3); /* add namespace to module table */ +} /* ----------------------------------------------------------------------------- * global variable support code: classes * ----------------------------------------------------------------------------- */ @@ -570,6 +711,23 @@ SWIGINTERN int SWIG_Lua_class_disown(lua_State* L) return 0; } +/* Constructor proxy. Used when class name entry in module is not class constructor, +but special table instead. */ +SWIGINTERN int SWIG_Lua_constructor_proxy(lua_State* L) +{ + /* unlimited number of parameters + First one is our proxy table and we should remove it + Other we should pass to real constructor + */ + assert(lua_istable(L,1)); + lua_pushstring(L,".constructor"); + lua_rawget(L,1); + assert(!lua_isnil(L,-1)); + lua_replace(L,1); /* replace our table with real constructor */ + lua_call(L,lua_gettop(L)-1,1); + return 1; +} + /* gets the swig class registry (or creates it) */ SWIGINTERN void SWIG_Lua_get_class_registry(lua_State* L) { @@ -614,6 +772,21 @@ SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_C } } +/* helper to recursively add class static details (static attributes, operations and constants) */ +SWIGINTERN void SWIG_Lua_add_class_static_details(lua_State* L, swig_lua_class* clss) +{ + int i = 0; + /* The class namespace table must be on the top of the stack */ + assert(lua_istable(L,-1)); + /* call all the base classes first: we can then override these later: */ + for(i=0;clss->bases[i];i++) + { + SWIG_Lua_add_class_static_details(L,clss->bases[i]); + } + + SWIG_Lua_add_namespace_details(L, &clss->cls_static); +} + /* helper to recursively add class details (attributes & operations) */ SWIGINTERN void SWIG_Lua_add_class_details(lua_State* L,swig_lua_class* clss) { @@ -667,15 +840,42 @@ SWIGINTERN void SWIG_Lua_init_base_class(lua_State* L,swig_lua_class* clss) } } -/* performs the entire class registration process */ -SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss) +/* Register class static methods,attributes etc as well as constructor proxy */ +SWIGINTERN void SWIG_Lua_class_register_static(lua_State* L, swig_lua_class* clss) { + lua_checkstack(L,5); /* just in case */ + assert(lua_istable(L,-1)); /* just in case */ + assert(strcmp(clss->name, clss->cls_static.name) == 0); /* in class those 2 must be equal */ + + SWIG_Lua_namespace_register(L,&clss->cls_static); + + SWIG_Lua_get_table(L,clss->name); // Get namespace table back + assert(lua_istable(L,-1)); /* just in case */ + /* add its constructor to module with the name of the class so you can do MyClass(...) as well as new_MyClass(...) BUT only if a constructor is defined (this overcomes the problem of pure virtual classes without constructors)*/ if (clss->constructor) - SWIG_Lua_add_function(L,clss->name,clss->constructor); + { + SWIG_Lua_add_function(L,".constructor", clss->constructor); + lua_getmetatable(L,-1); + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_add_function(L,"__call", SWIG_Lua_constructor_proxy); + lua_pop(L,1); + } + + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_add_class_static_details(L, clss); + + /* clear stack */ + lua_pop(L,1); +} + +/* performs the entire class registration process */ +SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss) +{ + SWIG_Lua_class_register_static(L,clss); SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,clss->name); /* get the name */ diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index cff3107db..b76945b95 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -45,6 +45,7 @@ */ #include "swigmod.h" +#include "cparse.h" /**** Diagnostics: With the #define REPORT(), you can change the amount of diagnostics given @@ -111,6 +112,9 @@ private: String *s_const_tab; // table of global constants String *s_methods_tab; // table of class methods String *s_attr_tab; // table of class attributes + String *s_cls_attr_tab; // table of class static attributes + String *s_cls_methods_tab; // table of class static methods + String *s_cls_const_tab; // tables of class constants(including enums) 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 @@ -154,6 +158,9 @@ public: s_const_tab(0), s_methods_tab(0), s_attr_tab(0), + s_cls_attr_tab(0), + s_cls_methods_tab(0), + s_cls_const_tab(0), s_luacode(0), s_dot_get(0), s_dot_set(0), @@ -736,13 +743,18 @@ public: NEW LANGUAGE NOTE:END ************************************************/ /* Now register the function with the interpreter. */ if (!Getattr(n, "sym:overloaded")) { + //REPORT("dispatchFunction", n); // add_method(n, iname, wname, description); if (current==NO_CPP || current==STATIC_FUNC) { // emit normal fns & static fns + String *wrapname = Swig_name_wrapper(iname); 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); + if (getCurrentClass()) { + Setattr(n,"luaclassobj:wrap:name", wrapname); + } } } else { if (!Getattr(n, "sym:nextSibling")) { @@ -775,6 +787,7 @@ public: look for %typecheck(SWIG_TYPECHECK_*) in the .swg file NEW LANGUAGE NOTE:END ************************************************/ void dispatchFunction(Node *n) { + //REPORT("dispatchFunction", n); /* Last node in overloaded chain */ int maxargs; @@ -822,10 +835,14 @@ public: if (current==NO_CPP || current==STATIC_FUNC) // emit normal fns & static fns Printv(s_cmd_tab, tab4, "{ \"", symname, "\",", wname, "},\n", NIL); + if (getCurrentClass()) + Setattr(n,"luaclassobj:wrap:name", wname); + else + Delete(wname); + DelWrapper(f); Delete(dispatch); Delete(tmp); - Delete(wname); } @@ -878,8 +895,13 @@ public: } else { Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName); } - Delete(getName); - Delete(setName); + if (getCurrentClass()) { + Setattr(n, "luaclassobj:wrap:get", getName); + Setattr(n, "luaclassobj:wrap:set", setName); + } else { + Delete(getName); + Delete(setName); + } return result; } @@ -887,7 +909,7 @@ public: * constantWrapper() * ------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { - // REPORT("constantWrapper", n); + REPORT("constantWrapper", n); String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); String *nsname = Copy(iname); @@ -923,6 +945,20 @@ public: Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n"); return SWIG_NOWRAP; } + if (cparse_cplusplus && getCurrentClass()) { + // Additionally add to class constants + Swig_require("luaclassobj_constantWrapper", n, "*sym:name", "luaclassobj:symname", NIL); + Setattr(n, "sym:name", Getattr(n, "luaclassobj:symname")); + String *cls_nsname = Getattr(n, "sym:name"); + if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) { + Replaceall(tm, "$source", value); + Replaceall(tm, "$target", name); + Replaceall(tm, "$value", value); + Replaceall(tm, "$nsname", cls_nsname); + Printf(s_cls_const_tab, " %s,\n", tm); + } + Swig_restore(n); + } Delete(nsname); return SWIG_OK; } @@ -1009,6 +1045,19 @@ public: Printf(s_methods_tab, "static swig_lua_method swig_"); Printv(s_methods_tab, mangled_classname, "_methods[] = {\n", NIL); + s_cls_methods_tab = NewString(""); + Printf(s_cls_methods_tab, "static swig_lua_method swig_"); + Printv(s_cls_methods_tab, mangled_classname, "_cls_methods[] = {\n", NIL); + + s_cls_attr_tab = NewString(""); + Printf(s_cls_attr_tab, "static swig_lua_attribute swig_"); + Printv(s_cls_attr_tab, mangled_classname, "_cls_attributes[] = {\n", NIL); + + s_cls_const_tab = NewString(""); + Printf(s_cls_const_tab, "static swig_lua_const_info swig_"); + Printv(s_cls_const_tab, mangled_classname, "_cls_constants[] = {\n", NIL); + + // Generate normal wrappers Language::classHandler(n); @@ -1047,8 +1096,21 @@ public: Printf(s_attr_tab, " {0,0,0}\n};\n"); Printv(f_wrappers, s_attr_tab, NIL); + Printf(s_cls_attr_tab, " {0,0,0}\n};\n"); + Printv(f_wrappers, s_cls_attr_tab, NIL); + + Printf(s_cls_methods_tab, " {0,0}\n};\n"); + Printv(f_wrappers, s_cls_methods_tab, NIL); + + Printf(s_cls_const_tab, " {0,0,0,0,0,0}\n};\n"); + Printv(f_wrappers, s_cls_const_tab, NIL); + + Delete(s_methods_tab); Delete(s_attr_tab); + Delete(s_cls_methods_tab); + Delete(s_cls_attr_tab); + Delete(s_cls_const_tab); // Handle inheritance // note: with the idea of class hierarchies spread over multiple modules @@ -1122,7 +1184,10 @@ public: } else { Printf(f_wrappers, ",0"); } - Printf(f_wrappers, ", swig_%s_methods, swig_%s_attributes, swig_%s_bases, swig_%s_base_names };\n\n", mangled_classname, mangled_classname, mangled_classname, mangled_classname); + Printf(f_wrappers, ", swig_%s_methods, swig_%s_attributes, { \"%s\", swig_%s_cls_methods, swig_%s_cls_attributes, swig_%s_cls_constants }, swig_%s_bases, swig_%s_base_names };\n\n", + mangled_classname, mangled_classname, + class_name, mangled_classname, mangled_classname, mangled_classname, + mangled_classname, mangled_classname); // Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname, "_bases };\n\n", NIL); // Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, &_wrap_class_", mangled_classname, "},\n", NIL); @@ -1232,8 +1297,30 @@ public: * ---------------------------------------------------------------------- */ virtual int staticmemberfunctionHandler(Node *n) { + REPORT("staticmemberfunctionHandler", n); current = STATIC_FUNC; - return Language::staticmemberfunctionHandler(n); + String *symname = Getattr(n, "sym:name"); + int result = Language::staticmemberfunctionHandler(n); + + if (cparse_cplusplus && getCurrentClass()) { + Swig_restore(n); + } + current = NO_CPP; + if (result != SWIG_OK) + return result; + + if (Getattr(n, "sym:nextSibling")) + return SWIG_OK; + + Swig_require("luaclassobj_staticmemberfunctionHandler", n, "luaclassobj:wrap:name", NIL); + String *name = Getattr(n, "name"); + String *rname, *realname; + realname = symname ? symname : name; + rname = Getattr(n, "luaclassobj:wrap:name"); + Printv(s_cls_methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL); + Swig_restore(n); + + return SWIG_OK; } /* ------------------------------------------------------------ @@ -1243,8 +1330,17 @@ public: * ------------------------------------------------------------ */ virtual int memberconstantHandler(Node *n) { - // REPORT("memberconstantHandler",n); - return Language::memberconstantHandler(n); + REPORT("memberconstantHandler",n); + String *symname = Getattr(n, "sym:name"); + if (cparse_cplusplus && getCurrentClass()) { + Swig_save("luaclassobj_memberconstantHandler", n, "luaclassobj:symname", NIL); + Setattr(n, "luaclassobj:symname", symname); + } + int result = Language::memberconstantHandler(n); + if (cparse_cplusplus && getCurrentClass()) + Swig_restore(n); + + return result; } /* --------------------------------------------------------------------- @@ -1252,9 +1348,22 @@ public: * --------------------------------------------------------------------- */ virtual int staticmembervariableHandler(Node *n) { - // REPORT("staticmembervariableHandler",n); + REPORT("staticmembervariableHandler",n); current = STATIC_VAR; - return Language::staticmembervariableHandler(n); + String *symname = Getattr(n, "sym:name"); + int result = Language::staticmembervariableHandler(n); + + if (result != SWIG_OK) + return result; + + + if (Getattr(n, "wrappedasconstant")) + return SWIG_OK; + + Swig_require("luaclassobj_staticmembervariableHandler", n, "luaclassobj:wrap:get", "luaclassobj:wrap:set", NIL); + Printf(s_cls_attr_tab,"%s{ \"%s\", %s, %s},\n",tab4,symname,Getattr(n,"luaclassobj:wrap:get"), Getattr(n,"luaclassobj:wrap:set")); + Swig_restore(n); + return SWIG_OK; } /* --------------------------------------------------------------------- From 7a88729c87487c13163748c24b95196674f8ed21 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 13 Sep 2013 09:36:26 +0200 Subject: [PATCH 257/273] Remove trailing spaces in the generated code. No functional changes --- Lib/swigerrors.swg | 20 ++++---- Lib/swiginit.swg | 24 +++++----- Lib/swiglabels.swg | 12 ++--- Lib/swigrun.swg | 96 ++++++++++++++++++------------------- Lib/typemaps/swigmacros.swg | 58 +++++++++++----------- Source/Swig/misc.c | 8 ++-- 6 files changed, 109 insertions(+), 109 deletions(-) diff --git a/Lib/swigerrors.swg b/Lib/swigerrors.swg index 32857c498..1a6d20366 100644 --- a/Lib/swigerrors.swg +++ b/Lib/swigerrors.swg @@ -1,16 +1,16 @@ /* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 +#define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 diff --git a/Lib/swiginit.swg b/Lib/swiginit.swg index 6fe58d296..f321181eb 100644 --- a/Lib/swiginit.swg +++ b/Lib/swiginit.swg @@ -1,17 +1,17 @@ /* ----------------------------------------------------------------------------- * Type initialization: - * This problem is tough by the requirement that no dynamic - * memory is used. Also, since swig_type_info structures store pointers to + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back - * to swig_type_info structures, we need some lookup code at initialization. - * The idea is that swig generates all the structures that are needed. - * The runtime then collects these partially filled structures. - * The SWIG_InitializeModule function takes these initial arrays out of + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * - * The generated swig_type_info structures are assigned staticly to an initial + * The generated swig_type_info structures are assigned staticly to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the @@ -21,17 +21,17 @@ * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, - * we find the array of casts associated with the type, and loop through it + * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * - * First off, we lookup the cast->type name to see if it is already loaded. + * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. - * 2) If BOTH types (the one we are adding casting info to, and the + * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that @@ -108,7 +108,7 @@ SWIG_InitializeModule(void *clientdata) { swig_type_info *type = 0; swig_type_info *ret; swig_cast_info *cast; - + #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); #endif @@ -135,7 +135,7 @@ SWIG_InitializeModule(void *clientdata) { /* Insert casting types */ cast = swig_module.cast_initial[i]; while (cast->type) { - + /* Don't need to add information already in the list */ ret = 0; #ifdef SWIGRUNTIME_DEBUG diff --git a/Lib/swiglabels.swg b/Lib/swiglabels.swg index b943afb47..d428ac33d 100644 --- a/Lib/swiglabels.swg +++ b/Lib/swiglabels.swg @@ -29,28 +29,28 @@ #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else -# define SWIGUNUSED +# define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif +# endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif @@ -93,7 +93,7 @@ # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL -# endif +# endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index 21f0a5c14..7066e670e 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -22,7 +22,7 @@ You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the SWIG runtime code. In 99.9% of the cases, SWIG just needs to declare them as 'static'. - + But only do this if strictly necessary, ie, if you have problems with your compiler or suchlike. */ @@ -48,16 +48,16 @@ #define SWIG_POINTER_OWN 0x1 -/* +/* Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return an integer + + The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). - + Use the following macros/flags to set or process the returning states. - + In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { @@ -90,23 +90,23 @@ } else { // fail code } - + I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that also requires SWIG_ConvertPtr to return new result values, such as - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be @@ -120,17 +120,17 @@ int fooi(int); and you call - + food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ -#define SWIG_OK (0) +#define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) @@ -161,11 +161,11 @@ # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { +SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ # define SWIG_AddCast(r) (r) @@ -212,7 +212,7 @@ typedef struct swig_module_info { void *clientdata; /* Language specific module data */ } swig_module_info; -/* +/* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class" == "Class", etc. @@ -285,7 +285,7 @@ SWIG_TypeCheck(const char *c, swig_type_info *ty) { return 0; } -/* +/* Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * @@ -320,7 +320,7 @@ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } -/* +/* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * @@ -364,7 +364,7 @@ SWIG_TypePrettyName(const swig_type_info *type) { return type->name; } -/* +/* Set the clientdata field for a type */ SWIGRUNTIME void @@ -372,14 +372,14 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; - + while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } - } + } cast = cast->next; } } @@ -388,18 +388,18 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } - + /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { swig_module_info *iter = start; do { @@ -408,11 +408,11 @@ SWIG_MangledTypeQueryModule(swig_module_info *start, register size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; + register size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { register int compare = strcmp(name, iname); - if (compare == 0) { + if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { @@ -437,14 +437,14 @@ SWIG_MangledTypeQueryModule(swig_module_info *start, Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); @@ -463,12 +463,12 @@ SWIG_TypeQueryModule(swig_module_info *start, iter = iter->next; } while (iter != end); } - + /* neither found a match */ return 0; } -/* +/* Pack binary data into a string */ SWIGRUNTIME char * @@ -484,7 +484,7 @@ SWIG_PackData(char *c, void *ptr, size_t sz) { return c; } -/* +/* Unpack binary data from a string */ SWIGRUNTIME const char * @@ -498,21 +498,21 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); - else + else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); - else + else return (char *) 0; *u = uu; } return c; } -/* +/* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * diff --git a/Lib/typemaps/swigmacros.swg b/Lib/typemaps/swigmacros.swg index e95e7af92..c9b42facf 100644 --- a/Lib/typemaps/swigmacros.swg +++ b/Lib/typemaps/swigmacros.swg @@ -9,9 +9,9 @@ -------------------------- %arg(Arg) Safe argument wrap - %str(Arg) Stringtify the argument - %begin_block Begin a execution block - %end_block End a execution block + %str(Arg) Stringtify the argument + %begin_block Begin a execution block + %end_block End a execution block %block(Block) Execute Block as a excecution block %define_as(Def, Val) Define 'Def' as 'Val', expanding Def and Val first %ifcplusplus(V1, V2) if C++ Mode; then V1; else V2; fi @@ -19,33 +19,33 @@ Casting Operations: ------------------- - + SWIG provides the following casting macros, which implement the corresponding C++ casting operations: - %const_cast(a, Type) const_cast(a) - %static_cast(a, Type) static_cast(a) - %reinterpret_cast(a, Type) reinterpret_cast(a) - %numeric_cast(a, Type) static_cast(a) - %as_voidptr(a) const_cast(static_cast(a)) - %as_voidptrptr(a) reinterpret_cast(a) - + %const_cast(a, Type) const_cast(a) + %static_cast(a, Type) static_cast(a) + %reinterpret_cast(a, Type) reinterpret_cast(a) + %numeric_cast(a, Type) static_cast(a) + %as_voidptr(a) const_cast(static_cast(a)) + %as_voidptrptr(a) reinterpret_cast(a) + or their C unsafe versions. In C++ we use the safe version unless SWIG_NO_CPLUSPLUS_CAST is defined (usually via the -nocppcast swig flag). Memory allocation: ------------------ - + These allocation/freeing macros are safe to use in C or C++ and dispatch the proper new/delete/delete[] or free/malloc calls as needed. - + %new_instance(Type) Allocate a new instance of given Type %new_copy(value,Type) Allocate and initialize a new instance with 'value' %new_array(size,Type) Allocate a new array with given size and Type %new_copy_array(cptr,size,Type) Allocate and initialize a new array from 'cptr' - %delete(cptr) Delete an instance + %delete(cptr) Delete an instance %delete_array(cptr) Delete an array @@ -54,13 +54,13 @@ %formacro(Macro, Args...) or %formacro_1(Macro, Args...) for i in Args - do + do Macro($i) done %formacro_2(Macro2, Args...) for i,j in Args - do + do Macro2($i, $j) done @@ -71,12 +71,12 @@ %mark_flag(flag) flag := True - %evalif(flag,expr) + %evalif(flag,expr) if flag; then expr fi - %evalif_2(flag1 flag2,expr) + %evalif_2(flag1 flag2,expr) if flag1 and flag2; then expr fi @@ -84,7 +84,7 @@ */ /* ----------------------------------------------------------------------------- - * Basic preprocessor macros + * Basic preprocessor macros * ----------------------------------------------------------------------------- */ #define %arg(Arg...) Arg @@ -115,7 +115,7 @@ nocppval %define_as(SWIGVERSION, SWIG_VERSION) %#define SWIG_VERSION SWIGVERSION } -#endif +#endif @@ -153,10 +153,10 @@ nocppval /* ----------------------------------------------------------------------------- - * Allocating/freeing elements + * Allocating/freeing elements * ----------------------------------------------------------------------------- */ -#if defined(__cplusplus) +#if defined(__cplusplus) # define %new_instance(Type...) (new Type) # define %new_copy(val,Type...) (new Type(%static_cast(val, const Type&))) # define %new_array(size,Type...) (new Type[size]) @@ -184,7 +184,7 @@ nocppval /* ----------------------------------------------------------------------------- - * Auxiliary loop macros + * Auxiliary loop macros * ----------------------------------------------------------------------------- */ @@ -213,10 +213,10 @@ nocppval * SWIG flags * ----------------------------------------------------------------------------- */ -/* +/* mark a flag, ie, define a macro name but ignore it in - the interface. - + the interface. + the flag can be later used with %evalif */ @@ -224,16 +224,16 @@ nocppval /* - %evalif and %evalif_2 are use to evaluate or process + %evalif and %evalif_2 are use to evaluate or process an expression if the given predicate is 'true' (1). */ -%define %_evalif(_x,_expr) +%define %_evalif(_x,_expr) #if _x == 1 _expr #endif %enddef -%define %_evalif_2(_x,_y,_expr) +%define %_evalif_2(_x,_y,_expr) #if _x == 1 && _y == 1 _expr #endif diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index efa397878..651b94cf1 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -72,11 +72,11 @@ void Swig_banner(File *f) { Printf(f, "/* ----------------------------------------------------------------------------\n\ * This file was automatically generated by SWIG (http://www.swig.org).\n\ * Version %s\n\ - * \n\ - * This file is not intended to be easily readable and contains a number of \n\ + *\n\ + * This file is not intended to be easily readable and contains a number of\n\ * coding conventions designed to improve portability and efficiency. Do not make\n\ - * changes to this file unless you know what you are doing--modify the SWIG \n\ - * interface file instead. \n", Swig_package_version()); + * changes to this file unless you know what you are doing--modify the SWIG\n\ + * interface file instead.\n", Swig_package_version()); /* String too long for ISO compliance */ Printf(f, " * ----------------------------------------------------------------------------- */\n"); From ba9baefdd93922a585757e18f10e5723a0105202 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Sep 2013 12:53:45 +0100 Subject: [PATCH 258/273] sed portability fix creating swigwarn.swg --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 0ac8c88f9..c7972832c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -433,7 +433,7 @@ maintainer-clean: $(srcdir)/Lib/swigwarn.swg: $(srcdir)/Source/Include/swigwarn.h mkdir -p Lib echo "/* SWIG warning codes */" > $@ - cat $? | grep "^#define WARN\|/\*.*\*/\|^[ \t]*$$" | sed 's/^#define \(WARN.*[0-9]\+\)\(.*\)$$/%define SWIG\1 %enddef\2/' >> $@ + cat $? | grep "^#define WARN\|/\*.*\*/\|^[ \t]*$$" | sed 's/^#define \(WARN.*[0-9][0-9]*\)\(.*\)$$/%define SWIG\1 %enddef\2/' >> $@ ##################################################################### # TARGETS: install & friends From c4e29fb686b860584ac1def0dd36a7a3d46310c6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Sep 2013 15:51:50 -0700 Subject: [PATCH 259/273] Remove mkstemp replacement for ccache-swig on Cygwin Cygwin 1.7.0 as well as Cygwin 1.7.24 seem to be working okay Cygwin 1.7.24 gives gcc warning about dangerous use of mktemp --- CCache/ccache.h | 2 ++ CCache/util.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CCache/ccache.h b/CCache/ccache.h index 3c3e22311..dcbb03f0c 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -200,6 +200,8 @@ typedef int (*COMPAR_FN_T)(const void *, const void *); /* mkstemp() on some versions of cygwin don't handle binary files, so override */ +/* Seems okay in Cygwin 1.7.0 #ifdef __CYGWIN__ #undef HAVE_MKSTEMP #endif +*/ diff --git a/CCache/util.c b/CCache/util.c index bba232492..66f9823b9 100644 --- a/CCache/util.c +++ b/CCache/util.c @@ -82,7 +82,7 @@ void copy_fd(int fd_in, int fd_out) #ifndef HAVE_MKSTEMP /* cheap and nasty mkstemp replacement */ -static int mkstemp(char *template) +int mkstemp(char *template) { mktemp(template); return open(template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600); From cb4a23b2df066b316bc8c427e1849826e4341e95 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Sep 2013 15:52:42 -0700 Subject: [PATCH 260/273] Cygwin test-suite fix for tcl 8.5 on Cygwin --- Examples/test-suite/li_windows.i | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Examples/test-suite/li_windows.i b/Examples/test-suite/li_windows.i index 26f96cc3b..c99ffe4ca 100644 --- a/Examples/test-suite/li_windows.i +++ b/Examples/test-suite/li_windows.i @@ -4,6 +4,12 @@ %{ #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) + // Fix Tcl.h and Windows.h cat and mouse over definition of VOID + #if defined(_TCL) && defined(__CYGWIN__) + #ifdef VOID + #undef VOID + #endif + #endif #include #else // Use equivalent types for non-windows systems From f618a6999041614181272cc95afd290f19e30c6c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Sep 2013 17:32:54 -0700 Subject: [PATCH 261/273] Better detection of Ruby shared library extension Use Config to detect dll extension (needs to be .so for Ruby 1.9 on Cygwin) --- Examples/Makefile.in | 5 +++-- configure.ac | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index df754427c..5607feb9e 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -913,6 +913,7 @@ RUBY_INCLUDE= @RUBYINCLUDE@ RUBY_LIB = @RUBYLIB@ RUBY_DLNK = @RUBYDYNAMICLINKING@ RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS) +RUBY_SO = @RUBYSO@ RUBY = @RUBY@ RUBY_SCRIPT = $(RUNME).rb @@ -924,7 +925,7 @@ RUBY_SCRIPT = $(RUNME).rb ruby: $(SRCS) $(SWIG) -ruby $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(RUBY_INCLUDE) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO) # ----------------------------------------------------------------- # Build a C++ dynamically loadable module @@ -933,7 +934,7 @@ ruby: $(SRCS) ruby_cpp: $(SRCS) $(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO) # ----------------------------------------------------------------- # Build statically linked Ruby interpreter diff --git a/configure.ac b/configure.ac index 5b6441b86..c4db3ce98 100644 --- a/configure.ac +++ b/configure.ac @@ -1399,6 +1399,7 @@ if test -n "$RUBY"; then esac RUBYCCDLFLAGS=`($RUBY -rrbconfig -e 'print Config::CONFIG[["CCDLFLAGS"]]') 2>/dev/null` + RUBYSO=.`($RUBY -rrbconfig -e 'print Config::CONFIG[["DLEXT"]]') 2>/dev/null` else AC_MSG_RESULT(could not figure out how to run ruby) RUBYINCLUDE="-I/usr/local/lib/ruby/1.4/arch" @@ -1416,6 +1417,7 @@ AC_SUBST(RUBYINCLUDE) AC_SUBST(RUBYLIB) AC_SUBST(RUBYLINK) AC_SUBST(RUBYCCDLFLAGS) +AC_SUBST(RUBYSO) AC_SUBST(RUBYDYNAMICLINKING) #------------------------------------------------------------------------- From f01b52c44cbab9205a4fd4c2bcac5ba2d12ef460 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 13 Sep 2013 07:15:34 +0100 Subject: [PATCH 262/273] Tweak 'make beautify-file' unix2dos and dos2unix were renamed to todos and fromdos - they aren't really needed (on Linux anyway), so removed. --- Source/Makefile.am | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Makefile.am b/Source/Makefile.am index 984b9c268..40fa4d9f2 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -140,8 +140,6 @@ beautify-file: test -n "$(INDENTFILE)" || (echo INDENTFILE not defined && exit 1;) test -e $(INDENTFILE) || (echo File does not exist: $(INDENTFILE) && exit 1;) cp $(INDENTFILE) $(INDENTBAKSDIR)/$(INDENTFILE); - unix2dos $(INDENTFILE) - dos2unix $(INDENTFILE) indent -kr --honour-newlines --line-length160 --indent-level2 --braces-on-func-def-line --leave-optional-blank-lines $(SWIGTYPEDEFS) $(INDENTFILE) -o $(INDENTFILE).tmp; cat $(INDENTFILE).tmp | sed -e 's/const const /const /' > $(INDENTFILE); rm $(INDENTFILE).tmp; From 0431664b18f17774344c79962518acfa4c738746 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 15 Sep 2013 10:43:49 +0100 Subject: [PATCH 263/273] Guile OUTPUT typemap fix Fixes 'attempt to free a non-heap object' in some OUTPUT typemaps. --- CHANGES.current | 9 +++++++++ Examples/test-suite/typemap_qualifier_strip.i | 4 ++++ Lib/r/r.swg | 9 ++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index b2f007a92..7e756e912 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.11 (in progress) ============================ +2013-09-15: wsfulton + [R] Fix attempt to free a non-heap object in OUTPUT typemaps for: + unsigned short *OUTPUT + unsigned long *OUTPUT + signed long long *OUTPUT + char *OUTPUT + signed char*OUTPUT + unsigned char*OUTPUT + 2013-09-12: wsfulton [Lua] Pull Git patch #62. 1) Static members and static functions inside class can be accessed as diff --git a/Examples/test-suite/typemap_qualifier_strip.i b/Examples/test-suite/typemap_qualifier_strip.i index d91a7b109..9b9f24cd8 100644 --- a/Examples/test-suite/typemap_qualifier_strip.i +++ b/Examples/test-suite/typemap_qualifier_strip.i @@ -1,5 +1,9 @@ %module typemap_qualifier_strip +%typemap(freearg) int *ptr "" +%typemap(freearg) int *const ptrConst "" +%typemap(freearg) int const* constPtr "" + %typemap(in) int *ptr { int temp = 1234; $1 = &temp; diff --git a/Lib/r/r.swg b/Lib/r/r.swg index be42ff3a1..126611d61 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -114,12 +114,19 @@ signed int *OUTPUT, unsigned int *OUTPUT, short *OUTPUT, signed short *OUTPUT, +unsigned short *OUTPUT, long *OUTPUT, signed long *OUTPUT, +unsigned long *OUTPUT, long long *OUTPUT, +signed long long *OUTPUT, unsigned long long *OUTPUT, float *OUTPUT, -double *OUTPUT {} +double *OUTPUT, +char *OUTPUT, +signed char *OUTPUT, +unsigned char *OUTPUT +{} From 80b108eb70229680ad63daa7267d74ccc342dd2c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 15 Sep 2013 15:11:43 +0100 Subject: [PATCH 264/273] Add swig-2.0.11 release info and date --- ANNOUNCE | 8 ++++---- CHANGES.current | 2 +- Doc/Manual/Sections.html | 2 +- README | 2 +- RELEASENOTES | 4 ++++ 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 1c3297a5c..caaa55d8c 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,8 +1,8 @@ -*** ANNOUNCE: SWIG 2.0.10 (in progress) *** +*** ANNOUNCE: SWIG 2.0.11 (15 Sep 2013) *** http://www.swig.org -We're pleased to announce SWIG-2.0.10, the latest SWIG release. +We're pleased to announce SWIG-2.0.11, the latest SWIG release. What is SWIG? ============= @@ -21,11 +21,11 @@ Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-2.0.10.tar.gz + http://prdownloads.sourceforge.net/swig/swig-2.0.11.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-2.0.10.zip + http://prdownloads.sourceforge.net/swig/swigwin-2.0.11.zip Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. diff --git a/CHANGES.current b/CHANGES.current index 7e756e912..1727ecb2c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,7 +2,7 @@ Below are the changes for the current release. See the CHANGES file for changes in older releases. See the RELEASENOTES file for a summary of changes in each release. -Version 2.0.11 (in progress) +Version 2.0.11 (15 Sep 2013) ============================ 2013-09-15: wsfulton diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 9e4a3dd17..2dfb438f8 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

    SWIG-2.0 Documentation

    -Last update : SWIG-2.0.10 (in progress) +Last update : SWIG-2.0.11 (15 Sep 2013)

    Sections

    diff --git a/README b/README index 444643a0d..946bd9a8f 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 2.0.10 (in progress) +Version: 2.0.11 (15 Sep 2013) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, diff --git a/RELEASENOTES b/RELEASENOTES index 49eacf28a..720dc9d34 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -4,6 +4,10 @@ and CHANGES files. Release Notes ============= +SWIG-2.0.11 summary: +- Minor bug fixes and enhancements mostly in Python, but also + C#, Lua, Ocaml, Octave, Perl, PHP, Python, R, Ruby, Tcl. + SWIG-2.0.10 summary: - Ruby 1.9 support is now complete. - Add support for Guile 2.0 and Guile 1.6 support (GH interface) has From b0b8d4c87e0077baccf770441768f5ad3b15dcd3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 15 Sep 2013 22:39:08 +0100 Subject: [PATCH 265/273] Add hint about pushing tags post release [ci skip] --- Tools/mkrelease.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py index 9eceba07e..0623fe786 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -45,4 +45,4 @@ os.system("rsync --archive --verbose -P --times -e ssh " + "swigwin-" + version print "Finished" -print "Now log in to SourceForge and set the operating systems applicable to the newly uploaded tarball and zip file. Also remember to do a 'git push'." +print "Now log in to SourceForge and set the operating systems applicable to the newly uploaded tarball and zip file. Also remember to do a 'git push --tags'." From 37bccfd517dfebb4d191a144975d04c7ebfdea12 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Sep 2013 23:43:30 +0100 Subject: [PATCH 266/273] Bump version to 3.0.0 SWIG 3 is open for business - looks go crazy! --- ANNOUNCE | 8 +-- CHANGES | 138 +++++++++++++++++++++++++++++++++++++++ CHANGES.current | 136 +------------------------------------- Doc/Manual/Sections.html | 6 +- README | 2 +- configure.ac | 2 +- 6 files changed, 148 insertions(+), 144 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index caaa55d8c..90cc9ba24 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,8 +1,8 @@ -*** ANNOUNCE: SWIG 2.0.11 (15 Sep 2013) *** +*** ANNOUNCE: SWIG 3.0.0 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-2.0.11, the latest SWIG release. +We're pleased to announce SWIG-3.0.0, the latest SWIG release. What is SWIG? ============= @@ -21,11 +21,11 @@ Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-2.0.11.tar.gz + http://prdownloads.sourceforge.net/swig/swig-3.0.0.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-2.0.11.zip + http://prdownloads.sourceforge.net/swig/swigwin-3.0.0.zip Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. diff --git a/CHANGES b/CHANGES index 488bf7286..c70765cf1 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,144 @@ SWIG (Simplified Wrapper and Interface Generator) See the CHANGES.current file for changes in the current version. See the RELEASENOTES file for a summary of changes in each release. + +Version 2.0.11 (15 Sep 2013) +============================ + +2013-09-15: wsfulton + [R] Fix attempt to free a non-heap object in OUTPUT typemaps for: + unsigned short *OUTPUT + unsigned long *OUTPUT + signed long long *OUTPUT + char *OUTPUT + signed char*OUTPUT + unsigned char*OUTPUT + +2013-09-12: wsfulton + [Lua] Pull Git patch #62. + 1) Static members and static functions inside class can be accessed as + ModuleName.ClassName.FunctionName (MemberName respectively). Old way such as + ModuleName.ClassName_FunctionName still works. + 2) Same goes for enums inside classes: ModuleName.ClassName.EnumValue1 etc. + +2013-09-12: wsfulton + [UTL] Infinity is now by default an acceptable value for type 'float'. This fix makes + the handling of type 'float' and 'double' the same. The implementation requires the + C99 isfinite() macro, or otherwise some platform dependent equivalents, to be available. + + Users requiring the old behaviour of not accepting infinity, can define a 'check' typemap + wherever a float is used, such as: + + %typemap(check,fragment="") float, const float & %{ + if ($1 < -FLT_MAX || $1 > FLT_MAX) { + SWIG_exception_fail(SWIG_TypeError, "Overflow in type float"); + } + %} + + *** POTENTIAL INCOMPATIBILITY *** + +2013-08-30: wsfulton + [Lua] Pull Git patch #81: Include Lua error locus in SWIG error messages. + This is standard information in Lua error messages, and makes it much + easier to find bugs. + +2013-08-29: wsfulton + Pull Git patch #75: Handle UTF-8 files with BOM at beginning of file. Was giving an + 'Illegal token' syntax error. + +2013-08-29: wsfulton + [C#] Pull Git patch #77: Allow exporting std::map using non-default comparison function. + +2013-08-28: wsfulton + [Python] %implicitconv is improved for overloaded functions. Like in C++, the methods + with the actual types are considered before trying implicit conversions. Example: + + %implicitconv A; + struct A { + A(int i); + }; + class CCC { + public: + int xx(int i) { return 11; } + int xx(const A& i) { return 22; } + }; + + The following python code: + + CCC().xx(-1) + + will now return 11 instead of 22 - the implicit conversion is not done. + +2013-08-23: olly + [Python] Fix clang++ warning in generated wrapper code. + +2013-08-16: wsfulton + [Python] %implicitconv will now accept None where the implicit conversion takes a C/C++ pointer. + Problem highlighted by Bo Peng. Closes SF patch #230. + +2013-08-07: wsfulton + [Python] SF Patch #326 from Kris Thielemans - Remove SwigPyObject_print and SwigPyObject_str and + make the generated wrapper use the default python implementations, which will fall back to repr + (for -builtin option). + + Advantages: + - it avoids the swig user having to jump through hoops to get print to work as expected when + redefining repr/str slots. + - typing the name of a variable on the python prompt now prints the result of a (possibly redefined) + repr, without the swig user having to do any extra work. + - when redefining repr, the swig user doesn't necessarily have to redefine str as it will call the + redefined repr + - the behaviour is exactly the same as without the -builtin option while requiring no extra work + by the user (aside from adding the %feature("python:slot...) statements of course) + + Disadvantage: + - default str() will give different (but clearer?) output on swigged classes + +2013-07-30: wsfulton + [Python, Ruby] Fix #64 #65: Missing code in std::multimap wrappers. Previously an instantiation + of a std::map was erroneously required in addition to an instantiation of std::multimap with the + same template parameters to prevent compilation errors for the wrappers of a std::multimap. + +2013-07-14: joequant + [R] Change types file to allow for SEXP return values + +2013-07-05: wsfulton + [Python] Add %pythonbegin directive which works like %pythoncode, except the specified code is + added at the beginning of the generated .py file. This is primarily needed for importing from + __future__ statements required to be at the very beginning of the file. Example: + + %pythonbegin %{ + from __future__ import print_function + print("Loading", "Whizz", "Bang", sep=' ... ') + %} + +2013-07-01: wsfulton + [Python] Apply SF patch #340 - Uninitialized variable fix in SWIG_Python_NonDynamicSetAttr + when using -builtin. + +2013-07-01: wsfulton + [Python, Ruby, Ocaml] Apply SF patch #341 - fix a const_cast in generated code that was generating + a <:: digraph when using the unary scope operator (::) (global scope) in a template type. + +2013-07-01: wsfulton + [Python] Add SF patch #342 from Christian Delbaere to fix some director classes crashing on + object deletion when using -builtin. Fixes SF bug #1301. + +2013-06-11: wsfulton + [Python] Add SWIG_PYTHON_INTERPRETER_NO_DEBUG macro which can be defined to use the Release version + of the Python interpreter in Debug builds of the wrappers. The Visual Studio .dsp example + files have been modified to use this so that Debug builds will now work without having + to install or build a Debug build of the interpreter. + +2013-06-07: wsfulton + [Ruby] Git issue #52. Fix regression with missing rb_complex_new function for Ruby + versions prior to 1.9 using std::complex wrappers if just using std::complex as an output type. + Also fix the Complex helper functions external visibility (to static by default). + +2013-06-04: olly + [PHP] Fix SWIG_ZTS_ConvertResourcePtr() not to dereference NULL + if the type lookup fails. + Version 2.0.10 (27 May 2013) ============================ diff --git a/CHANGES.current b/CHANGES.current index 1727ecb2c..ddf123364 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,140 +2,6 @@ Below are the changes for the current release. See the CHANGES file for changes in older releases. See the RELEASENOTES file for a summary of changes in each release. -Version 2.0.11 (15 Sep 2013) +Version 3.0.0 (in progress) ============================ -2013-09-15: wsfulton - [R] Fix attempt to free a non-heap object in OUTPUT typemaps for: - unsigned short *OUTPUT - unsigned long *OUTPUT - signed long long *OUTPUT - char *OUTPUT - signed char*OUTPUT - unsigned char*OUTPUT - -2013-09-12: wsfulton - [Lua] Pull Git patch #62. - 1) Static members and static functions inside class can be accessed as - ModuleName.ClassName.FunctionName (MemberName respectively). Old way such as - ModuleName.ClassName_FunctionName still works. - 2) Same goes for enums inside classes: ModuleName.ClassName.EnumValue1 etc. - -2013-09-12: wsfulton - [UTL] Infinity is now by default an acceptable value for type 'float'. This fix makes - the handling of type 'float' and 'double' the same. The implementation requires the - C99 isfinite() macro, or otherwise some platform dependent equivalents, to be available. - - Users requiring the old behaviour of not accepting infinity, can define a 'check' typemap - wherever a float is used, such as: - - %typemap(check,fragment="") float, const float & %{ - if ($1 < -FLT_MAX || $1 > FLT_MAX) { - SWIG_exception_fail(SWIG_TypeError, "Overflow in type float"); - } - %} - - *** POTENTIAL INCOMPATIBILITY *** - -2013-08-30: wsfulton - [Lua] Pull Git patch #81: Include Lua error locus in SWIG error messages. - This is standard information in Lua error messages, and makes it much - easier to find bugs. - -2013-08-29: wsfulton - Pull Git patch #75: Handle UTF-8 files with BOM at beginning of file. Was giving an - 'Illegal token' syntax error. - -2013-08-29: wsfulton - [C#] Pull Git patch #77: Allow exporting std::map using non-default comparison function. - -2013-08-28: wsfulton - [Python] %implicitconv is improved for overloaded functions. Like in C++, the methods - with the actual types are considered before trying implicit conversions. Example: - - %implicitconv A; - struct A { - A(int i); - }; - class CCC { - public: - int xx(int i) { return 11; } - int xx(const A& i) { return 22; } - }; - - The following python code: - - CCC().xx(-1) - - will now return 11 instead of 22 - the implicit conversion is not done. - -2013-08-23: olly - [Python] Fix clang++ warning in generated wrapper code. - -2013-08-16: wsfulton - [Python] %implicitconv will now accept None where the implicit conversion takes a C/C++ pointer. - Problem highlighted by Bo Peng. Closes SF patch #230. - -2013-08-07: wsfulton - [Python] SF Patch #326 from Kris Thielemans - Remove SwigPyObject_print and SwigPyObject_str and - make the generated wrapper use the default python implementations, which will fall back to repr - (for -builtin option). - - Advantages: - - it avoids the swig user having to jump through hoops to get print to work as expected when - redefining repr/str slots. - - typing the name of a variable on the python prompt now prints the result of a (possibly redefined) - repr, without the swig user having to do any extra work. - - when redefining repr, the swig user doesn't necessarily have to redefine str as it will call the - redefined repr - - the behaviour is exactly the same as without the -builtin option while requiring no extra work - by the user (aside from adding the %feature("python:slot...) statements of course) - - Disadvantage: - - default str() will give different (but clearer?) output on swigged classes - -2013-07-30: wsfulton - [Python, Ruby] Fix #64 #65: Missing code in std::multimap wrappers. Previously an instantiation - of a std::map was erroneously required in addition to an instantiation of std::multimap with the - same template parameters to prevent compilation errors for the wrappers of a std::multimap. - -2013-07-14: joequant - [R] Change types file to allow for SEXP return values - -2013-07-05: wsfulton - [Python] Add %pythonbegin directive which works like %pythoncode, except the specified code is - added at the beginning of the generated .py file. This is primarily needed for importing from - __future__ statements required to be at the very beginning of the file. Example: - - %pythonbegin %{ - from __future__ import print_function - print("Loading", "Whizz", "Bang", sep=' ... ') - %} - -2013-07-01: wsfulton - [Python] Apply SF patch #340 - Uninitialized variable fix in SWIG_Python_NonDynamicSetAttr - when using -builtin. - -2013-07-01: wsfulton - [Python, Ruby, Ocaml] Apply SF patch #341 - fix a const_cast in generated code that was generating - a <:: digraph when using the unary scope operator (::) (global scope) in a template type. - -2013-07-01: wsfulton - [Python] Add SF patch #342 from Christian Delbaere to fix some director classes crashing on - object deletion when using -builtin. Fixes SF bug #1301. - -2013-06-11: wsfulton - [Python] Add SWIG_PYTHON_INTERPRETER_NO_DEBUG macro which can be defined to use the Release version - of the Python interpreter in Debug builds of the wrappers. The Visual Studio .dsp example - files have been modified to use this so that Debug builds will now work without having - to install or build a Debug build of the interpreter. - -2013-06-07: wsfulton - [Ruby] Git issue #52. Fix regression with missing rb_complex_new function for Ruby - versions prior to 1.9 using std::complex wrappers if just using std::complex as an output type. - Also fix the Complex helper functions external visibility (to static by default). - -2013-06-04: olly - [PHP] Fix SWIG_ZTS_ConvertResourcePtr() not to dereference NULL - if the type lookup fails. - diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 2dfb438f8..195111424 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -1,12 +1,12 @@ -SWIG-2.0 Documentation +SWIG-3.0 Documentation -

    SWIG-2.0 Documentation

    +

    SWIG-3.0 Documentation

    -Last update : SWIG-2.0.11 (15 Sep 2013) +Last update : SWIG-3.0.0 (in progress)

    Sections

    diff --git a/README b/README index 946bd9a8f..b6080a4fd 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 2.0.11 (15 Sep 2013) +Version: 3.0.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, diff --git a/configure.ac b/configure.ac index c4db3ce98..47d1e13ae 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. dnl The macros which aren't shipped with the autotools are stored in the dnl Tools/config directory in .m4 files. -AC_INIT([swig],[2.0.11],[http://www.swig.org]) +AC_INIT([swig],[3.0.0],[http://www.swig.org]) dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED dnl definition below can be removed From d0cb2b73dbd04a20f977db818056b0de5ac2605e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 18 Sep 2013 00:38:39 +0100 Subject: [PATCH 267/273] Remove X11 detection during configure X11 is not used anywhere. --- Examples/Makefile.in | 21 ------------ Lib/perl5/Makefile.in | 18 ++--------- Lib/python/Makefile.in | 18 ++--------- Lib/tcl/Makefile.in | 19 ++++------- configure.ac | 73 +----------------------------------------- 5 files changed, 13 insertions(+), 136 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 5607feb9e..e9b70f961 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -51,11 +51,6 @@ RUNPIPE= RUNME = runme -# X11 options - -XLIB = @XLIBSW@ -XINCLUDE = @XINCLUDES@ - IWRAP = $(INTERFACE:.i=_wrap.i) ISRCS = $(IWRAP:.i=.c) ICXXSRCS = $(IWRAP:.i=.cxx) @@ -136,7 +131,6 @@ TCL_SCRIPT = $(RUNME).tcl # Build a new version of the tclsh shell # ----------------------------------------------------------- - tclsh: $(SRCS) $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH) $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ @@ -147,21 +141,6 @@ tclsh_cpp: $(SRCS) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET) -# ----------------------------------------------------------- -# Build a new copy of wish -# ----------------------------------------------------------- - -wish: $(SRCS) - $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH) - $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ - $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET) - - -wish_cpp: $(SRCS) - $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH) - $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ - $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET) - # ----------------------------------------------------------- # Build a Tcl dynamic loadable module (you might need to tweak this) # ----------------------------------------------------------- diff --git a/Lib/perl5/Makefile.in b/Lib/perl5/Makefile.in index dde01894d..f11ad2bdf 100644 --- a/Lib/perl5/Makefile.in +++ b/Lib/perl5/Makefile.in @@ -47,7 +47,7 @@ SWIGOPT = -perl5 SWIGCC = $(CC) # SWIG Library files. Uncomment this to staticly rebuild Perl -#SWIGLIB = -static -lperlmain.i +#SWIGLIBS = -static -lperlmain.i # Rules for creating .o files from source. @@ -69,33 +69,21 @@ BUILD = @LDSHARED@ #DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc -# X11 installation (possibly needed if using Perl-Tk) - -XLIB = @XLIBSW@ -XINCLUDE = @XINCLUDES@ - # Perl installation PERL_INCLUDE = -I@PERL5EXT@ PERL_LIB = -L@PERL5EXT@ -lperl PERL_FLAGS = -Dbool=char -Dexplicit= -# Tcl installation. If using Tk you might need this - -TCL_INCLUDE = @TCLINCLUDE@ -TCL_LIB = @TCLLIB@ - # Build libraries (needed for static builds) LIBM = @LIBM@ LIBC = @LIBC@ SYSLIBS = $(LIBM) $(LIBC) @LIBS@ -# Build options (uncomment only one these) +# Build options -#TK_LIB = $(TCL_LIB) -ltcl -ltk $(XLIB) BUILD_LIBS = $(LIBS) # Dynamic loading -#BUILD_LIBS = $(PERL_LIB) $(TK_LIB) $(LIBS) $(SYSLIBS) # Static linking # Compilation rules for non-SWIG components @@ -123,7 +111,7 @@ $(WRAPOBJ) : $(WRAPFILE) $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(PERL_INCLUDE) $(PERL_FLAGS) $(WRAPFILE) $(WRAPFILE) : $(INTERFACE) - $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE) + $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) diff --git a/Lib/python/Makefile.in b/Lib/python/Makefile.in index 3243b3df4..71effea70 100644 --- a/Lib/python/Makefile.in +++ b/Lib/python/Makefile.in @@ -47,7 +47,7 @@ SWIGOPT = -python SWIGCC = $(CC) # SWIG Library files. Uncomment if rebuilding the Python interpreter -#SWIGLIB = -lembed.i +#SWIGLIBS = -lembed.i # Rules for creating .o files from source. @@ -69,32 +69,20 @@ BUILD = @LDSHARED@ #DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc -# X11 installation (needed if rebuilding Python + tkinter) - -XLIB = @XLIBSW@ -XINCLUDE = @XINCLUDES@ - # Python installation PY_INCLUDE = -DHAVE_CONFIG_H @PYINCLUDE@ PY_LIB = @PYLIB@ -# Tcl installation. Needed if rebuilding Python with tkinter. - -TCL_INCLUDE = @TCLINCLUDE@ -TCL_LIB = @TCLLIB@ - # Build libraries (needed for static builds) LIBM = @LIBM@ LIBC = @LIBC@ SYSLIBS = $(LIBM) $(LIBC) @LIBS@ -# Build options (uncomment only one these) +# Build options -#TKINTER = $(TCL_LIB) -ltk -ltcl $(XLIB) BUILD_LIBS = $(LIBS) # Dynamic loading -#BUILD_LIBS = $(PY_LIB) @PYLINK@ $(TKINTER) $(LIBS) $(SYSLIBS) # Compilation rules for non-SWIG components @@ -122,7 +110,7 @@ $(WRAPOBJ) : $(WRAPFILE) $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(PY_INCLUDE) $(WRAPFILE) : $(INTERFACE) - $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE) + $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) diff --git a/Lib/tcl/Makefile.in b/Lib/tcl/Makefile.in index 523349bb5..2ab0f7b01 100644 --- a/Lib/tcl/Makefile.in +++ b/Lib/tcl/Makefile.in @@ -1,5 +1,5 @@ # --------------------------------------------------------------- -# SWIG Tcl/Tk Makefile +# SWIG Tcl Makefile # # This file can be used to build various Tcl extensions with SWIG. # By default this file is set up for dynamic loading, but it can @@ -48,9 +48,8 @@ SWIG = $(exec_prefix)/bin/swig SWIGOPT = -tcl # use -tcl8 for Tcl 8.0 SWIGCC = $(CC) -# SWIG Library files. Uncomment one of these for rebuilding tclsh or wish -#SWIGLIB = -ltclsh.i -#SWIGLIB = -lwish.i +# SWIG Library files. Uncomment if rebuilding tclsh +#SWIGLIBS = -ltclsh.i # Rules for creating .o files from source. @@ -72,12 +71,7 @@ BUILD = @LDSHARED@ #DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc -# X11 installation (needed to rebuild Tk extensions) - -XLIB = @XLIBSW@ -XINCLUDE = @XINCLUDES@ - -# Tcl installation (where is Tcl/Tk located) +# Tcl installation (where is Tcl located) TCL_INCLUDE = @TCLINCLUDE@ TCL_LIB = @TCLLIB@ @@ -88,11 +82,10 @@ LIBM = @LIBM@ LIBC = @LIBC@ SYSLIBS = $(LIBM) $(LIBC) @LIBS@ -# Build options (uncomment only one these) +# Build options (uncomment only one of these) BUILD_LIBS = $(LIBS) # Dynamic loading #BUILD_LIBS = $(TCL_LIB) -ltcl $(LIBS) $(SYSLIBS) # tclsh -#BUILD_LIBS = $(TCL_LIB) -ltk -ltcl $(XLIB) $(LIBS) $(SYSLIBS) # wish # Compilation rules for non-SWIG components @@ -120,7 +113,7 @@ $(WRAPOBJ) : $(WRAPFILE) $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(TCL_INCLUDE) $(WRAPFILE) : $(INTERFACE) - $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE) + $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) diff --git a/configure.ac b/configure.ac index 47d1e13ae..2d1c4a592 100644 --- a/configure.ac +++ b/configure.ac @@ -418,80 +418,9 @@ else AC_MSG_ERROR([proper usage is --with-libc=STRING]) fi]) #-------------------------------------------------------------------- -# Locate the X11 header files and the X11 library archive. Try -# the ac_path_x macro first, but if it doesn't find the X stuff -# (e.g. because there's no xmkmf program) then check through -# a list of possible directories. Under some conditions the -# autoconf macro will return an include directory that contains -# no include files, so double-check its result just to be safe. +# Target languages #-------------------------------------------------------------------- -AC_PATH_X -not_really_there="" -if test "$no_x" = ""; then - if test "$x_includes" = ""; then - AC_TRY_CPP([#include ], , not_really_there="yes") - else - if test ! -r $x_includes/X11/Intrinsic.h; then - not_really_there="yes" - fi - fi -fi -if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then - AC_MSG_CHECKING(for X11 header files) - XINCLUDES="# no special path needed" - AC_TRY_CPP([#include ], , XINCLUDES="") - if test -z "$XINCLUDES"; then - dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/include/X11R4 /usr/X11R5/include /usr/include/X11R5 /usr/openwin/include /usr/X11/include /usr/sww/include /usr/X11R6/include /usr/include/X11R6" - for i in $dirs ; do - if test -r $i/X11/Intrinsic.h; then - XINCLUDES=" -I$i" - break - fi - done - fi - AC_MSG_RESULT($XINCLUDES) -else - if test "$x_includes" != ""; then - XINCLUDES=-I$x_includes - else - XINCLUDES="# no special path needed" - fi -fi -if test -z "$XINCLUDES"; then - AC_MSG_RESULT(couldn't find any!) - XINCLUDES="# no include files found" -fi - -if test "$no_x" = yes; then - AC_MSG_CHECKING(for X11 libraries) - XLIBSW= - dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/lib/X11R4 /usr/X11R5/lib /usr/lib/X11R5 /usr/X11R6/lib /usr/lib/X11R6 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib" - for i in $dirs ; do - if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then - AC_MSG_RESULT($i) - XLIBSW="-L$i -lX11" - break - fi - done -else - if test "$x_libraries" = ""; then - XLIBSW=-lX11 - else - XLIBSW="-L$x_libraries -lX11" - fi -fi -if test -z "$XLIBSW" ; then - AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow) -fi -if test -z "$XLIBSW" ; then - AC_MSG_RESULT(couldn't find any! Using -lX11.) - XLIBSW=-lX11 -fi - -AC_SUBST(XINCLUDES) -AC_SUBST(XLIBSW) - AC_ARG_WITH(alllang, AS_HELP_STRING([--without-alllang], [Disable all languages]), with_alllang="$withval") #-------------------------------------------------------------------- From 43032339d0517cd371b783693fb471a20f887e6d Mon Sep 17 00:00:00 2001 From: Gavin Kinsey Date: Thu, 19 Sep 2013 12:21:57 +0100 Subject: [PATCH 268/273] Fixed a memory leak for java STRING_ARRAY The allocation loop uses size, so the free loop should do the same, not size-1. --- Lib/java/various.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/java/various.i b/Lib/java/various.i index f589bf714..7ba7a5eb3 100644 --- a/Lib/java/various.i +++ b/Lib/java/various.i @@ -52,7 +52,7 @@ %typemap(freearg) char **STRING_ARRAY { int i; - for (i=0; i Date: Fri, 20 Sep 2013 18:47:46 +0100 Subject: [PATCH 269/273] Document Java char **STRING_ARRAY typemap fix --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index ddf123364..fe625d798 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,3 +5,6 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.0 (in progress) ============================ +2013-09-20: wsfulton + [Java] Fix a memory leak for the java char **STRING_ARRAY typemaps. + From 12708c9241bf9e5ef75a449ff848f2be84a35e72 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 25 Sep 2013 17:29:33 +1200 Subject: [PATCH 270/273] Fix typos --- CHANGES | 4 ++-- Doc/Manual/Java.html | 2 +- Doc/Manual/SWIG.html | 2 +- .../android/extend/src/org/swig/extendexample/SwigExtend.java | 2 +- Examples/csharp/extend/runme.cs | 2 +- Examples/d/extend/d1/runme.d | 2 +- Examples/d/extend/d2/runme.d | 2 +- Examples/go/extend/runme.go | 2 +- Examples/java/extend/runme.java | 2 +- Lib/go/go.swg | 2 +- Source/Modules/lang.cxx | 2 +- Source/Modules/python.cxx | 2 +- Tools/config/ac_compile_warnings.m4 | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index c70765cf1..4cc222901 100644 --- a/CHANGES +++ b/CHANGES @@ -3303,8 +3303,8 @@ Version 1.3.36 (24 June 2008) Makefile target being generated when generating makefiles with the -M family of options. For example: - $ swig -java -MM -MT overiddenname -c++ example.i - overiddenname: \ + $ swig -java -MM -MT overriddenname -c++ example.i + overriddenname: \ example.i \ example.h diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 0024d602a..f3d8a1684 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -7886,7 +7886,7 @@ where it is possible to step from Java code into a JNI method within one environ

    Alternatively, debugging can involve placing debug printout statements in the JNI layer using the %exception directive. See the special variables for %exception section. -Many of the default typemaps can also be overidden and modified for adding in extra logging/debug display information. +Many of the default typemaps can also be overridden and modified for adding in extra logging/debug display information.

    diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 25dc899de..f9ea5b2ef 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -258,7 +258,7 @@ this option the default output directory is the path to the input file. If -o and -outcurrentdir are used together, -outcurrentdir is effectively ignored as the output directory for the language files is the same directory as the -generated C/C++ file if not overidden with -outdir. +generated C/C++ file if not overridden with -outdir.

    5.1.3 Comments

    diff --git a/Examples/android/extend/src/org/swig/extendexample/SwigExtend.java b/Examples/android/extend/src/org/swig/extendexample/SwigExtend.java index a343dfebc..b88d36082 100644 --- a/Examples/android/extend/src/org/swig/extendexample/SwigExtend.java +++ b/Examples/android/extend/src/org/swig/extendexample/SwigExtend.java @@ -96,7 +96,7 @@ public class SwigExtend extends Activity // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in Java. The call to getPosition is - // slightly different, however, because of the overidden getPosition() call, since + // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, Java resolved the call // immediately in CEO, but now Java thinks the object is an instance of diff --git a/Examples/csharp/extend/runme.cs b/Examples/csharp/extend/runme.cs index 825dcdbca..92313aa5e 100644 --- a/Examples/csharp/extend/runme.cs +++ b/Examples/csharp/extend/runme.cs @@ -45,7 +45,7 @@ public class runme // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in C#. The call to getPosition is - // slightly different, however, because of the overidden getPosition() call, since + // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, C# resolved the call // immediately in CEO, but now C# thinks the object is an instance of diff --git a/Examples/d/extend/d1/runme.d b/Examples/d/extend/d1/runme.d index 96501d1a4..058432096 100644 --- a/Examples/d/extend/d1/runme.d +++ b/Examples/d/extend/d1/runme.d @@ -46,7 +46,7 @@ void main() { // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in D. The call to getPosition is - // slightly different, however, because of the overidden getPosition() call, since + // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, D resolved the call // immediately in CEO, but now D thinks the object is an instance of diff --git a/Examples/d/extend/d2/runme.d b/Examples/d/extend/d2/runme.d index 1ea6dfd21..cccdf463b 100644 --- a/Examples/d/extend/d2/runme.d +++ b/Examples/d/extend/d2/runme.d @@ -46,7 +46,7 @@ void main() { // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in D. The call to getPosition is - // slightly different, however, because of the overidden getPosition() call, since + // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, D resolved the call // immediately in CEO, but now D thinks the object is an instance of diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go index 8fdfd0a6c..770e27802 100644 --- a/Examples/go/extend/runme.go +++ b/Examples/go/extend/runme.go @@ -42,7 +42,7 @@ func main() { // treated the same. For items 0, 1, and 2, all methods // resolve in C++. For item 3, our CEO, GetTitle calls // GetPosition which resolves in Go. The call to GetPosition - // is slightly different, however, because of the overidden + // is slightly different, however, because of the overridden // GetPosition() call, since now the object reference has been // "laundered" by passing through EmployeeList as an // Employee*. Previously, Go resolved the call immediately in diff --git a/Examples/java/extend/runme.java b/Examples/java/extend/runme.java index 629bb14a6..f1ec1ea06 100644 --- a/Examples/java/extend/runme.java +++ b/Examples/java/extend/runme.java @@ -55,7 +55,7 @@ public class runme { // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in Java. The call to getPosition is - // slightly different, however, because of the overidden getPosition() call, since + // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, Java resolved the call // immediately in CEO, but now Java thinks the object is an instance of diff --git a/Lib/go/go.swg b/Lib/go/go.swg index cc3beef7d..b00533fa3 100644 --- a/Lib/go/go.swg +++ b/Lib/go/go.swg @@ -431,7 +431,7 @@ %} /* Typecheck typemaps. The purpose of these is merely to issue a - warning for overloaded C++ functions * that cannot be overloaded in + warning for overloaded C++ functions that cannot be overloaded in Go as more than one C++ type maps to a single Go type. */ %typecheck(SWIG_TYPECHECK_BOOL) /* Go bool */ diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index eb7d49480..6cc6e9fc3 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2513,7 +2513,7 @@ int Language::classHandler(Node *n) { Setattr(m, "parentNode", n); /* * There is a bug that needs fixing still... - * This area of code is creating methods which have not been overidden in a derived class (director methods that are protected in the base) + * This area of code is creating methods which have not been overridden in a derived class (director methods that are protected in the base) * If the method is overloaded, then Swig_overload_dispatch() incorrectly generates a call to the base wrapper, _wrap_xxx method * See director_protected_overloaded.i - Possibly sym:overname needs correcting here. Printf(stdout, "new method: %s::%s(%s)\n", Getattr(parentNode(m), "name"), Getattr(m, "name"), ParmList_str_defaultargs(Getattr(m, "parms"))); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 94802e06d..98f6cac09 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3728,7 +3728,7 @@ public: if (builtin) builtin_pre_decl(n); - /* Overide the shadow file so we can capture its methods */ + /* Override the shadow file so we can capture its methods */ f_shadow = NewString(""); // Set up type check for director class constructor diff --git a/Tools/config/ac_compile_warnings.m4 b/Tools/config/ac_compile_warnings.m4 index 4c030ea59..7e4239a3c 100644 --- a/Tools/config/ac_compile_warnings.m4 +++ b/Tools/config/ac_compile_warnings.m4 @@ -4,7 +4,7 @@ dnl Set the maximum warning verbosity according to C and C++ compiler used. dnl Currently supports g++ and gcc. dnl dnl The compiler options are always added CFLAGS and CXXFLAGS even if -dnl these are overidden at configure time. Removing the maximum warning +dnl these are overridden at configure time. Removing the maximum warning dnl flags can be removed with --without-maximum-compile-warnings. For example: dnl dnl ./configure --without-maximum-compile-warnings CFLAGS= CXXFLAGS= From c4d40c7b64c0a599780f94824ca9d6d00f71264c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Oct 2013 22:13:57 +0100 Subject: [PATCH 271/273] PHP directors - generate call_user_function on one line --- Source/Modules/php.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 3cae48383..652bd1e63 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2606,8 +2606,8 @@ done: /* wrap complex arguments to zvals */ Printv(w->code, wrap_args, NIL); - Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,\n"); - Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx); + Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,"); + Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx); if (tm) { Printv(w->code, Str(tm), "\n", NIL); From e186d2176a527c0e171c8e85e42121a7a1d7d6de Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 4 Oct 2013 23:08:33 +0100 Subject: [PATCH 272/273] Fix %naturalvar and templated methods using enums %naturalvar was not being picked up - use the symbol table instead for looking up the feature. use_naturalvar_mode() has been moved to Language class (not strictly necessary though) --- CHANGES.current | 4 +++ Examples/test-suite/common.mk | 1 + Examples/test-suite/naturalvar_more.i | 46 +++++++++++++++++++++++++++ Source/Modules/lang.cxx | 20 ++++++++---- Source/Modules/swigmod.h | 6 ++-- 5 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 Examples/test-suite/naturalvar_more.i diff --git a/CHANGES.current b/CHANGES.current index fe625d798..edd39af31 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.0 (in progress) ============================ +2013-10-04: wsfulton + Fix %naturalvar not having any affect on templated classes instantiated with an + enum as the template parameter type. Problem reported by Vadim Zeitlin. + 2013-09-20: wsfulton [Java] Fix a memory leak for the java char **STRING_ARRAY typemaps. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 997f8e715..381a49f7b 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -274,6 +274,7 @@ CPP_TEST_CASES += \ nspace \ nspace_extend \ naturalvar \ + naturalvar_more \ nested_class \ nested_comment \ nested_workaround \ diff --git a/Examples/test-suite/naturalvar_more.i b/Examples/test-suite/naturalvar_more.i new file mode 100644 index 000000000..2cbfb069c --- /dev/null +++ b/Examples/test-suite/naturalvar_more.i @@ -0,0 +1,46 @@ +%module naturalvar_more + +// The instantiation of a template using an enum in the template parameter was not picking up %naturalvar. + +// These typemaps will be used if %naturalvar is not working +%typemap(out) T *te, T *const_te "_should_not_use_this_out_typemap_" +%typemap(varout) T *te, T *const_te "_should_not_use_this_varout_typemap_" +%typemap(out) Hidden *hidden "_should_not_use_this_out_typemap_" +%typemap(varout) Hidden *hidden "_should_not_use_this_varout_typemap_" + +%naturalvar T; +%naturalvar Hidden; + +%inline %{ +template struct T {}; +struct K {}; +struct Hidden; +%} +%{ +struct Hidden {}; +%} + +%inline %{ +namespace Space { + enum E { E1, E2, E3 }; +} +%} + +%template(TE) T; + +%include +%include +%template(VectorString) std::vector; + +%inline { +using namespace Space; +struct S { + T te; + const T const_te; + const std::vector::value_type const_string_member; // check this resolves to std::string which has a naturalvar + std::vector::value_type string_member; // check this resolves to std::string which has a naturalvar + Hidden hidden; + S() : const_te(), const_string_member("initial string value") {} +}; +} + diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 6cc6e9fc3..1e63d4d9c 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -467,9 +467,9 @@ void swig_pragma(char *lang, char *name, char *value) { } /* -------------------------------------------------------------------------- - * use_naturalvar_mode() + * Language::use_naturalvar_mode() * -------------------------------------------------------------------------- */ -int use_naturalvar_mode(Node *n) { +int Language::use_naturalvar_mode(Node *n) const { if (Getattr(n, "unnamed")) return 0; int nvar = naturalvar_mode || GetFlag(n, "feature:naturalvar"); @@ -478,12 +478,17 @@ int use_naturalvar_mode(Node *n) { SwigType *ty = Getattr(n, "type"); SwigType *fullty = SwigType_typedef_resolve_all(ty); if (SwigType_isclass(fullty)) { - Node *m = Copy(n); SwigType *tys = SwigType_strip_qualifiers(fullty); - Swig_features_get(Swig_cparse_features(), 0, tys, 0, m); - nvar = GetFlag(m, "feature:naturalvar"); + if (!CPlusPlus) { + Replaceall(tys, "struct ", ""); + Replaceall(tys, "union ", ""); + Replaceall(tys, "class ", ""); + } + Node *typenode = Swig_symbol_clookup(tys, 0); + assert(typenode); + if (typenode) + nvar = GetFlag(typenode, "feature:naturalvar"); Delete(tys); - Delete(m); } Delete(fullty); } @@ -1441,6 +1446,7 @@ int Language::membervariableHandler(Node *n) { tm = Swig_typemap_lookup("memberin", nin, target, 0); Delete(nin); } + int flags = Extend | SmartPointer | use_naturalvar_mode(n); if (isNonVirtualProtectedAccess(n)) flags = flags | CWRAP_ALL_PROTECTED_ACCESS; @@ -3091,7 +3097,7 @@ Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) { * Tries to locate a class from a type definition * ----------------------------------------------------------------------------- */ -Node *Language::classLookup(const SwigType *s) { +Node *Language::classLookup(const SwigType *s) const { Node *n = 0; /* Look in hash of cached values */ diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index b3722af40..4fcf013eb 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -215,7 +215,7 @@ public: virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */ virtual void dumpSymbols(); virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */ - virtual Node *classLookup(const SwigType *s); /* Class lookup */ + virtual Node *classLookup(const SwigType *s) const; /* Class lookup */ virtual Node *enumLookup(SwigType *s); /* Enum lookup */ virtual int abstractClassTest(Node *n); /* Is class really abstract? */ virtual int is_assignable(Node *n); /* Is variable assignable? */ @@ -300,6 +300,9 @@ protected: This does not include protected virtual methods as they are turned on with the dirprot option. */ bool isNonVirtualProtectedAccess(Node *n) const; + /* Identify if a wrapped global or member variable n should use the naturalvar feature */ + int use_naturalvar_mode(Node *n) const; + /* Director subclass comparison test */ String *none_comparison; @@ -380,7 +383,6 @@ int is_protected(Node *n); int is_member_director(Node *parentnode, Node *member); int is_member_director(Node *member); int is_non_virtual_protected_access(Node *n); /* Check if the non-virtual protected members are required (for directors) */ -int use_naturalvar_mode(Node *n); void Wrapper_virtual_elimination_mode_set(int); void Wrapper_fast_dispatch_mode_set(int); From 3fcbb40af94f9209c2da4f806db45ef24ad8408b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 Oct 2013 02:16:02 +0100 Subject: [PATCH 273/273] Remove incorrectly and newly introduced assert Was failing in li_boost_shared_ptr.i for some languages. A similar testcase has been added into naturalvar_more.i. --- Examples/test-suite/naturalvar_more.i | 7 +++++++ Source/Modules/lang.cxx | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/naturalvar_more.i b/Examples/test-suite/naturalvar_more.i index 2cbfb069c..aebb6b23e 100644 --- a/Examples/test-suite/naturalvar_more.i +++ b/Examples/test-suite/naturalvar_more.i @@ -15,9 +15,15 @@ template struct T {}; struct K {}; struct Hidden; +namespace Ace { + int glob; +} %} %{ struct Hidden {}; +namespace Ace { + template struct NoIdea {}; +} %} %inline %{ @@ -40,6 +46,7 @@ struct S { const std::vector::value_type const_string_member; // check this resolves to std::string which has a naturalvar std::vector::value_type string_member; // check this resolves to std::string which has a naturalvar Hidden hidden; + Ace::NoIdea noidea; S() : const_te(), const_string_member("initial string value") {} }; } diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 1e63d4d9c..a62084499 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -485,7 +485,6 @@ int Language::use_naturalvar_mode(Node *n) const { Replaceall(tys, "class ", ""); } Node *typenode = Swig_symbol_clookup(tys, 0); - assert(typenode); if (typenode) nvar = GetFlag(typenode, "feature:naturalvar"); Delete(tys);
    +
    SWIG_MemoryError
    +
    rb_eNoMemError
    +
    SWIG_IOError
    +
    rb_eIOError
    +
    SWIG_RuntimeError
    +
    rb_eRuntimeError
    +
    SWIG_IndexError
    +
    rb_eIndexError
    +
    SWIG_TypeError
    +
    rb_eTypeError
    +
    SWIG_DivisionByZero
    +
    rb_eZeroDivError
    +
    SWIG_OverflowError
    +
    rb_eRangeError
    +
    SWIG_SyntaxError
    +
    rb_eSyntaxError
    +
    SWIG_ValueError
    +
    rb_eArgError
    +
    SWIG_SystemError
    +
    rb_eFatal
    +
    SWIG_AttributeError
    +
    rb_eRuntimeError
    +
    SWIG_NullReferenceError
    +
    rb_eNullReferenceError*
    +
    SWIG_ObjectPreviouslyDeletedError
    +
    rb_eObjectPreviouslyDeleted*
    +
    SWIG_UnknownError
    +
    rb_eRuntimeError
    * These error classes are created by SWIG and are not built-in Ruby exception classes
    @@ -1812,10 +1798,9 @@ Obj is a C++ instance of an exception class, type is a string specifying the type of exception (for example, "MyError") and desc is the SWIG description of the exception class. For example:

    -
    -%raise(SWIG_NewPointerObj(e, -SWIGTYPE_p_AssertionFailedException, -0), ":AssertionFailedException", SWIGTYPE_p_AssertionFailedException);
    +
    +%raise(SWIG_NewPointerObj(e, SWIGTYPE_p_AssertionFailedException, 0), ":AssertionFailedException", SWIGTYPE_p_AssertionFailedException);
    +

    This is useful when you want to pass the current exception object @@ -1849,7 +1834,7 @@ providing for a more natural integration between C++ code and Ruby code.

    foo = Foo.new
    begin
    foo.test()
    rescue CustomError => e
    puts "Caught custom error"
    end
    -

    For another example look at swig/Examples/ruby/exception_class.
    +

    For another example look at swig/Examples/ruby/exception_class.

    @@ -1876,8 +1861,11 @@ attached to a specific C datatype. The general form of this declaration is as follows ( parts enclosed in [...] are optional ):    

    -
    %typemap( method [, modifiers...] ) typelist -code;
    +
    +
    +%typemap( method [, modifiers...] ) typelist code;
    +
    +

    method is a simply a name that specifies what kind of typemap is being defined. It is usually a name like "in", @@ -1936,7 +1924,10 @@ following sample code:

    prints the result:

    -
    Received an integer : 6
    720
    +
    +Received an integer : 6
    +720
    +

    In this example, the typemap is applied to all occurrences of @@ -2122,33 +2113,33 @@ function arguments. For example: - - + - - + - - + - - + - - + - - + @@ -2205,33 +2196,33 @@ to a Ruby object.

    $input Input object + $input Input object holding value to be converted.
    $symname Name of + $symname Name of function/method being wrapped
    $1...n Argument being + $1...n Argument being sent to the function
    $1_name Name of the + $1_name Name of the argument (if provided)
    $1_type The actual C + $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable + $1_ltype The assignable version of the C datatype matched by the typemap.
    - - + - - + - - + - - + - - + - - + @@ -2301,18 +2292,18 @@ example:

    $result Result object + $result Result object returned to target language.
    $symname Name of + $symname Name of function/method being wrapped
    $1...n Argument being + $1...n Argument being wrapped
    $1_name Name of the + $1_name Name of the argument (if provided)
    $1_type The actual C + $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable + $1_ltype The assignable version of the C datatype matched by the typemap.
    - - + - - + - - + @@ -2441,38 +2432,38 @@ typemap.
    $result Result object + $result Result object returned to target language.
    $input The original + $input The original input object passed.
    $symname Name of + $symname Name of function/method being wrapped.
    - - + - - + - - + - - + - - + - - + - - + @@ -2488,15 +2479,11 @@ of the "out" typemap, making its rule often similar to the "in" typemap.

    -

    - -%typemap(directorout) int {

    - -   $result = NUM2INT($1);

    - -}
    - -
    +
    +%typemap(directorout) int {
    +   $result = NUM2INT($1);
    +
    +

    The following special variables are available:

    @@ -2504,35 +2491,35 @@ typemap.
    $result Result object + $result Result object returned to target language.
    $symname Name of + $symname Name of function/method being wrapped
    $1...n Argument being + $1...n Argument being wrapped
    $1_name Name of the + $1_name Name of the argument (if provided)
    $1_type The actual C + $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable + $1_ltype The assignable version of the C datatype matched by the typemap.
    this C++ this, + this C++ this, referring to the class itself.
    - - + + - - + + - - + + - - + - - + - - + - - + @@ -2540,17 +2527,18 @@ referring to the class itself.

    Currently, the directorout nor the out typemap support the -option numoutputs, +option numoutputs, but the Ruby module provides that functionality through a %feature directive.  Thus, a function can be made to return "nothing" if you do:

    -
    %feature("numoutputs","0") -MyClass::function;
    +
    +%feature("numoutputs","0") MyClass::function;
    +

    This feature can be useful if a function returns a status code, which you want to discard but still use the typemap to raise an -exception.
    +exception.

    @@ -2560,12 +2548,12 @@ exception.

    Output argument processing in director member functions.

    -
    %typemap(directorargout, -fragment="output_helper") int {
    - -$result = output_helper( $result, NUM2INT($1) );

    - -}
    +
    +%typemap(directorargout,
    +fragment="output_helper") int {
    +  $result = output_helper( $result, NUM2INT($1) );
    +}
    +

    The following special variables are available:

    @@ -2573,39 +2561,39 @@ $result = output_helper( $result, NUM2INT($1) );
    $inputRuby object being sent to the function$inputRuby object being sent to the function
    $symname Name of function/method being wrapped$symname Name of function/method being wrapped
    $1...n Argument being sent to the function$1...n Argument being sent to the function
    $1_name Name of the + $1_name Name of the argument (if provided)
    $1_type The actual C + $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable + $1_ltype The assignable version of the C datatype matched by the typemap.
    this C++ this, + this C++ this, referring to the class itself.
    - - + + - - + + - - + + - - + + - - + - - + - - + - - + @@ -2702,28 +2690,28 @@ across multiple languages.

    - - + + - - + + - - + + - - + + - - + @@ -2735,65 +2723,65 @@ SWIG_From_float(float)

    Here, while the Ruby versions return the value directly, the SWIG -versions do not, but return a status value to indicate success (SWIG_OK). While more akward to use, this allows you to write typemaps that report more helpful error messages, like:

    -

    -%typemap(in) size_t (int ok)

    -  ok = SWIG_AsVal_size_t($input, &$1);
    -  if (!SWIG_IsOK(ok)) {
    -    SWIG_exception_fail(SWIG_ArgError(ok), -Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -));
    -   }
    -
    -}
    -
      
    +versions do not, but return a status value to indicate success (SWIG_OK). While more akward to use, this allows you to write typemaps that report more helpful error messages, like:

    + +
    +
    +%typemap(in) size_t (int ok)
    +  ok = SWIG_AsVal_size_t($input, &$1);
    +  if (!SWIG_IsOK(ok)) {
    +    SWIG_exception_fail(SWIG_ArgError(ok), Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input));
    +  }
    +}
    +
    +
    +
    $resultResult that the director function returns$resultResult that the director function returns
    $inputRuby object being sent to the function$inputRuby object being sent to the function
    $symnamename of the function/method being wrapped$symnamename of the function/method being wrapped
    $1...nArgument being sent to the function$1...nArgument being sent to the function
    $1_nameName of the + $1_nameName of the argument (if provided)
    $1_typeThe actual C + $1_typeThe actual C datatype matched by the typemap
    $1_ltypeThe assignable + $1_ltypeThe assignable version of the C datatype matched by the typemap
    thisC++ this, + thisC++ this, referring to the instance of the class itself
    INT2NUM(long or int) SWIG_From_int(int x)INT2NUM(long or int) SWIG_From_int(int x) int to Fixnum or Bignum
    INT2FIX(long or int) INT2FIX(long or int) int to Fixnum (faster than INT2NUM)
    CHR2FIX(char) SWIG_From_char(char x)CHR2FIX(char) SWIG_From_char(char x) char to Fixnum
    rb_str_new2(char*) SWIG_FromCharPtrAndSize(char*, size_t)rb_str_new2(char*) SWIG_FromCharPtrAndSize(char*, size_t) char* to String
    rb_float_new(double) SWIG_From_double(double),
    +
    rb_float_new(double) SWIG_From_double(double),
    SWIG_From_float(float)
    float/double to Float
    - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + +
    int NUM2INT(Numeric)SWIG_AsVal_int(VALUE, int*)int NUM2INT(Numeric)SWIG_AsVal_int(VALUE, int*)
    int FIX2INT(Numeric)SWIG_AsVal_int(VALUE, int*)int FIX2INT(Numeric)SWIG_AsVal_int(VALUE, int*)
    unsigned int NUM2UINT(Numeric)SWIG_AsVal_unsigned_SS_int(VALUE, int*)unsigned int NUM2UINT(Numeric)SWIG_AsVal_unsigned_SS_int(VALUE, int*)
    unsigned int FIX2UINT(Numeric)SWIG_AsVal_unsigned_SS_int(VALUE, int*)unsigned int FIX2UINT(Numeric)SWIG_AsVal_unsigned_SS_int(VALUE, int*)
    long NUM2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)long NUM2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)
    long FIX2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)long FIX2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)
    unsigned long FIX2ULONG(Numeric)SWIG_AsVal_unsigned_SS_long(VALUE, unsigned long*)unsigned long FIX2ULONG(Numeric)SWIG_AsVal_unsigned_SS_long(VALUE, unsigned long*)
    char NUM2CHR(Numeric or String)SWIG_AsVal_char(VALUE, int*)char NUM2CHR(Numeric or String)SWIG_AsVal_char(VALUE, int*)
    char * StringValuePtr(String)SWIG_AsCharPtrAndSize(VALUE, char*, size_t, int* alloc)char * StringValuePtr(String)SWIG_AsCharPtrAndSize(VALUE, char*, size_t, int* alloc)
    char * rb_str2cstr(String, int*length)char * rb_str2cstr(String, int*length)
    double NUM2DBL(Numeric)(double) SWIG_AsVal_int(VALUE) or similardouble NUM2DBL(Numeric)(double) SWIG_AsVal_int(VALUE) or similar
    @@ -3250,16 +3238,17 @@ generated file. 

    For example, to generate html web pages from a C++ file, you'd do: 

    -
    -$ -rdoc -E cxx=c -f html file_wrap.cxx
    +
    +
    +$ rdoc -E cxx=c -f html file_wrap.cxx
    +

    To generate ri documentation from a c wrap file, you could do:

    -
    $ rdoc --r file_wrap.c -
    +
    +$ rdoc -r file_wrap.c
    +

    36.8.1 Module docstring

    @@ -3611,7 +3600,7 @@ that defines a derived class:

    extension module:

    -
    $ swig -c++ -ruby shape.i
    +
    $ swig -c++ -ruby shape.i
     
    @@ -3887,7 +3876,7 @@ class library models a zoo and the animals it contains.

    %module zoo

    %{
    #include <string>
    #include <vector>

    #include "zoo.h"
    %}

    class Animal
    {
    private:
    typedef std::vector<Animal*> AnimalsType;
    typedef AnimalsType::iterator IterType;
    protected:
    AnimalsType animals;
    protected:
    std::string name_;
    public:
    // Construct an animal with this name
    Animal(const char* name) : name_(name) {}

    // Return the animal's name
    const char* get_name() const { return name.c_str(); }
    };

    class Zoo
    {
    protected:
    std::vector<animal *=""> animals;

    public:
    // Construct an empty zoo
    Zoo() {}

    /* Create a new animal. */
    static Animal* Zoo::create_animal(const char* name)
    {
    return new Animal(name);
    }

    // Add a new animal to the zoo
    void add_animal(Animal* animal) {
    animals.push_back(animal);
    }

    Animal* remove_animal(size_t i) {
    Animal* result = this->animals[i];
    IterType iter = this->animals.begin();
    std::advance(iter, i);
    this->animals.erase(iter);

    return result;
    }

    // Return the number of animals in the zoo
    size_t get_num_animals() const {
    return animals.size();
    }

    // Return a pointer to the ith animal
    Animal* get_animal(size_t i) const {
    return animals[i];
    }
    };

    -

    Let's say you SWIG this code and then run IRB:
    +

    Let's say you SWIG this code and then run IRB:

    @@ -3968,8 +3957,7 @@ class-by-class basis if needed. To fix the example above:

    %module example

    %{
    #include "example.h"
    %}

    /* Tell SWIG that create_animal creates a new object */
    %newobject Zoo::create_animal;

    /* Tell SWIG to keep track of mappings between C/C++ structs/classes. */
    %trackobjects;

    %include "example.h"
    -

    When this code runs we see:
    - +

    When this code runs we see:

    @@ -4013,7 +4001,7 @@ has problems. For example:

    The problem is that Ruby does not know that the zoo object contains a reference to a Ruby object. Thus, when Ruby garbage -collects tiger1 +collects tiger1 it frees the underlying C++ object.

    This can be fixed by implementing a mark @@ -4086,8 +4074,8 @@ above.

    To show how to use the %freefunc directive, let's slightly change our example. Assume that the zoo object is responsible for freeing animal that it contains. This means -that the Zoo::add_animal -function should be marked with a DISOWN typemap +that the Zoo::add_animal +function should be marked with a DISOWN typemap and the destructor should be updated as below:

    @@ -4283,19 +4271,12 @@ collect any VALUE objects defined from that point on.  

    To mark functions to either reset the ruby stack or not, you can use:

    -
    %initstack -  Class::memberfunction;  // only re-init the stack -in this director method
    - -%ignorestack Class::memberfunction;  // do not re-init the -stack in this director method
    - -%initstack   Class;       -        // init the stack on all -the methods of this class
    - -%initstack;   // all director functions will -re-init the stack
    +
    +%initstack Class::memberfunction;   // only re-init the stack in this director method
    +%ignorestack Class::memberfunction; // do not re-init the stack in this director method
    +%initstack Class;                   // init the stack on all the methods of this class
    +%initstack;                         // all director functions will re-init the stack
    +
    From 66599db01d3090379f3f3c793fc04c984cdef964 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 8 Jun 2013 01:41:16 +0100 Subject: [PATCH 217/273] Ruby html docs formatting - modify code snippets to be same as other chapters --- Doc/Manual/Ruby.html | 1461 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 1271 insertions(+), 190 deletions(-) diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 1798d1df7..f1523ecf5 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -220,7 +220,8 @@ file from the Ruby distribution:

    Create a file called extconf.rb that looks like the following:

    -
    require 'mkmf'
    create_makefile('example')
    +
    require 'mkmf'
    +create_makefile('example')
  • @@ -342,7 +343,9 @@ the C++ runtime libraries to the list of libraries linked into your extension, e.g.

    -
    require 'mkmf'
    $libs = append_library($libs, "supc++")
    create_makefile('example')
    +
    require 'mkmf'
    +$libs = append_library($libs, "supc++")
    +create_makefile('example')

    36.2 Building Ruby Extensions under Windows 95/NT

    @@ -417,7 +420,11 @@ Ruby and use the require command as normal. For example if you have this ruby file run.rb:

    -
    # file: run.rb
    require 'Example'

    # Call a c function
    print "Foo = ", Example.Foo, "\n"
    +
    # file: run.rb
    +require 'Example'
    +
    +# Call a c function
    +print "Foo = ", Example.Foo, "\n"

    Ensure the dll just built is in your path or current @@ -516,20 +523,30 @@ example, given the SWIG interface file example.i:

    -
    %module example

    int fact(int n);
    +
    %module example
    +
    +int fact(int n);

    and C source file example.c:

    -
    int fact(int n) {
    if (n == 0)
    return 1;
    return (n * fact(n-1));
    }
    +
    int fact(int n) {
    +  if (n == 0)
    +  return 1;
    +  return (n * fact(n-1));
    +}

    SWIG will generate a method fact in the Example module that can be used like so:

    -
    $ irb
    irb(main):001:0> require 'example'
    true
    irb(main):002:0> Example.fact(4)
    24
    +
    $ irb
    +irb(main):001:0> require 'example'
    +true
    +irb(main):002:0> Example.fact(4)
    +24

    36.3.3 Variable Linking

    @@ -541,20 +558,38 @@ one to set it. For example, the following SWIG interface file declares two global variables:

    -
    // SWIG interface file with global variables
    %module example
    ...
    %inline %{
    extern int variable1;
    extern double Variable2;
    %}
    ...
    +
    // SWIG interface file with global variables
    +%module example
    +...
    +%inline %{
    +  extern int variable1;
    +  extern double Variable2;
    +%}
    +...

    Now look at the Ruby interface:

    -
    $ irb
    irb(main):001:0> require 'Example'
    true
    irb(main):002:0> Example.variable1 = 2
    2
    irb(main):003:0> Example.Variable2 = 4 * 10.3
    41.2
    irb(main):004:0> Example.Variable2
    41.2
    +
    $ irb
    +irb(main):001:0> require 'Example'
    +true
    +irb(main):002:0> Example.variable1 = 2
    +2
    +irb(main):003:0> Example.Variable2 = 4 * 10.3
    +41.2
    +irb(main):004:0> Example.Variable2
    +41.2

    If you make an error in variable assignment, you will receive an error message. For example:

    -
    irb(main):005:0> Example.Variable2 = "hello"
    TypeError: no implicit conversion to float from string
    from (irb):5:in `Variable2='
    from (irb):5
    +
    irb(main):005:0> Example.Variable2 = "hello"
    +TypeError: no implicit conversion to float from string
    +from (irb):5:in `Variable2='
    +from (irb):5

    If a variable is declared as const, it @@ -565,7 +600,11 @@ result in an error.

    directive. For example:

    -
    %immutable;
    %inline %{
    extern char *path;
    %}
    %mutable;
    +
    %immutable;
    +%inline %{
    +  extern char *path;
    +%}
    +%mutable;

    The %immutable directive stays in @@ -580,14 +619,24 @@ to the appropriate value. To create a constant, use #define or the %constant directive. For example:

    -
    #define PI 3.14159
    #define VERSION "1.0"

    %constant int FOO = 42;
    %constant const char *path = "/usr/local";

    const int BAR = 32;
    +
    #define PI 3.14159
    +#define VERSION "1.0"
    +
    +%constant int FOO = 42;
    +%constant const char *path = "/usr/local";
    +
    +const int BAR = 32;

    Remember to use the :: operator in Ruby to get at these constant values, e.g.

    -
    $ irb
    irb(main):001:0> require 'Example'
    true
    irb(main):002:0> Example::PI
    3.14159
    +
    $ irb
    +irb(main):001:0> require 'Example'
    +true
    +irb(main):002:0> Example::PI
    +3.14159

    36.3.5 Pointers

    @@ -599,14 +648,16 @@ data objects. So, for example, consider a SWIG interface file containing only the declarations:

    -
    Foo *get_foo();
    void set_foo(Foo *foo);
    +
    Foo *get_foo();
    +void set_foo(Foo *foo);

    For this case, the get_foo() method returns an instance of an internally generated Ruby class:

    -
    irb(main):001:0> foo = Example::get_foo()
    #<SWIG::TYPE_p_Foo:0x402b1654>
    +
    irb(main):001:0> foo = Example::get_foo()
    +#<SWIG::TYPE_p_Foo:0x402b1654>

    A NULL pointer is always represented by @@ -620,7 +671,9 @@ methods (i.e. "getters" and "setters") for all of the struct members. For example, this struct declaration:

    -
    struct Vector {
    double x, y;
    };
    +
    struct Vector {
    +  double x, y;
    +};

    gets wrapped as a Vector class, with @@ -629,7 +682,15 @@ Ruby instance methods x, x=, be used to access structure data from Ruby as follows:

    -
    $ irb
    irb(main):001:0> require 'Example'
    true
    irb(main):002:0> f = Example::Vector.new
    #<Example::Vector:0x4020b268>
    irb(main):003:0> f.x = 10
    nil
    irb(main):004:0> f.x
    10.0
    +
    $ irb
    +irb(main):001:0> require 'Example'
    +true
    +irb(main):002:0> f = Example::Vector.new
    +#<Example::Vector:0x4020b268>
    +irb(main):003:0> f.x = 10
    +nil
    +irb(main):004:0> f.x
    +10.0

    Similar access is provided for unions and the public data @@ -641,7 +702,14 @@ directive (in C++, private may also be used). For example:

    -
    struct Foo {
    ...
    %immutable;
    int x; /* Read-only members */
    char *name;
    %mutable;
    ...
    };
    +
    struct Foo {
    +  ...
    +  %immutable;
    +  int x; /* Read-only members */
    +  char *name;
    +  %mutable;
    +  ...
    +};

    When char * members of a structure are @@ -656,13 +724,17 @@ this is not the behavior you want, you will have to use a typemap this code:

    -
    struct Foo {
    int x[50];
    };
    +
    struct Foo {
    +  int x[50];
    +};

    produces a single accessor function like this:

    -
    int *Foo_x_get(Foo *self) {
    return self->x;
    };
    +
    int *Foo_x_get(Foo *self) {
    +  return self->x;
    +};

    If you want to set an array member, you will need to supply a @@ -675,13 +747,25 @@ structure).

    pointers. For example,

    -
    struct Foo {
    ...
    };

    struct Bar {
    Foo f;
    };
    +
    struct Foo {
    +  ...
    +};
    +
    +struct Bar {
    +  Foo f;
    +};

    generates accessor functions such as this:

    -
    Foo *Bar_f_get(Bar *b) {
    return &b->f;
    }

    void Bar_f_set(Bar *b, Foo *val) {
    b->f = *val;
    }
    +
    Foo *Bar_f_get(Bar *b) {
    +  return &b->f;
    +}
    +
    +void Bar_f_set(Bar *b, Foo *val) {
    +  b->f = *val;
    +}

    36.3.7 C++ classes

    @@ -695,7 +779,17 @@ are wrapped as Ruby singleton methods. So, given the C++ class declaration:

    -
    class List {
    public:
    List();
    ~List();
    int search(char *item);
    void insert(char *item);
    void remove(char *item);
    char *get(int n);
    int length;
    static void print(List *l);
    };
    +
    class List {
    +public:
    +  List();
    +  ~List();
    +  int search(char *item);
    +  void insert(char *item);
    +  void remove(char *item);
    +  char *get(int n);
    +  int length;
    +  static void print(List *l);
    +};

    SWIG would create a List class with:

    @@ -713,7 +807,20 @@ class.
  • In Ruby, these functions are used as follows:

    -
    require 'Example'

    l = Example::List.new

    l.insert("Ale")
    l.insert("Stout")
    l.insert("Lager")
    Example.print(l)
    l.length()
    ----- produces the following output
    Lager
    Stout
    Ale
    3
    +
    require 'Example'
    +
    +l = Example::List.new
    +
    +l.insert("Ale")
    +l.insert("Stout")
    +l.insert("Lager")
    +Example.print(l)
    +l.length()
    +----- produces the following output 
    +Lager
    +Stout
    +Ale
    +3

    36.3.8 C++ Inheritance

    @@ -723,7 +830,13 @@ class. Therefore, if you have classes like this:

    -
    class Parent {
    ...
    };

    class Child : public Parent {
    ...
    };
    +
    class Parent {
    +  ...
    +};
    +
    +class Child : public Parent {
    +  ...
    +};

    those classes are wrapped into a hierarchy of Ruby classes @@ -731,7 +844,20 @@ that reflect the same inheritance structure. All of the usual Ruby utility methods work normally:

    -
    irb(main):001:0> c = Child.new
    #<Bar:0x4016efd4>
    irb(main):002:0> c.instance_of? Child
    true
    irb(main):003:0> b.instance_of? Parent
    false
    irb(main):004:0> b.is_a? Child
    true
    irb(main):005:0> b.is_a? Parent
    true
    irb(main):006:0> Child < Parent
    true
    irb(main):007:0> Child > Parent
    false
    +
    irb(main):001:0> c = Child.new
    +#<Bar:0x4016efd4>
    +irb(main):002:0> c.instance_of? Child
    +true
    +irb(main):003:0> b.instance_of? Parent
    +false
    +irb(main):004:0> b.is_a? Child
    +true
    +irb(main):005:0> b.is_a? Parent
    +true
    +irb(main):006:0> Child < Parent
    +true
    +irb(main):007:0> Child > Parent
    +false

    Furthermore, if you have a function like this:

    @@ -752,7 +878,10 @@ additional base classes are ignored. As an example, consider a SWIG interface file with a declaration like this:

    -
    class Derived : public Base1, public Base2
    {
    ...
    };
    +
    class Derived : public Base1, public Base2
    +{
    +  ...
    +};

    For this case, the resulting Ruby class (Derived) @@ -764,7 +893,8 @@ relationship would fail). When SWIG processes this interface file, you'll see a warning message like:

    -
    example.i:5: Warning 802: Warning for Derived: Base Base2 ignored.
    Multiple inheritance is not supported in Ruby.
    +
    example.i:5: Warning 802: Warning for Derived: Base Base2 ignored.
    +Multiple inheritance is not supported in Ruby.

    Starting with SWIG 1.3.20, the Ruby module for SWIG provides @@ -783,7 +913,10 @@ $ swig -c++ -ruby -minherit example.i contains a declaration like this:

    -
    class Derived : public Base1, public Base2
    {
    ...
    };
    +
    class Derived : public Base1, public Base2
    +{
    +  ...
    +};

    and you run SWIG with the -minherit @@ -797,7 +930,28 @@ modules that the actual instance methods for the classes are defined, i.e.

    -
    class Base1
    module Impl
    # Define Base1 methods here
    end
    include Impl
    end

    class Base2
    module Impl
    # Define Base2 methods here
    end
    include Impl
    end

    class Derived
    module Impl
    include Base1::Impl
    include Base2::Impl
    # Define Derived methods here
    end
    include Impl
    end
    +
    class Base1
    +  module Impl
    +  # Define Base1 methods here
    +  end
    +  include Impl
    +end
    +
    +class Base2
    +  module Impl
    +  # Define Base2 methods here
    +  end
    +  include Impl
    +end
    +
    +class Derived
    +  module Impl
    +  include Base1::Impl
    +  include Base2::Impl
    +  # Define Derived methods here
    +  end
    +  include Impl
    +end

    Observe that after the nested Impl @@ -811,7 +965,9 @@ operation, neither Base1 nor Base2 is a true superclass of Derived anymore:

    -
    obj = Derived.new
    obj.is_a? Base1 # this will return false...
    obj.is_a? Base2 # ... and so will this
    +
    obj = Derived.new
    +obj.is_a? Base1 # this will return false...
    +obj.is_a? Base2 # ... and so will this

    In most cases, this is not a serious problem since objects of @@ -828,38 +984,48 @@ mostly supported by SWIG. For example, if you have two functions like this:

    -
    void foo(int);
    void foo(char *c);
    +
    void foo(int);
    +void foo(char *c);

    You can use them in Ruby in a straightforward manner:

    -
    irb(main):001:0> foo(3) # foo(int)
    irb(main):002:0> foo("Hello") # foo(char *c)
    +
    irb(main):001:0> foo(3) # foo(int)
    +irb(main):002:0> foo("Hello") # foo(char *c)

    Similarly, if you have a class like this,

    -
    class Foo {
    public:
    Foo();
    Foo(const Foo &);
    ...
    };
    +
    class Foo {
    +public:
    +  Foo();
    +  Foo(const Foo &);
    +  ...
    +};

    you can write Ruby code like this:

    -
    irb(main):001:0> f = Foo.new # Create a Foo
    irb(main):002:0> g = Foo.new(f) # Copy f
    +
    irb(main):001:0> f = Foo.new # Create a Foo
    +irb(main):002:0> g = Foo.new(f) # Copy f

    Overloading support is not quite as flexible as in C++. Sometimes there are methods that SWIG can't disambiguate. For example:

    -
    void spam(int);
    void spam(short);
    +
    void spam(int);
    +void spam(short);

    or

    -
    void foo(Bar *b);
    void foo(Bar &b);
    +
    void foo(Bar *b);
    +void foo(Bar &b);

    If declarations such as these appear, you will get a warning @@ -869,21 +1035,26 @@ message like this:

     example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
     example.i:11: Warning 509: as it is shadowed by spam(int).
    -
    -
    +

    To fix this, you either need to ignore or rename one of the methods. For example:

    -
    %rename(spam_short) spam(short);
    ...
    void spam(int);
    void spam(short); // Accessed as spam_short
    +
    %rename(spam_short) spam(short);
    +...
    +void spam(int); 
    +void spam(short); // Accessed as spam_short

    or

    -
    %ignore spam(short);
    ...
    void spam(int);
    void spam(short); // Ignored
    +
    %ignore spam(short);
    +...
    +void spam(int); 
    +void spam(short); // Ignored

    SWIG resolves overloaded functions and methods using a @@ -903,7 +1074,11 @@ automatically by SWIG and do not require any special treatment on your part. So if your class declares an overloaded addition operator, e.g.

    -
    class Complex {
    ...
    Complex operator+(Complex &);
    ...
    };
    +
    class Complex {
    +  ...
    +  Complex operator+(Complex &);
    +  ...
    +};

    the resulting Ruby class will also support the addition (+) @@ -916,13 +1091,17 @@ to do is give the operator the name of a valid Ruby identifier. For example:

    -
    %rename(add_complex) operator+(Complex &, Complex &);
    ...
    Complex operator+(Complex &, Complex &);
    +
    %rename(add_complex) operator+(Complex &, Complex &);
    +...
    +Complex operator+(Complex &, Complex &);

    Now, in Ruby, you can do this:

    -
    a = Example::Complex.new(2, 3)
    b = Example::Complex.new(4, -1)
    c = Example.add_complex(a, b)
    +
    a = Example::Complex.new(2, 3)
    +b = Example::Complex.new(4, -1)
    +c = Example.add_complex(a, b)

    More details about wrapping C++ operators into Ruby operators @@ -938,13 +1117,29 @@ broken up into submodules or packages. For example, if you have a file like this,

    -
    %module example

    namespace foo {
    int fact(int n);
    struct Vector {
    double x,y,z;
    };
    };
    +
    %module example
    +
    +namespace foo {
    +  int fact(int n);
    +  struct Vector {
    +    double x,y,z;
    +  };
    +};

    it works in Ruby as follows:

    -
    irb(main):001:0> require 'example'
    true
    irb(main):002:0> Example.fact(3)
    6
    irb(main):003:0> v = Example::Vector.new
    #<Example::Vector:0x4016f4d4>
    irb(main):004:0> v.x = 3.4
    3.4
    irb(main):004:0> v.y
    0.0
    +
    irb(main):001:0> require 'example'
    +true
    +irb(main):002:0> Example.fact(3)
    +6
    +irb(main):003:0> v = Example::Vector.new
    +#<Example::Vector:0x4016f4d4>
    +irb(main):004:0> v.x = 3.4
    +3.4
    +irb(main):004:0> v.y
    +0.0

    If your program has more than one namespace, name conflicts @@ -952,7 +1147,15 @@ like this,

    example:

    -
    %rename(Bar_spam) Bar::spam;

    namespace Foo {
    int spam();
    }

    namespace Bar {
    int spam();
    }
    +
    %rename(Bar_spam) Bar::spam;
    +
    +namespace Foo {
    +  int spam();
    +}
    +
    +namespace Bar {
    +  int spam();
    +}

    If you have more than one namespace and your want to keep @@ -971,13 +1174,37 @@ for a particular template instantiation. To do this, you use the %template

    -
    %module example

    %{
    #include "pair.h"
    %}

    template<class T1, class T2>
    struct pair {
    typedef T1 first_type;
    typedef T2 second_type;
    T1 first;
    T2 second;
    pair();
    pair(const T1&, const T2&);
    ~pair();
    };

    %template(Pairii) pair<int,int>;
    +
    %module example
    +
    +%{
    +#include "pair.h"
    +%}
    +
    +template<class T1, class T2>
    +struct pair {
    +  typedef T1 first_type;
    +  typedef T2 second_type;
    +  T1 first;
    +  T2 second;
    +  pair();
    +  pair(const T1&, const T2&);
    +  ~pair();
    +};
    +
    +%template(Pairii) pair<int,int>;

    In Ruby:

    -
    irb(main):001:0> require 'example'
    true
    irb(main):002:0> p = Example::Pairii.new(3, 4)
    #<Example:Pairii:0x4016f4df>
    irb(main):003:0> p.first
    3
    irb(main):004:0> p.second
    4
    +
    irb(main):001:0> require 'example'
    +true
    +irb(main):002:0> p = Example::Pairii.new(3, 4)
    +#<Example:Pairii:0x4016f4df>
    +irb(main):003:0> p.first
    +3
    +irb(main):004:0> p.second
    +4

    36.3.13 C++ Standard Template Library (STL)

    @@ -994,7 +1221,9 @@ of standard C++ templates. For example, suppose the C++ library you're wrapping has a function that expects a vector of floats:

    -
    %module example

    float sum(const std::vector<float>& values);
    +
    %module example
    +
    +float sum(const std::vector<float>& values);

    Rather than go through the hassle of writing an "in" typemap @@ -1003,7 +1232,10 @@ std::vector<float>, you can just use the std_vector.i module from the standard SWIG library:

    -
    %module example

    %include std_vector.i
    float sum(const std::vector<float>& values);
    +
    %module example
    +
    +%include std_vector.i
    +float sum(const std::vector<float>& values);

    Ruby's STL wrappings provide additional methods to make them @@ -1012,7 +1244,17 @@ behave more similarly to Ruby's native classes.

    Thus, you can do, for example:

    -
    v = IntVector.new
    v << 2

    v << 3
    v << 4
    v.each { |x| puts x }

    => 2

    3
    4
    v.delete_if { |x| x == 3 }
    => [2,4]
    +
    v = IntVector.new
    +v << 2
    +v << 3
    +v << 4
    +v.each { |x| puts x }
    +
    +=> 2
    +3
    +4
    +v.delete_if { |x| x == 3 }
    +=> [2,4]

    The SWIG Ruby module provides also the ability for all the STL @@ -1107,7 +1349,7 @@ a << 1 a << 2 a << 3 a -=> [1,2,3] +=> [1,2,3] # Custom sorting behavior defined by a Ruby proc b = IntSet.new( proc { |a,b| a > b } ) @@ -1115,7 +1357,7 @@ b << 1 b << 2 b << 3 b -=>  [3,2,1] +=>  [3,2,1]

    @@ -1211,19 +1453,30 @@ involves the use of a template class that implements operator->() like this:

    -
    template<class T> class SmartPtr {
    ...
    T *operator->();
    ...
    }
    +
    template<class T> class SmartPtr {
    +  ...
    +  T *operator->();
    +  ...
    +}

    Then, if you have a class like this,

    -
    class Foo {
    public:
    int x;
    int bar();
    };
    +
    class Foo {
    +public:
    +  int x;
    +  int bar();
    +};

    A smart pointer would be used in C++ as follows:

    -
    SmartPtr<Foo> p = CreateFoo(); // Created somehow (not shown)
    ...
    p->x = 3; // Foo::x
    int y = p->bar(); // Foo::bar
    +
    SmartPtr<Foo> p = CreateFoo(); // Created somehow (not shown)
    +...
    +p->x = 3; // Foo::x
    +int y = p->bar(); // Foo::bar

    To wrap this in Ruby, simply tell SWIG about the SmartPtr @@ -1232,13 +1485,20 @@ instantiate SmartPtr using %template if necessary. For example:

    -
    %module example
    ...
    %template(SmartPtrFoo) SmartPtr<Foo>;
    ...
    +
    %module example
    +...
    +%template(SmartPtrFoo) SmartPtr<Foo>;
    +...

    Now, in Ruby, everything should just "work":

    -
    irb(main):001:0> p = Example::CreateFoo() # Create a smart-pointer somehow
    #<Example::SmartPtrFoo:0x4016f4df>
    irb(main):002:0> p.x = 3 # Foo::x
    3
    irb(main):003:0> p.bar() # Foo::bar
    +
    irb(main):001:0> p = Example::CreateFoo() # Create a smart-pointer somehow
    +#<Example::SmartPtrFoo:0x4016f4df>
    +irb(main):002:0> p.x = 3 # Foo::x
    +3
    +irb(main):003:0> p.bar() # Foo::bar

    If you ever need to access the underlying pointer returned by @@ -1246,7 +1506,7 @@ if necessary. For example:

    method. For example:

    -
    irb(main):004:0> f = p.__deref__() # Returns underlying Foo *
    +
    irb(main):004:0> f = p.__deref__() # Returns underlying Foo *

    36.3.17 Cross-Language Polymorphism

    @@ -1271,7 +1531,9 @@ directive to indicate what action should be taken when a Ruby exception is raised. The following code should suffice in most cases:

    -
    %feature("director:except") {
    throw Swig::DirectorMethodException($error);
    }
    +
    %feature("director:except") {
    +  throw Swig::DirectorMethodException($error);
    +}

    When this feature is activated, the call to the Ruby instance @@ -1329,7 +1591,22 @@ add a new method of the aliased name that calls the original function. For example:

    -
    class MyArray {
    public:
    // Construct an empty array
    MyArray();

    // Return the size of this array
    size_t length() const;
    };

    %extend MyArray {
    // MyArray#size is an alias for MyArray#length
    size_t size() const {
    return $self->length();
    }
    }
    +
    class MyArray {
    +public:
    +  // Construct an empty array
    +  MyArray();
    +
    +  // Return the size of this array
    +  size_t length() const;
    +};
    +
    +%extend MyArray {
    +  // MyArray#size is an alias for MyArray#length
    +  size_t size() const {
    +    return $self->length();
    +  }
    +}
    + 

    A better solution is to use the %alias @@ -1337,7 +1614,17 @@ directive (unique to SWIG's Ruby module). The previous example could then be rewritten as:

    -
    // MyArray#size is an alias for MyArray#length
    %alias MyArray::length "size";

    class MyArray {
    public:
    // Construct an empty array
    MyArray();

    // Return the size of this array
    size_t length() const;
    };

    +
    // MyArray#size is an alias for MyArray#length
    +%alias MyArray::length "size";
    +
    +class MyArray {
    +public:
    +  // Construct an empty array
    +  MyArray();
    + 
    +  // Return the size of this array
    +  size_t length() const;
    +};

    Multiple aliases can be associated with a method by providing @@ -1382,7 +1669,11 @@ type to Ruby's true or false. For example:

    -
    %rename("is_it_safe?") is_it_safe();

    %typemap(out) int is_it_safe
    "$result = ($1 != 0) ? Qtrue : Qfalse;";

    int is_it_safe();

    +
    %rename("is_it_safe?") is_it_safe();
    +
    +%typemap(out) int is_it_safe "$result = ($1 != 0) ? Qtrue : Qfalse;";
    +
    +int is_it_safe();

    A better solution is to use the %predicate @@ -1390,13 +1681,16 @@ directive (unique to SWIG's Ruby module) to designate a method as a predicate method. For the previous example, this would look like:

    -
    %predicate is_it_safe();

    int is_it_safe();

    +
    %predicate is_it_safe();
    +
    +int is_it_safe();

    This method would be invoked from Ruby code like this:

    -
    irb(main):001:0> Example::is_it_safe?
    true

    +
    irb(main):001:0> Example::is_it_safe?
    +true

    The %predicate directive is implemented @@ -1420,7 +1714,9 @@ directive which is unique to the Ruby module and was introduced in SWIG 1.3.28. For example:

    -
    %bang sort(int arr[]);

    int sort(int arr[]);
    +
    %bang sort(int arr[]);
    +
    +int sort(int arr[]); 

    This method would be invoked from Ruby code like this:

    @@ -1441,7 +1737,14 @@ Features") for more details).

    getter and setter methods. For example:

    -
    class Foo {
    Foo() {}

    int getValue() { return value_; }

    void setValue(int value) { value_ = value; }

    private:
    int value_;
    };
    +
    class Foo {
    +  Foo() {}
    +  int getValue() { return value_; }
    +  void setValue(int value) { value_ = value; }
    +
    +private:
    +  int value_;
    +};

    By default, SWIG will expose these methods to Ruby as get_value @@ -1450,13 +1753,16 @@ methods to be exposed in Ruby as value and value=. That allows the methods to be used like this:

    -
    irb(main):001:0> foo = Foo.new()
    irb(main):002:0> foo.value = 5
    irb(main):003:0> puts foo.value
    +
    irb(main):001:0> foo = Foo.new()
    +irb(main):002:0> foo.value = 5
    +irb(main):003:0> puts foo.value

    This can be done by using the %rename directive:

    -
    %rename("value") Foo::getValue();
    %rename("value=") Foo::setValue(int value);
    +
    %rename("value") Foo::getValue();
    +%rename("value=") Foo::setValue(int value);

    36.5 Input and output parameters

    @@ -1466,20 +1772,42 @@ methods to be exposed in Ruby as value and value=. passed as simple pointers. For example:

    -
    void add(int x, int y, int *result) {
    *result = x + y;
    }
    or
    int sub(int *x, int *y) {
    return *x-*y;
    }
    +
    void add(int x, int y, int *result) {
    +  *result = x + y;
    +}
    +
    + +

    +or +

    + +
    +
    +int sub(int *x, int *y) {
    +  return *x-*y;
    +}

    The easiest way to handle these situations is to use the typemaps.i file. For example:

    -
    %module Example
    %include "typemaps.i"

    void add(int, int, int *OUTPUT);
    int sub(int *INPUT, int *INPUT);
    +
    %module Example
    +%include "typemaps.i"
    +
    +void add(int, int, int *OUTPUT);
    +int sub(int *INPUT, int *INPUT);

    In Ruby, this allows you to pass simple values. For example:

    -
    a = Example.add(3,4)
    puts a
    7
    b = Example.sub(7,4)
    puts b
    3
    +
    a = Example.add(3,4)
    +puts a
    +7
    +b = Example.sub(7,4)
    +puts b
    +3

    Notice how the INPUT parameters allow @@ -1491,26 +1819,39 @@ or OUTPUT, use the %apply directive. For example:

    -
    %module Example
    %include "typemaps.i"

    %apply int *OUTPUT { int *result };
    %apply int *INPUT { int *x, int *y};

    void add(int x, int y, int *result);
    int sub(int *x, int *y);
    +
    %module Example
    +%include "typemaps.i"
    +
    +%apply int *OUTPUT { int *result };
    +%apply int *INPUT { int *x, int *y};
    +
    +void add(int x, int y, int *result);
    +int sub(int *x, int *y);

    If a function mutates one of its parameters like this,

    -
    void negate(int *x) {
    *x = -(*x);
    }
    +
    void negate(int *x) {
    + *x = -(*x);
    +}

    you can use INOUT like this:

    -
    %include "typemaps.i"
    ...
    void negate(int *INOUT);
    +
    %include "typemaps.i"
    +...
    +void negate(int *INOUT);

    In Ruby, a mutated parameter shows up as a return value. For example:

    -
    a = Example.negate(3)
    print a
    -3

    +
    a = Example.negate(3)
    +print a
    +-3

    The most common use of these special typemap rules is to @@ -1518,21 +1859,30 @@ handle functions that return more than one value. For example, sometimes a function returns a result as well as a special error code:

    -
    /* send message, return number of bytes sent, success code, and error_code */
    int send_message(char *text, int *success, int *error_code);
    +
    /* send message, return number of bytes sent, success code, and error_code */
    +int send_message(char *text, int *success, int *error_code);

    To wrap such a function, simply use the OUTPUT rule above. For example:

    -
    %module example
    %include "typemaps.i"
    ...
    int send_message(char *, int *OUTPUT, int *OUTPUT);
    +
    %module example
    +%include "typemaps.i"
    +...
    +int send_message(char *, int *OUTPUT, int *OUTPUT);

    When used in Ruby, the function will return an array of multiple values.

    -
    bytes, success, error_code = send_message("Hello World")
    if not success
    print "error #{error_code} : in send_message"
    else
    print "Sent", bytes
    end
    +
    bytes, success, error_code = send_message("Hello World")
    +if not success
    +  print "error #{error_code} : in send_message"
    +else
    +  print "Sent", bytes
    +end

    Another way to access multiple return values is to use the %apply @@ -1541,13 +1891,17 @@ related to SWIG as OUTPUT values through the use of %apply

    -
    %module Example
    %include "typemaps.i"
    %apply int *OUTPUT { int *rows, int *columns };
    ...
    void get_dimensions(Matrix *m, int *rows, int*columns);
    +
    %module Example
    +%include "typemaps.i"
    +%apply int *OUTPUT { int *rows, int *columns };
    +...
    +void get_dimensions(Matrix *m, int *rows, int*columns);

    In Ruby:

    -
    r, c = Example.get_dimensions(m)
    +
    r, c = Example.get_dimensions(m)

    36.6 Exception handling

    @@ -1563,7 +1917,44 @@ Features contains more details, but suppose you have a C++ class like the following :

    -
    class DoubleArray {
    private:
    int n;
    double *ptr;
    public:
    // Create a new array of fixed size
    DoubleArray(int size) {
    ptr = new double[size];
    n = size;
    }

    // Destroy an array
    ~DoubleArray() {
    delete ptr;
    }

    // Return the length of the array
    int length() {
    return n;
    }

    // Get an array item and perform bounds checking.
    double getitem(int i) {
    if ((i >= 0) && (i < n))
    return ptr[i];
    else
    throw RangeError();
    }

    // Set an array item and perform bounds checking.
    void setitem(int i, double val) {
    if ((i >= 0) && (i < n))
    ptr[i] = val;
    else {
    throw RangeError();
    }
    }
    };
    +
    class DoubleArray {
    +private:
    +  int n;
    +  double *ptr;
    +public:
    +  // Create a new array of fixed size
    +  DoubleArray(int size) {
    +    ptr = new double[size];
    +    n = size;
    +  }
    + 
    +  // Destroy an array
    +  ~DoubleArray() {
    +    delete ptr;
    +  } 
    + 
    +  // Return the length of the array
    +  int length() {
    +    return n;
    +  }
    + 
    +  // Get an array item and perform bounds checking.
    +  double getitem(int i) {
    +    if ((i >= 0) && (i < n))
    +      return ptr[i];
    +    else
    +      throw RangeError();
    +  }
    + 
    +  // Set an array item and perform bounds checking.
    +  void setitem(int i, double val) {
    +    if ((i >= 0) && (i < n))
    +      ptr[i] = val;
    +    else {
    +      throw RangeError();
    +    }
    +  }
    +};

    Since several methods in this class can throw an exception @@ -1571,7 +1962,19 @@ for an out-of-bounds access, you might want to catch this in the Ruby extension by writing the following in an interface file:

    -
    %exception {
    try {
    $action
    }
    catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error.");
    }
    }

    class DoubleArray {
    ...
    };
    +
    %exception {
    +  try {
    +    $action
    +  }
    +  catch (const RangeError&) {
    +    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    +    rb_raise(cpperror, "Range error.");
    +  }
    +}
    +
    +class DoubleArray {
    +  ...
    +};

    The exception handling code is inserted directly into @@ -1586,7 +1989,23 @@ consider refining the exception handler to only apply to specific methods like this:

    -
    %exception getitem {
    try {
    $action
    }
    catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error in getitem.");
    }
    }

    %exception setitem {
    try {
    $action
    }
    catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error in setitem.");
    }
    }
    +
    %exception getitem {
    +  try {
    +    $action
    +  } catch (const RangeError&) {
    +    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    +    rb_raise(cpperror, "Range error in getitem.");
    +  }
    +}
    + 
    +%exception setitem {
    +  try {
    +    $action
    +  } catch (const RangeError&) {
    +    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    +    rb_raise(cpperror, "Range error in setitem.");
    +  }
    +}

    In this case, the exception handler is only attached to @@ -1612,12 +2031,23 @@ after the C++ class' constructor was called. 

    For example, this yields the class over after its construction: -
    -

    -
    class Window
    {
    public:
    Window(int x, int y, int w, int h);
    // .... other methods here ....
    };

    // Add support for yielding self in the Class' constructor.
    %exception Window::Window {
    $action
    if (rb_block_given_p()) {
    rb_yield(self);
    }
    }
    +
    class Window
    +{
    +public:
    + Window(int x, int y, int w, int h);
    +// .... other methods here ....
    +};
    +
    +// Add support for yielding self in the Class' constructor.
    +%exception Window::Window {
    +  $action
    +  if (rb_block_given_p()) {
    +    rb_yield(self);
    +  }
    +}

    Then, in ruby, it can be used like:

    @@ -1630,8 +2060,6 @@ Window.new(0,0,360,480) { |w| -
    -

    For other methods, you can usually use a dummy parameter with a special in typemap, like:

    @@ -1825,17 +2253,30 @@ This allows C++ exceptions to be directly mapped to Ruby exceptions, providing for a more natural integration between C++ code and Ruby code.

    -
    	%exceptionclass CustomError;

    %inline %{
    class CustomError { };

    class Foo {
    public:
    void test() { throw CustomError; }
    };
    }
    +
    %exceptionclass CustomError;
    +
    +%inline %{
    +  class CustomError { };
    +
    +  class Foo { 
    +  public:
    +    void test() { throw CustomError; }
    +  };
    +%}

    From Ruby you can now call this method like this:

    -
    foo = Foo.new
    begin
    foo.test()
    rescue CustomError => e
    puts "Caught custom error"
    end
    +
    foo = Foo.new
    +begin
    +  foo.test()
    +rescue CustomError => e
    +  puts "Caught custom error"
    +end 

    For another example look at swig/Examples/ruby/exception_class. -

    36.7 Typemaps

    @@ -1882,7 +2323,11 @@ patterns that the typemap will match. The general form of this list is as follows:

    -
    typelist : typepattern [, typepattern, typepattern, ... ] ;

    typepattern : type [ (parms) ]
    | type name [ (parms) ]
    | ( typelist ) [ (parms) ]
    +
    typelist : typepattern [, typepattern, typepattern, ... ] ;
    +
    +typepattern : type [ (parms) ]
    +  | type name [ (parms) ]
    +  | ( typelist ) [ (parms) ]

    Each type pattern is either a simple type, a simple type and @@ -1895,14 +2340,25 @@ will be explained shortly.

    typemap. It can take any one of the following forms:

    -
    code : { ... }
    | " ... "
    | %{ ... %}
    +
    code : { ... }
    +  | " ... "
    +  | %{ ... %}

    For example, to convert integers from Ruby to C, you might define a typemap like this:

    -
    %module example

    %typemap(in) int {
    $1 = (int) NUM2INT($input);
    printf("Received an integer : %d\n",$1);
    }

    %inline %{
    extern int fact(int n);
    %}
    +
    %module example
    +
    +%typemap(in) int {
    +  $1 = (int) NUM2INT($input);
    +  printf("Received an integer : %d\n",$1);
    +}
    +
    +%inline %{
    +  extern int fact(int n);
    +%}

    Typemaps are always associated with some specific aspect of @@ -1918,7 +2374,9 @@ The $input variable is the input Ruby object.

    following sample code:

    -
    require 'example'

    puts Example.fact(6)
    +
    require 'example'
    +
    +puts Example.fact(6)

    prints the result:

    @@ -1935,7 +2393,16 @@ the int datatype. You can refine this by supplying an optional parameter name. For example:

    -
    %module example

    %typemap(in) int n {
    $1 = (int) NUM2INT($input);
    printf("n = %d\n",$1);
    }

    %inline %{
    extern int fact(int n);
    %}
    +
    %module example
    +
    +%typemap(in) int n {
    +  $1 = (int) NUM2INT($input);
    +  printf("n = %d\n",$1);
    +}
    +
    +%inline %{
    +  extern int fact(int n);
    +%}

    In this case, the typemap code is only attached to arguments @@ -1950,7 +2417,13 @@ addition, the typemap system follows typedef declarations. For example:

    -
    %typemap(in) int n {
    $1 = (int) NUM2INT($input);
    printf("n = %d\n",$1);
    }

    typedef int Integer;
    extern int fact(Integer n); // Above typemap is applied
    +
    %typemap(in) int n {
    +  $1 = (int) NUM2INT($input);
    +  printf("n = %d\n",$1);
    +}
    +
    +typedef int Integer;
    +extern int fact(Integer n); // Above typemap is applied

    However, the matching of typedef only @@ -1961,7 +2434,12 @@ it is not applied to arguments of type int.

    arguments. For example:

    -
    %typemap(in) (char *str, int len) {
    $1 = StringValuePtr($input);
    $2 = (int) RSTRING($input)->len;
    };

    int count(char c, char *str, int len);
    +
    %typemap(in) (char *str, int len) {
    +  $1 = StringValuePtr($input);
    +  $2 = (int) RSTRING($input)->len;
    +};
    +
    +int count(char c, char *str, int len);

    When a multi-argument typemap is defined, the arguments are @@ -1969,7 +2447,8 @@ always handled as a single Ruby object. This allows the function count to be used as follows (notice how the length parameter is omitted):

    -
    puts Example.count('o','Hello World')
    2
    +
    puts Example.count('o','Hello World')
    +2

    36.7.2 Typemap scope

    @@ -1980,7 +2459,20 @@ declarations that follow. A typemap may be redefined for different sections of an input file. For example:

    -
    // typemap1
    %typemap(in) int {
    ...
    }

    int fact(int); // typemap1
    int gcd(int x, int y); // typemap1

    // typemap2
    %typemap(in) int {
    ...
    }

    int isprime(int); // typemap2
    +
    // typemap1
    +%typemap(in) int {
    +  ...
    +}
    +
    +int fact(int); // typemap1
    +int gcd(int x, int y); // typemap1
    +
    +// typemap2
    +%typemap(in) int {
    +  ...
    +}
    +
    +int isprime(int); // typemap2

    One exception to the typemap scoping rules pertains to the @@ -1991,7 +2483,18 @@ block are subject to the typemap rules that are in effect at the point where the class itself is defined. For example:

    -
    class Foo {
    ...
    };

    %typemap(in) int {
    ...
    }

    %extend Foo {
    int blah(int x); // typemap has no effect. Declaration is attached to Foo which
    // appears before the %typemap declaration.
    };
    +
    class Foo {
    +  ...
    +};
    +
    +%typemap(in) int {
    +  ...
    +}
    +
    +%extend Foo {
    +  int blah(int x); // typemap has no effect. Declaration is attached to Foo which 
    +  // appears before the %typemap declaration.
    +};

    36.7.3 Copying a typemap

    @@ -2000,27 +2503,31 @@ where the class itself is defined. For example:

    A typemap is copied by using assignment. For example:

    -
    %typemap(in) Integer = int;
    +
    %typemap(in) Integer = int;

    or this:

    -
    %typemap(in) Integer, Number, int32_t = int;
    +
    %typemap(in) Integer, Number, int32_t = int;

    Types are often managed by a collection of different typemaps. For example:

    -
    %typemap(in) int { ... }
    %typemap(out) int { ... }
    %typemap(varin) int { ... }
    %typemap(varout) int { ... }
    +
    %typemap(in) int { ... }
    +%typemap(out) int { ... }
    +%typemap(varin) int { ... }
    +%typemap(varout) int { ... }

    To copy all of these typemaps to a new type, use %apply. For example:

    -
    %apply int { Integer }; // Copy all int typemaps to Integer
    %apply int { Integer, Number }; // Copy all int typemaps to both Integer and Number
    +
    %apply int { Integer }; // Copy all int typemaps to Integer
    +%apply int { Integer, Number }; // Copy all int typemaps to both Integer and Number

    The patterns for %apply follow the same @@ -2028,7 +2535,8 @@ rules as for %typemap. For example:

    -
    %apply int *output { Integer *output }; // Typemap with name
    %apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments
    +
    %apply int *output { Integer *output }; // Typemap with name
    +%apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments

    36.7.4 Deleting a typemap

    @@ -2038,14 +2546,17 @@ rules as for example:

    -
    %typemap(in) int; // Clears typemap for int
    %typemap(in) int, long, short; // Clears typemap for int, long, short
    %typemap(in) int *output;
    +
    %typemap(in) int; // Clears typemap for int
    +%typemap(in) int, long, short; // Clears typemap for int, long, short
    +%typemap(in) int *output; 

    The %clear directive clears all typemaps for a given type. For example:

    -
    %clear int; // Removes all types for int
    %clear int *output, long *output;
    +
    %clear int; // Removes all types for int
    +%clear int *output, long *output;

    Note: Since SWIG's default behavior is @@ -2060,7 +2571,24 @@ typemaps immediately after the clear operation.

    within a C++ namespace, and within a C++ class. For example:

    -
    %typemap(in) int {
    ...
    }

    namespace std {
    class string;
    %typemap(in) string {
    ...
    }
    }

    class Bar {
    public:
    typedef const int & const_reference;
    %typemap(out) const_reference {
    ...
    }
    };
    +
    %typemap(in) int {
    +  ...
    +}
    +
    +namespace std {
    +  class string;
    +  %typemap(in) string {
    +    ...
    +  }
    +}
    +
    +class Bar {
    +public:
    +  typedef const int & const_reference;
    +  %typemap(out) const_reference {
    +    ...
    +  }
    +};

    When a typemap appears inside a namespace or class, it stays @@ -2068,14 +2596,31 @@ in effect until the end of the SWIG input (just like before). However, the typemap takes the local scope into account. Therefore, this code

    -
    namespace std {
    class string;
    %typemap(in) string {
    ...
    }
    }
    +
    namespace std {
    +  class string;
    +  %typemap(in) string {
    +    ...
    +  }
    +}

    is really defining a typemap for the type std::string. You could have code like this:

    -
    namespace std {
    class string;
    %typemap(in) string { /* std::string */
    ...
    }
    }

    namespace Foo {
    class string;
    %typemap(in) string { /* Foo::string */
    ...
    }
    }
    +
    namespace std {
    +  class string;
    +  %typemap(in) string { /* std::string */
    +  ...
    +  }
    +}
    +
    +namespace Foo {
    +  class string;
    +  %typemap(in) string { /* Foo::string */
    +  ...
    +  }
    +}

    In this case, there are two completely distinct typemaps that @@ -2104,7 +2649,9 @@ function arguments. For example:

    -
    %typemap(in) int {
    $1 = NUM2INT($input);
    }
    +
    %typemap(in) int {
    +  $1 = NUM2INT($input);
    +}

    The following special variables are available:

    @@ -2153,7 +2700,10 @@ it can be used to implement customized conversions.

    arguments to be specified. For example:

    -
    // Ignored argument.
    %typemap(in, numinputs=0) int *out (int temp) {
    $1 = &temp;
    }
    +
    // Ignored argument.
    +%typemap(in, numinputs=0) int *out (int temp) {
    +  $1 = &temp;
    +}

    At this time, only zero or one arguments may be converted.

    @@ -2166,7 +2716,9 @@ functions and methods. It merely checks an argument to see whether or not it matches a specific type. For example:

    -
    %typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) int {
    $1 = FIXNUM_P($input) ? 1 : 0;
    }
    +
    %typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) int {
    +  $1 = FIXNUM_P($input) ? 1 : 0;
    +}

    For typechecking, the $1 variable is always a simple integer @@ -2184,11 +2736,11 @@ on "Typemaps and Overloading."

    Converts return value of a C function to a Ruby object.

    -

    -%typemap(out) int {
    -   $result = INT2NUM( $1 );
    -}
    -
    +
    +
    %typemap(out) int {
    +  $result = INT2NUM( $1 );
    +}
    +

    The following special variables are available.

    @@ -2238,7 +2790,10 @@ normally necessary, but might be useful in highly specialized applications. For example:

    -
    // Set argument to NULL before any conversion occurs
    %typemap(arginit) int *data {
    $1 = NULL;
    }
    +
    // Set argument to NULL before any conversion occurs
    +%typemap(arginit) int *data {
    +  $1 = NULL;
    +}

    36.7.6.5 "default" typemap

    @@ -2248,7 +2803,11 @@ applications. For example:

    default argument. For example:

    -
    %typemap(default) int flags {
    $1 = DEFAULT_FLAGS;
    }
    ...
    int foo(int x, int y, int flags);
    +
    %typemap(default) int flags {
    +  $1 = DEFAULT_FLAGS;
    +}
    +...
    +int foo(int x, int y, int flags);

    The primary use of this typemap is to either change the @@ -2270,7 +2829,11 @@ during argument conversion. The typemap is applied after arguments have been converted. For example:

    -
    %typemap(check) int positive {
    if ($1 <= 0) {
    SWIG_exception(SWIG_ValueError,"Expected positive value.");
    }
    }
    +
    %typemap(check) int positive {
    +  if ($1 <= 0) {
    +    SWIG_exception(SWIG_ValueError,"Expected positive value.");
    +  }
    +}

    36.7.6.7 "argout" typemap

    @@ -2283,7 +2846,15 @@ combined with an "in" typemap---possibly to ignore the input value. For example:

    -
    /* Set the input argument to point to a temporary variable */
    %typemap(in, numinputs=0) int *out (int temp) {
    $1 = &temp;
    }

    %typemap(argout, fragment="output_helper") int *out {
    // Append output value $1 to $result (assuming a single integer in this case)
    $result = output_helper( $result, INT2NUM(*$1) );
    }
    +
    /* Set the input argument to point to a temporary variable */
    +%typemap(in, numinputs=0) int *out (int temp) {
    + $1 = &temp;
    +}
    +
    +%typemap(argout, fragment="output_helper") int *out {
    +  // Append output value $1 to $result (assuming a single integer in this case)
    +  $result = output_helper( $result, INT2NUM(*$1) );
    +}

    The following special variables are available.

    @@ -2329,7 +2900,15 @@ usually cleans up argument resources allocated by the "in" typemap. For example:

    -
    // Get a list of integers
    %typemap(in) int *items {
    int nitems = Length($input);
    $1 = (int *) malloc(sizeof(int)*nitems);
    }
    // Free the list
    %typemap(freearg) int *items {
    free($1);
    }
    +
    // Get a list of integers
    +%typemap(in) int *items {
    +  int nitems = Length($input); 
    +  $1 = (int *) malloc(sizeof(int)*nitems);
    +}
    +// Free the list 
    +%typemap(freearg) int *items {
    +  free($1);
    +}

    The "freearg" typemap inserted at the end of the wrapper @@ -2346,7 +2925,17 @@ directive and is used to deallocate memory used by the return result of a function. For example:

    -
    %typemap(newfree) string * {
    delete $1;
    }
    %typemap(out) string * {
    $result = PyString_FromString($1->c_str());
    }
    ...

    %newobject foo;
    ...
    string *foo();
    +
    %typemap(newfree) string * {
    +  delete $1;
    +}
    +%typemap(out) string * {
    +  $result = PyString_FromString($1->c_str());
    +}
    +...
    +
    +%newobject foo;
    +...
    +string *foo();

    See Object @@ -2361,7 +2950,9 @@ typically used to handle array members and other special cases. For example:

    -
    %typemap(memberin) int [4] {
    memmove($1, $input, 4*sizeof(int));
    }
    +
    %typemap(memberin) int [4] {
    +  memmove($1, $input, 4*sizeof(int));
    +}

    It is rarely necessary to write "memberin" typemaps---SWIG @@ -2395,7 +2986,11 @@ other typemaps as it is based around the exception type rather than the type of a parameter or variable. For example:

    -
    %typemap(throws) const char * %{
    rb_raise(rb_eRuntimeError, $1);
    SWIG_fail;
    %}
    void bar() throw (const char *);
    +
    %typemap(throws) const char * %{
    +  rb_raise(rb_eRuntimeError, $1);
    +  SWIG_fail;
    +%}
    +void bar() throw (const char *);

    As can be seen from the generated code below, SWIG generates @@ -2403,7 +2998,15 @@ an exception handler with the catch block comprising the "throws" typemap content.

    -
    ...
    try {
    bar();
    }
    catch(char const *_e) {
    rb_raise(rb_eRuntimeError, _e);
    SWIG_fail;
    }
    ...
    +
    ...
    +try {
    +  bar();
    +}
    +catch(char const *_e) {
    +  rb_raise(rb_eRuntimeError, _e);
    +  SWIG_fail;
    +}
    +...

    Note that if your methods do not have an exception @@ -2420,11 +3023,11 @@ of the "in" typemap, making its typemap rule often similar to the "out" typemap.

    -

    -%typemap(directorin) int {
    -     $result = INT2NUM($1);
    -}
    -
    +
    +%typemap(directorin) int {
    +  $result = INT2NUM($1);
    +}
    +

    The following special variables are available.

    @@ -2685,8 +3288,8 @@ across multiple languages.

    RUBYSWIGRUBYSWIG