From 753120d76b8b967cacee8fca33cf2c9161d81bb3 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Fri, 22 Mar 2013 15:47:41 +0400 Subject: [PATCH 001/732] interfaces (1) --- Source/Modules/csharp.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 4ef62d2cc..9821e2c95 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -79,6 +79,7 @@ class CSHARP:public Language { String *director_method_types; // Director method types String *director_connect_parms; // Director delegates parameter list for director connect call String *destructor_call; //C++ destructor call if any + String *interface_code; // Director method stuff: List *dmethods_seq; @@ -130,6 +131,7 @@ public: variable_name(NULL), proxy_class_constants_code(NULL), module_class_constants_code(NULL), + interface_code(0), enum_code(NULL), dllimport(NULL), namespce(NULL), @@ -1843,7 +1845,9 @@ public: * ---------------------------------------------------------------------- */ virtual int classHandler(Node *n) { - + String* old_interface_code = interface_code; + interface_code = NewStringEmpty(); + bool isInterface = GetFlag(n, "feature:interface") != 0; String *nspace = getNSpace(); File *f_proxy = NULL; if (proxy_flag) { @@ -1887,7 +1891,6 @@ public: // Start writing out the proxy class file emitBanner(f_proxy); - addOpenNamespace(nspace, f_proxy); Clear(proxy_class_def); @@ -1980,6 +1983,8 @@ public: destructor_call = NULL; Delete(proxy_class_constants_code); proxy_class_constants_code = NULL; + Delete(interface_code); + interface_code = old_interface_code; } return SWIG_OK; From 0898d6435d453d1034bf6bd097001b241d3d4f8d Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Sun, 14 Apr 2013 04:53:03 +0400 Subject: [PATCH 002/732] interfaces (1) --- Source/Modules/csharp.cxx | 173 ++++++++++++++++++++++++++++---------- 1 file changed, 127 insertions(+), 46 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 4ef62d2cc..b5d978674 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -51,6 +51,7 @@ class CSHARP:public Language { String *imclass_class_code; // intermediary class code String *proxy_class_def; String *proxy_class_code; + String *interface_class_code; // if %feature("interface") was declared for a class, here goes the interface declaration String *module_class_code; String *proxy_class_name; // proxy class name String *full_proxy_class_name;// fully qualified proxy class name when using nspace feature, otherwise same as proxy_class_name @@ -121,6 +122,7 @@ public: imclass_name(NULL), module_class_name(NULL), imclass_class_code(NULL), + interface_class_code(NULL), proxy_class_def(NULL), proxy_class_code(NULL), module_class_code(NULL), @@ -1577,7 +1579,39 @@ public: } return Language::pragmaDirective(n); } + String* getQualifiedInterfaceName(Node* n) + { + // TODO: qualified interface name //getProxyName(Getattr(base.item, "name")) + return Getattr(n, "feature:interface:name"); + } + void addInterfaceNameAndUpcasts(String* interface_list, String* interface_upcasts, Iterator base, String* c_baseclass, String* c_classname) { + String* iname = getQualifiedInterfaceName(base.item); + if (Len(interface_list)) + Append(interface_list, ", "); + Append(interface_list, iname); + Printf(interface_upcasts, " [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]\n"); + String* upcast_name = 0; + if (String* cptr_func = Getattr(base.item, "feature:interface:cptr")) + upcast_name = NewStringf("%s.%s", iname, cptr_func); + else + upcast_name = NewStringf("%s.GetCPtr", iname); + Printf(interface_upcasts, " IntPtr %s()", upcast_name); + Replaceall(upcast_name, ".", "_"); + String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, upcast_name); + String *wname = Swig_name_wrapper(upcast_method); + Printf(interface_upcasts, "{ return %s.%s(swigCPtr.Handle); }\n", imclass_name, upcast_method ); + Printv(imclass_cppcasts_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); + Printf(imclass_cppcasts_code, " public static extern IntPtr %s(IntPtr jarg1);\n", upcast_method); + Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); + Printv(upcasts_code, + "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n", + " return (", c_baseclass, " *)jarg1;\n" + "}\n", "\n", NIL); + Delete(upcast_name); + Delete(wname); + Delete(upcast_method); + } /* ----------------------------------------------------------------------------- * emitProxyClassDefAndCPPCasts() * ----------------------------------------------------------------------------- */ @@ -1587,6 +1621,8 @@ public: String *c_baseclass = NULL; String *baseclass = NULL; String *c_baseclassname = NULL; + String *interface_list = NewStringEmpty(); + String *interface_upcasts = NewStringEmpty(); SwigType *typemap_lookup_type = Getattr(n, "classtypeobj"); bool feature_director = Swig_directorclass(n) ? true : false; @@ -1605,6 +1641,10 @@ public: while (base.item && GetFlag(base.item, "feature:ignore")) { base = Next(base); } + while (base.item && Getattr(base.item, "feature:interface")) { + addInterfaceNameAndUpcasts(interface_list, interface_upcasts, base, c_baseclass, c_classname); + base = Next(base); + } if (base.item) { c_baseclassname = Getattr(base.item, "name"); baseclass = Copy(getProxyName(c_baseclassname)); @@ -1613,14 +1653,14 @@ public: base = Next(base); /* Warn about multiple inheritance for additional base class(es) */ while (base.item) { - if (GetFlag(base.item, "feature:ignore")) { - base = Next(base); - continue; - } - String *proxyclassname = Getattr(n, "classtypeobj"); - String *baseclassname = Getattr(base.item, "name"); - Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), - "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname)); + if (Getattr(base.item, "feature:interface")) { + addInterfaceNameAndUpcasts(interface_list, interface_upcasts, base, c_baseclass, c_classname); + } else if (!GetFlag(base.item, "feature:ignore")) { + String *proxyclassname = Getattr(n, "classtypeobj"); + String *baseclassname = Getattr(base.item, "name"); + Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), + "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname)); + } base = Next(base); } } @@ -1647,6 +1687,9 @@ public: // Pure C# interfaces const String *pure_interfaces = typemapLookup(n, derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE); + if (*Char(interface_list) && *Char(pure_interfaces)) + Append(interface_list, ", "); + Append(interface_list, pure_interfaces); // Start writing the proxy class Printv(proxy_class_def, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", NIL); @@ -1658,8 +1701,8 @@ public: Printv(proxy_class_def, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " $csclassname", // Class name and base class - (*Char(wanted_base) || *Char(pure_interfaces)) ? " : " : "", wanted_base, (*Char(wanted_base) && *Char(pure_interfaces)) ? // Interfaces - ", " : "", pure_interfaces, " {", derived ? typemapLookup(n, "csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class + (*Char(wanted_base) || *Char(interface_list)) ? " : " : "", wanted_base, (*Char(wanted_base) && *Char(interface_list)) ? // Interfaces + ", " : "", interface_list, " {", derived ? typemapLookup(n, "csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class NIL); @@ -1704,6 +1747,8 @@ public: Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " ", derived ? "override" : "virtual", " void ", destruct_methodname, "() ", destruct, "\n", NIL); } + if (*Char(interface_upcasts)) + Printv(proxy_class_def, interface_upcasts, NIL); if (feature_director) { // Generate director connect method @@ -1785,6 +1830,7 @@ public: Delete(director_connect_method_name); } + Delete(interface_list); Delete(attributes); Delete(destruct); @@ -1838,6 +1884,38 @@ public: Delete(baseclass); } + static void emitInterfaceDeclaration(Node* n, String* iname, File* f_interface) + { + Printf(f_interface, "public interface %s", iname); + if (List *baselist = Getattr(n, "bases")) { + String* bases = 0; + for (Iterator base = First(baselist); base.item; base = Next(base)) { + if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface")) + continue; // TODO: warn about skipped non-interface bases + String* base_iname = Getattr(base.item, "feature:interface:name"); + if (!base_iname) { + Swig_error(Getfile(n), Getline(n), "interface %s has a base interface %s w/o name attribute", iname, Getattr(base.item, "name")); + continue; + } + if (!bases) + bases = NewStringf(" : %s", base_iname); + else { + Append(bases, ", "); + Append(bases, base_iname); + } + } + if (bases) { + Printv(f_interface, bases, NIL); + Delete(bases); + } + } + Printf(f_interface, " {\n"); + Printf(f_interface, " [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]\n"); + if (String* cptr_func = Getattr(n, "feature:interface:cptr")) + Printf(f_interface, " IntPtr %s();\n", cptr_func); + else + Printf(f_interface, " IntPtr GetCPtr();\n"); + } /* ---------------------------------------------------------------------- * classHandler() * ---------------------------------------------------------------------- */ @@ -1846,6 +1924,9 @@ public: String *nspace = getNSpace(); File *f_proxy = NULL; + File *f_interface = NULL; + String *old_interface_class_code = interface_class_code; + interface_class_code = 0; if (proxy_flag) { proxy_class_name = NewString(Getattr(n, "sym:name")); @@ -1883,18 +1964,32 @@ public: } Append(filenames_list, Copy(filen)); Delete(filen); - filen = NULL; // Start writing out the proxy class file emitBanner(f_proxy); - addOpenNamespace(nspace, f_proxy); Clear(proxy_class_def); Clear(proxy_class_code); - destructor_call = NewString(""); - proxy_class_constants_code = NewString(""); + destructor_call = NewStringEmpty(); + proxy_class_constants_code = NewStringEmpty(); + if (Getattr(n, "feature:interface")) { + interface_class_code = NewStringEmpty(); + String* iname = Copy(Getattr(n, "feature:interface:name")); + if (!iname) + iname = NewStringf("I%s", proxy_class_name); + filen = NewStringf("%s%s.cs", output_directory, iname); + f_interface = NewFile(filen, "w", SWIG_output_files()); + if (!f_interface) { + FileErrorDisplay(filen); + SWIG_exit(EXIT_FAILURE); + } + Append(filenames_list, filen); // file name ownership goes to the list + emitBanner(f_interface); + addOpenNamespace(nspace, f_interface); + emitInterfaceDeclaration(n, iname, f_interface); + } } Language::classHandler(n); @@ -1934,41 +2029,16 @@ public: Printf(f_proxy, "}\n"); addCloseNamespace(nspace, f_proxy); Delete(f_proxy); - f_proxy = NULL; - - /* Output the downcast method, if necessary. Note: There's no other really - good place to put this code, since Abstract Base Classes (ABCs) can and should have - downcasts, making the constructorHandler() a bad place (because ABCs don't get to - have constructors emitted.) */ - if (GetFlag(n, "feature:javadowncast")) { - String *downcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGDowncast"); - String *wname = Swig_name_wrapper(downcast_method); - - String *norm_name = SwigType_namestr(Getattr(n, "name")); - - Printf(imclass_class_code, " public final static native %s %s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, downcast_method); - - Wrapper *dcast_wrap = NewWrapper(); - - Printf(dcast_wrap->def, "SWIGEXPORT jobject SWIGSTDCALL %s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {", wname); - Printf(dcast_wrap->code, " Swig::Director *director = (Swig::Director *) 0;\n"); - Printf(dcast_wrap->code, " jobject jresult = (jobject) 0;\n"); - Printf(dcast_wrap->code, " %s *obj = *((%s **)&jCPtrBase);\n", norm_name, norm_name); - Printf(dcast_wrap->code, " if (obj) director = dynamic_cast(obj);\n"); - Printf(dcast_wrap->code, " if (director) jresult = director->swig_get_self(jenv);\n"); - Printf(dcast_wrap->code, " return jresult;\n"); - Printf(dcast_wrap->code, "}\n"); - - Wrapper_print(dcast_wrap, f_wrappers); - DelWrapper(dcast_wrap); - - Delete(norm_name); - Delete(wname); - Delete(downcast_method); + if (f_interface) { + Printv(f_interface, interface_class_code, "}\n", NIL); + addCloseNamespace(nspace, f_interface); + Delete(f_interface); } emitDirectorExtraMethods(n); + Delete(interface_class_code); + interface_class_code = old_interface_class_code; Delete(csclazzname); Delete(proxy_class_name); proxy_class_name = NULL; @@ -2053,6 +2123,7 @@ public: String *pre_code = NewString(""); String *post_code = NewString(""); String *terminator_code = NewString(""); + bool is_interface = Getattr(parentNode(n), "feature:interface") != 0 && !static_flag; if (!proxy_flag) return; @@ -2136,6 +2207,9 @@ public: if (static_flag) Printf(function_code, "static "); Printf(function_code, "%s %s(", return_type, proxy_function_name); + if (is_interface) + Printf(interface_class_code, " %s %s(", return_type, proxy_function_name); + Printv(imcall, full_imclass_name, ".$imfuncname(", NIL); if (!static_flag) @@ -2215,10 +2289,15 @@ public: } /* Add parameter to proxy function */ - if (gencomma >= 2) + if (gencomma >= 2) { Printf(function_code, ", "); + if (is_interface) + Printf(interface_class_code, ", "); + } gencomma = 2; Printf(function_code, "%s %s", param_type, arg); + if (is_interface) + Printf(interface_class_code, "%s %s", param_type, arg); Delete(arg); Delete(param_type); @@ -2228,6 +2307,8 @@ public: Printf(imcall, ")"); Printf(function_code, ")"); + if (is_interface) + Printf(interface_class_code, ");\n"); // Transform return type used in PInvoke function (in intermediary class) to type used in C# wrapper function (in proxy class) if ((tm = Swig_typemap_lookup("csout", n, "", 0))) { From 9c317fae903ef4fb0cc7ac3388cbdfa0290a7968 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Tue, 16 Apr 2013 23:53:21 +0400 Subject: [PATCH 003/732] namespace support added GetCPtr now returns HandleRef "feature:interface:name" is now mandatory attribute --- Source/Modules/csharp.cxx | 59 +++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index b5d978674..ea977e10b 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1581,26 +1581,37 @@ public: } String* getQualifiedInterfaceName(Node* n) { - // TODO: qualified interface name //getProxyName(Getattr(base.item, "name")) - return Getattr(n, "feature:interface:name"); + String* ret; + String *nspace = Getattr(n, "sym:nspace"); + String *iname = Getattr(n, "feature:interface:name"); + if (nspace) { + if (namespce) + ret = NewStringf("%s.%s.%s", namespce, nspace, iname); + else + ret = NewStringf("%s.%s", nspace, iname); + } else { + ret = Copy(iname); + } + return ret; } - void addInterfaceNameAndUpcasts(String* interface_list, String* interface_upcasts, Iterator base, String* c_baseclass, String* c_classname) { - String* iname = getQualifiedInterfaceName(base.item); + void addInterfaceNameAndUpcasts(String* interface_list, String* interface_upcasts, Node* base, String* c_classname) { + String* c_baseclass = SwigType_namestr(Getattr(base, "name")); + String* iname = getQualifiedInterfaceName(base); if (Len(interface_list)) Append(interface_list, ", "); Append(interface_list, iname); Printf(interface_upcasts, " [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]\n"); String* upcast_name = 0; - if (String* cptr_func = Getattr(base.item, "feature:interface:cptr")) + if (String* cptr_func = Getattr(base, "feature:interface:cptr")) upcast_name = NewStringf("%s.%s", iname, cptr_func); else upcast_name = NewStringf("%s.GetCPtr", iname); - Printf(interface_upcasts, " IntPtr %s()", upcast_name); + Printf(interface_upcasts, " HandleRef %s()", upcast_name); Replaceall(upcast_name, ".", "_"); String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, upcast_name); String *wname = Swig_name_wrapper(upcast_method); - Printf(interface_upcasts, "{ return %s.%s(swigCPtr.Handle); }\n", imclass_name, upcast_method ); + Printf(interface_upcasts, "{ return new HandleRef((%s)this, %s.%s(swigCPtr.Handle)); }\n", iname, imclass_name, upcast_method ); Printv(imclass_cppcasts_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); Printf(imclass_cppcasts_code, " public static extern IntPtr %s(IntPtr jarg1);\n", upcast_method); Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); @@ -1611,6 +1622,8 @@ public: Delete(upcast_name); Delete(wname); Delete(upcast_method); + Delete(iname); + Delete(c_baseclass); } /* ----------------------------------------------------------------------------- * emitProxyClassDefAndCPPCasts() @@ -1642,7 +1655,7 @@ public: base = Next(base); } while (base.item && Getattr(base.item, "feature:interface")) { - addInterfaceNameAndUpcasts(interface_list, interface_upcasts, base, c_baseclass, c_classname); + addInterfaceNameAndUpcasts(interface_list, interface_upcasts, base.item, c_classname); base = Next(base); } if (base.item) { @@ -1654,7 +1667,7 @@ public: /* Warn about multiple inheritance for additional base class(es) */ while (base.item) { if (Getattr(base.item, "feature:interface")) { - addInterfaceNameAndUpcasts(interface_list, interface_upcasts, base, c_baseclass, c_classname); + addInterfaceNameAndUpcasts(interface_list, interface_upcasts, base.item, c_classname); } else if (!GetFlag(base.item, "feature:ignore")) { String *proxyclassname = Getattr(n, "classtypeobj"); String *baseclassname = Getattr(base.item, "name"); @@ -1665,6 +1678,9 @@ public: } } } + if (Getattr(n, "feature:interface")) { + addInterfaceNameAndUpcasts(interface_list, interface_upcasts, n, c_classname); + } } bool derived = baseclass && getProxyName(c_baseclassname); @@ -1884,8 +1900,9 @@ public: Delete(baseclass); } - static void emitInterfaceDeclaration(Node* n, String* iname, File* f_interface) + void emitInterfaceDeclaration(Node* n, String* iname, File* f_interface) { + Printv(f_interface, typemapLookup(n, "csimports", Getattr(n, "classtypeobj"), WARN_NONE), "\n", NIL); Printf(f_interface, "public interface %s", iname); if (List *baselist = Getattr(n, "bases")) { String* bases = 0; @@ -1893,10 +1910,6 @@ public: if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface")) continue; // TODO: warn about skipped non-interface bases String* base_iname = Getattr(base.item, "feature:interface:name"); - if (!base_iname) { - Swig_error(Getfile(n), Getline(n), "interface %s has a base interface %s w/o name attribute", iname, Getattr(base.item, "name")); - continue; - } if (!bases) bases = NewStringf(" : %s", base_iname); else { @@ -1912,9 +1925,9 @@ public: Printf(f_interface, " {\n"); Printf(f_interface, " [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]\n"); if (String* cptr_func = Getattr(n, "feature:interface:cptr")) - Printf(f_interface, " IntPtr %s();\n", cptr_func); + Printf(f_interface, " HandleRef %s();\n", cptr_func); else - Printf(f_interface, " IntPtr GetCPtr();\n"); + Printf(f_interface, " HandleRef GetCPtr();\n"); } /* ---------------------------------------------------------------------- * classHandler() @@ -1976,9 +1989,11 @@ public: proxy_class_constants_code = NewStringEmpty(); if (Getattr(n, "feature:interface")) { interface_class_code = NewStringEmpty(); - String* iname = Copy(Getattr(n, "feature:interface:name")); - if (!iname) - iname = NewStringf("I%s", proxy_class_name); + String* iname = Getattr(n, "feature:interface:name"); + if (!iname) { + Swig_error(Getfile(n), Getline(n), "Interface %s has no name attribute", proxy_class_name); + SWIG_exit(EXIT_FAILURE); + } filen = NewStringf("%s%s.cs", output_directory, iname); f_interface = NewFile(filen, "w", SWIG_output_files()); if (!f_interface) { @@ -2196,8 +2211,10 @@ public: Printf(function_code, " %s ", methodmods); if (!is_smart_pointer()) { // Smart pointer classes do not mirror the inheritance hierarchy of the underlying pointer type, so no virtual/override/new required. - if (Getattr(n, "override")) - Printf(function_code, "override "); + if (Node *base = Getattr(n, "override")) { + if (!Getattr(parentNode(base), "feature:interface")) + Printf(function_code, "override "); + } else if (checkAttribute(n, "storage", "virtual")) Printf(function_code, "virtual "); if (Getattr(n, "hides")) From 1a40b9a1ed4ac0b24eaee5aec410870d8c7cb1d5 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Mon, 20 May 2013 14:11:58 +0400 Subject: [PATCH 004/732] propagate non-abstract "interface" base methods (1) --- Source/Modules/csharp.cxx | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index ea977e10b..9a5bed966 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1929,6 +1929,55 @@ public: else Printf(f_interface, " HandleRef GetCPtr();\n"); } + void collectNonAbstractMethods(Node* n, List* methods) { + if (List *baselist = Getattr(n, "bases")) { + for (Iterator base = First(baselist); base.item; base = Next(base)) { + if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface")) + continue; + for (Node* child = firstChild(base.item); child; child = nextSibling(child)) { + if (strcmp(Char(nodeType(child)), "cdecl") == 0) { + if (GetFlag(child, "feature:ignore") || Getattr(child, "feature:interface:owner") || GetFlag(child, "abstract")) + continue; // skip methods propagated to bases and abstracts + Node* m = Copy(child); + Setattr(m, "feature:interface:owner", base.item); + Append(methods, m); + } + } + collectNonAbstractMethods(base.item, methods); + } + } + } + void propagateInterfaceMethods(Node *n) + { + List* methods = NewList(); + collectNonAbstractMethods(n, methods); + // TODO: filter all the method not implemented in "n" and its bases. + for (Iterator mi = First(methods); mi.item; mi = Next(mi)) { + String *this_decl = Getattr(mi.item, "decl"); + String *resolved_decl = SwigType_typedef_resolve_all(this_decl); + bool overloaded = false; + if (SwigType_isfunction(resolved_decl)) { + String *name = Getattr(mi.item, "name"); + for (Node* child = firstChild(mi.item); child; child = nextSibling(child)) { + if (Getattr(child, "feature:interface:owner")) + break; // at the end of the list are newly appended methods + if (checkAttribute(child, "name", name)) { + String *decl = SwigType_typedef_resolve_all(Getattr(child, "decl")); + overloaded = Strcmp(decl, this_decl) == 0; + Delete(decl); + if (overloaded) + break; + } + } + } + Delete(resolved_decl); + if (!overloaded) + appendChild(n, mi.item); + else + Delete(mi.item); + } + Delete(methods); + } /* ---------------------------------------------------------------------- * classHandler() * ---------------------------------------------------------------------- */ @@ -1987,6 +2036,7 @@ public: destructor_call = NewStringEmpty(); proxy_class_constants_code = NewStringEmpty(); + propagateInterfaceMethods(n); if (Getattr(n, "feature:interface")) { interface_class_code = NewStringEmpty(); String* iname = Getattr(n, "feature:interface:name"); From 9c0ceb2adf178f0c5233459d4f6cc62f82782082 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Mon, 20 May 2013 18:19:46 +0400 Subject: [PATCH 005/732] propagate non-abstract "interface" base methods (2) --- Source/Modules/csharp.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 9a5bed966..52b8371af 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1929,6 +1929,8 @@ public: else Printf(f_interface, " HandleRef GetCPtr();\n"); } + + // collect all not abstract methods from the bases marked as "interface" void collectNonAbstractMethods(Node* n, List* methods) { if (List *baselist = Getattr(n, "bases")) { for (Iterator base = First(baselist); base.item; base = Next(base)) { @@ -1939,6 +1941,8 @@ public: if (GetFlag(child, "feature:ignore") || Getattr(child, "feature:interface:owner") || GetFlag(child, "abstract")) continue; // skip methods propagated to bases and abstracts Node* m = Copy(child); + set_nextSibling(m, NIL); + set_previousSibling(m, NIL); Setattr(m, "feature:interface:owner", base.item); Append(methods, m); } @@ -1947,18 +1951,18 @@ public: } } } + // append all the interface methods not implemented in the current class, so that it would not be abstract void propagateInterfaceMethods(Node *n) { List* methods = NewList(); collectNonAbstractMethods(n, methods); - // TODO: filter all the method not implemented in "n" and its bases. for (Iterator mi = First(methods); mi.item; mi = Next(mi)) { String *this_decl = Getattr(mi.item, "decl"); String *resolved_decl = SwigType_typedef_resolve_all(this_decl); bool overloaded = false; if (SwigType_isfunction(resolved_decl)) { String *name = Getattr(mi.item, "name"); - for (Node* child = firstChild(mi.item); child; child = nextSibling(child)) { + for (Node* child = firstChild(n); child; child = nextSibling(child)) { if (Getattr(child, "feature:interface:owner")) break; // at the end of the list are newly appended methods if (checkAttribute(child, "name", name)) { From a61b45d1a2b9c796b6693fc2352d00bc49ea88a0 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Tue, 21 May 2013 03:49:52 +0400 Subject: [PATCH 006/732] propagate non-abstract "interface" base methods (3) --- Source/Modules/csharp.cxx | 56 +++------------------------------------ Source/Modules/lang.cxx | 55 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 53 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 52b8371af..89722cf8a 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -19,6 +19,8 @@ /* Hash type used for upcalls from C/C++ */ typedef DOH UpcallData; +void Swig_propagate_interface_methods(Node *n); + class CSHARP:public Language { static const char *usage; const String *empty_string; @@ -1930,58 +1932,6 @@ public: Printf(f_interface, " HandleRef GetCPtr();\n"); } - // collect all not abstract methods from the bases marked as "interface" - void collectNonAbstractMethods(Node* n, List* methods) { - if (List *baselist = Getattr(n, "bases")) { - for (Iterator base = First(baselist); base.item; base = Next(base)) { - if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface")) - continue; - for (Node* child = firstChild(base.item); child; child = nextSibling(child)) { - if (strcmp(Char(nodeType(child)), "cdecl") == 0) { - if (GetFlag(child, "feature:ignore") || Getattr(child, "feature:interface:owner") || GetFlag(child, "abstract")) - continue; // skip methods propagated to bases and abstracts - Node* m = Copy(child); - set_nextSibling(m, NIL); - set_previousSibling(m, NIL); - Setattr(m, "feature:interface:owner", base.item); - Append(methods, m); - } - } - collectNonAbstractMethods(base.item, methods); - } - } - } - // append all the interface methods not implemented in the current class, so that it would not be abstract - void propagateInterfaceMethods(Node *n) - { - List* methods = NewList(); - collectNonAbstractMethods(n, methods); - for (Iterator mi = First(methods); mi.item; mi = Next(mi)) { - String *this_decl = Getattr(mi.item, "decl"); - String *resolved_decl = SwigType_typedef_resolve_all(this_decl); - bool overloaded = false; - if (SwigType_isfunction(resolved_decl)) { - String *name = Getattr(mi.item, "name"); - for (Node* child = firstChild(n); child; child = nextSibling(child)) { - if (Getattr(child, "feature:interface:owner")) - break; // at the end of the list are newly appended methods - if (checkAttribute(child, "name", name)) { - String *decl = SwigType_typedef_resolve_all(Getattr(child, "decl")); - overloaded = Strcmp(decl, this_decl) == 0; - Delete(decl); - if (overloaded) - break; - } - } - } - Delete(resolved_decl); - if (!overloaded) - appendChild(n, mi.item); - else - Delete(mi.item); - } - Delete(methods); - } /* ---------------------------------------------------------------------- * classHandler() * ---------------------------------------------------------------------- */ @@ -2040,7 +1990,7 @@ public: destructor_call = NewStringEmpty(); proxy_class_constants_code = NewStringEmpty(); - propagateInterfaceMethods(n); + Swig_propagate_interface_methods(n); if (Getattr(n, "feature:interface")) { interface_class_code = NewStringEmpty(); String* iname = Getattr(n, "feature:interface:name"); diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index eb7d49480..78e959bfc 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -3603,3 +3603,58 @@ Language *Language::instance() { Hash *Language::getClassHash() const { return classhash; } + +// 2 methods below are used in C# && Java module "feature:interface" implementation +// +// Collect all not abstract methods from the bases marked as "interface" +void Swig_collect_non_abstract_methods(Node* n, List* methods) { + if (List *baselist = Getattr(n, "bases")) { + for (Iterator base = First(baselist); base.item; base = Next(base)) { + if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface")) + continue; + for (Node* child = firstChild(base.item); child; child = nextSibling(child)) { + if (strcmp(Char(nodeType(child)), "cdecl") == 0) { + if (GetFlag(child, "feature:ignore") || Getattr(child, "feature:interface:owner") || GetFlag(child, "abstract")) + continue; // skip methods propagated to bases and abstracts + Node* m = Copy(child); + set_nextSibling(m, NIL); + set_previousSibling(m, NIL); + Setattr(m, "feature:interface:owner", base.item); + Append(methods, m); + } + } + Swig_collect_non_abstract_methods(base.item, methods); + } + } +} +// Append all the interface methods not implemented in the current class, so that it would not be abstract +void Swig_propagate_interface_methods(Node *n) +{ + List* methods = NewList(); + Swig_collect_non_abstract_methods(n, methods); + for (Iterator mi = First(methods); mi.item; mi = Next(mi)) { + String *this_decl = Getattr(mi.item, "decl"); + String *resolved_decl = SwigType_typedef_resolve_all(this_decl); + bool overloaded = false; + if (SwigType_isfunction(resolved_decl)) { + String *name = Getattr(mi.item, "name"); + for (Node* child = firstChild(n); child; child = nextSibling(child)) { + if (Getattr(child, "feature:interface:owner")) + break; // at the end of the list are newly appended methods + if (checkAttribute(child, "name", name)) { + String *decl = SwigType_typedef_resolve_all(Getattr(child, "decl")); + overloaded = Strcmp(decl, this_decl) == 0; + Delete(decl); + if (overloaded) + break; + } + } + } + Delete(resolved_decl); + if (!overloaded) + appendChild(n, mi.item); + else + Delete(mi.item); + } + Delete(methods); +} From 766d55255b738b6e6bd6690ab6c2442916a4600b Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Tue, 21 May 2013 20:05:54 +0400 Subject: [PATCH 007/732] feature:interface ported to Java --- Examples/test-suite/java/Makefile.in | 3 +- .../multiple_inheritance_abstract_runme.java | 109 +++++++++++ .../multiple_inheritance_abstract.i | 96 ++++++++++ Lib/csharp/feature_interface.i | 26 +++ Lib/java/feature_interface.i | 28 +++ Source/Modules/csharp.cxx | 40 ++-- Source/Modules/java.cxx | 178 ++++++++++++++++-- 7 files changed, 442 insertions(+), 38 deletions(-) create mode 100644 Examples/test-suite/java/multiple_inheritance_abstract_runme.java create mode 100644 Examples/test-suite/multiple_inheritance_abstract.i create mode 100644 Lib/csharp/feature_interface.i create mode 100644 Lib/java/feature_interface.i diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index e4f3c6b58..4c7fabc1f 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -34,7 +34,8 @@ CPP_TEST_CASES = \ java_prepost \ java_throws \ java_typemaps_proxy \ - java_typemaps_typewrapper + java_typemaps_typewrapper \ + multiple_inheritance_abstract # li_boost_intrusive_ptr include $(srcdir)/../common.mk diff --git a/Examples/test-suite/java/multiple_inheritance_abstract_runme.java b/Examples/test-suite/java/multiple_inheritance_abstract_runme.java new file mode 100644 index 000000000..a3cbdf64f --- /dev/null +++ b/Examples/test-suite/java/multiple_inheritance_abstract_runme.java @@ -0,0 +1,109 @@ +import multiple_inheritance_abstract.*; + +public class multiple_inheritance_abstract_runme { + + static { + try { + System.loadLibrary("multiple_inheritance_abstract"); + } 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); + } + } +//Test base class as a parameter in java +int jfoo1(CBase1 cb1){ +return cb1.foo1(); +} +int jbar1(ABase1 ab1){ +return ab1.bar1(); +} +int jfoo2(CBase2 cb2){ +return cb2.foo2(); +} + public static void main(String argv[]) { + //Test Derived1 + Derived1 d1=new Derived1(); + if(d1.foo1()!=3) + throw new RuntimeException("Derived1::foo1() failed in multiple_inheritance_abstract"); + if(d1.foo2()!=4) + throw new RuntimeException("Derived::foo2() failed in multiple_inheritance_abstract"); +//Test Derived2 + Derived2 d2=new Derived2(); + if(d2.foo1()!=6) + throw new RuntimeException("Derived2::foo1() failed in multiple_inheritance_abstract"); + if(d2.bar1()!=5) + throw new RuntimeException("Derived2::bar1() failed in multiple_inheritance_abstract"); +//Test Derived3 + Derived3 d3=new Derived3(); + if( d3.foo1()!=7) + throw new RuntimeException("Derived3::foo1() failed in multiple_inheritance_abstract"); + if(d3.foo2()!=8) + throw new RuntimeException("Derived3::foo2() failed in multiple_inheritance_abstract"); + if(d3.bar1()!=9) + throw new RuntimeException("Derived3::bar1() failed in multiple_inheritance_abstract"); +//Test interfaces from c++ classes + CBase1 cb1=new SWIGTYPE_CBase1(); + CBase2 cb2=new SWIGTYPE_CBase2(); + if(cb1.foo1()!=1) + throw new RuntimeException("CBase1::foo1() failed in multiple_inheritance_abstract"); + if(cb2.foo2()!=2) + throw new RuntimeException("CBase2::foo2() failed in multiple_inheritance_abstract"); + //Test abstract class as return value + ABase1 ab1=d3.clone(); + if( ab1.bar1()!=9) + throw new RuntimeException("Derived3::bar1() through ABase1 failed in multiple_inheritance_abstract"); +//Test concrete base class as return value + CBase1 cb6=d2.clone(); + CBase2 cb7=d1.clone(); +if(cb6.foo1()!=6) + throw new RuntimeException("Derived2::foo1() through CBase1 failed in multiple_inheritance_abstract"); +if(cb7.foo2()!=4) + throw new RuntimeException("Derived1:foo2() through ABase1 failed in multiple_inheritance_abstract"); + //Test multi inheritance + CBase1 cb3=new Derived1(); + CBase1 cb4=new Derived3(); + CBase2 cb5=new Derived3(); + ABase1 ab6=new Derived2(); + if(cb3.foo1()!=3) + throw new RuntimeException("Derived1::foo1()through CBase1 failed in multiple_inheritance_abstract"); + if(cb4.foo1()!=7) + throw new RuntimeException("Derived3::foo1()through CBase1 failed in multiple_inheritance_abstract"); + if(cb5.foo2()!=8) + throw new RuntimeException("Derived3::foo2()through CBase2 failed in multiple_inheritance_abstract"); + if(ab6.bar1()!=5) + throw new RuntimeException("Derived2::bar1()through ABase1 failed in multiple_inheritance_abstract"); +//Test base classes as parameter in java +multiple_inheritance_abstract_runme mhar=new multiple_inheritance_abstract_runme(); +if(mhar.jfoo1(d1)!=3) + throw new RuntimeException("jfoo1()through Derived1 as parameter failed in multiple_inheritance_abstract"); +if(mhar.jfoo1(d2)!=6) + throw new RuntimeException("jfoo1()through Derived2 as parameter failed in multiple_inheritance_abstract"); +if(mhar.jfoo1(d3)!=7) + throw new RuntimeException("jfoo1()through Derived3 as parameter failed in multiple_inheritance_abstract"); +if(mhar.jfoo2(d1)!=4) + throw new RuntimeException("jfoo2()through Derived1 as parameter failed in multiple_inheritance_abstract"); +if(mhar.jfoo2(d3)!=8) + throw new RuntimeException("jfoo2()through Derived3 as parameter failed in multiple_inheritance_abstract"); +if(mhar.jbar1(d2)!=5) + throw new RuntimeException("jbar1()through Derived2 as parameter failed in multiple_inheritance_abstract"); +if(mhar.jbar1(d3)!=9) + throw new RuntimeException("jbar1()through Derived3 as parameter failed in multiple_inheritance_abstract"); +/*//Test ABase1 as a parameter + if(multiple_inheritance_abstract.foo6(d2)!=5) + throw new RuntimeException("foo6() through Derived2 as a parameter failed in multiple_inheritance_abstract"); +if(multiple_inheritance_abstract.foo6(d3)!=9) + throw new RuntimeException("foo6() through Derived3 as a parameter failed in multiple_inheritance_abstract"); +//Test CBase1 CBase2 as parameters +if(multiple_inheritance_abstract.foo7(d3)!=7) + throw new RuntimeException("foo7() ,Derived3 as a parameter failed in multiple_inheritance_abstract"); +if(multiple_inheritance_abstract.foo7(d1)!=3) + throw new RuntimeException("foo7() ,Derived1 as a parameter failed in multiple_inheritance_abstract"); +if(multiple_inheritance_abstract.foo7(d2)!=6) + throw new RuntimeException("foo7() ,Derived3 as a parameter failed in multiple_inheritance_abstract"); +if(multiple_inheritance_abstract.foo8(d3)!=4) + throw new RuntimeException("foo8() ,Derived3 as a parameter failed in multiple_inheritance_abstract"); +if(multiple_inheritance_abstract.foo8(d1)!=8) + throw new RuntimeException("foo8() ,Derived1 as a parameter failed in multiple_inheritance_abstract");*/ + +} +} diff --git a/Examples/test-suite/multiple_inheritance_abstract.i b/Examples/test-suite/multiple_inheritance_abstract.i new file mode 100644 index 000000000..1750d4275 --- /dev/null +++ b/Examples/test-suite/multiple_inheritance_abstract.i @@ -0,0 +1,96 @@ +%module multiple_inheritance_abstract + +%include "feature_interface.i" +DECLARE_INTERFACE_RENAME(ABase1, ABase1, SWIGTYPE_ABase1) +DECLARE_INTERFACE_RENAME(CBase1, CBase1, SWIGTYPE_CBase1) +DECLARE_INTERFACE_RENAME(CBase2, CBase2, SWIGTYPE_CBase2) + + +%inline %{ +struct CBase1 { +virtual void foo9(){ +return ; +} +virtual int foo1(){ + return 1; +} +int foo3(){ +return 10; +} +virtual ~CBase1(){ +} +}; +struct CBase2{ +virtual int foo2(){ +return 2; +} +virtual ~CBase2(){ +} +}; +struct ABase1{ +virtual int bar1()=0; +virtual ~ABase1(){ +} +}; + +struct Derived1 : CBase2,CBase1{ + virtual int foo1(){ +return 3; +} +virtual void foo9(){ +return; +} +virtual int foo2(){ +return 4; +} +virtual CBase2* clone(){ +return new Derived1(*this); +} +}; +struct Derived2:CBase1,ABase1{ +virtual int bar1(){ +return 5; +} +virtual int foo1(){ +return 6; +} +virtual void foo9(){ +return; +} +virtual CBase1* clone(){ +return new Derived2(*this); +} +}; +struct Derived3:ABase1,CBase1,CBase2{ +virtual int foo1(){ +return 7; +} +virtual int foo2(){ +return 8; +} +virtual int bar1(){ +return 9; +} +virtual void foo9(){ +} +virtual ABase1* clone(){ +return new Derived3(*this); +} +}; +ABase1* foo4(Derived3 d){ +return d.clone(); +} +int foo5(CBase1 cb1,CBase2 cb2){ +return cb1.foo1()+cb2.foo2(); +} +int foo6(ABase1* pab1){ +return pab1->bar1(); +} +int foo7(CBase1* pcb1){ +return pcb1->foo1(); +} +int foo8(CBase2* pcb2){ +return pcb2->foo2(); +} + +%} diff --git a/Lib/csharp/feature_interface.i b/Lib/csharp/feature_interface.i new file mode 100644 index 000000000..6eb25c855 --- /dev/null +++ b/Lib/csharp/feature_interface.i @@ -0,0 +1,26 @@ +%define DECLARE_INTERFACE_(CTYPE, INTERFACE, IMPL) +%feature("interface", name = "INTERFACE", cptr = "GetCPtr") CTYPE; +%typemap(cstype) CTYPE*, const CTYPE& "INTERFACE" +%typemap(csdirectorout) CTYPE*, const CTYPE& "$cscall.GetCPtr()" +%typemap(csdirectorin) CTYPE*, const CTYPE& +%{ + (INTERFACE)new IMPL($iminput,false) +%} +%typemap(csin) CTYPE*, const CTYPE& "$csinput.GetCPtr()" +%typemap(csout, excode=SWIGEXCODE) CTYPE*, const CTYPE& +{ + IMPL ret = new IMPL($imcall,true); + $excode + return (INTERFACE)ret; +} +%enddef + +%define DECLARE_INTERFACE_RENAME(CTYPE, INTERFACE, IMPL) +%rename (IMPL) CTYPE; +DECLARE_INTERFACE_(CTYPE, INTERFACE, IMPL) +%enddef + +%define DECLARE_INTERFACE(CTYPE, INTERFACE) +DECLARE_INTERFACE_(CTYPE, INTERFACE, CTYPE) +%enddef + diff --git a/Lib/java/feature_interface.i b/Lib/java/feature_interface.i new file mode 100644 index 000000000..079747d52 --- /dev/null +++ b/Lib/java/feature_interface.i @@ -0,0 +1,28 @@ +%define DECLARE_INTERFACE_(CTYPE, INTERFACE, IMPL) +%feature("interface", name = "INTERFACE", cptr = #INTERFACE ## "_getCPtr") CTYPE; +%typemap(jstype) CTYPE*, const CTYPE& "INTERFACE" +%typemap(jtype, nopgcpp="1") CTYPE*, const CTYPE& "long" +%typemap(javadirectorout) CTYPE*, const CTYPE& "$javacall." ## #INTERFACE ## "_getCPtr()" +%typemap(javadirectorin) CTYPE*, const CTYPE& +%{ + long cPtr = $jniinput; + return (cPtr == 0) ? null : (INTERFACE)new IMPL(cPtr,false) +%} +%typemap(javain) CTYPE*, const CTYPE& "$javainput." ## #INTERFACE ## "_getCPtr()" +%typemap(javaout) CTYPE*, const CTYPE& +{ + long cPtr = $jnicall; + return (cPtr == 0) ? null : (INTERFACE)new IMPL(cPtr,true); +} +SWIG_JAVABODY_PROXY(public, protected, CTYPE) +%enddef + +%define DECLARE_INTERFACE_RENAME(CTYPE, INTERFACE, IMPL) +%rename (IMPL) CTYPE; +DECLARE_INTERFACE_(CTYPE, INTERFACE, IMPL) +%enddef + +%define DECLARE_INTERFACE(CTYPE, INTERFACE) +DECLARE_INTERFACE_(CTYPE, INTERFACE, CTYPE) +%enddef + diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index aad2dbc14..94ae4f876 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -18,7 +18,7 @@ /* Hash type used for upcalls from C/C++ */ typedef DOH UpcallData; - +// helper function used in feature:interface implementation void Swig_propagate_interface_methods(Node *n); class CSHARP:public Language { @@ -82,7 +82,6 @@ class CSHARP:public Language { String *director_method_types; // Director method types String *director_connect_parms; // Director delegates parameter list for director connect call String *destructor_call; //C++ destructor call if any - String *interface_code; // Director method stuff: List *dmethods_seq; @@ -135,7 +134,6 @@ public: variable_name(NULL), proxy_class_constants_code(NULL), module_class_constants_code(NULL), - interface_code(0), enum_code(NULL), dllimport(NULL), namespce(NULL), @@ -1585,16 +1583,19 @@ public: } String* getQualifiedInterfaceName(Node* n) { - String* ret; - String *nspace = Getattr(n, "sym:nspace"); - String *iname = Getattr(n, "feature:interface:name"); - if (nspace) { - if (namespce) - ret = NewStringf("%s.%s.%s", namespce, nspace, iname); - else - ret = NewStringf("%s.%s", nspace, iname); - } else { - ret = Copy(iname); + String* ret = Getattr(n, "feature:interface:qname"); + if (!ret) { + String *nspace = Getattr(n, "sym:nspace"); + String *iname = Getattr(n, "feature:interface:name"); + if (nspace) { + if (namespce) + ret = NewStringf("%s.%s.%s", namespce, nspace, iname); + else + ret = NewStringf("%s.%s", nspace, iname); + } else { + ret = Copy(iname); + } + Setattr(n, "feature:interface:qname", ret); } return ret; } @@ -1611,7 +1612,7 @@ public: upcast_name = NewStringf("%s.%s", iname, cptr_func); else upcast_name = NewStringf("%s.GetCPtr", iname); - Printf(interface_upcasts, " HandleRef %s()", upcast_name); + Printf(interface_upcasts, " public HandleRef %s()", upcast_name); Replaceall(upcast_name, ".", "_"); String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, upcast_name); String *wname = Swig_name_wrapper(upcast_method); @@ -1626,7 +1627,6 @@ public: Delete(upcast_name); Delete(wname); Delete(upcast_method); - Delete(iname); Delete(c_baseclass); } /* ----------------------------------------------------------------------------- @@ -1850,6 +1850,7 @@ public: Delete(director_connect_method_name); } + Delete(interface_upcasts); Delete(interface_list); Delete(attributes); Delete(destruct); @@ -1939,9 +1940,6 @@ public: * ---------------------------------------------------------------------- */ virtual int classHandler(Node *n) { - String* old_interface_code = interface_code; - interface_code = NewStringEmpty(); - bool isInterface = GetFlag(n, "feature:interface") != 0; String *nspace = getNSpace(); File *f_proxy = NULL; File *f_interface = NULL; @@ -1982,8 +1980,7 @@ public: FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } - Append(filenames_list, Copy(filen)); - Delete(filen); + Append(filenames_list, filen); // Start writing out the proxy class file emitBanner(f_proxy); @@ -2013,6 +2010,7 @@ public: addOpenNamespace(nspace, f_interface); emitInterfaceDeclaration(n, iname, f_interface); } + Delete(output_directory); } Language::classHandler(n); @@ -2073,8 +2071,6 @@ public: destructor_call = NULL; Delete(proxy_class_constants_code); proxy_class_constants_code = NULL; - Delete(interface_code); - interface_code = old_interface_code; } return SWIG_OK; diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index f351c91a3..412533490 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -18,6 +18,8 @@ /* Hash type used for upcalls from C/C++ */ typedef DOH UpcallData; +// helper function used in feature:interface implementation +void Swig_propagate_interface_methods(Node *n); class JAVA:public Language { static const char *usage; @@ -53,6 +55,7 @@ class JAVA:public Language { String *imclass_class_code; // intermediary class code String *proxy_class_def; String *proxy_class_code; + String *interface_class_code; // if %feature("interface") was declared for a class, here goes the interface declaration String *module_class_code; String *proxy_class_name; // proxy class name String *full_proxy_class_name;// fully qualified proxy class name when using nspace feature, otherwise same as proxy_class_name @@ -124,6 +127,7 @@ public: imclass_class_code(NULL), proxy_class_def(NULL), proxy_class_code(NULL), + interface_class_code(NULL), module_class_code(NULL), proxy_class_name(NULL), full_proxy_class_name(NULL), @@ -1698,6 +1702,62 @@ public: return Language::pragmaDirective(n); } + String* getQualifiedInterfaceName(Node* n) + { + String* ret = Getattr(n, "feature:interface:qname"); + if (!ret) { + String *nspace = Getattr(n, "sym:nspace"); + String *symname = Getattr(n, "feature:interface:name"); + if (nspace) { + if (package) + ret = NewStringf("%s.%s.%s", package, nspace, symname); + else + ret = NewStringf("%s.%s", nspace, symname); + } else { + if (package) + ret = NewStringf("%s.%s", package, symname); + else + ret = Copy(symname); + } + Setattr(n, "feature:interface:qname", ret); + } + return ret; + } + void addInterfaceNameAndUpcasts(String* interface_list, String* interface_upcasts, Node* base, String* c_classname) { + String* c_baseclass = SwigType_namestr(Getattr(base, "name")); + String* iname = Getattr(base, "feature:interface:name"); + if (Len(interface_list)) + Append(interface_list, ", "); + Append(interface_list, iname); + + String* upcast_name = 0; + if (String* cptr_func = Getattr(base, "feature:interface:cptr")) + upcast_name = NewStringf("%s", cptr_func); + else + upcast_name = NewStringf("%s_getCPtr", iname); + Printf(interface_upcasts, " public long %s()", upcast_name); + Replaceall(upcast_name, ".", "_"); + String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, upcast_name); + String *jniname = makeValidJniName(upcast_method); + String *wname = Swig_name_wrapper(jniname); + Printf(interface_upcasts, "{ return %s.%s(swigCPtr); }\n", imclass_name, upcast_method ); + Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method); + Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); + Printv(upcasts_code, + "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", + " jlong baseptr = 0;\n" + " (void)jenv;\n" + " (void)jcls;\n" + " *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n" + " return baseptr;\n" + "}\n", "\n", NIL); + Delete(upcast_name); + Delete(wname); + Delete(jniname); + Delete(upcast_method); + Delete(c_baseclass); + } + /* ----------------------------------------------------------------------------- * emitProxyClassDefAndCPPCasts() * ----------------------------------------------------------------------------- */ @@ -1707,6 +1767,8 @@ public: String *c_baseclass = NULL; String *baseclass = NULL; String *c_baseclassname = NULL; + String *interface_list = NewStringEmpty(); + String *interface_upcasts = NewStringEmpty(); SwigType *typemap_lookup_type = Getattr(n, "classtypeobj"); bool feature_director = Swig_directorclass(n) ? true : false; @@ -1725,6 +1787,10 @@ public: while (base.item && GetFlag(base.item, "feature:ignore")) { base = Next(base); } + while (base.item && Getattr(base.item, "feature:interface")) { + addInterfaceNameAndUpcasts(interface_list, interface_upcasts, base.item, c_classname); + base = Next(base); + } if (base.item) { c_baseclassname = Getattr(base.item, "name"); baseclass = Copy(getProxyName(c_baseclassname)); @@ -1733,18 +1799,21 @@ public: base = Next(base); /* Warn about multiple inheritance for additional base class(es) */ while (base.item) { - if (GetFlag(base.item, "feature:ignore")) { - base = Next(base); - continue; - } - String *proxyclassname = Getattr(n, "classtypeobj"); - String *baseclassname = Getattr(base.item, "name"); - Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), - "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname)); + if (Getattr(base.item, "feature:interface")) { + addInterfaceNameAndUpcasts(interface_list, interface_upcasts, base.item, c_classname); + } else if (!GetFlag(base.item, "feature:ignore")) { + String *proxyclassname = Getattr(n, "classtypeobj"); + String *baseclassname = Getattr(base.item, "name"); + Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), + "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname)); + } base = Next(base); } } } + if (Getattr(n, "feature:interface")) { + addInterfaceNameAndUpcasts(interface_list, interface_upcasts, n, c_classname); + } } bool derived = baseclass && getProxyName(c_baseclassname); @@ -1767,13 +1836,15 @@ public: // Pure Java interfaces const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE); - + if (*Char(interface_list) && *Char(pure_interfaces)) + Append(interface_list, ", "); + Append(interface_list, pure_interfaces); // Start writing the proxy class Printv(proxy_class_def, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " $javaclassname", // Class name and bases - (*Char(wanted_base)) ? " extends " : "", wanted_base, *Char(pure_interfaces) ? // Pure Java interfaces - " implements " : "", pure_interfaces, " {", derived ? typemapLookup(n, "javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class + (*Char(wanted_base)) ? " extends " : "", wanted_base, *Char(interface_list) ? // Pure Java interfaces + " implements " : "", interface_list, " {", derived ? typemapLookup(n, "javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class NIL); @@ -1816,6 +1887,8 @@ public: if (*Char(destruct)) Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "()", destructor_throws_clause, " ", destruct, "\n", NIL); } + if (*Char(interface_upcasts)) + Printv(proxy_class_def, interface_upcasts, NIL); /* Insert directordisconnect typemap, if this class has directors enabled */ /* Also insert the swigTakeOwnership and swigReleaseOwnership methods */ @@ -1837,6 +1910,8 @@ public: Delete(take_jnicall); } + Delete(interface_upcasts); + Delete(interface_list); Delete(attributes); Delete(destruct); @@ -1897,13 +1972,53 @@ public: Delete(baseclass); } + void emitInterfaceDeclaration(Node* n, String* iname, File* f_interface, String *nspace) + { + if (package || nspace) { + Printf(f_interface, "package "); + if (package) + Printv(f_interface, package, nspace ? "." : "", NIL); + if (nspace) + Printv(f_interface, nspace, NIL); + Printf(f_interface, ";\n"); + } + + Printv(f_interface, typemapLookup(n, "javaimports", Getattr(n, "classtypeobj"), WARN_NONE), "\n", NIL); + Printf(f_interface, "public interface %s", iname); + if (List *baselist = Getattr(n, "bases")) { + String* bases = 0; + for (Iterator base = First(baselist); base.item; base = Next(base)) { + if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface")) + continue; // TODO: warn about skipped non-interface bases + String* base_iname = Getattr(base.item, "feature:interface:name"); + if (!bases) + bases = NewStringf(" : %s", base_iname); + else { + Append(bases, ", "); + Append(bases, base_iname); + } + } + if (bases) { + Printv(f_interface, "extends ", bases, NIL); + Delete(bases); + } + } + Printf(f_interface, " {\n"); + if (String* cptr_func = Getattr(n, "feature:interface:cptr")) + Printf(f_interface, " long %s();\n", cptr_func); + else + Printf(f_interface, " long %s_getCPtr();\n", iname); + } + /* ---------------------------------------------------------------------- * classHandler() * ---------------------------------------------------------------------- */ virtual int classHandler(Node *n) { - File *f_proxy = NULL; + File *f_interface = NULL; + String *old_interface_class_code = interface_class_code; + interface_class_code = 0; if (proxy_flag) { proxy_class_name = NewString(Getattr(n, "sym:name")); String *nspace = getNSpace(); @@ -1938,8 +2053,7 @@ public: FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } - Append(filenames_list, Copy(filen)); - Delete(filen); + Append(filenames_list, filen); filen = NULL; // Start writing out the proxy class file @@ -1960,6 +2074,24 @@ public: destructor_call = NewString(""); destructor_throws_clause = NewString(""); proxy_class_constants_code = NewString(""); + Swig_propagate_interface_methods(n); + if (Getattr(n, "feature:interface")) { + interface_class_code = NewStringEmpty(); + String* iname = Getattr(n, "feature:interface:name"); + if (!iname) { + Swig_error(Getfile(n), Getline(n), "Interface %s has no name attribute", proxy_class_name); + SWIG_exit(EXIT_FAILURE); + } + filen = NewStringf("%s%s.java", output_directory, iname); + f_interface = NewFile(filen, "w", SWIG_output_files()); + if (!f_interface) { + FileErrorDisplay(filen); + SWIG_exit(EXIT_FAILURE); + } + Append(filenames_list, filen); // file name ownership goes to the list + emitBanner(f_interface); + emitInterfaceDeclaration(n, iname, f_interface, nspace); + } Delete(output_directory); } @@ -2030,6 +2162,11 @@ public: Delete(downcast_method); } + if (f_interface) { + Printv(f_interface, interface_class_code, "}\n", NIL); + Delete(f_interface); + } + emitDirectorExtraMethods(n); Delete(javaclazzname); @@ -2119,6 +2256,7 @@ public: bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); + bool is_interface = Getattr(parentNode(n), "feature:interface") != 0 && !static_flag; if (!proxy_flag) return; @@ -2168,6 +2306,9 @@ public: if (static_flag) Printf(function_code, "static "); Printf(function_code, "%s %s(", return_type, proxy_function_name); + + if (is_interface) + Printf(interface_class_code, " %s %s(", return_type, proxy_function_name); Printv(imcall, full_imclass_name, ".$imfuncname(", NIL); if (!static_flag) { @@ -2255,10 +2396,15 @@ public: } /* Add parameter to proxy function */ - if (gencomma >= 2) + if (gencomma >= 2) { Printf(function_code, ", "); + if (is_interface) + Printf(interface_class_code, ", "); + } gencomma = 2; Printf(function_code, "%s %s", param_type, arg); + if (is_interface) + Printf(interface_class_code, "%s %s", param_type, arg); if (prematureGarbageCollectionPreventionParameter(pt, p)) { String *pgcppname = Getattr(p, "tmap:javain:pgcppname"); @@ -2280,6 +2426,8 @@ public: Printf(imcall, ")"); Printf(function_code, ")"); + if (is_interface) + Printf(interface_class_code, ");\n"); // Transform return type used in JNI function (in intermediary class) to type used in Java wrapper function (in proxy class) if ((tm = Swig_typemap_lookup("javaout", n, "", 0))) { From 5ccf08e3ec4e897d36fbd166523bad675a38a4f3 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Wed, 22 May 2013 00:20:58 +0400 Subject: [PATCH 008/732] interface inheritance (1) --- Source/Modules/java.cxx | 113 +++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 49 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 412533490..280cbe6cc 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1274,8 +1274,10 @@ public: // Add extra indentation Replaceall(enum_code, "\n", "\n "); Replaceall(enum_code, " \n", "\n"); - - Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); + if (GetFlag(getCurrentClass(), "feature:interface")) + Printv(interface_class_code, " ", enum_code, "\n\n", NIL); + else + Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); } else { // Global enums are defined in their own file String *output_directory = outputDirectory(nspace); @@ -1723,39 +1725,58 @@ public: } return ret; } - void addInterfaceNameAndUpcasts(String* interface_list, String* interface_upcasts, Node* base, String* c_classname) { - String* c_baseclass = SwigType_namestr(Getattr(base, "name")); - String* iname = Getattr(base, "feature:interface:name"); - if (Len(interface_list)) - Append(interface_list, ", "); - Append(interface_list, iname); + void addInterfaceNameAndUpcasts(String* interface_list, String* interface_upcasts, Hash* base_list, String* c_classname) { + List* keys = Keys(base_list); + for (Iterator it = First(keys); it.item; it = Next(it)) { + Node* base = Getattr(base_list, it.item); + String* c_baseclass = SwigType_namestr(Getattr(base, "name")); + String* iname = Getattr(base, "feature:interface:name"); + if (Len(interface_list)) + Append(interface_list, ", "); + Append(interface_list, iname); - String* upcast_name = 0; - if (String* cptr_func = Getattr(base, "feature:interface:cptr")) - upcast_name = NewStringf("%s", cptr_func); - else - upcast_name = NewStringf("%s_getCPtr", iname); - Printf(interface_upcasts, " public long %s()", upcast_name); - Replaceall(upcast_name, ".", "_"); - String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, upcast_name); - String *jniname = makeValidJniName(upcast_method); - String *wname = Swig_name_wrapper(jniname); - Printf(interface_upcasts, "{ return %s.%s(swigCPtr); }\n", imclass_name, upcast_method ); - Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method); - Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); - Printv(upcasts_code, - "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", - " jlong baseptr = 0;\n" - " (void)jenv;\n" - " (void)jcls;\n" - " *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n" - " return baseptr;\n" - "}\n", "\n", NIL); - Delete(upcast_name); - Delete(wname); - Delete(jniname); - Delete(upcast_method); - Delete(c_baseclass); + String* upcast_name = 0; + if (String* cptr_func = Getattr(base, "feature:interface:cptr")) + upcast_name = NewStringf("%s", cptr_func); + else + upcast_name = NewStringf("%s_getCPtr", iname); + Printf(interface_upcasts, " public long %s()", upcast_name); + Replaceall(upcast_name, ".", "_"); + String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, upcast_name); + String *jniname = makeValidJniName(upcast_method); + String *wname = Swig_name_wrapper(jniname); + Printf(interface_upcasts, "{ return %s.%s(swigCPtr); }\n", imclass_name, upcast_method ); + Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method); + Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); + Printv(upcasts_code, + "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", + " jlong baseptr = 0;\n" + " (void)jenv;\n" + " (void)jcls;\n" + " *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n" + " return baseptr;\n" + "}\n", "\n", NIL); + Delete(upcast_name); + Delete(wname); + Delete(jniname); + Delete(upcast_method); + Delete(c_baseclass); + } + Delete(keys); + Delete(base_list); + } + + void collectInterfaceBases(Hash* bases, Node* n) { + if (Getattr(n, "feature:interface")) { + String* name = Getattr(n, "feature:interface:name"); + if (Getattr(bases, name)) + return; + Setattr(bases, name, n); + } + if (List *baselist = Getattr(n, "bases")) { + for (Iterator base = First(baselist); base.item; base = Next(base)) + collectInterfaceBases(bases, base.item); + } } /* ----------------------------------------------------------------------------- @@ -1780,17 +1801,13 @@ public: Delete(attributes); // C++ inheritance + List* interface_classes = NewHash(); if (!purebase_replace) { List *baselist = Getattr(n, "bases"); if (baselist) { Iterator base = First(baselist); - while (base.item && GetFlag(base.item, "feature:ignore")) { + while (base.item && (GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface"))) base = Next(base); - } - while (base.item && Getattr(base.item, "feature:interface")) { - addInterfaceNameAndUpcasts(interface_list, interface_upcasts, base.item, c_classname); - base = Next(base); - } if (base.item) { c_baseclassname = Getattr(base.item, "name"); baseclass = Copy(getProxyName(c_baseclassname)); @@ -1799,9 +1816,7 @@ public: base = Next(base); /* Warn about multiple inheritance for additional base class(es) */ while (base.item) { - if (Getattr(base.item, "feature:interface")) { - addInterfaceNameAndUpcasts(interface_list, interface_upcasts, base.item, c_classname); - } else if (!GetFlag(base.item, "feature:ignore")) { + if (!GetFlag(base.item, "feature:ignore") && !Getattr(base.item, "feature:interface")) { String *proxyclassname = Getattr(n, "classtypeobj"); String *baseclassname = Getattr(base.item, "name"); Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), @@ -1811,10 +1826,9 @@ public: } } } - if (Getattr(n, "feature:interface")) { - addInterfaceNameAndUpcasts(interface_list, interface_upcasts, n, c_classname); - } } + collectInterfaceBases(interface_classes, n); + addInterfaceNameAndUpcasts(interface_list, interface_upcasts, interface_classes, c_classname); bool derived = baseclass && getProxyName(c_baseclassname); if (derived && purebase_notderived) @@ -1988,18 +2002,19 @@ public: if (List *baselist = Getattr(n, "bases")) { String* bases = 0; for (Iterator base = First(baselist); base.item; base = Next(base)) { - if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface")) + if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface")) { continue; // TODO: warn about skipped non-interface bases + } String* base_iname = Getattr(base.item, "feature:interface:name"); if (!bases) - bases = NewStringf(" : %s", base_iname); + bases = Copy(base_iname); else { Append(bases, ", "); Append(bases, base_iname); } } if (bases) { - Printv(f_interface, "extends ", bases, NIL); + Printv(f_interface, " extends ", bases, NIL); Delete(bases); } } From 77bb7673ed23c6b8d7d7485011f31661cd728437 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Wed, 22 May 2013 18:47:45 +0400 Subject: [PATCH 009/732] interface inheritance (2) --- Source/Modules/csharp.cxx | 80 +++++++++++++++++++-------------------- Source/Modules/java.cxx | 24 +++--------- Source/Modules/lang.cxx | 52 +++++++++++++++++++------ 3 files changed, 85 insertions(+), 71 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 94ae4f876..64e3301cf 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1599,35 +1599,40 @@ public: } return ret; } - void addInterfaceNameAndUpcasts(String* interface_list, String* interface_upcasts, Node* base, String* c_classname) { - String* c_baseclass = SwigType_namestr(Getattr(base, "name")); - String* iname = getQualifiedInterfaceName(base); - if (Len(interface_list)) - Append(interface_list, ", "); - Append(interface_list, iname); + void addInterfaceNameAndUpcasts(String* interface_list, String* interface_upcasts, Hash* base_list, String* c_classname) { + List* keys = Keys(base_list); + for (Iterator it = First(keys); it.item; it = Next(it)) { + Node* base = Getattr(base_list, it.item); + String* c_baseclass = SwigType_namestr(Getattr(base, "name")); + String* iname = getQualifiedInterfaceName(base); + if (Len(interface_list)) + Append(interface_list, ", "); + Append(interface_list, iname); - Printf(interface_upcasts, " [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]\n"); - String* upcast_name = 0; - if (String* cptr_func = Getattr(base, "feature:interface:cptr")) - upcast_name = NewStringf("%s.%s", iname, cptr_func); - else - upcast_name = NewStringf("%s.GetCPtr", iname); - Printf(interface_upcasts, " public HandleRef %s()", upcast_name); - Replaceall(upcast_name, ".", "_"); - String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, upcast_name); - String *wname = Swig_name_wrapper(upcast_method); - Printf(interface_upcasts, "{ return new HandleRef((%s)this, %s.%s(swigCPtr.Handle)); }\n", iname, imclass_name, upcast_method ); - Printv(imclass_cppcasts_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); - Printf(imclass_cppcasts_code, " public static extern IntPtr %s(IntPtr jarg1);\n", upcast_method); - Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); - Printv(upcasts_code, - "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n", - " return (", c_baseclass, " *)jarg1;\n" - "}\n", "\n", NIL); - Delete(upcast_name); - Delete(wname); - Delete(upcast_method); - Delete(c_baseclass); + Printf(interface_upcasts, " [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]\n"); + String* upcast_name = 0; + if (String* cptr_func = Getattr(base, "feature:interface:cptr")) + upcast_name = NewStringf("%s.%s", iname, cptr_func); + else + upcast_name = NewStringf("%s.GetCPtr", iname); + Printf(interface_upcasts, " public HandleRef %s()", upcast_name); + Replaceall(upcast_name, ".", "_"); + String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, upcast_name); + String *wname = Swig_name_wrapper(upcast_method); + Printf(interface_upcasts, "{ return new HandleRef((%s)this, %s.%s(swigCPtr.Handle)); }\n", iname, imclass_name, upcast_method ); + Printv(imclass_cppcasts_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); + Printf(imclass_cppcasts_code, " public static extern IntPtr %s(IntPtr jarg1);\n", upcast_method); + Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); + Printv(upcasts_code, + "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n", + " return (", c_baseclass, " *)jarg1;\n" + "}\n", "\n", NIL); + Delete(upcast_name); + Delete(wname); + Delete(upcast_method); + Delete(c_baseclass); + } + Delete(keys); } /* ----------------------------------------------------------------------------- * emitProxyClassDefAndCPPCasts() @@ -1655,13 +1660,8 @@ public: List *baselist = Getattr(n, "bases"); if (baselist) { Iterator base = First(baselist); - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - while (base.item && Getattr(base.item, "feature:interface")) { - addInterfaceNameAndUpcasts(interface_list, interface_upcasts, base.item, c_classname); + while (base.item && (GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface"))) base = Next(base); - } if (base.item) { c_baseclassname = Getattr(base.item, "name"); baseclass = Copy(getProxyName(c_baseclassname)); @@ -1670,9 +1670,7 @@ public: base = Next(base); /* Warn about multiple inheritance for additional base class(es) */ while (base.item) { - if (Getattr(base.item, "feature:interface")) { - addInterfaceNameAndUpcasts(interface_list, interface_upcasts, base.item, c_classname); - } else if (!GetFlag(base.item, "feature:ignore")) { + if (!GetFlag(base.item, "feature:ignore") && !Getattr(base.item, "feature:interface")) { String *proxyclassname = Getattr(n, "classtypeobj"); String *baseclassname = Getattr(base.item, "name"); Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), @@ -1682,10 +1680,9 @@ public: } } } - if (Getattr(n, "feature:interface")) { - addInterfaceNameAndUpcasts(interface_list, interface_upcasts, n, c_classname); - } } + if (Hash* interface_classes = Getattr(n, "feature:interface:bases")) + addInterfaceNameAndUpcasts(interface_list, interface_upcasts, interface_classes, c_classname); bool derived = baseclass && getProxyName(c_baseclassname); if (derived && purebase_notderived) @@ -2144,7 +2141,8 @@ public: String *pre_code = NewString(""); String *post_code = NewString(""); String *terminator_code = NewString(""); - bool is_interface = Getattr(parentNode(n), "feature:interface") != 0 && !static_flag; + bool is_interface = Getattr(parentNode(n), "feature:interface") != 0 + && !static_flag && Getattr(n, "feature:interface:owner") == 0; if (!proxy_flag) return; diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 280cbe6cc..a6b7576cd 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1763,20 +1763,6 @@ public: Delete(c_baseclass); } Delete(keys); - Delete(base_list); - } - - void collectInterfaceBases(Hash* bases, Node* n) { - if (Getattr(n, "feature:interface")) { - String* name = Getattr(n, "feature:interface:name"); - if (Getattr(bases, name)) - return; - Setattr(bases, name, n); - } - if (List *baselist = Getattr(n, "bases")) { - for (Iterator base = First(baselist); base.item; base = Next(base)) - collectInterfaceBases(bases, base.item); - } } /* ----------------------------------------------------------------------------- @@ -1827,8 +1813,8 @@ public: } } } - collectInterfaceBases(interface_classes, n); - addInterfaceNameAndUpcasts(interface_list, interface_upcasts, interface_classes, c_classname); + if (Hash* interface_classes = Getattr(n, "feature:interface:bases")) + addInterfaceNameAndUpcasts(interface_list, interface_upcasts, interface_classes, c_classname); bool derived = baseclass && getProxyName(c_baseclassname); if (derived && purebase_notderived) @@ -2002,9 +1988,8 @@ public: if (List *baselist = Getattr(n, "bases")) { String* bases = 0; for (Iterator base = First(baselist); base.item; base = Next(base)) { - if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface")) { + if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface")) continue; // TODO: warn about skipped non-interface bases - } String* base_iname = Getattr(base.item, "feature:interface:name"); if (!bases) bases = Copy(base_iname); @@ -2271,7 +2256,8 @@ public: bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); - bool is_interface = Getattr(parentNode(n), "feature:interface") != 0 && !static_flag; + bool is_interface = Getattr(parentNode(n), "feature:interface") != 0 + && !static_flag && Getattr(n, "feature:interface:owner") == 0; if (!proxy_flag) return; diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 78e959bfc..b8462a182 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -3604,35 +3604,65 @@ Hash *Language::getClassHash() const { return classhash; } -// 2 methods below are used in C# && Java module "feature:interface" implementation +// 4 methods below are used in C# && Java module "feature:interface" implementation // // Collect all not abstract methods from the bases marked as "interface" -void Swig_collect_non_abstract_methods(Node* n, List* methods) { - if (List *baselist = Getattr(n, "bases")) { - for (Iterator base = First(baselist); base.item; base = Next(base)) { - if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface")) +static void collect_interface_methods(Node* n, List* methods) { + if (Hash* bases = Getattr(n, "feature:interface:bases")){ + List* keys = Keys(bases); + for (Iterator base = First(keys); base.item; base = Next(base)) { + Node* cls = Getattr(bases, base.item); + if (cls == n) continue; - for (Node* child = firstChild(base.item); child; child = nextSibling(child)) { + for (Node* child = firstChild(cls); child; child = nextSibling(child)) { if (strcmp(Char(nodeType(child)), "cdecl") == 0) { - if (GetFlag(child, "feature:ignore") || Getattr(child, "feature:interface:owner") || GetFlag(child, "abstract")) - continue; // skip methods propagated to bases and abstracts + if (GetFlag(child, "feature:ignore") || Getattr(child, "feature:interface:owner")) + continue; // skip methods propagated to bases Node* m = Copy(child); set_nextSibling(m, NIL); set_previousSibling(m, NIL); - Setattr(m, "feature:interface:owner", base.item); + Setattr(m, "feature:interface:owner", cls); Append(methods, m); } } - Swig_collect_non_abstract_methods(base.item, methods); } + Delete(keys); } } + +static void collect_interface_bases(Hash* bases, Node* n) { + if (Getattr(n, "feature:interface")) { + String* name = Getattr(n, "feature:interface:name"); + if (Getattr(bases, name)) + return; + Setattr(bases, name, n); + } + if (List *baselist = Getattr(n, "bases")) { + for (Iterator base = First(baselist); base.item; base = Next(base)) + if (!GetFlag(base.item, "feature:ignore")) + collect_interface_bases(bases, base.item); + } +} + +static void Swig_collect_interface_bases(Node* n) { + Hash* interface_classes = NewHash(); + collect_interface_bases(interface_classes, n); + if (Len(interface_classes) == 0) + Delete(interface_classes); + else + Setattr(n, "feature:interface:bases", interface_classes); +} + // Append all the interface methods not implemented in the current class, so that it would not be abstract void Swig_propagate_interface_methods(Node *n) { + Swig_collect_interface_bases(n); List* methods = NewList(); - Swig_collect_non_abstract_methods(n, methods); + collect_interface_methods(n, methods); + bool is_interface = Getattr(n, "feature:interface") != 0; for (Iterator mi = First(methods); mi.item; mi = Next(mi)) { + if (!is_interface && GetFlag(mi.item, "abstract")) + continue; String *this_decl = Getattr(mi.item, "decl"); String *resolved_decl = SwigType_typedef_resolve_all(this_decl); bool overloaded = false; From 9b0f385a50906268802b6cc1ab6a65a37faa1261 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Thu, 23 May 2013 00:11:58 +0400 Subject: [PATCH 010/732] interface implementation visibility --- Source/Modules/csharp.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 64e3301cf..f43244355 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1615,7 +1615,7 @@ public: upcast_name = NewStringf("%s.%s", iname, cptr_func); else upcast_name = NewStringf("%s.GetCPtr", iname); - Printf(interface_upcasts, " public HandleRef %s()", upcast_name); + Printf(interface_upcasts, " HandleRef %s()", upcast_name); Replaceall(upcast_name, ".", "_"); String *upcast_method = Swig_name_member(getNSpace(), proxy_class_name, upcast_name); String *wname = Swig_name_wrapper(upcast_method); From 73cf08ea64646cddc1b385de44516c07793482d5 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Fri, 24 May 2013 01:55:19 +0400 Subject: [PATCH 011/732] javadirectorin fix --- Lib/java/feature_interface.i | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/java/feature_interface.i b/Lib/java/feature_interface.i index 079747d52..0a93a2619 100644 --- a/Lib/java/feature_interface.i +++ b/Lib/java/feature_interface.i @@ -5,8 +5,7 @@ %typemap(javadirectorout) CTYPE*, const CTYPE& "$javacall." ## #INTERFACE ## "_getCPtr()" %typemap(javadirectorin) CTYPE*, const CTYPE& %{ - long cPtr = $jniinput; - return (cPtr == 0) ? null : (INTERFACE)new IMPL(cPtr,false) + ($jniinput == 0) ? null : (INTERFACE)new IMPL($jniinput,false) %} %typemap(javain) CTYPE*, const CTYPE& "$javainput." ## #INTERFACE ## "_getCPtr()" %typemap(javaout) CTYPE*, const CTYPE& From 9450491c358005099e0d6b3a3cbf7dcfe0db8193 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Wed, 29 May 2013 23:49:30 +0400 Subject: [PATCH 012/732] interface test added --- Examples/test-suite/common.mk | 1 + Examples/test-suite/multiple_inheritance_abstract.i | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 83be90d2d..760f5e357 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -257,6 +257,7 @@ CPP_TEST_CASES += \ minherit2 \ mixed_types \ multiple_inheritance \ + multiple_inheritance_abstract \ name_cxx \ name_warnings \ namespace_class \ diff --git a/Examples/test-suite/multiple_inheritance_abstract.i b/Examples/test-suite/multiple_inheritance_abstract.i index 1750d4275..c29462065 100644 --- a/Examples/test-suite/multiple_inheritance_abstract.i +++ b/Examples/test-suite/multiple_inheritance_abstract.i @@ -1,10 +1,11 @@ %module multiple_inheritance_abstract +#if defined(SWIGJAVA) || defined(SWIGCSHARP) %include "feature_interface.i" DECLARE_INTERFACE_RENAME(ABase1, ABase1, SWIGTYPE_ABase1) DECLARE_INTERFACE_RENAME(CBase1, CBase1, SWIGTYPE_CBase1) DECLARE_INTERFACE_RENAME(CBase2, CBase2, SWIGTYPE_CBase2) - +#endif %inline %{ struct CBase1 { From 0de11efdd3b7b7a42e28896a92da0341044d4ad5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 15 Jun 2015 18:02:28 +0200 Subject: [PATCH 013/732] Use "mixed" path to source directory under Cygwin. This allows build to work with both native and Cygwin builds of SWIG and doesn't restrict us to building in the source directory as was the case previously because SWIG_LIB was explicitly not set under Windows. --- configure.ac | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 1eb338617..3877811d4 100644 --- a/configure.ac +++ b/configure.ac @@ -2790,6 +2790,17 @@ AC_SUBST(SKIP_ANDROID) ABS_SRCDIR=`(cd ${srcdir} && pwd)` +dnl Under Cygwin, we may need native absolute path as it is used by SWIG, which +dnl may be a native, and not a Cygwin, program (this is the case when it's +dnl built using MinGW or cccl compiler in Cygwin environment). However it may, +dnl although this is probably more rare, also be built as a Cygwin program. +dnl Using "mixed" path like we do here allows the path to work in both cases. +case $host in +*-*-cygwin* ) + ABS_SRCDIR=`cygpath --mixed $ABS_SRCDIR` + ;; +esac + # Root directory ROOT_DIR=`pwd` case $host in @@ -2827,12 +2838,20 @@ case $build in esac AC_DEFINE_UNQUOTED(SWIG_LIB_WIN_UNIX, ["$SWIG_LIB_WIN_UNIX"], [Directory for SWIG system-independent libraries (Unix install on native Windows)]) -# For testing - Windows builds of SWIG do not need SWIG_LIB set -AC_EGREP_CPP([yes], -[#ifdef _WIN32 - yes -#endif -], [SWIG_LIB_PREINST=], [SWIG_LIB_PREINST=$ABS_SRCDIR/Lib]) +dnl For testing purposes, don't set SWIG_LIB_PREINST when building SWIG in the +dnl source directory under Windows because it is supposed to work without +dnl SWIG_LIB being set at all in this particular case. +if test "${srcdir}" = "."; then + AC_EGREP_CPP([yes], + [#ifdef _WIN32 + yes + #endif + ], [SWIG_LIB_PREINST=], [SWIG_LIB_PREINST=$ABS_SRCDIR/Lib]) +else + dnl When not building in source directory, we must always set SWIG_LIB, + dnl even under Windows, as things couldn't work without it. + SWIG_LIB_PREINST=$ABS_SRCDIR/Lib +fi AC_SUBST(SWIG_LIB_PREINST) AC_CONFIG_FILES([ From 0350e6abce26e8b619a924c4f4ad1411704aa6b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= Date: Mon, 6 Jul 2015 10:28:03 +0200 Subject: [PATCH 014/732] Set OCAMLC to empty if Ocaml compiler not found OCAMLC is tested for 'empty string' when setting SKIP_OCAML (configure.ac:2677), setting it to ':' will not skip ocaml. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 712ca0abd..bc9567219 100644 --- a/configure.ac +++ b/configure.ac @@ -1891,7 +1891,7 @@ else AC_MSG_CHECKING(for Ocaml compiler) if test -z "$OCAMLC"; then - AC_CHECK_PROGS(OCAMLC, ocamlc, :) + AC_CHECK_PROGS(OCAMLC, ocamlc, ) fi AC_MSG_CHECKING(for Ocaml toplevel creator) From 08fa873638fc3d1a0169da8583ae492f765d3a5b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 18 Jul 2015 18:27:43 +0200 Subject: [PATCH 015/732] Make callback unit test pass for PHP backend. Deprecated %callback(1) doesn't work with PHP, use "%s" to give the same name to the callback as to the C function explicitly instead. --- Examples/test-suite/callback.i | 10 +++++++++- Examples/test-suite/php/Makefile.in | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/callback.i b/Examples/test-suite/callback.i index 8e28dad06..c92994898 100644 --- a/Examples/test-suite/callback.i +++ b/Examples/test-suite/callback.i @@ -1,10 +1,18 @@ %module callback +// Not specifying the callback name is only possible in Python. +#ifdef SWIGPYTHON %callback(1) foo; %callback(1) foof; %callback(1) A::bar; %callback(1) A::foom; -%callback("%s_Cb_Ptr") foo_T; // old style, still works. +#else +%callback("%s") foo; +%callback("%s") foof; +%callback("%s") A::bar; +%callback("%s") A::foom; +#endif +%callback("%s_Cb_Ptr") foo_T; // this works in Python too %inline %{ diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index c3f8af5cb..c365d01c3 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -10,6 +10,7 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ + callback \ php_iterator \ php_namewarn_rename \ From a4b319ce8eba4fe971235f611fd656148f6f3ed5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 18 Jul 2015 16:08:05 +0200 Subject: [PATCH 016/732] Remove callback function from autodoc unit test. It doesn't seem to belong there at all, there is a dedicated callback unit test for it and it was added to the initial version of autodoc.i back in 124253d69828b4323f939bf118254ee96aefcdc7 without any explanation, so just remove it. As this callback was used in a PHP test, perform this test for callback.i now and use "%(uppercase)s" construct inside %callback to test that this works. --- Examples/test-suite/autodoc.i | 6 ------ Examples/test-suite/callback.i | 2 +- Examples/test-suite/php/autodoc_runme.php | 9 --------- Examples/test-suite/php/callback_runme.php | 9 +++++++++ 4 files changed, 10 insertions(+), 16 deletions(-) delete mode 100644 Examples/test-suite/php/autodoc_runme.php create mode 100644 Examples/test-suite/php/callback_runme.php diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index d85899756..07afa5794 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -114,12 +114,6 @@ } %} -%callback("%(uppercase)s_CALLBACK") func_cb; - -%inline { - int func_cb(int c, int d) { return c; } -} - // Bug 3310528 %feature("autodoc","1") banana; // names + types %inline %{ diff --git a/Examples/test-suite/callback.i b/Examples/test-suite/callback.i index c92994898..4db63353b 100644 --- a/Examples/test-suite/callback.i +++ b/Examples/test-suite/callback.i @@ -12,7 +12,7 @@ %callback("%s") A::bar; %callback("%s") A::foom; #endif -%callback("%s_Cb_Ptr") foo_T; // this works in Python too +%callback("%(uppercase)s_Cb_Ptr") foo_T; // this works in Python too %inline %{ diff --git a/Examples/test-suite/php/autodoc_runme.php b/Examples/test-suite/php/autodoc_runme.php deleted file mode 100644 index f2e19d3cb..000000000 --- a/Examples/test-suite/php/autodoc_runme.php +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/Examples/test-suite/php/callback_runme.php b/Examples/test-suite/php/callback_runme.php new file mode 100644 index 000000000..392d5e598 --- /dev/null +++ b/Examples/test-suite/php/callback_runme.php @@ -0,0 +1,9 @@ + not a resource\n"); + +check::done(); +?> From 6915061b7d88792ebcb383b3ca3d0347d84fb414 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Tue, 21 Jul 2015 19:30:44 +0300 Subject: [PATCH 017/732] explicitly %ignore'd symbol does not get feature:ignore if it is only added to C symbol table --- Source/CParse/parser.y | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 38f876390..aa8ab789c 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -466,6 +466,8 @@ static void add_symbols(Node *n) { if (only_csymbol || GetFlag(n,"feature:ignore")) { /* Only add to C symbol table and continue */ Swig_symbol_add(0, n); + if (strncmp(Char(symname),"$ignore",7) == 0) + SetFlag(n,"feature:ignore"); } else if (strncmp(Char(symname),"$ignore",7) == 0) { char *c = Char(symname)+7; SetFlag(n,"feature:ignore"); From c7e4c2d41884254d1a9e2ce8f288420e7f3419d5 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Wed, 22 Jul 2015 15:40:13 +0300 Subject: [PATCH 018/732] refactoring: 2 ways of ignoring symbol in add_symbols() merged for clarity --- Source/CParse/parser.y | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index aa8ab789c..26e6549c5 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -463,20 +463,18 @@ static void add_symbols(Node *n) { SetFlag(n,"feature:ignore"); } } - if (only_csymbol || GetFlag(n,"feature:ignore")) { + if (only_csymbol || GetFlag(n,"feature:ignore") || strncmp(Char(symname),"$ignore",7) == 0) { /* Only add to C symbol table and continue */ Swig_symbol_add(0, n); - if (strncmp(Char(symname),"$ignore",7) == 0) - SetFlag(n,"feature:ignore"); - } else if (strncmp(Char(symname),"$ignore",7) == 0) { - char *c = Char(symname)+7; - SetFlag(n,"feature:ignore"); - if (strlen(c)) { - SWIG_WARN_NODE_BEGIN(n); - Swig_warning(0,Getfile(n), Getline(n), "%s\n",c+1); - SWIG_WARN_NODE_END(n); + if (strncmp(Char(symname),"$ignore",7) == 0) { + char *c = Char(symname) + 7; + SetFlag(n, "feature:ignore"); + if (strlen(c)) { + SWIG_WARN_NODE_BEGIN(n); + Swig_warning(0,Getfile(n), Getline(n), "%s\n",c+1); + SWIG_WARN_NODE_END(n); + } } - Swig_symbol_add(0, n); } else { Node *c; if ((wrn) && (Len(wrn))) { From 94f683868adc0a2e25b1315b3a6bffe7a488bd25 Mon Sep 17 00:00:00 2001 From: Lindley French Date: Mon, 15 Jun 2015 14:28:19 -0700 Subject: [PATCH 019/732] Enable variable and typemap substitution in typemap kwargs, and a test that verifies this works for directorin:descriptor. --- Examples/test-suite/java/Makefile.in | 1 + .../java/java_director_ptrclass_runme.java | 47 ++++++++ Examples/test-suite/java_director_ptrclass.i | 107 ++++++++++++++++++ Source/Swig/typemap.c | 28 +++++ 4 files changed, 183 insertions(+) create mode 100644 Examples/test-suite/java/java_director_ptrclass_runme.java create mode 100644 Examples/test-suite/java_director_ptrclass.i diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 310f1a773..3dc6555ef 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -27,6 +27,7 @@ CPP_TEST_CASES = \ java_director_assumeoverride \ java_director_exception_feature \ java_director_exception_feature_nspace \ + java_director_ptrclass \ java_enums \ java_jnitypes \ java_lib_arrays_dimensionless \ diff --git a/Examples/test-suite/java/java_director_ptrclass_runme.java b/Examples/test-suite/java/java_director_ptrclass_runme.java new file mode 100644 index 000000000..2d78a8f2e --- /dev/null +++ b/Examples/test-suite/java/java_director_ptrclass_runme.java @@ -0,0 +1,47 @@ + +import java_director_ptrclass.*; + +public class java_director_ptrclass_runme { + + static { + try { + System.loadLibrary("java_director_ptrclass"); + } 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[]) { + Foo f = new Foo(); + Foo ft = new TouchingFoo(); + Baz b = new Baz(); + if (b.GetTouched()) { + throw new RuntimeException ( "Baz should not have been touched yet." ); + } + + Baz b2 = f.FinalMaybeTouch(b); + + if (b2.GetTouched() || b.GetTouched()) { + throw new RuntimeException ( "Baz should not have been touched by Foo." ); + } + + Baz b3 = ft.FinalMaybeTouch(b); + + if (!b.GetTouched() || !b3.GetTouched() || !b2.GetTouched()) { + throw new RuntimeException ( "Baz was not touched by TouchingFoo. This" + + " might mean the directorin typemap is not" + + " parsing the typemap(jstype, Bar) in its" + + " 'descriptor' kwarg correctly." ); + } + } +} + +class TouchingFoo extends Foo { + @Override + public Baz MaybeTouch(Baz baz_ptr) { + baz_ptr.SetTouched(); + return baz_ptr; + } +} + diff --git a/Examples/test-suite/java_director_ptrclass.i b/Examples/test-suite/java_director_ptrclass.i new file mode 100644 index 000000000..6b4fc1f08 --- /dev/null +++ b/Examples/test-suite/java_director_ptrclass.i @@ -0,0 +1,107 @@ +%module(directors="1") java_director_ptrclass + +// Tests that custom director typemaps can be used with C++ types that +// represent a pointer, in such a way that Java perceives this class as +// equivalent to the underlying type. In particular, this verifies that +// a typemap lookup within a typemap kwarg, in this case +// directorin:descriptor, works as expected. + +%{ +namespace bar { +class Baz { +public: + Baz() : touched(false) {} + void SetTouched() { touched = true; } + bool GetTouched() { return touched; } +private: + bool touched; +}; + +template +class Ptr { +public: + Ptr(T* b) : b_(b) {} + T* Get() const { return b_; } +private: + T* b_; +}; + +class Foo { +public: + // Calling FinalMaybeTouch from Java unambiguously goes through C++ to + // reach MaybeTouch. + Ptr< bar::Baz > FinalMaybeTouch(Baz* b) { + return MaybeTouch(Ptr< bar::Baz >(b)); + } + virtual Ptr< bar::Baz > MaybeTouch(Ptr< bar::Baz > f) { + return f; /* Don't touch */ + } + virtual ~Foo() {} +}; +} +%} + +%feature("director") Foo; + +%typemap(jni) bar::Ptr< bar::Baz > "jlong" +%typemap(jtype) bar::Ptr< bar::Baz > "long" +%typemap(jstype) bar::Ptr< bar::Baz > "Baz" +%typemap(in) bar::Ptr< bar::Baz > { + $1 = bar::Ptr< bar::Baz >(*( bar::Baz**)&$input); +} +%typemap(out) bar::Ptr< bar::Baz > { + const bar::Ptr< bar::Baz >& ptr = $1; + if (ptr.Get()) { + $result = ($typemap(jni, bar::Baz))ptr.Get(); + } else { + $result = 0; + } +} +%typemap(javain) bar::Ptr< bar::Baz > "$typemap(jstype, bar::Baz).getCPtr($javainput)" +%typemap(javaout) bar::Ptr< bar::Baz > { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new $typemap(jstype, bar::Baz)(cPtr, false); +} +%typemap(directorin, descriptor="L$packagepath/$typemap(jstype, bar::Baz);") bar::Ptr< bar::Baz > +%{ *((bar::Baz**)&$input) = ((bar::Ptr< bar::Baz >&)$1).Get(); %} +%typemap(directorout) bar::Ptr< bar::Baz > { + $result = bar::Ptr< bar::Baz >(*( bar::Baz**)&$input); +} +%typemap(javadirectorin) bar::Ptr< bar::Baz > %{ + ((long)$jniinput == 0) ? null : new $typemap(jstype, bar::Baz)($jniinput, false) +%} +%typemap(javadirectorout) bar::Ptr< bar::Baz > "$typemap(jstype, bar::Baz).getCPtr($javacall)" + +namespace bar { +class Baz { +public: + Baz() : touched(false) {} + void SetTouched() { touched = true; } + bool GetTouched() { return touched; } +private: + bool touched; +}; + +template +class Ptr { +public: + Ptr(T* b) : b_(b) {} + T* Get() { return b_; } +private: + T* b_; +}; + +class Foo { +public: + // Calling FinalMaybeTouch from Java unambiguously goes through C++ to + // reach MaybeTouch. + Ptr< bar::Baz > FinalMaybeTouch(Baz* b) { + return MaybeTouch(Ptr< bar::Baz >(b)); + } + virtual Ptr< bar::Baz > MaybeTouch(Ptr< bar::Baz > f) { + return f; /* Don't touch */ + } + virtual ~Foo() {} +}; +} + diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 23b1e80e9..cee323fb9 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1397,6 +1397,20 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No String *value = Copy(Getattr(kw, "value")); String *kwtype = Getattr(kw, "type"); char *ckwname = Char(Getattr(kw, "name")); + { + /* Expand variables and typemaps in kwargs. */ + SwigType *ptype = Getattr(node, "type"); + String *pname = Getattr(node, "name"); + String *lname = Getattr(node, "lname"); + SwigType *mtype = Getattr(node, "tmap:match"); + SwigType *matchtype = mtype ? mtype : ptype; + ParmList *parm_sublist; + typemap_replace_vars(value, NULL, matchtype, ptype, pname, lname, 0); + parm_sublist = NewParmWithoutFileLineInfo(ptype, pname); + Setattr(parm_sublist, "lname", lname); + replace_embedded_typemap(value, parm_sublist, NULL, tm); + Delete(parm_sublist); + } if (kwtype) { String *mangle = Swig_string_mangle(kwtype); Append(value, mangle); @@ -1569,6 +1583,20 @@ static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method while (kw) { String *value = Copy(Getattr(kw, "value")); String *type = Getattr(kw, "type"); + { + /* Expand variables and typemaps in kwargs. */ + SwigType *ptype = Getattr(p, "type"); + String *pname = Getattr(p, "name"); + String *lname = Getattr(p, "lname"); + SwigType *mtype = Getattr(p, "tmap:match"); + SwigType *matchtype = mtype ? mtype : ptype; + ParmList *parm_sublist; + typemap_replace_vars(value, NULL, matchtype, ptype, pname, lname, 0); + parm_sublist = NewParmWithoutFileLineInfo(ptype, pname); + Setattr(parm_sublist, "lname", lname); + replace_embedded_typemap(value, parm_sublist, NULL, tm); + Delete(parm_sublist); + } if (type) { Hash *v = NewHash(); Setattr(v, "type", type); From 2f00f6c8cc6377210312290913662ddacf9e8b69 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 22 Jul 2015 13:02:15 +0100 Subject: [PATCH 020/732] Support special variable expansion in special variable macros in typemap attributes. Add test cases for special variable expansions and special variable macros (aka embedded typemaps) expansion. --- Examples/test-suite/common.mk | 1 + .../special_variable_attributes_runme.cs | 32 ++++ .../test-suite/special_variable_attributes.i | 170 ++++++++++++++++++ Source/Swig/typemap.c | 47 +++-- 4 files changed, 234 insertions(+), 16 deletions(-) create mode 100644 Examples/test-suite/csharp/special_variable_attributes_runme.cs create mode 100644 Examples/test-suite/special_variable_attributes.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 3f3b2216f..cc1ec7464 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -374,6 +374,7 @@ CPP_TEST_CASES += \ smart_pointer_templatevariables \ smart_pointer_typedef \ special_variables \ + special_variable_attributes \ special_variable_macros \ static_array_member \ static_const_member \ diff --git a/Examples/test-suite/csharp/special_variable_attributes_runme.cs b/Examples/test-suite/csharp/special_variable_attributes_runme.cs new file mode 100644 index 000000000..0365ba47c --- /dev/null +++ b/Examples/test-suite/csharp/special_variable_attributes_runme.cs @@ -0,0 +1,32 @@ + +// This is the bool runtime testcase. It checks that the C++ bool type works. + +using System; +using special_variable_attributesNamespace; + +public class special_variable_attributes_runme { + + public static void Main() { + if (special_variable_attributes.getNumber1() != 111) + throw new ApplicationException("getNumber1 failed"); + if (special_variable_attributes.getNumber2() != 222) + throw new ApplicationException("getNumber2 failed"); + if (special_variable_attributes.getNumber3() != 333) + throw new ApplicationException("getNumber3 failed"); + + if (special_variable_attributes.bounceNumber1(10) != 110) + throw new ApplicationException("bounceNumber1 failed"); + if (special_variable_attributes.bounceNumber2(10) != 220) + throw new ApplicationException("bounceNumber2 failed"); + if (special_variable_attributes.bounceNumber3(10) != 330) + throw new ApplicationException("bounceNumber3 failed"); + + if (special_variable_attributes.multi1(12.34) != 12+34) + throw new ApplicationException("multi1 failed"); + if (special_variable_attributes.multi2(12.34) != 12+34+55) + throw new ApplicationException("multi2 failed"); + if (special_variable_attributes.multi3(12.34) != 12+34+77) + throw new ApplicationException("multi3 failed"); + } + +} diff --git a/Examples/test-suite/special_variable_attributes.i b/Examples/test-suite/special_variable_attributes.i new file mode 100644 index 000000000..02dd5f36c --- /dev/null +++ b/Examples/test-suite/special_variable_attributes.i @@ -0,0 +1,170 @@ +%module special_variable_attributes + +// Special variable expansion and special variable macros, aka embedded typemaps - expansion tests +// Tests these are expanded within typemap attributes. +// Also tests that these are expanded when used together, so that the special variables +// can be used as the type passed to the special variable macro. +// C# is used for testing as it is one of the few languages that uses a lot of typemap attributes. +// Attributes in both 'in' and 'out' typemaps are needed, that is, +// typemaps targeting both parameters and return values respectively). + +#ifdef SWIGCSHARP +// Check special variable expansion in typemap attributes. +// This changes return by reference into return by value. +// Takes advantage of the fact that 'int' is a valid type in both C and C#. +// This is not a realistic use, just a way to test the variable expansion in the 'out' attribute. +%typemap(ctype, out="$*1_ltype") int& getNumber1 "_not_used_" +%typemap(imtype, out="$*1_ltype") int& getNumber1 "_not_used_" +%typemap(cstype, out="$*1_ltype") int& getNumber1 "_not_used_" +%typemap(out) int& getNumber1 "$result = *$1;" +%typemap(csout, excode=SWIGEXCODE) int & getNumber1 { + int ret = $imcall;$excode + return ret; + } +#endif + +%inline %{ +int& getNumber1() { + static int num = 111; + return num; +} +%} + +#ifdef SWIGCSHARP +// Check special variable macro expansion in typemap attributes. +// This changes return by reference into return by value. +%typemap(ctype, out="$typemap(ctype, int)") int& getNumber2 "_not_used_" +%typemap(imtype, out="$typemap(imtype, int)") int& getNumber2 "_not_used_" +%typemap(cstype, out="$typemap(cstype, int)") int& getNumber2 "_not_used_" +%typemap(out) int& getNumber2 "$result = *$1;" +%typemap(csout, excode=SWIGEXCODE) int & getNumber2 { + int ret = $imcall;$excode + return ret; + } +#endif + +%inline %{ +int& getNumber2() { + static int num = 222; + return num; +} +%} + + +#ifdef SWIGCSHARP +// Check special variable macro expansion and special variable expansion in typemap attributes. +// This changes return by reference into return by value. +%typemap(ctype, out="$typemap(ctype, $*1_ltype)") int& getNumber3 "_not_used_" +%typemap(imtype, out="$typemap(imtype, $*1_ltype)") int& getNumber3 "_not_used_" +%typemap(cstype, out="$typemap(cstype, $*1_ltype)") int& getNumber3 "_not_used_" +%typemap(out) int& getNumber3 "$result = *$1;" +%typemap(csout, excode=SWIGEXCODE) int & getNumber3 { + int ret = $imcall;$excode + return ret; + } +#endif + +%inline %{ +int& getNumber3() { + static int num = 333; + return num; +} +%} + +#ifdef SWIGCSHARP +// Check special variable macro expansion in typemap attributes. +%typemap(csin, + pre=" $typemap(cstype, int) $csinput_scaled = 11;" + ) int num1 +%{$csinput * $csinput_scaled %} +#endif + +%inline %{ +int bounceNumber1(int num1) { + return num1; +} +%} + +#ifdef SWIGCSHARP +// Check special variable expansion in typemap attributes. +%typemap(csin, + pre=" $1_type $csinput_scaled = 22;" + ) int num2 +%{$csinput * $csinput_scaled %} +#endif + +%inline %{ +int bounceNumber2(int num2) { + return num2; +} +%} + +#ifdef SWIGCSHARP +// Check special variable and special variable macro expansion in typemap attributes. +%typemap(csin, + pre=" $typemap(cstype, $1_type) $csinput_scaled = 33;" + ) int num3 +%{$csinput * $csinput_scaled %} +#endif + +%inline %{ +int bounceNumber3(int num3) { + return num3; +} +%} + +///////////////////////////////// +//// Multi-argument typemaps //// +///////////////////////////////// + +// Test expansion of special variables +#ifdef SWIGCSHARP +%typemap(ctype) (int intvar, char charvar) "double" +%typemap(imtype) (int intvar, char charvar) "double" +%typemap(cstype) (int intvar, char charvar) "double" +%typemap(in) (int intvar, char charvar) +%{ + // split double value a.b into two numbers, a and b*100 + $1 = (int)$input; + $2 = ($input - $1 + 0.005) * 100; +%} +%typemap(csin, + pre=" $1_type $csinput_$1_type = 50;\n" // $1_type should expand to int + " $2_type $csinput_$2_type = 'A';" // $2_type should expand to char + ) (int intvar, char charvar) +%{$csinput + ($csinput_int - 50 + $csinput_char - 'A') + ($csinput_$1_type - 50 + $csinput_$2_type - 'A')%} +#endif + +%inline %{ +int multi1(int intvar, char charvar) { + return intvar + charvar; +} +%} + +#ifdef SWIGCSHARP +%typemap(csin, + pre=" $typemap(cstype, int) $csinput_$typemap(cstype, int) = 50;\n" // also should expand to int + " $typemap(cstype, char) $csinput_$typemap(cstype, char) = 'A';" // also should expand to char + ) (int intvar, char charvar) +%{55 + $csinput + ($csinput_int - 50 + $csinput_char - 'A') + ($csinput_$typemap(cstype, int) - 50 + $csinput_$typemap(cstype, char) - 'A')%} +#endif + +%inline %{ +int multi2(int intvar, char charvar) { + return intvar + charvar; +} +%} + +#ifdef SWIGCSHARP +%typemap(csin, + pre=" $typemap(cstype, $1_type) $csinput_$typemap(cstype, $1_type) = 50;\n" // also should expand to int + " $typemap(cstype, $2_type) $csinput_$typemap(cstype, $2_type) = 'A';" // also should expand to char + ) (int intvar, char charvar) +%{77 + $csinput + ($csinput_int - 50 + $csinput_char - 'A') + ($csinput_$typemap(cstype, $1_type) - 50 + $csinput_$typemap(cstype, $2_type) - 'A')%} +#endif + +%inline %{ +int multi3(int intvar, char charvar) { + return intvar + charvar; +} +%} diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index cee323fb9..7f8ff60cd 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1398,14 +1398,16 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No String *kwtype = Getattr(kw, "type"); char *ckwname = Char(Getattr(kw, "name")); { - /* Expand variables and typemaps in kwargs. */ + /* Expand special variables in typemap attributes. */ SwigType *ptype = Getattr(node, "type"); String *pname = Getattr(node, "name"); String *lname = Getattr(node, "lname"); SwigType *mtype = Getattr(node, "tmap:match"); SwigType *matchtype = mtype ? mtype : ptype; ParmList *parm_sublist; - typemap_replace_vars(value, NULL, matchtype, ptype, pname, lname, 0); + typemap_replace_vars(value, NULL, matchtype, ptype, pname, lname, 1); + + /* Expand special variable macros (embedded typemaps) in typemap attributes. */ parm_sublist = NewParmWithoutFileLineInfo(ptype, pname); Setattr(parm_sublist, "lname", lname); replace_embedded_typemap(value, parm_sublist, NULL, tm); @@ -1572,30 +1574,43 @@ String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *node, co * If this hash (tm) contains a linked list of parameters under its "kwargs" * attribute, add keys for each of those named keyword arguments to this * parameter for later use. - * For example, attach the typemap attributes to p: + * For example, attach the typemap attributes to firstp (first parameter in parameter list): * %typemap(in, foo="xyz") ... - * A new attribute called "tmap:in:foo" with value "xyz" is attached to p. + * A new attribute called "tmap:in:foo" with value "xyz" is attached to firstp. + * Also expands special variables and special variable macros in the typemap attributes. * ----------------------------------------------------------------------------- */ -static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method, Parm *p) { +static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method, Parm *firstp, int nmatch) { String *temp = NewStringEmpty(); Parm *kw = Getattr(tm, "kwargs"); while (kw) { String *value = Copy(Getattr(kw, "value")); String *type = Getattr(kw, "type"); - { - /* Expand variables and typemaps in kwargs. */ - SwigType *ptype = Getattr(p, "type"); + int i; + Parm *p = firstp; + /* Expand special variables */ + for (i = 0; i < nmatch; i++) { + SwigType *type = Getattr(p, "type"); String *pname = Getattr(p, "name"); String *lname = Getattr(p, "lname"); SwigType *mtype = Getattr(p, "tmap:match"); - SwigType *matchtype = mtype ? mtype : ptype; - ParmList *parm_sublist; - typemap_replace_vars(value, NULL, matchtype, ptype, pname, lname, 0); - parm_sublist = NewParmWithoutFileLineInfo(ptype, pname); + SwigType *matchtype = mtype ? mtype : type; + typemap_replace_vars(value, NULL, matchtype, type, pname, lname, i + 1); + p = nextSibling(p); + } + + /* Expand special variable macros (embedded typemaps). + * Special variable are expanded first above as they might be used in the special variable macros. + * For example: $typemap(imtype, $2_type). */ + p = firstp; + for (i = 0; i < nmatch; i++) { + SwigType *type = Getattr(p, "type"); + String *pname = Getattr(p, "name"); + String *lname = Getattr(p, "lname"); + ParmList *parm_sublist = NewParmWithoutFileLineInfo(type, pname); Setattr(parm_sublist, "lname", lname); replace_embedded_typemap(value, parm_sublist, NULL, tm); - Delete(parm_sublist); + p = nextSibling(p); } if (type) { Hash *v = NewHash(); @@ -1606,13 +1621,13 @@ static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method } Clear(temp); Printf(temp, "%s:%s", tmap_method, Getattr(kw, "name")); - Setattr(p, typemap_method_name(temp), value); + Setattr(firstp, typemap_method_name(temp), value); Delete(value); kw = nextSibling(kw); } Clear(temp); Printf(temp, "%s:match_type", tmap_method); - Setattr(p, typemap_method_name(temp), Getattr(tm, "type")); + Setattr(firstp, typemap_method_name(temp), Getattr(tm, "type")); Delete(temp); } @@ -1807,7 +1822,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p Setattr(firstp, typemap_method_name(temp), p); /* Attach kwargs */ - typemap_attach_kwargs(tm, tmap_method, firstp); + typemap_attach_kwargs(tm, tmap_method, firstp, nmatch); /* Replace the argument number */ sprintf(temp, "%d", argnum); From f482adc6d1a4b1cc27b4ecbb6b461d1f747906b6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 22 Jul 2015 23:23:55 +0100 Subject: [PATCH 021/732] Add documentation and CHANGES for special variables and typemap attributes. Also add info about special variable expansions in special variable macros. --- CHANGES.current | 35 +++++++++++++++++++ Doc/Manual/Contents.html | 2 ++ Doc/Manual/Typemaps.html | 72 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 0c56946f8..cd5ae106a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,41 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.7 (in progress) =========================== +2015-07-22: wsfulton + Support for special variable expansion in typemap attributes. Example usage expansion + in the 'out' attribute (C# specific): + + %typemap(ctype, out="$*1_ltype") unsigned int& "$*1_ltype" + + is equivalent to the following as $*1_ltype expands to 'unsigned int': + + %typemap(ctype, out="unsigned int") unsigned int& "unsigned int" + + Special variables can be used within special variable macros too. Example usage expansion: + + %typemap(cstype) unsigned int "uint" + %typemap(cstype, out="$typemap(cstype, $*1_ltype)") unsigned int& "$typemap(cstype, $*1_ltype)" + + Special variables are expanded first and hence the above is equivalent to: + + %typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)" + + which then expands to: + + %typemap(cstype, out="uint") unsigned int& "uint" + +2015-07-22: lindleyf + Apply patch #439 - support for $typemap() (aka embedded typemaps or special variable + macros) in typemap attributes. A simple example where $typemap() is expanded in the + 'out' attribute (C# specific): + + %typemap(cstype) unsigned int "uint" + %typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)" + + is equivalent to: + + %typemap(cstype, out="uint") unsigned int& "uint" + 2015-07-18: m7thon [Python] Docstrings provided via %feature("docstring") are now quoted and added to the tp_doc slot when using python builtin classes (-builtin). When no docstring is diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 793f2ed21..06c858b29 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -441,6 +441,8 @@
  • $descriptor(type)
  • $typemap(method, typepattern) +
  • Special variables and typemap attributes +
  • Special variables combined with special variable macros
  • Common typemap methods +
  • Special variables and typemap attributes +
  • Special variables combined with special variable macros
  • Common typemap methods
      @@ -2425,6 +2427,76 @@ The result is the following expansion + +

      11.4.5 Special variables and typemap attributes

      + + +

      +As of SWIG-3.0.7 typemap attributes will also expand special variables and special variable macros. +

      + +

      +Example usage showing the expansion in the 'out' attribute (C# specific) as well as the main typemap body: +

      + +
      +
      +%typemap(ctype, out="$*1_ltype") unsigned int& "$*1_ltype"
      +
      +
      + +

      +is equivalent to the following as $*1_ltype expands to unsigned int: +

      + +
      +
      +%typemap(ctype, out="unsigned int") unsigned int& "unsigned int"
      +
      +
      + +

      11.4.6 Special variables combined with special variable macros

      + + +

      +Special variables can also be used within special variable macros. +The special variables are expanded before they are used in the special variable macros. +

      + +

      +Consider the following C# typemaps: +

      + +
      +
      +%typemap(cstype) unsigned int "uint"
      +%typemap(cstype, out="$typemap(cstype, $*1_ltype)") unsigned int& "$typemap(cstype, $*1_ltype)"
      +
      +
      + +

      +Special variables are expanded first and hence the above is equivalent to: +

      + +
      +
      +%typemap(cstype) unsigned int "uint"
      +%typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)"
      +
      +
      + +

      +which then expands to: +

      + +
      +
      +%typemap(cstype) unsigned int "uint"
      +%typemap(cstype, out="uint") unsigned int& "uint"
      +
      +
      + +

      11.5 Common typemap methods

      From 457e0bfa815d0cef8fc3019313b1c2b4c799835a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 24 Jul 2015 00:32:46 +0100 Subject: [PATCH 022/732] Typemap attribute fixes Fix for breakages in previous few commits: - Perl test-suite - the "varout" typemap "type" attribute is now expanded in typemap.c instead of Perl.cxx. - The swig_typemap_warn errors testcase showed that $1 was no longer being expanded correctly when used in output typemaps (lname not set). --- Source/Modules/perl5.cxx | 17 ++------ Source/Swig/typemap.c | 85 +++++++++++++++++++++++----------------- 2 files changed, 52 insertions(+), 50 deletions(-) diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 979f96484..2ff7c6f91 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -1045,21 +1045,9 @@ public: String *tt = Getattr(n, "tmap:varout:type"); if (tt) { - String *tm = NewStringf("&SWIGTYPE%s", SwigType_manglestr(t)); - if (Replaceall(tt, "$1_descriptor", tm)) { - SwigType_remember(t); - } - Delete(tm); - SwigType *st = Copy(t); - SwigType_add_pointer(st); - tm = NewStringf("&SWIGTYPE%s", SwigType_manglestr(st)); - if (Replaceall(tt, "$&1_descriptor", tm)) { - SwigType_remember(st); - } - Delete(tm); - Delete(st); + tt = NewStringf("&%s", tt); } else { - tt = (String *) "0"; + tt = NewString("0"); } /* Now add symbol to the PERL interpreter */ if (GetFlag(n, "feature:immutable")) { @@ -1087,6 +1075,7 @@ public: if (export_all) Printf(exported, "$%s ", iname); + Delete(tt); DelWrapper(setf); DelWrapper(getf); Delete(getname); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 7f8ff60cd..4c6530061 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1318,6 +1318,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No char *cmethod = Char(tmap_method); int optimal_attribute = 0; int optimal_substitution = 0; + int delete_optimal_attribute = 0; int num_substitutions = 0; SwigType *matchtype = 0; @@ -1372,7 +1373,6 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No Delete(typestr); } - Delete(qpname); qpname = 0; Delete(noscope_pname); @@ -1391,39 +1391,16 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No s = Copy(s); /* Make a local copy of the typemap code */ - /* Attach kwargs - ie the typemap attributes */ - kw = Getattr(tm, "kwargs"); - while (kw) { - String *value = Copy(Getattr(kw, "value")); - String *kwtype = Getattr(kw, "type"); - char *ckwname = Char(Getattr(kw, "name")); - { - /* Expand special variables in typemap attributes. */ - SwigType *ptype = Getattr(node, "type"); - String *pname = Getattr(node, "name"); - String *lname = Getattr(node, "lname"); - SwigType *mtype = Getattr(node, "tmap:match"); - SwigType *matchtype = mtype ? mtype : ptype; - ParmList *parm_sublist; - typemap_replace_vars(value, NULL, matchtype, ptype, pname, lname, 1); - - /* Expand special variable macros (embedded typemaps) in typemap attributes. */ - parm_sublist = NewParmWithoutFileLineInfo(ptype, pname); - Setattr(parm_sublist, "lname", lname); - replace_embedded_typemap(value, parm_sublist, NULL, tm); - Delete(parm_sublist); + /* Look in the "out" typemap for the "optimal" attribute */ + if (Cmp(cmethod, "out") == 0) { + kw = Getattr(tm, "kwargs"); + while (kw) { + if (Cmp(Getattr(kw, "name"), "optimal") == 0) { + optimal_attribute = GetFlag(kw, "value"); + break; + } + kw = nextSibling(kw); } - if (kwtype) { - String *mangle = Swig_string_mangle(kwtype); - Append(value, mangle); - Delete(mangle); - } - sprintf(temp, "%s:%s", cmethod, ckwname); - Setattr(node, typemap_method_name(temp), value); - if (Cmp(temp, "out:optimal") == 0) - optimal_attribute = (Cmp(value, "0") != 0) ? 1 : 0; - Delete(value); - kw = nextSibling(kw); } if (optimal_attribute) { @@ -1454,14 +1431,15 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No } } if (!optimal_substitution) { - Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(node), Getline(node), "Method %s usage of the optimal attribute ignored\n", Swig_name_decl(node)); - Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(s), Getline(s), "in the out typemap as the following cannot be used to generate optimal code: %s\n", clname); - Delattr(node, "tmap:out:optimal"); + Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(node), Getline(node), "Method %s usage of the optimal attribute ignored\n", Swig_name_decl(node)); + Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(s), Getline(s), "in the out typemap as the following cannot be used to generate optimal code: %s\n", clname); + delete_optimal_attribute = 1; } } else { assert(!f); } } + if (actioncode) { assert(f); Append(f->code, actioncode); @@ -1502,6 +1480,41 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No Delete(parm_sublist); } + /* Attach kwargs - ie the typemap attributes */ + kw = Getattr(tm, "kwargs"); + while (kw) { + String *value = Copy(Getattr(kw, "value")); + String *kwtype = Getattr(kw, "type"); + char *ckwname = Char(Getattr(kw, "name")); + { + /* Expand special variables in typemap attributes. */ + SwigType *ptype = Getattr(node, "type"); + String *pname = Getattr(node, "name"); + SwigType *mtype = Getattr(node, "tmap:match"); + SwigType *matchtype = mtype ? mtype : ptype; + ParmList *parm_sublist; + typemap_replace_vars(value, NULL, matchtype, ptype, pname, (char *)lname, 1); + + /* Expand special variable macros (embedded typemaps) in typemap attributes. */ + parm_sublist = NewParmWithoutFileLineInfo(ptype, pname); + Setattr(parm_sublist, "lname", lname); + replace_embedded_typemap(value, parm_sublist, NULL, tm); + Delete(parm_sublist); + } + if (kwtype) { + String *mangle = Swig_string_mangle(kwtype); + Append(value, mangle); + Delete(mangle); + } + sprintf(temp, "%s:%s", cmethod, ckwname); + Setattr(node, typemap_method_name(temp), value); + Delete(value); + kw = nextSibling(kw); + } + + if (delete_optimal_attribute) + Delattr(node, "tmap:out:optimal"); + Replace(s, "$name", pname, DOH_REPLACE_ANY); symname = Getattr(node, "sym:name"); From 812f789db6ec21ebe817521424dff32ada8be00c Mon Sep 17 00:00:00 2001 From: xantares Date: Sat, 25 Jul 2015 16:25:42 +0200 Subject: [PATCH 023/732] Avoid gcc uninitialized variable warnings in Python wrappers. Just initialize the local array with zeroes. Closes #453. --- 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 781cab721..df7fb3445 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2385,7 +2385,7 @@ public: Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args) {", NIL); Wrapper_add_local(f, "argc", "int argc"); - Printf(tmp, "PyObject *argv[%d]", maxargs + 1); + Printf(tmp, "PyObject *argv[%d] = {0}", maxargs + 1); Wrapper_add_local(f, "argv", tmp); if (!fastunpack) { From fa282b3540c87927fc3562bd0f0863accf6a853f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 28 Jul 2015 00:18:02 +0100 Subject: [PATCH 024/732] Improve Python docstring indentation handling SWIG-3.0.5 and earlier sometimes truncated text provided in the docstring feature. SWIG-3.0.6 gave a 'Line indented less than expected' error instead of truncating the docstring text. Now the indentation for the 'docstring' feature is smarter and is adjusted so that no truncation occurs. Closes #475 --- CHANGES.current | 11 ++ Examples/test-suite/python/Makefile.in | 1 + .../python/python_docstring_runme.py | 100 ++++++++++++++ Examples/test-suite/python_docstring.i | 98 ++++++++++++++ Source/Modules/python.cxx | 126 ++++++++++++++---- 5 files changed, 308 insertions(+), 28 deletions(-) create mode 100644 Examples/test-suite/python/python_docstring_runme.py create mode 100644 Examples/test-suite/python_docstring.i diff --git a/CHANGES.current b/CHANGES.current index cd5ae106a..de10ba23f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,17 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.7 (in progress) =========================== +2015-07-28: wsfulton + [Python] Fix #475. Improve docstring indentation handling. + + SWIG-3.0.5 and earlier sometimes truncated text provided in the docstring feature. + This occurred when the indentation (whitespace) in the docstring was less in the + second or later lines when compared to the first line. + SWIG-3.0.6 gave a 'Line indented less than expected' error instead of truncating + the docstring text. + Now the indentation for the 'docstring' feature is smarter and is appropriately + adjusted so that no truncation occurs. + 2015-07-22: wsfulton Support for special variable expansion in typemap attributes. Example usage expansion in the 'out' attribute (C# specific): diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index a99c30439..59c8eed9e 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -59,6 +59,7 @@ CPP_TEST_CASES += \ python_abstractbase \ python_append \ python_director \ + python_docstring \ python_nondynamic \ python_overload_simple_cast \ python_pythoncode \ diff --git a/Examples/test-suite/python/python_docstring_runme.py b/Examples/test-suite/python/python_docstring_runme.py new file mode 100644 index 000000000..0284ea0de --- /dev/null +++ b/Examples/test-suite/python/python_docstring_runme.py @@ -0,0 +1,100 @@ +from python_docstring import * +import inspect + +def check(got, expected): + expected_list = expected.split("\n") + got_list = got.split("\n") + + if expected_list != got_list: + raise RuntimeError("\n" + "Expected: " + str(expected_list) + "\n" + "Got : " + str(got_list)) + +# When getting docstrings, use inspect.getdoc(x) instead of x.__doc__ otherwise the different options +# such as -O, -builtin, -classic produce different initial indentation. + +check(inspect.getdoc(DocStrings.docstring1), + " line 1\n" + "line 2\n" + "\n" + "\n" + "\n" + "line 3" + ) + +check(inspect.getdoc(DocStrings.docstring2), + "line 1\n" + " line 2\n" + "\n" + "\n" + "\n" + " line 3" + ) + +check(inspect.getdoc(DocStrings.docstring3), + "line 1\n" + " line 2\n" + "\n" + "\n" + "\n" + " line 3" + ) + +check(inspect.getdoc(DocStrings.docstring4), + "line 1\n" + " line 2\n" + "\n" + "\n" + "\n" + " line 3" + ) + +check(inspect.getdoc(DocStrings.docstring5), + "line 1\n" + " line 2\n" + "\n" + "\n" + "\n" + " line 3" + ) + +check(inspect.getdoc(DocStrings.docstring6), + "line 1\n" + " line 2\n" + "\n" + "\n" + "\n" + " line 3" + ) + +check(inspect.getdoc(DocStrings.docstring7), + "line 1\n" + "line 2\n" + "line 3" + ) + +check(inspect.getdoc(DocStrings.docstringA), + "first line\n" + "second line" + ) + +check(inspect.getdoc(DocStrings.docstringB), + "first line\n" + "second line" + ) + +check(inspect.getdoc(DocStrings.docstringC), + "first line\n" + "second line" + ) + +# One line doc special case, use __doc__ +check(DocStrings.docstringX.__doc__, + " one line docs" + ) + +check(inspect.getdoc(DocStrings.docstringX), + "one line docs" + ) + +check(inspect.getdoc(DocStrings.docstringY), + "one line docs" + ) diff --git a/Examples/test-suite/python_docstring.i b/Examples/test-suite/python_docstring.i new file mode 100644 index 000000000..3b88167eb --- /dev/null +++ b/Examples/test-suite/python_docstring.i @@ -0,0 +1,98 @@ +%module python_docstring + +// Test indentation when using the docstring feature. +// Checks tabs and spaces as input for indentation. + +%feature("docstring") docstring1 %{ + line 1 +line 2 + + + +line 3 +%} + +%feature("docstring") docstring2 %{ +line 1 + line 2 + + + + line 3 + %} + +%feature("docstring") docstring3 %{ + line 1 + line 2 + + + + line 3 + %} + +%feature("docstring") docstring4 %{ + line 1 + line 2 + + + + line 3 + %} + +%feature("docstring") docstring5 +%{ line 1 + line 2 + + + + line 3 + %} + +%feature("docstring") docstring6 +{ + line 1 + line 2 + + + + line 3 +} + +%feature("docstring") docstring7 +{ +line 1 +line 2 +line 3 +} + +%feature("docstring") docstringA +%{ first line + second line%} + +%feature("docstring") docstringB +%{ first line + second line%} + +%feature("docstring") docstringC +%{ first line + second line%} + +%feature("docstring") docstringX " one line docs" +%feature("docstring") docstringY "one line docs" + +%inline %{ +struct DocStrings { + void docstring1() {} + void docstring2() {} + void docstring3() {} + void docstring4() {} + void docstring5() {} + void docstring6() {} + void docstring7() {} + void docstringA() {} + void docstringB() {} + void docstringC() {} + void docstringX() {} + void docstringY() {} +}; +%} diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index df7fb3445..f91e43d82 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -12,6 +12,7 @@ * ----------------------------------------------------------------------------- */ #include "swigmod.h" +#include #include "cparse.h" #include #include @@ -1356,12 +1357,15 @@ public: return str; } - /* ------------------------------------------------------------ - * pythoncode() - Output python code into the shadow file + * indent_pythoncode() + * + * Format (indent) Python code. + * Remove leading whitespace from 'code' and re-indent using + * the indentation string in 'indent'. * ------------------------------------------------------------ */ - String *pythoncode(String *code, const_String_or_char_ptr indent, String * file, int line) { + String *indent_pythoncode(const String *code, const_String_or_char_ptr indent, String *file, int line) { String *out = NewString(""); String *temp; char *t; @@ -1383,7 +1387,7 @@ public: // Line number within the pythoncode. int py_line = 0; - String * initial = 0; + String *initial = 0; Iterator si; /* Get the initial indentation. Skip lines which only contain whitespace @@ -1401,7 +1405,7 @@ public: const char *c = Char(si.item); int i; for (i = 0; isspace((unsigned char)c[i]); i++) { - // Scan forward until we find a non-space (which may be a nul byte). + // Scan forward until we find a non-space (which may be a null byte). } char ch = c[i]; if (ch && ch != '#') { @@ -1423,7 +1427,7 @@ public: int i; for (i = 0; isspace((unsigned char)c[i]); i++) { - // Scan forward until we find a non-space (which may be a nul byte). + // Scan forward until we find a non-space (which may be a null byte). } char ch = c[i]; if (!ch) { @@ -1469,6 +1473,72 @@ public: return out; } + /* ------------------------------------------------------------ + * indent_docstring() + * + * Format (indent) a Python docstring. + * Remove leading whitespace from 'code' and re-indent using + * the indentation string in 'indent'. + * ------------------------------------------------------------ */ + + String *indent_docstring(const String *code, const_String_or_char_ptr indent) { + String *out = NewString(""); + String *temp; + char *t; + if (!indent) + indent = ""; + + temp = NewString(code); + + t = Char(temp); + if (*t == '{') { + Delitem(temp, 0); + Delitem(temp, DOH_END); + } + + /* Split the input text into lines */ + List *clist = SplitLines(temp); + Delete(temp); + + Iterator si; + + int truncate_characters_count = INT_MAX; + for (si = First(clist); si.item; si = Next(si)) { + const char *c = Char(si.item); + int i; + for (i = 0; isspace((unsigned char)c[i]); i++) { + // Scan forward until we find a non-space (which may be a null byte). + } + char ch = c[i]; + if (ch) { + // Found a line which isn't just whitespace + if (i < truncate_characters_count) + truncate_characters_count = i; + } + } + + if (truncate_characters_count == INT_MAX) + truncate_characters_count = 0; + + for (si = First(clist); si.item; si = Next(si)) { + const char *c = Char(si.item); + + int i; + for (i = 0; isspace((unsigned char)c[i]); i++) { + // Scan forward until we find a non-space (which may be a null byte). + } + char ch = c[i]; + if (!ch) { + // Line is just whitespace - emit an empty line. + Putc('\n', out); + continue; + } + + Printv(out, indent, c + truncate_characters_count, "\n", NIL); + } + Delete(clist); + return out; + } /* ------------------------------------------------------------ * autodoc level declarations @@ -1552,21 +1622,21 @@ public: if (have_auto && have_ds) { // Both autodoc and docstring are present doc = NewString(""); Printv(doc, triple_double, "\n", - pythoncode(autodoc, indent, Getfile(n), Getline(n)), "\n", - pythoncode(str, indent, Getfile(n), Getline(n)), indent, triple_double, NIL); + indent_docstring(autodoc, indent), "\n", + indent_docstring(str, indent), indent, triple_double, NIL); } else if (!have_auto && have_ds) { // only docstring if (Strchr(str, '\n') == 0) { doc = NewStringf("%s%s%s", triple_double, str, triple_double); } else { doc = NewString(""); - Printv(doc, triple_double, "\n", pythoncode(str, indent, Getfile(n), Getline(n)), indent, triple_double, NIL); + Printv(doc, triple_double, "\n", indent_docstring(str, indent), indent, triple_double, NIL); } } else if (have_auto && !have_ds) { // only autodoc if (Strchr(autodoc, '\n') == 0) { doc = NewStringf("%s%s%s", triple_double, autodoc, triple_double); } else { doc = NewString(""); - Printv(doc, triple_double, "\n", pythoncode(autodoc, indent, Getfile(n), Getline(n)), indent, triple_double, NIL); + Printv(doc, triple_double, "\n", indent_docstring(autodoc, indent), indent, triple_double, NIL); } } else doc = NewString(""); @@ -2286,10 +2356,10 @@ public: if (have_docstring(n)) Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_dest, pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_dest, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n)), "\n", NIL); if (have_pythonappend(n)) { Printv(f_dest, tab4 "val = ", funcCall(name, callParms), "\n", NIL); - Printv(f_dest, pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_dest, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n)), "\n", NIL); Printv(f_dest, tab4 "return val\n", NIL); } else { Printv(f_dest, tab4 "return ", funcCall(name, callParms), "\n", NIL); @@ -4498,7 +4568,7 @@ public: have_repr = 1; } if (Getattr(n, "feature:shadow")) { - String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n)); + String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n)); String *pyaction = NewStringf("%s.%s", module, fullname); Replaceall(pycode, "$action", pyaction); Delete(pyaction); @@ -4520,12 +4590,12 @@ public: Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); if (have_pythonprepend(n)) { fproxy = 0; - Printv(f_shadow, pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); } if (have_pythonappend(n)) { fproxy = 0; Printv(f_shadow, tab8, "val = ", funcCall(fullname, callParms), "\n", NIL); - Printv(f_shadow, pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n\n", NIL); @@ -4605,10 +4675,10 @@ public: if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow, pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); if (have_pythonappend(n)) { Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL); - Printv(f_shadow, pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL); @@ -4693,7 +4763,7 @@ public: if (!have_constructor && handled_as_init) { if (!builtin) { if (Getattr(n, "feature:shadow")) { - String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n)); + String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n)); String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); @@ -4722,7 +4792,7 @@ public: if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow, pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); Printv(f_shadow, pass_self, NIL); if (fastinit) { Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self, ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), ")\n", NIL); @@ -4732,7 +4802,7 @@ public: tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", tab8, "except:\n", tab8, tab4, "self.this = this\n", NIL); } if (have_pythonappend(n)) - Printv(f_shadow, pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n\n", NIL); Delete(pass_self); } have_constructor = 1; @@ -4741,7 +4811,7 @@ public: /* Hmmm. We seem to be creating a different constructor. We're just going to create a function for it. */ if (Getattr(n, "feature:shadow")) { - String *pycode = pythoncode(Getattr(n, "feature:shadow"), "", Getfile(n), Getline(n)); + String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), "", Getfile(n), Getline(n)); String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); @@ -4755,7 +4825,7 @@ public: if (have_docstring(n)) Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow_stubs, pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow_stubs, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n)), "\n", NIL); String *subfunc = NULL; /* if (builtin) @@ -4768,7 +4838,7 @@ public: Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); #endif if (have_pythonappend(n)) - Printv(f_shadow_stubs, pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow_stubs, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n)), "\n", NIL); Printv(f_shadow_stubs, tab4, "return val\n", NIL); Delete(subfunc); } @@ -4805,7 +4875,7 @@ public: if (shadow) { if (Getattr(n, "feature:shadow")) { - String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n)); + String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n)); String *pyaction = NewStringf("%s.%s", module, Swig_name_destroy(NSPACE_TODO, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); @@ -4823,7 +4893,7 @@ public: if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow, pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); #ifdef USE_THISOWN Printv(f_shadow, tab8, "try:\n", NIL); Printv(f_shadow, tab8, tab4, "if self.thisown:", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "(self)\n", NIL); @@ -4831,7 +4901,7 @@ public: #else #endif if (have_pythonappend(n)) - Printv(f_shadow, pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); Printv(f_shadow, tab8, "pass\n", NIL); Printv(f_shadow, "\n", NIL); } @@ -5011,12 +5081,12 @@ public: if (!ImportMode && (Cmp(section, "python") == 0 || Cmp(section, "shadow") == 0)) { if (shadow) { - String *pycode = pythoncode(code, shadow_indent, Getfile(n), Getline(n)); + String *pycode = indent_pythoncode(code, shadow_indent, Getfile(n), Getline(n)); Printv(f_shadow, pycode, NIL); Delete(pycode); } } else if (!ImportMode && (Cmp(section, "pythonbegin") == 0)) { - String *pycode = pythoncode(code, "", Getfile(n), Getline(n)); + String *pycode = indent_pythoncode(code, "", Getfile(n), Getline(n)); Printv(f_shadow_begin, pycode, NIL); Delete(pycode); } else { From a779f9bbc1aebb832663442a53dc70398858a310 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 28 Jul 2015 00:32:31 +0100 Subject: [PATCH 025/732] Function comment header formatting corrections --- Source/Modules/python.cxx | 112 ++++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 46 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index f91e43d82..d21c34f36 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1300,7 +1300,7 @@ public: /* ------------------------------------------------------------ * import_name_string() - * ------------------------------------------------------------ */ + * ------------------------------------------------------------ */ static String *import_name_string(const String *mainpkg, const String *mainmod, const String *pkg, const String *mod, const String *sym) { if (!relativeimport) { @@ -1346,9 +1346,10 @@ public: /* ------------------------------------------------------------ * funcCall() - * Emit shadow code to call a function in the extension - * module. Using proper argument and calling style for - * given node n. + * + * Emit shadow code to call a function in the extension + * module. Using proper argument and calling style for + * given node n. * ------------------------------------------------------------ */ String *funcCall(String *name, String *parms) { String *str = NewString(""); @@ -1574,8 +1575,9 @@ public: /* ------------------------------------------------------------ * have_docstring() - * Check if there is a docstring directive and it has text, - * or there is an autodoc flag set + * + * Check if there is a docstring directive and it has text, + * or there is an autodoc flag set * ------------------------------------------------------------ */ bool have_docstring(Node *n) { @@ -1585,9 +1587,10 @@ public: /* ------------------------------------------------------------ * docstring() - * Get the docstring text, stripping off {} if neccessary, - * and enclose in triple double quotes. If autodoc is also - * set then it will build a combined docstring. + * + * Get the docstring text, stripping off {} if neccessary, + * and enclose in triple double quotes. If autodoc is also + * set then it will build a combined docstring. * ------------------------------------------------------------ */ String *docstring(Node *n, autodoc_t ad_type, const String *indent, bool use_triple = true) { @@ -1650,8 +1653,9 @@ public: /* ------------------------------------------------------------ * cdocstring() - * Get the docstring text as it would appear in C-language - * source code. + * + * Get the docstring text as it would appear in C-language + * source code. * ------------------------------------------------------------ */ String *cdocstring(Node *n, autodoc_t ad_type) @@ -1680,7 +1684,8 @@ public: /* ----------------------------------------------------------------------------- * addMissingParameterNames() - * For functions that have not had nameless parameters set in the Language class. + * + * For functions that have not had nameless parameters set in the Language class. * * Inputs: * plist - entire parameter list @@ -1705,8 +1710,9 @@ public: /* ------------------------------------------------------------ * make_autodocParmList() - * Generate the documentation for the function parameters - * Parameters: + * + * Generate the documentation for the function parameters + * Parameters: * func_annotation: Function annotation support * ------------------------------------------------------------ */ @@ -1813,12 +1819,13 @@ public: /* ------------------------------------------------------------ * make_autodoc() - * Build a docstring for the node, using parameter and other - * info in the parse tree. If the value of the autodoc - * attribute is "0" then do not include parameter types, if - * it is "1" (the default) then do. If it has some other - * value then assume it is supplied by the extension writer - * and use it directly. + * + * Build a docstring for the node, using parameter and other + * info in the parse tree. If the value of the autodoc + * attribute is "0" then do not include parameter types, if + * it is "1" (the default) then do. If it has some other + * value then assume it is supplied by the extension writer + * and use it directly. * ------------------------------------------------------------ */ String *make_autodoc(Node *n, autodoc_t ad_type) { @@ -1957,9 +1964,10 @@ public: } /* ------------------------------------------------------------ - * convertDoubleValue() - * Check if the given string looks like a decimal floating point constant - * and return it if it does, otherwise return NIL. + * convertDoubleValue() + * + * Check if the given string looks like a decimal floating point constant + * and return it if it does, otherwise return NIL. * ------------------------------------------------------------ */ String *convertDoubleValue(String *v) { const char *const s = Char(v); @@ -2001,8 +2009,9 @@ public: /* ------------------------------------------------------------ * convertValue() - * Check if string v can be a Python value literal or a - * constant. Return NIL if it isn't. + * + * Check if string v can be a Python value literal or a + * constant. Return NIL if it isn't. * ------------------------------------------------------------ */ String *convertValue(String *v, SwigType *type) { const char *const s = Char(v); @@ -2124,12 +2133,13 @@ public: /* ------------------------------------------------------------ * is_representable_as_pyargs() - * Check if the function parameters default argument values - * can be represented in Python. * - * If this method returns false, the parameters will be translated - * to a generic "*args" which allows us to deal with default values - * at C++ code level where they can always be handled. + * Check if the function parameters default argument values + * can be represented in Python. + * + * If this method returns false, the parameters will be translated + * to a generic "*args" which allows us to deal with default values + * at C++ code level where they can always be handled. * ------------------------------------------------------------ */ bool is_representable_as_pyargs(Node *n) { ParmList *plist = CopyParmList(Getattr(n, "parms")); @@ -2171,9 +2181,10 @@ public: /* ------------------------------------------------------------ * is_real_overloaded() - * Check if the function is overloaded, but not just have some - * siblings generated due to the original function have - * default arguments. + * + * Check if the function is overloaded, but not just have some + * siblings generated due to the original function have + * default arguments. * ------------------------------------------------------------ */ bool is_real_overloaded(Node *n) { Node *h = Getattr(n, "sym:overloaded"); @@ -2197,8 +2208,9 @@ public: /* ------------------------------------------------------------ * make_pyParmList() - * Generate parameter list for Python functions or methods, - * reuse make_autodocParmList() to do so. + * + * Generate parameter list for Python functions or methods, + * reuse make_autodocParmList() to do so. * ------------------------------------------------------------ */ String *make_pyParmList(Node *n, bool in_class, bool is_calling, int kw) { /* Get the original function for a defaultargs copy, @@ -2244,7 +2256,8 @@ public: /* ------------------------------------------------------------ * have_pythonprepend() - * Check if there is a %pythonprepend directive and it has text + * + * Check if there is a %pythonprepend directive and it has text * ------------------------------------------------------------ */ bool have_pythonprepend(Node *n) { @@ -2254,7 +2267,8 @@ public: /* ------------------------------------------------------------ * pythonprepend() - * Get the %pythonprepend code, stripping off {} if neccessary + * + * Get the %pythonprepend code, stripping off {} if neccessary * ------------------------------------------------------------ */ String *pythonprepend(Node *n) { @@ -2269,7 +2283,8 @@ public: /* ------------------------------------------------------------ * have_pythonappend() - * Check if there is a %pythonappend directive and it has text + * + * Check if there is a %pythonappend directive and it has text * ------------------------------------------------------------ */ bool have_pythonappend(Node *n) { @@ -2281,7 +2296,8 @@ public: /* ------------------------------------------------------------ * pythonappend() - * Get the %pythonappend code, stripping off {} if neccessary + * + * Get the %pythonappend code, stripping off {} if neccessary * ------------------------------------------------------------ */ String *pythonappend(Node *n) { @@ -2299,7 +2315,8 @@ public: /* ------------------------------------------------------------ * have_addtofunc() - * Check if there is a %addtofunc directive and it has text + * + * Check if there is a %addtofunc directive and it has text * ------------------------------------------------------------ */ bool have_addtofunc(Node *n) { @@ -2309,8 +2326,9 @@ public: /* ------------------------------------------------------------ * returnTypeAnnotation() - * Helper function for constructing the function annotation - * of the returning type, return a empty string for Python 2.x + * + * Helper function for constructing the function annotation + * of the returning type, return a empty string for Python 2.x * ------------------------------------------------------------ */ String *returnTypeAnnotation(Node *n) { String *ret = 0; @@ -2343,9 +2361,10 @@ public: /* ------------------------------------------------------------ * emitFunctionShadowHelper() - * Refactoring some common code out of functionWrapper and - * dispatchFunction that writes the proxy code for non-member - * functions. + * + * Refactoring some common code out of functionWrapper and + * dispatchFunction that writes the proxy code for non-member + * functions. * ------------------------------------------------------------ */ void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) { @@ -2374,7 +2393,8 @@ public: /* ------------------------------------------------------------ * check_kwargs() - * check if using kwargs is allowed for this Node + * + * check if using kwargs is allowed for this Node * ------------------------------------------------------------ */ int check_kwargs(Node *n) const { From e69cc0c0f5dbd8c7950dcdd466aa504f8bbc9a9b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 29 Jul 2015 18:57:09 +0100 Subject: [PATCH 026/732] Improve python code indentation warning / error messages --- CHANGES.current | 24 +++++++++++ .../errors/swig_pythoncode_bad.stderr | 2 +- .../errors/swig_pythoncode_bad2.stderr | 2 +- .../test-suite/errors/swig_pythoncode_bad3.i | 7 ++++ .../errors/swig_pythoncode_bad3.stderr | 1 + Source/Modules/python.cxx | 42 +++++++++---------- 6 files changed, 55 insertions(+), 23 deletions(-) create mode 100644 Examples/test-suite/errors/swig_pythoncode_bad3.i create mode 100644 Examples/test-suite/errors/swig_pythoncode_bad3.stderr diff --git a/CHANGES.current b/CHANGES.current index de10ba23f..12b287626 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,30 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.7 (in progress) =========================== +2015-07-29: wsfulton + [Python] Improve indentation warning and error messages for code in the following directives: + + %pythonprepend + %pythonappend + %pythoncode + %pythonbegin + %feature("shadow") + + Old error example: + Error: Line indented less than expected (line 3 of pythoncode) + + New error example: + Error: Line indented less than expected (line 3 of %pythoncode or %insert("python") block) + as no line should be indented less than the indentation in line 1 + + Old warning example: + Warning 740: Whitespace prefix doesn't match (line 2 of %pythoncode or %insert("python") block) + + New warning example: + Warning 740: Whitespace indentation is inconsistent compared to earlier lines (line 3 of + %pythoncode or %insert("python") block) + + 2015-07-28: wsfulton [Python] Fix #475. Improve docstring indentation handling. diff --git a/Examples/test-suite/errors/swig_pythoncode_bad.stderr b/Examples/test-suite/errors/swig_pythoncode_bad.stderr index 71e5db8da..4bded5677 100644 --- a/Examples/test-suite/errors/swig_pythoncode_bad.stderr +++ b/Examples/test-suite/errors/swig_pythoncode_bad.stderr @@ -1 +1 @@ -swig_pythoncode_bad.i:7: Error: Line indented less than expected (line 2 of pythoncode) +swig_pythoncode_bad.i:7: Error: Line indented less than expected (line 2 of %pythoncode or %insert("python") block) as no line should be indented less than the indentation in line 1 diff --git a/Examples/test-suite/errors/swig_pythoncode_bad2.stderr b/Examples/test-suite/errors/swig_pythoncode_bad2.stderr index 48ad77e51..4fce40444 100644 --- a/Examples/test-suite/errors/swig_pythoncode_bad2.stderr +++ b/Examples/test-suite/errors/swig_pythoncode_bad2.stderr @@ -1 +1 @@ -swig_pythoncode_bad2.i:13: Error: Line indented less than expected (line 3 of pythoncode) +swig_pythoncode_bad2.i:13: Error: Line indented less than expected (line 3 of %pythoncode or %insert("python") block) as no line should be indented less than the indentation in line 1 diff --git a/Examples/test-suite/errors/swig_pythoncode_bad3.i b/Examples/test-suite/errors/swig_pythoncode_bad3.i new file mode 100644 index 000000000..5759158d9 --- /dev/null +++ b/Examples/test-suite/errors/swig_pythoncode_bad3.i @@ -0,0 +1,7 @@ +%module xxx + +%pythoncode %{ + def extra(): + print "extra a" # indentation is 2 spaces then tab + print "extra b" # indentation is tab then 2 spaces +%} diff --git a/Examples/test-suite/errors/swig_pythoncode_bad3.stderr b/Examples/test-suite/errors/swig_pythoncode_bad3.stderr new file mode 100644 index 000000000..2de4e7d05 --- /dev/null +++ b/Examples/test-suite/errors/swig_pythoncode_bad3.stderr @@ -0,0 +1 @@ +swig_pythoncode_bad3.i:7: Warning 740: Whitespace indentation is inconsistent compared to earlier lines (line 3 of %pythoncode or %insert("python") block) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index d21c34f36..5670d9581 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1366,7 +1366,7 @@ public: * the indentation string in 'indent'. * ------------------------------------------------------------ */ - String *indent_pythoncode(const String *code, const_String_or_char_ptr indent, String *file, int line) { + String *indent_pythoncode(const String *code, const_String_or_char_ptr indent, String *file, int line, const char *directive_name) { String *out = NewString(""); String *temp; char *t; @@ -1453,7 +1453,7 @@ public: if (i < Len(initial)) { // There's non-whitespace in the initial prefix of this line. - Swig_error(file, line, "Line indented less than expected (line %d of pythoncode)\n", py_line); + Swig_error(file, line, "Line indented less than expected (line %d of %s) as no line should be indented less than the indentation in line 1\n", py_line, directive_name); Printv(out, indent, c, "\n", NIL); } else { if (memcmp(c, Char(initial), Len(initial)) == 0) { @@ -1462,7 +1462,7 @@ public: continue; } Swig_warning(WARN_PYTHON_INDENT_MISMATCH, - file, line, "Whitespace prefix doesn't match (line %d of pythoncode)\n", py_line); + file, line, "Whitespace indentation is inconsistent compared to earlier lines (line %d of %s)\n", py_line, directive_name); // To avoid gratuitously breaking interface files which worked with // SWIG <= 3.0.5, we remove a prefix of the same number of bytes for // lines which start with different whitespace to the line we got @@ -2375,10 +2375,10 @@ public: if (have_docstring(n)) Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_dest, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_dest, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); if (have_pythonappend(n)) { Printv(f_dest, tab4 "val = ", funcCall(name, callParms), "\n", NIL); - Printv(f_dest, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_dest, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL); Printv(f_dest, tab4 "return val\n", NIL); } else { Printv(f_dest, tab4 "return ", funcCall(name, callParms), "\n", NIL); @@ -4588,7 +4588,7 @@ public: have_repr = 1; } if (Getattr(n, "feature:shadow")) { - String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n)); + String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n), "%feature(\"shadow\")"); String *pyaction = NewStringf("%s.%s", module, fullname); Replaceall(pycode, "$action", pyaction); Delete(pyaction); @@ -4610,12 +4610,12 @@ public: Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); if (have_pythonprepend(n)) { fproxy = 0; - Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); } if (have_pythonappend(n)) { fproxy = 0; Printv(f_shadow, tab8, "val = ", funcCall(fullname, callParms), "\n", NIL); - Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n\n", NIL); @@ -4695,10 +4695,10 @@ public: if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); if (have_pythonappend(n)) { Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL); - Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL); @@ -4783,7 +4783,7 @@ public: if (!have_constructor && handled_as_init) { if (!builtin) { if (Getattr(n, "feature:shadow")) { - String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n)); + String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n), "%feature(\"shadow\")"); String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); @@ -4812,7 +4812,7 @@ public: if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); Printv(f_shadow, pass_self, NIL); if (fastinit) { Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self, ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), ")\n", NIL); @@ -4822,7 +4822,7 @@ public: tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", tab8, "except:\n", tab8, tab4, "self.this = this\n", NIL); } if (have_pythonappend(n)) - Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n\n", NIL); Delete(pass_self); } have_constructor = 1; @@ -4831,7 +4831,7 @@ public: /* Hmmm. We seem to be creating a different constructor. We're just going to create a function for it. */ if (Getattr(n, "feature:shadow")) { - String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), "", Getfile(n), Getline(n)); + String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), "", Getfile(n), Getline(n), "%feature(\"shadow\")"); String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); @@ -4845,7 +4845,7 @@ public: if (have_docstring(n)) Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow_stubs, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow_stubs, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); String *subfunc = NULL; /* if (builtin) @@ -4858,7 +4858,7 @@ public: Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); #endif if (have_pythonappend(n)) - Printv(f_shadow_stubs, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow_stubs, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL); Printv(f_shadow_stubs, tab4, "return val\n", NIL); Delete(subfunc); } @@ -4895,7 +4895,7 @@ public: if (shadow) { if (Getattr(n, "feature:shadow")) { - String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n)); + String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n), "%feature(\"shadow\")"); String *pyaction = NewStringf("%s.%s", module, Swig_name_destroy(NSPACE_TODO, symname)); Replaceall(pycode, "$action", pyaction); Delete(pyaction); @@ -4913,7 +4913,7 @@ public: if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); #ifdef USE_THISOWN Printv(f_shadow, tab8, "try:\n", NIL); Printv(f_shadow, tab8, tab4, "if self.thisown:", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "(self)\n", NIL); @@ -4921,7 +4921,7 @@ public: #else #endif if (have_pythonappend(n)) - Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n)), "\n", NIL); + Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL); Printv(f_shadow, tab8, "pass\n", NIL); Printv(f_shadow, "\n", NIL); } @@ -5101,12 +5101,12 @@ public: if (!ImportMode && (Cmp(section, "python") == 0 || Cmp(section, "shadow") == 0)) { if (shadow) { - String *pycode = indent_pythoncode(code, shadow_indent, Getfile(n), Getline(n)); + String *pycode = indent_pythoncode(code, shadow_indent, Getfile(n), Getline(n), "%pythoncode or %insert(\"python\") block"); Printv(f_shadow, pycode, NIL); Delete(pycode); } } else if (!ImportMode && (Cmp(section, "pythonbegin") == 0)) { - String *pycode = indent_pythoncode(code, "", Getfile(n), Getline(n)); + String *pycode = indent_pythoncode(code, "", Getfile(n), Getline(n), "%pythonbegin or %insert(\"pythonbegin\") block"); Printv(f_shadow_begin, pycode, NIL); Delete(pycode); } else { From 366e8a9f0634f255ad29e988beec949f9821b208 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Sat, 25 Jul 2015 02:18:00 +0300 Subject: [PATCH 027/732] Restored broken ignoring of operators etc. Added more comments. Added check for explicit $ignore, to allow correct using protected symbols This is a single commit for patch #476 --- Source/CParse/parser.y | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 26e6549c5..1beaaef27 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -466,14 +466,20 @@ static void add_symbols(Node *n) { if (only_csymbol || GetFlag(n,"feature:ignore") || strncmp(Char(symname),"$ignore",7) == 0) { /* Only add to C symbol table and continue */ Swig_symbol_add(0, n); - if (strncmp(Char(symname),"$ignore",7) == 0) { + if (!only_csymbol && !GetFlag(n, "feature:ignore")) { + /* Print the warning attached to $ignore name, if any */ char *c = Char(symname) + 7; - SetFlag(n, "feature:ignore"); if (strlen(c)) { SWIG_WARN_NODE_BEGIN(n); Swig_warning(0,Getfile(n), Getline(n), "%s\n",c+1); SWIG_WARN_NODE_END(n); } + /* If the symbol was ignored via "rename" and is visible, set also feature:ignore*/ + SetFlag(n, "feature:ignore"); + } + if (!GetFlag(n, "feature:ignore") && Strcmp(symname,"$ignore") == 0) { + /* Add feature:ignore if the symbol was explicitely ignored, regardless of visibility */ + SetFlag(n, "feature:ignore"); } } else { Node *c; From cd04b372a44c4f9a46b4f59f4aa83c08d0a2df3d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Jul 2015 20:20:38 +0100 Subject: [PATCH 028/732] Consistent memory intiailization between C and C++ in typemaps Remove unnecessary initialization via calloc calls and replace with malloc. --- Lib/java/arrays_java.i | 6 +++--- Lib/java/various.i | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/java/arrays_java.i b/Lib/java/arrays_java.i index 4b780aef9..402f088d5 100644 --- a/Lib/java/arrays_java.i +++ b/Lib/java/arrays_java.i @@ -52,7 +52,7 @@ static int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **ca #ifdef __cplusplus %{ *carr = new CTYPE[sz]; %} #else -%{ *carr = (CTYPE*) calloc(sz, sizeof(CTYPE)); %} +%{ *carr = (CTYPE*) malloc(sz * sizeof(CTYPE)); %} #endif %{ if (!*carr) { SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); @@ -259,7 +259,7 @@ JAVA_ARRAYS_TYPEMAPS(double, double, jdouble, Double, "[D") /* double[ANY] * #ifdef __cplusplus $1 = new $*1_ltype[sz]; #else - $1 = ($1_ltype) calloc(sz, sizeof($*1_ltype)); + $1 = ($1_ltype) malloc(sz * sizeof($*1_ltype)); #endif if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); @@ -289,7 +289,7 @@ JAVA_ARRAYS_TYPEMAPS(double, double, jdouble, Double, "[D") /* double[ANY] * #ifdef __cplusplus $1 = new $*1_ltype[sz]; #else - $1 = ($1_ltype) calloc(sz, sizeof($*1_ltype)); + $1 = ($1_ltype) malloc(sz * sizeof($*1_ltype)); #endif if (!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); diff --git a/Lib/java/various.i b/Lib/java/various.i index e8042b763..76fb2b129 100644 --- a/Lib/java/various.i +++ b/Lib/java/various.i @@ -29,7 +29,7 @@ #ifdef __cplusplus $1 = new char*[size+1]; #else - $1 = (char **)calloc(size+1, sizeof(char *)); + $1 = (char **)malloc((size+1) * sizeof(char *)); #endif for (i = 0; i Date: Thu, 30 Jul 2015 20:36:13 +0100 Subject: [PATCH 029/732] Initialise all newly created arrays in arrays.i library. Affects C++ code only. Closes #440. --- CHANGES.current | 4 ++++ Lib/carrays.i | 2 +- Lib/d/carrays.i | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 12b287626..61b461b6b 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.7 (in progress) =========================== +2015-07-30: wsfulton + Fix #440 - Initialise all newly created arrays when using %array_functions and %array_class + in the carrays.i library - bug is only relevant when using C++. + 2015-07-29: wsfulton [Python] Improve indentation warning and error messages for code in the following directives: diff --git a/Lib/carrays.i b/Lib/carrays.i index 201c17cac..3a9c3cfee 100644 --- a/Lib/carrays.i +++ b/Lib/carrays.i @@ -81,7 +81,7 @@ typedef struct { #ifdef __cplusplus NAME(int nelements) { - return new TYPE[nelements]; + return new TYPE[nelements](); } ~NAME() { delete [] self; diff --git a/Lib/d/carrays.i b/Lib/d/carrays.i index 37b59c871..f2803ea46 100644 --- a/Lib/d/carrays.i +++ b/Lib/d/carrays.i @@ -21,7 +21,7 @@ %{ static TYPE *new_##NAME(int nelements) { %} #ifdef __cplusplus -%{ return new TYPE[nelements]; %} +%{ return new TYPE[nelements](); %} #else %{ return (TYPE *) calloc(nelements,sizeof(TYPE)); %} #endif @@ -78,7 +78,7 @@ typedef struct {} NAME; %extend NAME { #ifdef __cplusplus NAME(int nelements) { - return new TYPE[nelements]; + return new TYPE[nelements](); } ~NAME() { delete [] self; From 4b23f5d9d4030a551eaac55aa910ce909745ae8a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Jul 2015 20:39:52 +0100 Subject: [PATCH 030/732] Consistent memory initialization in php typemaps. Memory was only initialized in C and not C++ - potential bug? --- Lib/php/php.swg | 2 +- Lib/php/typemaps.i | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 8b5fb7be3..05d25a1df 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -170,7 +170,7 @@ force=0; if (arg1==NULL) { #ifdef __cplusplus - ptr=new $*1_ltype; + ptr=new $*1_ltype(); #else ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); #endif diff --git a/Lib/php/typemaps.i b/Lib/php/typemaps.i index ca49ec327..0372884a6 100644 --- a/Lib/php/typemaps.i +++ b/Lib/php/typemaps.i @@ -299,7 +299,7 @@ INT_TYPEMAP(unsigned long long); force=0; if (arg1==NULL) { #ifdef __cplusplus - ptr=new $*1_ltype; + ptr=new $*1_ltype(); #else ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); #endif From a3f0921c577a5f169080641e59bd247b5fb322b9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Jul 2015 23:32:54 +0100 Subject: [PATCH 031/732] Ocaml configure changes Remove use of peculiar ':' default for OCAML in AC_CHECK_PROGS. Further refinement of issue #458. --- configure.ac | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index bc9567219..62dd4f6e9 100644 --- a/configure.ac +++ b/configure.ac @@ -1881,27 +1881,27 @@ if test x"${with_ocaml}" = xno -o x"${with_alllang}" = xno ; then else AC_MSG_CHECKING(for Ocaml DL load generator) if test -z "$OCAMLDLGEN"; then - AC_CHECK_PROGS(OCAMLDLGEN, ocamldlgen, :) + AC_CHECK_PROGS(OCAMLDLGEN, ocamldlgen) fi AC_MSG_CHECKING(for Ocaml package tool) if test -z "$OCAMLFIND"; then - AC_CHECK_PROGS(OCAMLFIND, ocamlfind, :) + AC_CHECK_PROGS(OCAMLFIND, ocamlfind) fi AC_MSG_CHECKING(for Ocaml compiler) if test -z "$OCAMLC"; then - AC_CHECK_PROGS(OCAMLC, ocamlc, ) + AC_CHECK_PROGS(OCAMLC, ocamlc) fi AC_MSG_CHECKING(for Ocaml toplevel creator) if test -z "$OCAMLMKTOP"; then - AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop, :) + AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop) fi AC_MSG_CHECKING(for Ocaml Pre-Processor-Pretty-Printer) if test -z "$CAMLP4"; then - AC_CHECK_PROGS(CAMLP4, camlp4, :) + AC_CHECK_PROGS(CAMLP4, camlp4) fi fi # Disabling ocaml From 2837550c4b1d1d5d6b3f366e164f97dee1ff78f2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 27 Jul 2015 17:19:36 +0200 Subject: [PATCH 032/732] Remove executable permission from appveyor.yml. This is not an executable file. --- appveyor.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml old mode 100755 new mode 100644 From cc6804724f686ce84408ed40e962179f9bde9d32 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 1 Aug 2015 17:43:36 +0100 Subject: [PATCH 033/732] Improve configure output when python is not installed --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d66888390..beab8c551 100644 --- a/configure.ac +++ b/configure.ac @@ -629,7 +629,7 @@ else fi fi - if test $PYVER -le 2; then + if test $PYVER -eq 1 -o $PYVER -eq 2; then AC_MSG_CHECKING(for Python prefix) PYPREFIX=`($PYTHON -c "import sys; sys.stdout.write(sys.prefix)") 2>/dev/null` AC_MSG_RESULT($PYPREFIX) From 2e7331964a39fc50fb04a8398f415a6d3b3b3732 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 27 Jul 2015 16:12:17 +0200 Subject: [PATCH 034/732] Use JAVA_HOME value in configure to detect Java. This is simpler than having to use --with-java, --with-javac and --with-javaincl options and, even more importantly, will usually just work by default. --- appveyor.yml | 2 +- configure.ac | 110 +++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 95 insertions(+), 17 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 25abcb342..dc96d0bca 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -65,7 +65,7 @@ build_script: - set CCCL_OPTIONS=--cccl-muffle /W3 - set CHECK_OPTIONS=CSHARPOPTIONS=-platform:%Platform% # Open dummy file descriptor to fix error on cygwin: ./configure: line 560: 0: Bad file descriptor -- bash -c "exec 0 Date: Sat, 1 Aug 2015 23:08:53 +0100 Subject: [PATCH 035/732] Move MinGW mixed path conversion code to the pathconvert tool In preparation for adding MinGW support to patch #438. --- Tools/convertpath | 21 ++++++++++++++------- configure.ac | 8 ++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Tools/convertpath b/Tools/convertpath index fce5ac24b..0cc8b74bb 100755 --- a/Tools/convertpath +++ b/Tools/convertpath @@ -1,25 +1,32 @@ #!/bin/sh -# Unix to Windows relative path conversion in a script. +# Unix to Windows path conversion in a script. # Useful for avoiding backslash quoting difficulties in Makefiles. -# Acts as a much dumbed down 'cygpath -w' tool. +# Acts as a much dumbed down cygpath tool mainly for use on MinGW. usage() { cat <&2; exit 1 ;; + esac ;; -u) shift; echo $@ | sed -e 's,\\,/,g' ;; + -w) shift; echo $@ | sed -e 's,/,\\,g' ;; -h) shift; usage; ;; *) usage; exit 1 ;; esac diff --git a/configure.ac b/configure.ac index beab8c551..18728bea0 100644 --- a/configure.ac +++ b/configure.ac @@ -2821,10 +2821,10 @@ AC_SUBST(swig_lib) AC_DEFINE_DIR(SWIG_LIB, swig_lib, [Directory for SWIG system-independent libraries]) case $build in - # Windows does not understand unix directories. Convert into a windows directory with drive letter. - *-*-mingw*) SWIG_LIB_WIN_UNIX=`cmd //c echo $SWIG_LIB | sed -e "s/[ ]*$//"`;; # This echo converts unix to mixed paths. Then zap unexpected trailing space. - *-*-cygwin*) SWIG_LIB_WIN_UNIX=`cygpath --mixed "$SWIG_LIB"`;; - *) SWIG_LIB_WIN_UNIX="";; + # Windows does not understand unix directories. Convert into a windows directory with drive letter. + *-*-mingw*) SWIG_LIB_WIN_UNIX=`${srcdir}/Tools/convertpath -m $SWIG_LIB`;; + *-*-cygwin*) SWIG_LIB_WIN_UNIX=`cygpath --mixed "$SWIG_LIB"`;; + *) SWIG_LIB_WIN_UNIX="";; esac AC_DEFINE_UNQUOTED(SWIG_LIB_WIN_UNIX, ["$SWIG_LIB_WIN_UNIX"], [Directory for SWIG system-independent libraries (Unix install on native Windows)]) From f5db2b43e673b6e2a5c6b4bc2db4469b31eb4b54 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 2 Aug 2015 10:05:09 +0100 Subject: [PATCH 036/732] SWIG_LIB fix for out of source MinGW builds --- configure.ac | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 3877811d4..1d5983f74 100644 --- a/configure.ac +++ b/configure.ac @@ -2796,9 +2796,8 @@ dnl built using MinGW or cccl compiler in Cygwin environment). However it may, dnl although this is probably more rare, also be built as a Cygwin program. dnl Using "mixed" path like we do here allows the path to work in both cases. case $host in -*-*-cygwin* ) - ABS_SRCDIR=`cygpath --mixed $ABS_SRCDIR` - ;; + *-*-mingw* ) ABS_SRCDIR=`${srcdir}/Tools/convertpath -m $ABS_SRCDIR` ;; + *-*-cygwin* ) ABS_SRCDIR=`cygpath --mixed $ABS_SRCDIR` ;; esac # Root directory From a1771cb8a0cbba65ffd07bee96a2cb41a9f112fd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 1 Aug 2015 08:01:06 +0100 Subject: [PATCH 037/732] Fix potential security exploit in generated Java classes --- CHANGES.current | 15 +++++++++++++ Doc/Manual/Java.html | 22 +++++++++---------- Examples/test-suite/java_typemaps_proxy.i | 8 +++---- .../test-suite/java_typemaps_typewrapper.i | 2 +- Lib/java/boost_intrusive_ptr.i | 8 +++---- Lib/java/boost_shared_ptr.i | 6 ++--- Lib/java/java.swg | 8 +++---- 7 files changed, 42 insertions(+), 27 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 61b461b6b..33ad11630 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,21 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.7 (in progress) =========================== +2015-08-02: wsfulton + [Java] Fix potential security exploit in generated Java classes. + The swigCPtr and swigCMemOwn member variables in the generated Java + classes are now declared 'transient' by default. Further details of the exploit + in Android is being published in an academic paper as part of USENIX WOOT '15: + https://www.usenix.org/conference/woot15/workshop-program/presentation/peles. + + In the unlikely event that you are relying on these members being serializable, + then you will need to override the default javabody and javabody_derived typemaps + to generate the old generated code. The relevant typemaps are in the Lib directory + in the java.swg, boost_shared_ptr.i and boost_intrusive_ptr.i files. Copy the + relevant default typemaps into your interface file and remove the 'transient' keyword. + + *** POTENTIAL INCOMPATIBILITY *** + 2015-07-30: wsfulton Fix #440 - Initialise all newly created arrays when using %array_functions and %array_class in the carrays.i library - bug is only relevant when using C++. diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 3a4f7ee5d..9d5c447f7 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -2390,8 +2390,8 @@ The default proxy class for our previous example looks like this:
       public class Foo {
      -  private long swigCPtr;
      -  protected boolean swigCMemOwn;
      +  private transient long swigCPtr;
      +  protected transient boolean swigCMemOwn;
       
         protected Foo(long cPtr, boolean cMemoryOwn) {
           swigCMemOwn = cMemoryOwn;
      @@ -2641,8 +2641,8 @@ The base class is generated much like any other proxy class seen so far:
       
       
       public class Base {
      -  private long swigCPtr;
      -  protected boolean swigCMemOwn;
      +  private transient long swigCPtr;
      +  protected transient boolean swigCMemOwn;
       
         protected Base(long cPtr, boolean cMemoryOwn) {
           swigCMemOwn = cMemoryOwn;
      @@ -2682,7 +2682,7 @@ The Derived class extends Base mirroring the C++ class inherit
       
       
       public class Derived extends Base {
      -  private long swigCPtr;
      +  private transient long swigCPtr;
       
         protected Derived(long cPtr, boolean cMemoryOwn) {
           super(exampleJNI.SWIGDerivedUpcast(cPtr), cMemoryOwn);
      @@ -2960,8 +2960,8 @@ and the Java proxy class generated by SWIG:
       
       
       public class Test {
      -  private long swigCPtr;
      -  protected boolean swigCMemOwn;
      +  private transient long swigCPtr;
      +  protected transient boolean swigCMemOwn;
       
         protected Test(long cPtr, boolean cMemoryOwn) {
           swigCMemOwn = cMemoryOwn;
      @@ -3034,7 +3034,7 @@ The generated type wrapper class, for say an int *, looks like this:
       
       
       public class SWIGTYPE_p_int {
      -  private long swigCPtr;
      +  private transient long swigCPtr;
       
         protected SWIGTYPE_p_int(long cPtr, boolean bFutureUse) {
           swigCPtr = cPtr;
      @@ -5900,8 +5900,8 @@ If you are invoking SWIG more than once and generating the wrapped classes into
       
       %typemap(javabody) SWIGTYPE %{
      -  private long swigCPtr;
      -  protected boolean swigCMemOwn;
      +  private transient long swigCPtr;
      +  protected transient boolean swigCMemOwn;
       
         protected $javaclassname(long cPtr, boolean cMemoryOwn) {
           swigCMemOwn = cMemoryOwn;
      @@ -5929,7 +5929,7 @@ For the typemap to be used in all type wrapper classes, all the different types
       
       %typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
      -  private long swigCPtr;
      +  private transient long swigCPtr;
       
         protected $javaclassname(long cPtr, boolean bFutureUse) {
           swigCPtr = cPtr;
      diff --git a/Examples/test-suite/java_typemaps_proxy.i b/Examples/test-suite/java_typemaps_proxy.i
      index e315a36b5..3e9b18335 100644
      --- a/Examples/test-suite/java_typemaps_proxy.i
      +++ b/Examples/test-suite/java_typemaps_proxy.i
      @@ -31,8 +31,8 @@ import java.lang.*; // for Exception
       
       // Create a new getCPtr() function which takes Java null and is public
       %typemap(javabody) NS::Greeting %{
      -  private long swigCPtr;
      -  protected boolean swigCMemOwn;
      +  private transient long swigCPtr;
      +  protected transient boolean swigCMemOwn;
       
         protected $javaclassname(long cPtr, boolean cMemoryOwn) {
           swigCMemOwn = cMemoryOwn;
      @@ -46,8 +46,8 @@ import java.lang.*; // for Exception
       
       // Make the pointer constructor public
       %typemap(javabody) NS::Farewell %{
      -  private long swigCPtr;
      -  protected boolean swigCMemOwn;
      +  private transient long swigCPtr;
      +  protected transient boolean swigCMemOwn;
       
         public $javaclassname(long cPtr, boolean cMemoryOwn) {
           swigCMemOwn = cMemoryOwn;
      diff --git a/Examples/test-suite/java_typemaps_typewrapper.i b/Examples/test-suite/java_typemaps_typewrapper.i
      index a99ca7b65..b7bf847ef 100644
      --- a/Examples/test-suite/java_typemaps_typewrapper.i
      +++ b/Examples/test-suite/java_typemaps_typewrapper.i
      @@ -39,7 +39,7 @@ import java.lang.*; // for Exception
       // Create a new getCPtr() function which takes Java null and is public
       // Make the pointer constructor public
       %typemap(javabody) Farewell * %{
      -  private long swigCPtr;
      +  private transient long swigCPtr;
       
         public $javaclassname(long cPtr, boolean bFutureUse) {
           swigCPtr = cPtr;
      diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i
      index f9525894f..1d8fa7445 100644
      --- a/Lib/java/boost_intrusive_ptr.i
      +++ b/Lib/java/boost_intrusive_ptr.i
      @@ -263,7 +263,7 @@
       
       // Base proxy classes
       %typemap(javabody) TYPE %{
      -  private long swigCPtr;
      +  private transient long swigCPtr;
         private boolean swigCMemOwnBase;
       
         PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
      @@ -278,7 +278,7 @@
       
       // Derived proxy classes
       %typemap(javabody_derived) TYPE %{
      -  private long swigCPtr;
      +  private transient long swigCPtr;
         private boolean swigCMemOwnDerived;
       
         PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
      @@ -413,7 +413,7 @@
       
       // Base proxy classes
       %typemap(javabody) TYPE %{
      -  private long swigCPtr;
      +  private transient long swigCPtr;
         private boolean swigCMemOwnBase;
       
         PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
      @@ -428,7 +428,7 @@
       
       // Derived proxy classes
       %typemap(javabody_derived) TYPE %{
      -  private long swigCPtr;
      +  private transient long swigCPtr;
         private boolean swigCMemOwnDerived;
       
         PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
      diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i
      index e75236993..136570da5 100644
      --- a/Lib/java/boost_shared_ptr.i
      +++ b/Lib/java/boost_shared_ptr.i
      @@ -145,8 +145,8 @@
       
       // Base proxy classes
       %typemap(javabody) TYPE %{
      -  private long swigCPtr;
      -  private boolean swigCMemOwn;
      +  private transient long swigCPtr;
      +  private transient boolean swigCMemOwn;
       
         PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
           swigCMemOwn = cMemoryOwn;
      @@ -160,7 +160,7 @@
       
       // Derived proxy classes
       %typemap(javabody_derived) TYPE %{
      -  private long swigCPtr;
      +  private transient long swigCPtr;
         private boolean swigCMemOwnDerived;
       
         PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
      diff --git a/Lib/java/java.swg b/Lib/java/java.swg
      index 22a4884ef..2e106796c 100644
      --- a/Lib/java/java.swg
      +++ b/Lib/java/java.swg
      @@ -1148,8 +1148,8 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
       %define SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
       // Base proxy classes
       %typemap(javabody) TYPE %{
      -  private long swigCPtr;
      -  protected boolean swigCMemOwn;
      +  private transient long swigCPtr;
      +  protected transient boolean swigCMemOwn;
       
         PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
           swigCMemOwn = cMemoryOwn;
      @@ -1163,7 +1163,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
       
       // Derived proxy classes
       %typemap(javabody_derived) TYPE %{
      -  private long swigCPtr;
      +  private transient long swigCPtr;
       
         PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
           super($imclassname.$javaclazznameSWIGUpcast(cPtr), cMemoryOwn);
      @@ -1179,7 +1179,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
       %define SWIG_JAVABODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
       // Typewrapper classes
       %typemap(javabody) TYPE *, TYPE &, TYPE &&, TYPE [] %{
      -  private long swigCPtr;
      +  private transient long swigCPtr;
       
         PTRCTOR_VISIBILITY $javaclassname(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
           swigCPtr = cPtr;
      
      From 651ad3030c709df13a49c365ead98e0cd0ac21cf Mon Sep 17 00:00:00 2001
      From: Vadim Zeitlin 
      Date: Sun, 2 Aug 2015 15:40:41 +0200
      Subject: [PATCH 038/732] Don't duplicate Java headers path under OS X in
       configure.
      
      Use /System/Library/Frameworks/JavaVM.framework/Headers in a single place only
      to make it easier to change it later and, hopefully, make the rather
      convoluted process of Java detection under OS X slightly more clear.
      ---
       configure.ac | 8 ++++----
       1 file changed, 4 insertions(+), 4 deletions(-)
      
      diff --git a/configure.ac b/configure.ac
      index 12105fb80..eea0a8133 100644
      --- a/configure.ac
      +++ b/configure.ac
      @@ -1217,9 +1217,9 @@ case $host in
           fi
           dnl The JAVA_HOME doesn't contain the JDK headers though, but they seem to
           dnl always be in the same location, according to Apple JNI documentation.
      -    JAVA_HOME_INCDIR="/System/Library/Frameworks/JavaVM.framework/Headers"
      -    if ! test -r "$JAVA_HOME_INCDIR/jni.h"; then
      -      JAVA_HOME_INCDIR=
      +    JAVA_OSX_STD_INCDIR="/System/Library/Frameworks/JavaVM.framework/Headers"
      +    if test -r "$JAVA_OSX_STD_INCDIR/jni.h"; then
      +      JAVA_HOME_INCDIR=$JAVA_OSX_STD_INCDIR
           fi
           ;;
       esac
      @@ -1292,7 +1292,7 @@ if test -z "$JAVAINCDIR" ; then
           # Add in default installation directory on Windows for Cygwin
           case $host in
           *-*-cygwin* | *-*-mingw*) JAVAINCDIR="c:/Program*Files*/Java/jdk*/include d:/Program*Files*/Java/jdk*/include c:/j2sdk*/include d:/j2sdk*/include c:/jdk*/include d:/jdk*/include $JAVAINCDIR";;
      -    *-*-darwin*) JAVAINCDIR="/System/Library/Frameworks/JavaVM.framework/Headers $JAVAINCDIR";;
      +    *-*-darwin*) JAVAINCDIR="$JAVA_OSX_STD_INCDIR $JAVAINCDIR";;
           *);;
           esac
       
      
      From 11974efe2e1e253693a69048c8617da74b39c892 Mon Sep 17 00:00:00 2001
      From: Vadim Zeitlin 
      Date: Sat, 1 Aug 2015 19:08:57 +0200
      Subject: [PATCH 039/732] Cosmetic: fix wrong configure options indentation in
       --help.
      
      Ensure that help for all options starts in the same column (unless the options
      are too long, as --with-guile-config=path, but at least avoid indenting it by
      a tab stop then).
      ---
       configure.ac | 16 ++++++++--------
       1 file changed, 8 insertions(+), 8 deletions(-)
      
      diff --git a/configure.ac b/configure.ac
      index f75bf44d3..84a074915 100644
      --- a/configure.ac
      +++ b/configure.ac
      @@ -1368,7 +1368,7 @@ else
       
         # check for include files
         AC_MSG_CHECKING(for JavaScriptCore/JavaScript.h)
      -  AC_ARG_WITH(jscoreinc, [  --with-jscinc=path    Set location of Javascript include directory], [JSCOREINCDIR="$withval"], [JSCOREINCDIR=])
      +  AC_ARG_WITH(jscoreinc, [  --with-jscinc=path      Set location of Javascript include directory], [JSCOREINCDIR="$withval"], [JSCOREINCDIR=])
       
         JSCOREVERSION=
       
      @@ -1402,7 +1402,7 @@ else
         fi
       
         # check for JavaScriptCore/Webkit libraries
      -  AC_ARG_WITH(jscorelib,[  --with-jsclib =path      Set location of the JavaScriptCore/Webkit library directory],[JSCORELIB="-L$withval"], [JSCORELIB=])
      +  AC_ARG_WITH(jscorelib,[  --with-jsclib=path      Set location of the JavaScriptCore/Webkit library directory],[JSCORELIB="-L$withval"], [JSCORELIB=])
       
         if test -z "$JSCORELIB" -a -n "$PKGCONFIG"; then
           AC_MSG_CHECKING(for JavaScriptCore/Webkit library)
      @@ -1426,7 +1426,7 @@ else
       
         # check for include files
         AC_MSG_CHECKING(for V8 Javascript v8.h)
      -  AC_ARG_WITH(jsv8inc, [  --with-jsv8inc=path    Set location of Javascript v8 include directory], [JSV8INCDIR="$withval"])
      +  AC_ARG_WITH(jsv8inc, [  --with-jsv8inc=path     Set location of Javascript v8 include directory], [JSV8INCDIR="$withval"])
       
         # if not include dir is specified we try to find
         if test -z "$JSV8INCDIR"; then
      @@ -1459,7 +1459,7 @@ else
       
         # check for V8 library
         AC_MSG_CHECKING(for V8 Javascript library)
      -  AC_ARG_WITH(jsv8lib,[  --with-jsv8lib=path      Set location of V8 Javascript library directory],[JSV8LIBDIR="$withval"], [JSV8LIB=])
      +  AC_ARG_WITH(jsv8lib,[  --with-jsv8lib=path     Set location of V8 Javascript library directory],[JSV8LIBDIR="$withval"], [JSV8LIB=])
       
         v8libdirs="$JSV8LIBDIR /usr/lib64/ /usr/local/lib64/ /usr/lib/ /usr/local/lib/"
         for d in $v8libdirs ; do
      @@ -1543,9 +1543,9 @@ AC_SUBST(GCJH)
       
       AC_ARG_WITH(android, AS_HELP_STRING([--without-android], [Disable Android])
       AS_HELP_STRING([--with-android=path], [Set location of android executable]),[ANDROIDBIN="$withval"], [ANDROIDBIN=yes])
      -AC_ARG_WITH(adb, [  --with-adb=path       Set location of adb executable - Android Debug Bridge],[ADBBIN="$withval"], [ADBBIN=])
      -AC_ARG_WITH(ant, [  --with-ant=path       Set location of ant executable for Android],[ANTBIN="$withval"], [ANTBIN=])
      -AC_ARG_WITH(ndk-build, [  --with-ndk-build=path       Set location of Android ndk-build executable],[NDKBUILDBIN="$withval"], [NDKBUILDBIN=])
      +AC_ARG_WITH(adb, [  --with-adb=path         Set location of adb executable - Android Debug Bridge],[ADBBIN="$withval"], [ADBBIN=])
      +AC_ARG_WITH(ant, [  --with-ant=path         Set location of ant executable for Android],[ANTBIN="$withval"], [ANTBIN=])
      +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
      @@ -1591,7 +1591,7 @@ 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=])
      +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],[
      
      From 1824cabcbce47995fcd1213194842f741b2114be Mon Sep 17 00:00:00 2001
      From: Vadim Zeitlin 
      Date: Sat, 1 Aug 2015 19:16:58 +0200
      Subject: [PATCH 040/732] Make configure --without-alllang option actually
       useful.
      
      Use it to disable all languages by default, but still allow enabling
      individual languages by explicitly using --with-lang options for them.
      
      E.g. to enable tests for Java only "--without-alllang --with-java" can now be
      used to skip the configure checks for all the other languages.
      ---
       CHANGES.current |   4 ++
       configure.ac    | 102 +++++++++++++++++++++++++-----------------------
       2 files changed, 58 insertions(+), 48 deletions(-)
      
      diff --git a/CHANGES.current b/CHANGES.current
      index 33ad11630..48ccc2036 100644
      --- a/CHANGES.current
      +++ b/CHANGES.current
      @@ -20,6 +20,10 @@ Version 3.0.7 (in progress)
       
                   *** POTENTIAL INCOMPATIBILITY ***
       
      +2015-08-01: vadz
      +            Make configure --without-alllang option more useful: it can now be overridden by the following
      +            --with-xxx options, allowing to easily enable just one or two languages.
      +
       2015-07-30: wsfulton
                   Fix #440 - Initialise all newly created arrays when using %array_functions and %array_class
                   in the carrays.i library - bug is only relevant when using C++.
      diff --git a/configure.ac b/configure.ac
      index 84a074915..8447e728e 100644
      --- a/configure.ac
      +++ b/configure.ac
      @@ -464,6 +464,12 @@ fi])
       
       AC_ARG_WITH(alllang, AS_HELP_STRING([--without-alllang], [Disable all languages]), with_alllang="$withval")
       
      +if test "$with_alllang" = "no"; then
      +  alllang_default=no
      +else
      +  alllang_default=yes
      +fi
      +
       AC_CHECK_PROGS(PKGCONFIG, [pkg-config])
       
       #--------------------------------------------------------------------
      @@ -478,14 +484,14 @@ AC_ARG_WITH(tclconfig, AS_HELP_STRING([--without-tcl], [Disable Tcl])
       AS_HELP_STRING([--with-tclconfig=path], [Set location of tclConfig.sh]), [with_tclconfig="$withval"], [with_tclconfig=])
       AC_ARG_WITH(tcl,
        [  --with-tcl=path         Set location of Tcl package],[
      -	TCLPACKAGE="$withval"], [TCLPACKAGE=yes])
      +	TCLPACKAGE="$withval"], [TCLPACKAGE="$alllang_default"])
       AC_ARG_WITH(tclincl,[  --with-tclincl=path     Set location of Tcl include directory],[
       	TCLINCLUDE="$ISYSTEM$withval"], [TCLINCLUDE=])
       AC_ARG_WITH(tcllib,[  --with-tcllib=path      Set location of Tcl library directory],[
       	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; then
       AC_MSG_NOTICE([Disabling Tcl])
       else
       AC_MSG_CHECKING([for Tcl configuration])
      @@ -606,10 +612,10 @@ PYLINK=
       PYPACKAGE=
       
       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])
      +AS_HELP_STRING([--with-python=path], [Set location of Python executable]),[ PYBIN="$withval"], [PYBIN="$alllang_default"])
       
       # 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; then
         AC_MSG_NOTICE([Disabling Python])
       else
         # First figure out the name of the Python executable
      @@ -747,10 +753,10 @@ PY3LINK=
       PY3PACKAGE=
       
       AC_ARG_WITH(python3, AS_HELP_STRING([--without-python3], [Disable Python 3.x support])
      -AS_HELP_STRING([--with-python3=path], [Set location of Python 3.x executable]),[ PY3BIN="$withval"], [PY3BIN=yes])
      +AS_HELP_STRING([--with-python3=path], [Set location of Python 3.x executable]),[ PY3BIN="$withval"], [PY3BIN="$alllang_default"])
       
       # 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; then
         AC_MSG_NOTICE([Disabling Python 3.x support])
       else
         if test "x$PY3BIN" = xyes; then
      @@ -902,10 +908,10 @@ AC_CHECK_PROGS(PEP8, pep8)
       PERLBIN=
       
       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])
      +AS_HELP_STRING([--with-perl5=path], [Set location of Perl5 executable]),[ PERLBIN="$withval"], [PERLBIN="$alllang_default"])
       
       # 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; then
       AC_MSG_NOTICE([Disabling Perl5])
       PERL=
       else
      @@ -1013,10 +1019,10 @@ OCTAVEBIN=
       OCTAVE_SO=.oct
       
       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])
      +AS_HELP_STRING([--with-octave=path], [Set location of Octave executable]),[OCTAVEBIN="$withval"], [OCTAVEBIN="$alllang_default"])
       
       # 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; then
          AC_MSG_NOTICE([Disabling Octave])
          OCTAVE=
       
      @@ -1098,11 +1104,11 @@ AC_SUBST(OCTAVE_LDFLAGS)
       #----------------------------------------------------------------
       
       AC_ARG_WITH(scilab, AS_HELP_STRING([--without-scilab], [Disable Scilab])
      -AS_HELP_STRING([--with-scilab=path], [Set location of Scilab executable]),[SCILABBIN="$withval"], [SCILABBIN=yes])
      +AS_HELP_STRING([--with-scilab=path], [Set location of Scilab executable]),[SCILABBIN="$withval"], [SCILABBIN="$alllang_default"])
       AC_ARG_WITH(scilab-inc, [  --with-scilab-inc=path  Set location of Scilab include directory], [SCILABINCDIR="$withval"], [SCILABINCDIR=""])
       
       # First, check for "--without-scilab" or "--with-scilab=no".
      -if test x"${SCILABBIN}" = xno -o x"${with_alllang}" = xno ; then
      +if test x"${SCILABBIN}" = xno; then
         AC_MSG_NOTICE([Disabling Scilab])
         SCILAB=
       else
      @@ -1184,11 +1190,11 @@ AC_SUBST(SCILABOPT)
       #----------------------------------------------------------------
       
       AC_ARG_WITH(java, AS_HELP_STRING([--without-java], [Disable Java])
      -AS_HELP_STRING([--with-java=path], [Set location of java executable]),[JAVABIN="$withval"], [JAVABIN=yes])
      +AS_HELP_STRING([--with-java=path], [Set location of java executable]),[JAVABIN="$withval"], [JAVABIN="$alllang_default"])
       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; then
       AC_MSG_NOTICE([Disabling Java])
       JAVA=
       else
      @@ -1321,10 +1327,10 @@ AC_SUBST(JAVACFLAGS)
       #----------------------------------------------------------------
       # Look for Javascript
       #----------------------------------------------------------------
      -AC_ARG_WITH(javascript, AS_HELP_STRING([--without-javascript], [Disable Javascript]), [with_javascript="$withval"], [with_javascript=yes])
      +AC_ARG_WITH(javascript, AS_HELP_STRING([--without-javascript], [Disable Javascript]), [with_javascript="$withval"], [with_javascript="$alllang_default"])
       
       # First, check for "--without-javascript" or "--with-javascript=no".
      -if test x"${with_javascript}" = xno -o x"${with_alllang}" = xno ; then
      +if test x"${with_javascript}" = xno; then
         AC_MSG_NOTICE([Disabling Javascript])
         JAVASCRIPT=
       else
      @@ -1514,11 +1520,11 @@ AC_SUBST(NODEGYP)
       #----------------------------------------------------------------
       
       AC_ARG_WITH(gcj, AS_HELP_STRING([--without-gcj], [Disable GCJ])
      -AS_HELP_STRING([--with-gcj=path], [Set location of gcj executable]),[GCJBIN="$withval"], [GCJBIN=yes])
      +AS_HELP_STRING([--with-gcj=path], [Set location of gcj executable]),[GCJBIN="$withval"], [GCJBIN="$alllang_default"])
       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; then
         AC_MSG_NOTICE([Disabling GCJ])
       else
         if test "x$GCJBIN" = xyes; then
      @@ -1542,13 +1548,13 @@ AC_SUBST(GCJH)
       #----------------------------------------------------------------
       
       AC_ARG_WITH(android, AS_HELP_STRING([--without-android], [Disable Android])
      -AS_HELP_STRING([--with-android=path], [Set location of android executable]),[ANDROIDBIN="$withval"], [ANDROIDBIN=yes])
      +AS_HELP_STRING([--with-android=path], [Set location of android executable]),[ANDROIDBIN="$withval"], [ANDROIDBIN="$alllang_default"])
       AC_ARG_WITH(adb, [  --with-adb=path         Set location of adb executable - Android Debug Bridge],[ADBBIN="$withval"], [ADBBIN=])
       AC_ARG_WITH(ant, [  --with-ant=path         Set location of ant executable for Android],[ANTBIN="$withval"], [ANTBIN=])
       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; then
         AC_MSG_NOTICE([Disabling Android])
         ANDROID=
       else
      @@ -1593,14 +1599,14 @@ 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(guile,[  --with-guile=path       Set location of Guile executable],[
      -	GUILE="$withval"], [GUILE=yes])
      +	GUILE="$withval"], [GUILE="$alllang_default"])
       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
      +if test x"${GUILE}" = xno; then
         AC_MSG_NOTICE([Disabling Guile])
       else
         if test -z "$GUILE_CONFIG" ; then
      @@ -1653,11 +1659,11 @@ AC_SUBST(GUILE_LIBS)
       #----------------------------------------------------------------
       
       AC_ARG_WITH(mzscheme, AS_HELP_STRING([--without-mzscheme], [Disable MzScheme])
      -AS_HELP_STRING([--with-mzscheme=path], [Set location of MzScheme executable]),[ MZSCHEMEBIN="$withval"], [MZSCHEMEBIN=yes])
      +AS_HELP_STRING([--with-mzscheme=path], [Set location of MzScheme executable]),[ MZSCHEMEBIN="$withval"], [MZSCHEMEBIN="$alllang_default"])
       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; then
         AC_MSG_NOTICE([Disabling MzScheme])
         MZC=
       else
      @@ -1697,11 +1703,11 @@ AC_SUBST(MZDYNOBJ)
       RUBYBIN=
       
       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])
      +AS_HELP_STRING([--with-ruby=path], [Set location of Ruby executable]),[ RUBYBIN="$withval"], [RUBYBIN="$alllang_default"])
       
       # First, check for "--without-ruby" or "--with-ruby=no".
       RUBYSO=$SO
      -if test x"${RUBYBIN}" = xno -o x"${with_alllang}" = xno ; then
      +if test x"${RUBYBIN}" = xno; then
       AC_MSG_NOTICE([Disabling Ruby])
       RUBY=
       else
      @@ -1825,10 +1831,10 @@ AC_SUBST(RUBYDYNAMICLINKING)
       PHPBIN=
       
       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])
      +AS_HELP_STRING([--with-php=path], [Set location of PHP executable]),[ PHPBIN="$withval"], [PHPBIN="$alllang_default"])
       
       # 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; then
           AC_MSG_NOTICE([Disabling PHP])
           PHP=
       else
      @@ -1868,7 +1874,7 @@ AC_SUBST(PHPINC)
       # Look for ocaml
       #----------------------------------------------------------------
       
      -AC_ARG_WITH(ocaml, AS_HELP_STRING([--without-ocaml], [Disable OCaml]), [with_ocaml="$withval"], [with_ocaml=yes])
      +AC_ARG_WITH(ocaml, AS_HELP_STRING([--without-ocaml], [Disable OCaml]), [with_ocaml="$withval"], [with_ocaml="$alllang_default"])
       AC_ARG_WITH(ocamlc,[  --with-ocamlc=path      Set location of ocamlc executable],[ OCAMLC="$withval"], [OCAMLC=])
       AC_ARG_WITH(ocamldlgen,[  --with-ocamldlgen=path  Set location of ocamldlgen],[ OCAMLDLGEN="$withval" ], [OCAMLDLGEN=])
       AC_ARG_WITH(ocamlfind,[  --with-ocamlfind=path   Set location of ocamlfind],[OCAMLFIND="$withval"],[OCAMLFIND=])
      @@ -1876,7 +1882,7 @@ AC_ARG_WITH(ocamlmktop,[  --with-ocamlmktop=path  Set location of ocamlmktop exe
       AC_ARG_WITH(camlp4,[  --with-camlp4=path  Set location of camlp4 executable],[ CAMLP4="$withval"], [CAMLP4=])
       
       # First, check for "--without-ocaml" or "--with-ocaml=no".
      -if test x"${with_ocaml}" = xno -o x"${with_alllang}" = xno ; then
      +if test x"${with_ocaml}" = xno; then
           AC_MSG_NOTICE([Disabling OCaml])
           OCAMLC=
       else
      @@ -1920,10 +1926,10 @@ AC_SUBST(CAMLP4)
       # Priority: configure option, automatic search
       PIKEBIN=
       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])
      +AS_HELP_STRING([--with-pike=path], [Set location of Pike executable]),[PIKEBIN="$withval"], [PIKEBIN="$alllang_default"])
       
       # 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; then
           AC_MSG_NOTICE([Disabling Pike])
           PIKEBIN=
       else
      @@ -1990,10 +1996,10 @@ CHICKENLIB=
       
       
       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])
      +AS_HELP_STRING([--with-chicken=path], [Set location of CHICKEN executable]),[ CHICKENBIN="$withval"], [CHICKENBIN="$alllang_default"])
       
       # 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; then
       AC_MSG_NOTICE([Disabling CHICKEN])
       else
       
      @@ -2084,12 +2090,12 @@ AC_SUBST(CHICKENSHAREDLIB)
       # Look for C#
       #----------------------------------------------------------------
       
      -AC_ARG_WITH(csharp, AS_HELP_STRING([--without-csharp], [Disable CSharp]), [with_csharp="$withval"], [with_csharp=yes])
      +AC_ARG_WITH(csharp, AS_HELP_STRING([--without-csharp], [Disable CSharp]), [with_csharp="$withval"], [with_csharp="$alllang_default"])
       AC_ARG_WITH(cil-interpreter, [  --with-cil-interpreter=path     Set location of CIL interpreter for CSharp],[CSHARPBIN="$withval"], [CSHARPBIN=])
       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; then
       AC_MSG_NOTICE([Disabling CSharp])
       CSHARPCOMPILER=
       else
      @@ -2207,14 +2213,14 @@ LUALINK=
       # LUABIN will be cleared if certain dependencies cannot be found
       
       AC_ARG_WITH(lua, AS_HELP_STRING([--without-lua], [Disable Lua])
      -AS_HELP_STRING([--with-lua=path], [Set location of Lua executable]),[ LUABIN="$withval"], [LUABIN=yes])
      +AS_HELP_STRING([--with-lua=path], [Set location of Lua executable]),[ LUABIN="$withval"], [LUABIN="$alllang_default"])
       AC_ARG_WITH(luaincl,[  --with-luaincl=path     Set location of Lua include directory],[
       	LUAINCLUDE="$withval"], [LUAINCLUDE=])
       AC_ARG_WITH(lualib,[  --with-lualib=path      Set location of Lua library directory],[
       	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; then
       AC_MSG_NOTICE([Disabling Lua])
       else
       
      @@ -2324,10 +2330,10 @@ AC_SUBST(LUABIN)
       ALLEGROCLBIN=
       
       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])
      +AS_HELP_STRING([--with-allegrocl=path], [Set location of Allegro CL executable (alisp)]),[ ALLEGROCLBIN="$withval"], [ALLEGROCLBIN="$alllang_default"])
       
       # 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; then
       AC_MSG_NOTICE([Disabling Allegro CL])
       ALLEGROCLBIN=
       else
      @@ -2347,10 +2353,10 @@ AC_SUBST(ALLEGROCLBIN)
       CLISPBIN=
       
       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])
      +AS_HELP_STRING([--with-clisp=path], [Set location of CLISP executable (clisp)]),[ CLISPBIN="$withval"], [CLISPBIN="$alllang_default"])
       
       # 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; then
       AC_MSG_NOTICE([Disabling CLISP])
       CLISPBIN=
       else
      @@ -2370,10 +2376,10 @@ AC_SUBST(CLISPBIN)
       RBIN=
       
       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])
      +AS_HELP_STRING([--with-r=path], [Set location of R executable (r)]),[ RBIN="$withval"], [RBIN="$alllang_default"])
       
       # 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; then
       AC_MSG_NOTICE([Disabling R])
       RBIN=
       else
      @@ -2391,9 +2397,9 @@ 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])
      +AS_HELP_STRING([--with-go=path], [Set location of Go compiler]),[GOBIN="$withval"], [GOBIN="$alllang_default"])
       
      -if test x"${GOBIN}" = xno -o x"${with_alllang}" = xno ; then
      +if test x"${GOBIN}" = xno; then
         AC_MSG_NOTICE([Disabling Go])
         GO=
         GOC=
      @@ -2516,13 +2522,13 @@ AC_SUBST(GOVERSIONOPTION)
       # Look for D
       #----------------------------------------------------------------
       
      -AC_ARG_WITH(d, AS_HELP_STRING([--without-d], [Disable D]), [with_d="$withval"], [with_d=yes])
      +AC_ARG_WITH(d, AS_HELP_STRING([--without-d], [Disable D]), [with_d="$withval"], [with_d="$alllang_default"])
       AC_ARG_WITH(d1-compiler, [  --with-d1-compiler=path  Set location of D1/Tango compiler (DMD compatible)],[D1COMPILERBIN="$withval"], [D1COMPILERBIN=])
       AC_ARG_WITH(d2-compiler, [  --with-d2-compiler=path  Set location of D2 compiler (DMD compatible)],[D2COMPILERBIN="$withval"], [D2COMPILERBIN=])
       
       
       # First, check for "--without-d" or "--with-d=no".
      -if test x"${with_d}" = xno -o x"${with_alllang}" = xno ; then
      +if test x"${with_d}" = xno; then
         AC_MSG_NOTICE([Disabling D])
         D1COMPILER=
         D2COMPILER=
      
      From a9c6edb3fb203496a1e5d438b676fd47cfae5475 Mon Sep 17 00:00:00 2001
      From: Vadim Zeitlin 
      Date: Sat, 1 Aug 2015 19:20:43 +0200
      Subject: [PATCH 041/732] Skip check for pep8 if Python is disabled in
       configure.
      
      There is no need for it, nor any other Python-related variables, to be defined
      if Python is not used.
      ---
       configure.ac | 12 ++++++------
       1 file changed, 6 insertions(+), 6 deletions(-)
      
      diff --git a/configure.ac b/configure.ac
      index 8447e728e..be4c716ae 100644
      --- a/configure.ac
      +++ b/configure.ac
      @@ -893,13 +893,13 @@ else
           ;;
         *)PYTHON3DYNAMICLINKING="";;
         esac
      -fi
       
      -AC_SUBST(PY3INCLUDE)
      -AC_SUBST(PY3LIB)
      -AC_SUBST(PY3LINK)
      -AC_SUBST(PYTHON3DYNAMICLINKING)
      -AC_CHECK_PROGS(PEP8, pep8)
      +  AC_SUBST(PY3INCLUDE)
      +  AC_SUBST(PY3LIB)
      +  AC_SUBST(PY3LINK)
      +  AC_SUBST(PYTHON3DYNAMICLINKING)
      +  AC_CHECK_PROGS(PEP8, pep8)
      +fi
       
       #----------------------------------------------------------------
       # Look for Perl5
      
      From 43b2075918234700a9e3ca18eefdf3a75dc5ba4a Mon Sep 17 00:00:00 2001
      From: Vadim Zeitlin 
      Date: Sat, 1 Aug 2015 19:23:31 +0200
      Subject: [PATCH 042/732] Don't check for all the languages in Travis
       language-specific builds.
      
      This should speed up configure and shorten its output.
      ---
       .travis.yml | 1 +
       1 file changed, 1 insertion(+)
      
      diff --git a/.travis.yml b/.travis.yml
      index 9b47611b7..69621cb9c 100644
      --- a/.travis.yml
      +++ b/.travis.yml
      @@ -129,6 +129,7 @@ before_install:
         - if test -n "$SWIGLANG"; then export cxxflags=$(Tools/testflags.py --language $SWIGLANG --cxxflags --std=$CPPSTD) && echo $cxxflags; fi
       script:
         - echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r'
      +  - if test -n "$SWIGLANG"; then CONFIGOPTS+=(--without-alllang --with-$SWIGLANG$PY3); fi
         - echo "${CONFIGOPTS[@]}"
         - ./autogen.sh && mkdir -p build/build && cd build/build && ../../configure "${CONFIGOPTS[@]}"
         - echo -en 'travis_fold:end:script.1\\r'
      
      From 2d4416136bb1ce50fd667fe28119b15378eac901 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sun, 2 Aug 2015 19:41:10 +0100
      Subject: [PATCH 043/732] Tweak configure output for Java
      
      ---
       configure.ac | 7 ++++---
       1 file changed, 4 insertions(+), 3 deletions(-)
      
      diff --git a/configure.ac b/configure.ac
      index 77c05e67d..f0483e54c 100644
      --- a/configure.ac
      +++ b/configure.ac
      @@ -1224,9 +1224,8 @@ case $host in
           ;;
       esac
       
      +AC_MSG_CHECKING(for java JDK)
       if test -n "$JAVA_HOME"; then
      -  AC_MSG_CHECKING(for JDK)
      -
         dnl Don't complain about missing executables/headers if they had been
         dnl explicitly overridden from the command line, but otherwise verify that we
         dnl have everything we need.
      @@ -1253,9 +1252,11 @@ if test -n "$JAVA_HOME"; then
           AC_MSG_RESULT([found (in $JAVA_HOME)])
         else
           AC_MSG_RESULT(no)
      -    AC_MSG_WARN([JAVA_HOME ($JAVA_HOME) is defined but doesn't point to a complete JDK installation, ignoring it.])
      +    AC_MSG_WARN([JAVA_HOME ($JAVA_HOME) is defined but does not point to a complete JDK installation, ignoring it.])
           JAVA_HOME=
         fi
      +else
      +  AC_MSG_RESULT([no (JAVA_HOME is not defined)])
       fi
       
       if test "x$JAVABIN" = xyes; then
      
      From 9c239819924bddfe299535e0662ce1fc470d7b13 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sun, 2 Aug 2015 19:47:02 +0100
      Subject: [PATCH 044/732] HTML fix in docs
      
      ---
       Doc/Manual/Typemaps.html | 2 +-
       1 file changed, 1 insertion(+), 1 deletion(-)
      
      diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
      index ee7495674..51fadb095 100644
      --- a/Doc/Manual/Typemaps.html
      +++ b/Doc/Manual/Typemaps.html
      @@ -2492,7 +2492,7 @@ which then expands to:
       
       %typemap(cstype) unsigned int "uint"
      -%typemap(cstype, out="uint") unsigned int& "uint"
      +%typemap(cstype, out="uint") unsigned int& "uint"
       
      From f970d9aae5f8033cbb4333fdea85349a2810ed7d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 2 Aug 2015 19:58:10 +0100 Subject: [PATCH 045/732] testcase warning fix --- Examples/test-suite/special_variable_attributes.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/special_variable_attributes.i b/Examples/test-suite/special_variable_attributes.i index 02dd5f36c..973a09344 100644 --- a/Examples/test-suite/special_variable_attributes.i +++ b/Examples/test-suite/special_variable_attributes.i @@ -126,7 +126,7 @@ int bounceNumber3(int num3) { %{ // split double value a.b into two numbers, a and b*100 $1 = (int)$input; - $2 = ($input - $1 + 0.005) * 100; + $2 = (char)(($input - $1 + 0.005) * 100); %} %typemap(csin, pre=" $1_type $csinput_$1_type = 50;\n" // $1_type should expand to int From c6f8aadc6471851844c8c6c0cb329a176d30621f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 2 Aug 2015 20:13:40 +0100 Subject: [PATCH 046/732] Cosmetic corrections - Mac OS X --- CHANGES | 8 ++++---- Doc/Manual/Contents.html | 2 +- Doc/Manual/Javascript.html | 10 +++++----- Examples/test-suite/csharp/Makefile.in | 2 +- Examples/test-suite/errors/Makefile.in | 2 +- Examples/test-suite/guile/li_std_string_runme.scm | 2 +- Source/Modules/javascript.cxx | 2 +- Tools/javascript/Makefile.in | 2 +- configure.ac | 6 +++--- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/CHANGES b/CHANGES index eb500e5f4..691fa5544 100644 --- a/CHANGES +++ b/CHANGES @@ -1726,7 +1726,7 @@ Version 2.0.6 (30 April 2012) [Lua] Fix uninitialised variable in SWIGTYPE **OUTPUT typemaps as reported by Jim Anderson. 2012-04-28: wsfulton - [Python] Fix compilation errors when wrapping STL containers on Mac OSX and possibly other systems. + [Python] Fix compilation errors when wrapping STL containers on Mac OS X and possibly other systems. 2012-04-28: wsfulton [Java] Patch 3521811 from Leo Davis - char **STRING_ARRAY typemaps fixed to handle @@ -2421,7 +2421,7 @@ Version 2.0.2 (20 February 2011) Update chapter name to MzScheme/Racket accounting for the rename of MzScheme to Racket. 2011-02-05: wsfulton - [C#] SF #3085906 - Possible fix running test-suite on Mac OSX. + [C#] SF #3085906 - Possible fix running test-suite on Mac OS X. 2011-02-05: wsfulton SF #3173367 Better information during configure about Boost prerequisite for running @@ -4074,7 +4074,7 @@ Version 1.3.37 (13 January 2009) in Allegro CL 2008-07-19: wsfulton - Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson. + Fix building of Tcl examples/test-suite on Mac OS X reported by Gideon Simpson. 2008-07-17: wsfulton Fix SF #2019156 Configuring with --without-octave or --without-alllang @@ -12895,7 +12895,7 @@ Version 1.3.20 (December 17, 2003) Suggested by Kerim Borchaev. 11/11/2003: beazley - Configuration changes to make SWIG work on Mac OSX 10.3.x (Panther). + Configuration changes to make SWIG work on Mac OS X 10.3.x (Panther). Tested with Python, Tcl, Perl, and Ruby---all of which seem to work. 11/08/2003: cheetah (William Fulton) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 06c858b29..e8b1e3477 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1072,7 +1072,7 @@
  • Embedded Webkit
  • Creating Applications with node-webkit diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 7857d9770..613ca99ed 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -25,7 +25,7 @@
  • Embedded Webkit
  • Creating Applications with node-webkit @@ -156,7 +156,7 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8
  • instanceOf does not work under JSC

  • -

    The primary development environment has been Linux (Ubuntu 12.04). Windows and OSX have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.

    +

    The primary development environment has been Linux (Ubuntu 12.04). Windows and Mac OS X have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.

    26.3 Integration

    @@ -166,7 +166,7 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8

    26.3.1 Creating node.js Extensions

    -

    To install node.js you can download an installer from their web-site for OSX and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

    +

    To install node.js you can download an installer from their web-site for Mac OS X and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

     $ sudo add-apt-repository ppa:chris-lea/node.js
    @@ -224,9 +224,9 @@ $ sudo apt-get remove gyp

    26.3.2 Embedded Webkit

    -

    Webkit is pre-installed on OSX and available as a library for GTK.

    +

    Webkit is pre-installed on Mac OS X and available as a library for GTK.

    -

    26.3.2.1 OSX

    +

    26.3.2.1 Mac OS X

    There is general information about programming with WebKit on Apple Developer Documentation. Details about Cocoa programming are not covered here.

    diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index d5eac5c03..0c799c7d9 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -73,7 +73,7 @@ setup = \ # Compiles C# files then runs the testcase. A testcase is only run if # a file is found which has _runme.cs appended after the testcase name. # Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX. -# DYLD_FALLBACK_LIBRARY_PATH is cleared for MacOSX. +# DYLD_FALLBACK_LIBRARY_PATH is cleared for Mac OS X. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \ diff --git a/Examples/test-suite/errors/Makefile.in b/Examples/test-suite/errors/Makefile.in index 4c61001e7..b5d01a0eb 100644 --- a/Examples/test-suite/errors/Makefile.in +++ b/Examples/test-suite/errors/Makefile.in @@ -32,7 +32,7 @@ include $(srcdir)/../common.mk # Portable dos2unix / todos for stripping CR TODOS = tr -d '\r' -#TODOS = sed -e 's/\r$$//' # On OSX behaves as if written 's/r$$//' +#TODOS = sed -e 's/\r$$//' # On Mac OS X behaves as if written 's/r$$//' # strip source directory from output, so that diffs compare STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||' diff --git a/Examples/test-suite/guile/li_std_string_runme.scm b/Examples/test-suite/guile/li_std_string_runme.scm index 83fc2b5e7..fcf2f58d2 100644 --- a/Examples/test-suite/guile/li_std_string_runme.scm +++ b/Examples/test-suite/guile/li_std_string_runme.scm @@ -25,7 +25,7 @@ (if (not (try-set-locale "C.UTF-8")) ; Linux (if (not (try-set-locale "en_US.utf8")) ; Linux -(if (not (try-set-locale "en_US.UTF-8")) ; Mac OSX +(if (not (try-set-locale "en_US.UTF-8")) ; Mac OS X (error "Failed to set any UTF-8 locale") ))) diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index 179ffb28c..6f0fb3afd 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -1100,7 +1100,7 @@ int JSEmitter::emitSetter(Node *n, bool is_member, bool is_static) { * ----------------------------------------------------------------------------- */ int JSEmitter::emitConstant(Node *n) { - // HACK: somehow it happened under OSX that before everything started + // HACK: somehow it happened under Mac OS X that before everything started // a lot of SWIG internal constants were emitted // This didn't happen on other platforms yet... // we ignore those premature definitions diff --git a/Tools/javascript/Makefile.in b/Tools/javascript/Makefile.in index 1eec5bc1e..5eeec0785 100644 --- a/Tools/javascript/Makefile.in +++ b/Tools/javascript/Makefile.in @@ -14,7 +14,7 @@ all: javascript CC = @CC@ -# HACK: under OSX a g++ compiled interpreter is seg-faulting when loading module libraries +# HACK: under Mac OS X a g++ compiled interpreter is seg-faulting when loading module libraries # with 'c++' it works... probably some missing flags? JSCXX = @JSINTERPRETERCXX@ CPPFLAGS = @BOOST_CPPFLAGS@ diff --git a/configure.ac b/configure.ac index 31bbac3bf..6d4505875 100644 --- a/configure.ac +++ b/configure.ac @@ -357,7 +357,7 @@ fi # On darwin 10.7,10.8,10.9 using clang++, need to ensure using # libc++ for tests and examples to run under mono. May affect -# other language targets as well - problem is an OSX incompatibility +# other language targets as well - problem is a Mac OS X incompatibility # between libraries depending on libstdc++ and libc++. CLANGXX= $CXX -v 2>&1 | grep -i clang >/dev/null && CLANGXX=yes @@ -1460,7 +1460,7 @@ else if test -z "$JSCOREINCDIR"; then JSCOREINCDIR="/usr/include/ /usr/local/include/" - # Add in default directory for JavaScriptCore headers for Linux and MacOSX + # Add in default directory for JavaScriptCore headers for Linux and Mac OS X case $host in *-*-linux*) JSCOREINCDIR="/usr/include/webkit-1.0/ /usr/include/webkitgtk-1.0/ /usr/local/include/webkit-1.0/JavaScriptCore/ $JSCOREINCDIR" @@ -1515,7 +1515,7 @@ else # if not include dir is specified we try to find if test -z "$JSV8INCDIR"; then - # Add in default directory for JavaScriptCore headers for Linux and MacOSX + # Add in default directory for JavaScriptCore headers for Linux and Mac OS X case $host in *-*-linux*) JSV8INCDIR="/usr/include /usr/local/include/ $JSV8INCDIR" From 892aaf577a6fdb663aafe1e6ada178de312d92f2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 2 Aug 2015 21:38:53 +0100 Subject: [PATCH 047/732] Test case warning suppression for visual c++ --- Examples/test-suite/array_typedef_memberin.i | 4 ++++ Examples/test-suite/default_constructor.i | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/Examples/test-suite/array_typedef_memberin.i b/Examples/test-suite/array_typedef_memberin.i index 3618c9305..7301057e9 100644 --- a/Examples/test-suite/array_typedef_memberin.i +++ b/Examples/test-suite/array_typedef_memberin.i @@ -1,5 +1,9 @@ %module array_typedef_memberin +#if defined(_MSC_VER) + #pragma warning(disable: 4351) // new behavior: elements of array 'xyz' will be default initialized +#endif + #if defined(SWIGSCILAB) %rename(ExDetail) ExampleDetail; #endif diff --git a/Examples/test-suite/default_constructor.i b/Examples/test-suite/default_constructor.i index 74673b74a..40a088cc9 100644 --- a/Examples/test-suite/default_constructor.i +++ b/Examples/test-suite/default_constructor.i @@ -113,6 +113,10 @@ public: void bar(F *) { } +#if defined(_MSC_VER) + #pragma warning(disable: 4624) // destructor could not be generated because a base class destructor is inaccessible or deleted +#endif + // Single inheritance, base has private destructor class FFF : public F { }; @@ -123,6 +127,10 @@ class GGG : public A, public F { class HHH : public F, public A { }; +#if defined(_MSC_VER) + #pragma warning(default: 4624) // destructor could not be generated because a base class destructor is inaccessible or deleted +#endif + /* A class with a protected destructor */ class G { protected: From c0de963191b4f88de9d293e3eac9ebbffe41014a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 2 Aug 2015 22:21:14 +0100 Subject: [PATCH 048/732] Test case warning suppression for visual c++ fix --- Examples/test-suite/array_typedef_memberin.i | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/array_typedef_memberin.i b/Examples/test-suite/array_typedef_memberin.i index 7301057e9..ad2855eed 100644 --- a/Examples/test-suite/array_typedef_memberin.i +++ b/Examples/test-suite/array_typedef_memberin.i @@ -1,14 +1,14 @@ %module array_typedef_memberin -#if defined(_MSC_VER) - #pragma warning(disable: 4351) // new behavior: elements of array 'xyz' will be default initialized -#endif - #if defined(SWIGSCILAB) %rename(ExDetail) ExampleDetail; #endif %inline %{ +#if defined(_MSC_VER) + #pragma warning(disable: 4351) // new behavior: elements of array 'xyz' will be default initialized +#endif + typedef short Eight[8]; typedef const short ConstEight[8]; namespace ArrayExample From 9d509ba92b039dc225a9df8feb5fc6d58e46b1ad Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 2 Aug 2015 22:51:59 +0100 Subject: [PATCH 049/732] Add 3.0.7 release summary and release date --- ANNOUNCE | 12 +++++++++++- CHANGES.current | 4 ++-- Doc/Manual/Sections.html | 2 +- README | 2 +- RELEASENOTES | 8 ++++++++ 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index f7d7eb8a9..6f1411668 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 3.0.7 (in progress) *** +*** ANNOUNCE: SWIG 3.0.7 (3 Aug 2015) *** http://www.swig.org @@ -18,6 +18,16 @@ include generation of scripting language extension modules, rapid prototyping, testing, and user interface development for large C/C++ systems. +Release Notes +============= +Detailed release notes are available with the release and are also +published on the SWIG web site at http://swig.org/release.html. + +SWIG-3.0.7 summary: +- Add support for Octave-4.0.0. +- Remove potential Android security exploit in generated Java classes. +- Minor new features and bug fixes. + Availability ============ The release is available for download on Sourceforge at diff --git a/CHANGES.current b/CHANGES.current index 48ccc2036..f6922c5f2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,8 +2,8 @@ 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 3.0.7 (in progress) -=========================== +Version 3.0.7 (3 Aug 2015) +========================== 2015-08-02: wsfulton [Java] Fix potential security exploit in generated Java classes. diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 4bf40c969..f0027d136 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

    SWIG-3.0 Documentation

    -Last update : SWIG-3.0.7 (in progress) +Last update : SWIG-3.0.7 (3 Aug 2015)

    Sections

    diff --git a/README b/README index a02c56ea9..27d33df32 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 3.0.7 (in progress) +Version: 3.0.7 (3 Aug 2015) 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 bb1d82bb9..895caa2dd 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -4,6 +4,14 @@ and CHANGES files. Release Notes ============= +Detailed release notes are available with the release and are also +published on the SWIG web site at http://swig.org/release.html. + +SWIG-3.0.7 summary: +- Add support for Octave-4.0.0. +- Remove potential Android security exploit in generated Java classes. +- Minor new features and bug fixes. + SWIG-3.0.6 summary: - Stability and regression fixes. - Fixed parsing of C++ corner cases. From 9babc2663449aa156233521475cff3849d6a7ac7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Aug 2015 08:12:38 +0100 Subject: [PATCH 050/732] Update Scilab test-suite output wording --- Examples/test-suite/scilab/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/scilab/Makefile.in b/Examples/test-suite/scilab/Makefile.in index 4a9a4f007..9ddd8f1aa 100644 --- a/Examples/test-suite/scilab/Makefile.in +++ b/Examples/test-suite/scilab/Makefile.in @@ -62,7 +62,7 @@ setup = \ mkdir $(TEST_DIR); \ fi; \ if [ -f $(SRC_RUNME_SCRIPT) ]; then \ - echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \ + echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \ if [ ! -f $(TEST_DIR) ]; then \ cp $(SRC_RUNME_SCRIPT) $(TEST_DIR); \ fi; \ @@ -73,7 +73,7 @@ setup = \ cp $(srcdir)/swigtest.quit $(TEST_DIR); \ fi; \ else \ - echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \ + echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \ fi; \ # Runs the testcase. A testcase is only run if From 5d363276f5688d2bf1b4ad304a191c216f5c8483 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Aug 2015 22:33:52 +0100 Subject: [PATCH 051/732] Bump version to 3.0.8 --- ANNOUNCE | 13 ++--- CHANGES | 117 ++++++++++++++++++++++++++++++++++++++ CHANGES.current | 119 +-------------------------------------- Doc/Manual/Sections.html | 2 +- README | 2 +- configure.ac | 2 +- 6 files changed, 126 insertions(+), 129 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 6f1411668..d9b932e2c 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,8 +1,8 @@ -*** ANNOUNCE: SWIG 3.0.7 (3 Aug 2015) *** +*** ANNOUNCE: SWIG 3.0.8 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-3.0.7, the latest SWIG release. +We're pleased to announce SWIG-3.0.8, the latest SWIG release. What is SWIG? ============= @@ -23,20 +23,15 @@ Release Notes Detailed release notes are available with the release and are also published on the SWIG web site at http://swig.org/release.html. -SWIG-3.0.7 summary: -- Add support for Octave-4.0.0. -- Remove potential Android security exploit in generated Java classes. -- Minor new features and bug fixes. - Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-3.0.7.tar.gz + http://prdownloads.sourceforge.net/swig/swig-3.0.8.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-3.0.7.zip + http://prdownloads.sourceforge.net/swig/swigwin-3.0.8.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 691fa5544..29b36352c 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,123 @@ 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 3.0.7 (3 Aug 2015) +========================== + +2015-08-02: wsfulton + [Java] Fix potential security exploit in generated Java classes. + The swigCPtr and swigCMemOwn member variables in the generated Java + classes are now declared 'transient' by default. Further details of the exploit + in Android is being published in an academic paper as part of USENIX WOOT '15: + https://www.usenix.org/conference/woot15/workshop-program/presentation/peles. + + In the unlikely event that you are relying on these members being serializable, + then you will need to override the default javabody and javabody_derived typemaps + to generate the old generated code. The relevant typemaps are in the Lib directory + in the java.swg, boost_shared_ptr.i and boost_intrusive_ptr.i files. Copy the + relevant default typemaps into your interface file and remove the 'transient' keyword. + + *** POTENTIAL INCOMPATIBILITY *** + +2015-08-01: vadz + Make configure --without-alllang option more useful: it can now be overridden by the following + --with-xxx options, allowing to easily enable just one or two languages. + +2015-07-30: wsfulton + Fix #440 - Initialise all newly created arrays when using %array_functions and %array_class + in the carrays.i library - bug is only relevant when using C++. + +2015-07-29: wsfulton + [Python] Improve indentation warning and error messages for code in the following directives: + + %pythonprepend + %pythonappend + %pythoncode + %pythonbegin + %feature("shadow") + + Old error example: + Error: Line indented less than expected (line 3 of pythoncode) + + New error example: + Error: Line indented less than expected (line 3 of %pythoncode or %insert("python") block) + as no line should be indented less than the indentation in line 1 + + Old warning example: + Warning 740: Whitespace prefix doesn't match (line 2 of %pythoncode or %insert("python") block) + + New warning example: + Warning 740: Whitespace indentation is inconsistent compared to earlier lines (line 3 of + %pythoncode or %insert("python") block) + + +2015-07-28: wsfulton + [Python] Fix #475. Improve docstring indentation handling. + + SWIG-3.0.5 and earlier sometimes truncated text provided in the docstring feature. + This occurred when the indentation (whitespace) in the docstring was less in the + second or later lines when compared to the first line. + SWIG-3.0.6 gave a 'Line indented less than expected' error instead of truncating + the docstring text. + Now the indentation for the 'docstring' feature is smarter and is appropriately + adjusted so that no truncation occurs. + +2015-07-22: wsfulton + Support for special variable expansion in typemap attributes. Example usage expansion + in the 'out' attribute (C# specific): + + %typemap(ctype, out="$*1_ltype") unsigned int& "$*1_ltype" + + is equivalent to the following as $*1_ltype expands to 'unsigned int': + + %typemap(ctype, out="unsigned int") unsigned int& "unsigned int" + + Special variables can be used within special variable macros too. Example usage expansion: + + %typemap(cstype) unsigned int "uint" + %typemap(cstype, out="$typemap(cstype, $*1_ltype)") unsigned int& "$typemap(cstype, $*1_ltype)" + + Special variables are expanded first and hence the above is equivalent to: + + %typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)" + + which then expands to: + + %typemap(cstype, out="uint") unsigned int& "uint" + +2015-07-22: lindleyf + Apply patch #439 - support for $typemap() (aka embedded typemaps or special variable + macros) in typemap attributes. A simple example where $typemap() is expanded in the + 'out' attribute (C# specific): + + %typemap(cstype) unsigned int "uint" + %typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)" + + is equivalent to: + + %typemap(cstype, out="uint") unsigned int& "uint" + +2015-07-18: m7thon + [Python] Docstrings provided via %feature("docstring") are now quoted and added to + the tp_doc slot when using python builtin classes (-builtin). When no docstring is + provided, the tp_doc slot is set to the fully qualified C/C++ class name. + Github issues #445 and #461. + +2015-07-17: kwwette + [octave] Support Octave version 4.0.0 (thanks to patches from Orion Poplawski). + +2015-07-07: wsfulton + SWIG no longer generates a wrapper for a class' constructor if that class has + any base class with a private destructor. This is because your compiler should + not allow a class to be instantiated if a base has a private destructor. Some + compilers do, so if you need the old behaviour, use the "notabstract" feature, eg: + + %feature("notabstract") Derived; + class Base { + ~Base() {} + }; + struct Derived : Base {}; + Version 3.0.6 (5 Jul 2015) ========================== diff --git a/CHANGES.current b/CHANGES.current index f6922c5f2..c0694f657 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,120 +2,5 @@ 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 3.0.7 (3 Aug 2015) -========================== - -2015-08-02: wsfulton - [Java] Fix potential security exploit in generated Java classes. - The swigCPtr and swigCMemOwn member variables in the generated Java - classes are now declared 'transient' by default. Further details of the exploit - in Android is being published in an academic paper as part of USENIX WOOT '15: - https://www.usenix.org/conference/woot15/workshop-program/presentation/peles. - - In the unlikely event that you are relying on these members being serializable, - then you will need to override the default javabody and javabody_derived typemaps - to generate the old generated code. The relevant typemaps are in the Lib directory - in the java.swg, boost_shared_ptr.i and boost_intrusive_ptr.i files. Copy the - relevant default typemaps into your interface file and remove the 'transient' keyword. - - *** POTENTIAL INCOMPATIBILITY *** - -2015-08-01: vadz - Make configure --without-alllang option more useful: it can now be overridden by the following - --with-xxx options, allowing to easily enable just one or two languages. - -2015-07-30: wsfulton - Fix #440 - Initialise all newly created arrays when using %array_functions and %array_class - in the carrays.i library - bug is only relevant when using C++. - -2015-07-29: wsfulton - [Python] Improve indentation warning and error messages for code in the following directives: - - %pythonprepend - %pythonappend - %pythoncode - %pythonbegin - %feature("shadow") - - Old error example: - Error: Line indented less than expected (line 3 of pythoncode) - - New error example: - Error: Line indented less than expected (line 3 of %pythoncode or %insert("python") block) - as no line should be indented less than the indentation in line 1 - - Old warning example: - Warning 740: Whitespace prefix doesn't match (line 2 of %pythoncode or %insert("python") block) - - New warning example: - Warning 740: Whitespace indentation is inconsistent compared to earlier lines (line 3 of - %pythoncode or %insert("python") block) - - -2015-07-28: wsfulton - [Python] Fix #475. Improve docstring indentation handling. - - SWIG-3.0.5 and earlier sometimes truncated text provided in the docstring feature. - This occurred when the indentation (whitespace) in the docstring was less in the - second or later lines when compared to the first line. - SWIG-3.0.6 gave a 'Line indented less than expected' error instead of truncating - the docstring text. - Now the indentation for the 'docstring' feature is smarter and is appropriately - adjusted so that no truncation occurs. - -2015-07-22: wsfulton - Support for special variable expansion in typemap attributes. Example usage expansion - in the 'out' attribute (C# specific): - - %typemap(ctype, out="$*1_ltype") unsigned int& "$*1_ltype" - - is equivalent to the following as $*1_ltype expands to 'unsigned int': - - %typemap(ctype, out="unsigned int") unsigned int& "unsigned int" - - Special variables can be used within special variable macros too. Example usage expansion: - - %typemap(cstype) unsigned int "uint" - %typemap(cstype, out="$typemap(cstype, $*1_ltype)") unsigned int& "$typemap(cstype, $*1_ltype)" - - Special variables are expanded first and hence the above is equivalent to: - - %typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)" - - which then expands to: - - %typemap(cstype, out="uint") unsigned int& "uint" - -2015-07-22: lindleyf - Apply patch #439 - support for $typemap() (aka embedded typemaps or special variable - macros) in typemap attributes. A simple example where $typemap() is expanded in the - 'out' attribute (C# specific): - - %typemap(cstype) unsigned int "uint" - %typemap(cstype, out="$typemap(cstype, unsigned int)") unsigned int& "$typemap(cstype, unsigned int)" - - is equivalent to: - - %typemap(cstype, out="uint") unsigned int& "uint" - -2015-07-18: m7thon - [Python] Docstrings provided via %feature("docstring") are now quoted and added to - the tp_doc slot when using python builtin classes (-builtin). When no docstring is - provided, the tp_doc slot is set to the fully qualified C/C++ class name. - Github issues #445 and #461. - -2015-07-17: kwwette - [octave] Support Octave version 4.0.0 (thanks to patches from Orion Poplawski). - -2015-07-07: wsfulton - SWIG no longer generates a wrapper for a class' constructor if that class has - any base class with a private destructor. This is because your compiler should - not allow a class to be instantiated if a base has a private destructor. Some - compilers do, so if you need the old behaviour, use the "notabstract" feature, eg: - - %feature("notabstract") Derived; - class Base { - ~Base() {} - }; - struct Derived : Base {}; - +Version 3.0.8 (in progress) +=========================== diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index f0027d136..b917c4cd8 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

    SWIG-3.0 Documentation

    -Last update : SWIG-3.0.7 (3 Aug 2015) +Last update : SWIG-3.0.8 (in progress)

    Sections

    diff --git a/README b/README index 27d33df32..e3f15e4da 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 3.0.7 (3 Aug 2015) +Version: 3.0.8 (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 6d4505875..74235204e 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],[3.0.7],[http://www.swig.org]) +AC_INIT([swig],[3.0.8],[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 a17c9727bd11c8dee4e67f4cb53b8e907436f874 Mon Sep 17 00:00:00 2001 From: Michael Schaller Date: Wed, 24 Jun 2015 14:48:17 +0200 Subject: [PATCH 052/732] Fleshed out Go's documentation about the director feature and added a director example. Fixes issues #418. --- Doc/Manual/Go.html | 559 +++++++++++++++++++++++++++++-- Examples/go/check.list | 1 + Examples/go/director/Makefile | 17 + Examples/go/director/director.go | 70 ++++ Examples/go/director/director.h | 41 +++ Examples/go/director/example.i | 11 + Examples/go/director/index.html | 28 ++ Examples/go/director/runme.go | 39 +++ 8 files changed, 741 insertions(+), 25 deletions(-) create mode 100644 Examples/go/director/Makefile create mode 100644 Examples/go/director/director.go create mode 100644 Examples/go/director/director.h create mode 100644 Examples/go/director/example.i create mode 100644 Examples/go/director/index.html create mode 100644 Examples/go/director/runme.go diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 20e923d19..0be378f6a 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -29,6 +29,17 @@
  • Go Templates
  • Go Director Classes +
  • Default Go primitive type mappings
  • Output arguments
  • Adding additional go code @@ -574,49 +585,547 @@ In order to use C++ templates in Go, you must tell SWIG to create wrappers for a particular template instantation. To do this, use the %template directive. +

    23.4.7 Go Director Classes

    -SWIG's director feature permits a Go type to act as the subclass of a -C++ class with virtual methods. This is complicated by the fact that -C++ and Go define inheritance differently. In Go, structs can inherit -methods via anonymous field embedding. However, when a method is -called for an embedded struct, if that method calls any other methods, -they are called for the embedded struct, not for the original type. -Therefore, SWIG must use Go interfaces to represent C++ inheritance. +SWIG's director feature permits a Go type to act as the subclass of a C++ class. +This is complicated by the fact that C++ and Go define inheritance differently. +SWIG normally represents the C++ class inheritance automatically in Go via +interfaces but with a Go type representing a subclass of a C++ class quite some +manual work is necessary. +

    + +

    +This subchapter gives a step by step guide how to properly sublass a C++ class +with a Go type. In general it is strongly recommended to follow this guide +completely to avoid common pitfalls with directors in Go. +

    + + +

    23.4.7.1 Example C++ code

    + +

    +The step by step guide is based on two example C++ classes. FooBarAbs is an +abstract C++ class and the FooBarCpp class inherits from it. This guide +explains how to implement a FooBarGo class similar to the FooBarCpp class.

    -In order to use the director feature in Go, you must define a type in -your Go code. You must then add methods for the type. Define a -method in Go for each C++ virtual function that you want to override. -You must then create a value of your new type, and pass a pointer to -it to the function NewDirectorClassName, -where ClassName is the name of the C++ class. That will -return a value of type ClassName. -

    - -

    -For example: +FooBarAbs abstract C++ class:

    -type GoClass struct { }
    -func (p *GoClass) VirtualFunction() { }
    -func MakeClass() ClassName {
    -	return NewDirectorClassName(&GoClass{})
    +class FooBarAbs
    +{
    +public:
    +	FooBarAbs() {};
    +	virtual ~FooBarAbs() {};
    +
    +	std::string FooBar() {
    +		return this->Foo() + ", " + this->Bar();
    +	};
    +
    +protected:
    +	virtual std::string Foo() {
    +		return "Foo";
    +	};
    +
    +	virtual std::string Bar() = 0;
    +};
    +
    +
    + +

    +FooBarCpp C++ class: +

    + +
    +
    +class FooBarCpp : public FooBarAbs
    +{
    +protected:
    +	virtual std::string Foo() {
    +		return "C++ " + FooBarAbs::Foo();
    +	}
    +
    +	virtual std::string Bar() {
    +		return "C++ Bar";
    +	}
    +};
    +
    +
    + +

    +Returned string by the FooBarCpp::FooBar method is: +

    + +
    +
    +C++ Foo, C++ Bar
    +
    +
    + + +

    +The complete example, including the FooBarGoo class implementation, can +be found in the end of the guide. +

    + + +

    23.4.7.2 Enable director feature

    + + +

    +The director feature is disabled by default. To use directors you must make two +changes to the interface file. First, add the "directors" option to the %module +directive, like this: +

    + +
    +
    +%module(directors="1") modulename
    +
    +
    + +

    +Second, you must use the %feature("director") directive to tell SWIG which +classes should get directors. In the example the FooBarAbs class needs the +director feature enabled so that the FooBarGo class can inherit from it, like +this: +

    + +
    +
    +%feature("director") FooBarAbs;
    +
    +
    + +

    +For a more detailed documentation of the director feature and how to enable or +disable it for specific classes and virtual methods see SWIG's Java +documentation on directors. +

    + + +

    23.4.7.3 Constructor and destructor

    + + +

    +SWIG creates an additional set of constructor and destructor functions once the +director feature has been enabled for a C++ class. NewDirectorClassName + allows to override virtual methods on the new object instance and +DeleteDirectorClassName needs to be used to free a director object instance +created with NewDirectorClassName. More on overriding virtual methods +follows later in this guide under +overriding virtual methods. +

    + +

    +The default constructor and destructor functions NewClassName and +DeleteClassName can still be used as before so that existing code +doesn't break just because the director feature has been enabled for a C++ +class. The behavior is undefined if the default and director constructor and +destructor functions get mixed and so great care needs to be taken that only one +of the constructor and destructor function pairs is used for any object +instance. Both constructor functions, the default and the director one, return +the same interface type. This makes it potentially hard to know which +destructor function, the default or the director one, needs to be called to +delete an object instance. +

    + +

    +In theory the DirectorInterface method could be used to +determine if an object instance was created via NewDirectorClassName: +

    + +
    +
    +if o.DirectorInterface() != nil {
    +	DeleteDirectorClassName(o)
    +} else {
    +	DeleteClassName(o)
     }
     

    -Any call in C++ code to the virtual function will wind up calling the -method defined in Go. The Go code may of course call other methods on -itself, and those methods may be defined either in Go or in C++. +In practice it is strongly recommended to embed a director object +instance in a Go struct so that a director object instance will be represented +as a distinct Go type that subclasses a C++ class. For this Go type custom +constructor and destructor functions take care of the director constructor and +destructor function calls and the resulting Go class will appear to the user as +any other SWIG wrapped C++ class. More on properly subclassing a C++ class +follows later in this guide under subclass via +embedding.

    + +

    23.4.7.4 Override virtual methods

    + + +

    +In order to override virtual methods on a C++ class with Go methods the +NewDirectorClassName constructor functions receives a +DirectorInterface argument. The methods in the +DirectorInterface are a subset of the public and protected virtual methods +of the C++ class. If the DirectorInterface contains a method with a +matching signature to a virtual method of the C++ class then the virtual C++ +method will be overwritten with the Go method. As Go doesn't support protected +methods all overriden protected virtual C++ methods will be public in Go. +

    + +

    +As an example see part of the FooBarGo class: +

    + +
    +
    +type overwritenMethodsOnFooBarAbs struct {
    +	fb FooBarAbs
    +}
    +
    +func (om *overwritenMethodsOnFooBarAbs) Foo() string {
    +	...
    +}
    +
    +func (om *overwritenMethodsOnFooBarAbs) Bar() string {
    +	...
    +}
    +
    +func NewFooBarGo() FooBarGo {
    +	om := &overwritenMethodsOnFooBarAbs{}
    +	fb := NewDirectorFooBarAbs(om)
    +	om.fb = fb
    +	...
    +}
    +
    +
    + +

    +The complete example, including the FooBarGoo class implementation, can +be found in the end of the guide. In +this part of the example the virtual methods FooBarAbs::Foo and +FooBarAbs::Bar have been overwritten with Go methods similarly to how +the FooBarAbs virtual methods are overwritten by the FooBarCpp +class. +

    + +

    +The DirectorInterface in the example is implemented by the +overwritenMethodsOnFooBarAbs Go struct type. A pointer to a +overwritenMethodsOnFooBarAbs struct instance will be given to the +NewDirectorFooBarAbs constructor function. The constructor return +value implements the FooBarAbs interface. +overwritenMethodsOnFooBarAbs could in theory be any Go type but in +practice a struct is used as it typically contains at least a value of the +C++ class interface so that the overwritten methods can use the rest of the +C++ class. If the FooBarGo class would receive additional constructor +arguments then these would also typically be stored in the +overwritenMethodsOnFooBarAbs struct so that they can be used by the +Go methods. +

    + + +

    23.4.7.5 Call base methods

    + + +

    +Often a virtual method will be overwritten to extend the original behavior of +the method in the base class. This is also the case for the FooBarCpp::Foo + method of the example code: +

    + +
    +
    +virtual std::string Foo() {
    +	return "C++ " + FooBarAbs::Foo();
    +}
    +
    +
    + +

    +To use base methods the DirectorClassNameMethodName wrapper functions +are automatically generated by SWIG for public and protected virtual methods. +The FooBarGo.Foo implementation in the example looks like this: +

    + +
    +
    +func (om *overwritenMethodsOnFooBarAbs) Foo() string {
    +	return "Go " + DirectorFooBarAbsFoo(om.fb)
    +}
    +
    +
    + +

    +The complete example, including the FooBarGoo class implementation, can +be found in the end of the guide. +

    + + +

    23.4.7.6 Subclass via embedding

    + + +

    +As previously mentioned in this guide the +default and director constructor functions return the same interface type. To +properly subclass a C++ class with a Go type the director object instance +returned by the NewDirectorClassName constructor function should be +embedded into a Go struct so that it represents a distinct but compatible type +in Go's type system. This Go struct should be private and the constructor and +destructor functions should instead work with a public interface type so that +the Go class that subclasses a C++ class can be used as a compatible drop in. +

    + +

    +The subclassing part of the FooBarGo class for an example looks like +this: +

    + +
    +
    +type FooBarGo interface {
    +	FooBarAbs
    +	deleteFooBarAbs()
    +	IsFooBarGo()
    +}
    +
    +type fooBarGo struct {
    +	FooBarAbs
    +}
    +
    +func (fbgs *fooBarGo) deleteFooBarAbs() {
    +	DeleteDirectorFooBarAbs(fbgs.FooBarAbs)
    +}
    +
    +func (fbgs *fooBarGo) IsFooBarGo() {}
    +
    +func NewFooBarGo() FooBarGo {
    +	om := &overwritenMethodsOnFooBarAbs{}
    +	fb := NewDirectorFooBarAbs(om)
    +	om.fb = fb
    +
    +	return &fooBarGo{FooBarAbs: fb}
    +}
    +
    +func DeleteFooBarGo(fbg FooBarGo) {
    +	fbg.deleteFooBarAbs()
    +}
    +
    +
    + + +

    +The complete example, including the FooBarGoo class implementation, can +be found in the end of the guide. In +this part of the example the private fooBarGo struct embeds +FooBarAbs which lets the fooBarGo Go type "inherit" all the +methods of the FooBarAbs C++ class by means of embedding. The public +FooBarGo interface type includes the FooBarAbs interface and +hence FooBarGo can be used as a drop in replacement for +FooBarAbs while the reverse isn't possible and would raise a compile +time error. Furthemore the constructor and destructor functions +NewFooBarGo and DeleteFooBarGo take care of all the director +specifics and to the user the class appears as any other SWIG wrapped C++ +class. +

    + + +

    23.4.7.7 Memory management with runtime.SetFinalizer

    + + +

    +In general all guidelines for C++ class memory +management apply as well to director classes. One often overlooked +limitation with runtime.SetFinalizer is that a finalizer doesn't run +in case of a cycle and director classes typically have a cycle. The cycle +in the FooBarGo class is here: +

    + +
    +
    +type overwritenMethodsOnFooBarAbs struct {
    +	fb FooBarAbs
    +}
    +
    +func NewFooBarGo() FooBarGo {
    +	om := &overwritenMethodsOnFooBarAbs{}
    +	fb := NewDirectorFooBarAbs(om) // fb.v = om
    +	om.fb = fb // Backlink causes cycle as fb.v = om!
    +	...
    +}
    +
    +
    + +

    +In order to be able to use runtime.SetFinalizer nevertheless the +finalizer needs to be set on something that isn't in a cycle and that references +the director object instance. In the FooBarGo class example the +FooBarAbs director instance can be automatically deleted by setting the +finalizer on fooBarGo: +

    + +
    +
    +type fooBarGo struct {
    +	FooBarAbs
    +}
    +
    +type overwritenMethodsOnFooBarAbs struct {
    +	fb FooBarAbs
    +}
    +
    +func NewFooBarGo() FooBarGo {
    +	om := &overwritenMethodsOnFooBarAbs{}
    +	fb := NewDirectorFooBarAbs(om)
    +	om.fb = fb // Backlink causes cycle as fb.v = om!
    +
    +	fbgs := &fooBarGo{FooBarAbs: fb}
    +	runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbs)
    +	return fbgs
    +}
    +
    +
    + +

    +Furthermore if runtime.SetFinalizer is in use either the +DeleteClassName destructor function needs to be removed or the +fooBarGo struct needs additional data to prevent double deletion. Please +read the C++ class memory management subchapter +before using runtime.SetFinalizer to know all of its gotchas. +

    + + +

    23.4.7.8 Complete FooBarGo example class

    + + +

    +The complete and annotated FooBarGo class looks like this: +

    + +
    +
    +// FooBarGo is a superset of FooBarAbs and hence FooBarGo can be used as a drop
    +// in replacement for FooBarAbs but the reverse causes a compile time error.
    +type FooBarGo interface {
    +	FooBarAbs
    +	deleteFooBarAbs()
    +	IsFooBarGo()
    +}
    +
    +// Via embedding fooBarGo "inherits" all methods of FooBarAbs.
    +type fooBarGo struct {
    +	FooBarAbs
    +}
    +
    +func (fbgs *fooBarGo) deleteFooBarAbs() {
    +	DeleteDirectorFooBarAbs(fbgs.FooBarAbs)
    +}
    +
    +// The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbs.
    +// This is also how the class hierarchy gets represented by the SWIG generated
    +// wrapper code.  For an instance FooBarCpp has the IsFooBarAbs and IsFooBarCpp
    +// methods.
    +func (fbgs *fooBarGo) IsFooBarGo() {}
    +
    +// Go type that defines the DirectorInterface. It contains the Foo and Bar
    +// methods that overwrite the respective virtual C++ methods on FooBarAbs.
    +type overwritenMethodsOnFooBarAbs struct {
    +	// Backlink to FooBarAbs so that the rest of the class can be used by the
    +	// overridden methods.
    +	fb FooBarAbs
    +
    +	// If additional constructor arguments have been given they are typically
    +	// stored here so that the overriden methods can use them.
    +}
    +
    +func (om *overwritenMethodsOnFooBarAbs) Foo() string {
    +	// DirectorFooBarAbsFoo calls the base method FooBarAbs::Foo.
    +	return "Go " + DirectorFooBarAbsFoo(om.fb)
    +}
    +
    +func (om *overwritenMethodsOnFooBarAbs) Bar() string {
    +	return "Go Bar"
    +}
    +
    +func NewFooBarGo() FooBarGo {
    +	// Instantiate FooBarAbs with selected methods overridden.  The methods that
    +	// will be overwritten are defined on overwritenMethodsOnFooBarAbs and have
    +	// a compatible signature to the respective virtual C++ methods.
    +	// Furthermore additional constructor arguments will be typically stored in
    +	// the overwritenMethodsOnFooBarAbs struct.
    +	om := &overwritenMethodsOnFooBarAbs{}
    +	fb := NewDirectorFooBarAbs(om)
    +	om.fb = fb // Backlink causes cycle as fb.v = om!
    +
    +	fbgs := &fooBarGo{FooBarAbs: fb}
    +	// The memory of the FooBarAbs director object instance can be automatically
    +	// freed once the FooBarGo instance is garbage collected by uncommenting the
    +	// following line.  Please make sure to understand the runtime.SetFinalizer
    +	// specific gotchas before doing this.  Furthemore DeleteFooBarGo should be
    +	// deleted if a finalizer is in use or the fooBarGo struct needs additional
    +	// data to prevent double deletion.
    +	// runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbs)
    +	return fbgs
    +}
    +
    +// Recommended to be removed if runtime.SetFinalizer is in use.
    +func DeleteFooBarGo(fbg FooBarGo) {
    +	fbg.deleteFooBarAbs()
    +}
    +
    +
    + +

    +Returned string by the FooBarGo.FooBar method is: +

    + +
    +
    +Go Foo, Go Bar
    +
    +
    + +

    +For comparison the FooBarCpp class looks like this: +

    + +
    +
    +class FooBarCpp : public FooBarAbs
    +{
    +protected:
    +	virtual std::string Foo() {
    +		return "C++ " + FooBarAbs::Foo();
    +	}
    +
    +	virtual std::string Bar() {
    +		return "C++ Bar";
    +	}
    +};
    +
    +
    + +

    +For comparison the returned string by the FooBarCpp::FooBar method is: +

    + +
    +
    +C++ Foo, C++ Bar
    +
    +
    + +

    +The complete source of this example can be found under + +SWIG/Examples/go/director/. +

    + +

    23.4.8 Default Go primitive type mappings

    diff --git a/Examples/go/check.list b/Examples/go/check.list index 5399b8979..b3f34b306 100644 --- a/Examples/go/check.list +++ b/Examples/go/check.list @@ -2,6 +2,7 @@ callback class constants +director enum extend funcptr diff --git a/Examples/go/director/Makefile b/Examples/go/director/Makefile new file mode 100644 index 000000000..8a5fd508a --- /dev/null +++ b/Examples/go/director/Makefile @@ -0,0 +1,17 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = +GOSRCS = example.go director.go # example.go gets generated by SWIG +TARGET = example +INTERFACE = example.i +SWIGOPT = + +check: build + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run + +build: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='$(GOSRCS)' \ + SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/director/director.go b/Examples/go/director/director.go new file mode 100644 index 000000000..c3132d217 --- /dev/null +++ b/Examples/go/director/director.go @@ -0,0 +1,70 @@ +package example + +// FooBarGo is a superset of FooBarAbs and hence FooBarGo can be used as a drop +// in replacement for FooBarAbs but the reverse causes a compile time error. +type FooBarGo interface { + FooBarAbs + deleteFooBarAbs() + IsFooBarGo() +} + +// Via embedding fooBarGo "inherits" all methods of FooBarAbs. +type fooBarGo struct { + FooBarAbs +} + +func (fbgs *fooBarGo) deleteFooBarAbs() { + DeleteDirectorFooBarAbs(fbgs.FooBarAbs) +} + +// The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbs. +// This is also how the class hierarchy gets represented by the SWIG generated +// wrapper code. For an instance FooBarCpp has the IsFooBarAbs and IsFooBarCpp +// methods. +func (fbgs *fooBarGo) IsFooBarGo() {} + +// Go type that defines the DirectorInterface. It contains the Foo and Bar +// methods that overwrite the respective virtual C++ methods on FooBarAbs. +type overwritenMethodsOnFooBarAbs struct { + // Backlink to FooBarAbs so that the rest of the class can be used by the + // overridden methods. + fb FooBarAbs + + // If additional constructor arguments have been given they are typically + // stored here so that the overriden methods can use them. +} + +func (om *overwritenMethodsOnFooBarAbs) Foo() string { + // DirectorFooBarAbsFoo calls the base method FooBarAbs::Foo. + return "Go " + DirectorFooBarAbsFoo(om.fb) +} + +func (om *overwritenMethodsOnFooBarAbs) Bar() string { + return "Go Bar" +} + +func NewFooBarGo() FooBarGo { + // Instantiate FooBarAbs with selected methods overridden. The methods that + // will be overwritten are defined on overwritenMethodsOnFooBarAbs and have + // a compatible signature to the respective virtual C++ methods. + // Furthermore additional constructor arguments will be typically stored in + // the overwritenMethodsOnFooBarAbs struct. + om := &overwritenMethodsOnFooBarAbs{} + fb := NewDirectorFooBarAbs(om) + om.fb = fb // Backlink causes cycle as fb.v = om! + + fbgs := &fooBarGo{FooBarAbs: fb} + // The memory of the FooBarAbs director object instance can be automatically + // freed once the FooBarGo instance is garbage collected by uncommenting the + // following line. Please make sure to understand the runtime.SetFinalizer + // specific gotchas before doing this. Furthemore DeleteFooBarGo should be + // deleted if a finalizer is in use or the fooBarGo struct needs additional + // data to prevent double deletion. + // runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbs) + return fbgs +} + +// Recommended to be removed if runtime.SetFinalizer is in use. +func DeleteFooBarGo(fbg FooBarGo) { + fbg.deleteFooBarAbs() +} diff --git a/Examples/go/director/director.h b/Examples/go/director/director.h new file mode 100644 index 000000000..e08c11594 --- /dev/null +++ b/Examples/go/director/director.h @@ -0,0 +1,41 @@ +#ifndef DIRECTOR_H +#define DIRECTOR_H + + +#include +#include + + +class FooBarAbs +{ +public: + FooBarAbs() {}; + virtual ~FooBarAbs() {}; + + std::string FooBar() { + return this->Foo() + ", " + this->Bar(); + }; + +protected: + virtual std::string Foo() { + return "Foo"; + }; + + virtual std::string Bar() = 0; +}; + + +class FooBarCpp : public FooBarAbs +{ +protected: + virtual std::string Foo() { + return "C++ " + FooBarAbs::Foo(); + } + + virtual std::string Bar() { + return "C++ Bar"; + } +}; + + +#endif diff --git a/Examples/go/director/example.i b/Examples/go/director/example.i new file mode 100644 index 000000000..b56998e6d --- /dev/null +++ b/Examples/go/director/example.i @@ -0,0 +1,11 @@ +/* File : example.i */ +%module(directors="1") example + +%include "std_string.i" + +%header %{ +#include "director.h" +%} + +%feature("director") FooBarAbs; +%include "director.h" diff --git a/Examples/go/director/index.html b/Examples/go/director/index.html new file mode 100644 index 000000000..d1d5a74bc --- /dev/null +++ b/Examples/go/director/index.html @@ -0,0 +1,28 @@ + + +SWIG:Examples:go:director + + + + +SWIG/Examples/go/director/ +
    + +

    How to subclass a C++ class with a Go type

    + +

    +See the Go Director +Classes documentation subsection for an explanation of this example. +

    + +

    +

      +
    • director.go. Go source with the definition of the FooBarGo class. +
    • director.h. Header with the definition of the FooBarAbs and FooBarCpp classes. +
    • example.i. SWIG interface file. +
    • runme.go. Sample Go program. +
    + +
    + + diff --git a/Examples/go/director/runme.go b/Examples/go/director/runme.go new file mode 100644 index 000000000..0d839bc88 --- /dev/null +++ b/Examples/go/director/runme.go @@ -0,0 +1,39 @@ +package main + +import ( + "./example" + "fmt" + "os" +) + +func Compare(name string, got string, exp string) error { + fmt.Printf("%s; Got: '%s'; Expected: '%s'\n", name, got, exp) + if got != exp { + return fmt.Errorf("%s returned unexpected string! Got: '%s'; Expected: '%s'\n", name, got, exp) + } + return nil +} + +func TestFooBarCpp() error { + fb := example.NewFooBarCpp() + defer example.DeleteFooBarCpp(fb) + return Compare("FooBarCpp.FooBar()", fb.FooBar(), "C++ Foo, C++ Bar") +} + +func TestFooBarGo() error { + fb := example.NewFooBarGo() + defer example.DeleteFooBarGo(fb) + return Compare("FooBarGo.FooBar()", fb.FooBar(), "Go Foo, Go Bar") +} + +func main() { + fmt.Println("Test output:") + fmt.Println("------------") + err := TestFooBarCpp() + err = TestFooBarGo() + fmt.Println("------------") + if err != nil { + fmt.Fprintf(os.Stderr, "Tests failed! Last error: %s\n", err.Error()) + os.Exit(1) + } +} From 94994a749e813176ddd68fc67e22ae2cda442ddd Mon Sep 17 00:00:00 2001 From: Michael Schaller Date: Wed, 24 Jun 2015 14:53:28 +0200 Subject: [PATCH 053/732] Removed empty line in table of contents of the Go documentation. --- Doc/Manual/Go.html | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 0be378f6a..19a078d89 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -38,7 +38,6 @@
  • Subclass via embedding
  • Memory management with runtime.SetFinalizer
  • Complete FooBarGo example class -
  • Default Go primitive type mappings
  • Output arguments From afd6a55ce1089b0ee67bfa5509abfa126926c459 Mon Sep 17 00:00:00 2001 From: Michael Schaller Date: Fri, 26 Jun 2015 11:25:23 +0200 Subject: [PATCH 054/732] Fixed Examples/go/director/Makefile as director.go was missing in separate build directories. --- Examples/go/director/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Examples/go/director/Makefile b/Examples/go/director/Makefile index 8a5fd508a..0bb5c7b98 100644 --- a/Examples/go/director/Makefile +++ b/Examples/go/director/Makefile @@ -10,6 +10,9 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: + if [ -n '$(SRCDIR)' ]; then \ + cp $(SRCDIR)/director.go .; \ + fi $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='$(GOSRCS)' \ SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp From 0db9a6ba7b243546979f9a1737bac8d8435295d8 Mon Sep 17 00:00:00 2001 From: Michael Schaller Date: Fri, 26 Jun 2015 12:34:43 +0200 Subject: [PATCH 055/732] Fixed Examples/go/director/Makefile as the copy of director.go wasn't cleaned up in separate build directories. --- Examples/go/director/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Examples/go/director/Makefile b/Examples/go/director/Makefile index 0bb5c7b98..0c59bf340 100644 --- a/Examples/go/director/Makefile +++ b/Examples/go/director/Makefile @@ -17,4 +17,7 @@ build: SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: + if [ -n '$(SRCDIR)' ]; then \ + rm director.go; \ + fi $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean From e47d87e404859b8de09663f8d38485238f7eab52 Mon Sep 17 00:00:00 2001 From: Michael Schaller Date: Fri, 26 Jun 2015 13:27:37 +0200 Subject: [PATCH 056/732] Fixed Examples/go/director/Makefile as there might be no copy of director.go during clean if a separate build directory is in use. --- Examples/go/director/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/go/director/Makefile b/Examples/go/director/Makefile index 0c59bf340..84de5855d 100644 --- a/Examples/go/director/Makefile +++ b/Examples/go/director/Makefile @@ -18,6 +18,6 @@ build: clean: if [ -n '$(SRCDIR)' ]; then \ - rm director.go; \ + rm director.go || true; \ fi $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean From d9d26149e78e1488c263c00c4604c998004f65b5 Mon Sep 17 00:00:00 2001 From: Michael Schaller Date: Tue, 4 Aug 2015 09:50:56 +0200 Subject: [PATCH 057/732] Some minor changes after first code review by ianlancetaylor. Renamed overwritenMethodsOnFooBarAbs to overwrittenMethodsOnFooBarAbs. Changed some line breaks. --- Doc/Manual/Go.html | 62 ++++++++++++++++---------------- Examples/go/director/director.go | 12 +++---- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 19a078d89..c008ef22c 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -592,8 +592,8 @@ the %template directive. SWIG's director feature permits a Go type to act as the subclass of a C++ class. This is complicated by the fact that C++ and Go define inheritance differently. SWIG normally represents the C++ class inheritance automatically in Go via -interfaces but with a Go type representing a subclass of a C++ class quite some -manual work is necessary. +interfaces but with a Go type representing a subclass of a C++ class some manual +work is necessary.

    @@ -714,12 +714,12 @@ documentation on directors.

    SWIG creates an additional set of constructor and destructor functions once the -director feature has been enabled for a C++ class. NewDirectorClassName - allows to override virtual methods on the new object instance and -DeleteDirectorClassName needs to be used to free a director object instance -created with NewDirectorClassName. More on overriding virtual methods -follows later in this guide under -overriding virtual methods. +director feature has been enabled for a C++ class. +NewDirectorClassName allows overriding virtual methods on the new +object instance and DeleteDirectorClassName needs to be used to free a +director object instance created with NewDirectorClassName. +More on overriding virtual methods follows later in this guide under +overriding virtual methods.

    @@ -782,20 +782,20 @@ As an example see part of the FooBarGo class:

    -type overwritenMethodsOnFooBarAbs struct {
    +type overwrittenMethodsOnFooBarAbs struct {
     	fb FooBarAbs
     }
     
    -func (om *overwritenMethodsOnFooBarAbs) Foo() string {
    +func (om *overwrittenMethodsOnFooBarAbs) Foo() string {
     	...
     }
     
    -func (om *overwritenMethodsOnFooBarAbs) Bar() string {
    +func (om *overwrittenMethodsOnFooBarAbs) Bar() string {
     	...
     }
     
     func NewFooBarGo() FooBarGo {
    -	om := &overwritenMethodsOnFooBarAbs{}
    +	om := &overwrittenMethodsOnFooBarAbs{}
     	fb := NewDirectorFooBarAbs(om)
     	om.fb = fb
     	...
    @@ -814,16 +814,16 @@ class.
     
     

    The DirectorInterface in the example is implemented by the -overwritenMethodsOnFooBarAbs Go struct type. A pointer to a -overwritenMethodsOnFooBarAbs struct instance will be given to the +overwrittenMethodsOnFooBarAbs Go struct type. A pointer to a +overwrittenMethodsOnFooBarAbs struct instance will be given to the NewDirectorFooBarAbs constructor function. The constructor return value implements the FooBarAbs interface. -overwritenMethodsOnFooBarAbs could in theory be any Go type but in +overwrittenMethodsOnFooBarAbs could in theory be any Go type but in practice a struct is used as it typically contains at least a value of the C++ class interface so that the overwritten methods can use the rest of the C++ class. If the FooBarGo class would receive additional constructor -arguments then these would also typically be stored in the -overwritenMethodsOnFooBarAbs struct so that they can be used by the +arguments then these would also typically be stored in the +overwrittenMethodsOnFooBarAbs struct so that they can be used by the Go methods.

    @@ -833,8 +833,8 @@ Go methods.

    Often a virtual method will be overwritten to extend the original behavior of -the method in the base class. This is also the case for the FooBarCpp::Foo - method of the example code: +the method in the base class. This is also the case for the +FooBarCpp::Foo method of the example code:

    @@ -853,7 +853,7 @@ The FooBarGo.Foo implementation in the example looks like this:
    -func (om *overwritenMethodsOnFooBarAbs) Foo() string {
    +func (om *overwrittenMethodsOnFooBarAbs) Foo() string {
     	return "Go " + DirectorFooBarAbsFoo(om.fb)
     }
     
    @@ -903,7 +903,7 @@ func (fbgs *fooBarGo) deleteFooBarAbs() { func (fbgs *fooBarGo) IsFooBarGo() {} func NewFooBarGo() FooBarGo { - om := &overwritenMethodsOnFooBarAbs{} + om := &overwrittenMethodsOnFooBarAbs{} fb := NewDirectorFooBarAbs(om) om.fb = fb @@ -946,12 +946,12 @@ in the FooBarGo class is here:
    -type overwritenMethodsOnFooBarAbs struct {
    +type overwrittenMethodsOnFooBarAbs struct {
     	fb FooBarAbs
     }
     
     func NewFooBarGo() FooBarGo {
    -	om := &overwritenMethodsOnFooBarAbs{}
    +	om := &overwrittenMethodsOnFooBarAbs{}
     	fb := NewDirectorFooBarAbs(om) // fb.v = om
     	om.fb = fb // Backlink causes cycle as fb.v = om!
     	...
    @@ -973,12 +973,12 @@ type fooBarGo struct {
     	FooBarAbs
     }
     
    -type overwritenMethodsOnFooBarAbs struct {
    +type overwrittenMethodsOnFooBarAbs struct {
     	fb FooBarAbs
     }
     
     func NewFooBarGo() FooBarGo {
    -	om := &overwritenMethodsOnFooBarAbs{}
    +	om := &overwrittenMethodsOnFooBarAbs{}
     	fb := NewDirectorFooBarAbs(om)
     	om.fb = fb // Backlink causes cycle as fb.v = om!
     
    @@ -1032,7 +1032,7 @@ func (fbgs *fooBarGo) IsFooBarGo() {}
     
     // Go type that defines the DirectorInterface. It contains the Foo and Bar
     // methods that overwrite the respective virtual C++ methods on FooBarAbs.
    -type overwritenMethodsOnFooBarAbs struct {
    +type overwrittenMethodsOnFooBarAbs struct {
     	// Backlink to FooBarAbs so that the rest of the class can be used by the
     	// overridden methods.
     	fb FooBarAbs
    @@ -1041,22 +1041,22 @@ type overwritenMethodsOnFooBarAbs struct {
     	// stored here so that the overriden methods can use them.
     }
     
    -func (om *overwritenMethodsOnFooBarAbs) Foo() string {
    +func (om *overwrittenMethodsOnFooBarAbs) Foo() string {
     	// DirectorFooBarAbsFoo calls the base method FooBarAbs::Foo.
     	return "Go " + DirectorFooBarAbsFoo(om.fb)
     }
     
    -func (om *overwritenMethodsOnFooBarAbs) Bar() string {
    +func (om *overwrittenMethodsOnFooBarAbs) Bar() string {
     	return "Go Bar"
     }
     
     func NewFooBarGo() FooBarGo {
     	// Instantiate FooBarAbs with selected methods overridden.  The methods that
    -	// will be overwritten are defined on overwritenMethodsOnFooBarAbs and have
    +	// will be overwritten are defined on overwrittenMethodsOnFooBarAbs and have
     	// a compatible signature to the respective virtual C++ methods.
     	// Furthermore additional constructor arguments will be typically stored in
    -	// the overwritenMethodsOnFooBarAbs struct.
    -	om := &overwritenMethodsOnFooBarAbs{}
    +	// the overwrittenMethodsOnFooBarAbs struct.
    +	om := &overwrittenMethodsOnFooBarAbs{}
     	fb := NewDirectorFooBarAbs(om)
     	om.fb = fb // Backlink causes cycle as fb.v = om!
     
    diff --git a/Examples/go/director/director.go b/Examples/go/director/director.go
    index c3132d217..a5078fe58 100644
    --- a/Examples/go/director/director.go
    +++ b/Examples/go/director/director.go
    @@ -25,7 +25,7 @@ func (fbgs *fooBarGo) IsFooBarGo() {}
     
     // Go type that defines the DirectorInterface. It contains the Foo and Bar
     // methods that overwrite the respective virtual C++ methods on FooBarAbs.
    -type overwritenMethodsOnFooBarAbs struct {
    +type overwrittenMethodsOnFooBarAbs struct {
     	// Backlink to FooBarAbs so that the rest of the class can be used by the
     	// overridden methods.
     	fb FooBarAbs
    @@ -34,22 +34,22 @@ type overwritenMethodsOnFooBarAbs struct {
     	// stored here so that the overriden methods can use them.
     }
     
    -func (om *overwritenMethodsOnFooBarAbs) Foo() string {
    +func (om *overwrittenMethodsOnFooBarAbs) Foo() string {
     	// DirectorFooBarAbsFoo calls the base method FooBarAbs::Foo.
     	return "Go " + DirectorFooBarAbsFoo(om.fb)
     }
     
    -func (om *overwritenMethodsOnFooBarAbs) Bar() string {
    +func (om *overwrittenMethodsOnFooBarAbs) Bar() string {
     	return "Go Bar"
     }
     
     func NewFooBarGo() FooBarGo {
     	// Instantiate FooBarAbs with selected methods overridden.  The methods that
    -	// will be overwritten are defined on overwritenMethodsOnFooBarAbs and have
    +	// will be overwritten are defined on overwrittenMethodsOnFooBarAbs and have
     	// a compatible signature to the respective virtual C++ methods.
     	// Furthermore additional constructor arguments will be typically stored in
    -	// the overwritenMethodsOnFooBarAbs struct.
    -	om := &overwritenMethodsOnFooBarAbs{}
    +	// the overwrittenMethodsOnFooBarAbs struct.
    +	om := &overwrittenMethodsOnFooBarAbs{}
     	fb := NewDirectorFooBarAbs(om)
     	om.fb = fb // Backlink causes cycle as fb.v = om!
     
    
    From 736613e26c911645237594980f6fa3064f634701 Mon Sep 17 00:00:00 2001
    From: Michael Schaller 
    Date: Wed, 5 Aug 2015 10:01:15 +0200
    Subject: [PATCH 058/732] [Go] Documentation cleanup of obsolete 'callback' and
     'extend' examples.
    
    After commit 17b1c1c (pull request 447; issue 418) the 'callback' and 'extend'
    examples have been removed in favor of the 'director' example.
    ---
     Examples/go/callback/Makefile     | 16 ------
     Examples/go/callback/callback.cxx |  4 --
     Examples/go/callback/example.h    | 23 ---------
     Examples/go/callback/example.i    | 11 -----
     Examples/go/callback/index.html   | 81 -------------------------------
     Examples/go/callback/runme.go     | 41 ----------------
     Examples/go/check.list            |  2 -
     Examples/go/extend/Makefile       | 16 ------
     Examples/go/extend/example.h      | 56 ---------------------
     Examples/go/extend/example.i      | 15 ------
     Examples/go/extend/extend.cxx     |  4 --
     Examples/go/extend/index.html     | 27 -----------
     Examples/go/extend/runme.go       | 76 -----------------------------
     Examples/go/index.html            |  7 ++-
     14 files changed, 3 insertions(+), 376 deletions(-)
     delete mode 100644 Examples/go/callback/Makefile
     delete mode 100644 Examples/go/callback/callback.cxx
     delete mode 100644 Examples/go/callback/example.h
     delete mode 100644 Examples/go/callback/example.i
     delete mode 100644 Examples/go/callback/index.html
     delete mode 100644 Examples/go/callback/runme.go
     delete mode 100644 Examples/go/extend/Makefile
     delete mode 100644 Examples/go/extend/example.h
     delete mode 100644 Examples/go/extend/example.i
     delete mode 100644 Examples/go/extend/extend.cxx
     delete mode 100644 Examples/go/extend/index.html
     delete mode 100644 Examples/go/extend/runme.go
    
    diff --git a/Examples/go/callback/Makefile b/Examples/go/callback/Makefile
    deleted file mode 100644
    index bf5275f14..000000000
    --- a/Examples/go/callback/Makefile
    +++ /dev/null
    @@ -1,16 +0,0 @@
    -TOP        = ../..
    -SWIG       = $(TOP)/../preinst-swig
    -CXXSRCS    = callback.cxx
    -TARGET     = example
    -INTERFACE  = example.i
    -SWIGOPT    =
    -
    -check: build
    -	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
    -
    -build:
    -	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
    -	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
    -
    -clean:
    -	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
    diff --git a/Examples/go/callback/callback.cxx b/Examples/go/callback/callback.cxx
    deleted file mode 100644
    index 450d75608..000000000
    --- a/Examples/go/callback/callback.cxx
    +++ /dev/null
    @@ -1,4 +0,0 @@
    -/* File : example.cxx */
    -
    -#include "example.h"
    -
    diff --git a/Examples/go/callback/example.h b/Examples/go/callback/example.h
    deleted file mode 100644
    index 1a0e8c432..000000000
    --- a/Examples/go/callback/example.h
    +++ /dev/null
    @@ -1,23 +0,0 @@
    -/* File : example.h */
    -
    -#include 
    -#include 
    -
    -class Callback {
    -public:
    -	virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; }
    -	virtual void run() { std::cout << "Callback::run()" << std::endl; }
    -};
    -
    -
    -class Caller {
    -private:
    -	Callback *_callback;
    -public:
    -	Caller(): _callback(0) {}
    -	~Caller() { delCallback(); }
    -	void delCallback() { delete _callback; _callback = 0; }
    -	void setCallback(Callback *cb) { delCallback(); _callback = cb; }
    -	void call() { if (_callback) _callback->run(); }
    -};
    -
    diff --git a/Examples/go/callback/example.i b/Examples/go/callback/example.i
    deleted file mode 100644
    index cf61ef9d2..000000000
    --- a/Examples/go/callback/example.i
    +++ /dev/null
    @@ -1,11 +0,0 @@
    -/* File : example.i */
    -%module(directors="1") example
    -%{
    -#include "example.h"
    -%}
    -
    -/* turn on director wrapping Callback */
    -%feature("director") Callback;
    -
    -%include "example.h"
    -
    diff --git a/Examples/go/callback/index.html b/Examples/go/callback/index.html
    deleted file mode 100644
    index b053cf547..000000000
    --- a/Examples/go/callback/index.html
    +++ /dev/null
    @@ -1,81 +0,0 @@
    -
    -
    -SWIG:Examples:go:callback
    -
    -
    -
    -
    -
    -SWIG/Examples/go/callback/
    -
    - -

    Implementing C++ callbacks in Go

    - -

    -This example illustrates how to use directors to implement C++ -callbacks in Go. -

    - -

    -Because Go and C++ use inheritance differently, you must call a -different function to create a class which uses callbacks. Instead of -calling the usual constructor function whose name is New -followed by the capitalized name of the class, you call a function -named NewDirector followed by the capitalized name of the -class. -

    - -

    -The first argument to the NewDirector function is an instance -of a type. The NewDirector function will return an interface -value as usual. However, when calling any method on the returned -value, the program will first check whether the value passed -to NewDirector implements that method. If it does, the -method will be called in Go. This is true whether the method is -called from Go code or C++ code. -

    - -

    -Note that the Go code will be called with just the Go value, not the -C++ value. If the Go code needs to call a C++ method on itself, you -need to get a copy of the C++ object. This is typically done as -follows: - -

    -
    -type Child struct { abi Parent }
    -func (p *Child) ChildMethod() {
    -	p.abi.ParentMethod()
    -}
    -func f() {
    -	p := &Child{nil}
    -	d := NewDirectorParent(p)
    -	p.abi = d
    -	...
    -}
    -
    -
    - -In other words, we first create the Go value. We pass that to -the NewDirector function to create the C++ value; this C++ -value will be created with an association to the Go value. We then -store the C++ value in the Go value, giving us the reverse -association. That permits us to call parent methods from the child. - -

    - -

    -To delete a director object, use the function DeleteDirector -followed by the capitalized name of the class. -

    - -

    -

    - -
    - - diff --git a/Examples/go/callback/runme.go b/Examples/go/callback/runme.go deleted file mode 100644 index 2eef77fdb..000000000 --- a/Examples/go/callback/runme.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - . "./example" - "fmt" -) - -func main() { - fmt.Println("Adding and calling a normal C++ callback") - fmt.Println("----------------------------------------") - - caller := NewCaller() - callback := NewCallback() - - caller.SetCallback(callback) - caller.Call() - caller.DelCallback() - - callback = NewDirectorCallback(new(GoCallback)) - - fmt.Println() - fmt.Println("Adding and calling a Go callback") - fmt.Println("------------------------------------") - - caller.SetCallback(callback) - caller.Call() - caller.DelCallback() - - // Test that a double delete does not occur as the object has - // already been deleted from the C++ layer. - DeleteDirectorCallback(callback) - - fmt.Println() - fmt.Println("Go exit") -} - -type GoCallback struct{} - -func (p *GoCallback) Run() { - fmt.Println("GoCallback.Run") -} diff --git a/Examples/go/check.list b/Examples/go/check.list index b3f34b306..25322352a 100644 --- a/Examples/go/check.list +++ b/Examples/go/check.list @@ -1,10 +1,8 @@ # see top-level Makefile.in -callback class constants director enum -extend funcptr multimap pointer diff --git a/Examples/go/extend/Makefile b/Examples/go/extend/Makefile deleted file mode 100644 index 290694210..000000000 --- a/Examples/go/extend/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -CXXSRCS = extend.cxx -TARGET = example -INTERFACE = example.i -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/extend/example.h b/Examples/go/extend/example.h deleted file mode 100644 index ca1aed28f..000000000 --- a/Examples/go/extend/example.h +++ /dev/null @@ -1,56 +0,0 @@ -/* File : example.h */ - -#include -#include -#include -#include -#include - -class Employee { -private: - std::string name; -public: - Employee(const char* n): name(n) {} - virtual std::string getTitle() { return getPosition() + " " + getName(); } - virtual std::string getName() { return name; } - virtual std::string getPosition() const { return "Employee"; } - virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } -}; - - -class Manager: public Employee { -public: - Manager(const char* n): Employee(n) {} - virtual std::string getPosition() const { return "Manager"; } -}; - - -class EmployeeList { - std::vector list; -public: - EmployeeList() { - list.push_back(new Employee("Bob")); - list.push_back(new Employee("Jane")); - list.push_back(new Manager("Ted")); - } - void addEmployee(Employee *p) { - list.push_back(p); - std::cout << "New employee added. Current employees are:" << std::endl; - std::vector::iterator i; - for (i=list.begin(); i!=list.end(); i++) { - std::cout << " " << (*i)->getTitle() << std::endl; - } - } - const Employee *get_item(int i) { - return list[i]; - } - ~EmployeeList() { - std::vector::iterator i; - std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; - for (i=list.begin(); i!=list.end(); i++) { - delete *i; - } - std::cout << "~EmployeeList empty." << std::endl; - } -}; - diff --git a/Examples/go/extend/example.i b/Examples/go/extend/example.i deleted file mode 100644 index c8ec32e09..000000000 --- a/Examples/go/extend/example.i +++ /dev/null @@ -1,15 +0,0 @@ -/* File : example.i */ -%module(directors="1") example -%{ -#include "example.h" -%} - -%include "std_vector.i" -%include "std_string.i" - -/* turn on director wrapping for Manager */ -%feature("director") Employee; -%feature("director") Manager; - -%include "example.h" - diff --git a/Examples/go/extend/extend.cxx b/Examples/go/extend/extend.cxx deleted file mode 100644 index 450d75608..000000000 --- a/Examples/go/extend/extend.cxx +++ /dev/null @@ -1,4 +0,0 @@ -/* File : example.cxx */ - -#include "example.h" - diff --git a/Examples/go/extend/index.html b/Examples/go/extend/index.html deleted file mode 100644 index 471fa9cdc..000000000 --- a/Examples/go/extend/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - -SWIG:Examples:go:extend - - - - - -SWIG/Examples/go/extend/ -
    - -

    Extending a simple C++ class in Go

    - -

    -This example illustrates the extending of a C++ class with cross -language polymorphism. - -

    -

    - -
    - - diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go deleted file mode 100644 index 770e27802..000000000 --- a/Examples/go/extend/runme.go +++ /dev/null @@ -1,76 +0,0 @@ -// This file illustrates the cross language polymorphism using directors. - -package main - -import ( - . "./example" - "fmt" -) - -type CEO struct{} - -func (p *CEO) GetPosition() string { - return "CEO" -} - -func main() { - // Create an instance of CEO, a class derived from the Go - // proxy of the underlying C++ class. The calls to getName() - // and getPosition() are standard, the call to getTitle() uses - // the director wrappers to call CEO.getPosition(). - - e := NewDirectorManager(new(CEO), "Alice") - fmt.Println(e.GetName(), " is a ", e.GetPosition()) - fmt.Println("Just call her \"", e.GetTitle(), "\"") - fmt.Println("----------------------") - - // Create a new EmployeeList instance. This class does not - // have a C++ director wrapper, but can be used freely with - // other classes that do. - - list := NewEmployeeList() - - // EmployeeList owns its items, so we must surrender ownership - // of objects we add. - // e.DisownMemory() - list.AddEmployee(e) - fmt.Println("----------------------") - - // Now we access the first four items in list (three are C++ - // objects that EmployeeList's constructor adds, the last is - // our CEO). The virtual 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 Go. The call to GetPosition - // 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 - // CEO, but now Go thinks the object is an instance of class - // Employee. So the call passes through the Employee proxy - // class and on to the C wrappers and C++ director, eventually - // ending up back at the Java CEO implementation of - // getPosition(). The call to GetTitle() for item 3 runs the - // C++ Employee::getTitle() method, which in turn calls - // GetPosition(). This virtual method call passes down - // through the C++ director class to the Java implementation - // in CEO. All this routing takes place transparently. - - fmt.Println("(position, title) for items 0-3:") - - fmt.Println(" ", list.Get_item(0).GetPosition(), ", \"", list.Get_item(0).GetTitle(), "\"") - fmt.Println(" ", list.Get_item(1).GetPosition(), ", \"", list.Get_item(1).GetTitle(), "\"") - fmt.Println(" ", list.Get_item(2).GetPosition(), ", \"", list.Get_item(2).GetTitle(), "\"") - fmt.Println(" ", list.Get_item(3).GetPosition(), ", \"", list.Get_item(3).GetTitle(), "\"") - fmt.Println("----------------------") - - // Time to delete the EmployeeList, which will delete all the - // Employee* items it contains. The last item is our CEO, - // which gets destroyed as well. - DeleteEmployeeList(list) - fmt.Println("----------------------") - - // All done. - - fmt.Println("Go exit") -} diff --git a/Examples/go/index.html b/Examples/go/index.html index 21dda21b5..4c07af3f0 100644 --- a/Examples/go/index.html +++ b/Examples/go/index.html @@ -21,8 +21,7 @@ certain C declarations are turned into constants.
  • pointer. Simple pointer handling.
  • funcptr. Pointers to functions.
  • template. C++ templates. -
  • callback. C++ callbacks using directors. -
  • extend. Polymorphism using directors. +
  • director. Example how to utilize the director feature.

    Compilation Issues

    @@ -46,7 +45,7 @@ the 6g or 8g compiler, the steps look like this
     % swig -go interface.i
     % gcc -fpic -c interface_wrap.c
    -% gcc -shared interface_wrap.o $(OBJS) -o interfacemodule.so 
    +% gcc -shared interface_wrap.o $(OBJS) -o interfacemodule.so
     % 6g interface.go
     % 6c interface_gc.c
     % gopack grc interface.a interface.6 interface_gc.6
    @@ -83,7 +82,7 @@ All of the examples were last tested with the following configuration
     
  • gcc-4.2.4 -Your mileage may vary. If you experience a problem, please let us know by +Your mileage may vary. If you experience a problem, please let us know by contacting us on the mailing lists. From 95a08b3950ea1f43846ccff11969c9179f2eeddd Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 5 Aug 2015 07:19:05 -0700 Subject: [PATCH 059/732] [Go] update build instructions in Examples/go/index.html --- Examples/go/index.html | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/Examples/go/index.html b/Examples/go/index.html index 4c07af3f0..b7d7017d3 100644 --- a/Examples/go/index.html +++ b/Examples/go/index.html @@ -36,20 +36,23 @@ certain C declarations are turned into constants.
  • On Unix the compilation of examples is done using the -file Example/Makefile. This makefile performs a manual -module compilation which is platform specific. When using -the 6g or 8g compiler, the steps look like this +file Example/Makefile. Normally builds are done simply +using go build. For testing purposes this makefile performs +a manual module compilation that is platform specific. When using +the gc compiler, the steps look approximately like this (GNU/Linux):
    -% swig -go interface.i
    -% gcc -fpic -c interface_wrap.c
    -% gcc -shared interface_wrap.o $(OBJS) -o interfacemodule.so
    -% 6g interface.go
    -% 6c interface_gc.c
    -% gopack grc interface.a interface.6 interface_gc.6
    -% 6l program.6
    +% swig -go -cgo interface.i
    +% mkdir -p gopath/src/interface
    +% cp interface_wrap.c interface_wrap.h interface.go gopath/src/interface
    +% GOPATH=`pwd`/gopath
    +% export GOPATH
    +% cd gopath/src/interface
    +% go build
    +% go tool compile $(SRCDIR)/runme.go
    +% go tool link -o runme runme.o
     
    @@ -57,10 +60,15 @@ the 6g or 8g compiler, the steps look like this
    -% swig -go interface.i
    -% gcc -c interface_wrap.c
    -% gccgo -c interface.go
    -% gccgo program.o interface.o interface_wrap.o
    +% swig -go -cgo interface.i
    +% mkdir -p gopath/src/interface
    +% cp interface_wrap.c interface_wrap.h interface.go gopath/src/interface
    +% GOPATH=`pwd`/gopath
    +% export GOPATH
    +% cd gopath/src/interface
    +% go build
    +% gccgo -c $(SRCDIR)/runme.go
    +% gccgo -o runme runme.o interface.a
     
    All of the examples were last tested with the following configuration -(10 May 2010): +(5 August 2015):
      -
    • Ubuntu Hardy -
    • gcc-4.2.4 +
    • Ubuntu Trusty +
    • gcc-4.8.4
    Your mileage may vary. If you experience a problem, please let us know by From c1fad12bdb6fa89c6cb546326289761d9fc4aede Mon Sep 17 00:00:00 2001 From: David Xu Date: Wed, 5 Aug 2015 21:54:51 -0400 Subject: [PATCH 060/732] Extend the export feature in the CFFI module to support exporting to a particular package. --- CHANGES.current | 4 ++++ Source/Modules/cffi.cxx | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c0694f657..b78865184 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,3 +4,7 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== + +2015-08-05: lyze + [CFFI] Extend the "export" feature in the CFFI module to support + exporting to a specified package. diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 8f718e653..39a1ac763 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -860,8 +860,11 @@ void CFFI::emit_struct_union(Node *n, bool un = false) { } void CFFI::emit_export(Node *n, String *name) { - if (GetInt(n, "feature:export")) - Printf(f_cl, "\n(cl:export '%s)\n", name); + if (GetInt(n, "feature:export")) { + String* package = Getattr(n, "feature:export:package"); + Printf(f_cl, "\n(cl:export '%s%s%s)\n", name, package ? " " : "", + package ? package : ""); + } } void CFFI::emit_inline(Node *n, String *name) { From a1bddd56eb3404c9a069a48fa7b391fd255a7905 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 6 Aug 2015 00:10:51 +0200 Subject: [PATCH 061/732] Make (char*, size_t) typemap usable for strings of other types in Java. Notably it now works for "unsigned char*" strings. Add a test to check that it now works in Java and also showing that it already worked for the other languages with support for this typemap. --- CHANGES.current | 4 ++++ Examples/test-suite/char_binary.i | 4 ++++ Examples/test-suite/java/char_binary_runme.java | 6 ++++++ Examples/test-suite/javascript/char_binary_runme.js | 10 ++++++++++ Examples/test-suite/perl5/char_binary_runme.pl | 5 ++++- Examples/test-suite/python/char_binary_runme.py | 7 +++++++ Lib/java/java.swg | 4 ++-- 7 files changed, 37 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c0694f657..f78f6bb48 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,3 +4,7 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== + +2015-08-05: vadz + [Java] Make (char* STRING, size_t LENGTH) typemaps usable for + strings of other types, e.g. "unsigned char*". diff --git a/Examples/test-suite/char_binary.i b/Examples/test-suite/char_binary.i index 778792946..394565438 100644 --- a/Examples/test-suite/char_binary.i +++ b/Examples/test-suite/char_binary.i @@ -5,12 +5,16 @@ A test case for testing non null terminated char pointers. %module char_binary %apply (char *STRING, size_t LENGTH) { (const char *str, size_t len) } +%apply (char *STRING, size_t LENGTH) { (const unsigned char *str, size_t len) } %inline %{ struct Test { size_t strlen(const char *str, size_t len) { return len; } + size_t ustrlen(const unsigned char *str, size_t len) { + return len; + } }; typedef char namet[5]; diff --git a/Examples/test-suite/java/char_binary_runme.java b/Examples/test-suite/java/char_binary_runme.java index 9227f8617..bc811ef5d 100644 --- a/Examples/test-suite/java/char_binary_runme.java +++ b/Examples/test-suite/java/char_binary_runme.java @@ -20,5 +20,11 @@ public class char_binary_runme { if (t.strlen(hil0) != 4) throw new RuntimeException("bad multi-arg typemap"); + + if (t.ustrlen(hile) != 4) + throw new RuntimeException("bad multi-arg typemap"); + + if (t.ustrlen(hil0) != 4) + throw new RuntimeException("bad multi-arg typemap"); } } diff --git a/Examples/test-suite/javascript/char_binary_runme.js b/Examples/test-suite/javascript/char_binary_runme.js index b2aac920c..01b72ebe1 100644 --- a/Examples/test-suite/javascript/char_binary_runme.js +++ b/Examples/test-suite/javascript/char_binary_runme.js @@ -5,10 +5,17 @@ if (t.strlen('hile') != 4) { print(t.strlen('hile')); throw("bad multi-arg typemap 1"); } +if (t.ustrlen('hile') != 4) { + print(t.ustrlen('hile')); + throw("bad multi-arg typemap 1"); +} if (t.strlen('hil\0') != 4) { throw("bad multi-arg typemap 2"); } +if (t.ustrlen('hil\0') != 4) { + throw("bad multi-arg typemap 2"); +} /* * creating a raw char* @@ -24,6 +31,9 @@ char_binary.pchar_setitem(pc, 4, 0); if (t.strlen(pc) != 4) { throw("bad multi-arg typemap (3)"); } +if (t.ustrlen(pc) != 4) { + throw("bad multi-arg typemap (3)"); +} char_binary.var_pchar = pc; if (char_binary.var_pchar != "hola") { diff --git a/Examples/test-suite/perl5/char_binary_runme.pl b/Examples/test-suite/perl5/char_binary_runme.pl index 4c50ee700..f97d740a6 100644 --- a/Examples/test-suite/perl5/char_binary_runme.pl +++ b/Examples/test-suite/perl5/char_binary_runme.pl @@ -1,14 +1,16 @@ use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 10; BEGIN { use_ok('char_binary') } require_ok('char_binary'); my $t = char_binary::Test->new(); is($t->strlen('hile'), 4, "string typemap"); +is($t->ustrlen('hile'), 4, "unsigned string typemap"); is($t->strlen("hil\0"), 4, "string typemap"); +is($t->ustrlen("hil\0"), 4, "unsigned string typemap"); # # creating a raw char* @@ -22,6 +24,7 @@ char_binary::pchar_setitem($pc, 4, 0); is($t->strlen($pc), 4, "string typemap"); +is($t->ustrlen($pc), 4, "unsigned string typemap"); $char_binary::var_pchar = $pc; is($char_binary::var_pchar, "hola", "pointer case"); diff --git a/Examples/test-suite/python/char_binary_runme.py b/Examples/test-suite/python/char_binary_runme.py index 13457253f..34caa3208 100644 --- a/Examples/test-suite/python/char_binary_runme.py +++ b/Examples/test-suite/python/char_binary_runme.py @@ -4,9 +4,14 @@ t = Test() if t.strlen('hile') != 4: print t.strlen('hile') raise RuntimeError, "bad multi-arg typemap" +if t.ustrlen('hile') != 4: + print t.ustrlen('hile') + raise RuntimeError, "bad multi-arg typemap" if t.strlen('hil\0') != 4: raise RuntimeError, "bad multi-arg typemap" +if t.ustrlen('hil\0') != 4: + raise RuntimeError, "bad multi-arg typemap" # # creating a raw char* @@ -21,6 +26,8 @@ pchar_setitem(pc, 4, 0) if t.strlen(pc) != 4: raise RuntimeError, "bad multi-arg typemap" +if t.ustrlen(pc) != 4: + raise RuntimeError, "bad multi-arg typemap" cvar.var_pchar = pc if cvar.var_pchar != "hola": diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 2e106796c..0ff487d80 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1330,8 +1330,8 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) %typemap(freearg) (char *STRING, size_t LENGTH) "" %typemap(in) (char *STRING, size_t LENGTH) { if ($input) { - $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0); - $2 = (size_t) JCALL1(GetArrayLength, jenv, $input); + $1 = ($1_ltype) JCALL2(GetByteArrayElements, jenv, $input, 0); + $2 = ($2_type) JCALL1(GetArrayLength, jenv, $input); } else { $1 = 0; $2 = 0; From 92328a2016bd0d3e5e383cbc30a6713c28c60470 Mon Sep 17 00:00:00 2001 From: xantares Date: Mon, 13 Apr 2015 11:15:18 +0200 Subject: [PATCH 062/732] pep257 & numpydoc conforming docstrings --- Doc/Manual/Python.html | 37 ++-- Examples/test-suite/autodoc.i | 4 +- Examples/test-suite/python/autodoc_runme.py | 222 +++++++++++--------- Source/Modules/python.cxx | 17 +- 4 files changed, 156 insertions(+), 124 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 57a2cd3ef..3af79e8d6 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -5273,8 +5273,8 @@ def function_name(*args, **kwargs):

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

    @@ -5283,11 +5283,12 @@ def function_name(*args, **kwargs): """ function_name(x, y, foo=None, bar=None) -> bool - Parameters: - x: int - y: int - foo: Foo * - bar: Bar * + Parameters + ---------- + x: int + y: int + foo: Foo * + bar: Bar * """ ... @@ -5318,11 +5319,12 @@ def function_name(*args, **kwargs): """ function_name(x, y, foo=None, bar=None) -> bool - Parameters: - x (C++ type: int) -- Input x dimension - y: int - foo: Foo * - bar: Bar * + Parameters + ---------- + x (C++ type: int) -- Input x dimension + y: int + foo: Foo * + bar: Bar * """
  • @@ -5341,11 +5343,12 @@ def function_name(*args, **kwargs): """ function_name(int x, int y, Foo foo=None, Bar bar=None) -> bool - Parameters: - x: int - y: int - foo: Foo * - bar: Bar * + Parameters + ---------- + x: int + y: int + foo: Foo * + bar: Bar * """ ... diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index 07afa5794..eda04d293 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -1,4 +1,4 @@ -%module(docstring="hello") autodoc +%module(docstring="hello.") autodoc %feature("autodoc"); @@ -27,7 +27,7 @@ %feature("autodoc","2") A::variable_c; // extended %feature("autodoc","3") A::variable_d; // extended + types -%feature("autodoc","just a string") A::funk; // names +%feature("autodoc","just a string.") A::funk; // names %inline { diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index f5b6b7ce6..7256669d9 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -23,8 +23,8 @@ if not is_new_style_class(A): # skip builtin check - the autodoc is missing, but it probably should not be skip = True -check(A.__doc__, "Proxy of C++ A class", "::A") -check(A.funk.__doc__, "just a string") +check(A.__doc__, "Proxy of C++ A class.", "::A") +check(A.funk.__doc__, "just a string.") check(A.func0.__doc__, "func0(self, arg2, hello) -> int", "func0(arg2, hello) -> int") @@ -35,17 +35,19 @@ check(A.func2.__doc__, "\n" " func2(self, arg2, hello) -> int\n" "\n" - " Parameters:\n" - " arg2: short\n" - " hello: int tuple[2]\n" + " Parameters\n" + " ----------\n" + " arg2: short\n" + " hello: int tuple[2]\n" "\n" " ", "\n" "func2(arg2, hello) -> int\n" "\n" - "Parameters:\n" - " arg2: short\n" - " hello: int tuple[2]\n" + "Parameters\n" + "----------\n" + "arg2: short\n" + "hello: int tuple[2]\n" "\n" "" ) @@ -53,17 +55,19 @@ check(A.func3.__doc__, "\n" " func3(A self, short arg2, Tuple hello) -> int\n" "\n" - " Parameters:\n" - " arg2: short\n" - " hello: int tuple[2]\n" + " Parameters\n" + " ----------\n" + " arg2: short\n" + " hello: int tuple[2]\n" "\n" " ", "\n" "func3(short arg2, Tuple hello) -> int\n" "\n" - "Parameters:\n" - " arg2: short\n" - " hello: int tuple[2]\n" + "Parameters\n" + "----------\n" + "arg2: short\n" + "hello: int tuple[2]\n" "\n" "" ) @@ -92,35 +96,39 @@ check(A.func2default.__doc__, "\n" " func2default(self, e, arg3, hello, f=2) -> int\n" "\n" - " Parameters:\n" - " e: A *\n" - " arg3: short\n" - " hello: int tuple[2]\n" - " f: double\n" + " Parameters\n" + " ----------\n" + " e: A *\n" + " arg3: short\n" + " hello: int tuple[2]\n" + " f: double\n" "\n" " func2default(self, e, arg3, hello) -> int\n" "\n" - " Parameters:\n" - " e: A *\n" - " arg3: short\n" - " hello: int tuple[2]\n" + " Parameters\n" + " ----------\n" + " e: A *\n" + " arg3: short\n" + " hello: int tuple[2]\n" "\n" " ", "\n" "func2default(e, arg3, hello, f=2) -> int\n" "\n" - "Parameters:\n" - " e: A *\n" - " arg3: short\n" - " hello: int tuple[2]\n" - " f: double\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg3: short\n" + "hello: int tuple[2]\n" + "f: double\n" "\n" "func2default(e, arg3, hello) -> int\n" "\n" - "Parameters:\n" - " e: A *\n" - " arg3: short\n" - " hello: int tuple[2]\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg3: short\n" + "hello: int tuple[2]\n" "\n" "" ) @@ -128,35 +136,39 @@ check(A.func3default.__doc__, "\n" " func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n" "\n" - " Parameters:\n" - " e: A *\n" - " arg3: short\n" - " hello: int tuple[2]\n" - " f: double\n" + " Parameters\n" + " ----------\n" + " e: A *\n" + " arg3: short\n" + " hello: int tuple[2]\n" + " f: double\n" "\n" " func3default(A self, A e, short arg3, Tuple hello) -> int\n" "\n" - " Parameters:\n" - " e: A *\n" - " arg3: short\n" - " hello: int tuple[2]\n" + " Parameters\n" + " ----------\n" + " e: A *\n" + " arg3: short\n" + " hello: int tuple[2]\n" "\n" " ", "\n" "func3default(A e, short arg3, Tuple hello, double f=2) -> int\n" "\n" - "Parameters:\n" - " e: A *\n" - " arg3: short\n" - " hello: int tuple[2]\n" - " f: double\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg3: short\n" + "hello: int tuple[2]\n" + "f: double\n" "\n" "func3default(A e, short arg3, Tuple hello) -> int\n" "\n" - "Parameters:\n" - " e: A *\n" - " arg3: short\n" - " hello: int tuple[2]\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg3: short\n" + "hello: int tuple[2]\n" "\n" "" ) @@ -185,35 +197,39 @@ check(A.func2static.__doc__, "\n" " func2static(e, arg2, hello, f=2) -> int\n" "\n" - " Parameters:\n" - " e: A *\n" - " arg2: short\n" - " hello: int tuple[2]\n" - " f: double\n" + " Parameters\n" + " ----------\n" + " e: A *\n" + " arg2: short\n" + " hello: int tuple[2]\n" + " f: double\n" "\n" " func2static(e, arg2, hello) -> int\n" "\n" - " Parameters:\n" - " e: A *\n" - " arg2: short\n" - " hello: int tuple[2]\n" + " Parameters\n" + " ----------\n" + " e: A *\n" + " arg2: short\n" + " hello: int tuple[2]\n" "\n" " ", "\n" "func2static(e, arg2, hello, f=2) -> int\n" "\n" - "Parameters:\n" - " e: A *\n" - " arg2: short\n" - " hello: int tuple[2]\n" - " f: double\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg2: short\n" + "hello: int tuple[2]\n" + "f: double\n" "\n" "func2static(e, arg2, hello) -> int\n" "\n" - "Parameters:\n" - " e: A *\n" - " arg2: short\n" - " hello: int tuple[2]\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg2: short\n" + "hello: int tuple[2]\n" "\n" "" ) @@ -221,35 +237,39 @@ check(A.func3static.__doc__, "\n" " func3static(A e, short arg2, Tuple hello, double f=2) -> int\n" "\n" - " Parameters:\n" - " e: A *\n" - " arg2: short\n" - " hello: int tuple[2]\n" - " f: double\n" + " Parameters\n" + " ----------\n" + " e: A *\n" + " arg2: short\n" + " hello: int tuple[2]\n" + " f: double\n" "\n" " func3static(A e, short arg2, Tuple hello) -> int\n" "\n" - " Parameters:\n" - " e: A *\n" - " arg2: short\n" - " hello: int tuple[2]\n" + " Parameters\n" + " ----------\n" + " e: A *\n" + " arg2: short\n" + " hello: int tuple[2]\n" "\n" " ", "\n" "func3static(A e, short arg2, Tuple hello, double f=2) -> int\n" "\n" - "Parameters:\n" - " e: A *\n" - " arg2: short\n" - " hello: int tuple[2]\n" - " f: double\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg2: short\n" + "hello: int tuple[2]\n" + "f: double\n" "\n" "func3static(A e, short arg2, Tuple hello) -> int\n" "\n" - "Parameters:\n" - " e: A *\n" - " arg2: short\n" - " hello: int tuple[2]\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg2: short\n" + "hello: int tuple[2]\n" "\n" "" ) @@ -268,8 +288,9 @@ if sys.version_info[0:2] > (2, 4): "\n" "A_variable_c_get(self) -> int\n" "\n" - "Parameters:\n" - " self: A *\n" + "Parameters\n" + "----------\n" + "self: A *\n" "\n", "A.variable_c" ) @@ -277,14 +298,15 @@ if sys.version_info[0:2] > (2, 4): "\n" "A_variable_d_get(A self) -> int\n" "\n" - "Parameters:\n" - " self: A *\n" + "Parameters\n" + "----------\n" + "self: A *\n" "\n", "A.variable_d" ) check(B.__doc__, - "Proxy of C++ B class", + "Proxy of C++ B class.", "::B" ) check(C.__init__.__doc__, "__init__(self, a, b, h) -> C", None, skip) @@ -294,10 +316,11 @@ check(E.__init__.__doc__, "\n" " __init__(self, a, b, h) -> E\n" "\n" - " Parameters:\n" - " a: special comment for parameter a\n" - " b: another special comment for parameter b\n" - " h: enum Hola\n" + " Parameters\n" + " ----------\n" + " a: special comment for parameter a\n" + " b: another special comment for parameter b\n" + " h: enum Hola\n" "\n" " ", None, skip ) @@ -305,10 +328,11 @@ check(F.__init__.__doc__, "\n" " __init__(F self, int a, int b, Hola h) -> F\n" "\n" - " Parameters:\n" - " a: special comment for parameter a\n" - " b: another special comment for parameter b\n" - " h: enum Hola\n" + " Parameters\n" + " ----------\n" + " a: special comment for parameter a\n" + " b: another special comment for parameter b\n" + " h: enum Hola\n" "\n" " ", None, skip ) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 5670d9581..362a40929 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -799,7 +799,11 @@ public: Swig_register_filebyname("python", f_shadow); if (mod_docstring && Len(mod_docstring)) { - Printv(f_shadow, "\"\"\"\n", mod_docstring, "\n\"\"\"\n\n", NIL); + const char *triple_double = "\"\"\""; + // follow PEP257 rules: https://www.python.org/dev/peps/pep-0257/ + // reported by pep257: https://github.com/GreenSteam/pep257 + const bool multi_line_ds = Strchr(mod_docstring, '\n'); + Printv(f_shadow, triple_double, multi_line_ds?"\n":"", mod_docstring, multi_line_ds?"\n":"", triple_double, "\n\n", NIL); Delete(mod_docstring); mod_docstring = NULL; } @@ -1795,8 +1799,9 @@ public: Append(doc, name); if (pdoc) { if (!pdocs) - pdocs = NewString("\nParameters:\n"); - Printf(pdocs, " %s\n", pdoc); + // numpydoc style: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt + pdocs = NewString("\nParameters\n----------\n"); + Printf(pdocs, "%s\n", pdoc); } // Write the function annotation if (func_annotation) @@ -1892,9 +1897,9 @@ public: Delete(rname); } else { if (CPlusPlus) { - Printf(doc, "Proxy of C++ %s class", real_classname); + Printf(doc, "Proxy of C++ %s class.", real_classname); } else { - Printf(doc, "Proxy of C %s struct", real_classname); + Printf(doc, "Proxy of C %s struct.", real_classname); } } } @@ -4329,7 +4334,7 @@ public: if (have_docstring(n)) { String *str = docstring(n, AUTODOC_CLASS, tab4); if (str && Len(str)) - Printv(f_shadow, tab4, str, "\n", NIL); + Printv(f_shadow, tab4, str, "\n\n", NIL); } if (!modern) { From 19a20c794bea67fb7e3530da362473c05cf87cad Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Aug 2015 22:23:31 +0100 Subject: [PATCH 063/732] Changes entry for numpydoc conforming docstrings. Changes entry for 92328a. Closes #383. --- CHANGES.current | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index f78f6bb48..49d59891c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,14 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-08-07: xantares + [Python] pep257 & numpydoc conforming docstrings: + - Mono-line module docsstring + - Rewrite autodoc parameters section in numpydoc style: + https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt + - One line summary should end with "." + - Adds a blank line after class docstring + 2015-08-05: vadz [Java] Make (char* STRING, size_t LENGTH) typemaps usable for strings of other types, e.g. "unsigned char*". From 8ac4a8147b2dc2c47c89f9ea3ded933ceee9372f Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Sat, 8 Aug 2015 11:32:55 -0700 Subject: [PATCH 064/732] capture the current behavior of perlprimtypes.swg is more detail --- .../test-suite/perl5/overload_simple_runme.pl | 39 ++++++++++++++++- Examples/test-suite/perl5/wrapmacro_runme.pl | 43 ++++++++++++++++++- 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/perl5/overload_simple_runme.pl b/Examples/test-suite/perl5/overload_simple_runme.pl index 624d428c6..57a585a22 100644 --- a/Examples/test-suite/perl5/overload_simple_runme.pl +++ b/Examples/test-suite/perl5/overload_simple_runme.pl @@ -2,7 +2,7 @@ use overload_simple; use vars qw/$DOWARN/; use strict; -use Test::More tests => 75; +use Test::More tests => 97; pass("loaded"); @@ -196,3 +196,40 @@ is(overload_simple::int_object(1), 1, "int_object(1)"); is(overload_simple::int_object(0), 0, "int_object(0)"); is(overload_simple::int_object(undef), 999, "int_object(Spam*)"); is(overload_simple::int_object($s), 999, "int_object(Spam*)"); + +# some of this section is duplication of above tests, but I want to see +# parity with the coverage in wrapmacro_runme.pl. + +sub check { + my($args, $want) = @_; + my($s, $rslt) = defined $want ? ($want, "bar:$want") : ('*boom*', undef); + is(eval("overload_simple::Spam::bar($args)"), $rslt, "bar($args) => $s"); +} + +# normal use patterns +check("11", 'int'); +check("11.0", 'double'); +check("'11'", 'char *'); +check("'11.0'", 'char *'); +check("-13", 'int'); +check("-13.0", 'double'); +check("'-13'", 'char *'); +check("'-13.0'", 'char *'); + +check("' '", 'char *'); +check("' 11 '", 'char *'); +# TypeError explosions +check("\\*STDIN", undef); +check("[]", undef); +check("{}", undef); +check("sub {}", undef); + +# regression cases +check("''", 'char *'); +check("' 11'", 'char *'); +check("' 11.0'", 'char *'); +check("' -11.0'", 'char *'); +check("\"11\x{0}\"", 'char *'); +check("\"\x{0}\"", 'char *'); +check("\"\x{9}11\x{0}this is not eleven.\"", 'char *'); +check("\"\x{9}11.0\x{0}this is also not eleven.\"", 'char *'); diff --git a/Examples/test-suite/perl5/wrapmacro_runme.pl b/Examples/test-suite/perl5/wrapmacro_runme.pl index 8e0154057..f2478b51b 100644 --- a/Examples/test-suite/perl5/wrapmacro_runme.pl +++ b/Examples/test-suite/perl5/wrapmacro_runme.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 27; BEGIN { use_ok('wrapmacro') } require_ok('wrapmacro'); @@ -12,3 +12,44 @@ my $b = -1; is(wrapmacro::maximum($a,$b), 2); is(wrapmacro::maximum($a/7.0, -$b*256), 256); is(wrapmacro::GUINT16_SWAP_LE_BE_CONSTANT(1), 256); + +# some of this section is duplication of above tests, but I want to see +# parity with the coverage in overload_simple_runme.pl. + +sub check { + my($args, $rslt) = @_; + my $s = defined $rslt ? $rslt : '*boom*'; + is(eval("wrapmacro::maximum($args)"), $rslt, "max($args) => $s"); +} + +# normal use patterns +check("0, 11", 11); +check("0, 11.0", 11); +check("0, '11'", 11); +check("0, '11.0'", 11); +check("11, -13", 11); +check("11, -13.0", 11); +{ local $TODO = 'strtoull() handles /^\s*-\d+$/ amusingly'; +check("11, '-13'", 11); +} +check("11, '-13.0'", 11); + +# TypeError explosions +check("0, ' '", undef); +check("0, ' 11 '", undef); +check("0, \\*STDIN", undef); +check("0, []", undef); +check("0, {}", undef); +check("0, sub {}", undef); + +# regression cases +{ local $TODO = 'strtol() and friends have edge cases we should guard against'; +check("-11, ''", undef); +check("0, ' 11'", undef); +check("0, ' 11.0'", undef); +check("-13, ' -11.0'", undef); +check("0, \"11\x{0}\"", undef); +check("0, \"\x{0}\"", undef); +check("0, \"\x{9}11\x{0}this is not eleven.\"", undef); +check("0, \"\x{9}11.0\x{0}this is also not eleven.\"", undef); +} From 9d1964014176e15411cc91ee160bde3f80c275a6 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Sat, 8 Aug 2015 11:33:32 -0700 Subject: [PATCH 065/732] check ranges in perlprimtype.swg more carefully to avoid clang warnings --- Lib/perl5/perlprimtypes.swg | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg index d7ac6f94e..6dd18b61f 100644 --- a/Lib/perl5/perlprimtypes.swg +++ b/Lib/perl5/perlprimtypes.swg @@ -37,7 +37,7 @@ SWIGINTERNINLINE SV * SWIG_From_dec(long)(long value) { SV *sv; - if (value >= IV_MIN && value <= IV_MAX) + if (IVSIZE >= sizeof(value) || (value >= IV_MIN && value <= IV_MAX)) sv = newSViv(value); else sv = newSVpvf("%ld", value); @@ -46,20 +46,22 @@ SWIG_From_dec(long)(long value) } %fragment(SWIG_AsVal_frag(long),"header", + fragment="", + fragment="", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(long)(SV *obj, long* val) { if (SvUOK(obj)) { UV v = SvUV(obj); - if (v <= LONG_MAX) { + if (UVSIZE < sizeof(*val) || v <= LONG_MAX) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else if (SvIOK(obj)) { IV v = SvIV(obj); - if (v >= LONG_MIN && v <= LONG_MAX) { + if (IVSIZE <= sizeof(*val) || (v >= LONG_MIN && v <= LONG_MAX)) { if(val) *val = v; return SWIG_OK; } @@ -102,7 +104,7 @@ SWIGINTERNINLINE SV * SWIG_From_dec(unsigned long)(unsigned long value) { SV *sv; - if (value <= UV_MAX) + if (UVSIZE >= sizeof(value) || value <= UV_MAX) sv = newSVuv(value); else sv = newSVpvf("%lu", value); @@ -111,20 +113,22 @@ SWIG_From_dec(unsigned long)(unsigned long value) } %fragment(SWIG_AsVal_frag(unsigned long),"header", + fragment="", + fragment="", fragment="SWIG_CanCastAsInteger") { SWIGINTERN int SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val) { if (SvUOK(obj)) { UV v = SvUV(obj); - if (v <= ULONG_MAX) { + if (UVSIZE <= sizeof(*val) || v <= ULONG_MAX) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else if (SvIOK(obj)) { IV v = SvIV(obj); - if (v >= 0 && v <= ULONG_MAX) { + if (v >= 0 && (IVSIZE <= sizeof(*val) || v <= ULONG_MAX)) { if (val) *val = v; return SWIG_OK; } @@ -164,13 +168,12 @@ SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val) %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), - fragment="", fragment="") { SWIGINTERNINLINE SV * SWIG_From_dec(long long)(long long value) { SV *sv; - if (value >= IV_MIN && value <= IV_MAX) + if (IVSIZE >= sizeof(value) || (value >= IV_MIN && value <= IV_MAX)) sv = newSViv((IV)(value)); else { //sv = newSVpvf("%lld", value); doesn't work in non 64bit Perl @@ -192,14 +195,15 @@ SWIG_AsVal_dec(long long)(SV *obj, long long *val) { if (SvUOK(obj)) { UV v = SvUV(obj); - if (v < LLONG_MAX) { + /* pretty sure this could allow v == LLONG MAX */ + if (UVSIZE < sizeof(*val) || v < LLONG_MAX) { if (val) *val = v; return SWIG_OK; } return SWIG_OverflowError; } else if (SvIOK(obj)) { IV v = SvIV(obj); - if (v >= LLONG_MIN && v <= LLONG_MAX) { + if (IVSIZE <= sizeof(*val) || (v >= LLONG_MIN && v <= LLONG_MAX)) { if (val) *val = v; return SWIG_OK; } @@ -241,13 +245,12 @@ SWIG_AsVal_dec(long long)(SV *obj, long long *val) %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), - fragment="", fragment="") { SWIGINTERNINLINE SV * SWIG_From_dec(unsigned long long)(unsigned long long value) { SV *sv; - if (value <= UV_MAX) + if (UVSIZE >= sizeof(value) || value <= UV_MAX) sv = newSVuv((UV)(value)); else { //sv = newSVpvf("%llu", value); doesn't work in non 64bit Perl @@ -267,11 +270,13 @@ SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(SV *obj, unsigned long long *val) { if (SvUOK(obj)) { + /* pretty sure this should be conditional on + * (UVSIZE <= sizeof(*val) || v <= ULLONG_MAX) */ if (val) *val = SvUV(obj); return SWIG_OK; } else if (SvIOK(obj)) { IV v = SvIV(obj); - if (v >= 0 && v <= ULLONG_MAX) { + if (v >= 0 && (IVSIZE <= sizeof(*val) || v <= ULLONG_MAX)) { if (val) *val = v; return SWIG_OK; } else { From 96e282b791ffbf9b9d6d3a1740945f14438f42cd Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Sat, 8 Aug 2015 13:21:24 -0700 Subject: [PATCH 066/732] update CHANGES.current --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 49d59891c..8c269f295 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-08-07: talby + [Perl] tidy -Wtautological-constant-out-of-range-compare warnings when building generated code under clang + 2015-08-07: xantares [Python] pep257 & numpydoc conforming docstrings: - Mono-line module docsstring From a941e5b605670a8b4686cec5f0d87562846552e2 Mon Sep 17 00:00:00 2001 From: Michael Schaller Date: Sat, 8 Aug 2015 19:44:41 +0200 Subject: [PATCH 067/732] [Go] Revert commit 5e88857 to undelete the 'callback' and 'extend' examples. The 'callback' and 'extend' examples were presumed to be obsoleted by the new 'director' example. The examples are helpful though to have similar examples across target languages and hence the commit @5e88857 which removed these examples got reverted. --- Examples/go/callback/Makefile | 16 ++++++ Examples/go/callback/callback.cxx | 4 ++ Examples/go/callback/example.h | 23 +++++++++ Examples/go/callback/example.i | 11 +++++ Examples/go/callback/index.html | 81 +++++++++++++++++++++++++++++++ Examples/go/callback/runme.go | 41 ++++++++++++++++ Examples/go/check.list | 2 + Examples/go/extend/Makefile | 16 ++++++ Examples/go/extend/example.h | 56 +++++++++++++++++++++ Examples/go/extend/example.i | 15 ++++++ Examples/go/extend/extend.cxx | 4 ++ Examples/go/extend/index.html | 27 +++++++++++ Examples/go/extend/runme.go | 76 +++++++++++++++++++++++++++++ Examples/go/index.html | 3 +- 14 files changed, 374 insertions(+), 1 deletion(-) create mode 100644 Examples/go/callback/Makefile create mode 100644 Examples/go/callback/callback.cxx create mode 100644 Examples/go/callback/example.h create mode 100644 Examples/go/callback/example.i create mode 100644 Examples/go/callback/index.html create mode 100644 Examples/go/callback/runme.go create mode 100644 Examples/go/extend/Makefile create mode 100644 Examples/go/extend/example.h create mode 100644 Examples/go/extend/example.i create mode 100644 Examples/go/extend/extend.cxx create mode 100644 Examples/go/extend/index.html create mode 100644 Examples/go/extend/runme.go diff --git a/Examples/go/callback/Makefile b/Examples/go/callback/Makefile new file mode 100644 index 000000000..bf5275f14 --- /dev/null +++ b/Examples/go/callback/Makefile @@ -0,0 +1,16 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = callback.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +check: build + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run + +build: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/callback/callback.cxx b/Examples/go/callback/callback.cxx new file mode 100644 index 000000000..450d75608 --- /dev/null +++ b/Examples/go/callback/callback.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/go/callback/example.h b/Examples/go/callback/example.h new file mode 100644 index 000000000..1a0e8c432 --- /dev/null +++ b/Examples/go/callback/example.h @@ -0,0 +1,23 @@ +/* File : example.h */ + +#include +#include + +class Callback { +public: + virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } + virtual void run() { std::cout << "Callback::run()" << std::endl; } +}; + + +class Caller { +private: + Callback *_callback; +public: + Caller(): _callback(0) {} + ~Caller() { delCallback(); } + void delCallback() { delete _callback; _callback = 0; } + void setCallback(Callback *cb) { delCallback(); _callback = cb; } + void call() { if (_callback) _callback->run(); } +}; + diff --git a/Examples/go/callback/example.i b/Examples/go/callback/example.i new file mode 100644 index 000000000..cf61ef9d2 --- /dev/null +++ b/Examples/go/callback/example.i @@ -0,0 +1,11 @@ +/* File : example.i */ +%module(directors="1") example +%{ +#include "example.h" +%} + +/* turn on director wrapping Callback */ +%feature("director") Callback; + +%include "example.h" + diff --git a/Examples/go/callback/index.html b/Examples/go/callback/index.html new file mode 100644 index 000000000..b053cf547 --- /dev/null +++ b/Examples/go/callback/index.html @@ -0,0 +1,81 @@ + + +SWIG:Examples:go:callback + + + + + +SWIG/Examples/go/callback/ +
    + +

    Implementing C++ callbacks in Go

    + +

    +This example illustrates how to use directors to implement C++ +callbacks in Go. +

    + +

    +Because Go and C++ use inheritance differently, you must call a +different function to create a class which uses callbacks. Instead of +calling the usual constructor function whose name is New +followed by the capitalized name of the class, you call a function +named NewDirector followed by the capitalized name of the +class. +

    + +

    +The first argument to the NewDirector function is an instance +of a type. The NewDirector function will return an interface +value as usual. However, when calling any method on the returned +value, the program will first check whether the value passed +to NewDirector implements that method. If it does, the +method will be called in Go. This is true whether the method is +called from Go code or C++ code. +

    + +

    +Note that the Go code will be called with just the Go value, not the +C++ value. If the Go code needs to call a C++ method on itself, you +need to get a copy of the C++ object. This is typically done as +follows: + +

    +
    +type Child struct { abi Parent }
    +func (p *Child) ChildMethod() {
    +	p.abi.ParentMethod()
    +}
    +func f() {
    +	p := &Child{nil}
    +	d := NewDirectorParent(p)
    +	p.abi = d
    +	...
    +}
    +
    +
    + +In other words, we first create the Go value. We pass that to +the NewDirector function to create the C++ value; this C++ +value will be created with an association to the Go value. We then +store the C++ value in the Go value, giving us the reverse +association. That permits us to call parent methods from the child. + +

    + +

    +To delete a director object, use the function DeleteDirector +followed by the capitalized name of the class. +

    + +

    +

    + +
    + + diff --git a/Examples/go/callback/runme.go b/Examples/go/callback/runme.go new file mode 100644 index 000000000..2eef77fdb --- /dev/null +++ b/Examples/go/callback/runme.go @@ -0,0 +1,41 @@ +package main + +import ( + . "./example" + "fmt" +) + +func main() { + fmt.Println("Adding and calling a normal C++ callback") + fmt.Println("----------------------------------------") + + caller := NewCaller() + callback := NewCallback() + + caller.SetCallback(callback) + caller.Call() + caller.DelCallback() + + callback = NewDirectorCallback(new(GoCallback)) + + fmt.Println() + fmt.Println("Adding and calling a Go callback") + fmt.Println("------------------------------------") + + caller.SetCallback(callback) + caller.Call() + caller.DelCallback() + + // Test that a double delete does not occur as the object has + // already been deleted from the C++ layer. + DeleteDirectorCallback(callback) + + fmt.Println() + fmt.Println("Go exit") +} + +type GoCallback struct{} + +func (p *GoCallback) Run() { + fmt.Println("GoCallback.Run") +} diff --git a/Examples/go/check.list b/Examples/go/check.list index 25322352a..b3f34b306 100644 --- a/Examples/go/check.list +++ b/Examples/go/check.list @@ -1,8 +1,10 @@ # see top-level Makefile.in +callback class constants director enum +extend funcptr multimap pointer diff --git a/Examples/go/extend/Makefile b/Examples/go/extend/Makefile new file mode 100644 index 000000000..290694210 --- /dev/null +++ b/Examples/go/extend/Makefile @@ -0,0 +1,16 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = extend.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +check: build + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run + +build: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/extend/example.h b/Examples/go/extend/example.h new file mode 100644 index 000000000..ca1aed28f --- /dev/null +++ b/Examples/go/extend/example.h @@ -0,0 +1,56 @@ +/* File : example.h */ + +#include +#include +#include +#include +#include + +class Employee { +private: + std::string name; +public: + Employee(const char* n): name(n) {} + virtual std::string getTitle() { return getPosition() + " " + getName(); } + virtual std::string getName() { return name; } + virtual std::string getPosition() const { return "Employee"; } + virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } +}; + + +class Manager: public Employee { +public: + Manager(const char* n): Employee(n) {} + virtual std::string getPosition() const { return "Manager"; } +}; + + +class EmployeeList { + std::vector list; +public: + EmployeeList() { + list.push_back(new Employee("Bob")); + list.push_back(new Employee("Jane")); + list.push_back(new Manager("Ted")); + } + void addEmployee(Employee *p) { + list.push_back(p); + std::cout << "New employee added. Current employees are:" << std::endl; + std::vector::iterator i; + for (i=list.begin(); i!=list.end(); i++) { + std::cout << " " << (*i)->getTitle() << std::endl; + } + } + const Employee *get_item(int i) { + return list[i]; + } + ~EmployeeList() { + std::vector::iterator i; + std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; + for (i=list.begin(); i!=list.end(); i++) { + delete *i; + } + std::cout << "~EmployeeList empty." << std::endl; + } +}; + diff --git a/Examples/go/extend/example.i b/Examples/go/extend/example.i new file mode 100644 index 000000000..c8ec32e09 --- /dev/null +++ b/Examples/go/extend/example.i @@ -0,0 +1,15 @@ +/* File : example.i */ +%module(directors="1") example +%{ +#include "example.h" +%} + +%include "std_vector.i" +%include "std_string.i" + +/* turn on director wrapping for Manager */ +%feature("director") Employee; +%feature("director") Manager; + +%include "example.h" + diff --git a/Examples/go/extend/extend.cxx b/Examples/go/extend/extend.cxx new file mode 100644 index 000000000..450d75608 --- /dev/null +++ b/Examples/go/extend/extend.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/go/extend/index.html b/Examples/go/extend/index.html new file mode 100644 index 000000000..471fa9cdc --- /dev/null +++ b/Examples/go/extend/index.html @@ -0,0 +1,27 @@ + + +SWIG:Examples:go:extend + + + + + +SWIG/Examples/go/extend/ +
    + +

    Extending a simple C++ class in Go

    + +

    +This example illustrates the extending of a C++ class with cross +language polymorphism. + +

    +

    + +
    + + diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go new file mode 100644 index 000000000..770e27802 --- /dev/null +++ b/Examples/go/extend/runme.go @@ -0,0 +1,76 @@ +// This file illustrates the cross language polymorphism using directors. + +package main + +import ( + . "./example" + "fmt" +) + +type CEO struct{} + +func (p *CEO) GetPosition() string { + return "CEO" +} + +func main() { + // Create an instance of CEO, a class derived from the Go + // proxy of the underlying C++ class. The calls to getName() + // and getPosition() are standard, the call to getTitle() uses + // the director wrappers to call CEO.getPosition(). + + e := NewDirectorManager(new(CEO), "Alice") + fmt.Println(e.GetName(), " is a ", e.GetPosition()) + fmt.Println("Just call her \"", e.GetTitle(), "\"") + fmt.Println("----------------------") + + // Create a new EmployeeList instance. This class does not + // have a C++ director wrapper, but can be used freely with + // other classes that do. + + list := NewEmployeeList() + + // EmployeeList owns its items, so we must surrender ownership + // of objects we add. + // e.DisownMemory() + list.AddEmployee(e) + fmt.Println("----------------------") + + // Now we access the first four items in list (three are C++ + // objects that EmployeeList's constructor adds, the last is + // our CEO). The virtual 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 Go. The call to GetPosition + // 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 + // CEO, but now Go thinks the object is an instance of class + // Employee. So the call passes through the Employee proxy + // class and on to the C wrappers and C++ director, eventually + // ending up back at the Java CEO implementation of + // getPosition(). The call to GetTitle() for item 3 runs the + // C++ Employee::getTitle() method, which in turn calls + // GetPosition(). This virtual method call passes down + // through the C++ director class to the Java implementation + // in CEO. All this routing takes place transparently. + + fmt.Println("(position, title) for items 0-3:") + + fmt.Println(" ", list.Get_item(0).GetPosition(), ", \"", list.Get_item(0).GetTitle(), "\"") + fmt.Println(" ", list.Get_item(1).GetPosition(), ", \"", list.Get_item(1).GetTitle(), "\"") + fmt.Println(" ", list.Get_item(2).GetPosition(), ", \"", list.Get_item(2).GetTitle(), "\"") + fmt.Println(" ", list.Get_item(3).GetPosition(), ", \"", list.Get_item(3).GetTitle(), "\"") + fmt.Println("----------------------") + + // Time to delete the EmployeeList, which will delete all the + // Employee* items it contains. The last item is our CEO, + // which gets destroyed as well. + DeleteEmployeeList(list) + fmt.Println("----------------------") + + // All done. + + fmt.Println("Go exit") +} diff --git a/Examples/go/index.html b/Examples/go/index.html index b7d7017d3..ed6a6b707 100644 --- a/Examples/go/index.html +++ b/Examples/go/index.html @@ -21,7 +21,8 @@ certain C declarations are turned into constants.
  • pointer. Simple pointer handling.
  • funcptr. Pointers to functions.
  • template. C++ templates. -
  • director. Example how to utilize the director feature. +
  • callback. C++ callbacks using directors. +
  • extend. Polymorphism using directors.

    Compilation Issues

    From 85037c3a33f4943afdcdaf0bc49b3f0433165f05 Mon Sep 17 00:00:00 2001 From: Michael Schaller Date: Sun, 9 Aug 2015 14:03:19 +0200 Subject: [PATCH 068/732] [Go] Updated the 'callback' and 'extend' examples to match the 'director' one. After the documentation update on how to utilize the director feature with commit @17b1c1c the 'callback' and 'extend' examples needed an update as well. --- Examples/go/callback/Makefile | 12 +++++- Examples/go/callback/example.h | 1 - Examples/go/callback/gocallback.go | 41 +++++++++++++++++++ Examples/go/callback/index.html | 64 ++++-------------------------- Examples/go/callback/runme.go | 16 ++------ Examples/go/director/Makefile | 11 ++--- Examples/go/extend/Makefile | 12 +++++- Examples/go/extend/ceo.go | 37 +++++++++++++++++ Examples/go/extend/example.h | 2 +- Examples/go/extend/index.html | 13 +++--- Examples/go/extend/runme.go | 20 +++------- Examples/go/index.html | 1 + 12 files changed, 130 insertions(+), 100 deletions(-) create mode 100644 Examples/go/callback/gocallback.go create mode 100644 Examples/go/extend/ceo.go diff --git a/Examples/go/callback/Makefile b/Examples/go/callback/Makefile index bf5275f14..7441e09bd 100644 --- a/Examples/go/callback/Makefile +++ b/Examples/go/callback/Makefile @@ -1,6 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = callback.cxx +GOSRCS = gocallback.go TARGET = example INTERFACE = example.i SWIGOPT = @@ -9,8 +10,15 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + if [ -n '$(SRCDIR)' ]; then \ + cp $(GOSRCS:%=$(SRCDIR)/%) .; \ + fi + @# Note: example.go gets generated by SWIG + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='example.go $(GOSRCS)' \ + SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: + if [ -n '$(SRCDIR)' ]; then \ + rm $(GOSRCS) || true; \ + fi $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/callback/example.h b/Examples/go/callback/example.h index 1a0e8c432..74ddad954 100644 --- a/Examples/go/callback/example.h +++ b/Examples/go/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/go/callback/gocallback.go b/Examples/go/callback/gocallback.go new file mode 100644 index 000000000..20fd0627a --- /dev/null +++ b/Examples/go/callback/gocallback.go @@ -0,0 +1,41 @@ +package example + +import ( + "fmt" +) + +type GoCallback interface { + Callback + deleteCallback() + IsGoCallback() +} + +type goCallback struct { + Callback +} + +func (p *goCallback) deleteCallback() { + DeleteDirectorCallback(p.Callback) +} + +func (p *goCallback) IsGoCallback() {} + +type overwrittenMethodsOnCallback struct { + p Callback +} + +func NewGoCallback() GoCallback { + om := &overwrittenMethodsOnCallback{} + p := NewDirectorCallback(om) + om.p = p + + return &goCallback{Callback: p} +} + +func DeleteGoCallback(p GoCallback) { + p.deleteCallback() +} + +func (p *goCallback) Run() { + fmt.Println("GoCallback.Run") +} diff --git a/Examples/go/callback/index.html b/Examples/go/callback/index.html index b053cf547..9a53065b0 100644 --- a/Examples/go/callback/index.html +++ b/Examples/go/callback/index.html @@ -12,67 +12,17 @@

    Implementing C++ callbacks in Go

    -This example illustrates how to use directors to implement C++ -callbacks in Go. -

    - -

    -Because Go and C++ use inheritance differently, you must call a -different function to create a class which uses callbacks. Instead of -calling the usual constructor function whose name is New -followed by the capitalized name of the class, you call a function -named NewDirector followed by the capitalized name of the -class. -

    - -

    -The first argument to the NewDirector function is an instance -of a type. The NewDirector function will return an interface -value as usual. However, when calling any method on the returned -value, the program will first check whether the value passed -to NewDirector implements that method. If it does, the -method will be called in Go. This is true whether the method is -called from Go code or C++ code. -

    - -

    -Note that the Go code will be called with just the Go value, not the -C++ value. If the Go code needs to call a C++ method on itself, you -need to get a copy of the C++ object. This is typically done as -follows: - -

    -
    -type Child struct { abi Parent }
    -func (p *Child) ChildMethod() {
    -	p.abi.ParentMethod()
    -}
    -func f() {
    -	p := &Child{nil}
    -	d := NewDirectorParent(p)
    -	p.abi = d
    -	...
    -}
    -
    -
    - -In other words, we first create the Go value. We pass that to -the NewDirector function to create the C++ value; this C++ -value will be created with an association to the Go value. We then -store the C++ value in the Go value, giving us the reverse -association. That permits us to call parent methods from the child. - -

    - -

    -To delete a director object, use the function DeleteDirector -followed by the capitalized name of the class. +This example illustrates how to use directors to implement C++ callbacks in Go. +See the Go Director +Classes documentation subsection for an in-depth explanation how to use the +director feature.

    diff --git a/Examples/go/callback/runme.go b/Examples/go/callback/runme.go index 2eef77fdb..03ab0c5e2 100644 --- a/Examples/go/callback/runme.go +++ b/Examples/go/callback/runme.go @@ -16,26 +16,18 @@ func main() { caller.Call() caller.DelCallback() - callback = NewDirectorCallback(new(GoCallback)) + go_callback := NewGoCallback() fmt.Println() fmt.Println("Adding and calling a Go callback") - fmt.Println("------------------------------------") + fmt.Println("--------------------------------") - caller.SetCallback(callback) + caller.SetCallback(go_callback) caller.Call() caller.DelCallback() - // Test that a double delete does not occur as the object has - // already been deleted from the C++ layer. - DeleteDirectorCallback(callback) + DeleteGoCallback(go_callback) fmt.Println() fmt.Println("Go exit") } - -type GoCallback struct{} - -func (p *GoCallback) Run() { - fmt.Println("GoCallback.Run") -} diff --git a/Examples/go/director/Makefile b/Examples/go/director/Makefile index 84de5855d..2e9e87b89 100644 --- a/Examples/go/director/Makefile +++ b/Examples/go/director/Makefile @@ -1,7 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig -CXXSRCS = -GOSRCS = example.go director.go # example.go gets generated by SWIG +CXXSRCS = +GOSRCS = director.go TARGET = example INTERFACE = example.i SWIGOPT = @@ -11,13 +11,14 @@ check: build build: if [ -n '$(SRCDIR)' ]; then \ - cp $(SRCDIR)/director.go .; \ + cp $(GOSRCS:%=$(SRCDIR)/%) .; \ fi - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='$(GOSRCS)' \ + @# Note: example.go gets generated by SWIG + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='example.go $(GOSRCS)' \ SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: if [ -n '$(SRCDIR)' ]; then \ - rm director.go || true; \ + rm $(GOSRCS) || true; \ fi $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/extend/Makefile b/Examples/go/extend/Makefile index 290694210..a9f2d8d7d 100644 --- a/Examples/go/extend/Makefile +++ b/Examples/go/extend/Makefile @@ -1,6 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = extend.cxx +GOSRCS = ceo.go TARGET = example INTERFACE = example.i SWIGOPT = @@ -9,8 +10,15 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + if [ -n '$(SRCDIR)' ]; then \ + cp $(GOSRCS:%=$(SRCDIR)/%) .; \ + fi + @# Note: example.go gets generated by SWIG + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='example.go $(GOSRCS)' \ + SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: + if [ -n '$(SRCDIR)' ]; then \ + rm $(GOSRCS) || true; \ + fi $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/extend/ceo.go b/Examples/go/extend/ceo.go new file mode 100644 index 000000000..8f00c92f2 --- /dev/null +++ b/Examples/go/extend/ceo.go @@ -0,0 +1,37 @@ +package example + +type CEO interface { + Manager + deleteManager() + IsCEO() +} + +type ceo struct { + Manager +} + +func (p *ceo) deleteManager() { + DeleteDirectorManager(p.Manager) +} + +func (p *ceo) IsCEO() {} + +type overwrittenMethodsOnManager struct { + p Manager +} + +func NewCEO(name string) CEO { + om := &overwrittenMethodsOnManager{} + p := NewDirectorManager(om, name) + om.p = p + + return &ceo{Manager: p} +} + +func DeleteCEO(p CEO) { + p.deleteManager() +} + +func (p *ceo) GetPosition() string { + return "CEO" +} diff --git a/Examples/go/extend/example.h b/Examples/go/extend/example.h index ca1aed28f..0c3b721bd 100644 --- a/Examples/go/extend/example.h +++ b/Examples/go/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++) { diff --git a/Examples/go/extend/index.html b/Examples/go/extend/index.html index 471fa9cdc..31788b2aa 100644 --- a/Examples/go/extend/index.html +++ b/Examples/go/extend/index.html @@ -12,13 +12,16 @@

    Extending a simple C++ class in Go

    -This example illustrates the extending of a C++ class with cross -language polymorphism. - +This example illustrates how to inherit from a C++ class in Go. +See the Go Director +Classes documentation subsection for an in-depth explanation how to use the +director feature.

    +

      -
    • example.h. Header file containing some enums. -
    • example.i. Interface file. +
    • ceo.go. Go source with the definition of the CEO class. +
    • example.h. Header with the definition of the Employee, Manager and EmployeeList classes. +
    • example.i. SWIG interface file.
    • runme.go. Sample Go program.
    diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go index 770e27802..a56968937 100644 --- a/Examples/go/extend/runme.go +++ b/Examples/go/extend/runme.go @@ -7,19 +7,12 @@ import ( "fmt" ) -type CEO struct{} - -func (p *CEO) GetPosition() string { - return "CEO" -} - func main() { // Create an instance of CEO, a class derived from the Go // proxy of the underlying C++ class. The calls to getName() // and getPosition() are standard, the call to getTitle() uses // the director wrappers to call CEO.getPosition(). - - e := NewDirectorManager(new(CEO), "Alice") + e := NewCEO("Alice") fmt.Println(e.GetName(), " is a ", e.GetPosition()) fmt.Println("Just call her \"", e.GetTitle(), "\"") fmt.Println("----------------------") @@ -27,7 +20,6 @@ func main() { // 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 := NewEmployeeList() // EmployeeList owns its items, so we must surrender ownership @@ -49,15 +41,13 @@ func main() { // CEO, but now Go thinks the object is an instance of class // Employee. So the call passes through the Employee proxy // class and on to the C wrappers and C++ director, eventually - // ending up back at the Java CEO implementation of + // ending up back at the Go CEO implementation of // getPosition(). The call to GetTitle() for item 3 runs the // C++ Employee::getTitle() method, which in turn calls // GetPosition(). This virtual method call passes down - // through the C++ director class to the Java implementation + // through the C++ director class to the Go implementation // in CEO. All this routing takes place transparently. - fmt.Println("(position, title) for items 0-3:") - fmt.Println(" ", list.Get_item(0).GetPosition(), ", \"", list.Get_item(0).GetTitle(), "\"") fmt.Println(" ", list.Get_item(1).GetPosition(), ", \"", list.Get_item(1).GetTitle(), "\"") fmt.Println(" ", list.Get_item(2).GetPosition(), ", \"", list.Get_item(2).GetTitle(), "\"") @@ -66,11 +56,11 @@ func main() { // Time to delete the EmployeeList, which will delete all the // Employee* items it contains. The last item is our CEO, - // which gets destroyed as well. + // which gets destroyed as well and hence there is no need to + // call DeleteCEO. DeleteEmployeeList(list) fmt.Println("----------------------") // All done. - fmt.Println("Go exit") } diff --git a/Examples/go/index.html b/Examples/go/index.html index ed6a6b707..467f4ecb7 100644 --- a/Examples/go/index.html +++ b/Examples/go/index.html @@ -23,6 +23,7 @@ certain C declarations are turned into constants.
  • template. C++ templates.
  • callback. C++ callbacks using directors.
  • extend. Polymorphism using directors. +
  • director. Example how to utilize the director feature.

    Compilation Issues

    From 608ef60ecf7774533b3344622be5b8df64bf133e Mon Sep 17 00:00:00 2001 From: Michael Schaller Date: Sun, 9 Aug 2015 14:32:23 +0200 Subject: [PATCH 069/732] [Go] Renamed 'FooBarAbs' to 'FooBarAbstract' in the documentation and examples. --- Doc/Manual/Go.html | 196 ++++++++++++++++--------------- Examples/go/director/director.go | 74 ++++++------ Examples/go/director/director.h | 10 +- Examples/go/director/example.i | 2 +- Examples/go/director/index.html | 2 +- 5 files changed, 144 insertions(+), 140 deletions(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index c008ef22c..ca12410ad 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -606,22 +606,22 @@ completely to avoid common pitfalls with directors in Go.

    23.4.7.1 Example C++ code

    -The step by step guide is based on two example C++ classes. FooBarAbs is an -abstract C++ class and the FooBarCpp class inherits from it. This guide +The step by step guide is based on two example C++ classes. FooBarAbstract is +an abstract C++ class and the FooBarCpp class inherits from it. This guide explains how to implement a FooBarGo class similar to the FooBarCpp class.

    -FooBarAbs abstract C++ class: +FooBarAbstract abstract C++ class:

    -class FooBarAbs
    +class FooBarAbstract
     {
     public:
    -	FooBarAbs() {};
    -	virtual ~FooBarAbs() {};
    +	FooBarAbstract() {};
    +	virtual ~FooBarAbstract() {};
     
     	std::string FooBar() {
     		return this->Foo() + ", " + this->Bar();
    @@ -643,11 +643,11 @@ protected:
     
     
    -class FooBarCpp : public FooBarAbs
    +class FooBarCpp : public FooBarAbstract
     {
     protected:
     	virtual std::string Foo() {
    -		return "C++ " + FooBarAbs::Foo();
    +		return "C++ " + FooBarAbstract::Foo();
     	}
     
     	virtual std::string Bar() {
    @@ -691,14 +691,14 @@ directive, like this:
     
     

    Second, you must use the %feature("director") directive to tell SWIG which -classes should get directors. In the example the FooBarAbs class needs the +classes should get directors. In the example the FooBarAbstract class needs the director feature enabled so that the FooBarGo class can inherit from it, like this:

    -%feature("director") FooBarAbs;
    +%feature("director") FooBarAbstract;
     
    @@ -782,21 +782,21 @@ As an example see part of the FooBarGo class:
    -type overwrittenMethodsOnFooBarAbs struct {
    -	fb FooBarAbs
    +type overwrittenMethodsOnFooBarAbstract struct {
    +	fb FooBarAbstract
     }
     
    -func (om *overwrittenMethodsOnFooBarAbs) Foo() string {
    +func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
     	...
     }
     
    -func (om *overwrittenMethodsOnFooBarAbs) Bar() string {
    +func (om *overwrittenMethodsOnFooBarAbstract) Bar() string {
     	...
     }
     
     func NewFooBarGo() FooBarGo {
    -	om := &overwrittenMethodsOnFooBarAbs{}
    -	fb := NewDirectorFooBarAbs(om)
    +	om := &overwrittenMethodsOnFooBarAbstract{}
    +	fb := NewDirectorFooBarAbstract(om)
     	om.fb = fb
     	...
     }
    @@ -806,25 +806,25 @@ func NewFooBarGo() FooBarGo {
     

    The complete example, including the FooBarGoo class implementation, can be found in the end of the guide. In -this part of the example the virtual methods FooBarAbs::Foo and -FooBarAbs::Bar have been overwritten with Go methods similarly to how -the FooBarAbs virtual methods are overwritten by the FooBarCpp -class. +this part of the example the virtual methods FooBarAbstract::Foo and +FooBarAbstract::Bar have been overwritten with Go methods similarly to +how the FooBarAbstract virtual methods are overwritten by the +FooBarCpp class.

    The DirectorInterface in the example is implemented by the -overwrittenMethodsOnFooBarAbs Go struct type. A pointer to a -overwrittenMethodsOnFooBarAbs struct instance will be given to the -NewDirectorFooBarAbs constructor function. The constructor return -value implements the FooBarAbs interface. -overwrittenMethodsOnFooBarAbs could in theory be any Go type but in -practice a struct is used as it typically contains at least a value of the +overwrittenMethodsOnFooBarAbstract Go struct type. A pointer to a +overwrittenMethodsOnFooBarAbstract struct instance will be given to the +NewDirectorFooBarAbstract constructor function. The constructor return +value implements the FooBarAbstract interface. +overwrittenMethodsOnFooBarAbstract could in theory be any Go type but +in practice a struct is used as it typically contains at least a value of the C++ class interface so that the overwritten methods can use the rest of the C++ class. If the FooBarGo class would receive additional constructor arguments then these would also typically be stored in the -overwrittenMethodsOnFooBarAbs struct so that they can be used by the -Go methods. +overwrittenMethodsOnFooBarAbstract struct so that they can be used by +the Go methods.

    @@ -840,7 +840,7 @@ the method in the base class. This is also the case for the
     virtual std::string Foo() {
    -	return "C++ " + FooBarAbs::Foo();
    +	return "C++ " + FooBarAbstract::Foo();
     }
     
    @@ -853,8 +853,8 @@ The FooBarGo.Foo implementation in the example looks like this:
    -func (om *overwrittenMethodsOnFooBarAbs) Foo() string {
    -	return "Go " + DirectorFooBarAbsFoo(om.fb)
    +func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
    +	return "Go " + DirectorFooBarAbstractFoo(om.fb)
     }
     
    @@ -887,31 +887,31 @@ this:
     type FooBarGo interface {
    -	FooBarAbs
    -	deleteFooBarAbs()
    +	FooBarAbstract
    +	deleteFooBarAbstract()
     	IsFooBarGo()
     }
     
     type fooBarGo struct {
    -	FooBarAbs
    +	FooBarAbstract
     }
     
    -func (fbgs *fooBarGo) deleteFooBarAbs() {
    -	DeleteDirectorFooBarAbs(fbgs.FooBarAbs)
    +func (fbgs *fooBarGo) deleteFooBarAbstract() {
    +	DeleteDirectorFooBarAbstract(fbgs.FooBarAbstract)
     }
     
     func (fbgs *fooBarGo) IsFooBarGo() {}
     
     func NewFooBarGo() FooBarGo {
    -	om := &overwrittenMethodsOnFooBarAbs{}
    -	fb := NewDirectorFooBarAbs(om)
    +	om := &overwrittenMethodsOnFooBarAbstract{}
    +	fb := NewDirectorFooBarAbstract(om)
     	om.fb = fb
     
    -	return &fooBarGo{FooBarAbs: fb}
    +	return &fooBarGo{FooBarAbstract: fb}
     }
     
     func DeleteFooBarGo(fbg FooBarGo) {
    -	fbg.deleteFooBarAbs()
    +	fbg.deleteFooBarAbstract()
     }
     
    @@ -921,12 +921,12 @@ func DeleteFooBarGo(fbg FooBarGo) { The complete example, including the FooBarGoo class implementation, can be found in the end of the guide. In this part of the example the private fooBarGo struct embeds -FooBarAbs which lets the fooBarGo Go type "inherit" all the -methods of the FooBarAbs C++ class by means of embedding. The public -FooBarGo interface type includes the FooBarAbs interface and -hence FooBarGo can be used as a drop in replacement for -FooBarAbs while the reverse isn't possible and would raise a compile -time error. Furthemore the constructor and destructor functions +FooBarAbstract which lets the fooBarGo Go type "inherit" all the +methods of the FooBarAbstract C++ class by means of embedding. The +public FooBarGo interface type includes the FooBarAbstract +interface and hence FooBarGo can be used as a drop in replacement for +FooBarAbstract while the reverse isn't possible and would raise a +compile time error. Furthemore the constructor and destructor functions NewFooBarGo and DeleteFooBarGo take care of all the director specifics and to the user the class appears as any other SWIG wrapped C++ class. @@ -946,13 +946,13 @@ in the FooBarGo class is here:
    -type overwrittenMethodsOnFooBarAbs struct {
    -	fb FooBarAbs
    +type overwrittenMethodsOnFooBarAbstract struct {
    +	fb FooBarAbstract
     }
     
     func NewFooBarGo() FooBarGo {
    -	om := &overwrittenMethodsOnFooBarAbs{}
    -	fb := NewDirectorFooBarAbs(om) // fb.v = om
    +	om := &overwrittenMethodsOnFooBarAbstract{}
    +	fb := NewDirectorFooBarAbstract(om) // fb.v = om
     	om.fb = fb // Backlink causes cycle as fb.v = om!
     	...
     }
    @@ -963,27 +963,27 @@ func NewFooBarGo() FooBarGo {
     In order to be able to use runtime.SetFinalizer nevertheless the
     finalizer needs to be set on something that isn't in a cycle and that references
     the director object instance.  In the FooBarGo class example the 
    -FooBarAbs director instance can be automatically deleted by setting the
    -finalizer on fooBarGo:
    +FooBarAbstract director instance can be automatically deleted by setting
    +the finalizer on fooBarGo:
     

     type fooBarGo struct {
    -	FooBarAbs
    +	FooBarAbstract
     }
     
    -type overwrittenMethodsOnFooBarAbs struct {
    -	fb FooBarAbs
    +type overwrittenMethodsOnFooBarAbstract struct {
    +	fb FooBarAbstract
     }
     
     func NewFooBarGo() FooBarGo {
    -	om := &overwrittenMethodsOnFooBarAbs{}
    -	fb := NewDirectorFooBarAbs(om)
    +	om := &overwrittenMethodsOnFooBarAbstract{}
    +	fb := NewDirectorFooBarAbstract(om)
     	om.fb = fb // Backlink causes cycle as fb.v = om!
     
    -	fbgs := &fooBarGo{FooBarAbs: fb}
    -	runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbs)
    +	fbgs := &fooBarGo{FooBarAbstract: fb}
    +	runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract)
     	return fbgs
     }
     
    @@ -1007,73 +1007,75 @@ The complete and annotated FooBarGo class looks like this:
    -// FooBarGo is a superset of FooBarAbs and hence FooBarGo can be used as a drop
    -// in replacement for FooBarAbs but the reverse causes a compile time error.
    +// FooBarGo is a superset of FooBarAbstract and hence FooBarGo can be used as a
    +// drop in replacement for FooBarAbstract but the reverse causes a compile time
    +// error.
     type FooBarGo interface {
    -	FooBarAbs
    -	deleteFooBarAbs()
    +	FooBarAbstract
    +	deleteFooBarAbstract()
     	IsFooBarGo()
     }
     
    -// Via embedding fooBarGo "inherits" all methods of FooBarAbs.
    +// Via embedding fooBarGo "inherits" all methods of FooBarAbstract.
     type fooBarGo struct {
    -	FooBarAbs
    +	FooBarAbstract
     }
     
    -func (fbgs *fooBarGo) deleteFooBarAbs() {
    -	DeleteDirectorFooBarAbs(fbgs.FooBarAbs)
    +func (fbgs *fooBarGo) deleteFooBarAbstract() {
    +	DeleteDirectorFooBarAbstract(fbgs.FooBarAbstract)
     }
     
    -// The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbs.
    +// The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbstract.
     // This is also how the class hierarchy gets represented by the SWIG generated
    -// wrapper code.  For an instance FooBarCpp has the IsFooBarAbs and IsFooBarCpp
    -// methods.
    +// wrapper code.  For an instance FooBarCpp has the IsFooBarAbstract and
    +// IsFooBarCpp methods.
     func (fbgs *fooBarGo) IsFooBarGo() {}
     
     // Go type that defines the DirectorInterface. It contains the Foo and Bar
    -// methods that overwrite the respective virtual C++ methods on FooBarAbs.
    -type overwrittenMethodsOnFooBarAbs struct {
    -	// Backlink to FooBarAbs so that the rest of the class can be used by the
    -	// overridden methods.
    -	fb FooBarAbs
    +// methods that overwrite the respective virtual C++ methods on FooBarAbstract.
    +type overwrittenMethodsOnFooBarAbstract struct {
    +	// Backlink to FooBarAbstract so that the rest of the class can be used by
    +	// the overridden methods.
    +	fb FooBarAbstract
     
     	// If additional constructor arguments have been given they are typically
     	// stored here so that the overriden methods can use them.
     }
     
    -func (om *overwrittenMethodsOnFooBarAbs) Foo() string {
    -	// DirectorFooBarAbsFoo calls the base method FooBarAbs::Foo.
    -	return "Go " + DirectorFooBarAbsFoo(om.fb)
    +func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
    +	// DirectorFooBarAbstractFoo calls the base method FooBarAbstract::Foo.
    +	return "Go " + DirectorFooBarAbstractFoo(om.fb)
     }
     
    -func (om *overwrittenMethodsOnFooBarAbs) Bar() string {
    +func (om *overwrittenMethodsOnFooBarAbstract) Bar() string {
     	return "Go Bar"
     }
     
     func NewFooBarGo() FooBarGo {
    -	// Instantiate FooBarAbs with selected methods overridden.  The methods that
    -	// will be overwritten are defined on overwrittenMethodsOnFooBarAbs and have
    -	// a compatible signature to the respective virtual C++ methods.
    -	// Furthermore additional constructor arguments will be typically stored in
    -	// the overwrittenMethodsOnFooBarAbs struct.
    -	om := &overwrittenMethodsOnFooBarAbs{}
    -	fb := NewDirectorFooBarAbs(om)
    +	// Instantiate FooBarAbstract with selected methods overridden.  The methods
    +	// that will be overwritten are defined on
    +	// overwrittenMethodsOnFooBarAbstract and have a compatible signature to the
    +	// respective virtual C++ methods. Furthermore additional constructor
    +	// arguments will be typically stored in the
    +	// overwrittenMethodsOnFooBarAbstract struct.
    +	om := &overwrittenMethodsOnFooBarAbstract{}
    +	fb := NewDirectorFooBarAbstract(om)
     	om.fb = fb // Backlink causes cycle as fb.v = om!
     
    -	fbgs := &fooBarGo{FooBarAbs: fb}
    -	// The memory of the FooBarAbs director object instance can be automatically
    -	// freed once the FooBarGo instance is garbage collected by uncommenting the
    -	// following line.  Please make sure to understand the runtime.SetFinalizer
    -	// specific gotchas before doing this.  Furthemore DeleteFooBarGo should be
    -	// deleted if a finalizer is in use or the fooBarGo struct needs additional
    -	// data to prevent double deletion.
    -	// runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbs)
    +	fbgs := &fooBarGo{FooBarAbstract: fb}
    +	// The memory of the FooBarAbstract director object instance can be
    +	// automatically freed once the FooBarGo instance is garbage collected by
    +	// uncommenting the following line.  Please make sure to understand the
    +	// runtime.SetFinalizer specific gotchas before doing this.  Furthemore
    +	// DeleteFooBarGo should be deleted if a finalizer is in use or the fooBarGo
    +	// struct needs additional data to prevent double deletion.
    +	// runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract)
     	return fbgs
     }
     
     // Recommended to be removed if runtime.SetFinalizer is in use.
     func DeleteFooBarGo(fbg FooBarGo) {
    -	fbg.deleteFooBarAbs()
    +	fbg.deleteFooBarAbstract()
     }
     
    @@ -1094,11 +1096,11 @@ For comparison the FooBarCpp class looks like this:
    -class FooBarCpp : public FooBarAbs
    +class FooBarCpp : public FooBarAbstract
     {
     protected:
     	virtual std::string Foo() {
    -		return "C++ " + FooBarAbs::Foo();
    +		return "C++ " + FooBarAbstract::Foo();
     	}
     
     	virtual std::string Bar() {
    diff --git a/Examples/go/director/director.go b/Examples/go/director/director.go
    index a5078fe58..4f99bfc6d 100644
    --- a/Examples/go/director/director.go
    +++ b/Examples/go/director/director.go
    @@ -1,70 +1,72 @@
     package example
     
    -// FooBarGo is a superset of FooBarAbs and hence FooBarGo can be used as a drop
    -// in replacement for FooBarAbs but the reverse causes a compile time error.
    +// FooBarGo is a superset of FooBarAbstract and hence FooBarGo can be used as a
    +// drop in replacement for FooBarAbstract but the reverse causes a compile time
    +// error.
     type FooBarGo interface {
    -	FooBarAbs
    -	deleteFooBarAbs()
    +	FooBarAbstract
    +	deleteFooBarAbstract()
     	IsFooBarGo()
     }
     
    -// Via embedding fooBarGo "inherits" all methods of FooBarAbs.
    +// Via embedding fooBarGo "inherits" all methods of FooBarAbstract.
     type fooBarGo struct {
    -	FooBarAbs
    +	FooBarAbstract
     }
     
    -func (fbgs *fooBarGo) deleteFooBarAbs() {
    -	DeleteDirectorFooBarAbs(fbgs.FooBarAbs)
    +func (fbgs *fooBarGo) deleteFooBarAbstract() {
    +	DeleteDirectorFooBarAbstract(fbgs.FooBarAbstract)
     }
     
    -// The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbs.
    +// The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbstract.
     // This is also how the class hierarchy gets represented by the SWIG generated
    -// wrapper code.  For an instance FooBarCpp has the IsFooBarAbs and IsFooBarCpp
    -// methods.
    +// wrapper code.  For an instance FooBarCpp has the IsFooBarAbstract and
    +// IsFooBarCpp methods.
     func (fbgs *fooBarGo) IsFooBarGo() {}
     
     // Go type that defines the DirectorInterface. It contains the Foo and Bar
    -// methods that overwrite the respective virtual C++ methods on FooBarAbs.
    -type overwrittenMethodsOnFooBarAbs struct {
    -	// Backlink to FooBarAbs so that the rest of the class can be used by the
    -	// overridden methods.
    -	fb FooBarAbs
    +// methods that overwrite the respective virtual C++ methods on FooBarAbstract.
    +type overwrittenMethodsOnFooBarAbstract struct {
    +	// Backlink to FooBarAbstract so that the rest of the class can be used by
    +	// the overridden methods.
    +	fb FooBarAbstract
     
     	// If additional constructor arguments have been given they are typically
     	// stored here so that the overriden methods can use them.
     }
     
    -func (om *overwrittenMethodsOnFooBarAbs) Foo() string {
    -	// DirectorFooBarAbsFoo calls the base method FooBarAbs::Foo.
    -	return "Go " + DirectorFooBarAbsFoo(om.fb)
    +func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
    +	// DirectorFooBarAbstractFoo calls the base method FooBarAbstract::Foo.
    +	return "Go " + DirectorFooBarAbstractFoo(om.fb)
     }
     
    -func (om *overwrittenMethodsOnFooBarAbs) Bar() string {
    +func (om *overwrittenMethodsOnFooBarAbstract) Bar() string {
     	return "Go Bar"
     }
     
     func NewFooBarGo() FooBarGo {
    -	// Instantiate FooBarAbs with selected methods overridden.  The methods that
    -	// will be overwritten are defined on overwrittenMethodsOnFooBarAbs and have
    -	// a compatible signature to the respective virtual C++ methods.
    -	// Furthermore additional constructor arguments will be typically stored in
    -	// the overwrittenMethodsOnFooBarAbs struct.
    -	om := &overwrittenMethodsOnFooBarAbs{}
    -	fb := NewDirectorFooBarAbs(om)
    +	// Instantiate FooBarAbstract with selected methods overridden.  The methods
    +	// that will be overwritten are defined on
    +	// overwrittenMethodsOnFooBarAbstract and have a compatible signature to the
    +	// respective virtual C++ methods. Furthermore additional constructor
    +	// arguments will be typically stored in the
    +	// overwrittenMethodsOnFooBarAbstract struct.
    +	om := &overwrittenMethodsOnFooBarAbstract{}
    +	fb := NewDirectorFooBarAbstract(om)
     	om.fb = fb // Backlink causes cycle as fb.v = om!
     
    -	fbgs := &fooBarGo{FooBarAbs: fb}
    -	// The memory of the FooBarAbs director object instance can be automatically
    -	// freed once the FooBarGo instance is garbage collected by uncommenting the
    -	// following line.  Please make sure to understand the runtime.SetFinalizer
    -	// specific gotchas before doing this.  Furthemore DeleteFooBarGo should be
    -	// deleted if a finalizer is in use or the fooBarGo struct needs additional
    -	// data to prevent double deletion.
    -	// runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbs)
    +	fbgs := &fooBarGo{FooBarAbstract: fb}
    +	// The memory of the FooBarAbstract director object instance can be
    +	// automatically freed once the FooBarGo instance is garbage collected by
    +	// uncommenting the following line.  Please make sure to understand the
    +	// runtime.SetFinalizer specific gotchas before doing this.  Furthemore
    +	// DeleteFooBarGo should be deleted if a finalizer is in use or the fooBarGo
    +	// struct needs additional data to prevent double deletion.
    +	// runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract)
     	return fbgs
     }
     
     // Recommended to be removed if runtime.SetFinalizer is in use.
     func DeleteFooBarGo(fbg FooBarGo) {
    -	fbg.deleteFooBarAbs()
    +	fbg.deleteFooBarAbstract()
     }
    diff --git a/Examples/go/director/director.h b/Examples/go/director/director.h
    index e08c11594..339a9adcd 100644
    --- a/Examples/go/director/director.h
    +++ b/Examples/go/director/director.h
    @@ -6,11 +6,11 @@
     #include 
     
     
    -class FooBarAbs
    +class FooBarAbstract
     {
     public:
    -	FooBarAbs() {};
    -	virtual ~FooBarAbs() {};
    +	FooBarAbstract() {};
    +	virtual ~FooBarAbstract() {};
     
     	std::string FooBar() {
     		return this->Foo() + ", " + this->Bar();
    @@ -25,11 +25,11 @@ protected:
     };
     
     
    -class FooBarCpp : public FooBarAbs
    +class FooBarCpp : public FooBarAbstract
     {
     protected:
     	virtual std::string Foo() {
    -		return "C++ " + FooBarAbs::Foo();
    +		return "C++ " + FooBarAbstract::Foo();
     	}
     
     	virtual std::string Bar() {
    diff --git a/Examples/go/director/example.i b/Examples/go/director/example.i
    index b56998e6d..e832bd8c6 100644
    --- a/Examples/go/director/example.i
    +++ b/Examples/go/director/example.i
    @@ -7,5 +7,5 @@
     #include "director.h"
     %}
     
    -%feature("director") FooBarAbs;
    +%feature("director") FooBarAbstract;
     %include "director.h"
    diff --git a/Examples/go/director/index.html b/Examples/go/director/index.html
    index d1d5a74bc..b93e780e5 100644
    --- a/Examples/go/director/index.html
    +++ b/Examples/go/director/index.html
    @@ -18,7 +18,7 @@ Classes documentation subsection for an explanation of this example.
     

    • director.go. Go source with the definition of the FooBarGo class. -
    • director.h. Header with the definition of the FooBarAbs and FooBarCpp classes. +
    • director.h. Header with the definition of the FooBarAbstract and FooBarCpp classes.
    • example.i. SWIG interface file.
    • runme.go. Sample Go program.
    From c8b15f64a000c09d6ab68802d55d8eec1705e5ff Mon Sep 17 00:00:00 2001 From: David Xu Date: Sun, 9 Aug 2015 13:56:13 -0400 Subject: [PATCH 070/732] Add user documentation to the export package extension. --- Doc/Manual/Lisp.html | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index 0b8d47846..d2bf316a4 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -284,9 +284,11 @@ Let's edit the interface file such that the C type "div_t*" is changed %feature("export"); %feature("inline") lispsort_double; - %feature("intern_function", "my-lispify") lispsort_double; +%feature("export", package="'some-other-package") lispsort_double; + %rename func123 renamed_cool_func; + %ignore "pointer_func"; %include "test.h" @@ -310,12 +312,13 @@ The feature intern_function ensures that all C names are lispsort_double;, here we are using an additional feature which allows us to use our lispify function.

    -

    The export feature allows us to export the symbols. The inline - feature declaims the declared function as inline. The rename - directive allows us to change the name(it is useful when - generating C wrapper code for handling overloaded - functions). The ignore directive ignores a certain - declaration. +

    The export feature allows us to export the symbols. If + the package argument is given, then the symbol will be exported to + the specified Lisp package. The inline feature declaims the + declared function as inline. The rename directive allows us to + change the name(it is useful when generating C wrapper code for handling + overloaded functions). The ignore directive ignores a certain + declaration.

    There are several other things which are possible, to see some example of usage of SWIG look at the Lispbuilder and wxCL @@ -381,7 +384,7 @@ The feature intern_function ensures that all C names are (n :int) (array :pointer)) -(cl:export '#.(my-lispify "lispsort_double" 'function)) +(cl:export '#.(my-lispify "lispsort_double" 'function) 'some-other-package) (cffi:defcenum #.(swig-lispify "color" 'enumname) #.(swig-lispify "RED" 'enumvalue :keyword) From da1c6c60d38d0b6206200247056a2a36ac227b74 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Wed, 17 Jun 2015 20:14:40 +1000 Subject: [PATCH 071/732] This is a modification to support use of tricky enumerations in R. It includes the addition of a _runme for an existing test - preproc_constants that was previously not run. That tests includes a preprocessor based setting of an enumeration which is ignored by the existing r enumeration infrastructure. The new version correctly reports the enumeration value as 4 - previous versions set it to 0. Traditional enumerations are unchanged. The approach used to deal with these enumerations is similar to that of other languages, and requires a call to a C function at runtime to return the enumeration value. The previous approach figured out the values statically and this is still used where possible. The need for a runtime call leads to changes in when swig code is used in packages - see below. One test that previously passed now fails - namely the R sourcing of preproc_constants.R, as the enumeration code requires the shared library, which isn't loaded by that script. There is also a modification to the way the R _runme.R files are used. The call to R CMD BATCH now includes a --args option that indicates the source folder for the unittest.R file, and the first couple of lines of the _runme.R files deal with correctly locating this. Out of source tests now run correctly. This work was motivated by problems generating the SimpleITK binding, specifically with some of the more complex enumerations. This approach does have some issues wrt to code in packages, but I can't see an alternative. The problem with packages is that the R code setting up the enumeration structures requires the shared library so that the C functions returning enumeration values can be called. The enumeration setup code thus needs to be moved to the package initialisation section. For SimpleITK I do this using an R script, which I think is an acceptable solution. The core part of the process is the following function. I dump all the enumeration stuff into a .onload function. This is only necessary if some of the enumerations are tricky. splitSwigFile <- function(filename, onloadfile, mainfile) { p1 <- parse(file=filename) getdefineEnum <- function(X) { return (is.call(X) & (X[[1]]=="defineEnumeration")) } dd <- sapply(p1, getdefineEnum) enums <- p1[dd] enums <- unlist(lapply(enums, deparse)) enums <- c(".onLoad <- function(libname, pkgname) {", enums, "}") everythingelse <- p1[!dd] everythingelse <- unlist(lapply(everythingelse, deparse)) writeLines(everythingelse, mainfile) writeLines(enums, onloadfile) } --- Examples/test-suite/r/Makefile.in | 3 +- .../test-suite/r/arrays_dimensionless_runme.R | 4 +- Examples/test-suite/r/funcptr_runme.R | 4 +- .../test-suite/r/ignore_parameter_runme.R | 4 +- Examples/test-suite/r/integers_runme.R | 4 +- Examples/test-suite/r/overload_method_runme.R | 4 +- .../test-suite/r/preproc_constants_runme.R | 11 + Examples/test-suite/r/r_copy_struct_runme.R | 4 +- Examples/test-suite/r/r_legacy_runme.R | 4 +- Examples/test-suite/r/r_sexp_runme.R | 4 +- Examples/test-suite/r/rename_simple_runme.R | 4 +- Examples/test-suite/r/simple_array_runme.R | 3 +- Examples/test-suite/r/unions_runme.R | 3 +- Source/Modules/r.cxx | 2065 ++++++++--------- 14 files changed, 1064 insertions(+), 1057 deletions(-) create mode 100644 Examples/test-suite/r/preproc_constants_runme.R diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index d0489531f..2c9a2c3f2 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -5,7 +5,7 @@ LANGUAGE = r SCRIPTSUFFIX = _runme.R WRAPSUFFIX = .R -RUNR = R CMD BATCH --no-save --no-restore +RUNR = R CMD BATCH --no-save --no-restore '--args $(SCRIPTDIR)' srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -44,6 +44,7 @@ include $(srcdir)/../common.mk +$(swig_and_compile_multi_cpp) $(run_multitestcase) + # Runs the testcase. # # Run the runme if it exists. If not just load the R wrapper to diff --git a/Examples/test-suite/r/arrays_dimensionless_runme.R b/Examples/test-suite/r/arrays_dimensionless_runme.R index 9b97de2d8..4fc2541ff 100644 --- a/Examples/test-suite/r/arrays_dimensionless_runme.R +++ b/Examples/test-suite/r/arrays_dimensionless_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("arrays_dimensionless", .Platform$dynlib.ext, sep="")) source("arrays_dimensionless.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/funcptr_runme.R b/Examples/test-suite/r/funcptr_runme.R index 3d5281bfa..c6127ef68 100644 --- a/Examples/test-suite/r/funcptr_runme.R +++ b/Examples/test-suite/r/funcptr_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("funcptr", .Platform$dynlib.ext, sep="")) source("funcptr.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/ignore_parameter_runme.R b/Examples/test-suite/r/ignore_parameter_runme.R index 89e461d71..612b70013 100644 --- a/Examples/test-suite/r/ignore_parameter_runme.R +++ b/Examples/test-suite/r/ignore_parameter_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("ignore_parameter", .Platform$dynlib.ext, sep="")) source("ignore_parameter.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/integers_runme.R b/Examples/test-suite/r/integers_runme.R index e31099a3b..6e2f63b70 100644 --- a/Examples/test-suite/r/integers_runme.R +++ b/Examples/test-suite/r/integers_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("integers", .Platform$dynlib.ext, sep="")) source("integers.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/overload_method_runme.R b/Examples/test-suite/r/overload_method_runme.R index afb590a74..790f3df10 100644 --- a/Examples/test-suite/r/overload_method_runme.R +++ b/Examples/test-suite/r/overload_method_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("overload_method", .Platform$dynlib.ext, sep="")) source("overload_method.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/preproc_constants_runme.R b/Examples/test-suite/r/preproc_constants_runme.R new file mode 100644 index 000000000..2a4a601eb --- /dev/null +++ b/Examples/test-suite/r/preproc_constants_runme.R @@ -0,0 +1,11 @@ +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + +dyn.load(paste("preproc_constants", .Platform$dynlib.ext, sep="")) +source("preproc_constants.R") +cacheMetaData(1) + +v <- enumToInteger('kValue', '_MyEnum') +print(v) +unittest(v,4) +q(save="no") diff --git a/Examples/test-suite/r/r_copy_struct_runme.R b/Examples/test-suite/r/r_copy_struct_runme.R index 21bd93b64..deadc61fe 100644 --- a/Examples/test-suite/r/r_copy_struct_runme.R +++ b/Examples/test-suite/r/r_copy_struct_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("r_copy_struct", .Platform$dynlib.ext, sep="")) source("r_copy_struct.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/r_legacy_runme.R b/Examples/test-suite/r/r_legacy_runme.R index 7e5ade87f..3ca229ff8 100644 --- a/Examples/test-suite/r/r_legacy_runme.R +++ b/Examples/test-suite/r/r_legacy_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("r_legacy", .Platform$dynlib.ext, sep="")) source("r_legacy.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/r_sexp_runme.R b/Examples/test-suite/r/r_sexp_runme.R index 96b36e8af..e7b28a965 100644 --- a/Examples/test-suite/r/r_sexp_runme.R +++ b/Examples/test-suite/r/r_sexp_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("r_sexp", .Platform$dynlib.ext, sep="")) source("r_sexp.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/rename_simple_runme.R b/Examples/test-suite/r/rename_simple_runme.R index b25aeb844..0628ca6c9 100644 --- a/Examples/test-suite/r/rename_simple_runme.R +++ b/Examples/test-suite/r/rename_simple_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("rename_simple", .Platform$dynlib.ext, sep="")) source("rename_simple.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/simple_array_runme.R b/Examples/test-suite/r/simple_array_runme.R index a6758dedd..fe70dc324 100644 --- a/Examples/test-suite/r/simple_array_runme.R +++ b/Examples/test-suite/r/simple_array_runme.R @@ -1,4 +1,5 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) dyn.load(paste("simple_array", .Platform$dynlib.ext, sep="")) source("simple_array.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/unions_runme.R b/Examples/test-suite/r/unions_runme.R index 76870d10c..fd148c7ef 100644 --- a/Examples/test-suite/r/unions_runme.R +++ b/Examples/test-suite/r/unions_runme.R @@ -1,4 +1,5 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) dyn.load(paste("unions", .Platform$dynlib.ext, sep="")) source("unions.R") cacheMetaData(1) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 0e8e23063..9f4455fd9 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files @@ -12,11 +12,11 @@ * ----------------------------------------------------------------------------- */ #include "swigmod.h" +#include static const double DEFAULT_NUMBER = .0000123456712312312323; -static String* replaceInitialDash(const String *name) -{ +static String *replaceInitialDash(const String *name) { String *retval; if (!Strncmp(name, "_", 1)) { retval = Copy(name); @@ -27,42 +27,57 @@ static String* replaceInitialDash(const String *name) return retval; } -static String * getRTypeName(SwigType *t, int *outCount = NULL) { +static String *getRTypeName(SwigType *t, int *outCount = NULL) { String *b = SwigType_base(t); List *els = SwigType_split(t); int count = 0; int i; - - if(Strncmp(b, "struct ", 7) == 0) + + if (Strncmp(b, "struct ", 7) == 0) Replace(b, "struct ", "", DOH_REPLACE_FIRST); - + /* Printf(stdout, " %s,base = %s\n", t, b); - for(i = 0; i < Len(els); i++) + for(i = 0; i < Len(els); i++) Printf(stdout, "%d) %s, ", i, Getitem(els,i)); Printf(stdout, "\n"); */ - - for(i = 0; i < Len(els); i++) { + + for (i = 0; i < Len(els); i++) { String *el = Getitem(els, i); - if(Strcmp(el, "p.") == 0 || Strncmp(el, "a(", 2) == 0) { + if (Strcmp(el, "p.") == 0 || Strncmp(el, "a(", 2) == 0) { count++; Append(b, "Ref"); } } - if(outCount) + if (outCount) *outCount = count; - + String *tmp = NewString(""); char *retName = Char(SwigType_manglestr(t)); Insert(tmp, 0, retName); return tmp; - + /* - if(count) - return(b); - - Delete(b); - return(NewString("")); - */ + if(count) + return(b); + + Delete(b); + return(NewString("")); + */ +} + +static String *getNamespacePrefix(const String *enumRef) { + // for use from enumDeclaration. + // returns the namespace part of a string + // Do we have any "::"? + String *name = NewString(enumRef); + + while (Strstr(name, "::")) { + name = NewStringf("%s", Strchr(name, ':') + 2); + } + String *result = NewStringWithSize(enumRef, Len(enumRef) - Len(name)); + + Delete(name); + return (result); } /********************* @@ -71,16 +86,16 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) { Now handles arrays, i.e. struct A[2] ****************/ -static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) { +static String *getRClassName(String *retType, int /*addRef */ = 1, int upRef = 0) { String *tmp = NewString(""); SwigType *resolved = SwigType_typedef_resolve_all(retType); char *retName = Char(SwigType_manglestr(resolved)); if (upRef) { Printf(tmp, "_p%s", retName); - } else{ + } else { Insert(tmp, 0, retName); } - + return tmp; /* #if 1 @@ -89,33 +104,33 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) { if(!l || n == 0) { #ifdef R_SWIG_VERBOSE if (debugMode) - Printf(stdout, "SwigType_split return an empty list for %s\n", - retType); + Printf(stdout, "SwigType_split return an empty list for %s\n", + retType); #endif return(tmp); } - - + + String *el = Getitem(l, n-1); char *ptr = Char(el); if(strncmp(ptr, "struct ", 7) == 0) ptr += 7; - + Printf(tmp, "%s", ptr); - + if(addRef) { for(int i = 0; i < n; i++) { - if(Strcmp(Getitem(l, i), "p.") == 0 || - Strncmp(Getitem(l, i), "a(", 2) == 0) - Printf(tmp, "Ref"); + if(Strcmp(Getitem(l, i), "p.") == 0 || + Strncmp(Getitem(l, i), "a(", 2) == 0) + Printf(tmp, "Ref"); } } - + #else char *retName = Char(SwigType_manglestr(retType)); if(!retName) return(tmp); - + if(addRef) { while(retName && strlen(retName) > 1 && strncmp(retName, "_p", 2) == 0) { retName += 2; @@ -126,7 +141,7 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) { retName ++; Insert(tmp, 0, retName); #endif - + return tmp; */ } @@ -137,50 +152,47 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) { Now handles arrays, i.e. struct A[2] ****************/ -static String * getRClassNameCopyStruct(String *retType, int addRef) { +static String *getRClassNameCopyStruct(String *retType, int addRef) { String *tmp = NewString(""); - + #if 1 List *l = SwigType_split(retType); int n = Len(l); - if(!l || n == 0) { + if (!l || n == 0) { #ifdef R_SWIG_VERBOSE Printf(stdout, "SwigType_split return an empty list for %s\n", retType); #endif - return(tmp); + return (tmp); } - - - String *el = Getitem(l, n-1); + + + String *el = Getitem(l, n - 1); char *ptr = Char(el); - if(strncmp(ptr, "struct ", 7) == 0) + if (strncmp(ptr, "struct ", 7) == 0) ptr += 7; - + Printf(tmp, "%s", ptr); - - if(addRef) { - for(int i = 0; i < n; i++) { - if(Strcmp(Getitem(l, i), "p.") == 0 || - Strncmp(Getitem(l, i), "a(", 2) == 0) - Printf(tmp, "Ref"); + + if (addRef) { + for (int i = 0; i < n; i++) { + if (Strcmp(Getitem(l, i), "p.") == 0 || Strncmp(Getitem(l, i), "a(", 2) == 0) + Printf(tmp, "Ref"); } } - #else char *retName = Char(SwigType_manglestr(retType)); - if(!retName) - return(tmp); - - if(addRef) { - while(retName && strlen(retName) > 1 && - strncmp(retName, "_p", 2) == 0) { + if (!retName) + return (tmp); + + if (addRef) { + while (retName && strlen(retName) > 1 && strncmp(retName, "_p", 2) == 0) { retName += 2; Printf(tmp, "Ref"); } } - - if(retName[0] == '_') - retName ++; + + if (retName[0] == '_') + retName++; Insert(tmp, 0, retName); #endif @@ -197,11 +209,8 @@ static String * getRClassNameCopyStruct(String *retType, int addRef) { static void writeListByLine(List *l, File *out, bool quote = 0) { int i, n = Len(l); - for(i = 0; i < n; i++) - Printf(out, "%s%s%s%s%s\n", tab8, - quote ? "\"" :"", - Getitem(l, i), - quote ? "\"" :"", i < n-1 ? "," : ""); + for (i = 0; i < n; i++) + Printf(out, "%s%s%s%s%s\n", tab8, quote ? "\"" : "", Getitem(l, i), quote ? "\"" : "", i < n - 1 ? "," : ""); } @@ -231,10 +240,13 @@ static void showUsage() { } static bool expandTypedef(SwigType *t) { - if (SwigType_isenum(t)) return false; + if (SwigType_isenum(t)) + return false; String *prefix = SwigType_prefix(t); - if (Strncmp(prefix, "f", 1)) return false; - if (Strncmp(prefix, "p.f", 3)) return false; + if (Strncmp(prefix, "f", 1)) + return false; + if (Strncmp(prefix, "p.f", 3)) + return false; return true; } @@ -246,11 +258,11 @@ static bool expandTypedef(SwigType *t) { static int addCopyParameter(SwigType *type) { int ok = 0; ok = Strncmp(type, "struct ", 7) == 0 || Strncmp(type, "p.struct ", 9) == 0; - if(!ok) { + if (!ok) { ok = Strncmp(type, "p.", 2); } - return(ok); + return (ok); } static void replaceRClass(String *tm, SwigType *type) { @@ -260,25 +272,28 @@ static void replaceRClass(String *tm, SwigType *type) { Replaceall(tm, "$R_class", tmp); Replaceall(tm, "$*R_class", tmp_base); Replaceall(tm, "$&R_class", tmp_ref); - Delete(tmp); Delete(tmp_base); Delete(tmp_ref); + Delete(tmp); + Delete(tmp_base); + Delete(tmp_ref); } static double getNumber(String *value) { double d = DEFAULT_NUMBER; - if(Char(value)) { - if(sscanf(Char(value), "%lf", &d) != 1) - return(DEFAULT_NUMBER); + if (Char(value)) { + if (sscanf(Char(value), "%lf", &d) != 1) + return (DEFAULT_NUMBER); } - return(d); + return (d); } -class R : public Language { + +class R:public Language { public: R(); void registerClass(Node *n); void main(int argc, char *argv[]); int top(Node *n); - + void dispatchFunction(Node *n); int functionWrapper(Node *n); int constantWrapper(Node *n); @@ -290,99 +305,90 @@ public: int membervariableHandler(Node *n); int typedefHandler(Node *n); - static List *Swig_overload_rank(Node *n, - bool script_lang_wrapping); + static List *Swig_overload_rank(Node *n, bool script_lang_wrapping); int memberfunctionHandler(Node *n) { if (debugMode) - Printf(stdout, " %s %s\n", - Getattr(n, "name"), - Getattr(n, "type")); + Printf(stdout, " %s %s\n", Getattr(n, "name"), Getattr(n, "type")); member_name = Getattr(n, "sym:name"); processing_class_member_function = 1; - int status = Language::memberfunctionHandler(n); - processing_class_member_function = 0; - return status; + int status = Language::memberfunctionHandler(n); + processing_class_member_function = 0; + return status; } - - /* Grab the name of the current class being processed so that we can - deal with members of that class. */ - int classHandler(Node *n){ - if(!ClassMemberTable) + /* Grab the name of the current class being processed so that we can + deal with members of that class. */ int classHandler(Node *n) { + if (!ClassMemberTable) ClassMemberTable = NewHash(); - + class_name = Getattr(n, "name"); int status = Language::classHandler(n); - + class_name = NULL; return status; } // Not used: String *runtimeCode(); - + protected: int addRegistrationRoutine(String *rname, int nargs); int outputRegistrationRoutines(File *out); - + int outputCommandLineArguments(File *out); - int generateCopyRoutines(Node *n); + int generateCopyRoutines(Node *n); int DumpCode(Node *n); - + int OutputMemberReferenceMethod(String *className, int isSet, List *el, File *out); int OutputArrayMethod(String *className, List *el, File *out); int OutputClassMemberTable(Hash *tb, File *out); int OutputClassMethodsTable(File *out); int OutputClassAccessInfo(Hash *tb, File *out); - + int defineArrayAccessors(SwigType *type); - + void addNamespaceFunction(String *name) { - if(!namespaceFunctions) + if (!namespaceFunctions) namespaceFunctions = NewList(); Append(namespaceFunctions, name); } void addNamespaceMethod(String *name) { - if(!namespaceMethods) + if (!namespaceMethods) namespaceMethods = NewList(); Append(namespaceMethods, name); } - - String* processType(SwigType *t, Node *n, int *nargs = NULL); + + String *processType(SwigType *t, Node *n, int *nargs = NULL); String *createFunctionPointerHandler(SwigType *t, Node *n, int *nargs); int addFunctionPointerProxy(String *name, Node *n, SwigType *t, String *s_paramTypes) { /*XXX Do we need to put the t in there to get the return type later. */ - if(!functionPointerProxyTable) + if (!functionPointerProxyTable) functionPointerProxyTable = NewHash(); - + Setattr(functionPointerProxyTable, name, n); - + Setattr(SClassDefs, name, name); - Printv(s_classes, "setClass('", - name, - "',\n", tab8, - "prototype = list(parameterTypes = c(", s_paramTypes, "),\n", - tab8, tab8, tab8, - "returnType = '", SwigType_manglestr(t), "'),\n", tab8, - "contains = 'CRoutinePointer')\n\n##\n", NIL); - + Printv(s_classes, "setClass('", + name, + "',\n", tab8, + "prototype = list(parameterTypes = c(", s_paramTypes, "),\n", + tab8, tab8, tab8, "returnType = '", SwigType_manglestr(t), "'),\n", tab8, "contains = 'CRoutinePointer')\n\n##\n", NIL); + return SWIG_OK; } - - void addSMethodInfo(String *name, - String *argType, int nargs); - // Simple initialization such as constant strings that can be reused. - void init(); - - - void addAccessor(String *memberName, Wrapper *f, - String *name, int isSet = -1); - + + void addSMethodInfo(String *name, String *argType, int nargs); + // Simple initialization such as constant strings that can be reused. + void init(); + + + void addAccessor(String *memberName, Wrapper *f, String *name, int isSet = -1); + static int getFunctionPointerNumArgs(Node *n, SwigType *tt); -protected: +protected: bool copyStruct; bool memoryProfile; bool aggressiveGc; @@ -400,95 +406,88 @@ protected: String *s_init; String *s_init_routine; String *s_namespace; - - // State variables that carry information across calls to functionWrapper() - // from member accessors and class declarations. + + // State variables that carry information across calls to functionWrapper() + // from member accessors and class declarations. String *opaqueClassDeclaration; int processing_variable; int processing_member_access_function; String *member_name; String *class_name; - - + + int processing_class_member_function; List *class_member_functions; List *class_member_set_functions; - + /* */ Hash *ClassMemberTable; Hash *ClassMethodsTable; Hash *SClassDefs; Hash *SMethodInfo; - - // Information about routines that are generated and to be registered with - // R for dynamic lookup. + + // Information about routines that are generated and to be registered with + // R for dynamic lookup. Hash *registrationTable; Hash *functionPointerProxyTable; - + List *namespaceFunctions; List *namespaceMethods; - List *namespaceClasses; // Probably can do this from ClassMemberTable. - - - // Store a copy of the command line. - // Need only keep a string that has it formatted. + List *namespaceClasses; // Probably can do this from ClassMemberTable. + + + // Store a copy of the command line. + // Need only keep a string that has it formatted. char **Argv; - int Argc; + int Argc; bool inCPlusMode; - + // State variables that we remember from the command line settings // potentially that govern the code we generate. String *DllName; String *Rpackage; - bool noInitializationCode; - bool outputNamespaceInfo; - + bool noInitializationCode; + bool outputNamespaceInfo; + String *UnProtectWrapupCode; // Static members static bool debugMode; }; -R::R() : - copyStruct(false), - memoryProfile(false), - aggressiveGc(false), - sfile(0), - f_init(0), - s_classes(0), - f_begin(0), - f_runtime(0), - f_wrapper(0), - s_header(0), - f_wrappers(0), - s_init(0), - s_init_routine(0), - s_namespace(0), - opaqueClassDeclaration(0), - processing_variable(0), - processing_member_access_function(0), - member_name(0), - class_name(0), - processing_class_member_function(0), - class_member_functions(0), - class_member_set_functions(0), - ClassMemberTable(0), - ClassMethodsTable(0), - SClassDefs(0), - SMethodInfo(0), - registrationTable(0), - functionPointerProxyTable(0), - namespaceFunctions(0), - namespaceMethods(0), - namespaceClasses(0), - Argv(0), - Argc(0), - inCPlusMode(false), - DllName(0), - Rpackage(0), - noInitializationCode(false), - outputNamespaceInfo(false), - UnProtectWrapupCode(0) { +R::R(): +copyStruct(false), +memoryProfile(false), +aggressiveGc(false), +sfile(0), +f_init(0), +s_classes(0), +f_begin(0), +f_runtime(0), +f_wrapper(0), +s_header(0), +f_wrappers(0), +s_init(0), +s_init_routine(0), +s_namespace(0), +opaqueClassDeclaration(0), +processing_variable(0), +processing_member_access_function(0), +member_name(0), +class_name(0), +processing_class_member_function(0), +class_member_functions(0), +class_member_set_functions(0), +ClassMemberTable(0), +ClassMethodsTable(0), +SClassDefs(0), +SMethodInfo(0), +registrationTable(0), +functionPointerProxyTable(0), +namespaceFunctions(0), +namespaceMethods(0), +namespaceClasses(0), +Argv(0), Argc(0), inCPlusMode(false), DllName(0), Rpackage(0), noInitializationCode(false), outputNamespaceInfo(false), UnProtectWrapupCode(0) { } bool R::debugMode = false; @@ -508,43 +507,44 @@ int R::getFunctionPointerNumArgs(Node *n, SwigType *tt) { void R::addSMethodInfo(String *name, String *argType, int nargs) { (void) argType; - - if(!SMethodInfo) + + if (!SMethodInfo) SMethodInfo = NewHash(); if (debugMode) Printf(stdout, "[addMethodInfo] %s\n", name); Hash *tb = Getattr(SMethodInfo, name); - if(!tb) { + if (!tb) { tb = NewHash(); Setattr(SMethodInfo, name, tb); } String *str = Getattr(tb, "max"); int max = -1; - if(str) + if (str) max = atoi(Char(str)); - if(max < nargs) { - if(str) Delete(str); + if (max < nargs) { + if (str) + Delete(str); str = NewStringf("%d", max); Setattr(tb, "max", str); } } - + /* Returns the name of the new routine. */ -String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { +String *R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { String *funName = SwigType_manglestr(t); - + /* See if we have already processed this one. */ - if(functionPointerProxyTable && Getattr(functionPointerProxyTable, funName)) + if (functionPointerProxyTable && Getattr(functionPointerProxyTable, funName)) return funName; - + if (debugMode) - Printf(stdout, " Defining %s\n", t); - + Printf(stdout, " Defining %s\n", t); + SwigType *rettype = Copy(Getattr(n, "type")); SwigType *funcparams = SwigType_functionpointer_decompose(rettype); String *rtype = SwigType_str(rettype, 0); @@ -558,13 +558,13 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { Printf(stdout, "Type: %s\n", t); Printf(stdout, "Return type: %s\n", SwigType_base(t)); } - + bool isVoidType = Strcmp(rettype, "void") == 0; if (debugMode) Printf(stdout, "%s is void ? %s (%s)\n", funName, isVoidType ? "yes" : "no", rettype); - + Wrapper *f = NewWrapper(); - + /* Go through argument list, attach lnames for arguments */ int i = 0; Parm *p = parms; @@ -573,14 +573,14 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { String *lname; if (!arg && Cmp(Getattr(p, "type"), "void")) { - lname = NewStringf("s_arg%d", i+1); + lname = NewStringf("s_arg%d", i + 1); Setattr(p, "name", lname); } else lname = arg; Setattr(p, "lname", lname); } - + Swig_typemap_attach_parms("out", parms, f); Swig_typemap_attach_parms("scoerceout", parms, f); Swig_typemap_attach_parms("scheck", parms, f); @@ -595,9 +595,9 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { Wrapper_add_local(f, "r_swig_cb_data", "RCallbackFunctionData *r_swig_cb_data = R_SWIG_getCallbackFunctionData()"); String *lvar = NewString("r_swig_cb_data"); - Wrapper_add_local(f, "r_tmp", "SEXP r_tmp"); // for use in converting arguments to R objects for call. - Wrapper_add_local(f, "r_nprotect", "int r_nprotect = 0"); // for use in converting arguments to R objects for call. - Wrapper_add_local(f, "r_vmax", "char * r_vmax= 0"); // for use in converting arguments to R objects for call. + Wrapper_add_local(f, "r_tmp", "SEXP r_tmp"); // for use in converting arguments to R objects for call. + Wrapper_add_local(f, "r_nprotect", "int r_nprotect = 0"); // for use in converting arguments to R objects for call. + Wrapper_add_local(f, "r_vmax", "char * r_vmax= 0"); // for use in converting arguments to R objects for call. // Add local for error code in return value. This is not in emit_return_variable because that assumes an out typemap // whereas the type makes are reverse @@ -605,136 +605,125 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { p = parms; int nargs = ParmList_len(parms); - if(numArgs) { + if (numArgs) { *numArgs = nargs; if (debugMode) Printf(stdout, "Setting number of parameters to %d\n", *numArgs); - } + } String *setExprElements = NewString(""); - + String *s_paramTypes = NewString(""); - for(i = 0; p; i++) { + for (i = 0; p; i++) { SwigType *tt = Getattr(p, "type"); SwigType *name = Getattr(p, "name"); String *tm = Getattr(p, "tmap:out"); - Printf(f->def, "%s %s", SwigType_str(tt, 0), name); - if(tm) { + Printf(f->def, "%s %s", SwigType_str(tt, 0), name); + if (tm) { Replaceall(tm, "$1", name); if (SwigType_isreference(tt)) { - String *tmp = NewString(""); + String *tmp = NewString(""); Append(tmp, "*"); - Append(tmp, name); - Replaceall(tm, tmp, name); + Append(tmp, name); + Replaceall(tm, tmp, name); } Replaceall(tm, "$result", "r_tmp"); - replaceRClass(tm, Getattr(p,"type")); - Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); - } - + replaceRClass(tm, Getattr(p, "type")); + Replaceall(tm, "$owner", "R_SWIG_EXTERNAL"); + } + Printf(setExprElements, "%s\n", tm); Printf(setExprElements, "SETCAR(r_swig_cb_data->el, %s);\n", "r_tmp"); Printf(setExprElements, "r_swig_cb_data->el = CDR(r_swig_cb_data->el);\n\n"); - + Printf(s_paramTypes, "'%s'", SwigType_manglestr(tt)); - - + + p = nextSibling(p); - if(p) { + if (p) { Printf(f->def, ", "); Printf(s_paramTypes, ", "); } } - - Printf(f->def, ") {\n"); - + + Printf(f->def, ") {\n"); + Printf(f->code, "Rf_protect(%s->expr = Rf_allocVector(LANGSXP, %d));\n", lvar, nargs + 1); Printf(f->code, "r_nprotect++;\n"); Printf(f->code, "r_swig_cb_data->el = r_swig_cb_data->expr;\n\n"); - + Printf(f->code, "SETCAR(r_swig_cb_data->el, r_swig_cb_data->fun);\n"); Printf(f->code, "r_swig_cb_data->el = CDR(r_swig_cb_data->el);\n\n"); - + Printf(f->code, "%s\n\n", setExprElements); - - Printv(f->code, "r_swig_cb_data->retValue = R_tryEval(", - "r_swig_cb_data->expr,", - " R_GlobalEnv,", - " &r_swig_cb_data->errorOccurred", - ");\n", - NIL); - + + Printv(f->code, "r_swig_cb_data->retValue = R_tryEval(", "r_swig_cb_data->expr,", " R_GlobalEnv,", " &r_swig_cb_data->errorOccurred", ");\n", NIL); + Printv(f->code, "\n", - "if(r_swig_cb_data->errorOccurred) {\n", - "R_SWIG_popCallbackFunctionData(1);\n", - "Rf_error(\"error in calling R function as a function pointer (", - funName, - ")\");\n", - "}\n", - NIL); - - - - if(!isVoidType) { - /* Need to deal with the return type of the function pointer, not the function pointer itself. + "if(r_swig_cb_data->errorOccurred) {\n", + "R_SWIG_popCallbackFunctionData(1);\n", "Rf_error(\"error in calling R function as a function pointer (", funName, ")\");\n", "}\n", NIL); + + + + if (!isVoidType) { + /* Need to deal with the return type of the function pointer, not the function pointer itself. So build a new node that has the relevant pieces. XXX Have to be a little more clever so that we can deal with struct A * - the * is getting lost. Is this still true? If so, will a SwigType_push() solve things? - */ + */ Parm *bbase = NewParmNode(rettype, n); String *returnTM = Swig_typemap_lookup("in", bbase, Swig_cresult_name(), f); - if(returnTM) { + if (returnTM) { String *tm = returnTM; - Replaceall(tm,"$input", "r_swig_cb_data->retValue"); - Replaceall(tm,"$target", Swig_cresult_name()); + Replaceall(tm, "$input", "r_swig_cb_data->retValue"); + Replaceall(tm, "$target", Swig_cresult_name()); replaceRClass(tm, rettype); - Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); - Replaceall(tm,"$disown","0"); + Replaceall(tm, "$owner", "R_SWIG_EXTERNAL"); + Replaceall(tm, "$disown", "0"); Printf(f->code, "%s\n", tm); } Delete(bbase); } - + Printv(f->code, "R_SWIG_popCallbackFunctionData(1);\n", NIL); Printv(f->code, "\n", UnProtectWrapupCode, NIL); - if (SwigType_isreference(rettype)) { - Printv(f->code, "return *", Swig_cresult_name(), ";\n", NIL); - } else if(!isVoidType) - Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL); - + if (SwigType_isreference(rettype)) { + Printv(f->code, "return *", Swig_cresult_name(), ";\n", NIL); + } else if (!isVoidType) + Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL); + Printv(f->code, "\n}\n", NIL); Replaceall(f->code, "SWIG_exception_fail", "SWIG_exception_noreturn"); - + /* To coerce correctly in S, we really want to have an extra/intermediate - function that handles the scoerceout. + function that handles the scoerceout. We need to check if any of the argument types have an entry in that map. If none do, the ignore and call the function straight. Otherwise, generate the a marshalling function. Need to be able to find it in S. Or use an entirely generic one that evaluates the expressions. Handle errors in the evaluation of the function by restoring - the stack, if there is one in use for this function (i.e. no + the stack, if there is one in use for this function (i.e. no userData). - */ - + */ + Wrapper_print(f, f_wrapper); - + addFunctionPointerProxy(funName, n, t, s_paramTypes); Delete(s_paramTypes); Delete(rtype); Delete(rettype); Delete(funcparams); DelWrapper(f); - + return funName; } void R::init() { - UnProtectWrapupCode = - NewStringf("%s", "vmaxset(r_vmax);\nif(r_nprotect) Rf_unprotect(r_nprotect);\n\n"); - + UnProtectWrapupCode = NewStringf("%s", "vmaxset(r_vmax);\nif(r_nprotect) Rf_unprotect(r_nprotect);\n\n"); + SClassDefs = NewHash(); - + sfile = NewString(""); f_init = NewString(""); s_header = NewString(""); @@ -761,18 +750,18 @@ int R::cDeclaration(Node *n) { /** Method from Language that is called to start the entire - processing off, i.e. the generation of the code. + processing off, i.e. the generation of the code. It is called after the input has been read and parsed. Here we open the output streams and generate the code. ***/ int R::top(Node *n) { String *module = Getattr(n, "name"); - if(!Rpackage) + if (!Rpackage) Rpackage = Copy(module); - if(!DllName) + if (!DllName) DllName = Copy(module); - if(outputNamespaceInfo) { + if (outputNamespaceInfo) { s_namespace = NewString(""); Swig_register_filebyname("snamespace", s_namespace); Printf(s_namespace, "useDynLib(%s)\n", DllName); @@ -797,7 +786,7 @@ int R::top(Node *n) { Printf(f_runtime, "#define SWIGR\n"); Printf(f_runtime, "\n"); - + Swig_banner_target_lang(s_init, "#"); outputCommandLineArguments(s_init); @@ -812,17 +801,17 @@ int R::top(Node *n) { Printf(f_wrapper, "#endif\n"); String *type_table = NewString(""); - SwigType_emit_type_table(f_runtime,f_wrapper); + SwigType_emit_type_table(f_runtime, f_wrapper); Delete(type_table); - if(ClassMemberTable) { + if (ClassMemberTable) { //XXX OutputClassAccessInfo(ClassMemberTable, sfile); Delete(ClassMemberTable); ClassMemberTable = NULL; } - Printf(f_init,"}\n"); - if(registrationTable) + Printf(f_init, "}\n"); + if (registrationTable) outputRegistrationRoutines(f_init); /* Now arrange to write the 2 files - .S and .c. */ @@ -848,35 +837,35 @@ int R::top(Node *n) { ****************************************************/ int R::DumpCode(Node *n) { String *output_filename = NewString(""); - - + + /* The name of the file in which we will generate the S code. */ Printf(output_filename, "%s%s.R", SWIG_output_directory(), Rpackage); - + #ifdef R_SWIG_VERBOSE Printf(stdout, "Writing S code to %s\n", output_filename); #endif - + File *scode = NewFile(output_filename, "w", SWIG_output_files()); if (!scode) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); } Delete(output_filename); - - + + Printf(scode, "%s\n\n", s_init); Printf(scode, "%s\n\n", s_classes); Printf(scode, "%s\n", sfile); - + Delete(scode); - String *outfile = Getattr(n,"outfile"); - File *runtime = NewFile(outfile,"w", SWIG_output_files()); + String *outfile = Getattr(n, "outfile"); + File *runtime = NewFile(outfile, "w", SWIG_output_files()); if (!runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - + Printf(runtime, "%s", f_begin); Printf(runtime, "%s\n", f_runtime); Printf(runtime, "%s\n", s_header); @@ -885,7 +874,7 @@ int R::DumpCode(Node *n) { Delete(runtime); - if(outputNamespaceInfo) { + if (outputNamespaceInfo) { output_filename = NewString(""); Printf(output_filename, "%sNAMESPACE", SWIG_output_directory()); File *ns = NewFile(output_filename, "w", SWIG_output_files()); @@ -894,7 +883,7 @@ int R::DumpCode(Node *n) { SWIG_exit(EXIT_FAILURE); } Delete(output_filename); - + Printf(ns, "%s\n", s_namespace); Printf(ns, "\nexport(\n"); @@ -913,7 +902,7 @@ int R::DumpCode(Node *n) { /* - We may need to do more.... so this is left as a + We may need to do more.... so this is left as a stub for the moment. */ int R::OutputClassAccessInfo(Hash *tb, File *out) { @@ -925,28 +914,28 @@ int R::OutputClassAccessInfo(Hash *tb, File *out) { /************************************************************************ Currently this just writes the information collected about the different methods of the C++ classes that have been processed - to the console. + to the console. This will be used later to define S4 generics and methods. **************************************************************************/ int R::OutputClassMethodsTable(File *) { Hash *tb = ClassMethodsTable; - - if(!tb) + + if (!tb) return SWIG_OK; - + List *keys = Keys(tb); String *key; int i, n = Len(keys); if (debugMode) { - for(i = 0; i < n ; i++ ) { + for (i = 0; i < n; i++) { key = Getitem(keys, i); Printf(stdout, "%d) %s\n", i, key); List *els = Getattr(tb, key); int nels = Len(els); Printf(stdout, "\t"); - for(int j = 0; j < nels; j+=2) { - Printf(stdout, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : ""); - Printf(stdout, "%s\n", Getitem(els, j+1)); + for (int j = 0; j < nels; j += 2) { + Printf(stdout, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : ""); + Printf(stdout, "%s\n", Getitem(els, j + 1)); } Printf(stdout, "\n"); } @@ -957,89 +946,88 @@ int R::OutputClassMethodsTable(File *) { /* - Iterate over the _set and <>_get + Iterate over the _set and <>_get elements and generate the $ and $<- functions that provide constrained access to the member fields in these elements. tb - a hash table that is built up in functionWrapper as we process each membervalueHandler. - The entries are indexed by _set and + The entries are indexed by _set and _get. Each entry is a List *. - + out - the stram where the code is to be written. This is the S code stream as we generate only S code here.. */ int R::OutputClassMemberTable(Hash *tb, File *out) { List *keys = Keys(tb), *el; - + String *key; int i, n = Len(keys); /* Loop over all the _set and _get entries in the table. */ - - if(n && outputNamespaceInfo) { + + if (n && outputNamespaceInfo) { Printf(s_namespace, "exportClasses("); } - for(i = 0; i < n; i++) { + for (i = 0; i < n; i++) { key = Getitem(keys, i); el = Getattr(tb, key); - + String *className = Getitem(el, 0); char *ptr = Char(key); ptr = &ptr[Len(key) - 3]; int isSet = strcmp(ptr, "set") == 0; - - // OutputArrayMethod(className, el, out); + + // OutputArrayMethod(className, el, out); OutputMemberReferenceMethod(className, isSet, el, out); - - if(outputNamespaceInfo) - Printf(s_namespace, "\"%s\"%s", className, i < n-1 ? "," : ""); + + if (outputNamespaceInfo) + Printf(s_namespace, "\"%s\"%s", className, i < n - 1 ? "," : ""); } - if(n && outputNamespaceInfo) { + if (n && outputNamespaceInfo) { Printf(s_namespace, ")\n"); } - + return n; } /******************************************************************* - Write the methods for $ or $<- for accessing a member field in an + Write the methods for $ or $<- for accessing a member field in an struct or union (or class). className - the name of the struct or union (e.g. Bar for struct Bar) - isSet - a logical value indicating whether the method is for + isSet - a logical value indicating whether the method is for modifying ($<-) or accessing ($) the member field. el - a list of length 2 * # accessible member elements + 1. - The first element is the name of the class. + The first element is the name of the class. The other pairs are member name and the name of the R function to access it. out - the stream where we write the code. ********************************************************************/ -int R::OutputMemberReferenceMethod(String *className, int isSet, - List *el, File *out) { +int R::OutputMemberReferenceMethod(String *className, int isSet, List *el, File *out) { int numMems = Len(el), j; int varaccessor = 0; - if (numMems == 0) + if (numMems == 0) return SWIG_OK; - + Wrapper *f = NewWrapper(), *attr = NewWrapper(); - + Printf(f->def, "function(x, name%s)", isSet ? ", value" : ""); Printf(attr->def, "function(x, i, j, ...%s)", isSet ? ", value" : ""); - + Printf(f->code, "{\n"); Printf(f->code, "%saccessorFuns = list(", tab8); Node *itemList = NewHash(); bool has_prev = false; - for(j = 0; j < numMems; j+=3) { + for (j = 0; j < numMems; j += 3) { String *item = Getitem(el, j); - if (Getattr(itemList, item)) + if (Getattr(itemList, item)) continue; Setattr(itemList, item, "1"); - + String *dup = Getitem(el, j + 1); char *ptr = Char(dup); ptr = &ptr[Len(dup) - 3]; - + if (!strcmp(ptr, "get")) varaccessor++; @@ -1055,7 +1043,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, } else { pitem = Copy(item); } - if (has_prev) + if (has_prev) Printf(f->code, ", "); Printf(f->code, "'%s' = %s", pitem, dup); has_prev = true; @@ -1063,114 +1051,102 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, } Delete(itemList); Printf(f->code, ");\n"); - + if (!isSet && varaccessor > 0) { Printf(f->code, "%svaccessors = c(", tab8); int vcount = 0; - for(j = 0; j < numMems; j+=3) { + for (j = 0; j < numMems; j += 3) { String *item = Getitem(el, j); String *dup = Getitem(el, j + 1); char *ptr = Char(dup); ptr = &ptr[Len(dup) - 3]; - + if (!strcmp(ptr, "get")) { - vcount++; - Printf(f->code, "'%s'%s", item, vcount < varaccessor ? ", " : ""); + vcount++; + Printf(f->code, "'%s'%s", item, vcount < varaccessor ? ", " : ""); } } Printf(f->code, ");\n"); } - - + + /* Printv(f->code, tab8, - "idx = pmatch(name, names(accessorFuns))\n", - tab8, - "if(is.na(idx)) {\n", - tab8, tab4, - "stop(\"No ", (isSet ? "modifiable" : "accessible"), " field named \", name, \" in ", className, - ": fields are \", paste(names(accessorFuns), sep = \", \")", - ")", "\n}\n", NIL); */ - Printv(f->code, ";", tab8, - "idx = pmatch(name, names(accessorFuns));\n", - tab8, - "if(is.na(idx)) \n", - tab8, tab4, NIL); - Printf(f->code, "return(callNextMethod(x, name%s));\n", - isSet ? ", value" : ""); + "idx = pmatch(name, names(accessorFuns))\n", + tab8, + "if(is.na(idx)) {\n", + tab8, tab4, + "stop(\"No ", (isSet ? "modifiable" : "accessible"), " field named \", name, \" in ", className, + ": fields are \", paste(names(accessorFuns), sep = \", \")", + ")", "\n}\n", NIL); */ + Printv(f->code, ";", tab8, "idx = pmatch(name, names(accessorFuns));\n", tab8, "if(is.na(idx)) \n", tab8, tab4, NIL); + Printf(f->code, "return(callNextMethod(x, name%s));\n", isSet ? ", value" : ""); Printv(f->code, tab8, "f = accessorFuns[[idx]];\n", NIL); - if(isSet) { + if (isSet) { Printv(f->code, tab8, "f(x, value);\n", NIL); Printv(f->code, tab8, "x;\n", NIL); // make certain to return the S value. } else { if (varaccessor) { - Printv(f->code, tab8, - "if (is.na(match(name, vaccessors))) function(...){f(x, ...)} else f(x);\n", NIL); + Printv(f->code, tab8, "if (is.na(match(name, vaccessors))) function(...){f(x, ...)} else f(x);\n", NIL); } else { Printv(f->code, tab8, "function(...){f(x, ...)};\n", NIL); } } Printf(f->code, "}\n"); - - + + Printf(out, "# Start of accessor method for %s\n", className); - Printf(out, "setMethod('$%s', '_p%s', ", - isSet ? "<-" : "", - getRClassName(className)); + Printf(out, "setMethod('$%s', '_p%s', ", isSet ? "<-" : "", getRClassName(className)); Wrapper_print(f, out); Printf(out, ");\n"); - - if(isSet) { - Printf(out, "setMethod('[[<-', c('_p%s', 'character'),", - getRClassName(className)); + + if (isSet) { + Printf(out, "setMethod('[[<-', c('_p%s', 'character'),", getRClassName(className)); Insert(f->code, 2, "name = i;\n"); Printf(attr->code, "%s", f->code); Wrapper_print(attr, out); Printf(out, ");\n"); } - + DelWrapper(attr); DelWrapper(f); - + Printf(out, "# end of accessor method for %s\n", className); - + return SWIG_OK; } /******************************************************************* - Write the methods for [ or [<- for accessing a member field in an + Write the methods for [ or [<- for accessing a member field in an struct or union (or class). className - the name of the struct or union (e.g. Bar for struct Bar) el - a list of length 2 * # accessible member elements + 1. - The first element is the name of the class. + The first element is the name of the class. The other pairs are member name and the name of the R function to access it. out - the stream where we write the code. ********************************************************************/ int R::OutputArrayMethod(String *className, List *el, File *out) { int numMems = Len(el), j; - - if(!el || numMems == 0) - return(0); - + + if (!el || numMems == 0) + return (0); + Printf(out, "# start of array methods for %s\n", className); - for(j = 0; j < numMems; j+=3) { + for (j = 0; j < numMems; j += 3) { String *item = Getitem(el, j); String *dup = Getitem(el, j + 1); if (!Strcmp(item, "__getitem__")) { - Printf(out, - "setMethod('[', '_p%s', function(x, i, j, ..., drop =TRUE) ", - getRClassName(className)); + Printf(out, "setMethod('[', '_p%s', function(x, i, j, ..., drop =TRUE) ", getRClassName(className)); Printf(out, " sapply(i, function (n) %s(x, as.integer(n-1))))\n\n", dup); } if (!Strcmp(item, "__setitem__")) { - Printf(out, "setMethod('[<-', '_p%s', function(x, i, j, ..., value)", - getRClassName(className)); + Printf(out, "setMethod('[<-', '_p%s', function(x, i, j, ..., value)", getRClassName(className)); Printf(out, " sapply(1:length(i), function(n) %s(x, as.integer(i[n]-1), value[n])))\n\n", dup); } - + } - + Printf(out, "# end of array methods for %s\n", className); - + return SWIG_OK; } @@ -1183,51 +1159,129 @@ int R::OutputArrayMethod(String *className, List *el, File *out) { int R::enumDeclaration(Node *n) { String *name = Getattr(n, "name"); String *tdname = Getattr(n, "tdname"); - + + if (cplus_mode != PUBLIC) { + return (SWIG_NOWRAP); + } + /* Using name if tdname is empty. */ - - if(Len(tdname) == 0) + + if (Len(tdname) == 0) tdname = name; - - if(!tdname || Strcmp(tdname, "") == 0) { + if (!tdname || Strcmp(tdname, "") == 0) { Language::enumDeclaration(n); return SWIG_OK; } - + String *mangled_tdname = SwigType_manglestr(tdname); String *scode = NewString(""); - - Printv(scode, "defineEnumeration('", mangled_tdname, "'", - ",\n", tab8, tab8, tab4, ".values = c(\n", NIL); - + String *possiblescode = NewString(""); + + // Need to create some C code to return the enum values. + // Presumably a C function for each element of the enum.. + // There is probably some sneaky way to use the + // standard methods of variable/constant access, but I can't see + // it yet. + // Need to fetch the namespace part of the enum in tdname, so + // that we can address the correct enum. Perhaps there is already an + // attribute that has this info, but I can't find it. That leaves + // searching for ::. Obviously needs to work if there is no nesting. + // + // One issue is that swig is generating defineEnumeration calls for + // enums in the private part of classes. This usually isn't a + // problem, but the model in which some C code returns the + // underlying value won't compile because it is accessing a private + // type. + // + // It will be best to turn off binding to private parts of + // classes. + + String *cppcode = NewString(""); + // this is the namespace that will get used inside the functions + // returning enumerations. + String *namespaceprefix = getNamespacePrefix(tdname); + Wrapper *eW = NewWrapper(); + Node *kk; + + for (kk = firstChild(n); kk; kk = nextSibling(kk)) { + String *ename = Getattr(kk, "name"); + String *fname = NewString(""); + String *cfunctname = NewStringf("R_swigenum_%s_%s", mangled_tdname, ename); + String *rfunctname = NewStringf("R_swigenum_%s_%s_get", mangled_tdname, ename); + Printf(fname, "%s(void){", cfunctname); + Printf(cppcode, "SWIGEXPORT SEXP \n%s\n", fname); + Printf(cppcode, "int result;\n"); + Printf(cppcode, "SEXP r_ans = R_NilValue;\n"); + Printf(cppcode, "result = (int)%s%s;\n", namespaceprefix, ename); + Printf(cppcode, "r_ans = Rf_ScalarInteger(result);\n"); + Printf(cppcode, "return(r_ans);\n}\n"); + + // Now emit the r binding functions + Printf(possiblescode, "`%s` = function(.copy=FALSE) {\n", rfunctname); + Printf(possiblescode, ".Call(\'%s\', as.logical(.copy), PACKAGE=\'%s\')\n}\n\n", cfunctname, Rpackage); + Printf(possiblescode, "attr(`%s`, \'returnType\')=\'integer\'\n", rfunctname); + Printf(possiblescode, "class(`%s`) = c(\"SWIGfunction\", class(\'%s\'))\n\n", rfunctname, rfunctname); + Delete(ename); + Delete(fname); + Delete(cfunctname); + Delete(rfunctname); + } + + Printv(cppcode, "", NIL); + + Printf(eW->code, "%s", cppcode); + Delete(cppcode); + + Delete(namespaceprefix); + + Printv(scode, "defineEnumeration('", mangled_tdname, "'", ",\n", tab8, tab8, tab4, ".values = c(\n", NIL); + Node *c; - int value = -1; // First number is zero + int value = -1; // First number is zero + bool needenumfunc = false; // Track whether we need runtime C + // calls to deduce correct enum values for (c = firstChild(n); c; c = nextSibling(c)) { // const char *tag = Char(nodeType(c)); - // if (Strcmp(tag,"cdecl") == 0) { + // if (Strcmp(tag,"cdecl") == 0) { name = Getattr(c, "name"); + // This needs to match the version earlier - could have stored it. + String *rfunctname = NewStringf("R_swigenum_%s_%s_get()", mangled_tdname, name); String *val = Getattr(c, "enumvalue"); - if(val && Char(val)) { - int inval = (int) getNumber(val); - if(inval == DEFAULT_NUMBER) - value++; - else - value = inval; - } else + String *numstring = NewString(""); + + if (val && Char(val)) { + double inval = getNumber(val); + if (inval == DEFAULT_NUMBER) { + // This should indicate there is some fancy text there + // so we want to call the special R functions + needenumfunc = true; + Printf(numstring, "%s", rfunctname); + } else { + value = (int) inval; + Printf(numstring, "%d", value); + + } + } else { value++; - - Printf(scode, "%s%s%s'%s' = %d%s\n", tab8, tab8, tab8, name, value, - nextSibling(c) ? ", " : ""); - // } + Printf(numstring, "%d", value); + } + Printf(scode, "%s%s%s'%s' = %s%s\n", tab8, tab8, tab8, name, numstring, nextSibling(c) ? ", " : ""); + Delete(rfunctname); + Delete(numstring); } - + Printv(scode, "))", NIL); + + if (needenumfunc) { + Wrapper_print(eW, f_wrapper); + Printf(sfile, "%s\n", possiblescode); + } Printf(sfile, "%s\n", scode); - + Delete(scode); + Delete(possiblescode); Delete(mangled_tdname); - return SWIG_OK; } @@ -1236,30 +1290,28 @@ int R::enumDeclaration(Node *n) { **************************************************************/ int R::variableWrapper(Node *n) { String *name = Getattr(n, "sym:name"); - + processing_variable = 1; Language::variableWrapper(n); // Force the emission of the _set and _get function wrappers. processing_variable = 0; - - + + SwigType *ty = Getattr(n, "type"); int addCopyParam = addCopyParameter(ty); - + //XXX processType(ty, n); - - if(!SwigType_isconst(ty)) { + + if (!SwigType_isconst(ty)) { Wrapper *f = NewWrapper(); - Printf(f->def, "%s = \nfunction(value%s)\n{\n", - name, addCopyParam ? ", .copy = FALSE" : ""); - Printv(f->code, "if(missing(value)) {\n", - name, "_get(", addCopyParam ? ".copy" : "", ")\n}", NIL); - Printv(f->code, " else {\n", - name, "_set(value)\n}\n}", NIL); - + Printf(f->def, "%s = \nfunction(value%s)\n{\n", name, addCopyParam ? ", .copy = FALSE" : ""); + Printv(f->code, "if(missing(value)) {\n", name, "_get(", addCopyParam ? ".copy" : "", ")\n}", NIL); + Printv(f->code, " else {\n", name, "_set(value)\n}\n}", NIL); + Wrapper_print(f, sfile); DelWrapper(f); } else { + Printf(sfile, "## constant in variableWrapper\n"); Printf(sfile, "%s = %s_get\n", name, name); } @@ -1267,27 +1319,27 @@ int R::variableWrapper(Node *n) { } -void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, - int isSet) { - if(isSet < 0) { + +void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, int isSet) { + if (isSet < 0) { int n = Len(name); char *ptr = Char(name); - isSet = Strcmp(NewString(&ptr[n-3]), "set") == 0; + isSet = Strcmp(NewString(&ptr[n - 3]), "set") == 0; } - + List *l = isSet ? class_member_set_functions : class_member_functions; - - if(!l) { + + if (!l) { l = NewList(); - if(isSet) + if (isSet) class_member_set_functions = l; else class_member_functions = l; } - + Append(l, memberName); Append(l, name); - + String *tmp = NewString(""); Wrapper_print(wrapper, tmp); Append(l, tmp); @@ -1299,237 +1351,235 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, #define MAX_OVERLOAD 256 struct Overloaded { - Node *n; /* Node */ - int argc; /* Argument count */ - ParmList *parms; /* Parameters used for overload check */ - int error; /* Ambiguity error */ + Node *n; /* Node */ + int argc; /* Argument count */ + ParmList *parms; /* Parameters used for overload check */ + int error; /* Ambiguity error */ }; -List * R::Swig_overload_rank(Node *n, - bool script_lang_wrapping) { - Overloaded nodes[MAX_OVERLOAD]; - int nnodes = 0; - Node *o = Getattr(n,"sym:overloaded"); +List *R::Swig_overload_rank(Node *n, bool script_lang_wrapping) { + Overloaded nodes[MAX_OVERLOAD]; + int nnodes = 0; + Node *o = Getattr(n, "sym:overloaded"); - if (!o) return 0; + if (!o) + return 0; Node *c = o; while (c) { - if (Getattr(c,"error")) { - c = Getattr(c,"sym:nextSibling"); + if (Getattr(c, "error")) { + c = Getattr(c, "sym:nextSibling"); continue; } /* if (SmartPointer && Getattr(c,"cplus:staticbase")) { - c = Getattr(c,"sym:nextSibling"); - continue; - } */ + c = Getattr(c,"sym:nextSibling"); + continue; + } */ /* Make a list of all the declarations (methods) that are overloaded with * this one particular method name */ - if (Getattr(c,"wrap:name")) { + if (Getattr(c, "wrap:name")) { nodes[nnodes].n = c; - nodes[nnodes].parms = Getattr(c,"wrap:parms"); + nodes[nnodes].parms = Getattr(c, "wrap:parms"); nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms); nodes[nnodes].error = 0; nnodes++; } - c = Getattr(c,"sym:nextSibling"); + c = Getattr(c, "sym:nextSibling"); } - + /* Sort the declarations by required argument count */ { - int i,j; + int i, j; for (i = 0; i < nnodes; i++) { - for (j = i+1; j < nnodes; j++) { - if (nodes[i].argc > nodes[j].argc) { - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } + for (j = i + 1; j < nnodes; j++) { + if (nodes[i].argc > nodes[j].argc) { + Overloaded t = nodes[i]; + nodes[i] = nodes[j]; + nodes[j] = t; + } } } } /* Sort the declarations by argument types */ { - int i,j; - for (i = 0; i < nnodes-1; i++) { - if (nodes[i].argc == nodes[i+1].argc) { - for (j = i+1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) { - Parm *p1 = nodes[i].parms; - Parm *p2 = nodes[j].parms; - int differ = 0; - int num_checked = 0; - while (p1 && p2 && (num_checked < nodes[i].argc)) { - if (debugMode) { - Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type")); - } - if (checkAttribute(p1,"tmap:in:numinputs","0")) { - p1 = Getattr(p1,"tmap:in:next"); - continue; - } - if (checkAttribute(p2,"tmap:in:numinputs","0")) { - p2 = Getattr(p2,"tmap:in:next"); - continue; - } - String *t1 = Getattr(p1,"tmap:typecheck:precedence"); - String *t2 = Getattr(p2,"tmap:typecheck:precedence"); - if (debugMode) { - Printf(stdout,"t1 = '%s', t2 = '%s'\n", t1, t2); - } - if ((!t1) && (!nodes[i].error)) { - Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), - "Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n", - Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); - nodes[i].error = 1; - } else if ((!t2) && (!nodes[j].error)) { - Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n", - Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); - nodes[j].error = 1; - } - if (t1 && t2) { - int t1v, t2v; - t1v = atoi(Char(t1)); - t2v = atoi(Char(t2)); - differ = t1v-t2v; - } - else if (!t1 && t2) differ = 1; - else if (t1 && !t2) differ = -1; - else if (!t1 && !t2) differ = -1; - num_checked++; - if (differ > 0) { - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - break; - } else if ((differ == 0) && (Strcmp(t1,"0") == 0)) { - t1 = Getattr(p1,"ltype"); - if (!t1) { - t1 = SwigType_ltype(Getattr(p1,"type")); - if (Getattr(p1,"tmap:typecheck:SWIGTYPE")) { - SwigType_add_pointer(t1); - } - Setattr(p1,"ltype",t1); - } - t2 = Getattr(p2,"ltype"); - if (!t2) { - t2 = SwigType_ltype(Getattr(p2,"type")); - if (Getattr(p2,"tmap:typecheck:SWIGTYPE")) { - SwigType_add_pointer(t2); - } - Setattr(p2,"ltype",t2); - } + int i, j; + for (i = 0; i < nnodes - 1; i++) { + if (nodes[i].argc == nodes[i + 1].argc) { + for (j = i + 1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) { + Parm *p1 = nodes[i].parms; + Parm *p2 = nodes[j].parms; + int differ = 0; + int num_checked = 0; + while (p1 && p2 && (num_checked < nodes[i].argc)) { + if (debugMode) { + Printf(stdout, "p1 = '%s', p2 = '%s'\n", Getattr(p1, "type"), Getattr(p2, "type")); + } + if (checkAttribute(p1, "tmap:in:numinputs", "0")) { + p1 = Getattr(p1, "tmap:in:next"); + continue; + } + if (checkAttribute(p2, "tmap:in:numinputs", "0")) { + p2 = Getattr(p2, "tmap:in:next"); + continue; + } + String *t1 = Getattr(p1, "tmap:typecheck:precedence"); + String *t2 = Getattr(p2, "tmap:typecheck:precedence"); + if (debugMode) { + Printf(stdout, "t1 = '%s', t2 = '%s'\n", t1, t2); + } + if ((!t1) && (!nodes[i].error)) { + Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), + "Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n", + Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); + nodes[i].error = 1; + } else if ((!t2) && (!nodes[j].error)) { + Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n", + Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); + nodes[j].error = 1; + } + if (t1 && t2) { + int t1v, t2v; + t1v = atoi(Char(t1)); + t2v = atoi(Char(t2)); + differ = t1v - t2v; + } else if (!t1 && t2) + differ = 1; + else if (t1 && !t2) + differ = -1; + else if (!t1 && !t2) + differ = -1; + num_checked++; + if (differ > 0) { + Overloaded t = nodes[i]; + nodes[i] = nodes[j]; + nodes[j] = t; + break; + } else if ((differ == 0) && (Strcmp(t1, "0") == 0)) { + t1 = Getattr(p1, "ltype"); + if (!t1) { + t1 = SwigType_ltype(Getattr(p1, "type")); + if (Getattr(p1, "tmap:typecheck:SWIGTYPE")) { + SwigType_add_pointer(t1); + } + Setattr(p1, "ltype", t1); + } + t2 = Getattr(p2, "ltype"); + if (!t2) { + t2 = SwigType_ltype(Getattr(p2, "type")); + if (Getattr(p2, "tmap:typecheck:SWIGTYPE")) { + SwigType_add_pointer(t2); + } + Setattr(p2, "ltype", t2); + } - /* Need subtype check here. If t2 is a subtype of t1, then we need to change the + /* Need subtype check here. If t2 is a subtype of t1, then we need to change the order */ - if (SwigType_issubtype(t2,t1)) { - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } + if (SwigType_issubtype(t2, t1)) { + Overloaded t = nodes[i]; + nodes[i] = nodes[j]; + nodes[j] = t; + } - if (Strcmp(t1,t2) != 0) { - differ = 1; - break; - } - } else if (differ) { - break; - } - if (Getattr(p1,"tmap:in:next")) { - p1 = Getattr(p1,"tmap:in:next"); - } else { - p1 = nextSibling(p1); - } - if (Getattr(p2,"tmap:in:next")) { - p2 = Getattr(p2,"tmap:in:next"); - } else { - p2 = nextSibling(p2); - } - } - if (!differ) { - /* See if declarations differ by const only */ - String *d1 = Getattr(nodes[i].n, "decl"); - String *d2 = Getattr(nodes[j].n, "decl"); - if (d1 && d2) { - String *dq1 = Copy(d1); - String *dq2 = Copy(d2); - if (SwigType_isconst(d1)) { - Delete(SwigType_pop(dq1)); - } - if (SwigType_isconst(d2)) { - Delete(SwigType_pop(dq2)); - } - if (Strcmp(dq1, dq2) == 0) { + if (Strcmp(t1, t2) != 0) { + differ = 1; + break; + } + } else if (differ) { + break; + } + if (Getattr(p1, "tmap:in:next")) { + p1 = Getattr(p1, "tmap:in:next"); + } else { + p1 = nextSibling(p1); + } + if (Getattr(p2, "tmap:in:next")) { + p2 = Getattr(p2, "tmap:in:next"); + } else { + p2 = nextSibling(p2); + } + } + if (!differ) { + /* See if declarations differ by const only */ + String *d1 = Getattr(nodes[i].n, "decl"); + String *d2 = Getattr(nodes[j].n, "decl"); + if (d1 && d2) { + String *dq1 = Copy(d1); + String *dq2 = Copy(d2); + if (SwigType_isconst(d1)) { + Delete(SwigType_pop(dq1)); + } + if (SwigType_isconst(d2)) { + Delete(SwigType_pop(dq2)); + } + if (Strcmp(dq1, dq2) == 0) { - if (SwigType_isconst(d1) && !SwigType_isconst(d2)) { - if (script_lang_wrapping) { - // Swap nodes so that the const method gets ignored (shadowed by the non-const method) - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } - differ = 1; - if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), - "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), - "using %s instead.\n", Swig_name_decl(nodes[i].n)); - } - } - nodes[j].error = 1; - } else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) { - differ = 1; - if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), - "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), - "using %s instead.\n", Swig_name_decl(nodes[i].n)); - } - } - nodes[j].error = 1; - } - } - Delete(dq1); - Delete(dq2); - } - } - if (!differ) { - if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n), - "as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), - "using %s instead.\n", Swig_name_decl(nodes[i].n)); - } - nodes[j].error = 1; - } - } - } + if (SwigType_isconst(d1) && !SwigType_isconst(d2)) { + if (script_lang_wrapping) { + // Swap nodes so that the const method gets ignored (shadowed by the non-const method) + Overloaded t = nodes[i]; + nodes[i] = nodes[j]; + nodes[j] = t; + } + differ = 1; + if (!nodes[j].error) { + if (script_lang_wrapping) { + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), + "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); + } else { + if (!Getattr(nodes[j].n, "overload:ignore")) + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); + } + } + nodes[j].error = 1; + } else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) { + differ = 1; + if (!nodes[j].error) { + if (script_lang_wrapping) { + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), + "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); + } else { + if (!Getattr(nodes[j].n, "overload:ignore")) + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); + } + } + nodes[j].error = 1; + } + } + Delete(dq1); + Delete(dq2); + } + } + if (!differ) { + if (!nodes[j].error) { + if (script_lang_wrapping) { + Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n), "as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n)); + } else { + if (!Getattr(nodes[j].n, "overload:ignore")) + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); + } + nodes[j].error = 1; + } + } + } } } } @@ -1539,7 +1589,7 @@ List * R::Swig_overload_rank(Node *n, for (i = 0; i < nnodes; i++) { if (nodes[i].error) Setattr(nodes[i].n, "overload:ignore", "1"); - Append(result,nodes[i].n); + Append(result, nodes[i].n); // Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms)); // Swig_print_node(nodes[i].n); } @@ -1551,37 +1601,33 @@ void R::dispatchFunction(Node *n) { Wrapper *f = NewWrapper(); String *symname = Getattr(n, "sym:name"); String *nodeType = Getattr(n, "nodeType"); - bool constructor = (!Cmp(nodeType, "constructor")); + bool constructor = (!Cmp(nodeType, "constructor")); String *sfname = NewString(symname); if (constructor) Replace(sfname, "new_", "", DOH_REPLACE_FIRST); - Printf(f->def, - "`%s` <- function(...) {", sfname); + Printf(f->def, "`%s` <- function(...) {", sfname); if (debugMode) { Swig_print_node(n); } List *dispatch = Swig_overload_rank(n, true); - int nfunc = Len(dispatch); - Printv(f->code, - "argtypes <- mapply(class, list(...));\n", - "argv <- list(...);\n", - "argc <- length(argtypes);\n", NIL ); + int nfunc = Len(dispatch); + Printv(f->code, "argtypes <- mapply(class, list(...));\n", "argv <- list(...);\n", "argc <- length(argtypes);\n", NIL); Printf(f->code, "# dispatch functions %d\n", nfunc); int cur_args = -1; bool first_compare = true; - for (int i=0; i < nfunc; i++) { - Node *ni = Getitem(dispatch,i); - Parm *pi = Getattr(ni,"wrap:parms"); + for (int i = 0; i < nfunc; i++) { + Node *ni = Getitem(dispatch, i); + Parm *pi = Getattr(ni, "wrap:parms"); int num_arguments = emit_num_arguments(pi); - String *overname = Getattr(ni,"sym:overname"); + String *overname = Getattr(ni, "sym:overname"); if (cur_args != num_arguments) { if (cur_args != -1) { - Printv(f->code, "} else ", NIL); + Printv(f->code, "} else ", NIL); } Printf(f->code, "if (argc == %d) {", num_arguments); cur_args = num_arguments; @@ -1591,67 +1637,52 @@ void R::dispatchFunction(Node *n) { int j; if (num_arguments > 0) { if (!first_compare) { - Printv(f->code, " else ", NIL); + Printv(f->code, " else ", NIL); } else { - first_compare = false; + first_compare = false; } Printv(f->code, "if (", NIL); - for (p =pi, j = 0 ; j < num_arguments ; j++) { - if (debugMode) { - Swig_print_node(p); - } - String *tm = Swig_typemap_lookup("rtype", p, "", 0); - if(tm) { - replaceRClass(tm, Getattr(p, "type")); - } + for (p = pi, j = 0; j < num_arguments; j++) { + if (debugMode) { + Swig_print_node(p); + } + String *tm = Swig_typemap_lookup("rtype", p, "", 0); + if (tm) { + replaceRClass(tm, Getattr(p, "type")); + } - String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0); - if (tmcheck) { - String *tmp = NewString(""); - Printf(tmp, "argv[[%d]]", j+1); - Replaceall(tmcheck, "$arg", tmp); - Printf(tmp, "argtype[%d]", j+1); - Replaceall(tmcheck, "$argtype", tmp); - if (tm) { - Replaceall(tmcheck, "$rtype", tm); - } - if (debugMode) { - Printf(stdout, "%s\n", tmcheck); - } - Printf(f->code, "%s(%s)", - j == 0? "" : " && ", - tmcheck); - p = Getattr(p, "tmap:in:next"); - continue; - } - if (tm) { - if (Strcmp(tm,"numeric")==0) { - Printf(f->code, "%sis.numeric(argv[[%d]])", - j == 0 ? "" : " && ", - j+1); - } - else if (Strcmp(tm,"integer")==0) { - Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))", - j == 0 ? "" : " && ", - j+1, j+1); - } - else if (Strcmp(tm,"character")==0) { - Printf(f->code, "%sis.character(argv[[%d]])", - j == 0 ? "" : " && ", - j+1); - } - else { - Printf(f->code, "%sextends(argtypes[%d], '%s')", - j == 0 ? "" : " && ", - j+1, - tm); - } - } - if (!SwigType_ispointer(Getattr(p, "type"))) { - Printf(f->code, " && length(argv[[%d]]) == 1", - j+1); - } - p = Getattr(p, "tmap:in:next"); + String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0); + if (tmcheck) { + String *tmp = NewString(""); + Printf(tmp, "argv[[%d]]", j + 1); + Replaceall(tmcheck, "$arg", tmp); + Printf(tmp, "argtype[%d]", j + 1); + Replaceall(tmcheck, "$argtype", tmp); + if (tm) { + Replaceall(tmcheck, "$rtype", tm); + } + if (debugMode) { + Printf(stdout, "%s\n", tmcheck); + } + Printf(f->code, "%s(%s)", j == 0 ? "" : " && ", tmcheck); + p = Getattr(p, "tmap:in:next"); + continue; + } + if (tm) { + if (Strcmp(tm, "numeric") == 0) { + Printf(f->code, "%sis.numeric(argv[[%d]])", j == 0 ? "" : " && ", j + 1); + } else if (Strcmp(tm, "integer") == 0) { + Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))", j == 0 ? "" : " && ", j + 1, j + 1); + } else if (Strcmp(tm, "character") == 0) { + Printf(f->code, "%sis.character(argv[[%d]])", j == 0 ? "" : " && ", j + 1); + } else { + Printf(f->code, "%sextends(argtypes[%d], '%s')", j == 0 ? "" : " && ", j + 1, tm); + } + } + if (!SwigType_ispointer(Getattr(p, "type"))) { + Printf(f->code, " && length(argv[[%d]]) == 1", j + 1); + } + p = Getattr(p, "tmap:in:next"); } Printf(f->code, ") { f <- %s%s; }\n", sfname, overname); } else { @@ -1659,10 +1690,7 @@ void R::dispatchFunction(Node *n) { } } if (cur_args != -1) { - Printf(f->code, "} else {\n" - "stop(\"cannot find overloaded function for %s with argtypes (\"," - "toString(argtypes),\")\");\n" - "}", sfname); + Printf(f->code, "} else {\n" "stop(\"cannot find overloaded function for %s with argtypes (\"," "toString(argtypes),\")\");\n" "}", sfname); } Printv(f->code, ";\nf(...)", NIL); Printv(f->code, ";\n}", NIL); @@ -1677,86 +1705,77 @@ void R::dispatchFunction(Node *n) { int R::functionWrapper(Node *n) { String *fname = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); - String *type = Getattr(n, "type"); - + String *type = Getattr(n, "type"); + if (debugMode) { - Printf(stdout, - " %s %s %s\n", fname, iname, type); + Printf(stdout, " %s %s %s\n", fname, iname, type); } String *overname = 0; String *nodeType = Getattr(n, "nodeType"); - bool constructor = (!Cmp(nodeType, "constructor")); - bool destructor = (!Cmp(nodeType, "destructor")); - + bool constructor = (!Cmp(nodeType, "constructor")); + bool destructor = (!Cmp(nodeType, "destructor")); + String *sfname = NewString(iname); - + if (constructor) Replace(sfname, "new_", "", DOH_REPLACE_FIRST); - - if (Getattr(n,"sym:overloaded")) { - overname = Getattr(n,"sym:overname"); + + if (Getattr(n, "sym:overloaded")) { + overname = Getattr(n, "sym:overname"); Append(sfname, overname); } - - if (debugMode) - Printf(stdout, - " processing parameters\n"); - - + + if (debugMode) + Printf(stdout, " processing parameters\n"); + + ParmList *l = Getattr(n, "parms"); Parm *p; String *tm; - + p = l; - while(p) { + while (p) { SwigType *resultType = Getattr(p, "type"); - if (expandTypedef(resultType) && - SwigType_istypedef(resultType)) { - SwigType *resolved = - SwigType_typedef_resolve_all(resultType); + if (expandTypedef(resultType) && SwigType_istypedef(resultType)) { + SwigType *resolved = SwigType_typedef_resolve_all(resultType); if (expandTypedef(resolved)) { - Setattr(p, "type", Copy(resolved)); + Setattr(p, "type", Copy(resolved)); } } p = nextSibling(p); - } + } - String *unresolved_return_type = - Copy(type); - if (expandTypedef(type) && - SwigType_istypedef(type)) { - SwigType *resolved = - SwigType_typedef_resolve_all(type); + String *unresolved_return_type = Copy(type); + if (expandTypedef(type) && SwigType_istypedef(type)) { + SwigType *resolved = SwigType_typedef_resolve_all(type); if (expandTypedef(resolved)) { type = Copy(resolved); Setattr(n, "type", type); } } - if (debugMode) - Printf(stdout, " unresolved_return_type %s\n", - unresolved_return_type); - if(processing_member_access_function) { + if (debugMode) + Printf(stdout, " unresolved_return_type %s\n", unresolved_return_type); + if (processing_member_access_function) { if (debugMode) - Printf(stdout, " '%s' '%s' '%s' '%s'\n", - fname, iname, member_name, class_name); - - if(opaqueClassDeclaration) + Printf(stdout, " '%s' '%s' '%s' '%s'\n", fname, iname, member_name, class_name); + + if (opaqueClassDeclaration) return SWIG_OK; - - - /* Add the name of this member to a list for this class_name. + + + /* Add the name of this member to a list for this class_name. We will dump all these at the end. */ - + int n = Len(iname); char *ptr = Char(iname); - bool isSet(Strcmp(NewString(&ptr[n-3]), "set") == 0); - - + bool isSet(Strcmp(NewString(&ptr[n - 3]), "set") == 0); + + String *tmp = NewString(""); Printf(tmp, "%s_%s", class_name, isSet ? "set" : "get"); - + List *memList = Getattr(ClassMemberTable, tmp); - if(!memList) { + if (!memList) { memList = NewList(); Append(memList, class_name); Setattr(ClassMemberTable, tmp, memList); @@ -1765,29 +1784,29 @@ int R::functionWrapper(Node *n) { Append(memList, member_name); Append(memList, iname); } - + int i; int nargs; - + String *wname = Swig_name_wrapper(iname); Replace(wname, "_wrap", "R_swig", DOH_REPLACE_FIRST); - if(overname) + if (overname) Append(wname, overname); - Setattr(n,"wrap:name", wname); + Setattr(n, "wrap:name", wname); Wrapper *f = NewWrapper(); Wrapper *sfun = NewWrapper(); - + int isVoidReturnType = (Strcmp(type, "void") == 0); - // Need to use the unresolved return type since - // typedef resolution removes the const which causes a + // Need to use the unresolved return type since + // typedef resolution removes the const which causes a // mismatch with the function action emit_return_variable(n, unresolved_return_type, f); SwigType *rtype = Getattr(n, "type"); int addCopyParam = 0; - if(!isVoidReturnType) + if (!isVoidReturnType) addCopyParam = addCopyParameter(rtype); @@ -1796,15 +1815,14 @@ int R::functionWrapper(Node *n) { // if(addCopyParam) if (debugMode) - Printf(stdout, "Adding a .copy argument to %s for %s = %s\n", - iname, type, addCopyParam ? "yes" : "no"); + Printf(stdout, "Adding a .copy argument to %s for %s = %s\n", iname, type, addCopyParam ? "yes" : "no"); Printv(f->def, "SWIGEXPORT SEXP\n", wname, " ( ", NIL); - Printf(sfun->def, "# Start of %s\n", iname); + Printf(sfun->def, "# Start of %s\n", iname); Printv(sfun->def, "\n`", sfname, "` = function(", NIL); - if(outputNamespaceInfo) //XXX Need to be a little more discriminating + if (outputNamespaceInfo) //XXX Need to be a little more discriminating addNamespaceFunction(iname); Swig_typemap_attach_parms("scoercein", l, f); @@ -1812,8 +1830,8 @@ int R::functionWrapper(Node *n) { Swig_typemap_attach_parms("scheck", l, f); emit_parameter_variables(l, f); - emit_attach_parmmaps(l,f); - Setattr(n,"wrap:parms",l); + emit_attach_parmmaps(l, f); + Setattr(n, "wrap:parms", l); nargs = emit_num_arguments(l); @@ -1829,7 +1847,7 @@ int R::functionWrapper(Node *n) { bool inFirstArg = true; bool inFirstType = true; Parm *curP; - for (p =l, i = 0 ; i < nargs ; i++) { + for (p = l, i = 0; i < nargs; i++) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); @@ -1840,26 +1858,26 @@ int R::functionWrapper(Node *n) { String *funcptr_name = processType(tt, p, &nargs); // SwigType *tp = Getattr(p, "type"); - String *name = Getattr(p,"name"); - String *lname = Getattr(p,"lname"); + String *name = Getattr(p, "name"); + String *lname = Getattr(p, "lname"); // R keyword renaming if (name) { if (Swig_name_warning(p, 0, name, 0)) { - name = 0; + name = 0; } else { - /* If we have a :: in the parameter name because we are accessing a static member of a class, say, then - we need to remove that prefix. */ - while (Strstr(name, "::")) { - //XXX need to free. - name = NewStringf("%s", Strchr(name, ':') + 2); - if (debugMode) - Printf(stdout, "+++ parameter name with :: in it %s\n", name); - } + /* If we have a :: in the parameter name because we are accessing a static member of a class, say, then + we need to remove that prefix. */ + while (Strstr(name, "::")) { + //XXX need to free. + name = NewStringf("%s", Strchr(name, ':') + 2); + if (debugMode) + Printf(stdout, "+++ parameter name with :: in it %s\n", name); + } } } if (!name || Len(name) == 0) - name = NewStringf("s_arg%d", i+1); + name = NewStringf("s_arg%d", i + 1); name = replaceInitialDash(name); @@ -1867,13 +1885,13 @@ int R::functionWrapper(Node *n) { name = Copy(name); Insert(name, 0, "s_"); } - - if(processing_variable) { + + if (processing_variable) { name = Copy(name); Insert(name, 0, "s_"); } - if(!Strcmp(name, fname)) { + if (!Strcmp(name, fname)) { name = Copy(name); Insert(name, 0, "s_"); } @@ -1881,79 +1899,73 @@ int R::functionWrapper(Node *n) { Printf(sargs, "%s, ", name); String *tm; - if((tm = Getattr(p, "tmap:scoercein"))) { + if ((tm = Getattr(p, "tmap:scoercein"))) { Replaceall(tm, "$input", name); replaceRClass(tm, Getattr(p, "type")); - if(funcptr_name) { - //XXX need to get this to return non-zero - if(nargs == -1) - nargs = getFunctionPointerNumArgs(p, tt); + if (funcptr_name) { + //XXX need to get this to return non-zero + if (nargs == -1) + nargs = getFunctionPointerNumArgs(p, tt); - String *snargs = NewStringf("%d", nargs); - Printv(sfun->code, "if(is.function(", name, ")) {", "\n", - "assert('...' %in% names(formals(", name, - ")) || length(formals(", name, ")) >= ", snargs, ");\n} ", NIL); - Delete(snargs); + String *snargs = NewStringf("%d", nargs); + Printv(sfun->code, "if(is.function(", name, ")) {", "\n", + "assert('...' %in% names(formals(", name, ")) || length(formals(", name, ")) >= ", snargs, ");\n} ", NIL); + Delete(snargs); - Printv(sfun->code, "else {\n", - "if(is.character(", name, ")) {\n", - name, " = getNativeSymbolInfo(", name, ");", - "\n};\n", - "if(is(", name, ", \"NativeSymbolInfo\")) {\n", - name, " = ", name, "$address", ";\n}\n", - "if(is(", name, ", \"ExternalReference\")) {\n", - name, " = ", name, "@ref;\n}\n", - "}; \n", - NIL); + Printv(sfun->code, "else {\n", + "if(is.character(", name, ")) {\n", + name, " = getNativeSymbolInfo(", name, ");", + "\n};\n", + "if(is(", name, ", \"NativeSymbolInfo\")) {\n", + name, " = ", name, "$address", ";\n}\n", "if(is(", name, ", \"ExternalReference\")) {\n", name, " = ", name, "@ref;\n}\n", "}; \n", NIL); } else { - Printf(sfun->code, "%s\n", tm); + Printf(sfun->code, "%s\n", tm); } } Printv(sfun->def, inFirstArg ? "" : ", ", name, NIL); - if ((tm = Getattr(p,"tmap:scheck"))) { + if ((tm = Getattr(p, "tmap:scheck"))) { - Replaceall(tm,"$target", lname); - Replaceall(tm,"$source", name); - Replaceall(tm,"$input", name); + Replaceall(tm, "$target", lname); + Replaceall(tm, "$source", name); + Replaceall(tm, "$input", name); replaceRClass(tm, Getattr(p, "type")); - Printf(sfun->code,"%s\n",tm); + Printf(sfun->code, "%s\n", tm); } curP = p; - if ((tm = Getattr(p,"tmap:in"))) { + if ((tm = Getattr(p, "tmap:in"))) { - Replaceall(tm,"$target", lname); - Replaceall(tm,"$source", name); - Replaceall(tm,"$input", name); + Replaceall(tm, "$target", lname); + Replaceall(tm, "$source", name); + Replaceall(tm, "$input", name); - if (Getattr(p,"wrap:disown") || (Getattr(p,"tmap:in:disown"))) { - Replaceall(tm,"$disown","SWIG_POINTER_DISOWN"); + if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) { + Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); } else { - Replaceall(tm,"$disown","0"); + Replaceall(tm, "$disown", "0"); } - if(funcptr_name) { - /* have us a function pointer */ - Printf(f->code, "if(TYPEOF(%s) != CLOSXP) {\n", name); - Replaceall(tm,"$R_class", ""); + if (funcptr_name) { + /* have us a function pointer */ + Printf(f->code, "if(TYPEOF(%s) != CLOSXP) {\n", name); + Replaceall(tm, "$R_class", ""); } else { - replaceRClass(tm, Getattr(p, "type")); + replaceRClass(tm, Getattr(p, "type")); } - Printf(f->code,"%s\n",tm); - if(funcptr_name) - Printf(f->code, "} else {\n%s = %s;\nR_SWIG_pushCallbackFunctionData(%s, NULL);\n}\n", - lname, funcptr_name, name); + Printf(f->code, "%s\n", tm); + if (funcptr_name) + Printf(f->code, "} else {\n%s = %s;\nR_SWIG_pushCallbackFunctionData(%s, NULL);\n}\n", lname, funcptr_name, name); Printv(f->def, inFirstArg ? "" : ", ", "SEXP ", name, NIL); - if (Len(name) != 0) - inFirstArg = false; - p = Getattr(p,"tmap:in:next"); + if (Len(name) != 0) + inFirstArg = false; + p = Getattr(p, "tmap:in:next"); } else { p = nextSibling(p); @@ -1961,18 +1973,18 @@ int R::functionWrapper(Node *n) { tm = Swig_typemap_lookup("rtype", curP, "", 0); - if(tm) { + if (tm) { replaceRClass(tm, Getattr(curP, "type")); } Printf(s_inputTypes, "%s'%s'", inFirstType ? "" : ", ", tm); Printf(s_inputMap, "%s%s='%s'", inFirstType ? "" : ", ", name, tm); inFirstType = false; - if(funcptr_name) + if (funcptr_name) Delete(funcptr_name); - } /* end of looping over parameters. */ + } /* end of looping over parameters. */ - if(addCopyParam) { + if (addCopyParam) { Printf(sfun->def, "%s.copy = FALSE", nargs > 0 ? ", " : ""); Printf(f->def, "%sSEXP s_swig_copy", nargs > 0 ? ", " : ""); @@ -1997,21 +2009,21 @@ int R::functionWrapper(Node *n) { String *outargs = NewString(""); int numOutArgs = isVoidReturnType ? -1 : 0; - for(p = l, i = 0; p; i++) { - if((tm = Getattr(p, "tmap:argout"))) { + for (p = l, i = 0; p; i++) { + if ((tm = Getattr(p, "tmap:argout"))) { // String *lname = Getattr(p, "lname"); numOutArgs++; String *pos = NewStringf("%d", numOutArgs); - Replaceall(tm,"$source", Getattr(p, "lname")); - Replaceall(tm,"$result", "r_ans"); - Replaceall(tm,"$n", pos); // The position into which to store the answer. - Replaceall(tm,"$arg", Getattr(p, "emit:input")); - Replaceall(tm,"$input", Getattr(p, "emit:input")); - Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); + Replaceall(tm, "$source", Getattr(p, "lname")); + Replaceall(tm, "$result", "r_ans"); + Replaceall(tm, "$n", pos); // The position into which to store the answer. + Replaceall(tm, "$arg", Getattr(p, "emit:input")); + Replaceall(tm, "$input", Getattr(p, "emit:input")); + Replaceall(tm, "$owner", "R_SWIG_EXTERNAL"); Printf(outargs, "%s\n", tm); - p = Getattr(p,"tmap:argout:next"); + p = Getattr(p, "tmap:argout:next"); } else p = nextSibling(p); } @@ -2019,60 +2031,57 @@ int R::functionWrapper(Node *n) { String *actioncode = emit_action(n); /* Deal with the explicit return value. */ - if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { SwigType *retType = Getattr(n, "type"); - //Printf(stdout, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no"); + //Printf(stdout, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no"); /* if(SwigType_isarray(retType)) { - defineArrayAccessors(retType); - } */ + defineArrayAccessors(retType); + } */ - Replaceall(tm,"$1", Swig_cresult_name()); - Replaceall(tm,"$result", "r_ans"); + Replaceall(tm, "$1", Swig_cresult_name()); + Replaceall(tm, "$result", "r_ans"); replaceRClass(tm, retType); - if (GetFlag(n,"feature:new")) { + if (GetFlag(n, "feature:new")) { Replaceall(tm, "$owner", "R_SWIG_OWNER"); } else { - Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); + Replaceall(tm, "$owner", "R_SWIG_EXTERNAL"); } #if 0 - if(addCopyParam) { + if (addCopyParam) { Printf(f->code, "if(LOGICAL(s_swig_copy)[0]) {\n"); Printf(f->code, "/* Deal with returning a reference. */\nr_ans = R_NilValue;\n"); Printf(f->code, "}\n else {\n"); - } + } #endif Printf(f->code, "%s\n", tm); #if 0 - if(addCopyParam) - Printf(f->code, "}\n"); /* end of if(s_swig_copy) ... else { ... } */ + if (addCopyParam) + Printf(f->code, "}\n"); /* end of if(s_swig_copy) ... else { ... } */ #endif } else { - Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, - "Unable to use return type %s in function %s.\n", SwigType_str(type, 0), fname); + Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(type, 0), fname); } - if(Len(outargs)) { + if (Len(outargs)) { Wrapper_add_local(f, "R_OutputValues", "SEXP R_OutputValues"); String *tmp = NewString(""); - if(!isVoidReturnType) + if (!isVoidReturnType) Printf(tmp, "Rf_protect(r_ans);\n"); - Printf(tmp, "Rf_protect(R_OutputValues = Rf_allocVector(VECSXP,%d));\nr_nprotect += %d;\n", - numOutArgs + !isVoidReturnType, - isVoidReturnType ? 1 : 2); + Printf(tmp, "Rf_protect(R_OutputValues = Rf_allocVector(VECSXP,%d));\nr_nprotect += %d;\n", numOutArgs + !isVoidReturnType, isVoidReturnType ? 1 : 2); - if(!isVoidReturnType) + if (!isVoidReturnType) Printf(tmp, "SET_VECTOR_ELT(R_OutputValues, 0, r_ans);\n"); Printf(tmp, "r_ans = R_OutputValues;\n"); Insert(outargs, 0, tmp); - Delete(tmp); + Delete(tmp); @@ -2088,7 +2097,7 @@ int R::functionWrapper(Node *n) { /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { - Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ + Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } @@ -2097,26 +2106,23 @@ int R::functionWrapper(Node *n) { /*If the user gave us something to convert the result in */ if ((tm = Swig_typemap_lookup("scoerceout", n, Swig_cresult_name(), sfun))) { - Replaceall(tm,"$source","ans"); - Replaceall(tm,"$result","ans"); + Replaceall(tm, "$source", "ans"); + Replaceall(tm, "$result", "ans"); replaceRClass(tm, Getattr(n, "type")); Chop(tm); } - Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname, - "', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL); - if(Len(tm)) - { - Printf(sfun->code, "%s\n\n", tm); - if (constructor) - { - String *finalizer = NewString(iname); - Replace(finalizer, "new_", "", DOH_REPLACE_FIRST); - Printf(sfun->code, "reg.finalizer(ans@ref, delete_%s)\n", finalizer); - } - Printf(sfun->code, "ans\n"); + Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname, "', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL); + if (Len(tm)) { + Printf(sfun->code, "%s\n\n", tm); + if (constructor) { + String *finalizer = NewString(iname); + Replace(finalizer, "new_", "", DOH_REPLACE_FIRST); + Printf(sfun->code, "reg.finalizer(ans@ref, delete_%s)\n", finalizer); } + Printf(sfun->code, "ans\n"); + } if (destructor) Printv(f->code, "R_ClearExternalPtr(self);\n", NIL); @@ -2125,27 +2131,23 @@ int R::functionWrapper(Node *n) { Printv(sfun->code, "\n}", NIL); /* Substitute the function name */ - Replaceall(f->code,"$symname",iname); + Replaceall(f->code, "$symname", iname); Wrapper_print(f, f_wrapper); Wrapper_print(sfun, sfile); Printf(sfun->code, "\n# End of %s\n", iname); tm = Swig_typemap_lookup("rtype", n, "", 0); - if(tm) { + if (tm) { SwigType *retType = Getattr(n, "type"); replaceRClass(tm, retType); - } - - Printv(sfile, "attr(`", sfname, "`, 'returnType') = '", - isVoidReturnType ? "void" : (tm ? tm : ""), - "'\n", NIL); - - if(nargs > 0) - Printv(sfile, "attr(`", sfname, "`, \"inputTypes\") = c(", - s_inputTypes, ")\n", NIL); - Printv(sfile, "class(`", sfname, "`) = c(\"SWIGFunction\", class('", - sfname, "'))\n\n", NIL); + } + + Printv(sfile, "attr(`", sfname, "`, 'returnType') = '", isVoidReturnType ? "void" : (tm ? tm : ""), "'\n", NIL); + + if (nargs > 0) + Printv(sfile, "attr(`", sfname, "`, \"inputTypes\") = c(", s_inputTypes, ")\n", NIL); + Printv(sfile, "class(`", sfname, "`) = c(\"SWIGFunction\", class('", sfname, "'))\n\n", NIL); if (memoryProfile) { Printv(sfile, "memory.profile()\n", NIL); @@ -2153,26 +2155,24 @@ int R::functionWrapper(Node *n) { if (aggressiveGc) { Printv(sfile, "gc()\n", NIL); } - // Printv(sfile, "setMethod('", name, "', '", name, "', ", iname, ")\n\n\n"); - /* If we are dealing with a method in an C++ class, then - add the name of the R function and its definition. + /* If we are dealing with a method in an C++ class, then + add the name of the R function and its definition. XXX need to figure out how to store the Wrapper if possible in the hash/list. Would like to be able to do this so that we can potentially insert - */ - if(processing_member_access_function || processing_class_member_function) { + */ + if (processing_member_access_function || processing_class_member_function) { addAccessor(member_name, sfun, iname); } - if (Getattr(n, "sym:overloaded") && - !Getattr(n, "sym:nextSibling")) { + if (Getattr(n, "sym:overloaded") && !Getattr(n, "sym:nextSibling")) { dispatchFunction(n); } - addRegistrationRoutine(wname, addCopyParam ? nargs +1 : nargs); + addRegistrationRoutine(wname, addCopyParam ? nargs + 1 : nargs); DelWrapper(f); DelWrapper(sfun); @@ -2193,21 +2193,20 @@ int R::constantWrapper(Node *n) { } /***************************************************** - Add the specified routine name to the collection of + Add the specified routine name to the collection of generated routines that are called from R functions. - This is used to register the routines with R for + This is used to register the routines with R for resolving symbols. rname - the name of the routine - nargs - the number of arguments it expects. + nargs - the number of arguments it expects. ******************************************************/ int R::addRegistrationRoutine(String *rname, int nargs) { - if(!registrationTable) + if (!registrationTable) registrationTable = NewHash(); - String *el = - NewStringf("{\"%s\", (DL_FUNC) &%s, %d}", rname, rname, nargs); - + String *el = NewStringf("{\"%s\", (DL_FUNC) &%s, %d}", rname, rname, nargs); + Setattr(registrationTable, rname, el); return SWIG_OK; @@ -2220,30 +2219,30 @@ int R::addRegistrationRoutine(String *rname, int nargs) { ******************************************************/ int R::outputRegistrationRoutines(File *out) { int i, n; - if(!registrationTable) - return(0); - if(inCPlusMode) + if (!registrationTable) + return (0); + if (inCPlusMode) Printf(out, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n"); Printf(out, "#include \n\n"); - if(inCPlusMode) + if (inCPlusMode) Printf(out, "#ifdef __cplusplus\n}\n#endif\n\n"); Printf(out, "SWIGINTERN R_CallMethodDef CallEntries[] = {\n"); - + List *keys = Keys(registrationTable); n = Len(keys); - for(i = 0; i < n; i++) + for (i = 0; i < n; i++) Printf(out, " %s,\n", Getattr(registrationTable, Getitem(keys, i))); Printf(out, " {NULL, NULL, 0}\n};\n\n"); - if(!noInitializationCode) { + if (!noInitializationCode) { if (inCPlusMode) Printv(out, "extern \"C\" ", NIL); Printf(out, "SWIGEXPORT void R_init_%s(DllInfo *dll) {\n", Rpackage); Printf(out, "%sR_registerRoutines(dll, NULL, CallEntries, NULL, NULL);\n", tab4); - if(Len(s_init_routine)) { + if (Len(s_init_routine)) { Printf(out, "\n%s\n", s_init_routine); } Printf(out, "}\n"); @@ -2257,60 +2256,58 @@ int R::outputRegistrationRoutines(File *out) { /**************************************************************************** Process a struct, union or class declaration in the source code, or an anonymous typedef struct - + *****************************************************************************/ -//XXX What do we need to do here - +//XXX What do we need to do here - // Define an S4 class to refer to this. void R::registerClass(Node *n) { - String *name = Getattr(n, "name"); - String *kind = Getattr(n, "kind"); + String *name = Getattr(n, "name"); + String *kind = Getattr(n, "kind"); if (debugMode) Swig_print_node(n); String *sname = NewStringf("_p%s", SwigType_manglestr(name)); - if(!Getattr(SClassDefs, sname)) { + if (!Getattr(SClassDefs, sname)) { Setattr(SClassDefs, sname, sname); String *base; - if(Strcmp(kind, "class") == 0) { + if (Strcmp(kind, "class") == 0) { base = NewString(""); List *l = Getattr(n, "bases"); - if(Len(l)) { - Printf(base, "c("); - for(int i = 0; i < Len(l); i++) { - registerClass(Getitem(l, i)); - Printf(base, "'_p%s'%s", - SwigType_manglestr(Getattr(Getitem(l, i), "name")), - i < Len(l)-1 ? ", " : ""); - } - Printf(base, ")"); + if (Len(l)) { + Printf(base, "c("); + for (int i = 0; i < Len(l); i++) { + registerClass(Getitem(l, i)); + Printf(base, "'_p%s'%s", SwigType_manglestr(Getattr(Getitem(l, i), "name")), i < Len(l) - 1 ? ", " : ""); + } + Printf(base, ")"); } else { - base = NewString("'C++Reference'"); + base = NewString("'C++Reference'"); } - } else + } else base = NewString("'ExternalReference'"); Printf(s_classes, "setClass('%s', contains = %s)\n", sname, base); Delete(base); } - + } int R::classDeclaration(Node *n) { - String *name = Getattr(n, "name"); - String *kind = Getattr(n, "kind"); + String *name = Getattr(n, "name"); + String *kind = Getattr(n, "kind"); if (debugMode) Swig_print_node(n); registerClass(n); - + /* If we have a typedef union { ... } U, then we never get to see the typedef via a regular call to typedefHandler. Instead, */ - if(Getattr(n, "unnamed") && Getattr(n, "storage") && Strcmp(Getattr(n, "storage"), "typedef") == 0 - && Getattr(n, "tdname") && Strcmp(Getattr(n, "tdname"), name) == 0) { + if (Getattr(n, "unnamed") && Getattr(n, "storage") && Strcmp(Getattr(n, "storage"), "typedef") == 0 + && Getattr(n, "tdname") && Strcmp(Getattr(n, "tdname"), name) == 0) { if (debugMode) Printf(stdout, "Typedef in the class declaration for %s\n", name); // typedefHandler(n); @@ -2318,7 +2315,7 @@ int R::classDeclaration(Node *n) { bool opaque = GetFlag(n, "feature:opaque") ? true : false; - if(opaque) + if (opaque) opaqueClassDeclaration = name; int status = Language::classDeclaration(n); @@ -2326,76 +2323,72 @@ int R::classDeclaration(Node *n) { opaqueClassDeclaration = NULL; - // OutputArrayMethod(name, class_member_functions, sfile); + // OutputArrayMethod(name, class_member_functions, sfile); if (class_member_functions) OutputMemberReferenceMethod(name, 0, class_member_functions, sfile); if (class_member_set_functions) OutputMemberReferenceMethod(name, 1, class_member_set_functions, sfile); - if(class_member_functions) { + if (class_member_functions) { Delete(class_member_functions); class_member_functions = NULL; } - if(class_member_set_functions) { + if (class_member_set_functions) { Delete(class_member_set_functions); class_member_set_functions = NULL; } if (Getattr(n, "has_destructor")) { - Printf(sfile, "setMethod('delete', '_p%s', function(obj) {delete%s(obj)})\n", - getRClassName(Getattr(n, "name")), - getRClassName(Getattr(n, "name"))); + Printf(sfile, "setMethod('delete', '_p%s', function(obj) {delete%s(obj)})\n", getRClassName(Getattr(n, "name")), getRClassName(Getattr(n, "name"))); } - if(!opaque && !Strcmp(kind, "struct") && copyStruct) { + if (!opaque && !Strcmp(kind, "struct") && copyStruct) { - String *def = - NewStringf("setClass(\"%s\",\n%srepresentation(\n", name, tab4); + String *def = NewStringf("setClass(\"%s\",\n%srepresentation(\n", name, tab4); bool firstItem = true; - for(Node *c = firstChild(n); c; ) { + for (Node *c = firstChild(n); c;) { String *elName; String *tp; elName = Getattr(c, "name"); - + String *elKind = Getattr(c, "kind"); if (!Equal(elKind, "variable")) { - c = nextSibling(c); - continue; + c = nextSibling(c); + continue; } if (!Len(elName)) { - c = nextSibling(c); - continue; + c = nextSibling(c); + continue; } #if 0 tp = getRType(c); #else tp = Swig_typemap_lookup("rtype", c, "", 0); - if(!tp) { - c = nextSibling(c); - continue; + if (!tp) { + c = nextSibling(c); + continue; } if (Strstr(tp, "R_class")) { - c = nextSibling(c); - continue; + c = nextSibling(c); + continue; } - if (Strcmp(tp, "character") && - Strstr(Getattr(c, "decl"), "p.")) { - c = nextSibling(c); - continue; + if (Strcmp(tp, "character") && Strstr(Getattr(c, "decl"), "p.")) { + c = nextSibling(c); + continue; } if (!firstItem) { - Printf(def, ",\n"); - } - // else + Printf(def, ",\n"); + } + // else //XXX How can we tell if this is already done. - // SwigType_push(elType, elDecl); - - + // SwigType_push(elType, elDecl); + + // returns "" tp = processType(elType, c, NULL); - // Printf(stdout, " elType %p\n", elType); - // tp = getRClassNameCopyStruct(Getattr(c, "type"), 1); + // Printf(stdout, " elType %p\n", elType); + // tp = getRClassNameCopyStruct(Getattr(c, "type"), 1); #endif String *elNameT = replaceInitialDash(elName); Printf(def, "%s%s = \"%s\"", tab8, elNameT, tp); @@ -2431,13 +2424,13 @@ int R::classDeclaration(Node *n) { int R::generateCopyRoutines(Node *n) { Wrapper *copyToR = NewWrapper(); Wrapper *copyToC = NewWrapper(); - + String *name = Getattr(n, "name"); String *tdname = Getattr(n, "tdname"); String *kind = Getattr(n, "kind"); String *type; - if(Len(tdname)) { + if (Len(tdname)) { type = Copy(tdname); } else { type = NewStringf("%s %s", kind, name); @@ -2448,14 +2441,12 @@ int R::generateCopyRoutines(Node *n) { if (debugMode) Printf(stdout, "generateCopyRoutines: name = %s, %s\n", name, type); - Printf(copyToR->def, "CopyToR%s = function(value, obj = new(\"%s\"))\n{\n", - mangledName, name); - Printf(copyToC->def, "CopyToC%s = function(value, obj)\n{\n", - mangledName); + Printf(copyToR->def, "CopyToR%s = function(value, obj = new(\"%s\"))\n{\n", mangledName, name); + Printf(copyToC->def, "CopyToC%s = function(value, obj)\n{\n", mangledName); Node *c = firstChild(n); - for(; c; c = nextSibling(c)) { + for (; c; c = nextSibling(c)) { String *elName = Getattr(c, "name"); if (!Len(elName)) { continue; @@ -2466,14 +2457,13 @@ int R::generateCopyRoutines(Node *n) { } String *tp = Swig_typemap_lookup("rtype", c, "", 0); - if(!tp) { + if (!tp) { continue; } if (Strstr(tp, "R_class")) { continue; } - if (Strcmp(tp, "character") && - Strstr(Getattr(c, "decl"), "p.")) { + if (Strcmp(tp, "character") && Strstr(Getattr(c, "decl"), "p.")) { continue; } @@ -2485,26 +2475,25 @@ int R::generateCopyRoutines(Node *n) { Delete(elNameT); } Printf(copyToR->code, "obj;\n}\n\n"); - String *rclassName = getRClassNameCopyStruct(type, 0); // without the Ref. - Printf(sfile, "# Start definition of copy functions & methods for %s\n", rclassName); - + String *rclassName = getRClassNameCopyStruct(type, 0); // without the Ref. + Printf(sfile, "# Start definition of copy functions & methods for %s\n", rclassName); + Wrapper_print(copyToR, sfile); Printf(copyToC->code, "obj\n}\n\n"); Wrapper_print(copyToC, sfile); - - - Printf(sfile, "# Start definition of copy methods for %s\n", rclassName); - Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s);\n", rclassName, - mangledName); - Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s);\n\n", rclassName, - mangledName); - - Printf(sfile, "# End definition of copy methods for %s\n", rclassName); - Printf(sfile, "# End definition of copy functions & methods for %s\n", rclassName); - + + + Printf(sfile, "# Start definition of copy methods for %s\n", rclassName); + Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s);\n", rclassName, mangledName); + Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s);\n\n", rclassName, mangledName); + + Printf(sfile, "# End definition of copy methods for %s\n", rclassName); + Printf(sfile, "# End definition of copy functions & methods for %s\n", rclassName); + String *m = NewStringf("%sCopyToR", name); addNamespaceMethod(m); - char *tt = Char(m); tt[Len(m)-1] = 'C'; + char *tt = Char(m); + tt[Len(m) - 1] = 'C'; addNamespaceMethod(m); Delete(m); Delete(rclassName); @@ -2518,9 +2507,9 @@ int R::generateCopyRoutines(Node *n) { /***** - Called when there is a typedef to be invoked. + Called when there is a typedef to be invoked. - XXX Needs to be enhanced or split to handle the case where we have a + XXX Needs to be enhanced or split to handle the case where we have a typedef within a classDeclaration emission because the struct/union/etc. is anonymous. ******/ @@ -2532,14 +2521,13 @@ int R::typedefHandler(Node *n) { processType(tp, n); - if(Strncmp(type, "struct ", 7) == 0) { + if (Strncmp(type, "struct ", 7) == 0) { String *name = Getattr(n, "name"); char *trueName = Char(type); trueName += 7; if (debugMode) Printf(stdout, " Defining S class %s\n", trueName); - Printf(s_classes, "setClass('_p%s', contains = 'ExternalReference')\n", - SwigType_manglestr(name)); + Printf(s_classes, "setClass('_p%s', contains = 'ExternalReference')\n", SwigType_manglestr(name)); } return Language::typedefHandler(n); @@ -2550,21 +2538,20 @@ int R::typedefHandler(Node *n) { /********************* Called when processing a field in a "class", i.e. struct, union or actual class. We set a state variable so that we can correctly - interpret the resulting functionWrapper() call and understand that + interpret the resulting functionWrapper() call and understand that it is for a field element. **********************/ int R::membervariableHandler(Node *n) { SwigType *t = Getattr(n, "type"); processType(t, n, NULL); processing_member_access_function = 1; - member_name = Getattr(n,"sym:name"); + member_name = Getattr(n, "sym:name"); if (debugMode) - Printf(stdout, " name = %s, sym:name = %s\n", - Getattr(n, "name"), member_name); + Printf(stdout, " name = %s, sym:name = %s\n", Getattr(n, "name"), member_name); int status(Language::membervariableHandler(n)); - if(!opaqueClassDeclaration && debugMode) + if (!opaqueClassDeclaration && debugMode) Printf(stdout, " %s %s\n", Getattr(n, "name"), Getattr(n, "type")); processing_member_access_function = 0; @@ -2577,7 +2564,7 @@ int R::membervariableHandler(Node *n) { /* This doesn't seem to get used so leave it out for the moment. */ -String * R::runtimeCode() { +String *R::runtimeCode() { String *s = Swig_include_sys("rrun.swg"); if (!s) { Printf(stdout, "*** Unable to open 'rrun.swg'\n"); @@ -2588,7 +2575,7 @@ String * R::runtimeCode() { /** - Called when SWIG wants to initialize this + Called when SWIG wants to initialize this We initialize anythin we want here. Most importantly, tell SWIG where to find the files (e.g. r.swg) for this module. Use Swig_mark_arg() to tell SWIG that it is understood and not to throw an error. @@ -2610,41 +2597,41 @@ void R::main(int argc, char *argv[]) { this->Argc = argc; this->Argv = argv; - allow_overloading();// can we support this? + allow_overloading(); // can we support this? - for(int i = 0; i < argc; i++) { - if(strcmp(argv[i], "-package") == 0) { + for (int i = 0; i < argc; i++) { + if (strcmp(argv[i], "-package") == 0) { Swig_mark_arg(i); i++; Swig_mark_arg(i); Rpackage = argv[i]; - } else if(strcmp(argv[i], "-dll") == 0) { + } else if (strcmp(argv[i], "-dll") == 0) { Swig_mark_arg(i); i++; Swig_mark_arg(i); DllName = argv[i]; - } else if(strcmp(argv[i], "-help") == 0) { + } else if (strcmp(argv[i], "-help") == 0) { showUsage(); - } else if(strcmp(argv[i], "-namespace") == 0) { + } else if (strcmp(argv[i], "-namespace") == 0) { outputNamespaceInfo = true; Swig_mark_arg(i); - } else if(!strcmp(argv[i], "-no-init-code")) { + } else if (!strcmp(argv[i], "-no-init-code")) { noInitializationCode = true; Swig_mark_arg(i); - } else if(!strcmp(argv[i], "-c++")) { + } else if (!strcmp(argv[i], "-c++")) { inCPlusMode = true; Swig_mark_arg(i); Printf(s_classes, "setClass('C++Reference', contains = 'ExternalReference')\n"); - } else if(!strcmp(argv[i], "-debug")) { + } else if (!strcmp(argv[i], "-debug")) { debugMode = true; Swig_mark_arg(i); - } else if (!strcmp(argv[i],"-cppcast")) { + } else if (!strcmp(argv[i], "-cppcast")) { cppcast = true; Swig_mark_arg(i); - } else if (!strcmp(argv[i],"-nocppcast")) { + } else if (!strcmp(argv[i], "-nocppcast")) { cppcast = false; Swig_mark_arg(i); - } else if (!strcmp(argv[i],"-copystruct")) { + } else if (!strcmp(argv[i], "-copystruct")) { copyStruct = true; Swig_mark_arg(i); } else if (!strcmp(argv[i], "-nocopystruct")) { @@ -2683,13 +2670,12 @@ void R::main(int argc, char *argv[]) { Could make this work for String or File and then just store the resulting string rather than the collection of arguments and argc. */ -int R::outputCommandLineArguments(File *out) -{ - if(Argc < 1 || !Argv || !Argv[0]) - return(-1); +int R::outputCommandLineArguments(File *out) { + if (Argc < 1 || !Argv || !Argv[0]) + return (-1); Printf(out, "\n## Generated via the command line invocation:\n##\t"); - for(int i = 0; i < Argc ; i++) { + for (int i = 0; i < Argc; i++) { Printf(out, " %s", Argv[i]); } Printf(out, "\n\n\n"); @@ -2699,10 +2685,9 @@ int R::outputCommandLineArguments(File *out) -/* How SWIG instantiates an object from this module. +/* How SWIG instantiates an object from this module. See swigmain.cxx */ -extern "C" -Language *swig_r(void) { +extern "C" Language *swig_r(void) { return new R(); } @@ -2713,55 +2698,50 @@ Language *swig_r(void) { /* Needs to be reworked. */ -String * R::processType(SwigType *t, Node *n, int *nargs) { +String *R::processType(SwigType *t, Node *n, int *nargs) { //XXX Need to handle typedefs, e.g. // a type which is a typedef to a function pointer. SwigType *tmp = Getattr(n, "tdname"); if (debugMode) Printf(stdout, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp); - + SwigType *td = t; - if (expandTypedef(t) && - SwigType_istypedef(t)) { - SwigType *resolved = - SwigType_typedef_resolve_all(t); + if (expandTypedef(t) && SwigType_istypedef(t)) { + SwigType *resolved = SwigType_typedef_resolve_all(t); if (expandTypedef(resolved)) { td = Copy(resolved); } } - if(!td) { + if (!td) { int count = 0; String *b = getRTypeName(t, &count); - if(count && b && !Getattr(SClassDefs, b)) { + if (count && b && !Getattr(SClassDefs, b)) { if (debugMode) - Printf(stdout, " Defining class %s\n", b); + Printf(stdout, " Defining class %s\n", b); - Printf(s_classes, "setClass('%s', contains = 'ExternalReference')\n", b); + Printf(s_classes, "setClass('%s', contains = 'ExternalReference')\n", b); Setattr(SClassDefs, b, b); } - + } - if(td) + if (td) t = td; - if(SwigType_isfunctionpointer(t)) { + if (SwigType_isfunctionpointer(t)) { if (debugMode) - Printf(stdout, - " Defining pointer handler %s\n", t); - + Printf(stdout, " Defining pointer handler %s\n", t); + String *tmp = createFunctionPointerHandler(t, n, nargs); return tmp; } - #if 0 SwigType_isfunction(t) && SwigType_ispointer(t) #endif - - return NULL; + return NULL; } @@ -2773,8 +2753,3 @@ String * R::processType(SwigType *t, Node *n, int *nargs) { /*************************************************************************************/ - - - - - From 8275f8158a04351c225a3cdad3787646391fe72a Mon Sep 17 00:00:00 2001 From: David Xu Date: Mon, 10 Aug 2015 21:47:05 -0400 Subject: [PATCH 072/732] Implement argout, freearg, and check typemaps for CFFI. --- Source/Modules/cffi.cxx | 91 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 2 deletions(-) diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 8f718e653..1068bcd4a 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -61,6 +61,11 @@ public: virtual int classHandler(Node *n); private: + static void checkConstraints(ParmList *parms, Wrapper *f); + static void argout(ParmList *parms, Wrapper *f); + static String *freearg(ParmList *parms); + static void cleanupFunction(Node *n, Wrapper *f, ParmList *parms); + void emit_defun(Node *n, String *name); void emit_defmethod(Node *n); void emit_initialize_instance(Node *n); @@ -364,6 +369,77 @@ int CFFI::membervariableHandler(Node *n) { return Language::membervariableHandler(n); } + +void CFFI::checkConstraints(ParmList *parms, Wrapper *f) { + Parm *p = parms; + while (p) { + String *tm = Getattr(p, "tmap:check"); + if (!tm) { + p = nextSibling(p); + } else { + tm = Copy(tm); + Replaceall(tm, "$input", Getattr(p, "emit:input")); + Printv(f->code, tm, "\n\n", NULL); + Delete(tm); + p = Getattr(p, "tmap:check:next"); + } + } +} + +void CFFI::argout(ParmList *parms, Wrapper *f) { + Parm *p = parms; + while (p) { + String *tm = Getattr(p, "tmap:argout"); + if (!tm) { + p = nextSibling(p); + } else { + tm = Copy(tm); + Replaceall(tm, "$result", Swig_cresult_name()); + Replaceall(tm, "$input", Getattr(p, "emit:input")); + Printv(f->code, tm, "\n", NULL); + Delete(tm); + p = Getattr(p, "tmap:argout:next"); + } + } +} + +String *CFFI::freearg(ParmList *parms) { + String *ret = NewString(""); + Parm *p = parms; + while (p) { + String *tm = Getattr(p, "tmap:freearg"); + if (!tm) { + p = nextSibling(p); + } else { + tm = Copy(tm); + Replaceall(tm, "$input", Getattr(p, "emit:input")); + Printv(ret, tm, "\n", NULL); + Delete(tm); + p = Getattr(p, "tmap:freearg:next"); + } + } + return ret; +} + +void CFFI::cleanupFunction(Node *n, Wrapper *f, ParmList *parms) { + String *cleanup = freearg(parms); + Printv(f->code, cleanup, NULL); + + if (GetFlag(n, "feature:new")) { + String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0); + if (tm) { + Replaceall(tm, "$source", Swig_cresult_name()); + Printv(f->code, tm, "\n", NULL); + Delete(tm); + } + } + + Replaceall(f->code, "$cleanup", cleanup); + Delete(cleanup); + + Replaceall(f->code, "$symname", Getattr(n, "sym:name")); +} + int CFFI::functionWrapper(Node *n) { ParmList *parms = Getattr(n, "parms"); @@ -451,6 +527,9 @@ int CFFI::functionWrapper(Node *n) { // Emit the function definition String *signature = SwigType_str(return_type, name_and_parms); Printf(f->def, "EXPORT %s {", signature); + + checkConstraints(parms, f); + Printf(f->code, " try {\n"); String *actioncode = emit_action(n); @@ -459,9 +538,17 @@ int CFFI::functionWrapper(Node *n) { if (result_convert) { Replaceall(result_convert, "$result", "lresult"); Printf(f->code, "%s\n", result_convert); - if(!is_void_return) Printf(f->code, " return lresult;\n"); - Delete(result_convert); } + Delete(result_convert); + + argout(parms, f); + + cleanupFunction(n, f, parms); + + if (!is_void_return) { + Printf(f->code, " return lresult;\n"); + } + emit_return_variable(n, Getattr(n, "type"), f); Printf(f->code, " } catch (...) {\n"); From 834a93f449bae04602c822cf8fd087814069772e Mon Sep 17 00:00:00 2001 From: Joseph C Wang Date: Tue, 11 Aug 2015 09:57:57 +0800 Subject: [PATCH 073/732] Revert "Merge pull request #494 from richardbeare/enumR2015B" This reverts commit cb8973f3139d4d31d731cd8020641a70c7c293b1, reversing changes made to ac3284f78c3af61027ffe4765ba50161670d929e. --- Examples/test-suite/r/Makefile.in | 3 +- .../test-suite/r/arrays_dimensionless_runme.R | 4 +- Examples/test-suite/r/funcptr_runme.R | 4 +- .../test-suite/r/ignore_parameter_runme.R | 4 +- Examples/test-suite/r/integers_runme.R | 4 +- Examples/test-suite/r/overload_method_runme.R | 4 +- .../test-suite/r/preproc_constants_runme.R | 11 - Examples/test-suite/r/r_copy_struct_runme.R | 4 +- Examples/test-suite/r/r_legacy_runme.R | 4 +- Examples/test-suite/r/r_sexp_runme.R | 4 +- Examples/test-suite/r/rename_simple_runme.R | 4 +- Examples/test-suite/r/simple_array_runme.R | 3 +- Examples/test-suite/r/unions_runme.R | 3 +- Source/Modules/r.cxx | 2065 +++++++++-------- 14 files changed, 1057 insertions(+), 1064 deletions(-) delete mode 100644 Examples/test-suite/r/preproc_constants_runme.R diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 2c9a2c3f2..d0489531f 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -5,7 +5,7 @@ LANGUAGE = r SCRIPTSUFFIX = _runme.R WRAPSUFFIX = .R -RUNR = R CMD BATCH --no-save --no-restore '--args $(SCRIPTDIR)' +RUNR = R CMD BATCH --no-save --no-restore srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -44,7 +44,6 @@ include $(srcdir)/../common.mk +$(swig_and_compile_multi_cpp) $(run_multitestcase) - # Runs the testcase. # # Run the runme if it exists. If not just load the R wrapper to diff --git a/Examples/test-suite/r/arrays_dimensionless_runme.R b/Examples/test-suite/r/arrays_dimensionless_runme.R index 4fc2541ff..9b97de2d8 100644 --- a/Examples/test-suite/r/arrays_dimensionless_runme.R +++ b/Examples/test-suite/r/arrays_dimensionless_runme.R @@ -1,6 +1,4 @@ -clargs <- commandArgs(trailing=TRUE) -source(file.path(clargs[1], "unittest.R")) - +source("unittest.R") dyn.load(paste("arrays_dimensionless", .Platform$dynlib.ext, sep="")) source("arrays_dimensionless.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/funcptr_runme.R b/Examples/test-suite/r/funcptr_runme.R index c6127ef68..3d5281bfa 100644 --- a/Examples/test-suite/r/funcptr_runme.R +++ b/Examples/test-suite/r/funcptr_runme.R @@ -1,6 +1,4 @@ -clargs <- commandArgs(trailing=TRUE) -source(file.path(clargs[1], "unittest.R")) - +source("unittest.R") dyn.load(paste("funcptr", .Platform$dynlib.ext, sep="")) source("funcptr.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/ignore_parameter_runme.R b/Examples/test-suite/r/ignore_parameter_runme.R index 612b70013..89e461d71 100644 --- a/Examples/test-suite/r/ignore_parameter_runme.R +++ b/Examples/test-suite/r/ignore_parameter_runme.R @@ -1,6 +1,4 @@ -clargs <- commandArgs(trailing=TRUE) -source(file.path(clargs[1], "unittest.R")) - +source("unittest.R") dyn.load(paste("ignore_parameter", .Platform$dynlib.ext, sep="")) source("ignore_parameter.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/integers_runme.R b/Examples/test-suite/r/integers_runme.R index 6e2f63b70..e31099a3b 100644 --- a/Examples/test-suite/r/integers_runme.R +++ b/Examples/test-suite/r/integers_runme.R @@ -1,6 +1,4 @@ -clargs <- commandArgs(trailing=TRUE) -source(file.path(clargs[1], "unittest.R")) - +source("unittest.R") dyn.load(paste("integers", .Platform$dynlib.ext, sep="")) source("integers.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/overload_method_runme.R b/Examples/test-suite/r/overload_method_runme.R index 790f3df10..afb590a74 100644 --- a/Examples/test-suite/r/overload_method_runme.R +++ b/Examples/test-suite/r/overload_method_runme.R @@ -1,6 +1,4 @@ -clargs <- commandArgs(trailing=TRUE) -source(file.path(clargs[1], "unittest.R")) - +source("unittest.R") dyn.load(paste("overload_method", .Platform$dynlib.ext, sep="")) source("overload_method.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/preproc_constants_runme.R b/Examples/test-suite/r/preproc_constants_runme.R deleted file mode 100644 index 2a4a601eb..000000000 --- a/Examples/test-suite/r/preproc_constants_runme.R +++ /dev/null @@ -1,11 +0,0 @@ -clargs <- commandArgs(trailing=TRUE) -source(file.path(clargs[1], "unittest.R")) - -dyn.load(paste("preproc_constants", .Platform$dynlib.ext, sep="")) -source("preproc_constants.R") -cacheMetaData(1) - -v <- enumToInteger('kValue', '_MyEnum') -print(v) -unittest(v,4) -q(save="no") diff --git a/Examples/test-suite/r/r_copy_struct_runme.R b/Examples/test-suite/r/r_copy_struct_runme.R index deadc61fe..21bd93b64 100644 --- a/Examples/test-suite/r/r_copy_struct_runme.R +++ b/Examples/test-suite/r/r_copy_struct_runme.R @@ -1,6 +1,4 @@ -clargs <- commandArgs(trailing=TRUE) -source(file.path(clargs[1], "unittest.R")) - +source("unittest.R") dyn.load(paste("r_copy_struct", .Platform$dynlib.ext, sep="")) source("r_copy_struct.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/r_legacy_runme.R b/Examples/test-suite/r/r_legacy_runme.R index 3ca229ff8..7e5ade87f 100644 --- a/Examples/test-suite/r/r_legacy_runme.R +++ b/Examples/test-suite/r/r_legacy_runme.R @@ -1,6 +1,4 @@ -clargs <- commandArgs(trailing=TRUE) -source(file.path(clargs[1], "unittest.R")) - +source("unittest.R") dyn.load(paste("r_legacy", .Platform$dynlib.ext, sep="")) source("r_legacy.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/r_sexp_runme.R b/Examples/test-suite/r/r_sexp_runme.R index e7b28a965..96b36e8af 100644 --- a/Examples/test-suite/r/r_sexp_runme.R +++ b/Examples/test-suite/r/r_sexp_runme.R @@ -1,6 +1,4 @@ -clargs <- commandArgs(trailing=TRUE) -source(file.path(clargs[1], "unittest.R")) - +source("unittest.R") dyn.load(paste("r_sexp", .Platform$dynlib.ext, sep="")) source("r_sexp.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/rename_simple_runme.R b/Examples/test-suite/r/rename_simple_runme.R index 0628ca6c9..b25aeb844 100644 --- a/Examples/test-suite/r/rename_simple_runme.R +++ b/Examples/test-suite/r/rename_simple_runme.R @@ -1,6 +1,4 @@ -clargs <- commandArgs(trailing=TRUE) -source(file.path(clargs[1], "unittest.R")) - +source("unittest.R") dyn.load(paste("rename_simple", .Platform$dynlib.ext, sep="")) source("rename_simple.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/simple_array_runme.R b/Examples/test-suite/r/simple_array_runme.R index fe70dc324..a6758dedd 100644 --- a/Examples/test-suite/r/simple_array_runme.R +++ b/Examples/test-suite/r/simple_array_runme.R @@ -1,5 +1,4 @@ -clargs <- commandArgs(trailing=TRUE) -source(file.path(clargs[1], "unittest.R")) +source("unittest.R") dyn.load(paste("simple_array", .Platform$dynlib.ext, sep="")) source("simple_array.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/unions_runme.R b/Examples/test-suite/r/unions_runme.R index fd148c7ef..76870d10c 100644 --- a/Examples/test-suite/r/unions_runme.R +++ b/Examples/test-suite/r/unions_runme.R @@ -1,5 +1,4 @@ -clargs <- commandArgs(trailing=TRUE) -source(file.path(clargs[1], "unittest.R")) +source("unittest.R") dyn.load(paste("unions", .Platform$dynlib.ext, sep="")) source("unions.R") cacheMetaData(1) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 9f4455fd9..0e8e23063 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files @@ -12,11 +12,11 @@ * ----------------------------------------------------------------------------- */ #include "swigmod.h" -#include static const double DEFAULT_NUMBER = .0000123456712312312323; -static String *replaceInitialDash(const String *name) { +static String* replaceInitialDash(const String *name) +{ String *retval; if (!Strncmp(name, "_", 1)) { retval = Copy(name); @@ -27,57 +27,42 @@ static String *replaceInitialDash(const String *name) { return retval; } -static String *getRTypeName(SwigType *t, int *outCount = NULL) { +static String * getRTypeName(SwigType *t, int *outCount = NULL) { String *b = SwigType_base(t); List *els = SwigType_split(t); int count = 0; int i; - - if (Strncmp(b, "struct ", 7) == 0) + + if(Strncmp(b, "struct ", 7) == 0) Replace(b, "struct ", "", DOH_REPLACE_FIRST); - + /* Printf(stdout, " %s,base = %s\n", t, b); - for(i = 0; i < Len(els); i++) + for(i = 0; i < Len(els); i++) Printf(stdout, "%d) %s, ", i, Getitem(els,i)); Printf(stdout, "\n"); */ - - for (i = 0; i < Len(els); i++) { + + for(i = 0; i < Len(els); i++) { String *el = Getitem(els, i); - if (Strcmp(el, "p.") == 0 || Strncmp(el, "a(", 2) == 0) { + if(Strcmp(el, "p.") == 0 || Strncmp(el, "a(", 2) == 0) { count++; Append(b, "Ref"); } } - if (outCount) + if(outCount) *outCount = count; - + String *tmp = NewString(""); char *retName = Char(SwigType_manglestr(t)); Insert(tmp, 0, retName); return tmp; - + /* - if(count) - return(b); - - Delete(b); - return(NewString("")); - */ -} - -static String *getNamespacePrefix(const String *enumRef) { - // for use from enumDeclaration. - // returns the namespace part of a string - // Do we have any "::"? - String *name = NewString(enumRef); - - while (Strstr(name, "::")) { - name = NewStringf("%s", Strchr(name, ':') + 2); - } - String *result = NewStringWithSize(enumRef, Len(enumRef) - Len(name)); - - Delete(name); - return (result); + if(count) + return(b); + + Delete(b); + return(NewString("")); + */ } /********************* @@ -86,16 +71,16 @@ static String *getNamespacePrefix(const String *enumRef) { Now handles arrays, i.e. struct A[2] ****************/ -static String *getRClassName(String *retType, int /*addRef */ = 1, int upRef = 0) { +static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) { String *tmp = NewString(""); SwigType *resolved = SwigType_typedef_resolve_all(retType); char *retName = Char(SwigType_manglestr(resolved)); if (upRef) { Printf(tmp, "_p%s", retName); - } else { + } else{ Insert(tmp, 0, retName); } - + return tmp; /* #if 1 @@ -104,33 +89,33 @@ static String *getRClassName(String *retType, int /*addRef */ = 1, int upRef = if(!l || n == 0) { #ifdef R_SWIG_VERBOSE if (debugMode) - Printf(stdout, "SwigType_split return an empty list for %s\n", - retType); + Printf(stdout, "SwigType_split return an empty list for %s\n", + retType); #endif return(tmp); } - - + + String *el = Getitem(l, n-1); char *ptr = Char(el); if(strncmp(ptr, "struct ", 7) == 0) ptr += 7; - + Printf(tmp, "%s", ptr); - + if(addRef) { for(int i = 0; i < n; i++) { - if(Strcmp(Getitem(l, i), "p.") == 0 || - Strncmp(Getitem(l, i), "a(", 2) == 0) - Printf(tmp, "Ref"); + if(Strcmp(Getitem(l, i), "p.") == 0 || + Strncmp(Getitem(l, i), "a(", 2) == 0) + Printf(tmp, "Ref"); } } - + #else char *retName = Char(SwigType_manglestr(retType)); if(!retName) return(tmp); - + if(addRef) { while(retName && strlen(retName) > 1 && strncmp(retName, "_p", 2) == 0) { retName += 2; @@ -141,7 +126,7 @@ static String *getRClassName(String *retType, int /*addRef */ = 1, int upRef = retName ++; Insert(tmp, 0, retName); #endif - + return tmp; */ } @@ -152,47 +137,50 @@ static String *getRClassName(String *retType, int /*addRef */ = 1, int upRef = Now handles arrays, i.e. struct A[2] ****************/ -static String *getRClassNameCopyStruct(String *retType, int addRef) { +static String * getRClassNameCopyStruct(String *retType, int addRef) { String *tmp = NewString(""); - + #if 1 List *l = SwigType_split(retType); int n = Len(l); - if (!l || n == 0) { + if(!l || n == 0) { #ifdef R_SWIG_VERBOSE Printf(stdout, "SwigType_split return an empty list for %s\n", retType); #endif - return (tmp); + return(tmp); } - - - String *el = Getitem(l, n - 1); + + + String *el = Getitem(l, n-1); char *ptr = Char(el); - if (strncmp(ptr, "struct ", 7) == 0) + if(strncmp(ptr, "struct ", 7) == 0) ptr += 7; - + Printf(tmp, "%s", ptr); - - if (addRef) { - for (int i = 0; i < n; i++) { - if (Strcmp(Getitem(l, i), "p.") == 0 || Strncmp(Getitem(l, i), "a(", 2) == 0) - Printf(tmp, "Ref"); + + if(addRef) { + for(int i = 0; i < n; i++) { + if(Strcmp(Getitem(l, i), "p.") == 0 || + Strncmp(Getitem(l, i), "a(", 2) == 0) + Printf(tmp, "Ref"); } } + #else char *retName = Char(SwigType_manglestr(retType)); - if (!retName) - return (tmp); - - if (addRef) { - while (retName && strlen(retName) > 1 && strncmp(retName, "_p", 2) == 0) { + if(!retName) + return(tmp); + + if(addRef) { + while(retName && strlen(retName) > 1 && + strncmp(retName, "_p", 2) == 0) { retName += 2; Printf(tmp, "Ref"); } } - - if (retName[0] == '_') - retName++; + + if(retName[0] == '_') + retName ++; Insert(tmp, 0, retName); #endif @@ -209,8 +197,11 @@ static String *getRClassNameCopyStruct(String *retType, int addRef) { static void writeListByLine(List *l, File *out, bool quote = 0) { int i, n = Len(l); - for (i = 0; i < n; i++) - Printf(out, "%s%s%s%s%s\n", tab8, quote ? "\"" : "", Getitem(l, i), quote ? "\"" : "", i < n - 1 ? "," : ""); + for(i = 0; i < n; i++) + Printf(out, "%s%s%s%s%s\n", tab8, + quote ? "\"" :"", + Getitem(l, i), + quote ? "\"" :"", i < n-1 ? "," : ""); } @@ -240,13 +231,10 @@ static void showUsage() { } static bool expandTypedef(SwigType *t) { - if (SwigType_isenum(t)) - return false; + if (SwigType_isenum(t)) return false; String *prefix = SwigType_prefix(t); - if (Strncmp(prefix, "f", 1)) - return false; - if (Strncmp(prefix, "p.f", 3)) - return false; + if (Strncmp(prefix, "f", 1)) return false; + if (Strncmp(prefix, "p.f", 3)) return false; return true; } @@ -258,11 +246,11 @@ static bool expandTypedef(SwigType *t) { static int addCopyParameter(SwigType *type) { int ok = 0; ok = Strncmp(type, "struct ", 7) == 0 || Strncmp(type, "p.struct ", 9) == 0; - if (!ok) { + if(!ok) { ok = Strncmp(type, "p.", 2); } - return (ok); + return(ok); } static void replaceRClass(String *tm, SwigType *type) { @@ -272,28 +260,25 @@ static void replaceRClass(String *tm, SwigType *type) { Replaceall(tm, "$R_class", tmp); Replaceall(tm, "$*R_class", tmp_base); Replaceall(tm, "$&R_class", tmp_ref); - Delete(tmp); - Delete(tmp_base); - Delete(tmp_ref); + Delete(tmp); Delete(tmp_base); Delete(tmp_ref); } static double getNumber(String *value) { double d = DEFAULT_NUMBER; - if (Char(value)) { - if (sscanf(Char(value), "%lf", &d) != 1) - return (DEFAULT_NUMBER); + if(Char(value)) { + if(sscanf(Char(value), "%lf", &d) != 1) + return(DEFAULT_NUMBER); } - return (d); + return(d); } - -class R:public Language { +class R : public Language { public: R(); void registerClass(Node *n); void main(int argc, char *argv[]); int top(Node *n); - + void dispatchFunction(Node *n); int functionWrapper(Node *n); int constantWrapper(Node *n); @@ -305,90 +290,99 @@ public: int membervariableHandler(Node *n); int typedefHandler(Node *n); - static List *Swig_overload_rank(Node *n, bool script_lang_wrapping); + static List *Swig_overload_rank(Node *n, + bool script_lang_wrapping); int memberfunctionHandler(Node *n) { if (debugMode) - Printf(stdout, " %s %s\n", Getattr(n, "name"), Getattr(n, "type")); + Printf(stdout, " %s %s\n", + Getattr(n, "name"), + Getattr(n, "type")); member_name = Getattr(n, "sym:name"); processing_class_member_function = 1; - int status = Language::memberfunctionHandler(n); - processing_class_member_function = 0; - return status; + int status = Language::memberfunctionHandler(n); + processing_class_member_function = 0; + return status; } - /* Grab the name of the current class being processed so that we can - deal with members of that class. */ int classHandler(Node *n) { - if (!ClassMemberTable) - ClassMemberTable = NewHash(); + /* Grab the name of the current class being processed so that we can + deal with members of that class. */ + int classHandler(Node *n){ + if(!ClassMemberTable) + ClassMemberTable = NewHash(); + class_name = Getattr(n, "name"); int status = Language::classHandler(n); - + class_name = NULL; return status; } // Not used: String *runtimeCode(); - + protected: int addRegistrationRoutine(String *rname, int nargs); int outputRegistrationRoutines(File *out); - + int outputCommandLineArguments(File *out); - int generateCopyRoutines(Node *n); + int generateCopyRoutines(Node *n); int DumpCode(Node *n); - + int OutputMemberReferenceMethod(String *className, int isSet, List *el, File *out); int OutputArrayMethod(String *className, List *el, File *out); int OutputClassMemberTable(Hash *tb, File *out); int OutputClassMethodsTable(File *out); int OutputClassAccessInfo(Hash *tb, File *out); - + int defineArrayAccessors(SwigType *type); - + void addNamespaceFunction(String *name) { - if (!namespaceFunctions) + if(!namespaceFunctions) namespaceFunctions = NewList(); Append(namespaceFunctions, name); } void addNamespaceMethod(String *name) { - if (!namespaceMethods) + if(!namespaceMethods) namespaceMethods = NewList(); Append(namespaceMethods, name); } - - String *processType(SwigType *t, Node *n, int *nargs = NULL); + + String* processType(SwigType *t, Node *n, int *nargs = NULL); String *createFunctionPointerHandler(SwigType *t, Node *n, int *nargs); int addFunctionPointerProxy(String *name, Node *n, SwigType *t, String *s_paramTypes) { /*XXX Do we need to put the t in there to get the return type later. */ - if (!functionPointerProxyTable) + if(!functionPointerProxyTable) functionPointerProxyTable = NewHash(); - + Setattr(functionPointerProxyTable, name, n); - + Setattr(SClassDefs, name, name); - Printv(s_classes, "setClass('", - name, - "',\n", tab8, - "prototype = list(parameterTypes = c(", s_paramTypes, "),\n", - tab8, tab8, tab8, "returnType = '", SwigType_manglestr(t), "'),\n", tab8, "contains = 'CRoutinePointer')\n\n##\n", NIL); - + Printv(s_classes, "setClass('", + name, + "',\n", tab8, + "prototype = list(parameterTypes = c(", s_paramTypes, "),\n", + tab8, tab8, tab8, + "returnType = '", SwigType_manglestr(t), "'),\n", tab8, + "contains = 'CRoutinePointer')\n\n##\n", NIL); + return SWIG_OK; } + - - void addSMethodInfo(String *name, String *argType, int nargs); - // Simple initialization such as constant strings that can be reused. - void init(); - - - void addAccessor(String *memberName, Wrapper *f, String *name, int isSet = -1); - + void addSMethodInfo(String *name, + String *argType, int nargs); + // Simple initialization such as constant strings that can be reused. + void init(); + + + void addAccessor(String *memberName, Wrapper *f, + String *name, int isSet = -1); + static int getFunctionPointerNumArgs(Node *n, SwigType *tt); -protected: +protected: bool copyStruct; bool memoryProfile; bool aggressiveGc; @@ -406,88 +400,95 @@ protected: String *s_init; String *s_init_routine; String *s_namespace; - - // State variables that carry information across calls to functionWrapper() - // from member accessors and class declarations. + + // State variables that carry information across calls to functionWrapper() + // from member accessors and class declarations. String *opaqueClassDeclaration; int processing_variable; int processing_member_access_function; String *member_name; String *class_name; - - + + int processing_class_member_function; List *class_member_functions; List *class_member_set_functions; - + /* */ Hash *ClassMemberTable; Hash *ClassMethodsTable; Hash *SClassDefs; Hash *SMethodInfo; - - // Information about routines that are generated and to be registered with - // R for dynamic lookup. + + // Information about routines that are generated and to be registered with + // R for dynamic lookup. Hash *registrationTable; Hash *functionPointerProxyTable; - + List *namespaceFunctions; List *namespaceMethods; - List *namespaceClasses; // Probably can do this from ClassMemberTable. - - - // Store a copy of the command line. - // Need only keep a string that has it formatted. + List *namespaceClasses; // Probably can do this from ClassMemberTable. + + + // Store a copy of the command line. + // Need only keep a string that has it formatted. char **Argv; - int Argc; + int Argc; bool inCPlusMode; - + // State variables that we remember from the command line settings // potentially that govern the code we generate. String *DllName; String *Rpackage; - bool noInitializationCode; - bool outputNamespaceInfo; - + bool noInitializationCode; + bool outputNamespaceInfo; + String *UnProtectWrapupCode; // Static members static bool debugMode; }; -R::R(): -copyStruct(false), -memoryProfile(false), -aggressiveGc(false), -sfile(0), -f_init(0), -s_classes(0), -f_begin(0), -f_runtime(0), -f_wrapper(0), -s_header(0), -f_wrappers(0), -s_init(0), -s_init_routine(0), -s_namespace(0), -opaqueClassDeclaration(0), -processing_variable(0), -processing_member_access_function(0), -member_name(0), -class_name(0), -processing_class_member_function(0), -class_member_functions(0), -class_member_set_functions(0), -ClassMemberTable(0), -ClassMethodsTable(0), -SClassDefs(0), -SMethodInfo(0), -registrationTable(0), -functionPointerProxyTable(0), -namespaceFunctions(0), -namespaceMethods(0), -namespaceClasses(0), -Argv(0), Argc(0), inCPlusMode(false), DllName(0), Rpackage(0), noInitializationCode(false), outputNamespaceInfo(false), UnProtectWrapupCode(0) { +R::R() : + copyStruct(false), + memoryProfile(false), + aggressiveGc(false), + sfile(0), + f_init(0), + s_classes(0), + f_begin(0), + f_runtime(0), + f_wrapper(0), + s_header(0), + f_wrappers(0), + s_init(0), + s_init_routine(0), + s_namespace(0), + opaqueClassDeclaration(0), + processing_variable(0), + processing_member_access_function(0), + member_name(0), + class_name(0), + processing_class_member_function(0), + class_member_functions(0), + class_member_set_functions(0), + ClassMemberTable(0), + ClassMethodsTable(0), + SClassDefs(0), + SMethodInfo(0), + registrationTable(0), + functionPointerProxyTable(0), + namespaceFunctions(0), + namespaceMethods(0), + namespaceClasses(0), + Argv(0), + Argc(0), + inCPlusMode(false), + DllName(0), + Rpackage(0), + noInitializationCode(false), + outputNamespaceInfo(false), + UnProtectWrapupCode(0) { } bool R::debugMode = false; @@ -507,44 +508,43 @@ int R::getFunctionPointerNumArgs(Node *n, SwigType *tt) { void R::addSMethodInfo(String *name, String *argType, int nargs) { (void) argType; - - if (!SMethodInfo) + + if(!SMethodInfo) SMethodInfo = NewHash(); if (debugMode) Printf(stdout, "[addMethodInfo] %s\n", name); Hash *tb = Getattr(SMethodInfo, name); - if (!tb) { + if(!tb) { tb = NewHash(); Setattr(SMethodInfo, name, tb); } String *str = Getattr(tb, "max"); int max = -1; - if (str) + if(str) max = atoi(Char(str)); - if (max < nargs) { - if (str) - Delete(str); + if(max < nargs) { + if(str) Delete(str); str = NewStringf("%d", max); Setattr(tb, "max", str); } } - + /* Returns the name of the new routine. */ -String *R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { +String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { String *funName = SwigType_manglestr(t); - + /* See if we have already processed this one. */ - if (functionPointerProxyTable && Getattr(functionPointerProxyTable, funName)) + if(functionPointerProxyTable && Getattr(functionPointerProxyTable, funName)) return funName; - + if (debugMode) - Printf(stdout, " Defining %s\n", t); - + Printf(stdout, " Defining %s\n", t); + SwigType *rettype = Copy(Getattr(n, "type")); SwigType *funcparams = SwigType_functionpointer_decompose(rettype); String *rtype = SwigType_str(rettype, 0); @@ -558,13 +558,13 @@ String *R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { Printf(stdout, "Type: %s\n", t); Printf(stdout, "Return type: %s\n", SwigType_base(t)); } - + bool isVoidType = Strcmp(rettype, "void") == 0; if (debugMode) Printf(stdout, "%s is void ? %s (%s)\n", funName, isVoidType ? "yes" : "no", rettype); - + Wrapper *f = NewWrapper(); - + /* Go through argument list, attach lnames for arguments */ int i = 0; Parm *p = parms; @@ -573,14 +573,14 @@ String *R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { String *lname; if (!arg && Cmp(Getattr(p, "type"), "void")) { - lname = NewStringf("s_arg%d", i + 1); + lname = NewStringf("s_arg%d", i+1); Setattr(p, "name", lname); } else lname = arg; Setattr(p, "lname", lname); } - + Swig_typemap_attach_parms("out", parms, f); Swig_typemap_attach_parms("scoerceout", parms, f); Swig_typemap_attach_parms("scheck", parms, f); @@ -595,9 +595,9 @@ String *R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { Wrapper_add_local(f, "r_swig_cb_data", "RCallbackFunctionData *r_swig_cb_data = R_SWIG_getCallbackFunctionData()"); String *lvar = NewString("r_swig_cb_data"); - Wrapper_add_local(f, "r_tmp", "SEXP r_tmp"); // for use in converting arguments to R objects for call. - Wrapper_add_local(f, "r_nprotect", "int r_nprotect = 0"); // for use in converting arguments to R objects for call. - Wrapper_add_local(f, "r_vmax", "char * r_vmax= 0"); // for use in converting arguments to R objects for call. + Wrapper_add_local(f, "r_tmp", "SEXP r_tmp"); // for use in converting arguments to R objects for call. + Wrapper_add_local(f, "r_nprotect", "int r_nprotect = 0"); // for use in converting arguments to R objects for call. + Wrapper_add_local(f, "r_vmax", "char * r_vmax= 0"); // for use in converting arguments to R objects for call. // Add local for error code in return value. This is not in emit_return_variable because that assumes an out typemap // whereas the type makes are reverse @@ -605,125 +605,136 @@ String *R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { p = parms; int nargs = ParmList_len(parms); - if (numArgs) { + if(numArgs) { *numArgs = nargs; if (debugMode) Printf(stdout, "Setting number of parameters to %d\n", *numArgs); - } + } String *setExprElements = NewString(""); - + String *s_paramTypes = NewString(""); - for (i = 0; p; i++) { + for(i = 0; p; i++) { SwigType *tt = Getattr(p, "type"); SwigType *name = Getattr(p, "name"); String *tm = Getattr(p, "tmap:out"); - Printf(f->def, "%s %s", SwigType_str(tt, 0), name); - if (tm) { + Printf(f->def, "%s %s", SwigType_str(tt, 0), name); + if(tm) { Replaceall(tm, "$1", name); if (SwigType_isreference(tt)) { - String *tmp = NewString(""); + String *tmp = NewString(""); Append(tmp, "*"); - Append(tmp, name); - Replaceall(tm, tmp, name); + Append(tmp, name); + Replaceall(tm, tmp, name); } Replaceall(tm, "$result", "r_tmp"); - replaceRClass(tm, Getattr(p, "type")); - Replaceall(tm, "$owner", "R_SWIG_EXTERNAL"); - } - + replaceRClass(tm, Getattr(p,"type")); + Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); + } + Printf(setExprElements, "%s\n", tm); Printf(setExprElements, "SETCAR(r_swig_cb_data->el, %s);\n", "r_tmp"); Printf(setExprElements, "r_swig_cb_data->el = CDR(r_swig_cb_data->el);\n\n"); - + Printf(s_paramTypes, "'%s'", SwigType_manglestr(tt)); - - + + p = nextSibling(p); - if (p) { + if(p) { Printf(f->def, ", "); Printf(s_paramTypes, ", "); } } - - Printf(f->def, ") {\n"); - + + Printf(f->def, ") {\n"); + Printf(f->code, "Rf_protect(%s->expr = Rf_allocVector(LANGSXP, %d));\n", lvar, nargs + 1); Printf(f->code, "r_nprotect++;\n"); Printf(f->code, "r_swig_cb_data->el = r_swig_cb_data->expr;\n\n"); - + Printf(f->code, "SETCAR(r_swig_cb_data->el, r_swig_cb_data->fun);\n"); Printf(f->code, "r_swig_cb_data->el = CDR(r_swig_cb_data->el);\n\n"); - + Printf(f->code, "%s\n\n", setExprElements); - - Printv(f->code, "r_swig_cb_data->retValue = R_tryEval(", "r_swig_cb_data->expr,", " R_GlobalEnv,", " &r_swig_cb_data->errorOccurred", ");\n", NIL); - + + Printv(f->code, "r_swig_cb_data->retValue = R_tryEval(", + "r_swig_cb_data->expr,", + " R_GlobalEnv,", + " &r_swig_cb_data->errorOccurred", + ");\n", + NIL); + Printv(f->code, "\n", - "if(r_swig_cb_data->errorOccurred) {\n", - "R_SWIG_popCallbackFunctionData(1);\n", "Rf_error(\"error in calling R function as a function pointer (", funName, ")\");\n", "}\n", NIL); - - - - if (!isVoidType) { - /* Need to deal with the return type of the function pointer, not the function pointer itself. + "if(r_swig_cb_data->errorOccurred) {\n", + "R_SWIG_popCallbackFunctionData(1);\n", + "Rf_error(\"error in calling R function as a function pointer (", + funName, + ")\");\n", + "}\n", + NIL); + + + + if(!isVoidType) { + /* Need to deal with the return type of the function pointer, not the function pointer itself. So build a new node that has the relevant pieces. XXX Have to be a little more clever so that we can deal with struct A * - the * is getting lost. Is this still true? If so, will a SwigType_push() solve things? - */ + */ Parm *bbase = NewParmNode(rettype, n); String *returnTM = Swig_typemap_lookup("in", bbase, Swig_cresult_name(), f); - if (returnTM) { + if(returnTM) { String *tm = returnTM; - Replaceall(tm, "$input", "r_swig_cb_data->retValue"); - Replaceall(tm, "$target", Swig_cresult_name()); + Replaceall(tm,"$input", "r_swig_cb_data->retValue"); + Replaceall(tm,"$target", Swig_cresult_name()); replaceRClass(tm, rettype); - Replaceall(tm, "$owner", "R_SWIG_EXTERNAL"); - Replaceall(tm, "$disown", "0"); + Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); + Replaceall(tm,"$disown","0"); Printf(f->code, "%s\n", tm); } Delete(bbase); } - + Printv(f->code, "R_SWIG_popCallbackFunctionData(1);\n", NIL); Printv(f->code, "\n", UnProtectWrapupCode, NIL); - if (SwigType_isreference(rettype)) { - Printv(f->code, "return *", Swig_cresult_name(), ";\n", NIL); - } else if (!isVoidType) - Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL); - + if (SwigType_isreference(rettype)) { + Printv(f->code, "return *", Swig_cresult_name(), ";\n", NIL); + } else if(!isVoidType) + Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL); + Printv(f->code, "\n}\n", NIL); Replaceall(f->code, "SWIG_exception_fail", "SWIG_exception_noreturn"); - + /* To coerce correctly in S, we really want to have an extra/intermediate - function that handles the scoerceout. + function that handles the scoerceout. We need to check if any of the argument types have an entry in that map. If none do, the ignore and call the function straight. Otherwise, generate the a marshalling function. Need to be able to find it in S. Or use an entirely generic one that evaluates the expressions. Handle errors in the evaluation of the function by restoring - the stack, if there is one in use for this function (i.e. no + the stack, if there is one in use for this function (i.e. no userData). - */ - + */ + Wrapper_print(f, f_wrapper); - + addFunctionPointerProxy(funName, n, t, s_paramTypes); Delete(s_paramTypes); Delete(rtype); Delete(rettype); Delete(funcparams); DelWrapper(f); - + return funName; } void R::init() { - UnProtectWrapupCode = NewStringf("%s", "vmaxset(r_vmax);\nif(r_nprotect) Rf_unprotect(r_nprotect);\n\n"); - + UnProtectWrapupCode = + NewStringf("%s", "vmaxset(r_vmax);\nif(r_nprotect) Rf_unprotect(r_nprotect);\n\n"); + SClassDefs = NewHash(); - + sfile = NewString(""); f_init = NewString(""); s_header = NewString(""); @@ -750,18 +761,18 @@ int R::cDeclaration(Node *n) { /** Method from Language that is called to start the entire - processing off, i.e. the generation of the code. + processing off, i.e. the generation of the code. It is called after the input has been read and parsed. Here we open the output streams and generate the code. ***/ int R::top(Node *n) { String *module = Getattr(n, "name"); - if (!Rpackage) + if(!Rpackage) Rpackage = Copy(module); - if (!DllName) + if(!DllName) DllName = Copy(module); - if (outputNamespaceInfo) { + if(outputNamespaceInfo) { s_namespace = NewString(""); Swig_register_filebyname("snamespace", s_namespace); Printf(s_namespace, "useDynLib(%s)\n", DllName); @@ -786,7 +797,7 @@ int R::top(Node *n) { Printf(f_runtime, "#define SWIGR\n"); Printf(f_runtime, "\n"); - + Swig_banner_target_lang(s_init, "#"); outputCommandLineArguments(s_init); @@ -801,17 +812,17 @@ int R::top(Node *n) { Printf(f_wrapper, "#endif\n"); String *type_table = NewString(""); - SwigType_emit_type_table(f_runtime, f_wrapper); + SwigType_emit_type_table(f_runtime,f_wrapper); Delete(type_table); - if (ClassMemberTable) { + if(ClassMemberTable) { //XXX OutputClassAccessInfo(ClassMemberTable, sfile); Delete(ClassMemberTable); ClassMemberTable = NULL; } - Printf(f_init, "}\n"); - if (registrationTable) + Printf(f_init,"}\n"); + if(registrationTable) outputRegistrationRoutines(f_init); /* Now arrange to write the 2 files - .S and .c. */ @@ -837,35 +848,35 @@ int R::top(Node *n) { ****************************************************/ int R::DumpCode(Node *n) { String *output_filename = NewString(""); - - + + /* The name of the file in which we will generate the S code. */ Printf(output_filename, "%s%s.R", SWIG_output_directory(), Rpackage); - + #ifdef R_SWIG_VERBOSE Printf(stdout, "Writing S code to %s\n", output_filename); #endif - + File *scode = NewFile(output_filename, "w", SWIG_output_files()); if (!scode) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); } Delete(output_filename); - - + + Printf(scode, "%s\n\n", s_init); Printf(scode, "%s\n\n", s_classes); Printf(scode, "%s\n", sfile); - + Delete(scode); - String *outfile = Getattr(n, "outfile"); - File *runtime = NewFile(outfile, "w", SWIG_output_files()); + String *outfile = Getattr(n,"outfile"); + File *runtime = NewFile(outfile,"w", SWIG_output_files()); if (!runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - + Printf(runtime, "%s", f_begin); Printf(runtime, "%s\n", f_runtime); Printf(runtime, "%s\n", s_header); @@ -874,7 +885,7 @@ int R::DumpCode(Node *n) { Delete(runtime); - if (outputNamespaceInfo) { + if(outputNamespaceInfo) { output_filename = NewString(""); Printf(output_filename, "%sNAMESPACE", SWIG_output_directory()); File *ns = NewFile(output_filename, "w", SWIG_output_files()); @@ -883,7 +894,7 @@ int R::DumpCode(Node *n) { SWIG_exit(EXIT_FAILURE); } Delete(output_filename); - + Printf(ns, "%s\n", s_namespace); Printf(ns, "\nexport(\n"); @@ -902,7 +913,7 @@ int R::DumpCode(Node *n) { /* - We may need to do more.... so this is left as a + We may need to do more.... so this is left as a stub for the moment. */ int R::OutputClassAccessInfo(Hash *tb, File *out) { @@ -914,28 +925,28 @@ int R::OutputClassAccessInfo(Hash *tb, File *out) { /************************************************************************ Currently this just writes the information collected about the different methods of the C++ classes that have been processed - to the console. + to the console. This will be used later to define S4 generics and methods. **************************************************************************/ int R::OutputClassMethodsTable(File *) { Hash *tb = ClassMethodsTable; - - if (!tb) + + if(!tb) return SWIG_OK; - + List *keys = Keys(tb); String *key; int i, n = Len(keys); if (debugMode) { - for (i = 0; i < n; i++) { + for(i = 0; i < n ; i++ ) { key = Getitem(keys, i); Printf(stdout, "%d) %s\n", i, key); List *els = Getattr(tb, key); int nels = Len(els); Printf(stdout, "\t"); - for (int j = 0; j < nels; j += 2) { - Printf(stdout, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : ""); - Printf(stdout, "%s\n", Getitem(els, j + 1)); + for(int j = 0; j < nels; j+=2) { + Printf(stdout, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : ""); + Printf(stdout, "%s\n", Getitem(els, j+1)); } Printf(stdout, "\n"); } @@ -946,88 +957,89 @@ int R::OutputClassMethodsTable(File *) { /* - Iterate over the _set and <>_get + Iterate over the _set and <>_get elements and generate the $ and $<- functions that provide constrained access to the member fields in these elements. tb - a hash table that is built up in functionWrapper as we process each membervalueHandler. - The entries are indexed by _set and + The entries are indexed by _set and _get. Each entry is a List *. - + out - the stram where the code is to be written. This is the S code stream as we generate only S code here.. */ int R::OutputClassMemberTable(Hash *tb, File *out) { List *keys = Keys(tb), *el; - + String *key; int i, n = Len(keys); /* Loop over all the _set and _get entries in the table. */ - - if (n && outputNamespaceInfo) { + + if(n && outputNamespaceInfo) { Printf(s_namespace, "exportClasses("); } - for (i = 0; i < n; i++) { + for(i = 0; i < n; i++) { key = Getitem(keys, i); el = Getattr(tb, key); - + String *className = Getitem(el, 0); char *ptr = Char(key); ptr = &ptr[Len(key) - 3]; int isSet = strcmp(ptr, "set") == 0; - - // OutputArrayMethod(className, el, out); + + // OutputArrayMethod(className, el, out); OutputMemberReferenceMethod(className, isSet, el, out); - - if (outputNamespaceInfo) - Printf(s_namespace, "\"%s\"%s", className, i < n - 1 ? "," : ""); + + if(outputNamespaceInfo) + Printf(s_namespace, "\"%s\"%s", className, i < n-1 ? "," : ""); } - if (n && outputNamespaceInfo) { + if(n && outputNamespaceInfo) { Printf(s_namespace, ")\n"); } - + return n; } /******************************************************************* - Write the methods for $ or $<- for accessing a member field in an + Write the methods for $ or $<- for accessing a member field in an struct or union (or class). className - the name of the struct or union (e.g. Bar for struct Bar) - isSet - a logical value indicating whether the method is for + isSet - a logical value indicating whether the method is for modifying ($<-) or accessing ($) the member field. el - a list of length 2 * # accessible member elements + 1. - The first element is the name of the class. + The first element is the name of the class. The other pairs are member name and the name of the R function to access it. out - the stream where we write the code. ********************************************************************/ -int R::OutputMemberReferenceMethod(String *className, int isSet, List *el, File *out) { +int R::OutputMemberReferenceMethod(String *className, int isSet, + List *el, File *out) { int numMems = Len(el), j; int varaccessor = 0; - if (numMems == 0) + if (numMems == 0) return SWIG_OK; - + Wrapper *f = NewWrapper(), *attr = NewWrapper(); - + Printf(f->def, "function(x, name%s)", isSet ? ", value" : ""); Printf(attr->def, "function(x, i, j, ...%s)", isSet ? ", value" : ""); - + Printf(f->code, "{\n"); Printf(f->code, "%saccessorFuns = list(", tab8); Node *itemList = NewHash(); bool has_prev = false; - for (j = 0; j < numMems; j += 3) { + for(j = 0; j < numMems; j+=3) { String *item = Getitem(el, j); - if (Getattr(itemList, item)) + if (Getattr(itemList, item)) continue; Setattr(itemList, item, "1"); - + String *dup = Getitem(el, j + 1); char *ptr = Char(dup); ptr = &ptr[Len(dup) - 3]; - + if (!strcmp(ptr, "get")) varaccessor++; @@ -1043,7 +1055,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, List *el, File } else { pitem = Copy(item); } - if (has_prev) + if (has_prev) Printf(f->code, ", "); Printf(f->code, "'%s' = %s", pitem, dup); has_prev = true; @@ -1051,102 +1063,114 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, List *el, File } Delete(itemList); Printf(f->code, ");\n"); - + if (!isSet && varaccessor > 0) { Printf(f->code, "%svaccessors = c(", tab8); int vcount = 0; - for (j = 0; j < numMems; j += 3) { + for(j = 0; j < numMems; j+=3) { String *item = Getitem(el, j); String *dup = Getitem(el, j + 1); char *ptr = Char(dup); ptr = &ptr[Len(dup) - 3]; - + if (!strcmp(ptr, "get")) { - vcount++; - Printf(f->code, "'%s'%s", item, vcount < varaccessor ? ", " : ""); + vcount++; + Printf(f->code, "'%s'%s", item, vcount < varaccessor ? ", " : ""); } } Printf(f->code, ");\n"); } - - + + /* Printv(f->code, tab8, - "idx = pmatch(name, names(accessorFuns))\n", - tab8, - "if(is.na(idx)) {\n", - tab8, tab4, - "stop(\"No ", (isSet ? "modifiable" : "accessible"), " field named \", name, \" in ", className, - ": fields are \", paste(names(accessorFuns), sep = \", \")", - ")", "\n}\n", NIL); */ - Printv(f->code, ";", tab8, "idx = pmatch(name, names(accessorFuns));\n", tab8, "if(is.na(idx)) \n", tab8, tab4, NIL); - Printf(f->code, "return(callNextMethod(x, name%s));\n", isSet ? ", value" : ""); + "idx = pmatch(name, names(accessorFuns))\n", + tab8, + "if(is.na(idx)) {\n", + tab8, tab4, + "stop(\"No ", (isSet ? "modifiable" : "accessible"), " field named \", name, \" in ", className, + ": fields are \", paste(names(accessorFuns), sep = \", \")", + ")", "\n}\n", NIL); */ + Printv(f->code, ";", tab8, + "idx = pmatch(name, names(accessorFuns));\n", + tab8, + "if(is.na(idx)) \n", + tab8, tab4, NIL); + Printf(f->code, "return(callNextMethod(x, name%s));\n", + isSet ? ", value" : ""); Printv(f->code, tab8, "f = accessorFuns[[idx]];\n", NIL); - if (isSet) { + if(isSet) { Printv(f->code, tab8, "f(x, value);\n", NIL); Printv(f->code, tab8, "x;\n", NIL); // make certain to return the S value. } else { if (varaccessor) { - Printv(f->code, tab8, "if (is.na(match(name, vaccessors))) function(...){f(x, ...)} else f(x);\n", NIL); + Printv(f->code, tab8, + "if (is.na(match(name, vaccessors))) function(...){f(x, ...)} else f(x);\n", NIL); } else { Printv(f->code, tab8, "function(...){f(x, ...)};\n", NIL); } } Printf(f->code, "}\n"); - - + + Printf(out, "# Start of accessor method for %s\n", className); - Printf(out, "setMethod('$%s', '_p%s', ", isSet ? "<-" : "", getRClassName(className)); + Printf(out, "setMethod('$%s', '_p%s', ", + isSet ? "<-" : "", + getRClassName(className)); Wrapper_print(f, out); Printf(out, ");\n"); - - if (isSet) { - Printf(out, "setMethod('[[<-', c('_p%s', 'character'),", getRClassName(className)); + + if(isSet) { + Printf(out, "setMethod('[[<-', c('_p%s', 'character'),", + getRClassName(className)); Insert(f->code, 2, "name = i;\n"); Printf(attr->code, "%s", f->code); Wrapper_print(attr, out); Printf(out, ");\n"); } - + DelWrapper(attr); DelWrapper(f); - + Printf(out, "# end of accessor method for %s\n", className); - + return SWIG_OK; } /******************************************************************* - Write the methods for [ or [<- for accessing a member field in an + Write the methods for [ or [<- for accessing a member field in an struct or union (or class). className - the name of the struct or union (e.g. Bar for struct Bar) el - a list of length 2 * # accessible member elements + 1. - The first element is the name of the class. + The first element is the name of the class. The other pairs are member name and the name of the R function to access it. out - the stream where we write the code. ********************************************************************/ int R::OutputArrayMethod(String *className, List *el, File *out) { int numMems = Len(el), j; - - if (!el || numMems == 0) - return (0); - + + if(!el || numMems == 0) + return(0); + Printf(out, "# start of array methods for %s\n", className); - for (j = 0; j < numMems; j += 3) { + for(j = 0; j < numMems; j+=3) { String *item = Getitem(el, j); String *dup = Getitem(el, j + 1); if (!Strcmp(item, "__getitem__")) { - Printf(out, "setMethod('[', '_p%s', function(x, i, j, ..., drop =TRUE) ", getRClassName(className)); + Printf(out, + "setMethod('[', '_p%s', function(x, i, j, ..., drop =TRUE) ", + getRClassName(className)); Printf(out, " sapply(i, function (n) %s(x, as.integer(n-1))))\n\n", dup); } if (!Strcmp(item, "__setitem__")) { - Printf(out, "setMethod('[<-', '_p%s', function(x, i, j, ..., value)", getRClassName(className)); + Printf(out, "setMethod('[<-', '_p%s', function(x, i, j, ..., value)", + getRClassName(className)); Printf(out, " sapply(1:length(i), function(n) %s(x, as.integer(i[n]-1), value[n])))\n\n", dup); } - + } - + Printf(out, "# end of array methods for %s\n", className); - + return SWIG_OK; } @@ -1159,129 +1183,51 @@ int R::OutputArrayMethod(String *className, List *el, File *out) { int R::enumDeclaration(Node *n) { String *name = Getattr(n, "name"); String *tdname = Getattr(n, "tdname"); - - if (cplus_mode != PUBLIC) { - return (SWIG_NOWRAP); - } - + /* Using name if tdname is empty. */ - - if (Len(tdname) == 0) + + if(Len(tdname) == 0) tdname = name; - if (!tdname || Strcmp(tdname, "") == 0) { + + if(!tdname || Strcmp(tdname, "") == 0) { Language::enumDeclaration(n); return SWIG_OK; } - + String *mangled_tdname = SwigType_manglestr(tdname); String *scode = NewString(""); - String *possiblescode = NewString(""); - - // Need to create some C code to return the enum values. - // Presumably a C function for each element of the enum.. - // There is probably some sneaky way to use the - // standard methods of variable/constant access, but I can't see - // it yet. - // Need to fetch the namespace part of the enum in tdname, so - // that we can address the correct enum. Perhaps there is already an - // attribute that has this info, but I can't find it. That leaves - // searching for ::. Obviously needs to work if there is no nesting. - // - // One issue is that swig is generating defineEnumeration calls for - // enums in the private part of classes. This usually isn't a - // problem, but the model in which some C code returns the - // underlying value won't compile because it is accessing a private - // type. - // - // It will be best to turn off binding to private parts of - // classes. - - String *cppcode = NewString(""); - // this is the namespace that will get used inside the functions - // returning enumerations. - String *namespaceprefix = getNamespacePrefix(tdname); - Wrapper *eW = NewWrapper(); - Node *kk; - - for (kk = firstChild(n); kk; kk = nextSibling(kk)) { - String *ename = Getattr(kk, "name"); - String *fname = NewString(""); - String *cfunctname = NewStringf("R_swigenum_%s_%s", mangled_tdname, ename); - String *rfunctname = NewStringf("R_swigenum_%s_%s_get", mangled_tdname, ename); - Printf(fname, "%s(void){", cfunctname); - Printf(cppcode, "SWIGEXPORT SEXP \n%s\n", fname); - Printf(cppcode, "int result;\n"); - Printf(cppcode, "SEXP r_ans = R_NilValue;\n"); - Printf(cppcode, "result = (int)%s%s;\n", namespaceprefix, ename); - Printf(cppcode, "r_ans = Rf_ScalarInteger(result);\n"); - Printf(cppcode, "return(r_ans);\n}\n"); - - // Now emit the r binding functions - Printf(possiblescode, "`%s` = function(.copy=FALSE) {\n", rfunctname); - Printf(possiblescode, ".Call(\'%s\', as.logical(.copy), PACKAGE=\'%s\')\n}\n\n", cfunctname, Rpackage); - Printf(possiblescode, "attr(`%s`, \'returnType\')=\'integer\'\n", rfunctname); - Printf(possiblescode, "class(`%s`) = c(\"SWIGfunction\", class(\'%s\'))\n\n", rfunctname, rfunctname); - Delete(ename); - Delete(fname); - Delete(cfunctname); - Delete(rfunctname); - } - - Printv(cppcode, "", NIL); - - Printf(eW->code, "%s", cppcode); - Delete(cppcode); - - Delete(namespaceprefix); - - Printv(scode, "defineEnumeration('", mangled_tdname, "'", ",\n", tab8, tab8, tab4, ".values = c(\n", NIL); - + + Printv(scode, "defineEnumeration('", mangled_tdname, "'", + ",\n", tab8, tab8, tab4, ".values = c(\n", NIL); + Node *c; - int value = -1; // First number is zero - bool needenumfunc = false; // Track whether we need runtime C - // calls to deduce correct enum values + int value = -1; // First number is zero for (c = firstChild(n); c; c = nextSibling(c)) { // const char *tag = Char(nodeType(c)); - // if (Strcmp(tag,"cdecl") == 0) { + // if (Strcmp(tag,"cdecl") == 0) { name = Getattr(c, "name"); - // This needs to match the version earlier - could have stored it. - String *rfunctname = NewStringf("R_swigenum_%s_%s_get()", mangled_tdname, name); String *val = Getattr(c, "enumvalue"); - String *numstring = NewString(""); - - if (val && Char(val)) { - double inval = getNumber(val); - if (inval == DEFAULT_NUMBER) { - // This should indicate there is some fancy text there - // so we want to call the special R functions - needenumfunc = true; - Printf(numstring, "%s", rfunctname); - } else { - value = (int) inval; - Printf(numstring, "%d", value); - - } - } else { + if(val && Char(val)) { + int inval = (int) getNumber(val); + if(inval == DEFAULT_NUMBER) + value++; + else + value = inval; + } else value++; - Printf(numstring, "%d", value); - } - Printf(scode, "%s%s%s'%s' = %s%s\n", tab8, tab8, tab8, name, numstring, nextSibling(c) ? ", " : ""); - Delete(rfunctname); - Delete(numstring); + + Printf(scode, "%s%s%s'%s' = %d%s\n", tab8, tab8, tab8, name, value, + nextSibling(c) ? ", " : ""); + // } } - + Printv(scode, "))", NIL); - - if (needenumfunc) { - Wrapper_print(eW, f_wrapper); - Printf(sfile, "%s\n", possiblescode); - } Printf(sfile, "%s\n", scode); - + Delete(scode); - Delete(possiblescode); Delete(mangled_tdname); + return SWIG_OK; } @@ -1290,28 +1236,30 @@ int R::enumDeclaration(Node *n) { **************************************************************/ int R::variableWrapper(Node *n) { String *name = Getattr(n, "sym:name"); - + processing_variable = 1; Language::variableWrapper(n); // Force the emission of the _set and _get function wrappers. processing_variable = 0; - - + + SwigType *ty = Getattr(n, "type"); int addCopyParam = addCopyParameter(ty); - + //XXX processType(ty, n); - - if (!SwigType_isconst(ty)) { + + if(!SwigType_isconst(ty)) { Wrapper *f = NewWrapper(); - Printf(f->def, "%s = \nfunction(value%s)\n{\n", name, addCopyParam ? ", .copy = FALSE" : ""); - Printv(f->code, "if(missing(value)) {\n", name, "_get(", addCopyParam ? ".copy" : "", ")\n}", NIL); - Printv(f->code, " else {\n", name, "_set(value)\n}\n}", NIL); - + Printf(f->def, "%s = \nfunction(value%s)\n{\n", + name, addCopyParam ? ", .copy = FALSE" : ""); + Printv(f->code, "if(missing(value)) {\n", + name, "_get(", addCopyParam ? ".copy" : "", ")\n}", NIL); + Printv(f->code, " else {\n", + name, "_set(value)\n}\n}", NIL); + Wrapper_print(f, sfile); DelWrapper(f); } else { - Printf(sfile, "## constant in variableWrapper\n"); Printf(sfile, "%s = %s_get\n", name, name); } @@ -1319,27 +1267,27 @@ int R::variableWrapper(Node *n) { } - -void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, int isSet) { - if (isSet < 0) { +void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, + int isSet) { + if(isSet < 0) { int n = Len(name); char *ptr = Char(name); - isSet = Strcmp(NewString(&ptr[n - 3]), "set") == 0; + isSet = Strcmp(NewString(&ptr[n-3]), "set") == 0; } - + List *l = isSet ? class_member_set_functions : class_member_functions; - - if (!l) { + + if(!l) { l = NewList(); - if (isSet) + if(isSet) class_member_set_functions = l; else class_member_functions = l; } - + Append(l, memberName); Append(l, name); - + String *tmp = NewString(""); Wrapper_print(wrapper, tmp); Append(l, tmp); @@ -1351,235 +1299,237 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, int isSe #define MAX_OVERLOAD 256 struct Overloaded { - Node *n; /* Node */ - int argc; /* Argument count */ - ParmList *parms; /* Parameters used for overload check */ - int error; /* Ambiguity error */ + Node *n; /* Node */ + int argc; /* Argument count */ + ParmList *parms; /* Parameters used for overload check */ + int error; /* Ambiguity error */ }; -List *R::Swig_overload_rank(Node *n, bool script_lang_wrapping) { - Overloaded nodes[MAX_OVERLOAD]; - int nnodes = 0; - Node *o = Getattr(n, "sym:overloaded"); +List * R::Swig_overload_rank(Node *n, + bool script_lang_wrapping) { + Overloaded nodes[MAX_OVERLOAD]; + int nnodes = 0; + Node *o = Getattr(n,"sym:overloaded"); - if (!o) - return 0; + if (!o) return 0; Node *c = o; while (c) { - if (Getattr(c, "error")) { - c = Getattr(c, "sym:nextSibling"); + if (Getattr(c,"error")) { + c = Getattr(c,"sym:nextSibling"); continue; } /* if (SmartPointer && Getattr(c,"cplus:staticbase")) { - c = Getattr(c,"sym:nextSibling"); - continue; - } */ + c = Getattr(c,"sym:nextSibling"); + continue; + } */ /* Make a list of all the declarations (methods) that are overloaded with * this one particular method name */ - if (Getattr(c, "wrap:name")) { + if (Getattr(c,"wrap:name")) { nodes[nnodes].n = c; - nodes[nnodes].parms = Getattr(c, "wrap:parms"); + nodes[nnodes].parms = Getattr(c,"wrap:parms"); nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms); nodes[nnodes].error = 0; nnodes++; } - c = Getattr(c, "sym:nextSibling"); + c = Getattr(c,"sym:nextSibling"); } - + /* Sort the declarations by required argument count */ { - int i, j; + int i,j; for (i = 0; i < nnodes; i++) { - for (j = i + 1; j < nnodes; j++) { - if (nodes[i].argc > nodes[j].argc) { - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } + for (j = i+1; j < nnodes; j++) { + if (nodes[i].argc > nodes[j].argc) { + Overloaded t = nodes[i]; + nodes[i] = nodes[j]; + nodes[j] = t; + } } } } /* Sort the declarations by argument types */ { - int i, j; - for (i = 0; i < nnodes - 1; i++) { - if (nodes[i].argc == nodes[i + 1].argc) { - for (j = i + 1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) { - Parm *p1 = nodes[i].parms; - Parm *p2 = nodes[j].parms; - int differ = 0; - int num_checked = 0; - while (p1 && p2 && (num_checked < nodes[i].argc)) { - if (debugMode) { - Printf(stdout, "p1 = '%s', p2 = '%s'\n", Getattr(p1, "type"), Getattr(p2, "type")); - } - if (checkAttribute(p1, "tmap:in:numinputs", "0")) { - p1 = Getattr(p1, "tmap:in:next"); - continue; - } - if (checkAttribute(p2, "tmap:in:numinputs", "0")) { - p2 = Getattr(p2, "tmap:in:next"); - continue; - } - String *t1 = Getattr(p1, "tmap:typecheck:precedence"); - String *t2 = Getattr(p2, "tmap:typecheck:precedence"); - if (debugMode) { - Printf(stdout, "t1 = '%s', t2 = '%s'\n", t1, t2); - } - if ((!t1) && (!nodes[i].error)) { - Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), - "Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n", - Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); - nodes[i].error = 1; - } else if ((!t2) && (!nodes[j].error)) { - Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n", - Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); - nodes[j].error = 1; - } - if (t1 && t2) { - int t1v, t2v; - t1v = atoi(Char(t1)); - t2v = atoi(Char(t2)); - differ = t1v - t2v; - } else if (!t1 && t2) - differ = 1; - else if (t1 && !t2) - differ = -1; - else if (!t1 && !t2) - differ = -1; - num_checked++; - if (differ > 0) { - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - break; - } else if ((differ == 0) && (Strcmp(t1, "0") == 0)) { - t1 = Getattr(p1, "ltype"); - if (!t1) { - t1 = SwigType_ltype(Getattr(p1, "type")); - if (Getattr(p1, "tmap:typecheck:SWIGTYPE")) { - SwigType_add_pointer(t1); - } - Setattr(p1, "ltype", t1); - } - t2 = Getattr(p2, "ltype"); - if (!t2) { - t2 = SwigType_ltype(Getattr(p2, "type")); - if (Getattr(p2, "tmap:typecheck:SWIGTYPE")) { - SwigType_add_pointer(t2); - } - Setattr(p2, "ltype", t2); - } + int i,j; + for (i = 0; i < nnodes-1; i++) { + if (nodes[i].argc == nodes[i+1].argc) { + for (j = i+1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) { + Parm *p1 = nodes[i].parms; + Parm *p2 = nodes[j].parms; + int differ = 0; + int num_checked = 0; + while (p1 && p2 && (num_checked < nodes[i].argc)) { + if (debugMode) { + Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type")); + } + if (checkAttribute(p1,"tmap:in:numinputs","0")) { + p1 = Getattr(p1,"tmap:in:next"); + continue; + } + if (checkAttribute(p2,"tmap:in:numinputs","0")) { + p2 = Getattr(p2,"tmap:in:next"); + continue; + } + String *t1 = Getattr(p1,"tmap:typecheck:precedence"); + String *t2 = Getattr(p2,"tmap:typecheck:precedence"); + if (debugMode) { + Printf(stdout,"t1 = '%s', t2 = '%s'\n", t1, t2); + } + if ((!t1) && (!nodes[i].error)) { + Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), + "Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n", + Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); + nodes[i].error = 1; + } else if ((!t2) && (!nodes[j].error)) { + Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n", + Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); + nodes[j].error = 1; + } + if (t1 && t2) { + int t1v, t2v; + t1v = atoi(Char(t1)); + t2v = atoi(Char(t2)); + differ = t1v-t2v; + } + else if (!t1 && t2) differ = 1; + else if (t1 && !t2) differ = -1; + else if (!t1 && !t2) differ = -1; + num_checked++; + if (differ > 0) { + Overloaded t = nodes[i]; + nodes[i] = nodes[j]; + nodes[j] = t; + break; + } else if ((differ == 0) && (Strcmp(t1,"0") == 0)) { + t1 = Getattr(p1,"ltype"); + if (!t1) { + t1 = SwigType_ltype(Getattr(p1,"type")); + if (Getattr(p1,"tmap:typecheck:SWIGTYPE")) { + SwigType_add_pointer(t1); + } + Setattr(p1,"ltype",t1); + } + t2 = Getattr(p2,"ltype"); + if (!t2) { + t2 = SwigType_ltype(Getattr(p2,"type")); + if (Getattr(p2,"tmap:typecheck:SWIGTYPE")) { + SwigType_add_pointer(t2); + } + Setattr(p2,"ltype",t2); + } - /* Need subtype check here. If t2 is a subtype of t1, then we need to change the + /* Need subtype check here. If t2 is a subtype of t1, then we need to change the order */ - if (SwigType_issubtype(t2, t1)) { - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } + if (SwigType_issubtype(t2,t1)) { + Overloaded t = nodes[i]; + nodes[i] = nodes[j]; + nodes[j] = t; + } - if (Strcmp(t1, t2) != 0) { - differ = 1; - break; - } - } else if (differ) { - break; - } - if (Getattr(p1, "tmap:in:next")) { - p1 = Getattr(p1, "tmap:in:next"); - } else { - p1 = nextSibling(p1); - } - if (Getattr(p2, "tmap:in:next")) { - p2 = Getattr(p2, "tmap:in:next"); - } else { - p2 = nextSibling(p2); - } - } - if (!differ) { - /* See if declarations differ by const only */ - String *d1 = Getattr(nodes[i].n, "decl"); - String *d2 = Getattr(nodes[j].n, "decl"); - if (d1 && d2) { - String *dq1 = Copy(d1); - String *dq2 = Copy(d2); - if (SwigType_isconst(d1)) { - Delete(SwigType_pop(dq1)); - } - if (SwigType_isconst(d2)) { - Delete(SwigType_pop(dq2)); - } - if (Strcmp(dq1, dq2) == 0) { + if (Strcmp(t1,t2) != 0) { + differ = 1; + break; + } + } else if (differ) { + break; + } + if (Getattr(p1,"tmap:in:next")) { + p1 = Getattr(p1,"tmap:in:next"); + } else { + p1 = nextSibling(p1); + } + if (Getattr(p2,"tmap:in:next")) { + p2 = Getattr(p2,"tmap:in:next"); + } else { + p2 = nextSibling(p2); + } + } + if (!differ) { + /* See if declarations differ by const only */ + String *d1 = Getattr(nodes[i].n, "decl"); + String *d2 = Getattr(nodes[j].n, "decl"); + if (d1 && d2) { + String *dq1 = Copy(d1); + String *dq2 = Copy(d2); + if (SwigType_isconst(d1)) { + Delete(SwigType_pop(dq1)); + } + if (SwigType_isconst(d2)) { + Delete(SwigType_pop(dq2)); + } + if (Strcmp(dq1, dq2) == 0) { - if (SwigType_isconst(d1) && !SwigType_isconst(d2)) { - if (script_lang_wrapping) { - // Swap nodes so that the const method gets ignored (shadowed by the non-const method) - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } - differ = 1; - if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), - "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); - } - } - nodes[j].error = 1; - } else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) { - differ = 1; - if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), - "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); - } - } - nodes[j].error = 1; - } - } - Delete(dq1); - Delete(dq2); - } - } - if (!differ) { - if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n), "as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), "using %s instead.\n", Swig_name_decl(nodes[i].n)); - } - nodes[j].error = 1; - } - } - } + if (SwigType_isconst(d1) && !SwigType_isconst(d2)) { + if (script_lang_wrapping) { + // Swap nodes so that the const method gets ignored (shadowed by the non-const method) + Overloaded t = nodes[i]; + nodes[i] = nodes[j]; + nodes[j] = t; + } + differ = 1; + if (!nodes[j].error) { + if (script_lang_wrapping) { + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), + "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); + } else { + if (!Getattr(nodes[j].n, "overload:ignore")) + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), + "using %s instead.\n", Swig_name_decl(nodes[i].n)); + } + } + nodes[j].error = 1; + } else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) { + differ = 1; + if (!nodes[j].error) { + if (script_lang_wrapping) { + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), + "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); + } else { + if (!Getattr(nodes[j].n, "overload:ignore")) + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), + "using %s instead.\n", Swig_name_decl(nodes[i].n)); + } + } + nodes[j].error = 1; + } + } + Delete(dq1); + Delete(dq2); + } + } + if (!differ) { + if (!nodes[j].error) { + if (script_lang_wrapping) { + Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n), + "as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n)); + } else { + if (!Getattr(nodes[j].n, "overload:ignore")) + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), + "using %s instead.\n", Swig_name_decl(nodes[i].n)); + } + nodes[j].error = 1; + } + } + } } } } @@ -1589,7 +1539,7 @@ List *R::Swig_overload_rank(Node *n, bool script_lang_wrapping) { for (i = 0; i < nnodes; i++) { if (nodes[i].error) Setattr(nodes[i].n, "overload:ignore", "1"); - Append(result, nodes[i].n); + Append(result,nodes[i].n); // Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms)); // Swig_print_node(nodes[i].n); } @@ -1601,33 +1551,37 @@ void R::dispatchFunction(Node *n) { Wrapper *f = NewWrapper(); String *symname = Getattr(n, "sym:name"); String *nodeType = Getattr(n, "nodeType"); - bool constructor = (!Cmp(nodeType, "constructor")); + bool constructor = (!Cmp(nodeType, "constructor")); String *sfname = NewString(symname); if (constructor) Replace(sfname, "new_", "", DOH_REPLACE_FIRST); - Printf(f->def, "`%s` <- function(...) {", sfname); + Printf(f->def, + "`%s` <- function(...) {", sfname); if (debugMode) { Swig_print_node(n); } List *dispatch = Swig_overload_rank(n, true); - int nfunc = Len(dispatch); - Printv(f->code, "argtypes <- mapply(class, list(...));\n", "argv <- list(...);\n", "argc <- length(argtypes);\n", NIL); + int nfunc = Len(dispatch); + Printv(f->code, + "argtypes <- mapply(class, list(...));\n", + "argv <- list(...);\n", + "argc <- length(argtypes);\n", NIL ); Printf(f->code, "# dispatch functions %d\n", nfunc); int cur_args = -1; bool first_compare = true; - for (int i = 0; i < nfunc; i++) { - Node *ni = Getitem(dispatch, i); - Parm *pi = Getattr(ni, "wrap:parms"); + for (int i=0; i < nfunc; i++) { + Node *ni = Getitem(dispatch,i); + Parm *pi = Getattr(ni,"wrap:parms"); int num_arguments = emit_num_arguments(pi); - String *overname = Getattr(ni, "sym:overname"); + String *overname = Getattr(ni,"sym:overname"); if (cur_args != num_arguments) { if (cur_args != -1) { - Printv(f->code, "} else ", NIL); + Printv(f->code, "} else ", NIL); } Printf(f->code, "if (argc == %d) {", num_arguments); cur_args = num_arguments; @@ -1637,52 +1591,67 @@ void R::dispatchFunction(Node *n) { int j; if (num_arguments > 0) { if (!first_compare) { - Printv(f->code, " else ", NIL); + Printv(f->code, " else ", NIL); } else { - first_compare = false; + first_compare = false; } Printv(f->code, "if (", NIL); - for (p = pi, j = 0; j < num_arguments; j++) { - if (debugMode) { - Swig_print_node(p); - } - String *tm = Swig_typemap_lookup("rtype", p, "", 0); - if (tm) { - replaceRClass(tm, Getattr(p, "type")); - } + for (p =pi, j = 0 ; j < num_arguments ; j++) { + if (debugMode) { + Swig_print_node(p); + } + String *tm = Swig_typemap_lookup("rtype", p, "", 0); + if(tm) { + replaceRClass(tm, Getattr(p, "type")); + } - String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0); - if (tmcheck) { - String *tmp = NewString(""); - Printf(tmp, "argv[[%d]]", j + 1); - Replaceall(tmcheck, "$arg", tmp); - Printf(tmp, "argtype[%d]", j + 1); - Replaceall(tmcheck, "$argtype", tmp); - if (tm) { - Replaceall(tmcheck, "$rtype", tm); - } - if (debugMode) { - Printf(stdout, "%s\n", tmcheck); - } - Printf(f->code, "%s(%s)", j == 0 ? "" : " && ", tmcheck); - p = Getattr(p, "tmap:in:next"); - continue; - } - if (tm) { - if (Strcmp(tm, "numeric") == 0) { - Printf(f->code, "%sis.numeric(argv[[%d]])", j == 0 ? "" : " && ", j + 1); - } else if (Strcmp(tm, "integer") == 0) { - Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))", j == 0 ? "" : " && ", j + 1, j + 1); - } else if (Strcmp(tm, "character") == 0) { - Printf(f->code, "%sis.character(argv[[%d]])", j == 0 ? "" : " && ", j + 1); - } else { - Printf(f->code, "%sextends(argtypes[%d], '%s')", j == 0 ? "" : " && ", j + 1, tm); - } - } - if (!SwigType_ispointer(Getattr(p, "type"))) { - Printf(f->code, " && length(argv[[%d]]) == 1", j + 1); - } - p = Getattr(p, "tmap:in:next"); + String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0); + if (tmcheck) { + String *tmp = NewString(""); + Printf(tmp, "argv[[%d]]", j+1); + Replaceall(tmcheck, "$arg", tmp); + Printf(tmp, "argtype[%d]", j+1); + Replaceall(tmcheck, "$argtype", tmp); + if (tm) { + Replaceall(tmcheck, "$rtype", tm); + } + if (debugMode) { + Printf(stdout, "%s\n", tmcheck); + } + Printf(f->code, "%s(%s)", + j == 0? "" : " && ", + tmcheck); + p = Getattr(p, "tmap:in:next"); + continue; + } + if (tm) { + if (Strcmp(tm,"numeric")==0) { + Printf(f->code, "%sis.numeric(argv[[%d]])", + j == 0 ? "" : " && ", + j+1); + } + else if (Strcmp(tm,"integer")==0) { + Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))", + j == 0 ? "" : " && ", + j+1, j+1); + } + else if (Strcmp(tm,"character")==0) { + Printf(f->code, "%sis.character(argv[[%d]])", + j == 0 ? "" : " && ", + j+1); + } + else { + Printf(f->code, "%sextends(argtypes[%d], '%s')", + j == 0 ? "" : " && ", + j+1, + tm); + } + } + if (!SwigType_ispointer(Getattr(p, "type"))) { + Printf(f->code, " && length(argv[[%d]]) == 1", + j+1); + } + p = Getattr(p, "tmap:in:next"); } Printf(f->code, ") { f <- %s%s; }\n", sfname, overname); } else { @@ -1690,7 +1659,10 @@ void R::dispatchFunction(Node *n) { } } if (cur_args != -1) { - Printf(f->code, "} else {\n" "stop(\"cannot find overloaded function for %s with argtypes (\"," "toString(argtypes),\")\");\n" "}", sfname); + Printf(f->code, "} else {\n" + "stop(\"cannot find overloaded function for %s with argtypes (\"," + "toString(argtypes),\")\");\n" + "}", sfname); } Printv(f->code, ";\nf(...)", NIL); Printv(f->code, ";\n}", NIL); @@ -1705,77 +1677,86 @@ void R::dispatchFunction(Node *n) { int R::functionWrapper(Node *n) { String *fname = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); - String *type = Getattr(n, "type"); - + String *type = Getattr(n, "type"); + if (debugMode) { - Printf(stdout, " %s %s %s\n", fname, iname, type); + Printf(stdout, + " %s %s %s\n", fname, iname, type); } String *overname = 0; String *nodeType = Getattr(n, "nodeType"); - bool constructor = (!Cmp(nodeType, "constructor")); - bool destructor = (!Cmp(nodeType, "destructor")); - + bool constructor = (!Cmp(nodeType, "constructor")); + bool destructor = (!Cmp(nodeType, "destructor")); + String *sfname = NewString(iname); - + if (constructor) Replace(sfname, "new_", "", DOH_REPLACE_FIRST); - - if (Getattr(n, "sym:overloaded")) { - overname = Getattr(n, "sym:overname"); + + if (Getattr(n,"sym:overloaded")) { + overname = Getattr(n,"sym:overname"); Append(sfname, overname); } - - if (debugMode) - Printf(stdout, " processing parameters\n"); - - + + if (debugMode) + Printf(stdout, + " processing parameters\n"); + + ParmList *l = Getattr(n, "parms"); Parm *p; String *tm; - + p = l; - while (p) { + while(p) { SwigType *resultType = Getattr(p, "type"); - if (expandTypedef(resultType) && SwigType_istypedef(resultType)) { - SwigType *resolved = SwigType_typedef_resolve_all(resultType); + if (expandTypedef(resultType) && + SwigType_istypedef(resultType)) { + SwigType *resolved = + SwigType_typedef_resolve_all(resultType); if (expandTypedef(resolved)) { - Setattr(p, "type", Copy(resolved)); + Setattr(p, "type", Copy(resolved)); } } p = nextSibling(p); - } + } - String *unresolved_return_type = Copy(type); - if (expandTypedef(type) && SwigType_istypedef(type)) { - SwigType *resolved = SwigType_typedef_resolve_all(type); + String *unresolved_return_type = + Copy(type); + if (expandTypedef(type) && + SwigType_istypedef(type)) { + SwigType *resolved = + SwigType_typedef_resolve_all(type); if (expandTypedef(resolved)) { type = Copy(resolved); Setattr(n, "type", type); } } - if (debugMode) - Printf(stdout, " unresolved_return_type %s\n", unresolved_return_type); - if (processing_member_access_function) { + if (debugMode) + Printf(stdout, " unresolved_return_type %s\n", + unresolved_return_type); + if(processing_member_access_function) { if (debugMode) - Printf(stdout, " '%s' '%s' '%s' '%s'\n", fname, iname, member_name, class_name); - - if (opaqueClassDeclaration) + Printf(stdout, " '%s' '%s' '%s' '%s'\n", + fname, iname, member_name, class_name); + + if(opaqueClassDeclaration) return SWIG_OK; - - - /* Add the name of this member to a list for this class_name. + + + /* Add the name of this member to a list for this class_name. We will dump all these at the end. */ - + int n = Len(iname); char *ptr = Char(iname); - bool isSet(Strcmp(NewString(&ptr[n - 3]), "set") == 0); - - + bool isSet(Strcmp(NewString(&ptr[n-3]), "set") == 0); + + String *tmp = NewString(""); Printf(tmp, "%s_%s", class_name, isSet ? "set" : "get"); - + List *memList = Getattr(ClassMemberTable, tmp); - if (!memList) { + if(!memList) { memList = NewList(); Append(memList, class_name); Setattr(ClassMemberTable, tmp, memList); @@ -1784,29 +1765,29 @@ int R::functionWrapper(Node *n) { Append(memList, member_name); Append(memList, iname); } - + int i; int nargs; - + String *wname = Swig_name_wrapper(iname); Replace(wname, "_wrap", "R_swig", DOH_REPLACE_FIRST); - if (overname) + if(overname) Append(wname, overname); - Setattr(n, "wrap:name", wname); + Setattr(n,"wrap:name", wname); Wrapper *f = NewWrapper(); Wrapper *sfun = NewWrapper(); - + int isVoidReturnType = (Strcmp(type, "void") == 0); - // Need to use the unresolved return type since - // typedef resolution removes the const which causes a + // Need to use the unresolved return type since + // typedef resolution removes the const which causes a // mismatch with the function action emit_return_variable(n, unresolved_return_type, f); SwigType *rtype = Getattr(n, "type"); int addCopyParam = 0; - if (!isVoidReturnType) + if(!isVoidReturnType) addCopyParam = addCopyParameter(rtype); @@ -1815,14 +1796,15 @@ int R::functionWrapper(Node *n) { // if(addCopyParam) if (debugMode) - Printf(stdout, "Adding a .copy argument to %s for %s = %s\n", iname, type, addCopyParam ? "yes" : "no"); + Printf(stdout, "Adding a .copy argument to %s for %s = %s\n", + iname, type, addCopyParam ? "yes" : "no"); Printv(f->def, "SWIGEXPORT SEXP\n", wname, " ( ", NIL); - Printf(sfun->def, "# Start of %s\n", iname); + Printf(sfun->def, "# Start of %s\n", iname); Printv(sfun->def, "\n`", sfname, "` = function(", NIL); - if (outputNamespaceInfo) //XXX Need to be a little more discriminating + if(outputNamespaceInfo) //XXX Need to be a little more discriminating addNamespaceFunction(iname); Swig_typemap_attach_parms("scoercein", l, f); @@ -1830,8 +1812,8 @@ int R::functionWrapper(Node *n) { Swig_typemap_attach_parms("scheck", l, f); emit_parameter_variables(l, f); - emit_attach_parmmaps(l, f); - Setattr(n, "wrap:parms", l); + emit_attach_parmmaps(l,f); + Setattr(n,"wrap:parms",l); nargs = emit_num_arguments(l); @@ -1847,7 +1829,7 @@ int R::functionWrapper(Node *n) { bool inFirstArg = true; bool inFirstType = true; Parm *curP; - for (p = l, i = 0; i < nargs; i++) { + for (p =l, i = 0 ; i < nargs ; i++) { while (checkAttribute(p, "tmap:in:numinputs", "0")) { p = Getattr(p, "tmap:in:next"); @@ -1858,26 +1840,26 @@ int R::functionWrapper(Node *n) { String *funcptr_name = processType(tt, p, &nargs); // SwigType *tp = Getattr(p, "type"); - String *name = Getattr(p, "name"); - String *lname = Getattr(p, "lname"); + String *name = Getattr(p,"name"); + String *lname = Getattr(p,"lname"); // R keyword renaming if (name) { if (Swig_name_warning(p, 0, name, 0)) { - name = 0; + name = 0; } else { - /* If we have a :: in the parameter name because we are accessing a static member of a class, say, then - we need to remove that prefix. */ - while (Strstr(name, "::")) { - //XXX need to free. - name = NewStringf("%s", Strchr(name, ':') + 2); - if (debugMode) - Printf(stdout, "+++ parameter name with :: in it %s\n", name); - } + /* If we have a :: in the parameter name because we are accessing a static member of a class, say, then + we need to remove that prefix. */ + while (Strstr(name, "::")) { + //XXX need to free. + name = NewStringf("%s", Strchr(name, ':') + 2); + if (debugMode) + Printf(stdout, "+++ parameter name with :: in it %s\n", name); + } } } if (!name || Len(name) == 0) - name = NewStringf("s_arg%d", i + 1); + name = NewStringf("s_arg%d", i+1); name = replaceInitialDash(name); @@ -1885,13 +1867,13 @@ int R::functionWrapper(Node *n) { name = Copy(name); Insert(name, 0, "s_"); } - - if (processing_variable) { + + if(processing_variable) { name = Copy(name); Insert(name, 0, "s_"); } - if (!Strcmp(name, fname)) { + if(!Strcmp(name, fname)) { name = Copy(name); Insert(name, 0, "s_"); } @@ -1899,73 +1881,79 @@ int R::functionWrapper(Node *n) { Printf(sargs, "%s, ", name); String *tm; - if ((tm = Getattr(p, "tmap:scoercein"))) { + if((tm = Getattr(p, "tmap:scoercein"))) { Replaceall(tm, "$input", name); replaceRClass(tm, Getattr(p, "type")); - if (funcptr_name) { - //XXX need to get this to return non-zero - if (nargs == -1) - nargs = getFunctionPointerNumArgs(p, tt); + if(funcptr_name) { + //XXX need to get this to return non-zero + if(nargs == -1) + nargs = getFunctionPointerNumArgs(p, tt); - String *snargs = NewStringf("%d", nargs); - Printv(sfun->code, "if(is.function(", name, ")) {", "\n", - "assert('...' %in% names(formals(", name, ")) || length(formals(", name, ")) >= ", snargs, ");\n} ", NIL); - Delete(snargs); + String *snargs = NewStringf("%d", nargs); + Printv(sfun->code, "if(is.function(", name, ")) {", "\n", + "assert('...' %in% names(formals(", name, + ")) || length(formals(", name, ")) >= ", snargs, ");\n} ", NIL); + Delete(snargs); - Printv(sfun->code, "else {\n", - "if(is.character(", name, ")) {\n", - name, " = getNativeSymbolInfo(", name, ");", - "\n};\n", - "if(is(", name, ", \"NativeSymbolInfo\")) {\n", - name, " = ", name, "$address", ";\n}\n", "if(is(", name, ", \"ExternalReference\")) {\n", name, " = ", name, "@ref;\n}\n", "}; \n", NIL); + Printv(sfun->code, "else {\n", + "if(is.character(", name, ")) {\n", + name, " = getNativeSymbolInfo(", name, ");", + "\n};\n", + "if(is(", name, ", \"NativeSymbolInfo\")) {\n", + name, " = ", name, "$address", ";\n}\n", + "if(is(", name, ", \"ExternalReference\")) {\n", + name, " = ", name, "@ref;\n}\n", + "}; \n", + NIL); } else { - Printf(sfun->code, "%s\n", tm); + Printf(sfun->code, "%s\n", tm); } } Printv(sfun->def, inFirstArg ? "" : ", ", name, NIL); - if ((tm = Getattr(p, "tmap:scheck"))) { + if ((tm = Getattr(p,"tmap:scheck"))) { - Replaceall(tm, "$target", lname); - Replaceall(tm, "$source", name); - Replaceall(tm, "$input", name); + Replaceall(tm,"$target", lname); + Replaceall(tm,"$source", name); + Replaceall(tm,"$input", name); replaceRClass(tm, Getattr(p, "type")); - Printf(sfun->code, "%s\n", tm); + Printf(sfun->code,"%s\n",tm); } curP = p; - if ((tm = Getattr(p, "tmap:in"))) { + if ((tm = Getattr(p,"tmap:in"))) { - Replaceall(tm, "$target", lname); - Replaceall(tm, "$source", name); - Replaceall(tm, "$input", name); + Replaceall(tm,"$target", lname); + Replaceall(tm,"$source", name); + Replaceall(tm,"$input", name); - if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) { - Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); + if (Getattr(p,"wrap:disown") || (Getattr(p,"tmap:in:disown"))) { + Replaceall(tm,"$disown","SWIG_POINTER_DISOWN"); } else { - Replaceall(tm, "$disown", "0"); + Replaceall(tm,"$disown","0"); } - if (funcptr_name) { - /* have us a function pointer */ - Printf(f->code, "if(TYPEOF(%s) != CLOSXP) {\n", name); - Replaceall(tm, "$R_class", ""); + if(funcptr_name) { + /* have us a function pointer */ + Printf(f->code, "if(TYPEOF(%s) != CLOSXP) {\n", name); + Replaceall(tm,"$R_class", ""); } else { - replaceRClass(tm, Getattr(p, "type")); + replaceRClass(tm, Getattr(p, "type")); } - Printf(f->code, "%s\n", tm); - if (funcptr_name) - Printf(f->code, "} else {\n%s = %s;\nR_SWIG_pushCallbackFunctionData(%s, NULL);\n}\n", lname, funcptr_name, name); + Printf(f->code,"%s\n",tm); + if(funcptr_name) + Printf(f->code, "} else {\n%s = %s;\nR_SWIG_pushCallbackFunctionData(%s, NULL);\n}\n", + lname, funcptr_name, name); Printv(f->def, inFirstArg ? "" : ", ", "SEXP ", name, NIL); - if (Len(name) != 0) - inFirstArg = false; - p = Getattr(p, "tmap:in:next"); + if (Len(name) != 0) + inFirstArg = false; + p = Getattr(p,"tmap:in:next"); } else { p = nextSibling(p); @@ -1973,18 +1961,18 @@ int R::functionWrapper(Node *n) { tm = Swig_typemap_lookup("rtype", curP, "", 0); - if (tm) { + if(tm) { replaceRClass(tm, Getattr(curP, "type")); } Printf(s_inputTypes, "%s'%s'", inFirstType ? "" : ", ", tm); Printf(s_inputMap, "%s%s='%s'", inFirstType ? "" : ", ", name, tm); inFirstType = false; - if (funcptr_name) + if(funcptr_name) Delete(funcptr_name); - } /* end of looping over parameters. */ + } /* end of looping over parameters. */ - if (addCopyParam) { + if(addCopyParam) { Printf(sfun->def, "%s.copy = FALSE", nargs > 0 ? ", " : ""); Printf(f->def, "%sSEXP s_swig_copy", nargs > 0 ? ", " : ""); @@ -2009,21 +1997,21 @@ int R::functionWrapper(Node *n) { String *outargs = NewString(""); int numOutArgs = isVoidReturnType ? -1 : 0; - for (p = l, i = 0; p; i++) { - if ((tm = Getattr(p, "tmap:argout"))) { + for(p = l, i = 0; p; i++) { + if((tm = Getattr(p, "tmap:argout"))) { // String *lname = Getattr(p, "lname"); numOutArgs++; String *pos = NewStringf("%d", numOutArgs); - Replaceall(tm, "$source", Getattr(p, "lname")); - Replaceall(tm, "$result", "r_ans"); - Replaceall(tm, "$n", pos); // The position into which to store the answer. - Replaceall(tm, "$arg", Getattr(p, "emit:input")); - Replaceall(tm, "$input", Getattr(p, "emit:input")); - Replaceall(tm, "$owner", "R_SWIG_EXTERNAL"); + Replaceall(tm,"$source", Getattr(p, "lname")); + Replaceall(tm,"$result", "r_ans"); + Replaceall(tm,"$n", pos); // The position into which to store the answer. + Replaceall(tm,"$arg", Getattr(p, "emit:input")); + Replaceall(tm,"$input", Getattr(p, "emit:input")); + Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); Printf(outargs, "%s\n", tm); - p = Getattr(p, "tmap:argout:next"); + p = Getattr(p,"tmap:argout:next"); } else p = nextSibling(p); } @@ -2031,57 +2019,60 @@ int R::functionWrapper(Node *n) { String *actioncode = emit_action(n); /* Deal with the explicit return value. */ - if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { + if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { SwigType *retType = Getattr(n, "type"); - //Printf(stdout, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no"); + //Printf(stdout, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no"); /* if(SwigType_isarray(retType)) { - defineArrayAccessors(retType); - } */ + defineArrayAccessors(retType); + } */ - Replaceall(tm, "$1", Swig_cresult_name()); - Replaceall(tm, "$result", "r_ans"); + Replaceall(tm,"$1", Swig_cresult_name()); + Replaceall(tm,"$result", "r_ans"); replaceRClass(tm, retType); - if (GetFlag(n, "feature:new")) { + if (GetFlag(n,"feature:new")) { Replaceall(tm, "$owner", "R_SWIG_OWNER"); } else { - Replaceall(tm, "$owner", "R_SWIG_EXTERNAL"); + Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); } #if 0 - if (addCopyParam) { + if(addCopyParam) { Printf(f->code, "if(LOGICAL(s_swig_copy)[0]) {\n"); Printf(f->code, "/* Deal with returning a reference. */\nr_ans = R_NilValue;\n"); Printf(f->code, "}\n else {\n"); - } + } #endif Printf(f->code, "%s\n", tm); #if 0 - if (addCopyParam) - Printf(f->code, "}\n"); /* end of if(s_swig_copy) ... else { ... } */ + if(addCopyParam) + Printf(f->code, "}\n"); /* end of if(s_swig_copy) ... else { ... } */ #endif } else { - Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(type, 0), fname); + Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, + "Unable to use return type %s in function %s.\n", SwigType_str(type, 0), fname); } - if (Len(outargs)) { + if(Len(outargs)) { Wrapper_add_local(f, "R_OutputValues", "SEXP R_OutputValues"); String *tmp = NewString(""); - if (!isVoidReturnType) + if(!isVoidReturnType) Printf(tmp, "Rf_protect(r_ans);\n"); - Printf(tmp, "Rf_protect(R_OutputValues = Rf_allocVector(VECSXP,%d));\nr_nprotect += %d;\n", numOutArgs + !isVoidReturnType, isVoidReturnType ? 1 : 2); + Printf(tmp, "Rf_protect(R_OutputValues = Rf_allocVector(VECSXP,%d));\nr_nprotect += %d;\n", + numOutArgs + !isVoidReturnType, + isVoidReturnType ? 1 : 2); - if (!isVoidReturnType) + if(!isVoidReturnType) Printf(tmp, "SET_VECTOR_ELT(R_OutputValues, 0, r_ans);\n"); Printf(tmp, "r_ans = R_OutputValues;\n"); Insert(outargs, 0, tmp); - Delete(tmp); + Delete(tmp); @@ -2097,7 +2088,7 @@ int R::functionWrapper(Node *n) { /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { - Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ + Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */ Printf(f->code, "%s\n", tm); } } @@ -2106,23 +2097,26 @@ int R::functionWrapper(Node *n) { /*If the user gave us something to convert the result in */ if ((tm = Swig_typemap_lookup("scoerceout", n, Swig_cresult_name(), sfun))) { - Replaceall(tm, "$source", "ans"); - Replaceall(tm, "$result", "ans"); + Replaceall(tm,"$source","ans"); + Replaceall(tm,"$result","ans"); replaceRClass(tm, Getattr(n, "type")); Chop(tm); } - Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname, "', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL); - if (Len(tm)) { - Printf(sfun->code, "%s\n\n", tm); - if (constructor) { - String *finalizer = NewString(iname); - Replace(finalizer, "new_", "", DOH_REPLACE_FIRST); - Printf(sfun->code, "reg.finalizer(ans@ref, delete_%s)\n", finalizer); + Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname, + "', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL); + if(Len(tm)) + { + Printf(sfun->code, "%s\n\n", tm); + if (constructor) + { + String *finalizer = NewString(iname); + Replace(finalizer, "new_", "", DOH_REPLACE_FIRST); + Printf(sfun->code, "reg.finalizer(ans@ref, delete_%s)\n", finalizer); + } + Printf(sfun->code, "ans\n"); } - Printf(sfun->code, "ans\n"); - } if (destructor) Printv(f->code, "R_ClearExternalPtr(self);\n", NIL); @@ -2131,23 +2125,27 @@ int R::functionWrapper(Node *n) { Printv(sfun->code, "\n}", NIL); /* Substitute the function name */ - Replaceall(f->code, "$symname", iname); + Replaceall(f->code,"$symname",iname); Wrapper_print(f, f_wrapper); Wrapper_print(sfun, sfile); Printf(sfun->code, "\n# End of %s\n", iname); tm = Swig_typemap_lookup("rtype", n, "", 0); - if (tm) { + if(tm) { SwigType *retType = Getattr(n, "type"); replaceRClass(tm, retType); - } - - Printv(sfile, "attr(`", sfname, "`, 'returnType') = '", isVoidReturnType ? "void" : (tm ? tm : ""), "'\n", NIL); - - if (nargs > 0) - Printv(sfile, "attr(`", sfname, "`, \"inputTypes\") = c(", s_inputTypes, ")\n", NIL); - Printv(sfile, "class(`", sfname, "`) = c(\"SWIGFunction\", class('", sfname, "'))\n\n", NIL); + } + + Printv(sfile, "attr(`", sfname, "`, 'returnType') = '", + isVoidReturnType ? "void" : (tm ? tm : ""), + "'\n", NIL); + + if(nargs > 0) + Printv(sfile, "attr(`", sfname, "`, \"inputTypes\") = c(", + s_inputTypes, ")\n", NIL); + Printv(sfile, "class(`", sfname, "`) = c(\"SWIGFunction\", class('", + sfname, "'))\n\n", NIL); if (memoryProfile) { Printv(sfile, "memory.profile()\n", NIL); @@ -2155,24 +2153,26 @@ int R::functionWrapper(Node *n) { if (aggressiveGc) { Printv(sfile, "gc()\n", NIL); } + // Printv(sfile, "setMethod('", name, "', '", name, "', ", iname, ")\n\n\n"); - /* If we are dealing with a method in an C++ class, then - add the name of the R function and its definition. + /* If we are dealing with a method in an C++ class, then + add the name of the R function and its definition. XXX need to figure out how to store the Wrapper if possible in the hash/list. Would like to be able to do this so that we can potentially insert - */ - if (processing_member_access_function || processing_class_member_function) { + */ + if(processing_member_access_function || processing_class_member_function) { addAccessor(member_name, sfun, iname); } - if (Getattr(n, "sym:overloaded") && !Getattr(n, "sym:nextSibling")) { + if (Getattr(n, "sym:overloaded") && + !Getattr(n, "sym:nextSibling")) { dispatchFunction(n); } - addRegistrationRoutine(wname, addCopyParam ? nargs + 1 : nargs); + addRegistrationRoutine(wname, addCopyParam ? nargs +1 : nargs); DelWrapper(f); DelWrapper(sfun); @@ -2193,20 +2193,21 @@ int R::constantWrapper(Node *n) { } /***************************************************** - Add the specified routine name to the collection of + Add the specified routine name to the collection of generated routines that are called from R functions. - This is used to register the routines with R for + This is used to register the routines with R for resolving symbols. rname - the name of the routine - nargs - the number of arguments it expects. + nargs - the number of arguments it expects. ******************************************************/ int R::addRegistrationRoutine(String *rname, int nargs) { - if (!registrationTable) + if(!registrationTable) registrationTable = NewHash(); - String *el = NewStringf("{\"%s\", (DL_FUNC) &%s, %d}", rname, rname, nargs); - + String *el = + NewStringf("{\"%s\", (DL_FUNC) &%s, %d}", rname, rname, nargs); + Setattr(registrationTable, rname, el); return SWIG_OK; @@ -2219,30 +2220,30 @@ int R::addRegistrationRoutine(String *rname, int nargs) { ******************************************************/ int R::outputRegistrationRoutines(File *out) { int i, n; - if (!registrationTable) - return (0); - if (inCPlusMode) + if(!registrationTable) + return(0); + if(inCPlusMode) Printf(out, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n"); Printf(out, "#include \n\n"); - if (inCPlusMode) + if(inCPlusMode) Printf(out, "#ifdef __cplusplus\n}\n#endif\n\n"); Printf(out, "SWIGINTERN R_CallMethodDef CallEntries[] = {\n"); - + List *keys = Keys(registrationTable); n = Len(keys); - for (i = 0; i < n; i++) + for(i = 0; i < n; i++) Printf(out, " %s,\n", Getattr(registrationTable, Getitem(keys, i))); Printf(out, " {NULL, NULL, 0}\n};\n\n"); - if (!noInitializationCode) { + if(!noInitializationCode) { if (inCPlusMode) Printv(out, "extern \"C\" ", NIL); Printf(out, "SWIGEXPORT void R_init_%s(DllInfo *dll) {\n", Rpackage); Printf(out, "%sR_registerRoutines(dll, NULL, CallEntries, NULL, NULL);\n", tab4); - if (Len(s_init_routine)) { + if(Len(s_init_routine)) { Printf(out, "\n%s\n", s_init_routine); } Printf(out, "}\n"); @@ -2256,58 +2257,60 @@ int R::outputRegistrationRoutines(File *out) { /**************************************************************************** Process a struct, union or class declaration in the source code, or an anonymous typedef struct - + *****************************************************************************/ -//XXX What do we need to do here - +//XXX What do we need to do here - // Define an S4 class to refer to this. void R::registerClass(Node *n) { - String *name = Getattr(n, "name"); - String *kind = Getattr(n, "kind"); + String *name = Getattr(n, "name"); + String *kind = Getattr(n, "kind"); if (debugMode) Swig_print_node(n); String *sname = NewStringf("_p%s", SwigType_manglestr(name)); - if (!Getattr(SClassDefs, sname)) { + if(!Getattr(SClassDefs, sname)) { Setattr(SClassDefs, sname, sname); String *base; - if (Strcmp(kind, "class") == 0) { + if(Strcmp(kind, "class") == 0) { base = NewString(""); List *l = Getattr(n, "bases"); - if (Len(l)) { - Printf(base, "c("); - for (int i = 0; i < Len(l); i++) { - registerClass(Getitem(l, i)); - Printf(base, "'_p%s'%s", SwigType_manglestr(Getattr(Getitem(l, i), "name")), i < Len(l) - 1 ? ", " : ""); - } - Printf(base, ")"); + if(Len(l)) { + Printf(base, "c("); + for(int i = 0; i < Len(l); i++) { + registerClass(Getitem(l, i)); + Printf(base, "'_p%s'%s", + SwigType_manglestr(Getattr(Getitem(l, i), "name")), + i < Len(l)-1 ? ", " : ""); + } + Printf(base, ")"); } else { - base = NewString("'C++Reference'"); + base = NewString("'C++Reference'"); } - } else + } else base = NewString("'ExternalReference'"); Printf(s_classes, "setClass('%s', contains = %s)\n", sname, base); Delete(base); } - + } int R::classDeclaration(Node *n) { - String *name = Getattr(n, "name"); - String *kind = Getattr(n, "kind"); + String *name = Getattr(n, "name"); + String *kind = Getattr(n, "kind"); if (debugMode) Swig_print_node(n); registerClass(n); - + /* If we have a typedef union { ... } U, then we never get to see the typedef via a regular call to typedefHandler. Instead, */ - if (Getattr(n, "unnamed") && Getattr(n, "storage") && Strcmp(Getattr(n, "storage"), "typedef") == 0 - && Getattr(n, "tdname") && Strcmp(Getattr(n, "tdname"), name) == 0) { + if(Getattr(n, "unnamed") && Getattr(n, "storage") && Strcmp(Getattr(n, "storage"), "typedef") == 0 + && Getattr(n, "tdname") && Strcmp(Getattr(n, "tdname"), name) == 0) { if (debugMode) Printf(stdout, "Typedef in the class declaration for %s\n", name); // typedefHandler(n); @@ -2315,7 +2318,7 @@ int R::classDeclaration(Node *n) { bool opaque = GetFlag(n, "feature:opaque") ? true : false; - if (opaque) + if(opaque) opaqueClassDeclaration = name; int status = Language::classDeclaration(n); @@ -2323,72 +2326,76 @@ int R::classDeclaration(Node *n) { opaqueClassDeclaration = NULL; - // OutputArrayMethod(name, class_member_functions, sfile); + // OutputArrayMethod(name, class_member_functions, sfile); if (class_member_functions) OutputMemberReferenceMethod(name, 0, class_member_functions, sfile); if (class_member_set_functions) OutputMemberReferenceMethod(name, 1, class_member_set_functions, sfile); - if (class_member_functions) { + if(class_member_functions) { Delete(class_member_functions); class_member_functions = NULL; } - if (class_member_set_functions) { + if(class_member_set_functions) { Delete(class_member_set_functions); class_member_set_functions = NULL; } if (Getattr(n, "has_destructor")) { - Printf(sfile, "setMethod('delete', '_p%s', function(obj) {delete%s(obj)})\n", getRClassName(Getattr(n, "name")), getRClassName(Getattr(n, "name"))); + Printf(sfile, "setMethod('delete', '_p%s', function(obj) {delete%s(obj)})\n", + getRClassName(Getattr(n, "name")), + getRClassName(Getattr(n, "name"))); } - if (!opaque && !Strcmp(kind, "struct") && copyStruct) { + if(!opaque && !Strcmp(kind, "struct") && copyStruct) { - String *def = NewStringf("setClass(\"%s\",\n%srepresentation(\n", name, tab4); + String *def = + NewStringf("setClass(\"%s\",\n%srepresentation(\n", name, tab4); bool firstItem = true; - for (Node *c = firstChild(n); c;) { + for(Node *c = firstChild(n); c; ) { String *elName; String *tp; elName = Getattr(c, "name"); - + String *elKind = Getattr(c, "kind"); if (!Equal(elKind, "variable")) { - c = nextSibling(c); - continue; + c = nextSibling(c); + continue; } if (!Len(elName)) { - c = nextSibling(c); - continue; + c = nextSibling(c); + continue; } #if 0 tp = getRType(c); #else tp = Swig_typemap_lookup("rtype", c, "", 0); - if (!tp) { - c = nextSibling(c); - continue; + if(!tp) { + c = nextSibling(c); + continue; } if (Strstr(tp, "R_class")) { - c = nextSibling(c); - continue; + c = nextSibling(c); + continue; } - if (Strcmp(tp, "character") && Strstr(Getattr(c, "decl"), "p.")) { - c = nextSibling(c); - continue; + if (Strcmp(tp, "character") && + Strstr(Getattr(c, "decl"), "p.")) { + c = nextSibling(c); + continue; } if (!firstItem) { - Printf(def, ",\n"); - } - // else + Printf(def, ",\n"); + } + // else //XXX How can we tell if this is already done. - // SwigType_push(elType, elDecl); - - + // SwigType_push(elType, elDecl); + + // returns "" tp = processType(elType, c, NULL); - // Printf(stdout, " elType %p\n", elType); - // tp = getRClassNameCopyStruct(Getattr(c, "type"), 1); + // Printf(stdout, " elType %p\n", elType); + // tp = getRClassNameCopyStruct(Getattr(c, "type"), 1); #endif String *elNameT = replaceInitialDash(elName); Printf(def, "%s%s = \"%s\"", tab8, elNameT, tp); @@ -2424,13 +2431,13 @@ int R::classDeclaration(Node *n) { int R::generateCopyRoutines(Node *n) { Wrapper *copyToR = NewWrapper(); Wrapper *copyToC = NewWrapper(); - + String *name = Getattr(n, "name"); String *tdname = Getattr(n, "tdname"); String *kind = Getattr(n, "kind"); String *type; - if (Len(tdname)) { + if(Len(tdname)) { type = Copy(tdname); } else { type = NewStringf("%s %s", kind, name); @@ -2441,12 +2448,14 @@ int R::generateCopyRoutines(Node *n) { if (debugMode) Printf(stdout, "generateCopyRoutines: name = %s, %s\n", name, type); - Printf(copyToR->def, "CopyToR%s = function(value, obj = new(\"%s\"))\n{\n", mangledName, name); - Printf(copyToC->def, "CopyToC%s = function(value, obj)\n{\n", mangledName); + Printf(copyToR->def, "CopyToR%s = function(value, obj = new(\"%s\"))\n{\n", + mangledName, name); + Printf(copyToC->def, "CopyToC%s = function(value, obj)\n{\n", + mangledName); Node *c = firstChild(n); - for (; c; c = nextSibling(c)) { + for(; c; c = nextSibling(c)) { String *elName = Getattr(c, "name"); if (!Len(elName)) { continue; @@ -2457,13 +2466,14 @@ int R::generateCopyRoutines(Node *n) { } String *tp = Swig_typemap_lookup("rtype", c, "", 0); - if (!tp) { + if(!tp) { continue; } if (Strstr(tp, "R_class")) { continue; } - if (Strcmp(tp, "character") && Strstr(Getattr(c, "decl"), "p.")) { + if (Strcmp(tp, "character") && + Strstr(Getattr(c, "decl"), "p.")) { continue; } @@ -2475,25 +2485,26 @@ int R::generateCopyRoutines(Node *n) { Delete(elNameT); } Printf(copyToR->code, "obj;\n}\n\n"); - String *rclassName = getRClassNameCopyStruct(type, 0); // without the Ref. - Printf(sfile, "# Start definition of copy functions & methods for %s\n", rclassName); - + String *rclassName = getRClassNameCopyStruct(type, 0); // without the Ref. + Printf(sfile, "# Start definition of copy functions & methods for %s\n", rclassName); + Wrapper_print(copyToR, sfile); Printf(copyToC->code, "obj\n}\n\n"); Wrapper_print(copyToC, sfile); - - - Printf(sfile, "# Start definition of copy methods for %s\n", rclassName); - Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s);\n", rclassName, mangledName); - Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s);\n\n", rclassName, mangledName); - - Printf(sfile, "# End definition of copy methods for %s\n", rclassName); - Printf(sfile, "# End definition of copy functions & methods for %s\n", rclassName); - + + + Printf(sfile, "# Start definition of copy methods for %s\n", rclassName); + Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s);\n", rclassName, + mangledName); + Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s);\n\n", rclassName, + mangledName); + + Printf(sfile, "# End definition of copy methods for %s\n", rclassName); + Printf(sfile, "# End definition of copy functions & methods for %s\n", rclassName); + String *m = NewStringf("%sCopyToR", name); addNamespaceMethod(m); - char *tt = Char(m); - tt[Len(m) - 1] = 'C'; + char *tt = Char(m); tt[Len(m)-1] = 'C'; addNamespaceMethod(m); Delete(m); Delete(rclassName); @@ -2507,9 +2518,9 @@ int R::generateCopyRoutines(Node *n) { /***** - Called when there is a typedef to be invoked. + Called when there is a typedef to be invoked. - XXX Needs to be enhanced or split to handle the case where we have a + XXX Needs to be enhanced or split to handle the case where we have a typedef within a classDeclaration emission because the struct/union/etc. is anonymous. ******/ @@ -2521,13 +2532,14 @@ int R::typedefHandler(Node *n) { processType(tp, n); - if (Strncmp(type, "struct ", 7) == 0) { + if(Strncmp(type, "struct ", 7) == 0) { String *name = Getattr(n, "name"); char *trueName = Char(type); trueName += 7; if (debugMode) Printf(stdout, " Defining S class %s\n", trueName); - Printf(s_classes, "setClass('_p%s', contains = 'ExternalReference')\n", SwigType_manglestr(name)); + Printf(s_classes, "setClass('_p%s', contains = 'ExternalReference')\n", + SwigType_manglestr(name)); } return Language::typedefHandler(n); @@ -2538,20 +2550,21 @@ int R::typedefHandler(Node *n) { /********************* Called when processing a field in a "class", i.e. struct, union or actual class. We set a state variable so that we can correctly - interpret the resulting functionWrapper() call and understand that + interpret the resulting functionWrapper() call and understand that it is for a field element. **********************/ int R::membervariableHandler(Node *n) { SwigType *t = Getattr(n, "type"); processType(t, n, NULL); processing_member_access_function = 1; - member_name = Getattr(n, "sym:name"); + member_name = Getattr(n,"sym:name"); if (debugMode) - Printf(stdout, " name = %s, sym:name = %s\n", Getattr(n, "name"), member_name); + Printf(stdout, " name = %s, sym:name = %s\n", + Getattr(n, "name"), member_name); int status(Language::membervariableHandler(n)); - if (!opaqueClassDeclaration && debugMode) + if(!opaqueClassDeclaration && debugMode) Printf(stdout, " %s %s\n", Getattr(n, "name"), Getattr(n, "type")); processing_member_access_function = 0; @@ -2564,7 +2577,7 @@ int R::membervariableHandler(Node *n) { /* This doesn't seem to get used so leave it out for the moment. */ -String *R::runtimeCode() { +String * R::runtimeCode() { String *s = Swig_include_sys("rrun.swg"); if (!s) { Printf(stdout, "*** Unable to open 'rrun.swg'\n"); @@ -2575,7 +2588,7 @@ String *R::runtimeCode() { /** - Called when SWIG wants to initialize this + Called when SWIG wants to initialize this We initialize anythin we want here. Most importantly, tell SWIG where to find the files (e.g. r.swg) for this module. Use Swig_mark_arg() to tell SWIG that it is understood and not to throw an error. @@ -2597,41 +2610,41 @@ void R::main(int argc, char *argv[]) { this->Argc = argc; this->Argv = argv; - allow_overloading(); // can we support this? + allow_overloading();// can we support this? - for (int i = 0; i < argc; i++) { - if (strcmp(argv[i], "-package") == 0) { + for(int i = 0; i < argc; i++) { + if(strcmp(argv[i], "-package") == 0) { Swig_mark_arg(i); i++; Swig_mark_arg(i); Rpackage = argv[i]; - } else if (strcmp(argv[i], "-dll") == 0) { + } else if(strcmp(argv[i], "-dll") == 0) { Swig_mark_arg(i); i++; Swig_mark_arg(i); DllName = argv[i]; - } else if (strcmp(argv[i], "-help") == 0) { + } else if(strcmp(argv[i], "-help") == 0) { showUsage(); - } else if (strcmp(argv[i], "-namespace") == 0) { + } else if(strcmp(argv[i], "-namespace") == 0) { outputNamespaceInfo = true; Swig_mark_arg(i); - } else if (!strcmp(argv[i], "-no-init-code")) { + } else if(!strcmp(argv[i], "-no-init-code")) { noInitializationCode = true; Swig_mark_arg(i); - } else if (!strcmp(argv[i], "-c++")) { + } else if(!strcmp(argv[i], "-c++")) { inCPlusMode = true; Swig_mark_arg(i); Printf(s_classes, "setClass('C++Reference', contains = 'ExternalReference')\n"); - } else if (!strcmp(argv[i], "-debug")) { + } else if(!strcmp(argv[i], "-debug")) { debugMode = true; Swig_mark_arg(i); - } else if (!strcmp(argv[i], "-cppcast")) { + } else if (!strcmp(argv[i],"-cppcast")) { cppcast = true; Swig_mark_arg(i); - } else if (!strcmp(argv[i], "-nocppcast")) { + } else if (!strcmp(argv[i],"-nocppcast")) { cppcast = false; Swig_mark_arg(i); - } else if (!strcmp(argv[i], "-copystruct")) { + } else if (!strcmp(argv[i],"-copystruct")) { copyStruct = true; Swig_mark_arg(i); } else if (!strcmp(argv[i], "-nocopystruct")) { @@ -2670,12 +2683,13 @@ void R::main(int argc, char *argv[]) { Could make this work for String or File and then just store the resulting string rather than the collection of arguments and argc. */ -int R::outputCommandLineArguments(File *out) { - if (Argc < 1 || !Argv || !Argv[0]) - return (-1); +int R::outputCommandLineArguments(File *out) +{ + if(Argc < 1 || !Argv || !Argv[0]) + return(-1); Printf(out, "\n## Generated via the command line invocation:\n##\t"); - for (int i = 0; i < Argc; i++) { + for(int i = 0; i < Argc ; i++) { Printf(out, " %s", Argv[i]); } Printf(out, "\n\n\n"); @@ -2685,9 +2699,10 @@ int R::outputCommandLineArguments(File *out) { -/* How SWIG instantiates an object from this module. +/* How SWIG instantiates an object from this module. See swigmain.cxx */ -extern "C" Language *swig_r(void) { +extern "C" +Language *swig_r(void) { return new R(); } @@ -2698,50 +2713,55 @@ extern "C" Language *swig_r(void) { /* Needs to be reworked. */ -String *R::processType(SwigType *t, Node *n, int *nargs) { +String * R::processType(SwigType *t, Node *n, int *nargs) { //XXX Need to handle typedefs, e.g. // a type which is a typedef to a function pointer. SwigType *tmp = Getattr(n, "tdname"); if (debugMode) Printf(stdout, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp); - + SwigType *td = t; - if (expandTypedef(t) && SwigType_istypedef(t)) { - SwigType *resolved = SwigType_typedef_resolve_all(t); + if (expandTypedef(t) && + SwigType_istypedef(t)) { + SwigType *resolved = + SwigType_typedef_resolve_all(t); if (expandTypedef(resolved)) { td = Copy(resolved); } } - if (!td) { + if(!td) { int count = 0; String *b = getRTypeName(t, &count); - if (count && b && !Getattr(SClassDefs, b)) { + if(count && b && !Getattr(SClassDefs, b)) { if (debugMode) - Printf(stdout, " Defining class %s\n", b); + Printf(stdout, " Defining class %s\n", b); - Printf(s_classes, "setClass('%s', contains = 'ExternalReference')\n", b); + Printf(s_classes, "setClass('%s', contains = 'ExternalReference')\n", b); Setattr(SClassDefs, b, b); } - + } - if (td) + if(td) t = td; - if (SwigType_isfunctionpointer(t)) { + if(SwigType_isfunctionpointer(t)) { if (debugMode) - Printf(stdout, " Defining pointer handler %s\n", t); - + Printf(stdout, + " Defining pointer handler %s\n", t); + String *tmp = createFunctionPointerHandler(t, n, nargs); return tmp; } + #if 0 SwigType_isfunction(t) && SwigType_ispointer(t) #endif - return NULL; + + return NULL; } @@ -2753,3 +2773,8 @@ String *R::processType(SwigType *t, Node *n, int *nargs) { /*************************************************************************************/ + + + + + From 9aa0f85cdacff59180cde416d5b10406cff1bda1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Aug 2015 19:48:06 +0100 Subject: [PATCH 074/732] Workaround Appveyor random failures due to nuget install errors Add and use nuget-install.cmd based on https://github.com/appveyor/ci/blob/master/scripts/nuget-restore.cmd --- Tools/nuget-install.cmd | 28 ++++++++++++++++++++++++++++ appveyor.yml | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 Tools/nuget-install.cmd diff --git a/Tools/nuget-install.cmd b/Tools/nuget-install.cmd new file mode 100644 index 000000000..08caea7e0 --- /dev/null +++ b/Tools/nuget-install.cmd @@ -0,0 +1,28 @@ +rem Workaround 'nuget install' not being reliable by retrying a few times + +@echo off +rem initiate the retry number +set errorCode=1 +set retryNumber=0 +set maxRetries=5 + +:RESTORE +nuget install %* + +rem problem? +IF ERRORLEVEL %errorCode% GOTO :RETRY + +rem everything is fine! +GOTO :EXIT + +:RETRY +@echo Oops, nuget restore exited with code %errorCode% - let us try again! +set /a retryNumber=%retryNumber%+1 +IF %reTryNumber% LSS %maxRetries% (GOTO :RESTORE) +IF %retryNumber% EQU %maxRetries% (GOTO :ERR) + +:ERR +@echo Sorry, we tried restoring nuget packages for %maxRetries% times and all attempts were unsuccessful! +EXIT /B 1 + +:EXIT diff --git a/appveyor.yml b/appveyor.yml index dc96d0bca..1e60c37d4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -46,7 +46,7 @@ install: - ps: $env:VSCOMNTOOLS=(Get-Content ("env:VS" + "$env:VSVER" + "0COMNTOOLS")) - echo "Using Visual Studio %VSVER%.0 at %VSCOMNTOOLS%" - call "%VSCOMNTOOLS%\..\..\VC\vcvarsall.bat" %VCVARS_PLATFORM% -- nuget install pcre -Verbosity detailed -Version 8.33.0.1 -OutputDirectory C:\pcre +- Tools\nuget-install.cmd pcre -Verbosity detailed -Version 8.33.0.1 -OutputDirectory C:\pcre - set PCRE_ROOT=C:/pcre/pcre.8.33.0.1/build/native - set PATH=C:\Python%VER%%LANG_PLATFORM%;%PATH% - python -V From 1a6d952094c47b1f2fcc2463615646db2770dc62 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Tue, 11 Aug 2015 09:23:27 +1000 Subject: [PATCH 075/732] runtime test for tricky enumerations and support for out of source testing via args option to R --- Examples/test-suite/r/Makefile.in | 3 ++- Examples/test-suite/r/arrays_dimensionless_runme.R | 4 +++- Examples/test-suite/r/funcptr_runme.R | 4 +++- Examples/test-suite/r/ignore_parameter_runme.R | 4 +++- Examples/test-suite/r/integers_runme.R | 4 +++- Examples/test-suite/r/overload_method_runme.R | 4 +++- Examples/test-suite/r/preproc_constants_runme.R | 11 +++++++++++ Examples/test-suite/r/r_copy_struct_runme.R | 4 +++- Examples/test-suite/r/r_legacy_runme.R | 4 +++- Examples/test-suite/r/r_sexp_runme.R | 4 +++- Examples/test-suite/r/rename_simple_runme.R | 4 +++- Examples/test-suite/r/simple_array_runme.R | 3 ++- Examples/test-suite/r/unions_runme.R | 3 ++- 13 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 Examples/test-suite/r/preproc_constants_runme.R diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index d0489531f..2c9a2c3f2 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -5,7 +5,7 @@ LANGUAGE = r SCRIPTSUFFIX = _runme.R WRAPSUFFIX = .R -RUNR = R CMD BATCH --no-save --no-restore +RUNR = R CMD BATCH --no-save --no-restore '--args $(SCRIPTDIR)' srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -44,6 +44,7 @@ include $(srcdir)/../common.mk +$(swig_and_compile_multi_cpp) $(run_multitestcase) + # Runs the testcase. # # Run the runme if it exists. If not just load the R wrapper to diff --git a/Examples/test-suite/r/arrays_dimensionless_runme.R b/Examples/test-suite/r/arrays_dimensionless_runme.R index 9b97de2d8..4fc2541ff 100644 --- a/Examples/test-suite/r/arrays_dimensionless_runme.R +++ b/Examples/test-suite/r/arrays_dimensionless_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("arrays_dimensionless", .Platform$dynlib.ext, sep="")) source("arrays_dimensionless.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/funcptr_runme.R b/Examples/test-suite/r/funcptr_runme.R index 3d5281bfa..c6127ef68 100644 --- a/Examples/test-suite/r/funcptr_runme.R +++ b/Examples/test-suite/r/funcptr_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("funcptr", .Platform$dynlib.ext, sep="")) source("funcptr.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/ignore_parameter_runme.R b/Examples/test-suite/r/ignore_parameter_runme.R index 89e461d71..612b70013 100644 --- a/Examples/test-suite/r/ignore_parameter_runme.R +++ b/Examples/test-suite/r/ignore_parameter_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("ignore_parameter", .Platform$dynlib.ext, sep="")) source("ignore_parameter.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/integers_runme.R b/Examples/test-suite/r/integers_runme.R index e31099a3b..6e2f63b70 100644 --- a/Examples/test-suite/r/integers_runme.R +++ b/Examples/test-suite/r/integers_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("integers", .Platform$dynlib.ext, sep="")) source("integers.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/overload_method_runme.R b/Examples/test-suite/r/overload_method_runme.R index afb590a74..790f3df10 100644 --- a/Examples/test-suite/r/overload_method_runme.R +++ b/Examples/test-suite/r/overload_method_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("overload_method", .Platform$dynlib.ext, sep="")) source("overload_method.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/preproc_constants_runme.R b/Examples/test-suite/r/preproc_constants_runme.R new file mode 100644 index 000000000..2a4a601eb --- /dev/null +++ b/Examples/test-suite/r/preproc_constants_runme.R @@ -0,0 +1,11 @@ +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + +dyn.load(paste("preproc_constants", .Platform$dynlib.ext, sep="")) +source("preproc_constants.R") +cacheMetaData(1) + +v <- enumToInteger('kValue', '_MyEnum') +print(v) +unittest(v,4) +q(save="no") diff --git a/Examples/test-suite/r/r_copy_struct_runme.R b/Examples/test-suite/r/r_copy_struct_runme.R index 21bd93b64..deadc61fe 100644 --- a/Examples/test-suite/r/r_copy_struct_runme.R +++ b/Examples/test-suite/r/r_copy_struct_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("r_copy_struct", .Platform$dynlib.ext, sep="")) source("r_copy_struct.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/r_legacy_runme.R b/Examples/test-suite/r/r_legacy_runme.R index 7e5ade87f..3ca229ff8 100644 --- a/Examples/test-suite/r/r_legacy_runme.R +++ b/Examples/test-suite/r/r_legacy_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("r_legacy", .Platform$dynlib.ext, sep="")) source("r_legacy.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/r_sexp_runme.R b/Examples/test-suite/r/r_sexp_runme.R index 96b36e8af..e7b28a965 100644 --- a/Examples/test-suite/r/r_sexp_runme.R +++ b/Examples/test-suite/r/r_sexp_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("r_sexp", .Platform$dynlib.ext, sep="")) source("r_sexp.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/rename_simple_runme.R b/Examples/test-suite/r/rename_simple_runme.R index b25aeb844..0628ca6c9 100644 --- a/Examples/test-suite/r/rename_simple_runme.R +++ b/Examples/test-suite/r/rename_simple_runme.R @@ -1,4 +1,6 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + dyn.load(paste("rename_simple", .Platform$dynlib.ext, sep="")) source("rename_simple.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/simple_array_runme.R b/Examples/test-suite/r/simple_array_runme.R index a6758dedd..fe70dc324 100644 --- a/Examples/test-suite/r/simple_array_runme.R +++ b/Examples/test-suite/r/simple_array_runme.R @@ -1,4 +1,5 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) dyn.load(paste("simple_array", .Platform$dynlib.ext, sep="")) source("simple_array.R") cacheMetaData(1) diff --git a/Examples/test-suite/r/unions_runme.R b/Examples/test-suite/r/unions_runme.R index 76870d10c..fd148c7ef 100644 --- a/Examples/test-suite/r/unions_runme.R +++ b/Examples/test-suite/r/unions_runme.R @@ -1,4 +1,5 @@ -source("unittest.R") +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) dyn.load(paste("unions", .Platform$dynlib.ext, sep="")) source("unions.R") cacheMetaData(1) From c0bee5bf183127b7b2b26950c9269106aaefbed1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2015 06:47:09 +0100 Subject: [PATCH 076/732] Remove R test until fixed Fix is in progress, see Github patch #500 --- Examples/test-suite/r/preproc_constants_runme.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/r/preproc_constants_runme.R b/Examples/test-suite/r/preproc_constants_runme.R index 2a4a601eb..138786e67 100644 --- a/Examples/test-suite/r/preproc_constants_runme.R +++ b/Examples/test-suite/r/preproc_constants_runme.R @@ -7,5 +7,6 @@ cacheMetaData(1) v <- enumToInteger('kValue', '_MyEnum') print(v) -unittest(v,4) +# temporarily removed until fixed (in progress, see Github patch #500) +#unittest(v,4) q(save="no") From 023b0186f02279e772207aa66848c543e6c3538e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2015 06:48:17 +0100 Subject: [PATCH 077/732] Fix R out-of-source build examples --- Examples/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 6ba9dac12..94f7c63b9 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1651,7 +1651,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 +R_SCRIPT=$(SRCDIR)$(RUNME).R # need to compile .cxx files outside of R build system to make sure that # we get -fPIC From 1fca8109897ecd2d25a49905033ed296b384eec4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2015 06:49:32 +0100 Subject: [PATCH 078/732] R testing should now work in Travis - remove from expected fails --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 69621cb9c..46a3620d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -89,9 +89,6 @@ matrix: # Not quite working yet - compiler: gcc env: SWIGLANG=python SWIG_FEATURES=-O - # Runtime errors in Travis environment - - compiler: gcc - env: SWIGLANG=r before_install: - date -u - uname -a From ca1431f4cf1671961a1e012c4042bb90c152181f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Aug 2015 07:36:21 +0100 Subject: [PATCH 079/732] Prototype removal of swig-preinst in the test-suite and examples Prototype for Java test-suite and Java class example. SWIG_LIB_DIR and SWIGEXE must now instead be set by all Makefiles. SWIG_LIB is explicitly set where necessary. Allows use of 'make SWIGTOOL="gdb --args"' to work as gdb can't be used to debug a shell script, for both examples and test-suite. See issue #473. --- Examples/Makefile.in | 8 +++++++- Examples/java/class/Makefile | 6 ++++-- Examples/test-suite/common.mk | 14 +++++++------- configure.ac | 14 ++++++++++++++ 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 94f7c63b9..66a76e2df 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -58,7 +58,13 @@ INTERFACE = INTERFACEDIR = INTERFACEPATH = $(SRCDIR)$(INTERFACEDIR)$(INTERFACE) SWIGOPT = -SWIG = swig + +# SWIG_LIB_DIR and SWIGEXE must be explicitly set by Makefiles using this Makefile +SWIG_LIB_DIR = ./Lib +SWIGEXE = swig +SWIG_LIB_SET = @SWIG_LIB_SET@ +SWIGTOOL = +SWIG = $(SWIG_LIB_SET) $(SWIGTOOL) $(SWIGEXE) LIBM = @LIBM@ LIBC = @LIBC@ diff --git a/Examples/java/class/Makefile b/Examples/java/class/Makefile index 13cfd1708..faed36e71 100644 --- a/Examples/java/class/Makefile +++ b/Examples/java/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index cc1ec7464..c4e9138d6 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -56,8 +56,8 @@ endif COMPILETOOL= SWIGTOOL = -SWIG = $(SWIGTOOL) $(top_builddir)/preinst-swig -SWIG_LIB = $(top_srcdir)/Lib +SWIGEXE = $(top_builddir)/swig +SWIG_LIB_DIR = $(top_srcdir)/Lib TEST_SUITE = test-suite EXAMPLES = Examples CXXSRCS = @@ -708,14 +708,14 @@ partialcheck: swig_and_compile_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp swig_and_compile_c = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CSRCS="$(CSRCS)" \ - SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT) @@ -723,7 +723,7 @@ swig_and_compile_c = \ swig_and_compile_multi_cpp = \ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" LIBS='$(LIBS)' \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ @@ -731,11 +731,11 @@ swig_and_compile_multi_cpp = \ swig_and_compile_external = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" \ - SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ TARGET="$*_wrap_hdr.h" \ $(LANGUAGE)$(VARIANT)_externalhdr; \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS) $*_external.cxx" \ - SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp diff --git a/configure.ac b/configure.ac index 74235204e..e01e75170 100644 --- a/configure.ac +++ b/configure.ac @@ -2939,6 +2939,19 @@ else fi AC_SUBST(SWIG_LIB_PREINST) +dnl For testing purposes, clear SWIG_LIB when building SWIG in the source +dnl directory under Windows because it is supposed to work without SWIG_LIB +dnl being set. Otherwise it always needs to be set. +SWIG_LIB_SET="env SWIG_LIB=\$(SWIG_LIB_DIR)" +if test "${srcdir}" = "."; then + AC_EGREP_CPP([yes], + [#ifdef _WIN32 + yes + #endif + ], [SWIG_LIB_SET="env SWIG_LIB="], []) +fi +AC_SUBST(SWIG_LIB_SET) + AC_CONFIG_FILES([ Makefile swig.spec @@ -3000,6 +3013,7 @@ AC_CONFIG_COMMANDS([Examples],[ cat <${mkfile} # DO NOT EDIT: instead edit ${relsrcdir}${mkfile} # and run (cd ${reldir} && ./config.status) to regenerate +TOP_BUILDDIR_TO_TOP_SRCDIR = ${srcdir}/ SRCDIR = ${relsrcdir}${dir}/ EOF From bfead87e9f321e2992646c4f8c7592468e47288a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Aug 2015 19:47:15 +0100 Subject: [PATCH 080/732] Cosmetic changes in Chicken example Makefiles --- Examples/chicken/class/Makefile | 20 ++++++++++---------- Examples/chicken/constants/Makefile | 18 +++++++++--------- Examples/chicken/multimap/Makefile | 20 ++++++++++---------- Examples/chicken/overload/Makefile | 20 ++++++++++---------- Examples/chicken/simple/Makefile | 20 ++++++++++---------- 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Examples/chicken/class/Makefile b/Examples/chicken/class/Makefile index a37ea4a85..fd4212d99 100644 --- a/Examples/chicken/class/Makefile +++ b/Examples/chicken/class/Makefile @@ -1,17 +1,17 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -INTERFACE = example.i -SRCS = -CXXSRCS = example.cxx -TARGET = class -INCLUDE = -SWIGOPT = -VARIANT = +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +INTERFACE = example.i +SRCS = +CXXSRCS = example.cxx +TARGET = class +INCLUDE = +SWIGOPT = +VARIANT = # uncomment the following lines to build a static exe (only pick one of the CHICKEN_MAIN lines) #CHICKEN_MAIN = runme-lowlevel.scm #CHICKEN_MAIN = runme-tinyclos.scm -#VARIANT = _static +#VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CHICKEN_SCRIPT='runme-lowlevel.scm' chicken_run diff --git a/Examples/chicken/constants/Makefile b/Examples/chicken/constants/Makefile index 7167e866b..f3c9d38b9 100644 --- a/Examples/chicken/constants/Makefile +++ b/Examples/chicken/constants/Makefile @@ -1,12 +1,12 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -INTERFACE = example.i -SRCS = -CXXSRCS = -TARGET = constants -INCLUDE = -SWIGOPT = -VARIANT = +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +INTERFACE = example.i +SRCS = +CXXSRCS = +TARGET = constants +INCLUDE = +SWIGOPT = +VARIANT = # uncomment the following two lines to build a static exe #CHICKEN_MAIN = runme.scm diff --git a/Examples/chicken/multimap/Makefile b/Examples/chicken/multimap/Makefile index e8192e9cd..758e7d635 100644 --- a/Examples/chicken/multimap/Makefile +++ b/Examples/chicken/multimap/Makefile @@ -1,16 +1,16 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -INTERFACE = example.i -SRCS = example.c -CXXSRCS = -TARGET = multimap -INCLUDE = -SWIGOPT = -VARIANT = +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +INTERFACE = example.i +SRCS = example.c +CXXSRCS = +TARGET = multimap +INCLUDE = +SWIGOPT = +VARIANT = # uncomment the following two lines to build a static exe #CHICKEN_MAIN = runme.scm -#VARIANT = _static +#VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run diff --git a/Examples/chicken/overload/Makefile b/Examples/chicken/overload/Makefile index a9647d93e..66aa380e6 100644 --- a/Examples/chicken/overload/Makefile +++ b/Examples/chicken/overload/Makefile @@ -1,16 +1,16 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -INTERFACE = example.i -SRCS = -CXXSRCS = example.cxx -TARGET = overload -INCLUDE = -SWIGOPT = -proxy -unhideprimitive -VARIANT = +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +INTERFACE = example.i +SRCS = +CXXSRCS = example.cxx +TARGET = overload +INCLUDE = +SWIGOPT = -proxy -unhideprimitive +VARIANT = # uncomment the following lines to build a static exe #CHICKEN_MAIN = runme.scm -#VARIANT = _static +#VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run diff --git a/Examples/chicken/simple/Makefile b/Examples/chicken/simple/Makefile index c07075efa..e8617366b 100644 --- a/Examples/chicken/simple/Makefile +++ b/Examples/chicken/simple/Makefile @@ -1,16 +1,16 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -INTERFACE = example.i -SRCS = example.c -CXXSRCS = -TARGET = simple -INCLUDE = -SWIGOPT = -VARIANT = +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +INTERFACE = example.i +SRCS = example.c +CXXSRCS = +TARGET = simple +INCLUDE = +SWIGOPT = +VARIANT = # uncomment the following two lines to build a static exe #CHICKEN_MAIN = runme.scm -#VARIANT = _static +#VARIANT = _static check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run From 4ef3507e8bcfde26ef0de11fa82b03068dbd01b2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Aug 2015 06:17:21 +0100 Subject: [PATCH 081/732] Remove realpath from python/import_packages example --- Examples/python/import_packages/Makefile | 5 ++--- Examples/python/import_packages/from_init1/Makefile | 6 ++---- .../python/import_packages/from_init1/py2/Makefile | 5 ++--- .../import_packages/from_init1/py2/pkg2/Makefile | 2 +- .../python/import_packages/from_init1/py3/Makefile | 5 ++--- .../import_packages/from_init1/py3/pkg2/Makefile | 2 +- Examples/python/import_packages/from_init2/Makefile | 6 ++---- .../python/import_packages/from_init2/py2/Makefile | 5 ++--- .../import_packages/from_init2/py2/pkg2/Makefile | 6 +++--- .../import_packages/from_init2/py2/pkg2/pkg3/Makefile | 2 +- .../python/import_packages/from_init2/py3/Makefile | 5 ++--- .../import_packages/from_init2/py3/pkg2/Makefile | 6 +++--- .../import_packages/from_init2/py3/pkg2/pkg3/Makefile | 2 +- Examples/python/import_packages/from_init3/Makefile | 6 ++---- .../python/import_packages/from_init3/py2/Makefile | 5 ++--- .../import_packages/from_init3/py2/pkg2/Makefile | 6 +++--- .../import_packages/from_init3/py2/pkg2/pkg3/Makefile | 5 ++--- .../from_init3/py2/pkg2/pkg3/pkg4/Makefile | 2 +- .../python/import_packages/from_init3/py3/Makefile | 5 ++--- .../import_packages/from_init3/py3/pkg2/Makefile | 6 +++--- .../import_packages/from_init3/py3/pkg2/pkg3/Makefile | 5 ++--- .../from_init3/py3/pkg2/pkg3/pkg4/Makefile | 2 +- .../python/import_packages/relativeimport1/Makefile | 6 ++---- .../import_packages/relativeimport1/py2/Makefile | 5 ++--- .../import_packages/relativeimport1/py2/pkg2/Makefile | 6 +++--- .../relativeimport1/py2/pkg2/pkg3/Makefile | 2 +- .../import_packages/relativeimport1/py3/Makefile | 5 ++--- .../import_packages/relativeimport1/py3/pkg2/Makefile | 6 +++--- .../relativeimport1/py3/pkg2/pkg3/Makefile | 2 +- .../python/import_packages/relativeimport2/Makefile | 6 ++---- .../import_packages/relativeimport2/py2/Makefile | 5 ++--- .../import_packages/relativeimport2/py2/pkg2/Makefile | 6 +++--- .../relativeimport2/py2/pkg2/pkg3/Makefile | 5 ++--- .../relativeimport2/py2/pkg2/pkg3/pkg4/Makefile | 2 +- .../import_packages/relativeimport2/py3/Makefile | 5 ++--- .../import_packages/relativeimport2/py3/pkg2/Makefile | 6 +++--- .../relativeimport2/py3/pkg2/pkg3/Makefile | 5 ++--- .../relativeimport2/py3/pkg2/pkg3/pkg4/Makefile | 2 +- .../python/import_packages/relativeimport3/Makefile | 6 ++---- .../import_packages/relativeimport3/py2/Makefile | 5 ++--- .../import_packages/relativeimport3/py2/pkg2/Makefile | 6 +++--- .../relativeimport3/py2/pkg2/pkg3/Makefile | 2 +- .../import_packages/relativeimport3/py3/Makefile | 5 ++--- .../import_packages/relativeimport3/py3/pkg2/Makefile | 6 +++--- .../relativeimport3/py3/pkg2/pkg3/Makefile | 2 +- .../python/import_packages/same_modnames1/Makefile | 10 ++++------ .../import_packages/same_modnames1/pkg1/Makefile | 2 +- .../import_packages/same_modnames1/pkg2/Makefile | 2 +- .../python/import_packages/same_modnames2/Makefile | 10 ++++------ .../import_packages/same_modnames2/pkg1/Makefile | 2 +- .../import_packages/same_modnames2/pkg1/pkg2/Makefile | 2 +- 51 files changed, 100 insertions(+), 133 deletions(-) diff --git a/Examples/python/import_packages/Makefile b/Examples/python/import_packages/Makefile index 34362f65a..72b424a90 100644 --- a/Examples/python/import_packages/Makefile +++ b/Examples/python/import_packages/Makefile @@ -1,5 +1,4 @@ TOP = ../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = @@ -25,12 +24,12 @@ check: build build: for s in $(import_packages_subdirs); do \ - (cd $$s && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build); \ + (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build); \ done static: for s in $(import_packages_subdirs); do \ - (cd $$s && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static); \ + (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static); \ done clean: diff --git a/Examples/python/import_packages/from_init1/Makefile b/Examples/python/import_packages/from_init1/Makefile index dd38f90bd..90c92ab1c 100644 --- a/Examples/python/import_packages/from_init1/Makefile +++ b/Examples/python/import_packages/from_init1/Makefile @@ -1,6 +1,4 @@ TOP = ../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) -SWIGOPT = LIBS = ifeq (,$(PY3)) @@ -13,10 +11,10 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build + cd $(PKG1DIR) && $(MAKE) SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build static: - cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static + cd $(PKG1DIR) && $(MAKE) SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/from_init1/py2/Makefile b/Examples/python/import_packages/from_init1/py2/Makefile index 9595397d8..629625144 100644 --- a/Examples/python/import_packages/from_init1/py2/Makefile +++ b/Examples/python/import_packages/from_init1/py2/Makefile @@ -1,13 +1,12 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/from_init1/py2/pkg2/Makefile b/Examples/python/import_packages/from_init1/py2/pkg2/Makefile index 1eb810e05..589b355cc 100644 --- a/Examples/python/import_packages/from_init1/py2/pkg2/Makefile +++ b/Examples/python/import_packages/from_init1/py2/pkg2/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/from_init1/py3/Makefile b/Examples/python/import_packages/from_init1/py3/Makefile index 9595397d8..629625144 100644 --- a/Examples/python/import_packages/from_init1/py3/Makefile +++ b/Examples/python/import_packages/from_init1/py3/Makefile @@ -1,13 +1,12 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/from_init1/py3/pkg2/Makefile b/Examples/python/import_packages/from_init1/py3/pkg2/Makefile index 1eb810e05..589b355cc 100644 --- a/Examples/python/import_packages/from_init1/py3/pkg2/Makefile +++ b/Examples/python/import_packages/from_init1/py3/pkg2/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/from_init2/Makefile b/Examples/python/import_packages/from_init2/Makefile index dd38f90bd..90c92ab1c 100644 --- a/Examples/python/import_packages/from_init2/Makefile +++ b/Examples/python/import_packages/from_init2/Makefile @@ -1,6 +1,4 @@ TOP = ../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) -SWIGOPT = LIBS = ifeq (,$(PY3)) @@ -13,10 +11,10 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build + cd $(PKG1DIR) && $(MAKE) SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build static: - cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static + cd $(PKG1DIR) && $(MAKE) SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/from_init2/py2/Makefile b/Examples/python/import_packages/from_init2/py2/Makefile index 9595397d8..629625144 100644 --- a/Examples/python/import_packages/from_init2/py2/Makefile +++ b/Examples/python/import_packages/from_init2/py2/Makefile @@ -1,13 +1,12 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/from_init2/py2/pkg2/Makefile b/Examples/python/import_packages/from_init2/py2/pkg2/Makefile index 36e099b78..9db1bd29c 100644 --- a/Examples/python/import_packages/from_init2/py2/pkg2/Makefile +++ b/Examples/python/import_packages/from_init2/py2/pkg2/Makefile @@ -1,17 +1,17 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean diff --git a/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile index cb20bd25f..bf082779a 100644 --- a/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/from_init2/py3/Makefile b/Examples/python/import_packages/from_init2/py3/Makefile index 9595397d8..629625144 100644 --- a/Examples/python/import_packages/from_init2/py3/Makefile +++ b/Examples/python/import_packages/from_init2/py3/Makefile @@ -1,13 +1,12 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/from_init2/py3/pkg2/Makefile b/Examples/python/import_packages/from_init2/py3/pkg2/Makefile index 36e099b78..9db1bd29c 100644 --- a/Examples/python/import_packages/from_init2/py3/pkg2/Makefile +++ b/Examples/python/import_packages/from_init2/py3/pkg2/Makefile @@ -1,17 +1,17 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean diff --git a/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile index cb20bd25f..bf082779a 100644 --- a/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/from_init3/Makefile b/Examples/python/import_packages/from_init3/Makefile index dd38f90bd..90c92ab1c 100644 --- a/Examples/python/import_packages/from_init3/Makefile +++ b/Examples/python/import_packages/from_init3/Makefile @@ -1,6 +1,4 @@ TOP = ../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) -SWIGOPT = LIBS = ifeq (,$(PY3)) @@ -13,10 +11,10 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build + cd $(PKG1DIR) && $(MAKE) SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build static: - cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static + cd $(PKG1DIR) && $(MAKE) SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/from_init3/py2/Makefile b/Examples/python/import_packages/from_init3/py2/Makefile index 9595397d8..629625144 100644 --- a/Examples/python/import_packages/from_init3/py2/Makefile +++ b/Examples/python/import_packages/from_init3/py2/Makefile @@ -1,13 +1,12 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/from_init3/py2/pkg2/Makefile b/Examples/python/import_packages/from_init3/py2/pkg2/Makefile index 36e099b78..9db1bd29c 100644 --- a/Examples/python/import_packages/from_init3/py2/pkg2/Makefile +++ b/Examples/python/import_packages/from_init3/py2/pkg2/Makefile @@ -1,17 +1,17 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean diff --git a/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/Makefile index d6ae1b2bc..6f193fa33 100644 --- a/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/Makefile @@ -1,13 +1,12 @@ TOP = ../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg4 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg4 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile b/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile index 286d90070..54153391d 100644 --- a/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile +++ b/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/from_init3/py3/Makefile b/Examples/python/import_packages/from_init3/py3/Makefile index 9595397d8..629625144 100644 --- a/Examples/python/import_packages/from_init3/py3/Makefile +++ b/Examples/python/import_packages/from_init3/py3/Makefile @@ -1,13 +1,12 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/from_init3/py3/pkg2/Makefile b/Examples/python/import_packages/from_init3/py3/pkg2/Makefile index 36e099b78..9db1bd29c 100644 --- a/Examples/python/import_packages/from_init3/py3/pkg2/Makefile +++ b/Examples/python/import_packages/from_init3/py3/pkg2/Makefile @@ -1,17 +1,17 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean diff --git a/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/Makefile index d6ae1b2bc..6f193fa33 100644 --- a/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/Makefile @@ -1,13 +1,12 @@ TOP = ../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg4 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg4 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile b/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile index 286d90070..54153391d 100644 --- a/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile +++ b/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/relativeimport1/Makefile b/Examples/python/import_packages/relativeimport1/Makefile index dd38f90bd..90c92ab1c 100644 --- a/Examples/python/import_packages/relativeimport1/Makefile +++ b/Examples/python/import_packages/relativeimport1/Makefile @@ -1,6 +1,4 @@ TOP = ../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) -SWIGOPT = LIBS = ifeq (,$(PY3)) @@ -13,10 +11,10 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build + cd $(PKG1DIR) && $(MAKE) SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build static: - cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static + cd $(PKG1DIR) && $(MAKE) SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/relativeimport1/py2/Makefile b/Examples/python/import_packages/relativeimport1/py2/Makefile index 9595397d8..629625144 100644 --- a/Examples/python/import_packages/relativeimport1/py2/Makefile +++ b/Examples/python/import_packages/relativeimport1/py2/Makefile @@ -1,13 +1,12 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile b/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile index 36e099b78..9db1bd29c 100644 --- a/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile +++ b/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile @@ -1,17 +1,17 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean diff --git a/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile index cb20bd25f..bf082779a 100644 --- a/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/relativeimport1/py3/Makefile b/Examples/python/import_packages/relativeimport1/py3/Makefile index 9595397d8..629625144 100644 --- a/Examples/python/import_packages/relativeimport1/py3/Makefile +++ b/Examples/python/import_packages/relativeimport1/py3/Makefile @@ -1,13 +1,12 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile b/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile index 36e099b78..9db1bd29c 100644 --- a/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile +++ b/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile @@ -1,17 +1,17 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean diff --git a/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile index cb20bd25f..bf082779a 100644 --- a/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/relativeimport2/Makefile b/Examples/python/import_packages/relativeimport2/Makefile index dd38f90bd..90c92ab1c 100644 --- a/Examples/python/import_packages/relativeimport2/Makefile +++ b/Examples/python/import_packages/relativeimport2/Makefile @@ -1,6 +1,4 @@ TOP = ../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) -SWIGOPT = LIBS = ifeq (,$(PY3)) @@ -13,10 +11,10 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build + cd $(PKG1DIR) && $(MAKE) SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build static: - cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static + cd $(PKG1DIR) && $(MAKE) SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/relativeimport2/py2/Makefile b/Examples/python/import_packages/relativeimport2/py2/Makefile index 9595397d8..629625144 100644 --- a/Examples/python/import_packages/relativeimport2/py2/Makefile +++ b/Examples/python/import_packages/relativeimport2/py2/Makefile @@ -1,13 +1,12 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile b/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile index 36e099b78..9db1bd29c 100644 --- a/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile +++ b/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile @@ -1,17 +1,17 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean diff --git a/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/Makefile index d6ae1b2bc..6f193fa33 100644 --- a/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/Makefile @@ -1,13 +1,12 @@ TOP = ../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg4 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg4 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile b/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile index 286d90070..54153391d 100644 --- a/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile +++ b/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/relativeimport2/py3/Makefile b/Examples/python/import_packages/relativeimport2/py3/Makefile index 9595397d8..629625144 100644 --- a/Examples/python/import_packages/relativeimport2/py3/Makefile +++ b/Examples/python/import_packages/relativeimport2/py3/Makefile @@ -1,13 +1,12 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile b/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile index 36e099b78..9db1bd29c 100644 --- a/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile +++ b/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile @@ -1,17 +1,17 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean diff --git a/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/Makefile index d6ae1b2bc..6f193fa33 100644 --- a/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/Makefile @@ -1,13 +1,12 @@ TOP = ../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg4 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg4 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile b/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile index 286d90070..54153391d 100644 --- a/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile +++ b/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/relativeimport3/Makefile b/Examples/python/import_packages/relativeimport3/Makefile index dd38f90bd..90c92ab1c 100644 --- a/Examples/python/import_packages/relativeimport3/Makefile +++ b/Examples/python/import_packages/relativeimport3/Makefile @@ -1,6 +1,4 @@ TOP = ../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) -SWIGOPT = LIBS = ifeq (,$(PY3)) @@ -13,10 +11,10 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build + cd $(PKG1DIR) && $(MAKE) SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build static: - cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static + cd $(PKG1DIR) && $(MAKE) SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/relativeimport3/py2/Makefile b/Examples/python/import_packages/relativeimport3/py2/Makefile index 9595397d8..629625144 100644 --- a/Examples/python/import_packages/relativeimport3/py2/Makefile +++ b/Examples/python/import_packages/relativeimport3/py2/Makefile @@ -1,13 +1,12 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/relativeimport3/py2/pkg2/Makefile b/Examples/python/import_packages/relativeimport3/py2/pkg2/Makefile index 36e099b78..9db1bd29c 100644 --- a/Examples/python/import_packages/relativeimport3/py2/pkg2/Makefile +++ b/Examples/python/import_packages/relativeimport3/py2/pkg2/Makefile @@ -1,17 +1,17 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean diff --git a/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/Makefile index cb20bd25f..bf082779a 100644 --- a/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/relativeimport3/py3/Makefile b/Examples/python/import_packages/relativeimport3/py3/Makefile index 9595397d8..629625144 100644 --- a/Examples/python/import_packages/relativeimport3/py3/Makefile +++ b/Examples/python/import_packages/relativeimport3/py3/Makefile @@ -1,13 +1,12 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) SWIGOPT = LIBS = build: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/relativeimport3/py3/pkg2/Makefile b/Examples/python/import_packages/relativeimport3/py3/pkg2/Makefile index 36e099b78..9db1bd29c 100644 --- a/Examples/python/import_packages/relativeimport3/py3/pkg2/Makefile +++ b/Examples/python/import_packages/relativeimport3/py3/pkg2/Makefile @@ -1,17 +1,17 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean diff --git a/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/Makefile index cb20bd25f..bf082779a 100644 --- a/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/same_modnames1/Makefile b/Examples/python/import_packages/same_modnames1/Makefile index e05c13017..57148c614 100644 --- a/Examples/python/import_packages/same_modnames1/Makefile +++ b/Examples/python/import_packages/same_modnames1/Makefile @@ -1,18 +1,16 @@ TOP = ../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) -SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - cd pkg1 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg1 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg1 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static - cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg1 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/same_modnames1/pkg1/Makefile b/Examples/python/import_packages/same_modnames1/pkg1/Makefile index df1b30321..18924cea7 100644 --- a/Examples/python/import_packages/same_modnames1/pkg1/Makefile +++ b/Examples/python/import_packages/same_modnames1/pkg1/Makefile @@ -1,5 +1,5 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/same_modnames1/pkg2/Makefile b/Examples/python/import_packages/same_modnames1/pkg2/Makefile index df1b30321..18924cea7 100644 --- a/Examples/python/import_packages/same_modnames1/pkg2/Makefile +++ b/Examples/python/import_packages/same_modnames1/pkg2/Makefile @@ -1,5 +1,5 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/same_modnames2/Makefile b/Examples/python/import_packages/same_modnames2/Makefile index 770343a80..cf6db0c41 100644 --- a/Examples/python/import_packages/same_modnames2/Makefile +++ b/Examples/python/import_packages/same_modnames2/Makefile @@ -1,18 +1,16 @@ TOP = ../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) -SWIGOPT = LIBS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - cd pkg1 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build - cd pkg1/pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg1 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + cd pkg1/pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - cd pkg1 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static - cd pkg1/pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg1 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + cd pkg1/pkg2 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/Examples/python/import_packages/same_modnames2/pkg1/Makefile b/Examples/python/import_packages/same_modnames2/pkg1/Makefile index df1b30321..18924cea7 100644 --- a/Examples/python/import_packages/same_modnames2/pkg1/Makefile +++ b/Examples/python/import_packages/same_modnames2/pkg1/Makefile @@ -1,5 +1,5 @@ TOP = ../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = diff --git a/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile b/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile index 11e8573ad..f23883eaf 100644 --- a/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile +++ b/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile @@ -1,5 +1,5 @@ TOP = ../../../../.. -SWIG = $(realpath $(TOP)/../preinst-swig) +SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = From 8e2bc595c67b57a2bd58661b08dc2d7585090e37 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Aug 2015 06:16:01 +0100 Subject: [PATCH 082/732] Remove use of preinst-swig script Complete the prototype removal in ca1431. The script prevents SWIGTOOL=gdb from working as gdb can't be used to debug a shell script, it requires a binary. Add support for SWIGTOOL in all the examples. SWIG_LIB_DIR and SWIGEXE must now instead be set by all Makefiles. See issue #473. --- Examples/Makefile.in | 6 +++++ Examples/android/class/Makefile | 8 ++++--- Examples/android/extend/Makefile | 8 ++++--- Examples/android/simple/Makefile | 8 ++++--- Examples/chicken/class/Makefile | 9 +++++--- Examples/chicken/constants/Makefile | 6 +++-- Examples/chicken/egg/Makefile | 10 ++++---- Examples/chicken/multimap/Makefile | 6 +++-- Examples/chicken/overload/Makefile | 6 +++-- Examples/chicken/simple/Makefile | 6 +++-- Examples/csharp/arrays/Makefile | 6 +++-- Examples/csharp/callback/Makefile | 6 +++-- Examples/csharp/class/Makefile | 6 +++-- Examples/csharp/enum/Makefile | 6 +++-- Examples/csharp/extend/Makefile | 6 +++-- Examples/csharp/funcptr/Makefile | 6 +++-- Examples/csharp/nested/Makefile | 6 +++-- Examples/csharp/reference/Makefile | 6 +++-- Examples/csharp/simple/Makefile | 6 +++-- Examples/csharp/template/Makefile | 6 +++-- Examples/csharp/variables/Makefile | 6 +++-- Examples/d/example.mk.in | 15 ++++++++---- Examples/go/callback/Makefile | 8 ++++--- Examples/go/class/Makefile | 6 +++-- Examples/go/constants/Makefile | 6 +++-- Examples/go/director/Makefile | 8 ++++--- Examples/go/enum/Makefile | 6 +++-- Examples/go/extend/Makefile | 8 ++++--- Examples/go/funcptr/Makefile | 6 +++-- Examples/go/multimap/Makefile | 6 +++-- Examples/go/pointer/Makefile | 6 +++-- Examples/go/reference/Makefile | 6 +++-- Examples/go/simple/Makefile | 6 +++-- Examples/go/template/Makefile | 6 +++-- Examples/go/variables/Makefile | 6 +++-- Examples/guile/class/Makefile | 9 +++++--- Examples/guile/constants/Makefile | 6 +++-- Examples/guile/matrix/Makefile | 6 +++-- Examples/guile/multimap/Makefile | 9 +++++--- Examples/guile/multivalue/Makefile | 9 +++++--- Examples/guile/port/Makefile | 6 +++-- Examples/guile/simple/Makefile | 6 +++-- Examples/guile/std_vector/Makefile | 9 +++++--- Examples/java/callback/Makefile | 6 +++-- Examples/java/class/Makefile | 2 +- Examples/java/constants/Makefile | 6 +++-- Examples/java/enum/Makefile | 6 +++-- Examples/java/extend/Makefile | 6 +++-- Examples/java/funcptr/Makefile | 6 +++-- Examples/java/multimap/Makefile | 6 +++-- Examples/java/native/Makefile | 6 +++-- Examples/java/nested/Makefile | 6 +++-- Examples/java/pointer/Makefile | 6 +++-- Examples/java/reference/Makefile | 6 +++-- Examples/java/simple/Makefile | 6 +++-- Examples/java/template/Makefile | 6 +++-- Examples/java/typemap/Makefile | 6 +++-- Examples/java/variables/Makefile | 6 +++-- Examples/javascript/example.mk | 19 ++++++++------- Examples/lua/arrays/Makefile | 9 +++++--- Examples/lua/class/Makefile | 9 +++++--- Examples/lua/constants/Makefile | 9 +++++--- Examples/lua/dual/Makefile | 14 +++++++---- Examples/lua/embed/Makefile | 6 +++-- Examples/lua/embed2/Makefile | 6 +++-- Examples/lua/embed3/Makefile | 10 +++++--- Examples/lua/exception/Makefile | 9 +++++--- Examples/lua/funcptr3/Makefile | 9 +++++--- Examples/lua/functest/Makefile | 9 +++++--- Examples/lua/functor/Makefile | 9 +++++--- Examples/lua/import/Makefile | 23 +++++++++++-------- Examples/lua/nspace/Makefile | 9 +++++--- Examples/lua/owner/Makefile | 9 +++++--- Examples/lua/pointer/Makefile | 9 +++++--- Examples/lua/simple/Makefile | 9 +++++--- Examples/lua/variables/Makefile | 9 +++++--- Examples/modula3/class/Makefile | 6 +++-- Examples/modula3/enum/Makefile | 6 +++-- Examples/modula3/exception/Makefile | 6 +++-- Examples/modula3/reference/Makefile | 6 +++-- Examples/modula3/simple/Makefile | 6 +++-- Examples/modula3/typemap/Makefile | 6 +++-- Examples/mzscheme/multimap/Makefile | 6 +++-- Examples/mzscheme/simple/Makefile | 6 +++-- Examples/mzscheme/std_vector/Makefile | 3 ++- Examples/ocaml/argout_ref/Makefile | 9 +++++--- Examples/ocaml/contract/Makefile | 12 ++++++---- Examples/ocaml/scoped_enum/Makefile | 12 ++++++---- Examples/ocaml/shapes/Makefile | 12 ++++++---- Examples/ocaml/simple/Makefile | 12 ++++++---- Examples/ocaml/std_string/Makefile | 9 +++++--- Examples/ocaml/std_vector/Makefile | 9 +++++--- Examples/ocaml/stl/Makefile | 15 ++++++++---- Examples/ocaml/string_from_ptr/Makefile | 12 ++++++---- Examples/ocaml/strings_test/Makefile | 12 ++++++---- Examples/octave/example.mk | 15 ++++++++---- Examples/perl5/callback/Makefile | 9 +++++--- Examples/perl5/class/Makefile | 9 +++++--- Examples/perl5/constants/Makefile | 9 +++++--- Examples/perl5/constants2/Makefile | 9 +++++--- Examples/perl5/extend/Makefile | 9 +++++--- Examples/perl5/funcptr/Makefile | 9 +++++--- Examples/perl5/import/Makefile | 23 +++++++++++-------- Examples/perl5/java/Makefile | 6 +++-- Examples/perl5/multimap/Makefile | 9 +++++--- Examples/perl5/multiple_inheritance/Makefile | 9 +++++--- Examples/perl5/pointer/Makefile | 9 +++++--- Examples/perl5/reference/Makefile | 9 +++++--- Examples/perl5/simple/Makefile | 9 +++++--- Examples/perl5/value/Makefile | 9 +++++--- Examples/perl5/variables/Makefile | 9 +++++--- Examples/perl5/xmlstring/Makefile | 9 +++++--- Examples/php/callback/Makefile | 9 +++++--- Examples/php/class/Makefile | 9 +++++--- Examples/php/constants/Makefile | 9 +++++--- Examples/php/cpointer/Makefile | 9 +++++--- Examples/php/disown/Makefile | 9 +++++--- Examples/php/enum/Makefile | 9 +++++--- Examples/php/extend/Makefile | 9 +++++--- Examples/php/funcptr/Makefile | 9 +++++--- Examples/php/overloading/Makefile | 9 +++++--- Examples/php/pointer/Makefile | 9 +++++--- Examples/php/pragmas/Makefile | 9 +++++--- Examples/php/proxy/Makefile | 9 +++++--- Examples/php/reference/Makefile | 9 +++++--- Examples/php/simple/Makefile | 9 +++++--- Examples/php/sync/Makefile | 9 +++++--- Examples/php/value/Makefile | 9 +++++--- Examples/php/variables/Makefile | 9 +++++--- Examples/pike/class/Makefile | 9 +++++--- Examples/pike/constants/Makefile | 9 +++++--- Examples/pike/enum/Makefile | 9 +++++--- Examples/pike/overload/Makefile | 9 +++++--- Examples/pike/simple/Makefile | 9 +++++--- Examples/pike/template/Makefile | 9 +++++--- Examples/python/callback/Makefile | 9 +++++--- Examples/python/class/Makefile | 9 +++++--- Examples/python/constants/Makefile | 9 +++++--- Examples/python/contract/Makefile | 13 +++++++---- Examples/python/docstrings/Makefile | 9 +++++--- Examples/python/enum/Makefile | 9 +++++--- Examples/python/exception/Makefile | 9 +++++--- Examples/python/exceptproxy/Makefile | 9 +++++--- Examples/python/extend/Makefile | 9 +++++--- Examples/python/funcptr/Makefile | 9 +++++--- Examples/python/funcptr2/Makefile | 9 +++++--- Examples/python/functor/Makefile | 9 +++++--- Examples/python/import/Makefile | 23 +++++++++++-------- .../from_init1/py2/pkg2/Makefile | 23 +++++++++++-------- .../from_init1/py3/pkg2/Makefile | 23 +++++++++++-------- .../from_init2/py2/pkg2/Makefile | 13 +++++++---- .../from_init2/py2/pkg2/pkg3/Makefile | 13 +++++++---- .../from_init2/py3/pkg2/Makefile | 13 +++++++---- .../from_init2/py3/pkg2/pkg3/Makefile | 13 +++++++---- .../from_init3/py2/pkg2/Makefile | 13 +++++++---- .../from_init3/py2/pkg2/pkg3/pkg4/Makefile | 13 +++++++---- .../from_init3/py3/pkg2/Makefile | 13 +++++++---- .../from_init3/py3/pkg2/pkg3/pkg4/Makefile | 13 +++++++---- .../relativeimport1/py2/pkg2/Makefile | 13 +++++++---- .../relativeimport1/py2/pkg2/pkg3/Makefile | 13 +++++++---- .../relativeimport1/py3/pkg2/Makefile | 13 +++++++---- .../relativeimport1/py3/pkg2/pkg3/Makefile | 13 +++++++---- .../relativeimport2/py2/pkg2/Makefile | 13 +++++++---- .../py2/pkg2/pkg3/pkg4/Makefile | 13 +++++++---- .../relativeimport2/py3/pkg2/Makefile | 13 +++++++---- .../py3/pkg2/pkg3/pkg4/Makefile | 13 +++++++---- .../relativeimport3/py2/pkg2/Makefile | 13 +++++++---- .../relativeimport3/py2/pkg2/pkg3/Makefile | 13 +++++++---- .../relativeimport3/py3/pkg2/Makefile | 13 +++++++---- .../relativeimport3/py3/pkg2/pkg3/Makefile | 13 +++++++---- .../same_modnames1/pkg1/Makefile | 13 +++++++---- .../same_modnames1/pkg2/Makefile | 13 +++++++---- .../same_modnames2/pkg1/Makefile | 13 +++++++---- .../same_modnames2/pkg1/pkg2/Makefile | 13 +++++++---- Examples/python/import_template/Makefile | 23 +++++++++++-------- Examples/python/java/Makefile | 6 +++-- Examples/python/libffi/Makefile | 9 +++++--- Examples/python/multimap/Makefile | 9 +++++--- Examples/python/operator/Makefile | 9 +++++--- .../python/performance/constructor/Makefile | 21 ++++++++++------- Examples/python/performance/func/Makefile | 21 ++++++++++------- .../python/performance/hierarchy/Makefile | 21 ++++++++++------- .../performance/hierarchy_operator/Makefile | 21 ++++++++++------- Examples/python/performance/operator/Makefile | 21 ++++++++++------- Examples/python/pointer/Makefile | 9 +++++--- Examples/python/reference/Makefile | 9 +++++--- Examples/python/simple/Makefile | 9 +++++--- Examples/python/smartptr/Makefile | 9 +++++--- Examples/python/std_map/Makefile | 9 +++++--- Examples/python/std_vector/Makefile | 9 +++++--- Examples/python/template/Makefile | 9 +++++--- Examples/python/varargs/Makefile | 9 +++++--- Examples/python/variables/Makefile | 9 +++++--- Examples/r/class/Makefile | 6 +++-- Examples/r/simple/Makefile | 6 +++-- Examples/ruby/class/Makefile | 9 +++++--- Examples/ruby/constants/Makefile | 9 +++++--- Examples/ruby/enum/Makefile | 9 +++++--- Examples/ruby/exception_class/Makefile | 9 +++++--- Examples/ruby/free_function/Makefile | 9 +++++--- Examples/ruby/funcptr/Makefile | 9 +++++--- Examples/ruby/funcptr2/Makefile | 9 +++++--- Examples/ruby/functor/Makefile | 9 +++++--- Examples/ruby/hashargs/Makefile | 9 +++++--- Examples/ruby/import/Makefile | 23 +++++++++++-------- Examples/ruby/import_template/Makefile | 23 +++++++++++-------- Examples/ruby/java/Makefile | 6 +++-- Examples/ruby/mark_function/Makefile | 9 +++++--- Examples/ruby/multimap/Makefile | 9 +++++--- Examples/ruby/operator/Makefile | 9 +++++--- Examples/ruby/overloading/Makefile | 9 +++++--- Examples/ruby/pointer/Makefile | 9 +++++--- Examples/ruby/reference/Makefile | 9 +++++--- Examples/ruby/simple/Makefile | 9 +++++--- Examples/ruby/std_vector/Makefile | 9 +++++--- Examples/ruby/template/Makefile | 9 +++++--- Examples/ruby/value/Makefile | 9 +++++--- Examples/ruby/variables/Makefile | 9 +++++--- Examples/s-exp/uffi.lisp | 2 +- Examples/scilab/class/Makefile | 6 +++-- Examples/scilab/constants/Makefile | 6 +++-- Examples/scilab/contract/Makefile | 6 +++-- Examples/scilab/enum/Makefile | 6 +++-- Examples/scilab/funcptr/Makefile | 6 +++-- Examples/scilab/matrix/Makefile | 6 +++-- Examples/scilab/matrix2/Makefile | 6 +++-- Examples/scilab/pointer/Makefile | 6 +++-- Examples/scilab/simple/Makefile | 6 +++-- Examples/scilab/std_list/Makefile | 6 +++-- Examples/scilab/std_vector/Makefile | 6 +++-- Examples/scilab/struct/Makefile | 6 +++-- Examples/scilab/template/Makefile | 6 +++-- Examples/scilab/variables/Makefile | 6 +++-- Examples/tcl/class/Makefile | 9 +++++--- Examples/tcl/constants/Makefile | 9 +++++--- Examples/tcl/contract/Makefile | 13 +++++++---- Examples/tcl/enum/Makefile | 9 +++++--- Examples/tcl/funcptr/Makefile | 9 +++++--- Examples/tcl/import/Makefile | 23 +++++++++++-------- Examples/tcl/java/Makefile | 6 +++-- Examples/tcl/multimap/Makefile | 9 +++++--- Examples/tcl/operator/Makefile | 9 +++++--- Examples/tcl/pointer/Makefile | 9 +++++--- Examples/tcl/reference/Makefile | 9 +++++--- Examples/tcl/simple/Makefile | 9 +++++--- Examples/tcl/std_vector/Makefile | 9 +++++--- Examples/tcl/value/Makefile | 9 +++++--- Examples/tcl/variables/Makefile | 9 +++++--- Makefile.in | 8 ++----- 249 files changed, 1518 insertions(+), 817 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 66a76e2df..7ac312e58 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1453,6 +1453,12 @@ lua_cpp: $(SRCDIR_SRCS) $(GENCXXSRCS) $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(GENCXXSRCS) $(INCLUDES) $(LUA_INCLUDE) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO) +lua_externalhdr: + $(SWIG) -lua -external-runtime $(TARGET) + +lua_swig_cpp: + $(SWIG) -c++ -lua $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) + # ----------------------------------------------------------------- # Build statically linked Lua interpreter # ----------------------------------------------------------------- diff --git a/Examples/android/class/Makefile b/Examples/android/class/Makefile index 574566623..8b5a090e9 100644 --- a/Examples/android/class/Makefile +++ b/Examples/android/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib TARGET = example INTERFACE = example.i INTERFACEDIR = jni/ @@ -13,8 +14,9 @@ TARGETID = 1 check: build build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp install: diff --git a/Examples/android/extend/Makefile b/Examples/android/extend/Makefile index fb974d22c..19d90ecca 100644 --- a/Examples/android/extend/Makefile +++ b/Examples/android/extend/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib TARGET = example INTERFACE = example.i INTERFACEDIR = jni/ @@ -13,8 +14,9 @@ TARGETID = 1 check: build build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp install: diff --git a/Examples/android/simple/Makefile b/Examples/android/simple/Makefile index 2bf41968a..46bcd93ca 100644 --- a/Examples/android/simple/Makefile +++ b/Examples/android/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib TARGET = example INTERFACE = example.i INTERFACEDIR = jni/ @@ -13,8 +14,9 @@ TARGETID = 1 check: build build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android install: diff --git a/Examples/chicken/class/Makefile b/Examples/chicken/class/Makefile index fd4212d99..ea2d8b62e 100644 --- a/Examples/chicken/class/Makefile +++ b/Examples/chicken/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib INTERFACE = example.i SRCS = CXXSRCS = example.cxx @@ -22,14 +23,16 @@ build: $(TARGET) $(TARGET)_proxy $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp + INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp $(TARGET)_proxy: $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp + INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean diff --git a/Examples/chicken/constants/Makefile b/Examples/chicken/constants/Makefile index f3c9d38b9..2fdde0a58 100644 --- a/Examples/chicken/constants/Makefile +++ b/Examples/chicken/constants/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib INTERFACE = example.i SRCS = CXXSRCS = @@ -20,8 +21,9 @@ build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) + INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean diff --git a/Examples/chicken/egg/Makefile b/Examples/chicken/egg/Makefile index 55aa114eb..0137dc0a7 100644 --- a/Examples/chicken/egg/Makefile +++ b/Examples/chicken/egg/Makefile @@ -1,4 +1,6 @@ -SWIG = ../../../preinst-swig +TOP = ../.. +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib check: build cd eggs/install && csi ../../test.scm @@ -14,7 +16,7 @@ single: single_wrap.cxx # compile the single module with -nounit single_wrap.cxx: single.i - $(SWIG) -chicken -c++ -proxy -nounit single.i + $(SWIGEXE) -chicken -c++ -proxy -nounit single.i # Now build both mod1 and mod2 into a single egg multi: mod1_wrap.cxx mod2_wrap.cxx @@ -23,10 +25,10 @@ multi: mod1_wrap.cxx mod2_wrap.cxx rm -f mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx mod1_wrap.cxx: mod1.i - $(SWIG) -chicken -c++ -proxy mod1.i + $(SWIGEXE) -chicken -c++ -proxy mod1.i mod2_wrap.cxx: mod2.i - $(SWIG) -chicken -c++ -proxy mod2.i + $(SWIGEXE) -chicken -c++ -proxy mod2.i clean: rm -rf eggs diff --git a/Examples/chicken/multimap/Makefile b/Examples/chicken/multimap/Makefile index 758e7d635..551d1c74d 100644 --- a/Examples/chicken/multimap/Makefile +++ b/Examples/chicken/multimap/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib INTERFACE = example.i SRCS = example.c CXXSRCS = @@ -20,8 +21,9 @@ build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) + INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean diff --git a/Examples/chicken/overload/Makefile b/Examples/chicken/overload/Makefile index 66aa380e6..019390192 100644 --- a/Examples/chicken/overload/Makefile +++ b/Examples/chicken/overload/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib INTERFACE = example.i SRCS = CXXSRCS = example.cxx @@ -20,8 +21,9 @@ build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp + INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean diff --git a/Examples/chicken/simple/Makefile b/Examples/chicken/simple/Makefile index e8617366b..f5dd1a966 100644 --- a/Examples/chicken/simple/Makefile +++ b/Examples/chicken/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib INTERFACE = example.i SRCS = example.c CXXSRCS = @@ -20,8 +21,9 @@ build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) + INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean diff --git a/Examples/csharp/arrays/Makefile b/Examples/csharp/arrays/Makefile index e5d733d35..66b2c2171 100644 --- a/Examples/csharp/arrays/Makefile +++ b/Examples/csharp/arrays/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile diff --git a/Examples/csharp/callback/Makefile b/Examples/csharp/callback/Makefile index 4f4c84b9a..c7f264ecc 100644 --- a/Examples/csharp/callback/Makefile +++ b/Examples/csharp/callback/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile diff --git a/Examples/csharp/class/Makefile b/Examples/csharp/class/Makefile index 4f4c84b9a..c7f264ecc 100644 --- a/Examples/csharp/class/Makefile +++ b/Examples/csharp/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile diff --git a/Examples/csharp/enum/Makefile b/Examples/csharp/enum/Makefile index 4f4c84b9a..c7f264ecc 100644 --- a/Examples/csharp/enum/Makefile +++ b/Examples/csharp/enum/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile diff --git a/Examples/csharp/extend/Makefile b/Examples/csharp/extend/Makefile index 4f4c84b9a..c7f264ecc 100644 --- a/Examples/csharp/extend/Makefile +++ b/Examples/csharp/extend/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile diff --git a/Examples/csharp/funcptr/Makefile b/Examples/csharp/funcptr/Makefile index 99cdfa38a..9af1d66ff 100644 --- a/Examples/csharp/funcptr/Makefile +++ b/Examples/csharp/funcptr/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile diff --git a/Examples/csharp/nested/Makefile b/Examples/csharp/nested/Makefile index 4f4c84b9a..c7f264ecc 100644 --- a/Examples/csharp/nested/Makefile +++ b/Examples/csharp/nested/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile diff --git a/Examples/csharp/reference/Makefile b/Examples/csharp/reference/Makefile index 4f4c84b9a..c7f264ecc 100644 --- a/Examples/csharp/reference/Makefile +++ b/Examples/csharp/reference/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile diff --git a/Examples/csharp/simple/Makefile b/Examples/csharp/simple/Makefile index 99cdfa38a..9af1d66ff 100644 --- a/Examples/csharp/simple/Makefile +++ b/Examples/csharp/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile diff --git a/Examples/csharp/template/Makefile b/Examples/csharp/template/Makefile index 2d0e07009..010447fe2 100644 --- a/Examples/csharp/template/Makefile +++ b/Examples/csharp/template/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile diff --git a/Examples/csharp/variables/Makefile b/Examples/csharp/variables/Makefile index 99cdfa38a..9af1d66ff 100644 --- a/Examples/csharp/variables/Makefile +++ b/Examples/csharp/variables/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile diff --git a/Examples/d/example.mk.in b/Examples/d/example.mk.in index a1d9a85fc..84b3ceb09 100644 --- a/Examples/d/example.mk.in +++ b/Examples/d/example.mk.in @@ -23,7 +23,8 @@ endif EXAMPLES_TOP = ../../.. SWIG_TOP = ../../../.. -SWIG = $(SWIG_TOP)/preinst-swig +SWIGEXE = $(SWIG_TOP)/swig +SWIG_LIB_DIR = $(SWIG_TOP)/$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib EXTRA_CFLAGS = EXTRA_CXXFLAGS = EXTRA_LDFLAGS = @@ -44,11 +45,17 @@ check: build build: mkdir -p $(VERSION_DIR) if [ -f $(SRCDIR)example.cxx ]; then \ - $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CXXFLAGS='$(EXTRA_CXXFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' CXXSRCS='example.cxx' d_cpp; \ + $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CXXFLAGS='$(EXTRA_CXXFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' CXXSRCS='example.cxx' d_cpp; \ elif [ -f $(SRCDIR)example.c ]; then \ - $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='example.c' d; \ + $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='example.c' d; \ else \ - $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='' d; \ + $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='' d; \ fi $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile diff --git a/Examples/go/callback/Makefile b/Examples/go/callback/Makefile index 7441e09bd..86047367c 100644 --- a/Examples/go/callback/Makefile +++ b/Examples/go/callback/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = callback.cxx GOSRCS = gocallback.go TARGET = example @@ -15,10 +16,11 @@ build: fi @# Note: example.go gets generated by SWIG $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='example.go $(GOSRCS)' \ - SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: if [ -n '$(SRCDIR)' ]; then \ - rm $(GOSRCS) || true; \ + rm -f $(GOSRCS); \ fi $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/class/Makefile b/Examples/go/class/Makefile index de067cdd8..f72c067e6 100644 --- a/Examples/go/class/Makefile +++ b/Examples/go/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = class.cxx TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: diff --git a/Examples/go/constants/Makefile b/Examples/go/constants/Makefile index 8fb07fd6b..b791fc9cf 100644 --- a/Examples/go/constants/Makefile +++ b/Examples/go/constants/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: diff --git a/Examples/go/director/Makefile b/Examples/go/director/Makefile index 2e9e87b89..430cac834 100644 --- a/Examples/go/director/Makefile +++ b/Examples/go/director/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = GOSRCS = director.go TARGET = example @@ -15,10 +16,11 @@ build: fi @# Note: example.go gets generated by SWIG $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='example.go $(GOSRCS)' \ - SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: if [ -n '$(SRCDIR)' ]; then \ - rm $(GOSRCS) || true; \ + rm -f $(GOSRCS); \ fi $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/enum/Makefile b/Examples/go/enum/Makefile index 2e2f1b2bd..15defe905 100644 --- a/Examples/go/enum/Makefile +++ b/Examples/go/enum/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = enum.cxx TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: diff --git a/Examples/go/extend/Makefile b/Examples/go/extend/Makefile index a9f2d8d7d..a3c520e72 100644 --- a/Examples/go/extend/Makefile +++ b/Examples/go/extend/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = extend.cxx GOSRCS = ceo.go TARGET = example @@ -15,10 +16,11 @@ build: fi @# Note: example.go gets generated by SWIG $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='example.go $(GOSRCS)' \ - SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: if [ -n '$(SRCDIR)' ]; then \ - rm $(GOSRCS) || true; \ + rm -f $(GOSRCS); \ fi $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/funcptr/Makefile b/Examples/go/funcptr/Makefile index 82031c9d5..efeb6e860 100644 --- a/Examples/go/funcptr/Makefile +++ b/Examples/go/funcptr/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = funcptr.c TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: diff --git a/Examples/go/multimap/Makefile b/Examples/go/multimap/Makefile index 4d739162b..ba172611d 100644 --- a/Examples/go/multimap/Makefile +++ b/Examples/go/multimap/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = multimap.c TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: diff --git a/Examples/go/pointer/Makefile b/Examples/go/pointer/Makefile index 9f1f3fda0..20587fd95 100644 --- a/Examples/go/pointer/Makefile +++ b/Examples/go/pointer/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = pointer.c TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: diff --git a/Examples/go/reference/Makefile b/Examples/go/reference/Makefile index e136f6fae..d203fff6d 100644 --- a/Examples/go/reference/Makefile +++ b/Examples/go/reference/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = reference.cxx TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: diff --git a/Examples/go/simple/Makefile b/Examples/go/simple/Makefile index 5bc16549d..89b936f3d 100644 --- a/Examples/go/simple/Makefile +++ b/Examples/go/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = simple.c TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: diff --git a/Examples/go/template/Makefile b/Examples/go/template/Makefile index a1d674836..f79b083cb 100644 --- a/Examples/go/template/Makefile +++ b/Examples/go/template/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp clean: diff --git a/Examples/go/variables/Makefile b/Examples/go/variables/Makefile index d0da605e0..cef1186af 100644 --- a/Examples/go/variables/Makefile +++ b/Examples/go/variables/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = variables.c TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go clean: diff --git a/Examples/guile/class/Makefile b/Examples/guile/class/Makefile index 48426a8fb..84a7b4322 100644 --- a/Examples/guile/class/Makefile +++ b/Examples/guile/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' guile_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp clean: diff --git a/Examples/guile/constants/Makefile b/Examples/guile/constants/Makefile index d3f58ebdc..abe63d4b1 100644 --- a/Examples/guile/constants/Makefile +++ b/Examples/guile/constants/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = my-guile INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_augmented_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented clean: diff --git a/Examples/guile/matrix/Makefile b/Examples/guile/matrix/Makefile index 9e541c36f..cfe0c8536 100644 --- a/Examples/guile/matrix/Makefile +++ b/Examples/guile/matrix/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = matrix.c vector.c TARGET = my-guile INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' GUILE_RUNOPTIONS='-e do-test' guile_augmented_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-lm' guile_augmented clean: diff --git a/Examples/guile/multimap/Makefile b/Examples/guile/multimap/Makefile index b8f5e9b5a..f87670219 100644 --- a/Examples/guile/multimap/Makefile +++ b/Examples/guile/multimap/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' guile_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static clean: diff --git a/Examples/guile/multivalue/Makefile b/Examples/guile/multivalue/Makefile index b8f5e9b5a..f87670219 100644 --- a/Examples/guile/multivalue/Makefile +++ b/Examples/guile/multivalue/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' guile_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static clean: diff --git a/Examples/guile/port/Makefile b/Examples/guile/port/Makefile index 0274dbf9b..09ee821f5 100644 --- a/Examples/guile/port/Makefile +++ b/Examples/guile/port/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = my-guile INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_augmented_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented clean: diff --git a/Examples/guile/simple/Makefile b/Examples/guile/simple/Makefile index 517e41c64..d8fb2da81 100644 --- a/Examples/guile/simple/Makefile +++ b/Examples/guile/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = my-guile INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_augmented_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented clean: diff --git a/Examples/guile/std_vector/Makefile b/Examples/guile/std_vector/Makefile index d7f5de217..1146242c2 100644 --- a/Examples/guile/std_vector/Makefile +++ b/Examples/guile/std_vector/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' guile_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp clean: diff --git a/Examples/java/callback/Makefile b/Examples/java/callback/Makefile index 13cfd1708..c76e09262 100644 --- a/Examples/java/callback/Makefile +++ b/Examples/java/callback/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/class/Makefile b/Examples/java/class/Makefile index faed36e71..c76e09262 100644 --- a/Examples/java/class/Makefile +++ b/Examples/java/class/Makefile @@ -12,7 +12,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/constants/Makefile b/Examples/java/constants/Makefile index 637ce0ead..ddc2157a6 100644 --- a/Examples/java/constants/Makefile +++ b/Examples/java/constants/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/enum/Makefile b/Examples/java/enum/Makefile index 13cfd1708..c76e09262 100644 --- a/Examples/java/enum/Makefile +++ b/Examples/java/enum/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/extend/Makefile b/Examples/java/extend/Makefile index 13cfd1708..c76e09262 100644 --- a/Examples/java/extend/Makefile +++ b/Examples/java/extend/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/funcptr/Makefile b/Examples/java/funcptr/Makefile index c0b1927ca..4babc683d 100644 --- a/Examples/java/funcptr/Makefile +++ b/Examples/java/funcptr/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/multimap/Makefile b/Examples/java/multimap/Makefile index c0b1927ca..4babc683d 100644 --- a/Examples/java/multimap/Makefile +++ b/Examples/java/multimap/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/native/Makefile b/Examples/java/native/Makefile index fa67e48a4..b43a7d152 100644 --- a/Examples/java/native/Makefile +++ b/Examples/java/native/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/nested/Makefile b/Examples/java/nested/Makefile index 13cfd1708..c76e09262 100644 --- a/Examples/java/nested/Makefile +++ b/Examples/java/nested/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/pointer/Makefile b/Examples/java/pointer/Makefile index c0b1927ca..4babc683d 100644 --- a/Examples/java/pointer/Makefile +++ b/Examples/java/pointer/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/reference/Makefile b/Examples/java/reference/Makefile index 13cfd1708..c76e09262 100644 --- a/Examples/java/reference/Makefile +++ b/Examples/java/reference/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/simple/Makefile b/Examples/java/simple/Makefile index c0b1927ca..4babc683d 100644 --- a/Examples/java/simple/Makefile +++ b/Examples/java/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/template/Makefile b/Examples/java/template/Makefile index 637ce0ead..ddc2157a6 100644 --- a/Examples/java/template/Makefile +++ b/Examples/java/template/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/typemap/Makefile b/Examples/java/typemap/Makefile index fa67e48a4..b43a7d152 100644 --- a/Examples/java/typemap/Makefile +++ b/Examples/java/typemap/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/java/variables/Makefile b/Examples/java/variables/Makefile index c0b1927ca..4babc683d 100644 --- a/Examples/java/variables/Makefile +++ b/Examples/java/variables/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile diff --git a/Examples/javascript/example.mk b/Examples/javascript/example.mk index cb8a33efd..3ef012aa8 100644 --- a/Examples/javascript/example.mk +++ b/Examples/javascript/example.mk @@ -13,20 +13,23 @@ else JSV8_VERSION=0x031110 endif -EXAMPLES_TOP=../.. -SWIG_TOP=../../.. -SWIG = $(SWIG_TOP)/preinst-swig -TARGET = example -INTERFACE = example.i -SWIGOPT=-$(JSENGINE) -DV8_VERSION=$(JSV8_VERSION) +EXAMPLES_TOP = ../.. +SWIG_TOP = ../../.. +SWIGEXE = $(SWIG_TOP)/swig +SWIG_LIB_DIR = $(SWIG_TOP)/$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib +TARGET = example +INTERFACE = example.i +SWIGOPT = -$(JSENGINE) -DV8_VERSION=$(JSV8_VERSION) check: build $(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' JSENGINE='$(JSENGINE)' TARGET='$(TARGET)' javascript_run build: - $(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_wrapper_cpp - $(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' JSENGINE='$(JSENGINE)' javascript_build_cpp clean: diff --git a/Examples/lua/arrays/Makefile b/Examples/lua/arrays/Makefile index 4191f7ec3..70de9c453 100644 --- a/Examples/lua/arrays/Makefile +++ b/Examples/lua/arrays/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: diff --git a/Examples/lua/class/Makefile b/Examples/lua/class/Makefile index 96308f0df..dd78fdbe9 100644 --- a/Examples/lua/class/Makefile +++ b/Examples/lua/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: diff --git a/Examples/lua/constants/Makefile b/Examples/lua/constants/Makefile index ae33cb182..979dc7d45 100644 --- a/Examples/lua/constants/Makefile +++ b/Examples/lua/constants/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: diff --git a/Examples/lua/dual/Makefile b/Examples/lua/dual/Makefile index c86152a97..53b28b645 100644 --- a/Examples/lua/dual/Makefile +++ b/Examples/lua/dual/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib TARGET = dual GENCXXSRCS = example2_wrap.cxx INTERFACE = dual.i @@ -11,9 +12,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: - $(SWIG) -lua -external-runtime - $(SWIG) -c++ -lua $(SWIGOPT) -o $(GENCXXSRCS) $(SRCDIR)example2.i - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) GENCXXSRCS='$(GENCXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + lua_externalhdr + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-c++' INTERFACE='example2.i' lua_swig_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) GENCXXSRCS='$(GENCXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp clean: diff --git a/Examples/lua/embed/Makefile b/Examples/lua/embed/Makefile index 5e3a91893..7f4054492 100644 --- a/Examples/lua/embed/Makefile +++ b/Examples/lua/embed/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib TARGET = embed SRCS = example.c INTERFACE = example.i @@ -12,7 +13,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' LIBS='$(LIBS)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static clean: diff --git a/Examples/lua/embed2/Makefile b/Examples/lua/embed2/Makefile index d30ba0942..28d9682b4 100644 --- a/Examples/lua/embed2/Makefile +++ b/Examples/lua/embed2/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib TARGET = embed2 SRCS = example.c INTERFACE = example.i @@ -12,7 +13,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' LIBS='$(LIBS)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static clean: diff --git a/Examples/lua/embed3/Makefile b/Examples/lua/embed3/Makefile index fc0026122..d8e7c7385 100644 --- a/Examples/lua/embed3/Makefile +++ b/Examples/lua/embed3/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib TARGET = embed3 SRCS = example.cpp INTERFACE = example.i @@ -12,8 +13,11 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run build: - $(SWIG) -c++ -lua $(SWIGOPT) -external-runtime swigluarun.h - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + lua_externalhdr + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp clean: diff --git a/Examples/lua/exception/Makefile b/Examples/lua/exception/Makefile index ac9c28b69..a476f0b91 100644 --- a/Examples/lua/exception/Makefile +++ b/Examples/lua/exception/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: diff --git a/Examples/lua/funcptr3/Makefile b/Examples/lua/funcptr3/Makefile index aeeaad469..fb363cbe9 100644 --- a/Examples/lua/funcptr3/Makefile +++ b/Examples/lua/funcptr3/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: diff --git a/Examples/lua/functest/Makefile b/Examples/lua/functest/Makefile index aeeaad469..fb363cbe9 100644 --- a/Examples/lua/functest/Makefile +++ b/Examples/lua/functest/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: diff --git a/Examples/lua/functor/Makefile b/Examples/lua/functor/Makefile index e647fb2a8..1bc860a70 100644 --- a/Examples/lua/functor/Makefile +++ b/Examples/lua/functor/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: diff --git a/Examples/lua/import/Makefile b/Examples/lua/import/Makefile index 8d64a21c6..ff73702c4 100644 --- a/Examples/lua/import/Makefile +++ b/Examples/lua/import/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = @@ -7,14 +8,18 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' lua_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' lua_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' lua_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' lua_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' lua_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' lua_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' lua_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' lua_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean diff --git a/Examples/lua/nspace/Makefile b/Examples/lua/nspace/Makefile index 17757c2ec..fdedebca1 100644 --- a/Examples/lua/nspace/Makefile +++ b/Examples/lua/nspace/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: diff --git a/Examples/lua/owner/Makefile b/Examples/lua/owner/Makefile index 96308f0df..dd78fdbe9 100644 --- a/Examples/lua/owner/Makefile +++ b/Examples/lua/owner/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static clean: diff --git a/Examples/lua/pointer/Makefile b/Examples/lua/pointer/Makefile index aeeaad469..fb363cbe9 100644 --- a/Examples/lua/pointer/Makefile +++ b/Examples/lua/pointer/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: diff --git a/Examples/lua/simple/Makefile b/Examples/lua/simple/Makefile index 4191f7ec3..70de9c453 100644 --- a/Examples/lua/simple/Makefile +++ b/Examples/lua/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: diff --git a/Examples/lua/variables/Makefile b/Examples/lua/variables/Makefile index 4191f7ec3..70de9c453 100644 --- a/Examples/lua/variables/Makefile +++ b/Examples/lua/variables/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static clean: diff --git a/Examples/modula3/class/Makefile b/Examples/modula3/class/Makefile index 2e2f37526..b25f636c3 100644 --- a/Examples/modula3/class/Makefile +++ b/Examples/modula3/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example PLATFORM = LINUXLIBC6 @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) # compilation of example_wrap.cxx is started by cm3 diff --git a/Examples/modula3/enum/Makefile b/Examples/modula3/enum/Makefile index 3915e5405..ea56fae46 100644 --- a/Examples/modula3/enum/Makefile +++ b/Examples/modula3/enum/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -15,7 +16,8 @@ build: $(CXX) -Wall $(CONSTNUMERIC).c -o $(CONSTNUMERIC) $(CONSTNUMERIC) >$(CONSTNUMERIC).i - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ diff --git a/Examples/modula3/exception/Makefile b/Examples/modula3/exception/Makefile index 1dbf1a156..8d12ef19e 100644 --- a/Examples/modula3/exception/Makefile +++ b/Examples/modula3/exception/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -11,7 +12,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3_cpp # $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MODULA3SRCS='$(MODULA3SRCS)' MODULA3FLAGS='$(MODULA3FLAGS)' modula3_compile m3ppinplace $(MODULA3SRCS) diff --git a/Examples/modula3/reference/Makefile b/Examples/modula3/reference/Makefile index 3b68fe822..eaceceb1f 100644 --- a/Examples/modula3/reference/Makefile +++ b/Examples/modula3/reference/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ diff --git a/Examples/modula3/simple/Makefile b/Examples/modula3/simple/Makefile index 2796b25f8..3ba35d18b 100644 --- a/Examples/modula3/simple/Makefile +++ b/Examples/modula3/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ diff --git a/Examples/modula3/typemap/Makefile b/Examples/modula3/typemap/Makefile index 2796b25f8..3ba35d18b 100644 --- a/Examples/modula3/typemap/Makefile +++ b/Examples/modula3/typemap/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -10,7 +11,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ diff --git a/Examples/mzscheme/multimap/Makefile b/Examples/mzscheme/multimap/Makefile index ecf83fbeb..713ee43a7 100644 --- a/Examples/mzscheme/multimap/Makefile +++ b/Examples/mzscheme/multimap/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean diff --git a/Examples/mzscheme/simple/Makefile b/Examples/mzscheme/simple/Makefile index ecf83fbeb..713ee43a7 100644 --- a/Examples/mzscheme/simple/Makefile +++ b/Examples/mzscheme/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean diff --git a/Examples/mzscheme/std_vector/Makefile b/Examples/mzscheme/std_vector/Makefile index 75918a61e..74474aea1 100644 --- a/Examples/mzscheme/std_vector/Makefile +++ b/Examples/mzscheme/std_vector/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i diff --git a/Examples/ocaml/argout_ref/Makefile b/Examples/ocaml/argout_ref/Makefile index 09893af65..8b7fc959e 100644 --- a/Examples/ocaml/argout_ref/Makefile +++ b/Examples/ocaml/argout_ref/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -13,13 +14,15 @@ check: build build: static static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp dynamic: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp diff --git a/Examples/ocaml/contract/Makefile b/Examples/ocaml/contract/Makefile index df5d6a6f5..c77e6dcc4 100644 --- a/Examples/ocaml/contract/Makefile +++ b/Examples/ocaml/contract/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -13,19 +14,22 @@ check: build build: static dynamic: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static toplevel: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_toplevel diff --git a/Examples/ocaml/scoped_enum/Makefile b/Examples/ocaml/scoped_enum/Makefile index 794733971..9655c98e6 100644 --- a/Examples/ocaml/scoped_enum/Makefile +++ b/Examples/ocaml/scoped_enum/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -13,19 +14,22 @@ check: build build: static dynamic: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp toplevel: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel diff --git a/Examples/ocaml/shapes/Makefile b/Examples/ocaml/shapes/Makefile index 69102f3b1..b291d07e8 100644 --- a/Examples/ocaml/shapes/Makefile +++ b/Examples/ocaml/shapes/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = SRCS = example.c TARGET = example @@ -14,19 +15,22 @@ check: build build: static static_top static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp static_top: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel dynamic: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp diff --git a/Examples/ocaml/simple/Makefile b/Examples/ocaml/simple/Makefile index 49bf81c1e..88fef7435 100644 --- a/Examples/ocaml/simple/Makefile +++ b/Examples/ocaml/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -13,19 +14,22 @@ check: build build: static dynamic: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static toplevel: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_toplevel diff --git a/Examples/ocaml/std_string/Makefile b/Examples/ocaml/std_string/Makefile index 8f8b2f684..099b1fcee 100644 --- a/Examples/ocaml/std_string/Makefile +++ b/Examples/ocaml/std_string/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -11,12 +12,14 @@ check: build build: static static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp dynamic: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_dynamic_cpp diff --git a/Examples/ocaml/std_vector/Makefile b/Examples/ocaml/std_vector/Makefile index 8f8b2f684..099b1fcee 100644 --- a/Examples/ocaml/std_vector/Makefile +++ b/Examples/ocaml/std_vector/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -11,12 +12,14 @@ check: build build: static static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp dynamic: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_dynamic_cpp diff --git a/Examples/ocaml/stl/Makefile b/Examples/ocaml/stl/Makefile index e4cce4883..912dd9f8d 100644 --- a/Examples/ocaml/stl/Makefile +++ b/Examples/ocaml/stl/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -11,22 +12,26 @@ check: build build: static static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp director: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_director dynamic: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp toplevel: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_toplevel diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile index 294bdec83..f9b027802 100644 --- a/Examples/ocaml/string_from_ptr/Makefile +++ b/Examples/ocaml/string_from_ptr/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = -c++ SRCS = TARGET = example @@ -14,19 +15,22 @@ check: build build: static static_top static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp static_top: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel dynamic: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp diff --git a/Examples/ocaml/strings_test/Makefile b/Examples/ocaml/strings_test/Makefile index b6b866669..24e2e6cca 100644 --- a/Examples/ocaml/strings_test/Makefile +++ b/Examples/ocaml/strings_test/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -11,17 +12,20 @@ check: build build: static top static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp dynamic: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp top: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_toplevel diff --git a/Examples/octave/example.mk b/Examples/octave/example.mk index e0b1e4efb..1ab96f038 100644 --- a/Examples/octave/example.mk +++ b/Examples/octave/example.mk @@ -2,7 +2,8 @@ # These paths are relative to such an example directory TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib TARGET = swigexample INTERFACE = example.i @@ -11,18 +12,22 @@ check: build build: ifneq (,$(SRCS)) - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave else - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp endif ifneq (,$(TARGET2)$(SWIGOPT2)) ifneq (,$(SRCS)) - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave else - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave_cpp endif endif diff --git a/Examples/perl5/callback/Makefile b/Examples/perl5/callback/Makefile index 0d1cc574f..08271768c 100644 --- a/Examples/perl5/callback/Makefile +++ b/Examples/perl5/callback/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: diff --git a/Examples/perl5/class/Makefile b/Examples/perl5/class/Makefile index 0d1cc574f..08271768c 100644 --- a/Examples/perl5/class/Makefile +++ b/Examples/perl5/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: diff --git a/Examples/perl5/constants/Makefile b/Examples/perl5/constants/Makefile index b7b411534..b0dc67806 100644 --- a/Examples/perl5/constants/Makefile +++ b/Examples/perl5/constants/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: diff --git a/Examples/perl5/constants2/Makefile b/Examples/perl5/constants2/Makefile index 85dd13741..db676cc4e 100644 --- a/Examples/perl5/constants2/Makefile +++ b/Examples/perl5/constants2/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: diff --git a/Examples/perl5/extend/Makefile b/Examples/perl5/extend/Makefile index 0d1cc574f..08271768c 100644 --- a/Examples/perl5/extend/Makefile +++ b/Examples/perl5/extend/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: diff --git a/Examples/perl5/funcptr/Makefile b/Examples/perl5/funcptr/Makefile index 3e1de1fc1..dfc01843e 100644 --- a/Examples/perl5/funcptr/Makefile +++ b/Examples/perl5/funcptr/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: diff --git a/Examples/perl5/import/Makefile b/Examples/perl5/import/Makefile index b31ab7952..e9225af25 100644 --- a/Examples/perl5/import/Makefile +++ b/Examples/perl5/import/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = @@ -7,14 +8,18 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='baseclass' INTERFACE='base.i' perl5_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' perl5_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' perl5_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' perl5_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='baseclass' INTERFACE='base.i' perl5_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' perl5_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' perl5_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' perl5_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean diff --git a/Examples/perl5/java/Makefile b/Examples/perl5/java/Makefile index 5eaea3212..7c133235f 100644 --- a/Examples/perl5/java/Makefile +++ b/Examples/perl5/java/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: Example.class Example.h - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ CXXSHARED="gcj -fpic -shared Example.class" PERL5_CCFLAGS='' PERL5_EXP='' LIBS="-lstdc++" perl5_cpp diff --git a/Examples/perl5/multimap/Makefile b/Examples/perl5/multimap/Makefile index 3e1de1fc1..dfc01843e 100644 --- a/Examples/perl5/multimap/Makefile +++ b/Examples/perl5/multimap/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: diff --git a/Examples/perl5/multiple_inheritance/Makefile b/Examples/perl5/multiple_inheritance/Makefile index 1fe5a51bb..b73356e3e 100644 --- a/Examples/perl5/multiple_inheritance/Makefile +++ b/Examples/perl5/multiple_inheritance/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: diff --git a/Examples/perl5/pointer/Makefile b/Examples/perl5/pointer/Makefile index 3e1de1fc1..dfc01843e 100644 --- a/Examples/perl5/pointer/Makefile +++ b/Examples/perl5/pointer/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: diff --git a/Examples/perl5/reference/Makefile b/Examples/perl5/reference/Makefile index a22f5a68d..c4212099e 100644 --- a/Examples/perl5/reference/Makefile +++ b/Examples/perl5/reference/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp_static clean: diff --git a/Examples/perl5/simple/Makefile b/Examples/perl5/simple/Makefile index 3e1de1fc1..dfc01843e 100644 --- a/Examples/perl5/simple/Makefile +++ b/Examples/perl5/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: diff --git a/Examples/perl5/value/Makefile b/Examples/perl5/value/Makefile index 3e1de1fc1..dfc01843e 100644 --- a/Examples/perl5/value/Makefile +++ b/Examples/perl5/value/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: diff --git a/Examples/perl5/variables/Makefile b/Examples/perl5/variables/Makefile index 3e1de1fc1..dfc01843e 100644 --- a/Examples/perl5/variables/Makefile +++ b/Examples/perl5/variables/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean: diff --git a/Examples/perl5/xmlstring/Makefile b/Examples/perl5/xmlstring/Makefile index 4f02d3ee4..3b4ba0ea4 100644 --- a/Examples/perl5/xmlstring/Makefile +++ b/Examples/perl5/xmlstring/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS=$(LIBS) CXX="g++ -g3" perl5_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static clean: diff --git a/Examples/php/callback/Makefile b/Examples/php/callback/Makefile index 3ad3999a5..cbc75774c 100644 --- a/Examples/php/callback/Makefile +++ b/Examples/php/callback/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static clean: diff --git a/Examples/php/class/Makefile b/Examples/php/class/Makefile index 8b2b340e9..02a8668ac 100644 --- a/Examples/php/class/Makefile +++ b/Examples/php/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static diff --git a/Examples/php/constants/Makefile b/Examples/php/constants/Makefile index e5b49571e..9dbd3842d 100644 --- a/Examples/php/constants/Makefile +++ b/Examples/php/constants/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static diff --git a/Examples/php/cpointer/Makefile b/Examples/php/cpointer/Makefile index f2c15c5c1..05679f844 100644 --- a/Examples/php/cpointer/Makefile +++ b/Examples/php/cpointer/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static diff --git a/Examples/php/disown/Makefile b/Examples/php/disown/Makefile index 8b2b340e9..02a8668ac 100644 --- a/Examples/php/disown/Makefile +++ b/Examples/php/disown/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static diff --git a/Examples/php/enum/Makefile b/Examples/php/enum/Makefile index 2028d03c7..95ebf8fc1 100644 --- a/Examples/php/enum/Makefile +++ b/Examples/php/enum/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static diff --git a/Examples/php/extend/Makefile b/Examples/php/extend/Makefile index 3ad3999a5..cbc75774c 100644 --- a/Examples/php/extend/Makefile +++ b/Examples/php/extend/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static clean: diff --git a/Examples/php/funcptr/Makefile b/Examples/php/funcptr/Makefile index f2c15c5c1..05679f844 100644 --- a/Examples/php/funcptr/Makefile +++ b/Examples/php/funcptr/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static diff --git a/Examples/php/overloading/Makefile b/Examples/php/overloading/Makefile index 8b2b340e9..02a8668ac 100644 --- a/Examples/php/overloading/Makefile +++ b/Examples/php/overloading/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static diff --git a/Examples/php/pointer/Makefile b/Examples/php/pointer/Makefile index f2c15c5c1..05679f844 100644 --- a/Examples/php/pointer/Makefile +++ b/Examples/php/pointer/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static diff --git a/Examples/php/pragmas/Makefile b/Examples/php/pragmas/Makefile index e5b49571e..9dbd3842d 100644 --- a/Examples/php/pragmas/Makefile +++ b/Examples/php/pragmas/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static diff --git a/Examples/php/proxy/Makefile b/Examples/php/proxy/Makefile index 8b2b340e9..02a8668ac 100644 --- a/Examples/php/proxy/Makefile +++ b/Examples/php/proxy/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static diff --git a/Examples/php/reference/Makefile b/Examples/php/reference/Makefile index 8b2b340e9..02a8668ac 100644 --- a/Examples/php/reference/Makefile +++ b/Examples/php/reference/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static diff --git a/Examples/php/simple/Makefile b/Examples/php/simple/Makefile index f2c15c5c1..05679f844 100644 --- a/Examples/php/simple/Makefile +++ b/Examples/php/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static diff --git a/Examples/php/sync/Makefile b/Examples/php/sync/Makefile index 8b2b340e9..02a8668ac 100644 --- a/Examples/php/sync/Makefile +++ b/Examples/php/sync/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static diff --git a/Examples/php/value/Makefile b/Examples/php/value/Makefile index 3db7afec5..674e4368e 100644 --- a/Examples/php/value/Makefile +++ b/Examples/php/value/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static diff --git a/Examples/php/variables/Makefile b/Examples/php/variables/Makefile index f2c15c5c1..05679f844 100644 --- a/Examples/php/variables/Makefile +++ b/Examples/php/variables/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static diff --git a/Examples/pike/class/Makefile b/Examples/pike/class/Makefile index d8cf4ea7e..e5319dbe2 100644 --- a/Examples/pike/class/Makefile +++ b/Examples/pike/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static clean: diff --git a/Examples/pike/constants/Makefile b/Examples/pike/constants/Makefile index 736d30f03..45da7d269 100644 --- a/Examples/pike/constants/Makefile +++ b/Examples/pike/constants/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static clean: diff --git a/Examples/pike/enum/Makefile b/Examples/pike/enum/Makefile index d8cf4ea7e..e5319dbe2 100644 --- a/Examples/pike/enum/Makefile +++ b/Examples/pike/enum/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static clean: diff --git a/Examples/pike/overload/Makefile b/Examples/pike/overload/Makefile index f111b1137..5e5fe669b 100644 --- a/Examples/pike/overload/Makefile +++ b/Examples/pike/overload/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static clean: diff --git a/Examples/pike/simple/Makefile b/Examples/pike/simple/Makefile index d7f6b209e..8b49b4ea5 100644 --- a/Examples/pike/simple/Makefile +++ b/Examples/pike/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static clean: diff --git a/Examples/pike/template/Makefile b/Examples/pike/template/Makefile index da115c1d5..513dc3b4b 100644 --- a/Examples/pike/template/Makefile +++ b/Examples/pike/template/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static clean: diff --git a/Examples/python/callback/Makefile b/Examples/python/callback/Makefile index a4c4d2a69..71926f397 100644 --- a/Examples/python/callback/Makefile +++ b/Examples/python/callback/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/class/Makefile b/Examples/python/class/Makefile index 41cded284..471e39073 100644 --- a/Examples/python/class/Makefile +++ b/Examples/python/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/constants/Makefile b/Examples/python/constants/Makefile index 8ec6e9cc9..a412cf299 100644 --- a/Examples/python/constants/Makefile +++ b/Examples/python/constants/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: diff --git a/Examples/python/contract/Makefile b/Examples/python/contract/Makefile index fe1d9325e..54817c79d 100644 --- a/Examples/python/contract/Makefile +++ b/Examples/python/contract/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -9,12 +10,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mypython' INTERFACE='$(INTERFACE)' python_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean diff --git a/Examples/python/docstrings/Makefile b/Examples/python/docstrings/Makefile index f471930dd..f1365a599 100644 --- a/Examples/python/docstrings/Makefile +++ b/Examples/python/docstrings/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static diff --git a/Examples/python/enum/Makefile b/Examples/python/enum/Makefile index 41cded284..471e39073 100644 --- a/Examples/python/enum/Makefile +++ b/Examples/python/enum/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/exception/Makefile b/Examples/python/exception/Makefile index ad3d49fe1..8420c8297 100644 --- a/Examples/python/exception/Makefile +++ b/Examples/python/exception/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/exceptproxy/Makefile b/Examples/python/exceptproxy/Makefile index f406dfaf4..65af5ec82 100644 --- a/Examples/python/exceptproxy/Makefile +++ b/Examples/python/exceptproxy/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/extend/Makefile b/Examples/python/extend/Makefile index a4c4d2a69..71926f397 100644 --- a/Examples/python/extend/Makefile +++ b/Examples/python/extend/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/funcptr/Makefile b/Examples/python/funcptr/Makefile index 222916fa1..26bfd946e 100644 --- a/Examples/python/funcptr/Makefile +++ b/Examples/python/funcptr/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: diff --git a/Examples/python/funcptr2/Makefile b/Examples/python/funcptr2/Makefile index 222916fa1..26bfd946e 100644 --- a/Examples/python/funcptr2/Makefile +++ b/Examples/python/funcptr2/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: diff --git a/Examples/python/functor/Makefile b/Examples/python/functor/Makefile index 1234c310e..e5de5c5b7 100644 --- a/Examples/python/functor/Makefile +++ b/Examples/python/functor/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/import/Makefile b/Examples/python/import/Makefile index d83dfeaa8..ad208b3e7 100644 --- a/Examples/python/import/Makefile +++ b/Examples/python/import/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = @@ -7,14 +8,18 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp clean: diff --git a/Examples/python/import_packages/from_init1/py2/pkg2/Makefile b/Examples/python/import_packages/from_init1/py2/pkg2/Makefile index 589b355cc..102a8938b 100644 --- a/Examples/python/import_packages/from_init1/py2/pkg2/Makefile +++ b/Examples/python/import_packages/from_init1/py2/pkg2/Makefile @@ -1,19 +1,24 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp_static clean:: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/from_init1/py3/pkg2/Makefile b/Examples/python/import_packages/from_init1/py3/pkg2/Makefile index 589b355cc..102a8938b 100644 --- a/Examples/python/import_packages/from_init1/py3/pkg2/Makefile +++ b/Examples/python/import_packages/from_init1/py3/pkg2/Makefile @@ -1,19 +1,24 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp_static clean:: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/from_init2/py2/pkg2/Makefile b/Examples/python/import_packages/from_init2/py2/pkg2/Makefile index 9db1bd29c..c1f234e34 100644 --- a/Examples/python/import_packages/from_init2/py2/pkg2/Makefile +++ b/Examples/python/import_packages/from_init2/py2/pkg2/Makefile @@ -1,16 +1,19 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: diff --git a/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile index bf082779a..7a0cb18ad 100644 --- a/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile @@ -1,15 +1,18 @@ TOP = ../../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/from_init2/py3/pkg2/Makefile b/Examples/python/import_packages/from_init2/py3/pkg2/Makefile index 9db1bd29c..c1f234e34 100644 --- a/Examples/python/import_packages/from_init2/py3/pkg2/Makefile +++ b/Examples/python/import_packages/from_init2/py3/pkg2/Makefile @@ -1,16 +1,19 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: diff --git a/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile index bf082779a..7a0cb18ad 100644 --- a/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile @@ -1,15 +1,18 @@ TOP = ../../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/from_init3/py2/pkg2/Makefile b/Examples/python/import_packages/from_init3/py2/pkg2/Makefile index 9db1bd29c..c1f234e34 100644 --- a/Examples/python/import_packages/from_init3/py2/pkg2/Makefile +++ b/Examples/python/import_packages/from_init3/py2/pkg2/Makefile @@ -1,16 +1,19 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: diff --git a/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile b/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile index 54153391d..a870607e2 100644 --- a/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile +++ b/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile @@ -1,15 +1,18 @@ TOP = ../../../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/from_init3/py3/pkg2/Makefile b/Examples/python/import_packages/from_init3/py3/pkg2/Makefile index 9db1bd29c..c1f234e34 100644 --- a/Examples/python/import_packages/from_init3/py3/pkg2/Makefile +++ b/Examples/python/import_packages/from_init3/py3/pkg2/Makefile @@ -1,16 +1,19 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: diff --git a/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile b/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile index 54153391d..a870607e2 100644 --- a/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile +++ b/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile @@ -1,15 +1,18 @@ TOP = ../../../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile b/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile index 9db1bd29c..c1f234e34 100644 --- a/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile +++ b/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile @@ -1,16 +1,19 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: diff --git a/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile index bf082779a..7a0cb18ad 100644 --- a/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile @@ -1,15 +1,18 @@ TOP = ../../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile b/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile index 9db1bd29c..c1f234e34 100644 --- a/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile +++ b/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile @@ -1,16 +1,19 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: diff --git a/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile index bf082779a..7a0cb18ad 100644 --- a/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile @@ -1,15 +1,18 @@ TOP = ../../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile b/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile index 9db1bd29c..c1f234e34 100644 --- a/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile +++ b/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile @@ -1,16 +1,19 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: diff --git a/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile b/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile index 54153391d..a870607e2 100644 --- a/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile +++ b/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile @@ -1,15 +1,18 @@ TOP = ../../../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile b/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile index 9db1bd29c..c1f234e34 100644 --- a/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile +++ b/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile @@ -1,16 +1,19 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: diff --git a/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile b/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile index 54153391d..a870607e2 100644 --- a/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile +++ b/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile @@ -1,15 +1,18 @@ TOP = ../../../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/relativeimport3/py2/pkg2/Makefile b/Examples/python/import_packages/relativeimport3/py2/pkg2/Makefile index 9db1bd29c..c1f234e34 100644 --- a/Examples/python/import_packages/relativeimport3/py2/pkg2/Makefile +++ b/Examples/python/import_packages/relativeimport3/py2/pkg2/Makefile @@ -1,16 +1,19 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: diff --git a/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/Makefile index bf082779a..7a0cb18ad 100644 --- a/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/Makefile @@ -1,15 +1,18 @@ TOP = ../../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/relativeimport3/py3/pkg2/Makefile b/Examples/python/import_packages/relativeimport3/py3/pkg2/Makefile index 9db1bd29c..c1f234e34 100644 --- a/Examples/python/import_packages/relativeimport3/py3/pkg2/Makefile +++ b/Examples/python/import_packages/relativeimport3/py3/pkg2/Makefile @@ -1,16 +1,19 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp cd pkg3 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static clean: diff --git a/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/Makefile index bf082779a..7a0cb18ad 100644 --- a/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/Makefile +++ b/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/Makefile @@ -1,15 +1,18 @@ TOP = ../../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/same_modnames1/pkg1/Makefile b/Examples/python/import_packages/same_modnames1/pkg1/Makefile index 18924cea7..3ca7fab03 100644 --- a/Examples/python/import_packages/same_modnames1/pkg1/Makefile +++ b/Examples/python/import_packages/same_modnames1/pkg1/Makefile @@ -1,15 +1,18 @@ TOP = ../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/same_modnames1/pkg2/Makefile b/Examples/python/import_packages/same_modnames1/pkg2/Makefile index 18924cea7..3ca7fab03 100644 --- a/Examples/python/import_packages/same_modnames1/pkg2/Makefile +++ b/Examples/python/import_packages/same_modnames1/pkg2/Makefile @@ -1,15 +1,18 @@ TOP = ../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/same_modnames2/pkg1/Makefile b/Examples/python/import_packages/same_modnames2/pkg1/Makefile index 18924cea7..3ca7fab03 100644 --- a/Examples/python/import_packages/same_modnames2/pkg1/Makefile +++ b/Examples/python/import_packages/same_modnames2/pkg1/Makefile @@ -1,15 +1,18 @@ TOP = ../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile b/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile index f23883eaf..921bb9951 100644 --- a/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile +++ b/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile @@ -1,15 +1,18 @@ TOP = ../../../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_template/Makefile b/Examples/python/import_template/Makefile index d83dfeaa8..ad208b3e7 100644 --- a/Examples/python/import_template/Makefile +++ b/Examples/python/import_template/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = @@ -7,14 +8,18 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp clean: diff --git a/Examples/python/java/Makefile b/Examples/python/java/Makefile index 4befa38ba..7c75e6b91 100644 --- a/Examples/python/java/Makefile +++ b/Examples/python/java/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: Example.class Example.h - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ CXXSHARED="gcj -fpic -shared Example.class" DEFS='' LIBS="-lstdc++" python_cpp diff --git a/Examples/python/libffi/Makefile b/Examples/python/libffi/Makefile index db5dfe138..0875fdd96 100644 --- a/Examples/python/libffi/Makefile +++ b/Examples/python/libffi/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-L/usr/local/lib -lffi' python static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: diff --git a/Examples/python/multimap/Makefile b/Examples/python/multimap/Makefile index 222916fa1..26bfd946e 100644 --- a/Examples/python/multimap/Makefile +++ b/Examples/python/multimap/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: diff --git a/Examples/python/operator/Makefile b/Examples/python/operator/Makefile index 1234c310e..e5de5c5b7 100644 --- a/Examples/python/operator/Makefile +++ b/Examples/python/operator/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/performance/constructor/Makefile b/Examples/python/performance/constructor/Makefile index 8e65123cf..cbc11543f 100644 --- a/Examples/python/performance/constructor/Makefile +++ b/Examples/python/performance/constructor/Makefile @@ -1,19 +1,24 @@ TOP = ../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ - TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ - TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ - TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-module Simple_baseline' TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-O -module Simple_optimized' TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-builtin -O -module Simple_builtin' TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/performance/func/Makefile b/Examples/python/performance/func/Makefile index 8e65123cf..cbc11543f 100644 --- a/Examples/python/performance/func/Makefile +++ b/Examples/python/performance/func/Makefile @@ -1,19 +1,24 @@ TOP = ../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ - TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ - TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ - TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-module Simple_baseline' TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-O -module Simple_optimized' TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-builtin -O -module Simple_builtin' TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/performance/hierarchy/Makefile b/Examples/python/performance/hierarchy/Makefile index 8e65123cf..cbc11543f 100644 --- a/Examples/python/performance/hierarchy/Makefile +++ b/Examples/python/performance/hierarchy/Makefile @@ -1,19 +1,24 @@ TOP = ../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ - TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ - TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ - TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-module Simple_baseline' TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-O -module Simple_optimized' TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-builtin -O -module Simple_builtin' TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/performance/hierarchy_operator/Makefile b/Examples/python/performance/hierarchy_operator/Makefile index 8e65123cf..cbc11543f 100644 --- a/Examples/python/performance/hierarchy_operator/Makefile +++ b/Examples/python/performance/hierarchy_operator/Makefile @@ -1,19 +1,24 @@ TOP = ../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ - TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ - TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ - TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-module Simple_baseline' TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-O -module Simple_optimized' TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-builtin -O -module Simple_builtin' TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/performance/operator/Makefile b/Examples/python/performance/operator/Makefile index 8e65123cf..cbc11543f 100644 --- a/Examples/python/performance/operator/Makefile +++ b/Examples/python/performance/operator/Makefile @@ -1,19 +1,24 @@ TOP = ../../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = Simple INTERFACE = Simple.i build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ - TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ - TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ - TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-module Simple_baseline' TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-O -module Simple_optimized' TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='-builtin -O -module Simple_builtin' TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/pointer/Makefile b/Examples/python/pointer/Makefile index 222916fa1..26bfd946e 100644 --- a/Examples/python/pointer/Makefile +++ b/Examples/python/pointer/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: diff --git a/Examples/python/reference/Makefile b/Examples/python/reference/Makefile index 41cded284..471e39073 100644 --- a/Examples/python/reference/Makefile +++ b/Examples/python/reference/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/simple/Makefile b/Examples/python/simple/Makefile index 222916fa1..26bfd946e 100644 --- a/Examples/python/simple/Makefile +++ b/Examples/python/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: diff --git a/Examples/python/smartptr/Makefile b/Examples/python/smartptr/Makefile index 19609353d..34edcfc40 100644 --- a/Examples/python/smartptr/Makefile +++ b/Examples/python/smartptr/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/std_map/Makefile b/Examples/python/std_map/Makefile index f406dfaf4..65af5ec82 100644 --- a/Examples/python/std_map/Makefile +++ b/Examples/python/std_map/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/std_vector/Makefile b/Examples/python/std_vector/Makefile index f406dfaf4..65af5ec82 100644 --- a/Examples/python/std_vector/Makefile +++ b/Examples/python/std_vector/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/template/Makefile b/Examples/python/template/Makefile index f406dfaf4..65af5ec82 100644 --- a/Examples/python/template/Makefile +++ b/Examples/python/template/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static clean: diff --git a/Examples/python/varargs/Makefile b/Examples/python/varargs/Makefile index 8ec6e9cc9..a412cf299 100644 --- a/Examples/python/varargs/Makefile +++ b/Examples/python/varargs/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: diff --git a/Examples/python/variables/Makefile b/Examples/python/variables/Makefile index 222916fa1..26bfd946e 100644 --- a/Examples/python/variables/Makefile +++ b/Examples/python/variables/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean: diff --git a/Examples/r/class/Makefile b/Examples/r/class/Makefile index 3e5d6a6ca..6b4b306f3 100644 --- a/Examples/r/class/Makefile +++ b/Examples/r/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' r_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r_cpp clean: diff --git a/Examples/r/simple/Makefile b/Examples/r/simple/Makefile index 5cc41530c..add881898 100644 --- a/Examples/r/simple/Makefile +++ b/Examples/r/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' r_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r clean: diff --git a/Examples/ruby/class/Makefile b/Examples/ruby/class/Makefile index 516f842d7..0d469c655 100644 --- a/Examples/ruby/class/Makefile +++ b/Examples/ruby/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: diff --git a/Examples/ruby/constants/Makefile b/Examples/ruby/constants/Makefile index 561d5fd84..24698f2b4 100644 --- a/Examples/ruby/constants/Makefile +++ b/Examples/ruby/constants/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: diff --git a/Examples/ruby/enum/Makefile b/Examples/ruby/enum/Makefile index 516f842d7..0d469c655 100644 --- a/Examples/ruby/enum/Makefile +++ b/Examples/ruby/enum/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: diff --git a/Examples/ruby/exception_class/Makefile b/Examples/ruby/exception_class/Makefile index 6723a2a7c..2d4518e11 100644 --- a/Examples/ruby/exception_class/Makefile +++ b/Examples/ruby/exception_class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: diff --git a/Examples/ruby/free_function/Makefile b/Examples/ruby/free_function/Makefile index 516f842d7..0d469c655 100644 --- a/Examples/ruby/free_function/Makefile +++ b/Examples/ruby/free_function/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: diff --git a/Examples/ruby/funcptr/Makefile b/Examples/ruby/funcptr/Makefile index 15b39cf0d..d320c9a83 100644 --- a/Examples/ruby/funcptr/Makefile +++ b/Examples/ruby/funcptr/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: diff --git a/Examples/ruby/funcptr2/Makefile b/Examples/ruby/funcptr2/Makefile index 15b39cf0d..d320c9a83 100644 --- a/Examples/ruby/funcptr2/Makefile +++ b/Examples/ruby/funcptr2/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: diff --git a/Examples/ruby/functor/Makefile b/Examples/ruby/functor/Makefile index 348bd66e3..c7f998c14 100644 --- a/Examples/ruby/functor/Makefile +++ b/Examples/ruby/functor/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib TARGET = example INTERFACE = example.i LIBS = -lm @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: diff --git a/Examples/ruby/hashargs/Makefile b/Examples/ruby/hashargs/Makefile index 59a36c0dd..2d0d943e1 100644 --- a/Examples/ruby/hashargs/Makefile +++ b/Examples/ruby/hashargs/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: diff --git a/Examples/ruby/import/Makefile b/Examples/ruby/import/Makefile index b5d06bdd7..586e48870 100644 --- a/Examples/ruby/import/Makefile +++ b/Examples/ruby/import/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = @@ -7,14 +8,18 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' ruby_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' ruby_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' ruby_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' ruby_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean diff --git a/Examples/ruby/import_template/Makefile b/Examples/ruby/import_template/Makefile index b5d06bdd7..586e48870 100644 --- a/Examples/ruby/import_template/Makefile +++ b/Examples/ruby/import_template/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = @@ -7,14 +8,18 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' ruby_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' ruby_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' ruby_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' ruby_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean diff --git a/Examples/ruby/java/Makefile b/Examples/ruby/java/Makefile index 7d611abd2..bec5e1844 100644 --- a/Examples/ruby/java/Makefile +++ b/Examples/ruby/java/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: Example.class Example.h - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ CXXSHARED="gcj -fpic -shared Example.class" LIBS="-lstdc++" DEFS='' ruby_cpp diff --git a/Examples/ruby/mark_function/Makefile b/Examples/ruby/mark_function/Makefile index 516f842d7..0d469c655 100644 --- a/Examples/ruby/mark_function/Makefile +++ b/Examples/ruby/mark_function/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: diff --git a/Examples/ruby/multimap/Makefile b/Examples/ruby/multimap/Makefile index 15b39cf0d..d320c9a83 100644 --- a/Examples/ruby/multimap/Makefile +++ b/Examples/ruby/multimap/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: diff --git a/Examples/ruby/operator/Makefile b/Examples/ruby/operator/Makefile index bdcf52646..53241eead 100644 --- a/Examples/ruby/operator/Makefile +++ b/Examples/ruby/operator/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: diff --git a/Examples/ruby/overloading/Makefile b/Examples/ruby/overloading/Makefile index 516f842d7..0d469c655 100644 --- a/Examples/ruby/overloading/Makefile +++ b/Examples/ruby/overloading/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: diff --git a/Examples/ruby/pointer/Makefile b/Examples/ruby/pointer/Makefile index 15b39cf0d..d320c9a83 100644 --- a/Examples/ruby/pointer/Makefile +++ b/Examples/ruby/pointer/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: diff --git a/Examples/ruby/reference/Makefile b/Examples/ruby/reference/Makefile index 516f842d7..0d469c655 100644 --- a/Examples/ruby/reference/Makefile +++ b/Examples/ruby/reference/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: diff --git a/Examples/ruby/simple/Makefile b/Examples/ruby/simple/Makefile index 15b39cf0d..d320c9a83 100644 --- a/Examples/ruby/simple/Makefile +++ b/Examples/ruby/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: diff --git a/Examples/ruby/std_vector/Makefile b/Examples/ruby/std_vector/Makefile index 370bd8fb6..636a0f19f 100644 --- a/Examples/ruby/std_vector/Makefile +++ b/Examples/ruby/std_vector/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: diff --git a/Examples/ruby/template/Makefile b/Examples/ruby/template/Makefile index 370bd8fb6..636a0f19f 100644 --- a/Examples/ruby/template/Makefile +++ b/Examples/ruby/template/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static clean: diff --git a/Examples/ruby/value/Makefile b/Examples/ruby/value/Makefile index 15b39cf0d..d320c9a83 100644 --- a/Examples/ruby/value/Makefile +++ b/Examples/ruby/value/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: diff --git a/Examples/ruby/variables/Makefile b/Examples/ruby/variables/Makefile index 15b39cf0d..d320c9a83 100644 --- a/Examples/ruby/variables/Makefile +++ b/Examples/ruby/variables/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,11 +9,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean: diff --git a/Examples/s-exp/uffi.lisp b/Examples/s-exp/uffi.lisp index 253f85aba..aea9a1405 100644 --- a/Examples/s-exp/uffi.lisp +++ b/Examples/s-exp/uffi.lisp @@ -15,7 +15,7 @@ (defvar *swig-source-directory* #p"/home/mkoeppe/s/swig1.3/") -(defvar *swig-program* (merge-pathnames "preinst-swig" *swig-source-directory*)) +(defvar *swig-program* (merge-pathnames "swig" *swig-source-directory*)) (defun run-swig (swig-interface-file-name &key directory-search-list module ignore-errors c++) diff --git a/Examples/scilab/class/Makefile b/Examples/scilab/class/Makefile index b0545d804..40c97a5f7 100644 --- a/Examples/scilab/class/Makefile +++ b/Examples/scilab/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp clean: diff --git a/Examples/scilab/constants/Makefile b/Examples/scilab/constants/Makefile index 56e51e6f5..d47674b37 100644 --- a/Examples/scilab/constants/Makefile +++ b/Examples/scilab/constants/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab clean: diff --git a/Examples/scilab/contract/Makefile b/Examples/scilab/contract/Makefile index 208a88bfe..6604d191b 100644 --- a/Examples/scilab/contract/Makefile +++ b/Examples/scilab/contract/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab clean: diff --git a/Examples/scilab/enum/Makefile b/Examples/scilab/enum/Makefile index b0545d804..40c97a5f7 100644 --- a/Examples/scilab/enum/Makefile +++ b/Examples/scilab/enum/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp clean: diff --git a/Examples/scilab/funcptr/Makefile b/Examples/scilab/funcptr/Makefile index 208a88bfe..6604d191b 100644 --- a/Examples/scilab/funcptr/Makefile +++ b/Examples/scilab/funcptr/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab clean: diff --git a/Examples/scilab/matrix/Makefile b/Examples/scilab/matrix/Makefile index 208a88bfe..6604d191b 100644 --- a/Examples/scilab/matrix/Makefile +++ b/Examples/scilab/matrix/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab clean: diff --git a/Examples/scilab/matrix2/Makefile b/Examples/scilab/matrix2/Makefile index 208a88bfe..6604d191b 100644 --- a/Examples/scilab/matrix2/Makefile +++ b/Examples/scilab/matrix2/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab clean: diff --git a/Examples/scilab/pointer/Makefile b/Examples/scilab/pointer/Makefile index 92308c312..9ce2685bf 100644 --- a/Examples/scilab/pointer/Makefile +++ b/Examples/scilab/pointer/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab clean: diff --git a/Examples/scilab/simple/Makefile b/Examples/scilab/simple/Makefile index 208a88bfe..6604d191b 100644 --- a/Examples/scilab/simple/Makefile +++ b/Examples/scilab/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab clean: diff --git a/Examples/scilab/std_list/Makefile b/Examples/scilab/std_list/Makefile index b0545d804..40c97a5f7 100644 --- a/Examples/scilab/std_list/Makefile +++ b/Examples/scilab/std_list/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp clean: diff --git a/Examples/scilab/std_vector/Makefile b/Examples/scilab/std_vector/Makefile index f73144d78..490ac73b5 100644 --- a/Examples/scilab/std_vector/Makefile +++ b/Examples/scilab/std_vector/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp clean: diff --git a/Examples/scilab/struct/Makefile b/Examples/scilab/struct/Makefile index 7a030a33c..9f8b7e891 100644 --- a/Examples/scilab/struct/Makefile +++ b/Examples/scilab/struct/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab clean: diff --git a/Examples/scilab/template/Makefile b/Examples/scilab/template/Makefile index f73144d78..490ac73b5 100644 --- a/Examples/scilab/template/Makefile +++ b/Examples/scilab/template/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp clean: diff --git a/Examples/scilab/variables/Makefile b/Examples/scilab/variables/Makefile index 208a88bfe..6604d191b 100644 --- a/Examples/scilab/variables/Makefile +++ b/Examples/scilab/variables/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i @@ -8,7 +9,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab clean: diff --git a/Examples/tcl/class/Makefile b/Examples/tcl/class/Makefile index aacf30e04..3fd77cff5 100644 --- a/Examples/tcl/class/Makefile +++ b/Examples/tcl/class/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: diff --git a/Examples/tcl/constants/Makefile b/Examples/tcl/constants/Makefile index 17c8afa3f..67f6567a8 100644 --- a/Examples/tcl/constants/Makefile +++ b/Examples/tcl/constants/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = my_tclsh DLTARGET = example @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: diff --git a/Examples/tcl/contract/Makefile b/Examples/tcl/contract/Makefile index 01fdc37b3..bab90552b 100644 --- a/Examples/tcl/contract/Makefile +++ b/Examples/tcl/contract/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = my_tclsh DLTARGET = example @@ -10,12 +11,14 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean diff --git a/Examples/tcl/enum/Makefile b/Examples/tcl/enum/Makefile index aacf30e04..3fd77cff5 100644 --- a/Examples/tcl/enum/Makefile +++ b/Examples/tcl/enum/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: diff --git a/Examples/tcl/funcptr/Makefile b/Examples/tcl/funcptr/Makefile index 7155bf3c3..8765f7ef9 100644 --- a/Examples/tcl/funcptr/Makefile +++ b/Examples/tcl/funcptr/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = my_tclsh DLTARGET = example @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: diff --git a/Examples/tcl/import/Makefile b/Examples/tcl/import/Makefile index 6aa48e7a8..64ef0cdd1 100644 --- a/Examples/tcl/import/Makefile +++ b/Examples/tcl/import/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = LIBS = @@ -7,14 +8,18 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' tcl_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' tcl_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' tcl_cpp - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ - LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' tcl_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' tcl_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' tcl_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' tcl_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' tcl_cpp clean: diff --git a/Examples/tcl/java/Makefile b/Examples/tcl/java/Makefile index 4be3764e2..e4dfc536b 100644 --- a/Examples/tcl/java/Makefile +++ b/Examples/tcl/java/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -9,7 +10,8 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: Example.class Example.h - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ TCLCXXSHARED="gcj -fpic -shared Example.class " LIBS="-lstdc++" DEFS='' tcl_cpp diff --git a/Examples/tcl/multimap/Makefile b/Examples/tcl/multimap/Makefile index 7155bf3c3..8765f7ef9 100644 --- a/Examples/tcl/multimap/Makefile +++ b/Examples/tcl/multimap/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = my_tclsh DLTARGET = example @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: diff --git a/Examples/tcl/operator/Makefile b/Examples/tcl/operator/Makefile index 1c6e1be98..73dca485a 100644 --- a/Examples/tcl/operator/Makefile +++ b/Examples/tcl/operator/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: diff --git a/Examples/tcl/pointer/Makefile b/Examples/tcl/pointer/Makefile index 7155bf3c3..8765f7ef9 100644 --- a/Examples/tcl/pointer/Makefile +++ b/Examples/tcl/pointer/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = my_tclsh DLTARGET = example @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: diff --git a/Examples/tcl/reference/Makefile b/Examples/tcl/reference/Makefile index aacf30e04..3fd77cff5 100644 --- a/Examples/tcl/reference/Makefile +++ b/Examples/tcl/reference/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = example.cxx TARGET = example INTERFACE = example.i @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: diff --git a/Examples/tcl/simple/Makefile b/Examples/tcl/simple/Makefile index 7155bf3c3..8765f7ef9 100644 --- a/Examples/tcl/simple/Makefile +++ b/Examples/tcl/simple/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = my_tclsh DLTARGET = example @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: diff --git a/Examples/tcl/std_vector/Makefile b/Examples/tcl/std_vector/Makefile index f29f933ba..3ed97f27c 100644 --- a/Examples/tcl/std_vector/Makefile +++ b/Examples/tcl/std_vector/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib CXXSRCS = TARGET = my_tclsh DLTARGET = example @@ -10,11 +11,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl_cpp static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh_cpp_static clean: diff --git a/Examples/tcl/value/Makefile b/Examples/tcl/value/Makefile index 7155bf3c3..8765f7ef9 100644 --- a/Examples/tcl/value/Makefile +++ b/Examples/tcl/value/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = my_tclsh DLTARGET = example @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: diff --git a/Examples/tcl/variables/Makefile b/Examples/tcl/variables/Makefile index 7155bf3c3..8765f7ef9 100644 --- a/Examples/tcl/variables/Makefile +++ b/Examples/tcl/variables/Makefile @@ -1,5 +1,6 @@ TOP = ../.. -SWIG = $(TOP)/../preinst-swig +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = my_tclsh DLTARGET = example @@ -9,11 +10,13 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh clean: diff --git a/Makefile.in b/Makefile.in index e8e08a994..85b965051 100644 --- a/Makefile.in +++ b/Makefile.in @@ -101,10 +101,6 @@ skip-errors = test -n "" ACTION = check NOSKIP = -chk-set-swiglib = SWIG_LIB=@ROOT_DIR@/$(srcdir)/Lib -chk-set-swig = SWIG=@ROOT_DIR@/$(TARGET) -chk-set-env = $(chk-set-swiglib) $(chk-set-swig) - check-aliveness: test -x ./$(TARGET) ./$(TARGET) -version @@ -250,7 +246,7 @@ check-%-examples : %.actionexample: @cd Examples && $(MAKE) Makefile @echo $(ACTION)ing Examples/$(LANGUAGE)/$* - @(cd Examples/$(LANGUAGE)/$* && $(MAKE) $(FLAGS) $(chk-set-env) $(ACTION) RUNPIPE=$(RUNPIPE)) + @(cd Examples/$(LANGUAGE)/$* && $(MAKE) $(FLAGS) $(ACTION) RUNPIPE=$(RUNPIPE)) # gcj individual example java.actionexample: @@ -259,7 +255,7 @@ java.actionexample: echo "skipping Examples/$(LANGUAGE)/java $(ACTION) (gcj test)"; \ else \ echo $(ACTION)ing Examples/$(LANGUAGE)/java; \ - (cd Examples/$(LANGUAGE)/java && $(MAKE) $(FLAGS) $(chk-set-env) $(ACTION) RUNPIPE=$(RUNPIPE)) \ + (cd Examples/$(LANGUAGE)/java && $(MAKE) $(FLAGS) $(ACTION) RUNPIPE=$(RUNPIPE)) \ fi # Checks testcases in the test-suite excluding those which are known to be broken From 7192b1c7356f199b4913becbb4ef7bab8b2963fc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Aug 2015 07:34:02 +0100 Subject: [PATCH 083/732] Remove SWIG_LIB variable from Makefile --- Makefile.in | 12 ++++++------ configure.ac | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile.in b/Makefile.in index 85b965051..5be06bbc1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -21,7 +21,7 @@ FLAGS = -k -s ##################################################################### SHELL = /bin/sh -SWIG_LIB = @swig_lib@ +SWIG_LIB_INSTALL = @SWIG_LIB_INSTALL@ BIN_DIR = @bindir@ ENABLE_CCACHE = @ENABLE_CCACHE@ TARGET_NOEXE= swig @@ -508,16 +508,16 @@ lib-modules = std install-lib: @echo "Installing the SWIG library" - @$(MKINSTDIRS) $(DESTDIR)$(SWIG_LIB) + @$(MKINSTDIRS) $(DESTDIR)$(SWIG_LIB_INSTALL) @for file in $(srcdir)/Lib/*.i $(srcdir)/Lib/*.swg ; do \ i=`basename $$file` ; \ - echo "Installing $(DESTDIR)$(SWIG_LIB)/$$i"; \ - $(INSTALL_DATA) $$file $(DESTDIR)$(SWIG_LIB)/$$i; \ + echo "Installing $(DESTDIR)$(SWIG_LIB_INSTALL)/$$i"; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(SWIG_LIB_INSTALL)/$$i; \ done; @for lang in $(lib-languages) $(lib-modules); \ do \ echo "Installing language specific files for $$lang"; \ - dst=$(DESTDIR)$(SWIG_LIB)/$$lang; \ + dst=$(DESTDIR)$(SWIG_LIB_INSTALL)/$$lang; \ $(MKINSTDIRS) $$dst; \ (doti="`cd $(srcdir)/Lib/$$lang && ls *.i 2>/dev/null || echo ''`"; \ dotswg="`cd $(srcdir)/Lib/$$lang && ls *.swg 2>/dev/null || echo ''`"; \ @@ -552,7 +552,7 @@ uninstall-main: uninstall-lib: @echo "Uninstalling the SWIG library" - rm -rf $(DESTDIR)$(SWIG_LIB)/ + rm -rf $(DESTDIR)$(SWIG_LIB_INSTALL)/ uninstall-ccache: test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) uninstall) diff --git a/configure.ac b/configure.ac index e01e75170..b07463b86 100644 --- a/configure.ac +++ b/configure.ac @@ -2912,7 +2912,8 @@ AC_SUBST(ac_aux_dir) AC_ARG_WITH(swiglibdir,[ --with-swiglibdir=DIR Put SWIG system-independent libraries into DIR.], [swig_lib="$withval"], [swig_lib="${datadir}/swig/${PACKAGE_VERSION}"]) -AC_SUBST(swig_lib) +SWIG_LIB_INSTALL=${swig_lib} +AC_SUBST(SWIG_LIB_INSTALL) AC_DEFINE_DIR(SWIG_LIB, swig_lib, [Directory for SWIG system-independent libraries]) case $build in From 7f5a32195a0a897bf60f8bfa706b6719a7ac06c3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Aug 2015 08:15:00 +0100 Subject: [PATCH 084/732] XML examples out of source support Examples still don't work though! --- Examples/xml/Makefile.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Examples/xml/Makefile.in b/Examples/xml/Makefile.in index 27c86e3e9..2b6fecb7b 100644 --- a/Examples/xml/Makefile.in +++ b/Examples/xml/Makefile.in @@ -1,6 +1,8 @@ # Examples/xml/Makefile +srcdir = @srcdir@ top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ cleanup = tail +2 \ | sed -e 's/ident="ID[0-9A-F]*"//g' \ @@ -19,14 +21,12 @@ all-dot-i-files = \ example_xml.i \ gnarly.i -chk-swiglib = $(top_srcdir)/Lib - check: for f in $(all-dot-i-files) ; do \ base=`basename $$f .i` ; \ xml=$$base.xml ; \ - SWIG_LIB=$(chk-swiglib) $(top_srcdir)/swig -xml $$xml $$f ; \ - cat $$xml | $(cleanup) | diff -c $$base.expected-xml - ; \ + SWIG_LIB=$(top_srcdir)/Lib $(top_builddir)/swig -xml $$xml ${srcdir}/$$f ; \ + cat $$xml | $(cleanup) | diff -c ${srcdir}/$$base.expected-xml - ; \ done clean: @@ -38,7 +38,7 @@ distclean: clean # from here on, non-developers beware! %.expected-xml : %.i - SWIG_LIB=$(top_srcdir)/Lib $(top_srcdir)/swig -xml tmp-file $^ + SWIG_LIB=$(top_srcdir)/Lib $(top_builddir)/swig -xml tmp-file $^ cat tmp-file | $(cleanup) > $@ rm -f tmp-file From e00a8026a65889716ba85f26b641d79b71b44dbe Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Aug 2015 23:05:43 +0100 Subject: [PATCH 085/732] More remove SWIG_LIB variable --- Examples/Makefile.in | 7 +++++++ Examples/modula3/enum/Makefile | 2 +- Examples/mzscheme/std_vector/Makefile | 2 +- Examples/test-suite/common.mk | 4 ++-- Examples/test-suite/errors/Makefile.in | 7 +++++-- Examples/test-suite/go/Makefile.in | 16 ++++++++-------- Examples/test-suite/javascript/Makefile.in | 19 ++++++++++++------- Examples/xml/Makefile.in | 9 +++++++-- 8 files changed, 43 insertions(+), 23 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 7ac312e58..15e2e7ff1 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -139,6 +139,13 @@ distclean: rm -f d/example.mk rm -f xml/Makefile +################################################################## +# Very generic invocation of swig +################################################################## + +swiginvoke: + $(SWIG) $(SWIGOPT) + ################################################################## ##### Tcl/Tk ###### ################################################################## diff --git a/Examples/modula3/enum/Makefile b/Examples/modula3/enum/Makefile index ea56fae46..2c5c9b0a5 100644 --- a/Examples/modula3/enum/Makefile +++ b/Examples/modula3/enum/Makefile @@ -12,7 +12,7 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run build: - $(SWIG) -modula3 $(SWIGOPT) -module Example -generateconst $(CONSTNUMERIC) $(TARGET).h + $(SWIGEXE) -modula3 $(SWIGOPT) -module Example -generateconst $(CONSTNUMERIC) $(TARGET).h $(CXX) -Wall $(CONSTNUMERIC).c -o $(CONSTNUMERIC) $(CONSTNUMERIC) >$(CONSTNUMERIC).i diff --git a/Examples/mzscheme/std_vector/Makefile b/Examples/mzscheme/std_vector/Makefile index 74474aea1..96f5e80cf 100644 --- a/Examples/mzscheme/std_vector/Makefile +++ b/Examples/mzscheme/std_vector/Makefile @@ -13,7 +13,7 @@ check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run build: - $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACE) + $(SWIGEXE) -mzscheme -c++ $(SWIGOPT) $(INTERFACE) $(MZC) --compiler $(GPP) ++ccf "-I." --cc example_wrap.cxx $(MZC) --linker $(GPP) --ld $(TARGET).so example_wrap.o diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index c4e9138d6..123a7967d 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -723,8 +723,8 @@ swig_and_compile_c = \ swig_and_compile_multi_cpp = \ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" LIBS='$(LIBS)' \ - INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ + LIBS='$(LIBS)' INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done diff --git a/Examples/test-suite/errors/Makefile.in b/Examples/test-suite/errors/Makefile.in index b5d01a0eb..4a98f979f 100644 --- a/Examples/test-suite/errors/Makefile.in +++ b/Examples/test-suite/errors/Makefile.in @@ -20,6 +20,9 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ +SWIG_LIB_SET = @SWIG_LIB_SET@ +SWIGINVOKE = $(SWIG_LIB_SET) $(SWIGTOOL) $(SWIGEXE) + # All .i files with prefix 'cpp_' will be treated as C++ input and remaining .i files as C input ALL_ERROR_TEST_CASES := $(patsubst %.i,%, $(notdir $(wildcard $(srcdir)/*.i))) CPP_ERROR_TEST_CASES := $(filter cpp_%, $(ALL_ERROR_TEST_CASES)) @@ -40,12 +43,12 @@ STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||' # Rules for the different types of tests %.cpptest: echo "$(ACTION)ing errors testcase $*" - -$(SWIG) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT) + -$(SWIGINVOKE) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT) $(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT) %.ctest: echo "$(ACTION)ing errors testcase $*" - -$(SWIG) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT) + -$(SWIGINVOKE) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT) $(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT) %.clean: diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in index 63c18f2f4..6613e63c3 100644 --- a/Examples/test-suite/go/Makefile.in +++ b/Examples/test-suite/go/Makefile.in @@ -47,7 +47,7 @@ INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) $(run_testcase_cpp) if ! $(GO15); then \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp_nocgo; \ @@ -60,7 +60,7 @@ INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) $(run_testcase) if ! $(GO15); then \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CSRCS="$(CSRCS)" \ - SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_nocgo; \ @@ -80,8 +80,8 @@ multi_import.multicpptest: $(setup) for f in multi_import_b multi_import_a; do \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ - INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ + LIBS='$(LIBS)' INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done @@ -92,16 +92,16 @@ go_subdir_import.multicpptest: mkdir -p testdir/go_subdir_import/ mkdir -p gopath/src/testdir/go_subdir_import/ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ - INTERFACEPATH="$(SRCDIR)$(INTERFACEDIR)go_subdir_import_b.i" \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ + LIBS='$(LIBS)' INTERFACEPATH="$(SRCDIR)$(INTERFACEDIR)go_subdir_import_b.i" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) -outdir ." NOLINK=true \ TARGET="$(TARGETPREFIX)go_subdir_import_b$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" \ INTERFACE="testdir/go_subdir_import/go_subdir_import_b.i" \ $(LANGUAGE)$(VARIANT)_cpp; for f in testdir/go_subdir_import/go_subdir_import_c go_subdir_import_a ; do \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ - INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ + LIBS='$(LIBS)' INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in index 83b15f822..2c2397207 100644 --- a/Examples/test-suite/javascript/Makefile.in +++ b/Examples/test-suite/javascript/Makefile.in @@ -13,7 +13,8 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -SWIG = $(top_builddir)/preinst_swig +SWIGEXE = $(top_builddir)/swig +SWIG_LIB_DIR = $(top_srcdir)/Lib ifneq (, $(ENGINE)) JSENGINE=$(ENGINE) @@ -53,21 +54,25 @@ ifeq (node,$(JSENGINE)) enum_thorough.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" setup_node = \ - test -d $* || mkdir $*; \ + test -d $* || mkdir $* && \ sed -e 's|$$testcase|$*|g; s|$$cflags|$(GYP_CFLAGS)|g; s|$$srcdir|$(srcdir)|g' \ - $(srcdir)/node_template/binding.gyp.in > $*/binding.gyp; \ + $(srcdir)/node_template/binding.gyp.in > $*/binding.gyp && \ sed -e 's|$$testcase|$*|g;' \ $(srcdir)/node_template/index.js.in > $*/index.js # Note: we need to use swig in C parse mode, but make node-gyp believe it is c++ (via file extension) swig_and_compile_c = \ - $(setup_node); \ - $(SWIG) -javascript $(SWIGOPT) -o $*_wrap.cxx $(srcdir)/../$*.i; \ + $(setup_node) && \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ + SWIGOPT='-javascript $(SWIGOPT) -o $*_wrap.cxx $(srcdir)/../$*.i' swiginvoke && \ $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null swig_and_compile_cpp = \ - $(setup_node); \ - $(SWIG) -c++ -javascript $(SWIGOPT) $(srcdir)/../$*.i; \ + $(setup_node) && \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" \ + SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ + SWIGOPT='-c++ -javascript $(SWIGOPT) $(srcdir)/../$*.i' swiginvoke && \ $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null run_testcase = \ diff --git a/Examples/xml/Makefile.in b/Examples/xml/Makefile.in index 2b6fecb7b..44894b8ea 100644 --- a/Examples/xml/Makefile.in +++ b/Examples/xml/Makefile.in @@ -4,6 +4,11 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ +SWIGEXE = $(top_builddir)/swig +SWIG_LIB_DIR = $(top_srcdir)/Lib +SWIG_LIB_SET = @SWIG_LIB_SET@ +SWIGINVOKE = $(SWIG_LIB_SET) $(SWIGTOOL) $(SWIGEXE) + cleanup = tail +2 \ | sed -e 's/ident="ID[0-9A-F]*"//g' \ -e 's,name="/[^"]*/\([^/]*\.swg\)",name="\1",g' @@ -25,7 +30,7 @@ check: for f in $(all-dot-i-files) ; do \ base=`basename $$f .i` ; \ xml=$$base.xml ; \ - SWIG_LIB=$(top_srcdir)/Lib $(top_builddir)/swig -xml $$xml ${srcdir}/$$f ; \ + $(SWIGINVOKE) -xml $$xml ${srcdir}/$$f ; \ cat $$xml | $(cleanup) | diff -c ${srcdir}/$$base.expected-xml - ; \ done @@ -38,7 +43,7 @@ distclean: clean # from here on, non-developers beware! %.expected-xml : %.i - SWIG_LIB=$(top_srcdir)/Lib $(top_builddir)/swig -xml tmp-file $^ + $(SWIGINVOKE) -xml tmp-file $^ cat tmp-file | $(cleanup) > $@ rm -f tmp-file From ca64b0622925d549d49a5349b4177aefbfed263a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Aug 2015 23:15:33 +0100 Subject: [PATCH 086/732] Consistent quoting in Makefile --- Examples/test-suite/cffi/Makefile.in | 2 +- Examples/test-suite/chicken/Makefile.in | 2 +- Examples/test-suite/clisp/Makefile.in | 2 +- Examples/test-suite/common.mk | 38 +++++++++--------- Examples/test-suite/errors/Makefile.in | 2 +- Examples/test-suite/go/Makefile.in | 46 +++++++++++----------- Examples/test-suite/guile/Makefile.in | 2 +- Examples/test-suite/javascript/Makefile.in | 8 ++-- Examples/test-suite/lua/Makefile.in | 2 +- Examples/test-suite/mzscheme/Makefile.in | 2 +- Examples/test-suite/ocaml/Makefile.in | 2 +- Examples/test-suite/octave/Makefile.in | 2 +- Examples/test-suite/perl5/Makefile.in | 2 +- Examples/test-suite/php/Makefile.in | 6 +-- Examples/test-suite/pike/Makefile.in | 2 +- Examples/test-suite/python/Makefile.in | 2 +- Examples/test-suite/r/Makefile.in | 2 +- Examples/test-suite/ruby/Makefile.in | 2 +- Examples/test-suite/tcl/Makefile.in | 2 +- Examples/test-suite/uffi/Makefile.in | 2 +- 20 files changed, 65 insertions(+), 65 deletions(-) diff --git a/Examples/test-suite/cffi/Makefile.in b/Examples/test-suite/cffi/Makefile.in index ee7e3f61e..6eebaa07c 100644 --- a/Examples/test-suite/cffi/Makefile.in +++ b/Examples/test-suite/cffi/Makefile.in @@ -48,4 +48,4 @@ run_testcase = \ @exit 0 clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" cffi_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' cffi_clean diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in index 31ab311bb..b3dccc9c3 100644 --- a/Examples/test-suite/chicken/Makefile.in +++ b/Examples/test-suite/chicken/Makefile.in @@ -97,5 +97,5 @@ run_testcase = \ @exit 0 clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" chicken_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' chicken_clean rm -f *.scm diff --git a/Examples/test-suite/clisp/Makefile.in b/Examples/test-suite/clisp/Makefile.in index 6837ed60b..3d207178f 100644 --- a/Examples/test-suite/clisp/Makefile.in +++ b/Examples/test-suite/clisp/Makefile.in @@ -48,4 +48,4 @@ run_testcase = \ @exit 0 clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" clisp_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' clisp_clean diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 123a7967d..53a27ef9b 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -707,37 +707,37 @@ partialcheck: $(MAKE) check CC=true CXX=true LDSHARED=true CXXSHARED=true RUNTOOL=true COMPILETOOL=true swig_and_compile_cpp = \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ - INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ + TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \ $(LANGUAGE)$(VARIANT)_cpp swig_and_compile_c = \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CSRCS="$(CSRCS)" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ - INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CSRCS='$(CSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ + TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \ $(LANGUAGE)$(VARIANT) swig_and_compile_multi_cpp = \ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ - LIBS='$(LIBS)' INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + LIBS='$(LIBS)' INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR='$(INTERFACEDIR)' INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done swig_and_compile_external = \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ - TARGET="$*_wrap_hdr.h" \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + TARGET='$*_wrap_hdr.h' \ $(LANGUAGE)$(VARIANT)_externalhdr; \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS) $*_external.cxx" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ - INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS) $*_external.cxx' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ + TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \ $(LANGUAGE)$(VARIANT)_cpp swig_and_compile_runtime = \ diff --git a/Examples/test-suite/errors/Makefile.in b/Examples/test-suite/errors/Makefile.in index 4a98f979f..cf7889a1d 100644 --- a/Examples/test-suite/errors/Makefile.in +++ b/Examples/test-suite/errors/Makefile.in @@ -55,5 +55,5 @@ STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||' @exit 0 clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" python_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' python_clean @rm -f *.$(ERROR_EXT) *.py diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in index 6613e63c3..7fb97eb02 100644 --- a/Examples/test-suite/go/Makefile.in +++ b/Examples/test-suite/go/Makefile.in @@ -46,10 +46,10 @@ INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) +$(swig_and_compile_cpp) $(run_testcase_cpp) if ! $(GO15); then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ - INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ + TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \ $(LANGUAGE)$(VARIANT)_cpp_nocgo; \ $(run_testcase_cpp); \ fi @@ -59,10 +59,10 @@ INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) +$(swig_and_compile_c) $(run_testcase) if ! $(GO15); then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CSRCS="$(CSRCS)" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ - INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CSRCS='$(CSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ + TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \ $(LANGUAGE)$(VARIANT)_nocgo; \ $(run_testcase); \ fi @@ -79,10 +79,10 @@ li_windows.cpptest: multi_import.multicpptest: $(setup) for f in multi_import_b multi_import_a; do \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ - LIBS='$(LIBS)' INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + LIBS='$(LIBS)' INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR='$(INTERFACEDIR)' INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done $(run_multi_testcase) @@ -91,18 +91,18 @@ go_subdir_import.multicpptest: $(setup) mkdir -p testdir/go_subdir_import/ mkdir -p gopath/src/testdir/go_subdir_import/ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ - LIBS='$(LIBS)' INTERFACEPATH="$(SRCDIR)$(INTERFACEDIR)go_subdir_import_b.i" \ - INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) -outdir ." NOLINK=true \ - TARGET="$(TARGETPREFIX)go_subdir_import_b$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" \ - INTERFACE="testdir/go_subdir_import/go_subdir_import_b.i" \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + LIBS='$(LIBS)' INTERFACEPATH='$(SRCDIR)$(INTERFACEDIR)go_subdir_import_b.i' \ + INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT) -outdir .' NOLINK=true \ + TARGET='$(TARGETPREFIX)go_subdir_import_b$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' \ + INTERFACE='testdir/go_subdir_import/go_subdir_import_b.i' \ $(LANGUAGE)$(VARIANT)_cpp; for f in testdir/go_subdir_import/go_subdir_import_c go_subdir_import_a ; do \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ - LIBS='$(LIBS)' INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + LIBS='$(LIBS)' INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR='$(INTERFACEDIR)' INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done if $(GOGCC); then \ @@ -164,7 +164,7 @@ run_multi_testcase = \ @rm -rf $*.go $*_gc.c $*_wrap.* $*_runme $*.gox $*.a clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" go_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' go_clean rm -f mod_a.go mod_a.gox mod_b.go mod_b.gox rm -f imports_a.go imports_a.gox imports_b.go imports_b.gox rm -f clientdata_prop_a.go clientdata_prop_a.gox diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in index 9050d76f5..55885fc29 100644 --- a/Examples/test-suite/guile/Makefile.in +++ b/Examples/test-suite/guile/Makefile.in @@ -62,4 +62,4 @@ run_testcase = \ @rm -f $*-guile clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" guile_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' guile_clean diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in index 2c2397207..c68dd22b2 100644 --- a/Examples/test-suite/javascript/Makefile.in +++ b/Examples/test-suite/javascript/Makefile.in @@ -63,15 +63,15 @@ ifeq (node,$(JSENGINE)) # Note: we need to use swig in C parse mode, but make node-gyp believe it is c++ (via file extension) swig_and_compile_c = \ $(setup_node) && \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='-javascript $(SWIGOPT) -o $*_wrap.cxx $(srcdir)/../$*.i' swiginvoke && \ $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null swig_and_compile_cpp = \ $(setup_node) && \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" \ - SWIG_LIB_DIR="$(SWIG_LIB_DIR)" SWIGEXE="$(SWIGEXE)" \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='-c++ -javascript $(SWIGOPT) $(srcdir)/../$*.i' swiginvoke && \ $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null diff --git a/Examples/test-suite/lua/Makefile.in b/Examples/test-suite/lua/Makefile.in index c562f09df..7be59214b 100644 --- a/Examples/test-suite/lua/Makefile.in +++ b/Examples/test-suite/lua/Makefile.in @@ -56,7 +56,7 @@ run_testcase = \ @exit 0 clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" lua_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' lua_clean cvsignore: @echo '*wrap* *.so *.dll *.exp *.lib' diff --git a/Examples/test-suite/mzscheme/Makefile.in b/Examples/test-suite/mzscheme/Makefile.in index da92f76fd..3e15f8610 100644 --- a/Examples/test-suite/mzscheme/Makefile.in +++ b/Examples/test-suite/mzscheme/Makefile.in @@ -46,4 +46,4 @@ run_testcase = \ @exit 0 clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" mzscheme_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 0956fcbc4..ecdf32e9f 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -74,4 +74,4 @@ include $(srcdir)/../common.mk @rm -f $*.ml $*.mli; clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" ocaml_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' ocaml_clean diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index fbffd240c..be47904e2 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -68,7 +68,7 @@ run_testcase = \ @rm -f $*.m; clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" octave_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' octave_clean cvsignore: @echo '*wrap* *.mc *.so *.dll *.exp *.lib' diff --git a/Examples/test-suite/perl5/Makefile.in b/Examples/test-suite/perl5/Makefile.in index ccd12d6e4..539875da8 100644 --- a/Examples/test-suite/perl5/Makefile.in +++ b/Examples/test-suite/perl5/Makefile.in @@ -60,4 +60,4 @@ run_testcase = \ @rm -f $*.pm; clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" perl5_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' perl5_clean diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index c365d01c3..811eade36 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -60,9 +60,9 @@ missingtests: missingcpptests missingctests # found, runs testcase.php, except for multicpptests. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL="$(RUNTOOL)" php_run; \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL='$(RUNTOOL)' php_run; \ elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php RUNTOOL='$(RUNTOOL)' php_run; \ fi # Clean: remove the generated .php file @@ -70,7 +70,7 @@ run_testcase = \ @rm -f $*.php php_$*.h clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" php_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' php_clean rm -f clientdata_prop_a.php clientdata_prop_b.php php_clientdata_prop_a.h php_clientdata_prop_b.h rm -f import_stl_a.php import_stl_b.php php_import_stl_a.h php_import_stl_b.h rm -f imports_a.php imports_b.php php_imports_a.h php_imports_b.h diff --git a/Examples/test-suite/pike/Makefile.in b/Examples/test-suite/pike/Makefile.in index 92054dd9d..6e1bdfbff 100644 --- a/Examples/test-suite/pike/Makefile.in +++ b/Examples/test-suite/pike/Makefile.in @@ -46,4 +46,4 @@ run_testcase = \ @rm -f $*.pike; clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" pike_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' pike_clean diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 59c8eed9e..de35393d0 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -167,7 +167,7 @@ endif @if test "x$(SCRIPTDIR)" != "x$(srcdir)"; then rm -f $(SCRIPTDIR)/$(py2_runme); fi clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" python_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' 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 diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 2c9a2c3f2..312834a51 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -67,7 +67,7 @@ run_multitestcase = \ done # Clean clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" r_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' r_clean %.clean: @rm -f $*.R $*_wrap.so $*_wrap.cpp $*_wrap.c $*_wrap.o $*_runme.Rout $*.Rout diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index ae4995882..6660f687f 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -69,4 +69,4 @@ run_testcase = \ @exit 0 clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" ruby_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' ruby_clean diff --git a/Examples/test-suite/tcl/Makefile.in b/Examples/test-suite/tcl/Makefile.in index 82c59dee4..322e71914 100644 --- a/Examples/test-suite/tcl/Makefile.in +++ b/Examples/test-suite/tcl/Makefile.in @@ -55,4 +55,4 @@ run_testcase = \ @exit 0 clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" tcl_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' tcl_clean diff --git a/Examples/test-suite/uffi/Makefile.in b/Examples/test-suite/uffi/Makefile.in index 275778c87..5d6dc110c 100644 --- a/Examples/test-suite/uffi/Makefile.in +++ b/Examples/test-suite/uffi/Makefile.in @@ -48,4 +48,4 @@ run_testcase = \ @exit 0 clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" uffi_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' uffi_clean From abe52396b2e418f9ac9c810feddeedf4adc98bbc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 21 Aug 2015 22:35:13 +0100 Subject: [PATCH 087/732] Leave preinst-swig as a convenience only script for ad-hoc use --- configure.ac | 15 +-------------- preinst-swig.in | 4 ++++ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index b07463b86..6ea73f327 100644 --- a/configure.ac +++ b/configure.ac @@ -2924,20 +2924,7 @@ case $build in esac AC_DEFINE_UNQUOTED(SWIG_LIB_WIN_UNIX, ["$SWIG_LIB_WIN_UNIX"], [Directory for SWIG system-independent libraries (Unix install on native Windows)]) -dnl For testing purposes, don't set SWIG_LIB_PREINST when building SWIG in the -dnl source directory under Windows because it is supposed to work without -dnl SWIG_LIB being set at all in this particular case. -if test "${srcdir}" = "."; then - AC_EGREP_CPP([yes], - [#ifdef _WIN32 - yes - #endif - ], [SWIG_LIB_PREINST=], [SWIG_LIB_PREINST=$ABS_SRCDIR/Lib]) -else - dnl When not building in source directory, we must always set SWIG_LIB, - dnl even under Windows, as things couldn't work without it. - SWIG_LIB_PREINST=$ABS_SRCDIR/Lib -fi +SWIG_LIB_PREINST=$ABS_SRCDIR/Lib AC_SUBST(SWIG_LIB_PREINST) dnl For testing purposes, clear SWIG_LIB when building SWIG in the source diff --git a/preinst-swig.in b/preinst-swig.in index e77db7858..4cead1d88 100755 --- a/preinst-swig.in +++ b/preinst-swig.in @@ -1,4 +1,8 @@ #!/bin/sh + +# Convenience script for running SWIG before it is installed. +# Intended for ad-hoc usage and not by the test-suite or examples. + builddir=`dirname $0` SWIG_LIB=@SWIG_LIB_PREINST@ export SWIG_LIB From a1e385694e9a0aa543e9eeb362626a4f10708ff6 Mon Sep 17 00:00:00 2001 From: Rick Luddy Date: Tue, 25 Aug 2015 09:17:19 -0400 Subject: [PATCH 088/732] Removed golang stringing for signed/unsigned char With this change, generated code for golang treats char* as a string but treats signed char* and unsigned char* as normal pointers. This seems to fit better with the expected behavior, as the latter are more often used as non-string data. --- Lib/go/go.swg | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/Lib/go/go.swg b/Lib/go/go.swg index 35f914c5b..54a6f08a2 100644 --- a/Lib/go/go.swg +++ b/Lib/go/go.swg @@ -426,57 +426,41 @@ /* Strings. */ %typemap(gotype) - char *, char *&, char[ANY], char[], - signed char *, signed char *&, signed char[ANY], signed char[], - unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] -"string" + char *, char *&, char[ANY], char[] "string" /* Needed to avoid confusion with the way the go module handles references. */ -%typemap(gotype) char&, unsigned char& "*byte" -%typemap(gotype) signed char& "*int8" +%typemap(gotype) char& "*byte" %typemap(in) - char *, char[ANY], char[], - signed char *, signed char[ANY], signed char[], - unsigned char *, unsigned char[ANY], unsigned char[] + char *, char[ANY], char[] %{ $1 = ($1_ltype)$input.p; %} -%typemap(in) char *&, signed char *&, unsigned char *& +%typemap(in) char *& %{ $1 = ($1_ltype)$input.p; %} %typemap(out,fragment="AllocateString") - char *, char *&, char[ANY], char[], - signed char *, signed char *&, signed char[ANY], signed char[], - unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] + char *, char *&, char[ANY], char[] %{ $result = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0); %} %typemap(goout,fragment="CopyString") - char *, char *&, char[ANY], char[], - signed char *, signed char *&, signed char[ANY], signed char[], - unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] + char *, char *&, char[ANY], char[] %{ $result = swigCopyString($1) %} %typemap(directorin,fragment="AllocateString") - char *, char *&, char[ANY], char[], - signed char *, signed char *&, signed char[ANY], signed char[], - unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] + char *, char *&, char[ANY], char[] %{ $input = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0); %} %typemap(godirectorin,fragment="CopyString") - char *, char *&, char[ANY], char[], - signed char *, signed char *&, signed char[ANY], signed char[], - unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] + char *, char *&, char[ANY], char[] %{ $result = swigCopyString($input) %} %typemap(directorout) - char *, char *&, char[ANY], char[], - signed char *, signed char *&, signed char[ANY], signed char[], - unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[] + char *, char *&, char[ANY], char[] %{ $result = ($1_ltype)$input.p; %} /* String & length */ From 8d2f3403d285f448d3e50d56449ecaa82f554cdd Mon Sep 17 00:00:00 2001 From: Michael Schaller Date: Fri, 21 Aug 2015 15:09:42 +0200 Subject: [PATCH 089/732] [Go] Reworked beginning of the documentation. * Removed link to examples in the Go source tree as discussed in issue #418. * Reworded occurences of the 'gc tool' as it has been removed with Go 1.5. * Reworked chapter 23.3. This should make it easier for users to get started with SWIG as the chapter starts with how to use SWIG with the go tool. * Added helpful links. --- Doc/Manual/Go.html | 212 ++++++++++++++++++++++++--------------------- 1 file changed, 113 insertions(+), 99 deletions(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index ca12410ad..7531a218c 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -13,8 +13,8 @@

  • Examples
  • Running SWIG with Go
  • A tour of basic C/C++ wrapping
      @@ -60,38 +60,44 @@ see golang.org.

      -Go is a compiled language, not a scripting language. However, it does -not support direct calling of functions written in C/C++. The cgo -program may be used to generate wrappers to call C code from Go, but -there is no convenient way to call C++ code. SWIG fills this gap. +Go does not support direct calling of functions written in C/C++. The +cgo program may be used to generate +wrappers to call C code from Go, but there is no convenient way to call C++ +code. SWIG fills this gap.

      -There are (at least) two different Go compilers. One is the gc -compiler, normally invoked via the go tool. The other -is the gccgo compiler, which is a frontend to the gcc compiler suite. -The interface to C/C++ code is completely different for the two Go -compilers. SWIG supports both, selected by a command line option. +There are (at least) two different Go compilers. The first is the Go compiler +of the Go distribution. +Since Go 1.5 the Go compiler is part of the +go tool. Go 1.4 and earlier use the gc tool which is called by the go tool. +The second Go compiler is the +gccgo compiler, which is a frontend to the GCC compiler suite. +The interface to C/C++ code is completely different for the two Go compilers. +SWIG supports both Go compilers, selected by the -gccgo command line +option.

      -Because Go is a type-safe compiled language, SWIG's runtime type -checking and runtime library are not used with Go. This should be -borne in mind when reading the rest of the SWIG documentation. +Go is a type-safe compiled language and the wrapper code generated by SWIG is +type-safe as well. In case of type issues the build will fail and hence SWIG's +runtime library and +runtime type checking +are not used.

      23.2 Examples

      -Working examples can be found here: +Working examples can be found in the +SWIG source tree +.

      - +

      -The examples in the 2nd link are shipped with the SWIG distribution under the Examples/go directory. +Please note that the examples in the SWIG source tree use makefiles with the .i +SWIG interface file extension for backwards compatibility with Go 1.

      @@ -99,12 +105,83 @@ The examples in the 2nd link are shipped with the SWIG distribution under the Ex

      -To generate Go code, use the -go option with SWIG. By -default SWIG will generate code for the gc compilers. To generate -code for gccgo, you should also use the -gccgo option. +Most Go programs are built using the go +tool. Since Go 1.1 the go tool has support for SWIG. To use it, give your +SWIG interface file the extension .swig (for C code) or .swigcxx (for C++ code). +Put that file in a GOPATH/src directory as usual for Go sources. Put other +C/C++ code in the same directory with extensions of .c and .cxx. The +go build and go install commands will automatically run SWIG +for you and compile the generated wrapper code. To check the SWIG command line +options the go tool uses run go build -x. To access the automatically +generated files run go build -work. You'll find the files under the +temporary WORK directory.

      -

      23.3.1 Additional Commandline Options

      +

      +To manually generate and compile C/C++ wrapper code for Go, use the -go +option with SWIG. By default SWIG will generate code for the Go compiler of the +Go distribution. To generate code for gccgo, you should also use the -gccgo + option. +

      + +

      +When using the -cgo option, SWIG will generate files that can be used +directly by go build. Starting with the Go 1.5 distribution the +-cgo option has to be given. Put your SWIG interface file in a +directory under GOPATH/src, and give it a name that does not end in the +.swig or .swigcxx extension. Typically the SWIG interface file extension is .i +in this case. +

      + +
      +% swig -go -cgo example.i
      +% go install
      +
      + +

      +You will now have a Go package that you can import from other Go packages as +usual. +

      + +

      +To use SWIG without the -cgo option, more steps are required. Recall +that this only works with Go versions before 1.5. When using Go version 1.2 or +later, or when using gccgo, the code generated by SWIG can be linked directly +into the Go program. A typical command sequence when using the Go compiler of +the Go distribution would look like this: +

      + +
      +% swig -go example.i
      +% gcc -c code.c    # The C library being wrapped.
      +% gcc -c example_wrap.c
      +% go tool 6g example.go
      +% go tool 6c example_gc.c
      +% go tool pack grc example.a example.6 example_gc.6 code.o example_wrap.o
      +% go tool 6g main.go
      +% go tool 6l main.6
      +
      + +

      +You can also put the wrapped code into a shared library, and when using the Go +versions before 1.2 this is the only supported option. A typical command +sequence for this approach would look like this: +

      + +
      +% swig -go -use-shlib example.i
      +% gcc -c -fpic example.c
      +% gcc -c -fpic example_wrap.c
      +% gcc -shared example.o example_wrap.o -o example.so
      +% go tool 6g example.go
      +% go tool 6c example_gc.c
      +% go tool pack grc example.a example.6 example_gc.6
      +% go tool 6g main.go  # your code, not generated by SWIG
      +% go tool 6l main.6
      +
      + + +

      23.3.1 Go-specific Commandline Options

      @@ -116,9 +193,9 @@ also be seen by using: swig -go -help

  • - +
    - + @@ -144,7 +221,7 @@ swig -go -help + the Go compiler of the Go distribution. @@ -156,8 +233,8 @@ swig -go -help + meaningful for the Go compiler of the Go distribution, which needs to know at + compile time whether a shared library will be used. @@ -165,9 +242,9 @@ swig -go -help + the Go compiler of the Go distribution; when using gccgo, the equivalent name + will be taken from the -soname option passed to the linker. + Using this option implies the -use-shlib option. @@ -186,16 +263,17 @@ swig -go -help
    Go specific optionsGo-specific options
    -gccgo Generate code for gccgo. The default is to generate code for - the gc compiler.
    -use-shlib Tell SWIG to emit code that uses a shared library. This is only - meaningful for the gc compiler, which needs to know at compile time - whether a shared library will be used.
    Set the runtime name of the shared library that the dynamic linker should include at runtime. The default is the package name with ".so" appended. This is only used when generating code for - the gc compiler; when using gccgo, the equivalent name will be taken from - the -soname option passed to the linker. Using this - option implies the -use-shlib option.
    -

    23.3.2 Go Output Files

    + +

    23.3.2 Generated Wrapper Files

    -

    There are two different approaches to generating output files, +

    There are two different approaches to generating wrapper files, controlled by SWIG's -cgo option. The -cgo option works with Go version 1.2 or later. It is required when using Go version 1.5 or later.

    With or without the -cgo option, SWIG will generate the - following files when generating Go code:

    + following files when generating wrapper code:

    • @@ -229,70 +307,6 @@ combined with the compiled MODULE.go using go tool pack.
    -

    -Most Go programs are built using the go tool. The go tool has limited -support for SWIG. To use it, put your SWIG interface into a file with -the extension .swig, or, if you are wrapping C++ code, .swigcxx. Put -that file in a GOPATH/src directory as usual for Go sources. Put -other interface code in the same directory with extensions of .c and -.cxx. The go build and go install commands will -automatically run SWIG for you and will build the interface code. -

    - -

    -You can also use SWIG directly yourself. When using -the -cgo option, SWIG will generate files that can be used -directly by go build. Put your SWIG input file in a -directory under GOPATH/src, and give it a name that does not end in -.swig or .swigcxx. -

    - -
    -% swig -go -cgo example.i
    -% go install
    -
    - -

    -You will now have a Go package that you can import from other Go -packages as usual. -

    - -

    -To use SWIG without the -cgo option, more steps are required. -Recall that this only works with Go versions before 1.5. When using -Go version 1.2 or later, or when using gccgo, the code generated by -SWIG can be linked directly into the Go program. A typical command -sequence when using the gc compiler would look like this: -

    - -
    -% swig -go example.i
    -% gcc -c code.c	   # The C library being wrapped.
    -% gcc -c example_wrap.c
    -% go tool 6g example.go
    -% go tool 6c example_gc.c
    -% go tool pack grc example.a example.6 example_gc.6 code.o example_wrap.o
    -% go tool 6g main.go
    -% go tool 6l main.6
    -
    - -

    -You can also put the wrapped code into a shared library, and when -using the Go versions before 1.2 this is the only supported option. A -typical command sequence for this approach would look like this: -

    - -
    -% swig -go -use-shlib example.i
    -% gcc -c -fpic example.c
    -% gcc -c -fpic example_wrap.c
    -% gcc -shared example.o example_wrap.o -o example.so
    -% go tool 6g example.go
    -% go tool 6c example_gc.c
    -% go tool pack grc example.a example.6 example_gc.6
    -% go tool 6g main.go  # your code, not generated by SWIG
    -% go tool 6l main.6
    -

    23.4 A tour of basic C/C++ wrapping

    From d5cf0ab1110a81482d725d5abf0f0af44ebbcd21 Mon Sep 17 00:00:00 2001 From: Michael Schaller Date: Thu, 27 Aug 2015 10:07:45 +0200 Subject: [PATCH 090/732] First batch of changes after code review by @ianlancetaylor for pull request #502. --- Doc/Manual/Go.html | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 7531a218c..a62efec43 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -67,10 +67,9 @@ code. SWIG fills this gap.

    -There are (at least) two different Go compilers. The first is the Go compiler -of the Go distribution. -Since Go 1.5 the Go compiler is part of the -go tool. Go 1.4 and earlier use the gc tool which is called by the go tool. +There are (at least) two different Go compilers. The first is the gc compiler +of the Go distribution, normally +invoked via the go tool. The second Go compiler is the gccgo compiler, which is a frontend to the GCC compiler suite. The interface to C/C++ code is completely different for the two Go compilers. @@ -120,8 +119,8 @@ temporary WORK directory.

    To manually generate and compile C/C++ wrapper code for Go, use the -go option with SWIG. By default SWIG will generate code for the Go compiler of the -Go distribution. To generate code for gccgo, you should also use the -gccgo - option. +Go distribution. To generate code for gccgo, you should also use the +-gccgo option.

    From 5be177e5c31aa5a55aab7297f1ef841356f58cc5 Mon Sep 17 00:00:00 2001 From: Sjoerd Job Postmus Date: Fri, 28 Aug 2015 17:43:06 +0200 Subject: [PATCH 091/732] Do not use bare exception in generated Python code. By using the 'except:', you can catch all kinds of exceptions, including the KeyboardInterrupt and SystemExit exceptions. From the generated code, it is quite obvious that it is not these cases that should be caught, but more specific ones like AttributeError and TypeError. To be on the safe side, I decided to keep using 'Exception' for now. --- Source/Modules/python.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 362a40929..d894ba53c 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -904,7 +904,7 @@ public: Printv(f_shadow, "\n", "def _swig_repr(self):\n", tab4, "try:\n", tab8, "strthis = \"proxy of \" + self.this.__repr__()\n", - tab4, "except:\n", tab8, "strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL); + tab4, "except Exception:\n", tab8, "strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL); if (!classic) { /* Usage of types.ObjectType is deprecated. @@ -934,7 +934,7 @@ public: if (directorsEnabled()) { // Try loading weakref.proxy, which is only available in Python 2.1 and higher Printv(f_shadow, - "try:\n", tab4, "import weakref\n", tab4, "weakref_proxy = weakref.proxy\n", "except:\n", tab4, "weakref_proxy = lambda x: x\n", "\n\n", NIL); + "try:\n", tab4, "import weakref\n", tab4, "weakref_proxy = weakref.proxy\n", "except Exception:\n", tab4, "weakref_proxy = lambda x: x\n", "\n\n", NIL); } } // Include some information in the code @@ -4478,11 +4478,11 @@ public: if (!modern) { Printv(f_shadow_file, tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", - tab8, "except:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL); + tab8, "except Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL); } else { Printv(f_shadow_file, tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", - tab8, "except:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL); + tab8, "except Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL); } } @@ -4824,7 +4824,7 @@ public: } else { Printv(f_shadow, tab8, "this = ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), "\n", - tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", tab8, "except:\n", tab8, tab4, "self.this = this\n", NIL); + tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", tab8, "except Exception:\n", tab8, tab4, "self.this = this\n", NIL); } if (have_pythonappend(n)) Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n\n", NIL); @@ -4922,7 +4922,7 @@ public: #ifdef USE_THISOWN Printv(f_shadow, tab8, "try:\n", NIL); Printv(f_shadow, tab8, tab4, "if self.thisown:", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "(self)\n", NIL); - Printv(f_shadow, tab8, "except: pass\n", NIL); + Printv(f_shadow, tab8, "except Exception: pass\n", NIL); #else #endif if (have_pythonappend(n)) From ab8f05204f17b7a395a9226d7fa270e6736f02c6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 Aug 2015 13:08:18 +0100 Subject: [PATCH 092/732] Cosmetic changes in Octave runtime Fix bracket matching! --- Lib/octave/octrun.swg | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index ddfd48939..b6e4b6ccf 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -982,10 +982,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); } #if SWIG_OCTAVE_PREREQ(4,0,0) - void print(std::ostream &os, bool pr_as_read_syntax = false) { + void print(std::ostream &os, bool pr_as_read_syntax = false) #else - void print(std::ostream &os, bool pr_as_read_syntax = false) const { + void print(std::ostream &os, bool pr_as_read_syntax = false) const #endif + { if (is_string()) { os << string_value(); return; @@ -1178,10 +1179,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); } #if SWIG_OCTAVE_PREREQ(4,0,0) - void print(std::ostream &os, bool pr_as_read_syntax = false) { + void print(std::ostream &os, bool pr_as_read_syntax = false) #else - void print(std::ostream &os, bool pr_as_read_syntax = false) const { + void print(std::ostream &os, bool pr_as_read_syntax = false) const #endif + { indent(os); os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size(); newline(os); } From 01d4bc391c427876474b6ec58bab68d362421d06 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 31 Aug 2015 14:05:04 +0100 Subject: [PATCH 093/732] OS X bison warning suppression --- Source/CParse/parser.y | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 1beaaef27..ef9a568c4 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3667,6 +3667,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { String *name = 0; Node *n; Classprefix = 0; + (void)$5; $$ = currentOuterClass; currentOuterClass = Getattr($$, "nested:outer"); if (!currentOuterClass) From 567d4690cf385aa056d83e78fbe1cff758db325a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 31 Aug 2015 14:05:31 +0100 Subject: [PATCH 094/732] Fix ruby warning using clang in director exception code Suppresses warning: error: control may reach end of non-void function [-Werror,-Wreturn-type] The UNUSED macro is not expanded in ruby.h for rb_exc_raise for clang when it ought to be. For patch #512 --- Source/Modules/ruby.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 4b45b87ca..7c87b5192 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2971,6 +2971,7 @@ public: Printf(rescue->code, "if (%s == 0) ", depthCountName); Printv(rescue->code, Str(tm), "\n", NIL); Printv(rescue->code, "rb_exc_raise(error);\n", NIL); + Printv(rescue->code, "return Qnil;\n", NIL); Printv(rescue->code, "}", NIL); } From 578ab10365ce1d87e036b1af524bead346310216 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 1 Sep 2015 16:09:35 +1200 Subject: [PATCH 095/732] Remove configure probes for ranlib and ar These haven't been used by the SWIG build system for many years. --- configure.ac | 3 --- 1 file changed, 3 deletions(-) diff --git a/configure.ac b/configure.ac index 6ea73f327..0f2af0eca 100644 --- a/configure.ac +++ b/configure.ac @@ -122,9 +122,6 @@ echo "Note : None of the following packages are required for users to compile an echo "" AC_PROG_YACC -AC_PROG_RANLIB -AC_CHECK_PROGS(AR, ar aal, ar) -AC_SUBST(AR) AC_CHECK_PROGS(YODL2MAN, yodl2man) AC_CHECK_PROGS(YODL2HTML, yodl2html) From 11c422529e292c02a52cfb13fae4d976568e0ba8 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 2 Sep 2015 09:35:07 +1200 Subject: [PATCH 096/732] Remove superfluous trailing ; --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 0f2af0eca..2062733d8 100644 --- a/configure.ac +++ b/configure.ac @@ -1161,12 +1161,12 @@ else if test -r $i/api_scilab.h; then AC_MSG_RESULT($i) SCILABINCLUDE="-I$i" - break; + break fi if test -r $i/scilab/api_scilab.h; then AC_MSG_RESULT($i/scilab) SCILABINCLUDE="-I$i/scilab" - break; + break fi done if test "$SCILABINCLUDE" = "" ; then @@ -2988,7 +2988,7 @@ AC_CONFIG_COMMANDS([Examples],[ for mkfile in `cd ${srcdir} && find Examples/ -type f -name Makefile`; do dir=`dirname ${mkfile}` d=${dir} - reldir=""; + reldir="" while test "x$d" != "x." ; do d=`dirname $d` reldir="${reldir}../" From efcaa8fdaca0e25013d50d9b2c4239988d90eaf4 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 2 Sep 2015 09:40:55 +1200 Subject: [PATCH 097/732] Drop code to handle compilers lacking the 'bool' type. SWIG requires an ISO C++ compiler, so this is no longer useful. Fixes issue#513. --- Source/Modules/swigmod.h | 6 ------ configure.ac | 5 ----- 2 files changed, 11 deletions(-) diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index a30fdf8fa..c4007be51 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -18,12 +18,6 @@ #include "preprocessor.h" #include "swigwarn.h" -#if !defined(HAVE_BOOL) -typedef int bool; -#define true ((bool)1) -#define false ((bool)0) -#endif - #define NOT_VIRTUAL 0 #define PLAIN_VIRTUAL 1 #define PURE_VIRTUAL 2 diff --git a/configure.ac b/configure.ac index 2062733d8..b6842e35c 100644 --- a/configure.ac +++ b/configure.ac @@ -40,11 +40,6 @@ AC_DEFINE_UNQUOTED(SWIG_PLATFORM, ["$host"], [Platform that SWIG is built for]) dnl Checks for header files. AC_HEADER_STDC -dnl Checks for types. -AC_LANG_PUSH([C++]) -AC_CHECK_TYPES([bool]) -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 From 9155ff0fbb5f9b5e64e66a36f38f534c9a10dc3d Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 29 Aug 2015 11:59:30 +0100 Subject: [PATCH 098/732] Integrate OS X .travis.yml into master branch using multi-os feature. http://docs.travis-ci.com/user/multi-os/ Expand testflags.py to support clang vs gcc, as clang is used on OS X. --- .travis.yml | 125 ++++++++++++++++++++++++++-------- Tools/testflags.py | 15 ++-- Tools/travis-linux-install.sh | 97 ++++++++++++++++++++++++++ Tools/travis-osx-install.sh | 23 +++++++ 4 files changed, 227 insertions(+), 33 deletions(-) create mode 100644 Tools/travis-linux-install.sh create mode 100644 Tools/travis-osx-install.sh diff --git a/.travis.yml b/.travis.yml index 46a3620d1..c67fb92a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,128 +2,191 @@ language: cpp matrix: include: - compiler: clang + os: linux env: SWIGLANG= - compiler: gcc + os: linux env: SWIGLANG= - compiler: gcc + os: linux env: SWIGLANG= GCC5=1 CPP11=1 - compiler: gcc + os: linux env: SWIGLANG= GCC5=1 CPP14=1 - compiler: gcc + os: linux env: SWIGLANG=csharp - compiler: gcc + os: linux env: SWIGLANG=d - compiler: gcc + os: linux env: SWIGLANG=go - compiler: gcc + os: linux env: SWIGLANG=guile - compiler: gcc + os: linux env: SWIGLANG=java - compiler: gcc + os: linux env: SWIGLANG=javascript ENGINE=node - compiler: gcc + os: linux env: SWIGLANG=javascript ENGINE=jsc - compiler: gcc + os: linux env: SWIGLANG=javascript ENGINE=v8 - compiler: gcc + os: linux env: SWIGLANG=lua - compiler: gcc + os: linux env: SWIGLANG=octave SWIGJOBS=-j3 # 3.2 - compiler: gcc + os: linux env: SWIGLANG=octave SWIGJOBS=-j3 VER=3.8 - compiler: gcc + os: linux env: SWIGLANG=octave SWIGJOBS=-j3 VER=4.0 - compiler: gcc + os: linux env: SWIGLANG=perl5 - compiler: gcc + os: linux env: SWIGLANG=php - compiler: gcc + os: linux env: SWIGLANG=python VER=2.4 - compiler: gcc + os: linux env: SWIGLANG=python VER=2.5 - compiler: gcc + os: linux env: SWIGLANG=python VER=2.6 - compiler: gcc + os: linux env: SWIGLANG=python # 2.7 - compiler: gcc + os: linux env: SWIGLANG=python PY3=3 # 3.2 - compiler: gcc + os: linux env: SWIGLANG=python PY3=3 VER=3.3 - compiler: gcc + os: linux env: SWIGLANG=python PY3=3 VER=3.4 - compiler: gcc + os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin - compiler: gcc + os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 - compiler: gcc + os: linux env: SWIGLANG=python SWIG_FEATURES=-O - compiler: gcc + os: linux env: SWIGLANG=python SWIG_FEATURES=-classic - compiler: gcc + os: linux env: SWIGLANG=r - compiler: gcc + os: linux env: SWIGLANG=ruby - compiler: gcc + os: linux env: SWIGLANG=scilab - compiler: gcc + os: linux env: SWIGLANG=tcl - compiler: gcc + os: linux env: SWIGLANG=csharp GCC5=1 CPP11=1 - compiler: gcc + os: linux env: SWIGLANG=java GCC5=1 CPP11=1 - compiler: gcc + os: linux env: SWIGLANG=python GCC5=1 CPP11=1 + - os: osx + env: SWIGLANG= SWIG_CC=gcc-4.2 SWIG_CXX=g++-4.2 + - compiler: clang + os: osx + env: SWIGLANG= + - compiler: clang + os: osx + env: SWIGLANG=csharp + - compiler: clang + os: osx + env: SWIGLANG=go + - compiler: clang + os: osx + env: SWIGLANG=guile + - compiler: clang + os: osx + env: SWIGLANG=java + - compiler: clang + os: osx + env: SWIGLANG=lua + - compiler: clang + os: osx + env: SWIGLANG=perl5 + - compiler: clang + os: osx + env: SWIGLANG=php + - compiler: clang + os: osx + env: SWIGLANG=python + - compiler: clang + os: osx + env: SWIGLANG=python PY3=3 + - compiler: clang + os: osx + env: SWIGLANG=ruby + - compiler: clang + os: osx + env: SWIGLANG=tcl + allow_failures: # Lots of failing tests currently - compiler: gcc + os: linux env: SWIGLANG=ocaml # Occasional gcc internal compiler error - compiler: gcc + os: linux env: SWIGLANG=octave SWIGJOBS=-j3 VER=3.8 # Occasional gcc internal compiler error - compiler: gcc + os: linux env: SWIGLANG=octave SWIGJOBS=-j3 VER=4.0 # Not quite working yet - compiler: gcc + os: linux env: SWIGLANG=python SWIG_FEATURES=-classic # Not quite working yet - compiler: gcc + os: linux env: SWIGLANG=python SWIG_FEATURES=-O + - compiler: clang + os: osx + env: SWIGLANG=go before_install: - date -u - uname -a - - lsb_release -a - - sudo apt-get -qq update - - if test -n "$GCC5"; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get -qq update && sudo apt-get install -qq g++-5 && export CC=gcc-5 && export CXX=g++-5; fi - - if test -z "$GCC5"; then sudo apt-get -qq install libboost-dev; fi - - if test -n "$GCC5"; then sudo add-apt-repository -y ppa:boost-latest/ppa && sudo apt-get -qq update && sudo apt-get install -qq libboost1.55-dev; fi - - if test -z "$SWIGLANG"; then sudo apt-get -qq install yodl; fi - - if test "$SWIGLANG" = "csharp"; then sudo apt-get -qq install mono-devel; fi - - if test "$SWIGLANG" = "d"; then wget http://downloads.dlang.org/releases/2014/dmd_2.066.0-0_amd64.deb; sudo dpkg -i dmd_2.066.0-0_amd64.deb; 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" = "javascript" -a "$ENGINE" = "node"; then sudo apt-get install -qq rlwrap python-software-properties && echo 'yes' | sudo add-apt-repository ppa:chris-lea/node.js && sudo apt-get -qq update && sudo apt-get install -qq nodejs && sudo npm install -g node-gyp; fi - - if test "$SWIGLANG" = "javascript" -a "$ENGINE" = "jsc"; then sudo apt-get install -qq libwebkitgtk-dev; fi - - if test "$SWIGLANG" = "javascript" -a "$ENGINE" = "v8"; then sudo apt-get install -qq libv8-dev; fi - - 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 - # configure also looks for ocamldlgen, but this isn't packaged. But it isn't used by default so this doesn't matter. - - if test "$SWIGLANG" = "ocaml"; then sudo apt-get -qq install ocaml ocaml-findlib; fi - - if test "$SWIGLANG" = "octave" -a -z "$VER"; then sudo apt-get -qq install octave3.2 octave3.2-headers; fi - - if test "$SWIGLANG" = "octave" -a "$VER"; then sudo add-apt-repository -y ppa:kwwette/octaves && sudo apt-get -qq update && sudo apt-get -qq install liboctave${VER}-dev; fi - - if test "$SWIGLANG" = "php"; then sudo apt-get install php5-cli php5-dev; fi - - if test "$SWIGLANG" = "python"; then git clone https://github.com/jcrocholl/pep8.git && pushd pep8 && git checkout tags/1.5.7 && python ./setup.py build && sudo python ./setup.py install && popd; fi - - if test "$SWIGLANG" = "python" -a "$PY3" -a -z "$VER"; then sudo apt-get install -qq python3-dev; fi - - if test "$SWIGLANG" = "python" -a "$VER"; then sudo add-apt-repository -y ppa:fkrull/deadsnakes && sudo apt-get -qq update && sudo apt-get -qq install python${VER}-dev && CONFIGOPTS+=("--with-python${PY3}=python${VER}"); fi - - if test "$SWIGLANG" = "r"; then sudo apt-get -qq install r-base; fi - - if test "$SWIGLANG" = "scilab"; then sudo apt-get -qq install scilab; fi - - if test "$SWIGLANG" = "tcl"; then sudo apt-get -qq install tcl8.4-dev; fi + # Travis overrides CC environment with compiler predefined values + - if test -n "$SWIG_CC"; then export CC="$SWIG_CC"; fi + - if test -n "$SWIG_CXX"; then export CXX="$SWIG_CXX"; fi +install: + - if test "$TRAVIS_OS_NAME" = "linux"; then source Tools/travis-linux-install.sh; fi + - if test "$TRAVIS_OS_NAME" = "osx"; then source Tools/travis-osx-install.sh; fi - if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++11 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++11; fi - if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++14 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++14; fi + - ls -la $(which $CC) + - ls -la $(which $CXX) - $CC --version - $CXX --version - # Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic. - - if test -n "$SWIGLANG"; then export cflags=$(Tools/testflags.py --language $SWIGLANG --cflags --std=$CSTD) && echo $cflags; fi - - if test -n "$SWIGLANG"; then export cxxflags=$(Tools/testflags.py --language $SWIGLANG --cxxflags --std=$CPPSTD) && echo $cxxflags; fi script: - echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r' - if test -n "$SWIGLANG"; then CONFIGOPTS+=(--without-alllang --with-$SWIGLANG$PY3); fi @@ -135,8 +198,12 @@ script: - if test -z "$SWIGLANG"; then make -s $SWIGJOBS check-ccache; fi - if test -z "$SWIGLANG"; then make -s $SWIGJOBS check-errors-test-suite; fi - echo 'Installing...' && echo -en 'travis_fold:start:script.2\\r' - - if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi + # make install doesn't work on os x due to missing yodl2man + - if test -z "$SWIGLANG" -a "$TRAVIS_OS_NAME" = "linux"; then sudo make -s install && swig -version && ccache-swig -V; fi - echo -en 'travis_fold:end:script.2\\r' + # Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic. + - if test -n "$SWIGLANG"; then cflags=$($TRAVIS_BUILD_DIR/Tools/testflags.py --language $SWIGLANG --cflags --std=$CSTD --compiler=$CC) && echo $cflags; fi + - if test -n "$SWIGLANG"; then cxxflags=$($TRAVIS_BUILD_DIR/Tools/testflags.py --language $SWIGLANG --cxxflags --std=$CPPSTD --compiler=$CC) && echo $cxxflags; fi - if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi - if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi - if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi diff --git a/Tools/testflags.py b/Tools/testflags.py index 04bbc1c67..f8f31ea17 100755 --- a/Tools/testflags.py +++ b/Tools/testflags.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -def get_cflags(language, std): +def get_cflags(language, std, compiler): if std == None or len(std) == 0: std = "gnu89" c_common = "-fdiagnostics-show-option -std=" + std + " -Wno-long-long -Wreturn-type -Wdeclaration-after-statement" @@ -20,13 +20,15 @@ def get_cflags(language, std): "scilab":"-Werror " + c_common, "tcl":"-Werror " + c_common, } + if compiler == 'clang': + cflags["guile"] += " -Wno-attributes" # -Wno-attributes is for clang LLVM 3.5 and bdw-gc < 7.5 used by guile if language not in cflags: raise RuntimeError("{} is not a supported language".format(language)) return cflags[language] -def get_cxxflags(language, std): +def get_cxxflags(language, std, compiler): if std == None or len(std) == 0: std = "c++98" cxx_common = "-fdiagnostics-show-option -std=" + std + " -Wno-long-long -Wreturn-type" @@ -46,6 +48,8 @@ def get_cxxflags(language, std): "scilab": cxx_common, "tcl":"-Werror " + cxx_common, } + if compiler == 'clang': + cxxflags["guile"] += " -Wno-attributes" # -Wno-attributes is for clang LLVM 3.5 and bdw-gc < 7.5 used by guile if language not in cxxflags: raise RuntimeError("{} is not a supported language".format(language)) @@ -59,12 +63,15 @@ flags = parser.add_mutually_exclusive_group(required=True) flags.add_argument('-c', '--cflags', action='store_true', default=False, help='show CFLAGS') flags.add_argument('-x', '--cxxflags', action='store_true', default=False, help='show CXXFLAGS') parser.add_argument('-s', '--std', required=False, help='language standard flags for the -std= option') +parser.add_argument('-C', '--compiler', required=False, help='compiler used (clang or gcc)') args = parser.parse_args() if args.cflags: - print("{}".format(get_cflags(args.language, args.std))) + get_flags = get_cflags elif args.cxxflags: - print("{}".format(get_cxxflags(args.language, args.std))) + get_flags = get_cxxflags else: parser.print_help() exit(1) + +print(get_flags(args.language, args.std, args.compiler)) diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh new file mode 100644 index 000000000..11c937677 --- /dev/null +++ b/Tools/travis-linux-install.sh @@ -0,0 +1,97 @@ +#!/bin/bash +lsb_release -a +sudo apt-get -qq update + +if [[ "$GCC5" ]]; then + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + sudo add-apt-repository -y ppa:boost-latest/ppa + sudo apt-get -qq update + sudo apt-get install -qq g++-5 libboost1.55-dev + export CC=gcc-5 CXX=g++-5 +else + sudo apt-get -qq install libboost-dev +fi + +case "$SWIGLANG" in + "") + sudo apt-get -qq install yodl + ;; + "csharp") + sudo apt-get -qq install mono-devel + ;; + "d") + wget http://downloads.dlang.org/releases/2014/dmd_2.066.0-0_amd64.deb + sudo dpkg -i dmd_2.066.0-0_amd64.deb + ;; + "go") + # Until configure.ac is fixed + go env | sed -e 's/^/export /' > goenvsetup + source goenvsetup + rm -f goenvsetup + ;; + "javascript") + case "$ENGINE" in + "node") + sudo add-apt-repository -y ppa:chris-lea/node.js + sudo apt-get -qq update + sudo apt-get install -qq nodejs rlwrap + sudo npm install -g node-gyp + ;; + "jsc") + sudo apt-get install -qq libwebkitgtk-dev + ;; + "v8") + sudo apt-get install -qq libv8-dev + ;; + esac + ;; + "guile") + sudo apt-get -qq install guile-2.0-dev + ;; + "lua") + sudo apt-get -qq install lua5.1 liblua5.1-dev + ;; + "ocaml") + # configure also looks for ocamldlgen, but this isn't packaged. But it isn't used by default so this doesn't matter. + sudo apt-get -qq install ocaml ocaml-findlib + ;; + "octave") + if [[ -z "$VER" ]]; then + sudo apt-get -qq install octave3.2 octave3.2-headers + else + sudo add-apt-repository -y ppa:kwwette/octaves + sudo apt-get -qq update + sudo apt-get -qq install liboctave${VER}-dev + fi + ;; + "php") + sudo apt-get install php5-cli php5-dev + ;; + "python") + git clone https://github.com/jcrocholl/pep8.git + ( + cd pep8 + git checkout tags/1.5.7 + python ./setup.py build + sudo python ./setup.py install + ) + if [[ "$PY3" ]]; then + sudo apt-get install -qq python3-dev + fi + if [[ "$VER" ]]; then + sudo add-apt-repository -y ppa:fkrull/deadsnakes + sudo apt-get -qq update + sudo apt-get -qq install python${VER}-dev + CONFIGOPTS+=("--with-python${PY3}=python${VER}"); + fi + ;; + "r") + sudo apt-get -qq install r-base + ;; + "scilab") + sudo apt-get -qq install scilab + ;; + "tcl") + sudo apt-get -qq install tcl8.4-dev + ;; +esac diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh new file mode 100644 index 000000000..c85481b51 --- /dev/null +++ b/Tools/travis-osx-install.sh @@ -0,0 +1,23 @@ +#!/bin/bash +sw_vers +brew update +brew list +brew install pcre +# brew install boost +case "$SWIGLANG" in + "csharp") + brew install https://s3.amazonaws.com/travisbuilds.swig.org/mono.rb + ;; + "guile") + Tools/brew-install guile + ;; + "lua") + brew install lua + ;; + "python") + if [[ "$PY3" ]]; then + brew install python3 + brew list -v python3 + fi + ;; +esac From 3f0072c7ca0e26df9e1ae5c83378373f1efe48d9 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Mon, 31 Aug 2015 22:54:20 +0100 Subject: [PATCH 099/732] Add R to testflags.py --- Tools/testflags.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tools/testflags.py b/Tools/testflags.py index f8f31ea17..76389f046 100755 --- a/Tools/testflags.py +++ b/Tools/testflags.py @@ -16,6 +16,7 @@ def get_cflags(language, std, compiler): "perl5":"-Werror " + c_common, "php":"-Werror " + c_common, "python":"-Werror " + c_common, + "r":"-Werror " + c_common, "ruby":"-Werror " + c_common, "scilab":"-Werror " + c_common, "tcl":"-Werror " + c_common, @@ -44,6 +45,7 @@ def get_cxxflags(language, std, compiler): "perl5":"-Werror " + cxx_common, "php":"-Werror " + cxx_common, "python":"-Werror " + cxx_common, + "r":"-Werror " + cxx_common, "ruby":"-Werror " + cxx_common, "scilab": cxx_common, "tcl":"-Werror " + cxx_common, From 1ecd0bad3140ef299ddebd1efec1ed2638d870e9 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Mon, 31 Aug 2015 22:31:35 +0100 Subject: [PATCH 100/732] Make sure travis doesn't silently skip testing of some language --- .travis.yml | 1 + Makefile.in | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index c67fb92a0..a36b169b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -205,6 +205,7 @@ script: - if test -n "$SWIGLANG"; then cflags=$($TRAVIS_BUILD_DIR/Tools/testflags.py --language $SWIGLANG --cflags --std=$CSTD --compiler=$CC) && echo $cflags; fi - if test -n "$SWIGLANG"; then cxxflags=$($TRAVIS_BUILD_DIR/Tools/testflags.py --language $SWIGLANG --cxxflags --std=$CPPSTD --compiler=$CC) && echo $cxxflags; fi - if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi + - if test -n "$SWIGLANG"; then make check-$SWIGLANG-enabled; fi - if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi - if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi - echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r' diff --git a/Makefile.in b/Makefile.in index 5be06bbc1..d9d2c3f18 100644 --- a/Makefile.in +++ b/Makefile.in @@ -94,6 +94,12 @@ skip-android = test -n "@SKIP_ANDROID@" # Special errors test-case skip-errors = test -n "" +check-%-enabled: + @if $(skip-$*); then \ + echo skipping $* version; \ + exit 1; \ + fi + ##################################################################### # CHECK ##################################################################### From b1204ce92f94a3183e5528f70076b284726bcbe0 Mon Sep 17 00:00:00 2001 From: Rick Luddy Date: Thu, 3 Sep 2015 14:30:18 -0400 Subject: [PATCH 101/732] Revert reference change; update CHANGES.current --- CHANGES.current | 13 +++++++++++++ Lib/go/go.swg | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 8c269f295..e69474e9d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,19 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-09-03: demi-rluddy + [Go] Removed golang stringing for signed/unsigned char + + Changed default handling of signed char* and unsigned char* to be + opaque pointers rather than strings, similarly to how other + languages work. + + Any existing code relying on treating signed char* or unsigned + char* as a string can restore the old behavior with typemaps.i by + using %apply to copy the [unchanged] char* behavior. + + *** POTENTIAL INCOMPATIBILITY *** + 2015-08-07: talby [Perl] tidy -Wtautological-constant-out-of-range-compare warnings when building generated code under clang diff --git a/Lib/go/go.swg b/Lib/go/go.swg index 54a6f08a2..24f1b73f7 100644 --- a/Lib/go/go.swg +++ b/Lib/go/go.swg @@ -430,7 +430,8 @@ /* Needed to avoid confusion with the way the go module handles references. */ -%typemap(gotype) char& "*byte" +%typemap(gotype) char&, unsigned char& "*byte" +%typemap(gotype) signed char& "*int8" %typemap(in) char *, char[ANY], char[] From 9e69a2c198ff684b757ce26ca95a3b2112dbc530 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Sep 2015 12:14:21 +1200 Subject: [PATCH 102/732] Use name of PHP resource not wrapped C++ type Since callback::foo_T isn't a PHP resource, that error message doesn't really make sense as it was. As discussed in #467. --- Examples/test-suite/php/callback_runme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/php/callback_runme.php b/Examples/test-suite/php/callback_runme.php index 392d5e598..fefa32502 100644 --- a/Examples/test-suite/php/callback_runme.php +++ b/Examples/test-suite/php/callback_runme.php @@ -3,7 +3,7 @@ require "tests.php"; require "callback.php"; // In 2.0.6 and earlier, the constant was misnamed. -if (gettype(callback::FOO_I_Cb_Ptr) !== 'resource') die("callback::foo_T not a resource\n"); +if (gettype(callback::FOO_I_Cb_Ptr) !== 'resource') die("callback::FOO_I_Cb_Ptr not a resource\n"); check::done(); ?> From aa0e78103425b741fd533dc7d1af22a9fa429c73 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Sep 2015 12:50:52 +1200 Subject: [PATCH 103/732] Suppress pep8 E731 (lambda assignment) This is a new warning in pep8 1.6.0 which breaks our testsuite. --- Examples/test-suite/python/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index de35393d0..47535f569 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -11,7 +11,7 @@ endif LANGUAGE = python PYTHON = $(PYBIN) PEP8 = @PEP8@ -PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391 +PEP8_FLAGS = --ignore=E30,E402,E501,E731,W291,W391 #*_runme.py for Python 2.x, *_runme3.py for Python 3.x PY2SCRIPTSUFFIX = _runme.py From 8ab622c6d00cb6014c6b9fcd73ec564640b03d75 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Sep 2015 13:04:37 +1200 Subject: [PATCH 104/732] [Python] Fix docstrings for %callback functions Reinstates autodoc for callback function testcase from #467, actually tests the resulting docstring in the _runme.py and fixes SWIG/Python so the expected result is obtained. --- CHANGES.current | 3 +++ Examples/test-suite/autodoc.i | 6 ++++++ Examples/test-suite/python/autodoc_runme.py | 1 + Source/Modules/python.cxx | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 8c269f295..33b59fafa 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-09-04: olly + [Python] Fix docstrings for %callback functions. + 2015-08-07: talby [Perl] tidy -Wtautological-constant-out-of-range-compare warnings when building generated code under clang diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index eda04d293..a2d9f5b4e 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -114,6 +114,12 @@ } %} +%callback("%(uppercase)s_CALLBACK") func_cb; + +%inline { + int func_cb(int c, int d) { return c; } +} + // Bug 3310528 %feature("autodoc","1") banana; // names + types %inline %{ diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index 7256669d9..ce0aae0eb 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -355,4 +355,5 @@ check(funkdefaults.__doc__, check(func_input.__doc__, "func_input(int * INPUT) -> int") check(func_output.__doc__, "func_output() -> int") check(func_inout.__doc__, "func_inout(int * INOUT) -> int") +check(func_cb.__doc__, "func_cb(int c, int d) -> int") check(banana.__doc__, "banana(S a, S b, int c, Integer d)") diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index d894ba53c..35cfa63e9 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2389,7 +2389,7 @@ public: Printv(f_dest, tab4 "return ", funcCall(name, callParms), "\n", NIL); } - if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) { + if ((Getattr(n, "feature:python:callback") && !have_docstring(n)) || !have_addtofunc(n)) { /* If there is no addtofunc directive then just assign from the extension module (for speed up) */ Printv(f_dest, name, " = ", module, ".", name, "\n", NIL); } From e903854deda2aaf002c543d16e58e7555018ee3c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Sep 2015 14:29:21 +1200 Subject: [PATCH 105/732] valgrind --trace-children=yes no longer required We no longer use the preinst-swig wrapper script in the testsuite. --- Examples/test-suite/common.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 53a27ef9b..99fea03ed 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -33,9 +33,7 @@ # can be used for memory checking of the runtime tests using: # make RUNTOOL="valgrind --leak-check=full" # and valgrind can be used when invoking SWIG using: -# make SWIGTOOL="valgrind --tool=memcheck --trace-children=yes" -# Note: trace-children needed because of preinst-swig shell wrapper -# to the swig executable. +# make SWIGTOOL="valgrind --tool=memcheck" # # An individual test run can be debugged easily: # make director_string.cpptest RUNTOOL="gdb --args" From c270367ea01c402e11c5c13fcf41220a0652768f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Sep 2015 14:30:42 +1200 Subject: [PATCH 106/732] Add missing shell quoting --- preinst-swig.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/preinst-swig.in b/preinst-swig.in index 4cead1d88..ac00602bb 100755 --- a/preinst-swig.in +++ b/preinst-swig.in @@ -3,7 +3,7 @@ # Convenience script for running SWIG before it is installed. # Intended for ad-hoc usage and not by the test-suite or examples. -builddir=`dirname $0` -SWIG_LIB=@SWIG_LIB_PREINST@ +builddir=`dirname "$0"` +SWIG_LIB='@SWIG_LIB_PREINST@' export SWIG_LIB exec "$builddir/swig" "$@" From 8a6874e6337843fb6584cf298bb0b526776ec437 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Sep 2015 15:29:06 +1200 Subject: [PATCH 107/732] Fix docstrings for callback functions with -builtin --- Source/Modules/python.cxx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 35cfa63e9..e0306d746 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2389,7 +2389,7 @@ public: Printv(f_dest, tab4 "return ", funcCall(name, callParms), "\n", NIL); } - if ((Getattr(n, "feature:python:callback") && !have_docstring(n)) || !have_addtofunc(n)) { + if (!have_addtofunc(n)) { /* If there is no addtofunc directive then just assign from the extension module (for speed up) */ Printv(f_dest, name, " = ", module, ".", name, "\n", NIL); } @@ -2432,18 +2432,12 @@ public: if (!n) { Append(methods, "NULL"); - } else if (Getattr(n, "feature:callback")) { - if (have_docstring(n)) { - String *ds = cdocstring(n, AUTODOC_FUNC); - Printf(methods, "(char *)\"%s\\nswig_ptr: %s\"", ds, Getattr(n, "feature:callback:name")); - Delete(ds); - } else { - Printf(methods, "(char *)\"swig_ptr: %s\"", Getattr(n, "feature:callback:name")); - } } else if (have_docstring(n)) { String *ds = cdocstring(n, AUTODOC_FUNC); Printf(methods, "(char *)\"%s\"", ds); Delete(ds); + } else if (Getattr(n, "feature:callback")) { + Printf(methods, "(char *)\"swig_ptr: %s\"", Getattr(n, "feature:callback:name")); } else { Append(methods, "NULL"); } From 5dd553e244a08a94882b979a48185bc39222ec62 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 5 Sep 2015 11:21:17 +0100 Subject: [PATCH 108/732] Travis: unify GCC5 and SWIG_CC variables --- .travis.yml | 25 ++++++++++--------------- Tools/travis-linux-install.sh | 3 +-- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index a36b169b4..8de02e2b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,12 +7,10 @@ matrix: - compiler: gcc os: linux env: SWIGLANG= - - compiler: gcc - os: linux - env: SWIGLANG= GCC5=1 CPP11=1 - - compiler: gcc - os: linux - env: SWIGLANG= GCC5=1 CPP14=1 + - os: linux + env: SWIGLANG= SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + - os: linux + env: SWIGLANG= SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP14=1 - compiler: gcc os: linux env: SWIGLANG=csharp @@ -100,15 +98,12 @@ matrix: - compiler: gcc os: linux env: SWIGLANG=tcl - - compiler: gcc - os: linux - env: SWIGLANG=csharp GCC5=1 CPP11=1 - - compiler: gcc - os: linux - env: SWIGLANG=java GCC5=1 CPP11=1 - - compiler: gcc - os: linux - env: SWIGLANG=python GCC5=1 CPP11=1 + - os: linux + env: SWIGLANG=csharp SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + - os: linux + env: SWIGLANG=java SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + - os: linux + env: SWIGLANG=python SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 - os: osx env: SWIGLANG= SWIG_CC=gcc-4.2 SWIG_CXX=g++-4.2 - compiler: clang diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 11c937677..0b5172b6d 100644 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -2,12 +2,11 @@ lsb_release -a sudo apt-get -qq update -if [[ "$GCC5" ]]; then +if [[ "$CC" == gcc-5 ]]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo add-apt-repository -y ppa:boost-latest/ppa sudo apt-get -qq update sudo apt-get install -qq g++-5 libboost1.55-dev - export CC=gcc-5 CXX=g++-5 else sudo apt-get -qq install libboost-dev fi From b5873218b6aad203f04a7aca4b4258e42dd343c2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 Sep 2015 15:30:50 +0100 Subject: [PATCH 109/732] Ruby mark_function example and docs fixes Relates to Ruby trackings hash bug #225 --- Doc/Manual/Ruby.html | 2 +- Examples/ruby/mark_function/runme.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index e78447b92..6590a133b 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -4818,7 +4818,7 @@ public: class Zoo { protected: - std::vector<animal *=""> animals; + std::vector<Animal *> animals; public: // Construct an empty zoo diff --git a/Examples/ruby/mark_function/runme.rb b/Examples/ruby/mark_function/runme.rb index 6d84ee88f..a7c5b042e 100644 --- a/Examples/ruby/mark_function/runme.rb +++ b/Examples/ruby/mark_function/runme.rb @@ -9,7 +9,7 @@ begin zoo.add_animal(tiger1) # unset variables to force gc - tiger = nil + tiger1 = nil end GC.start @@ -20,4 +20,4 @@ tiger2 = zoo.get_animal(0) # Call a method to verify the animal is still valid and not gc'ed if tiger2.get_name != "tiger1" raise RuntimeError, "Wrong animal name" -end +end From 16a3ff3603f48840ffa456842e82f58721c0ba34 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 Sep 2015 15:43:05 +0100 Subject: [PATCH 110/732] Add executable permissions to new scripts --- Tools/travis-linux-install.sh | 0 Tools/travis-osx-install.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 Tools/travis-linux-install.sh mode change 100644 => 100755 Tools/travis-osx-install.sh diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh old mode 100644 new mode 100755 diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh old mode 100644 new mode 100755 From 89f13b03dae3279ecbd6f8e6ac0e33e5bdc67e07 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 Sep 2015 16:18:03 +0100 Subject: [PATCH 111/732] Correct to Unix CR/LF --- Examples/lua/import/README | 66 +++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/Examples/lua/import/README b/Examples/lua/import/README index 1a52e3c1e..af83d29b9 100644 --- a/Examples/lua/import/README +++ b/Examples/lua/import/README @@ -1,36 +1,36 @@ -This example tests the %import directive and working with multiple modules. - -Use 'lua runme.lua' to run a test. - -Overview: ---------- - -The example defines 4 different extension modules--each wrapping -a separate C++ class. - - base.i - Base class - foo.i - Foo class derived from Base - bar.i - Bar class derived from Base - spam.i - Spam class derived from Bar - -Each module uses %import to refer to another module. For -example, the 'foo.i' module uses '%import base.i' to get -definitions for its base class. - -If everything is okay, all of the modules will load properly and -type checking will work correctly. Caveat: Some compilers, for example -gcc-3.2.x, generate broken vtables with the inline methods in this test. -This is not a SWIG problem and can usually be solved with non-inlined -destructors compiled into separate shared objects/DLLs. - -Unix: ------ -- Run make -- Run the test as described above - -Windows: +This example tests the %import directive and working with multiple modules. + +Use 'lua runme.lua' to run a test. + +Overview: +--------- + +The example defines 4 different extension modules--each wrapping +a separate C++ class. + + base.i - Base class + foo.i - Foo class derived from Base + bar.i - Bar class derived from Base + spam.i - Spam class derived from Bar + +Each module uses %import to refer to another module. For +example, the 'foo.i' module uses '%import base.i' to get +definitions for its base class. + +If everything is okay, all of the modules will load properly and +type checking will work correctly. Caveat: Some compilers, for example +gcc-3.2.x, generate broken vtables with the inline methods in this test. +This is not a SWIG problem and can usually be solved with non-inlined +destructors compiled into separate shared objects/DLLs. + +Unix: +----- +- Run make +- Run the test as described above + +Windows: -------- Sorry, no files here. -If you know how, you could copy the python or ruby example dsw & dsp and try editing that +If you know how, you could copy the python or ruby example dsw & dsp and try editing that + - From 37e60f450f9d492ec90b55883ddb2a174877a66d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Sep 2015 17:23:48 +0100 Subject: [PATCH 112/732] Ruby tracking doc fixes --- Doc/Manual/Ruby.html | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 6590a133b..d5faeb7b8 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -4941,7 +4941,8 @@ class-by-class basis if needed. To fix the example above:

    /* 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; +/* Tell SWIG to keep track of mappings between C/C++ structs/classes. */ +%trackobjects; %include "example.h"
    @@ -5101,7 +5102,7 @@ static void mark_Zoo(void* ptr) {

    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 +information, please refer to the ruby_track_objects.i test case in the SWIG test suite.

    When this code is compiled we now see:

    @@ -5168,21 +5169,23 @@ 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 +object is responsible for freeing any animal that it contains. This means 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();
    - IterType end = this->animals.end();
    -
    - for(iter; iter != end; ++iter) {
    - Animal* animal = *iter;
    - delete animal;
    - }
    -}
    +
    +Zoo::~Zoo() {
    +  IterType iter = this->animals.begin();
    +  IterType end = this->animals.end();
    + 
    +  for(iter; iter != end; ++iter) {
    +    Animal* animal = *iter;
    +    delete animal;
    +  }
    +}
    +

    When we use these objects in IRB we see:

    From 0e725b5d9bd534964ae606852453df46d04037ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= Date: Thu, 3 Jan 2013 11:56:25 +0100 Subject: [PATCH 113/732] Fix Ruby tracking code to use C hash This is a patch to resolve SF bug 2034216 (Github issue #225) The bug is that the tracking code uses a ruby hash and thus may allocate objects (Bignum) while running the GC. This was tolerated in 1.8 but is invalid (raises an exception) in 1.9. The patch uses a C hash (also used by ruby) instead. --- Lib/ruby/rubytracking.swg | 127 +++++++++++++++----------------------- 1 file changed, 49 insertions(+), 78 deletions(-) diff --git a/Lib/ruby/rubytracking.swg b/Lib/ruby/rubytracking.swg index 0a36f4a05..d974228b8 100644 --- a/Lib/ruby/rubytracking.swg +++ b/Lib/ruby/rubytracking.swg @@ -22,19 +22,19 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ +/* Global hash table to store Trackings from C/C++ structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; +VALUE get_swig_trackings_count(ANYARGS) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Setup a Ruby hash table to store Trackings */ + +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ /* Try to see if some other .so has already created a @@ -43,87 +43,47 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } + else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ - - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", get_swig_trackings_count, NULL); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ - return Qnil; + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; } else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); + return Qnil; } } @@ -132,12 +92,8 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its @@ -147,10 +103,25 @@ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + if (TYPE(object) != T_DATA) + abort(); DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int _ruby_internal_iterate_callback(void* ptr, VALUE obj, void(*meth)(void* ptr, VALUE obj)) { + (*meth)(ptr, obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, (int (*)(ANYARGS))&_ruby_internal_iterate_callback, (st_data_t)meth); +} #ifdef __cplusplus } From e14b392596f453dc8f437de90e8d405a04d5df62 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 13 Sep 2015 13:25:29 +0100 Subject: [PATCH 114/732] Ruby trackings patch tidy up and add changes entry Closes #225 --- CHANGES.current | 7 +++++++ Lib/ruby/rubytracking.swg | 16 +++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6faf58a90..2e3a969d0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,13 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-09-13: kkaempf + [Ruby] Resolve tracking bug - issue #225. + The bug is that the tracking code uses a ruby hash and thus may + allocate objects (Bignum) while running the GC. This was tolerated in + 1.8 but is invalid (raises an exception) in 1.9. + The patch uses a C hash (also used by ruby) instead. + 2015-09-09: lyze [CFFI] Extend the "export" feature in the CFFI module to support exporting to a specified package. diff --git a/Lib/ruby/rubytracking.swg b/Lib/ruby/rubytracking.swg index d974228b8..37789c1c2 100644 --- a/Lib/ruby/rubytracking.swg +++ b/Lib/ruby/rubytracking.swg @@ -27,7 +27,7 @@ extern "C" { */ static st_table* swig_ruby_trackings = NULL; -VALUE get_swig_trackings_count(ANYARGS) { +static VALUE swig_ruby_trackings_count(ANYARGS) { return SWIG2NUM(swig_ruby_trackings->num_entries); } @@ -45,7 +45,7 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { */ VALUE trackings_value = Qnil; /* change the variable name so that we can mix modules - compiled with older SWIG's */ + compiled with older SWIG's - this used to be called "@__trackings__" */ ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); @@ -60,12 +60,11 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { /* No, it hasn't. Create one ourselves */ swig_ruby_trackings = st_init_numtable(); rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); - } - else { + } else { swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); } - rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", get_swig_trackings_count, NULL); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", swig_ruby_trackings_count, NULL); } /* Add a Tracking from a C/C++ struct to a Ruby object */ @@ -81,8 +80,7 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { return value; - } - else { + } else { return Qnil; } } @@ -114,13 +112,13 @@ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { to the passed callback function. */ /* Proxy method to abstract the internal trackings datatype */ -static int _ruby_internal_iterate_callback(void* ptr, VALUE obj, void(*meth)(void* ptr, VALUE obj)) { +static int swig_ruby_internal_iterate_callback(void* ptr, VALUE obj, void(*meth)(void* ptr, VALUE obj)) { (*meth)(ptr, obj); return ST_CONTINUE; } SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { - st_foreach(swig_ruby_trackings, (int (*)(ANYARGS))&_ruby_internal_iterate_callback, (st_data_t)meth); + st_foreach(swig_ruby_trackings, (int (*)(ANYARGS))&swig_ruby_internal_iterate_callback, (st_data_t)meth); } #ifdef __cplusplus From 604b3d009ce4ed170ebfcfb256fc5c91c08b1d0e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 13 Sep 2015 20:09:50 +0100 Subject: [PATCH 115/732] Ruby trackings bug fix support for 1.8 Issue #225 --- Lib/ruby/rubytracking.swg | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/ruby/rubytracking.swg b/Lib/ruby/rubytracking.swg index 37789c1c2..8f9f01be8 100644 --- a/Lib/ruby/rubytracking.swg +++ b/Lib/ruby/rubytracking.swg @@ -11,6 +11,11 @@ extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) From 4d4c7eca9a26976933c8383ee5fcde32cc04eefc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Sep 2015 17:25:37 +0100 Subject: [PATCH 116/732] Ruby free function declaration change Declare function taking void * parameter to be more flexible for upcoming smart pointer support. --- Source/Modules/ruby.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 7c87b5192..f45010f6a 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2718,7 +2718,9 @@ public: String *pname0 = Swig_cparm_name(0, 0); Printv(freefunc, "free_", klass->mname, NIL); - Printv(freebody, "SWIGINTERN void\n", freefunc, "(", klass->type, " *", pname0, ") {\n", tab4, NIL); + Printv(freebody, "SWIGINTERN void\n", freefunc, "(void *self) {\n", NIL); + Printv(freebody, tab4, klass->type, " *", pname0, " = (", klass->type, " *)self;\n", NIL); + Printv(freebody, tab4, NIL); /* Check to see if object tracking is activated for the class that owns this destructor. */ From 3d1e20248f8422681382be8a91c91d456d4595e7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Sep 2015 18:13:26 +0100 Subject: [PATCH 117/732] Ruby ownership refactor ready for smart pointers ruby_owntype replaced with swig_ruby_owntype which contains a member own for forthcoming smart pointer support. --- Lib/ruby/director.swg | 21 +++++++++++---------- Lib/ruby/rubyrun.swg | 27 ++++++++++++++++----------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg index 395dccc17..5d5161db4 100644 --- a/Lib/ruby/director.swg +++ b/Lib/ruby/director.swg @@ -29,8 +29,9 @@ namespace Swig { virtual ~GCItem() { } - virtual ruby_owntype get_own() const { - return 0; + virtual swig_ruby_owntype get_own() const { + swig_ruby_owntype own = {0}; + return own; } }; @@ -72,18 +73,18 @@ namespace Swig { }; struct GCItem_Object : GCItem { - GCItem_Object(ruby_owntype own) : _own(own) { + GCItem_Object(swig_ruby_owntype own) : _own(own) { } virtual ~GCItem_Object() { } - ruby_owntype get_own() const { + swig_ruby_owntype get_own() const { return _own; } private: - ruby_owntype _own; + swig_ruby_owntype _own; }; template @@ -323,20 +324,20 @@ namespace Swig { } } - void swig_acquire_ownership_obj(void *vptr, ruby_owntype own) const { - if (vptr && own) { + void swig_acquire_ownership_obj(void *vptr, swig_ruby_owntype own) const { + if (vptr && own.datafree) { SWIG_GUARD(swig_mutex_own); swig_owner[vptr] = new GCItem_Object(own); } } - ruby_owntype swig_release_ownership(void *vptr) const { - ruby_owntype own = 0; + swig_ruby_owntype swig_release_ownership(void *vptr) const { + swig_ruby_owntype own = {0}; if (vptr) { SWIG_GUARD(swig_mutex_own); swig_ownership_map::iterator iter = swig_owner.find(vptr); if (iter != swig_owner.end()) { - own = iter->second->get_own(); + own.datafree = iter->second->get_own().datafree; swig_owner.erase(iter); } } diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index c3e0b749b..151798579 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -14,7 +14,7 @@ #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) @@ -238,22 +238,24 @@ SWIG_Ruby_MangleStr(VALUE obj) } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0}; if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -270,7 +272,10 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership of the underlying C struct or C++ object. If so then we From 99b604518d00468e10ff8127d7b33d586b7e6cc0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 15 Sep 2015 03:05:42 +0200 Subject: [PATCH 118/732] Remove unused support for typemap scopes The functions Swig_typemap_new_scope() and Swig_typemap_pop_scope() introduced by 503746e964f545dccaf7b05cd8c4041049b2c409 back in 2000 were never used and ended up being commented out themselves, but support for typemap scopes still remain in several other functions. Remove it completely to make the code simpler without any ill effects. --- Source/Swig/swig.h | 2 - Source/Swig/typemap.c | 372 ++++++++++++++++++------------------------ 2 files changed, 157 insertions(+), 217 deletions(-) diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 5ee7f8d95..becae9456 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -409,8 +409,6 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f); extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode); - extern void Swig_typemap_new_scope(void); - extern Hash *Swig_typemap_pop_scope(void); extern void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *parms, Wrapper *f); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 4c6530061..ab2a8c0df 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -59,13 +59,9 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper * * ----------------------------------------------------------------------------- */ -#define MAX_SCOPE 32 +static Hash *typemaps; - -static Hash *typemaps[MAX_SCOPE]; -static int tm_scope = 0; - -static Hash *get_typemap(int tm_scope, const SwigType *type) { +static Hash *get_typemap(const SwigType *type) { Hash *tm = 0; SwigType *dtype = 0; SwigType *hashtype; @@ -79,7 +75,7 @@ static Hash *get_typemap(int tm_scope, const SwigType *type) { /* remove unary scope operator (::) prefix indicating global scope for looking up in the hashmap */ hashtype = SwigType_remove_global_scope_prefix(type); - tm = Getattr(typemaps[tm_scope], hashtype); + tm = Getattr(typemaps, hashtype); Delete(dtype); Delete(hashtype); @@ -87,7 +83,7 @@ static Hash *get_typemap(int tm_scope, const SwigType *type) { return tm; } -static void set_typemap(int tm_scope, const SwigType *type, Hash **tmhash) { +static void set_typemap(const SwigType *type, Hash **tmhash) { SwigType *hashtype = 0; Hash *new_tm = 0; assert(*tmhash == 0); @@ -96,7 +92,7 @@ static void set_typemap(int tm_scope, const SwigType *type, Hash **tmhash) { String *ty = Swig_symbol_template_deftype(rty, 0); String *tyq = Swig_symbol_type_qualify(ty, 0); hashtype = SwigType_remove_global_scope_prefix(tyq); - *tmhash = Getattr(typemaps[tm_scope], hashtype); + *tmhash = Getattr(typemaps, hashtype); Delete(rty); Delete(tyq); Delete(ty); @@ -111,7 +107,7 @@ static void set_typemap(int tm_scope, const SwigType *type, Hash **tmhash) { } /* note that the unary scope operator (::) prefix indicating global scope has been removed from the type */ - Setattr(typemaps[tm_scope], hashtype, *tmhash); + Setattr(typemaps, hashtype, *tmhash); Delete(hashtype); Delete(new_tm); @@ -125,12 +121,7 @@ static void set_typemap(int tm_scope, const SwigType *type, Hash **tmhash) { * ----------------------------------------------------------------------------- */ void Swig_typemap_init() { - int i; - for (i = 0; i < MAX_SCOPE; i++) { - typemaps[i] = 0; - } - typemaps[0] = NewHash(); - tm_scope = 0; + typemaps = NewHash(); } static String *typemap_method_name(const_String_or_char_ptr tmap_method) { @@ -160,32 +151,6 @@ static String *typemap_method_name(const_String_or_char_ptr tmap_method) { return s; } -#if 0 -/* ----------------------------------------------------------------------------- - * Swig_typemap_new_scope() - * - * Create a new typemap scope - * ----------------------------------------------------------------------------- */ - -void Swig_typemap_new_scope() { - tm_scope++; - typemaps[tm_scope] = NewHash(); -} - -/* ----------------------------------------------------------------------------- - * Swig_typemap_pop_scope() - * - * Pop the last typemap scope off - * ----------------------------------------------------------------------------- */ - -Hash *Swig_typemap_pop_scope() { - if (tm_scope > 0) { - return typemaps[tm_scope--]; - } - return 0; -} -#endif - /* ----------------------------------------------------------------------------- * typemap_register() * @@ -216,9 +181,9 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par pname = Getattr(parms, "name"); /* See if this type has been seen before */ - tm = get_typemap(tm_scope, type); + tm = get_typemap(type); if (!tm) { - set_typemap(tm_scope, type, &tm); + set_typemap(type, &tm); } if (pname) { /* See if parameter has been seen before */ @@ -311,15 +276,12 @@ void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms /* ----------------------------------------------------------------------------- * typemap_get() * - * Retrieve typemap information from current scope. + * Retrieve typemap information. * ----------------------------------------------------------------------------- */ -static Hash *typemap_get(SwigType *type, const_String_or_char_ptr name, int scope) { +static Hash *typemap_get(SwigType *type, const_String_or_char_ptr name) { Hash *tm, *tm1; - /* See if this type has been seen before */ - if ((scope < 0) || (scope > tm_scope)) - return 0; - tm = get_typemap(scope, type); + tm = get_typemap(type); if (!tm) { return 0; } @@ -342,51 +304,48 @@ int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcparms, Parm *p; String *pname; SwigType *ptype; - int ts = tm_scope; String *tm_methods, *multi_tmap_method; if (ParmList_len(parms) != ParmList_len(srcparms)) return -1; tm_method = typemap_method_name(tmap_method); - while (ts >= 0) { - p = srcparms; - tm_methods = NewString(tm_method); - while (p) { - ptype = Getattr(p, "type"); - pname = Getattr(p, "name"); + p = srcparms; + tm_methods = NewString(tm_method); + while (p) { + ptype = Getattr(p, "type"); + pname = Getattr(p, "name"); - /* Lookup the type */ - tm = typemap_get(ptype, pname, ts); - if (!tm) - break; + /* Lookup the type */ + tm = typemap_get(ptype, pname); + if (!tm) + break; - tm = Getattr(tm, tm_methods); - if (!tm) - break; + tm = Getattr(tm, tm_methods); + if (!tm) + break; - /* Got a match. Look for next typemap */ - multi_tmap_method = NewStringf("%s-%s+%s:", tm_methods, ptype, pname); - Delete(tm_methods); - tm_methods = multi_tmap_method; - p = nextSibling(p); - } + /* Got a match. Look for next typemap */ + multi_tmap_method = NewStringf("%s-%s+%s:", tm_methods, ptype, pname); Delete(tm_methods); - - if (!p && tm) { - /* Got some kind of match */ - String *parms_str = ParmList_str_multibrackets(parms); - String *srcparms_str = ParmList_str_multibrackets(srcparms); - String *source_directive = NewStringf("typemap(%s) %s = %s", tmap_method, parms_str, srcparms_str); - - typemap_register(tmap_method, parms, Getattr(tm, "code"), Getattr(tm, "locals"), Getattr(tm, "kwargs"), source_directive); - - Delete(source_directive); - Delete(srcparms_str); - Delete(parms_str); - return 0; - } - ts--; + tm_methods = multi_tmap_method; + p = nextSibling(p); } + Delete(tm_methods); + + if (!p && tm) { + /* Got some kind of match */ + String *parms_str = ParmList_str_multibrackets(parms); + String *srcparms_str = ParmList_str_multibrackets(srcparms); + String *source_directive = NewStringf("typemap(%s) %s = %s", tmap_method, parms_str, srcparms_str); + + typemap_register(tmap_method, parms, Getattr(tm, "code"), Getattr(tm, "locals"), Getattr(tm, "kwargs"), source_directive); + + Delete(source_directive); + Delete(srcparms_str); + Delete(parms_str); + return 0; + } + /* Not found */ return -1; @@ -411,7 +370,7 @@ void Swig_typemap_clear(const_String_or_char_ptr tmap_method, ParmList *parms) { while (p) { type = Getattr(p, "type"); name = Getattr(p, "name"); - tm = typemap_get(type, name, tm_scope); + tm = typemap_get(type, name); if (!tm) return; p = nextSibling(p); @@ -452,7 +411,6 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) { String *ssig, *dsig; Parm *p, *np, *lastp, *dp, *lastdp = 0; int narg = 0; - int ts = tm_scope; SwigType *type = 0, *name; Hash *tm, *sm; int match = 0; @@ -480,9 +438,9 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) { /* make sure a typemap node exists for the last destination node */ type = Getattr(lastdp, "type"); - tm = get_typemap(tm_scope, type); + tm = get_typemap(type); if (!tm) { - set_typemap(tm_scope, type, &tm); + set_typemap(type, &tm); } name = Getattr(lastdp, "name"); if (name) { @@ -501,69 +459,65 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) { type = Getattr(lastp, "type"); name = Getattr(lastp, "name"); - while (ts >= 0) { + /* See if there is a matching typemap in this scope */ + sm = typemap_get(type, name); - /* See if there is a matching typemap in this scope */ - sm = typemap_get(type, name, ts); + /* if there is not matching, look for a typemap in the + original typedef, if any, like in: - /* if there is not matching, look for a typemap in the - original typedef, if any, like in: - - typedef unsigned long size_t; - ... - %apply(size_t) {my_size}; ==> %apply(unsigned long) {my_size}; - */ - if (!sm) { - SwigType *ntype = SwigType_typedef_resolve(type); - if (ntype && (Cmp(ntype, type) != 0)) { - sm = typemap_get(ntype, name, ts); - } - Delete(ntype); + typedef unsigned long size_t; + ... + %apply(size_t) {my_size}; ==> %apply(unsigned long) {my_size}; + */ + if (!sm) { + SwigType *ntype = SwigType_typedef_resolve(type); + if (ntype && (Cmp(ntype, type) != 0)) { + sm = typemap_get(ntype, name); } + Delete(ntype); + } - if (sm) { - /* Got a typemap. Need to only merge attributes for methods that match our signature */ - Iterator ki; - match = 1; - for (ki = First(sm); ki.key; ki = Next(ki)) { - /* Check for a signature match with the source signature */ - if ((count_args(ki.key) == narg) && (Strstr(ki.key, ssig))) { - String *oldm; - /* A typemap we have to copy */ - String *nkey = Copy(ki.key); - Replace(nkey, ssig, dsig, DOH_REPLACE_ANY); + if (sm) { + /* Got a typemap. Need to only merge attributes for methods that match our signature */ + Iterator ki; + match = 1; + for (ki = First(sm); ki.key; ki = Next(ki)) { + /* Check for a signature match with the source signature */ + if ((count_args(ki.key) == narg) && (Strstr(ki.key, ssig))) { + String *oldm; + /* A typemap we have to copy */ + String *nkey = Copy(ki.key); + Replace(nkey, ssig, dsig, DOH_REPLACE_ANY); - /* Make sure the typemap doesn't already exist in the target map */ + /* Make sure the typemap doesn't already exist in the target map */ - oldm = Getattr(tm, nkey); - if (!oldm || (!Getattr(tm, "code"))) { - String *code; - ParmList *locals; - ParmList *kwargs; - Hash *sm1 = ki.item; + oldm = Getattr(tm, nkey); + if (!oldm || (!Getattr(tm, "code"))) { + String *code; + ParmList *locals; + ParmList *kwargs; + Hash *sm1 = ki.item; - code = Getattr(sm1, "code"); - locals = Getattr(sm1, "locals"); - kwargs = Getattr(sm1, "kwargs"); - if (code) { - String *src_str = ParmList_str_multibrackets(src); - String *dest_str = ParmList_str_multibrackets(dest); - String *source_directive = NewStringf("apply %s { %s }", src_str, dest_str); + code = Getattr(sm1, "code"); + locals = Getattr(sm1, "locals"); + kwargs = Getattr(sm1, "kwargs"); + if (code) { + String *src_str = ParmList_str_multibrackets(src); + String *dest_str = ParmList_str_multibrackets(dest); + String *source_directive = NewStringf("apply %s { %s }", src_str, dest_str); - Replace(nkey, dsig, "", DOH_REPLACE_ANY); - Replace(nkey, "tmap:", "", DOH_REPLACE_ANY); - typemap_register(nkey, dest, code, locals, kwargs, source_directive); + Replace(nkey, dsig, "", DOH_REPLACE_ANY); + Replace(nkey, "tmap:", "", DOH_REPLACE_ANY); + typemap_register(nkey, dest, code, locals, kwargs, source_directive); - Delete(source_directive); - Delete(dest_str); - Delete(src_str); - } + Delete(source_directive); + Delete(dest_str); + Delete(src_str); } - Delete(nkey); } + Delete(nkey); } } - ts--; } Delete(ssig); Delete(dsig); @@ -597,7 +551,7 @@ void Swig_typemap_clear_apply(Parm *parms) { } p = np; } - tm = get_typemap(tm_scope, Getattr(lastp, "type")); + tm = get_typemap(Getattr(lastp, "type")); if (!tm) { Delete(tsig); return; @@ -711,7 +665,6 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type SwigType *primitive = 0; SwigType *ctype = 0; SwigType *ctype_unstripped = 0; - int ts; int isarray; const String *cname = 0; const String *cqualifiedname = 0; @@ -722,90 +675,86 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type cname = name; if ((qualifiedname) && Len(qualifiedname)) cqualifiedname = qualifiedname; - ts = tm_scope; if (debug_display) { String *typestr = SwigType_str(type, cqualifiedname ? cqualifiedname : cname); Swig_diagnostic(Getfile(node), Getline(node), "Searching for a suitable '%s' typemap for: %s\n", tmap_method, typestr); Delete(typestr); } - while (ts >= 0) { - ctype = Copy(type); - ctype_unstripped = Copy(ctype); - while (ctype) { - /* Try to get an exact type-match */ - tm = get_typemap(ts, ctype); - result = typemap_search_helper(debug_display, tm, tm_method, ctype, cqualifiedname, cname, &backup); - if (result && Getattr(result, "code")) - goto ret_result; + ctype = Copy(type); + ctype_unstripped = Copy(ctype); + while (ctype) { + /* Try to get an exact type-match */ + tm = get_typemap(ctype); + result = typemap_search_helper(debug_display, tm, tm_method, ctype, cqualifiedname, cname, &backup); + if (result && Getattr(result, "code")) + goto ret_result; - { - /* Look for the type reduced to just the template prefix - for templated types without the template parameter list being specified */ - SwigType *template_prefix = SwigType_istemplate_only_templateprefix(ctype); - if (template_prefix) { - tm = get_typemap(ts, template_prefix); - result = typemap_search_helper(debug_display, tm, tm_method, template_prefix, cqualifiedname, cname, &backup); - Delete(template_prefix); - if (result && Getattr(result, "code")) - goto ret_result; - } - } - - /* look for [ANY] arrays */ - isarray = SwigType_isarray(ctype); - if (isarray) { - /* If working with arrays, strip away all of the dimensions and replace with "ANY". - See if that generates a match */ - SwigType *noarrays = strip_arrays(ctype); - tm = get_typemap(ts, noarrays); - result = typemap_search_helper(debug_display, tm, tm_method, noarrays, cqualifiedname, cname, &backup); - Delete(noarrays); + { + /* Look for the type reduced to just the template prefix - for templated types without the template parameter list being specified */ + SwigType *template_prefix = SwigType_istemplate_only_templateprefix(ctype); + if (template_prefix) { + tm = get_typemap(template_prefix); + result = typemap_search_helper(debug_display, tm, tm_method, template_prefix, cqualifiedname, cname, &backup); + Delete(template_prefix); if (result && Getattr(result, "code")) goto ret_result; } - - /* No match so far - try with a qualifier stripped (strip one qualifier at a time until none remain) - * The order of stripping in SwigType_strip_single_qualifier is used to provide some sort of consistency - * with the default (SWIGTYPE) typemap matching rules for the first qualifier to be stripped. */ - { - SwigType *oldctype = ctype; - ctype = SwigType_strip_single_qualifier(oldctype); - if (!Equal(ctype, oldctype)) { - Delete(oldctype); - continue; - } - Delete(oldctype); - } - - /* Once all qualifiers are stripped try resolve a typedef */ - { - SwigType *oldctype = ctype; - ctype = SwigType_typedef_resolve(ctype_unstripped); - Delete(oldctype); - ctype_unstripped = Copy(ctype); - } } - /* Hmmm. Well, no match seems to be found at all. See if there is some kind of default (SWIGTYPE) mapping */ - - primitive = SwigType_default_create(type); - while (primitive) { - tm = get_typemap(ts, primitive); - result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup); + /* look for [ANY] arrays */ + isarray = SwigType_isarray(ctype); + if (isarray) { + /* If working with arrays, strip away all of the dimensions and replace with "ANY". + See if that generates a match */ + SwigType *noarrays = strip_arrays(ctype); + tm = get_typemap(noarrays); + result = typemap_search_helper(debug_display, tm, tm_method, noarrays, cqualifiedname, cname, &backup); + Delete(noarrays); if (result && Getattr(result, "code")) goto ret_result; + } - { - SwigType *nprim = SwigType_default_deduce(primitive); - Delete(primitive); - primitive = nprim; + /* No match so far - try with a qualifier stripped (strip one qualifier at a time until none remain) + * The order of stripping in SwigType_strip_single_qualifier is used to provide some sort of consistency + * with the default (SWIGTYPE) typemap matching rules for the first qualifier to be stripped. */ + { + SwigType *oldctype = ctype; + ctype = SwigType_strip_single_qualifier(oldctype); + if (!Equal(ctype, oldctype)) { + Delete(oldctype); + continue; } + Delete(oldctype); } - if (ctype != type) { - Delete(ctype); - ctype = 0; + + /* Once all qualifiers are stripped try resolve a typedef */ + { + SwigType *oldctype = ctype; + ctype = SwigType_typedef_resolve(ctype_unstripped); + Delete(oldctype); + ctype_unstripped = Copy(ctype); } - ts--; /* Hmmm. Nothing found in this scope. Guess we'll go try another scope */ + } + + /* Hmmm. Well, no match seems to be found at all. See if there is some kind of default (SWIGTYPE) mapping */ + + primitive = SwigType_default_create(type); + while (primitive) { + tm = get_typemap(primitive); + result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup); + if (result && Getattr(result, "code")) + goto ret_result; + + { + SwigType *nprim = SwigType_default_deduce(primitive); + Delete(primitive); + primitive = nprim; + } + } + if (ctype != type) { + Delete(ctype); + ctype = 0; } result = backup; @@ -2110,16 +2059,9 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper * ----------------------------------------------------------------------------- */ void Swig_typemap_debug() { - int ts; int nesting_level = 2; Printf(stdout, "---[ typemaps ]--------------------------------------------------------------\n"); - - ts = tm_scope; - while (ts >= 0) { - Printf(stdout, "::: scope %d\n\n", ts); - Swig_print(typemaps[ts], nesting_level); - ts--; - } + Swig_print(typemaps, nesting_level); Printf(stdout, "-----------------------------------------------------------------------------\n"); } From 4677dbb7963f17ab046dcfa9be091f69168de990 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 13 Sep 2015 09:22:48 +0100 Subject: [PATCH 119/732] Add Ruby shared_ptr typemaps --- Lib/ruby/boost_shared_ptr.i | 321 ++++++++++++++++++++++++++++++++++++ Lib/ruby/std_shared_ptr.i | 2 + 2 files changed, 323 insertions(+) create mode 100644 Lib/ruby/boost_shared_ptr.i create mode 100644 Lib/ruby/std_shared_ptr.i diff --git a/Lib/ruby/boost_shared_ptr.i b/Lib/ruby/boost_shared_ptr.i new file mode 100644 index 000000000..8e3c0a13f --- /dev/null +++ b/Lib/ruby/boost_shared_ptr.i @@ -0,0 +1,321 @@ +%include + +// Set SHARED_PTR_DISOWN to $disown if required, for example +// #define SHARED_PTR_DISOWN $disown +#if !defined(SHARED_PTR_DISOWN) +#define SHARED_PTR_DISOWN 0 +#endif + +%fragment("SWIG_null_deleter_python", "header", fragment="SWIG_null_deleter") { +%#define SWIG_NO_NULL_DELETER_SWIG_BUILTIN_INIT +} + +// Language specific macro implementing all the customisations for handling the smart pointer +%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) + +// %naturalvar is as documented for member variables +%naturalvar TYPE; +%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; + +// destructor wrapper customisation +%feature("unref") TYPE + %{(void)arg1; + delete reinterpret_cast< SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > * >(self);%} + +// Typemap customisations... + +// plain value +%typemap(in) CONST TYPE (void *argp, int res = 0) { + swig_ruby_owntype newmem = {0}; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (!argp) { + %argument_nullref("$type", $symname, $argnum); + } else { + $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); + if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + } +} +%typemap(out) CONST TYPE { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +%typemap(varin) CONST TYPE { + void *argp = 0; + swig_ruby_owntype newmem = {0}; + int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + if (!argp) { + %argument_nullref("$type", $symname, $argnum); + } else { + $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); + if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + } +} +%typemap(varout) CONST TYPE { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); + %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// plain pointer +// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance +%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { + swig_ruby_owntype newmem = {0}; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (newmem.own & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast(tempshared.get(), $1_ltype); + } else { + smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); + } +} + +%typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE * { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); +} + +%typemap(varin) CONST TYPE * { + void *argp = 0; + swig_ruby_owntype newmem = {0}; + int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0; + if (newmem.own & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast(tempshared.get(), $1_ltype); + } else { + smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); + } +} +%typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE * { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; + %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// plain reference +%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { + swig_ruby_owntype newmem = {0}; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (!argp) { %argument_nullref("$type", $symname, $argnum); } + if (newmem.own & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast(tempshared.get(), $1_ltype); + } else { + $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); + } +} +%typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE & { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +%typemap(varin) CONST TYPE & { + void *argp = 0; + swig_ruby_owntype newmem = {0}; + int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; + if (!argp) { %argument_nullref("$type", $symname, $argnum); } + if (newmem.own & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = *%const_cast(tempshared.get(), $1_ltype); + } else { + $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); + } +} +%typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE & { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0); + %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// plain pointer by reference +// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance +%typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { + swig_ruby_owntype newmem = {0}; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (newmem.own & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + temp = %const_cast(tempshared.get(), $*1_ltype); + } else { + temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype); + } + $1 = &temp; +} +%typemap(out, fragment="SWIG_null_deleter_python") TYPE *CONST& { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +%typemap(varin) TYPE *CONST& %{ +#error "varin typemap not implemented" +%} +%typemap(varout) TYPE *CONST& %{ +#error "varout typemap not implemented" +%} + +// shared_ptr by value +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { + swig_ruby_owntype newmem = {0}; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); + if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); +} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + swig_ruby_owntype newmem = {0}; + void *argp = 0; + int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >(); + if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); +} +%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; + %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// shared_ptr by reference +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { + swig_ruby_owntype newmem = {0}; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (newmem.own & SWIG_CAST_NEW_MEMORY) { + if (argp) tempshared = *%reinterpret_cast(argp, $ltype); + delete %reinterpret_cast(argp, $ltype); + $1 = &tempshared; + } else { + $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; + } +} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ +#error "varin typemap not implemented" +%} +%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ +#error "varout typemap not implemented" +%} + +// shared_ptr by pointer +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { + swig_ruby_owntype newmem = {0}; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (newmem.own & SWIG_CAST_NEW_MEMORY) { + if (argp) tempshared = *%reinterpret_cast(argp, $ltype); + delete %reinterpret_cast(argp, $ltype); + $1 = &tempshared; + } else { + $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; + } +} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); + if ($owner) delete $1; +} + +%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ +#error "varin typemap not implemented" +%} +%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ +#error "varout typemap not implemented" +%} + +// shared_ptr by pointer reference +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { + swig_ruby_owntype newmem = {0}; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); + if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); + temp = &tempshared; + $1 = &temp; +} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ +#error "varin typemap not implemented" +%} +%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ +#error "varout typemap not implemented" +%} + +// Typecheck typemaps +// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting +// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) + TYPE CONST, + TYPE CONST &, + TYPE CONST *, + TYPE *CONST&, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { + int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0); + $1 = SWIG_CheckState(res); +} + + +// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug +%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} +%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} + + +%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; + + +%enddef diff --git a/Lib/ruby/std_shared_ptr.i b/Lib/ruby/std_shared_ptr.i new file mode 100644 index 000000000..df873679c --- /dev/null +++ b/Lib/ruby/std_shared_ptr.i @@ -0,0 +1,2 @@ +#define SWIG_SHARED_PTR_NAMESPACE std +%include From faeaacf112fefdd0b23d397b1933733d51c473c9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Sep 2015 19:36:48 +0100 Subject: [PATCH 120/732] smartptr feature support - factor out common code --- Source/CParse/cparse.h | 1 + Source/CParse/util.c | 22 ++++++++++++++ Source/Modules/csharp.cxx | 46 +++++++++++++---------------- Source/Modules/d.cxx | 55 ++++++++++++++--------------------- Source/Modules/java.cxx | 58 +++++++++++++++++-------------------- Source/Modules/octave.cxx | 19 +++--------- Source/Modules/python.cxx | 23 ++++----------- Source/Modules/typepass.cxx | 11 ++----- 8 files changed, 103 insertions(+), 132 deletions(-) diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h index 84a486fb7..ab5f74b19 100644 --- a/Source/CParse/cparse.h +++ b/Source/CParse/cparse.h @@ -57,6 +57,7 @@ extern "C" { /* util.c */ extern void Swig_cparse_replace_descriptor(String *s); + extern SwigType *Swig_cparse_smartptr(Node *n); extern void cparse_normalize_void(Node *); extern Parm *Swig_cparse_parm(String *s); extern ParmList *Swig_cparse_parms(String *s, Node *file_line_node); diff --git a/Source/CParse/util.c b/Source/CParse/util.c index 320671d9a..0e2136a49 100644 --- a/Source/CParse/util.c +++ b/Source/CParse/util.c @@ -70,6 +70,28 @@ void Swig_cparse_replace_descriptor(String *s) { } } +/* ----------------------------------------------------------------------------- + * Swig_cparse_smartptr() + * + * Parse the type in smartptr feature and convert into a SwigType. + * Error out if the parsing fails as this is like a parser syntax error. + * ----------------------------------------------------------------------------- */ + +SwigType *Swig_cparse_smartptr(Node *n) { + SwigType *smart = 0; + String *smartptr = Getattr(n, "feature:smartptr"); + if (smartptr) { + SwigType *cpt = Swig_cparse_type(smartptr); + if (cpt) { + smart = SwigType_typedef_resolve_all(cpt); + Delete(cpt); + } else { + Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, SwigType_namestr(Getattr(n, "name"))); + } + } + return smart; +} + /* ----------------------------------------------------------------------------- * cparse_normalize_void() * diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 9193cd34b..baed0c260 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1854,8 +1854,8 @@ public: // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy) if (derived) { - String *smartptr = Getattr(n, "feature:smartptr"); - String *upcast_method = Swig_name_member(getNSpace(), getClassPrefix(), smartptr != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast"); + SwigType *smart = Swig_cparse_smartptr(n); + String *upcast_method = Swig_name_member(getNSpace(), getClassPrefix(), smart != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast"); String *wname = Swig_name_wrapper(upcast_method); Printv(imclass_cppcasts_code, "\n [global::System.Runtime.InteropServices.DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); @@ -1863,29 +1863,22 @@ public: Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); - if (smartptr) { - SwigType *spt = Swig_cparse_type(smartptr); - if (spt) { - SwigType *smart = SwigType_typedef_resolve_all(spt); - Delete(spt); - SwigType *bsmart = Copy(smart); - SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); - SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); - Replaceall(bsmart, rclassname, rbaseclass); - Delete(rclassname); - Delete(rbaseclass); - String *smartnamestr = SwigType_namestr(smart); - String *bsmartnamestr = SwigType_namestr(bsmart); - Printv(upcasts_code, - "SWIGEXPORT ", bsmartnamestr, " * SWIGSTDCALL ", wname, "(", smartnamestr, " *jarg1) {\n", - " return jarg1 ? new ", bsmartnamestr, "(*jarg1) : 0;\n" - "}\n", "\n", NIL); - Delete(bsmartnamestr); - Delete(smartnamestr); - Delete(bsmart); - } else { - Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, c_classname); - } + if (smart) { + SwigType *bsmart = Copy(smart); + SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); + SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); + Replaceall(bsmart, rclassname, rbaseclass); + Delete(rclassname); + Delete(rbaseclass); + String *smartnamestr = SwigType_namestr(smart); + String *bsmartnamestr = SwigType_namestr(bsmart); + Printv(upcasts_code, + "SWIGEXPORT ", bsmartnamestr, " * SWIGSTDCALL ", wname, "(", smartnamestr, " *jarg1) {\n", + " return jarg1 ? new ", bsmartnamestr, "(*jarg1) : 0;\n" + "}\n", "\n", NIL); + Delete(bsmartnamestr); + Delete(smartnamestr); + Delete(bsmart); } else { Printv(upcasts_code, "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n", @@ -1894,6 +1887,7 @@ public: } Delete(wname); Delete(upcast_method); + Delete(smart); } Delete(baseclass); } @@ -3469,7 +3463,7 @@ public: Wrapper *code_wrap = NewWrapper(); Printf(code_wrap->def, "SWIGEXPORT void SWIGSTDCALL %s(void *objarg", wname); - if (Len(smartptr)) { + if (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"); diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 8b0bdded1..267dd8c03 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -3329,45 +3329,33 @@ private: /* --------------------------------------------------------------------------- * D::writeClassUpcast() * --------------------------------------------------------------------------- */ - void writeClassUpcast(Node *n, const String* d_class_name, - String* c_class_name, String* c_base_name) { - - String *smartptr = Getattr(n, "feature:smartptr"); - String *upcast_name = Swig_name_member(getNSpace(), d_class_name, - (smartptr != 0 ? "SmartPtrUpcast" : "Upcast")); + void writeClassUpcast(Node *n, const String* d_class_name, String* c_class_name, String* c_base_name) { + SwigType *smart = Swig_cparse_smartptr(n); + String *upcast_name = Swig_name_member(getNSpace(), d_class_name, (smart != 0 ? "SmartPtrUpcast" : "Upcast")); String *upcast_wrapper_name = Swig_name_wrapper(upcast_name); writeImDModuleFunction(upcast_name, "void*", "(void* objectRef)", upcast_wrapper_name); - if (smartptr) { - SwigType *spt = Swig_cparse_type(smartptr); - if (spt) { - SwigType *smart = SwigType_typedef_resolve_all(spt); - Delete(spt); - SwigType *bsmart = Copy(smart); - SwigType *rclassname = SwigType_typedef_resolve_all(c_class_name); - SwigType *rbaseclass = SwigType_typedef_resolve_all(c_base_name); - Replaceall(bsmart, rclassname, rbaseclass); - Delete(rclassname); - Delete(rbaseclass); - String *smartnamestr = SwigType_namestr(smart); - String *bsmartnamestr = SwigType_namestr(bsmart); - Printv(upcasts_code, - "SWIGEXPORT ", bsmartnamestr, " * ", upcast_wrapper_name, - "(", smartnamestr, " *objectRef) {\n", - " return objectRef ? new ", bsmartnamestr, "(*objectRef) : 0;\n" - "}\n", - "\n", NIL); - Delete(bsmartnamestr); - Delete(smartnamestr); - Delete(bsmart); - } else { - Swig_error(Getfile(n), Getline(n), - "Invalid type (%s) in 'smartptr' feature for class %s.\n", - smartptr, c_class_name); - } + if (smart) { + SwigType *bsmart = Copy(smart); + SwigType *rclassname = SwigType_typedef_resolve_all(c_class_name); + SwigType *rbaseclass = SwigType_typedef_resolve_all(c_base_name); + Replaceall(bsmart, rclassname, rbaseclass); + Delete(rclassname); + Delete(rbaseclass); + String *smartnamestr = SwigType_namestr(smart); + String *bsmartnamestr = SwigType_namestr(bsmart); + Printv(upcasts_code, + "SWIGEXPORT ", bsmartnamestr, " * ", upcast_wrapper_name, + "(", smartnamestr, " *objectRef) {\n", + " return objectRef ? new ", bsmartnamestr, "(*objectRef) : 0;\n" + "}\n", + "\n", NIL); + Delete(bsmartnamestr); + Delete(smartnamestr); + Delete(bsmart); } else { Printv(upcasts_code, "SWIGEXPORT ", c_base_name, " * ", upcast_wrapper_name, @@ -3382,6 +3370,7 @@ private: Delete(upcast_name); Delete(upcast_wrapper_name); + Delete(smart); } /* --------------------------------------------------------------------------- diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 0109bf41a..636189989 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1875,40 +1875,33 @@ public: // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy) if (derived) { - String *smartptr = Getattr(n, "feature:smartptr"); - String *upcast_method = Swig_name_member(getNSpace(), getClassPrefix(), smartptr != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast"); + SwigType *smart = Swig_cparse_smartptr(n); + String *upcast_method = Swig_name_member(getNSpace(), getClassPrefix(), smart != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast"); String *jniname = makeValidJniName(upcast_method); String *wname = Swig_name_wrapper(jniname); Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method); - if (smartptr) { - SwigType *spt = Swig_cparse_type(smartptr); - if (spt) { - SwigType *smart = SwigType_typedef_resolve_all(spt); - Delete(spt); - SwigType *bsmart = Copy(smart); - SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); - SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); - Replaceall(bsmart, rclassname, rbaseclass); - Delete(rclassname); - Delete(rbaseclass); - String *smartnamestr = SwigType_namestr(smart); - String *bsmartnamestr = SwigType_namestr(bsmart); - Printv(upcasts_code, - "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", - " jlong baseptr = 0;\n" - " ", smartnamestr, " *argp1;\n" - " (void)jenv;\n" - " (void)jcls;\n" - " argp1 = *(", smartnamestr, " **)&jarg1;\n" - " *(", bsmartnamestr, " **)&baseptr = argp1 ? new ", bsmartnamestr, "(*argp1) : 0;\n" - " return baseptr;\n" - "}\n", "\n", NIL); - Delete(bsmartnamestr); - Delete(smartnamestr); - Delete(bsmart); - } else { - Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, c_classname); - } + if (smart) { + SwigType *bsmart = Copy(smart); + SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); + SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); + Replaceall(bsmart, rclassname, rbaseclass); + Delete(rclassname); + Delete(rbaseclass); + String *smartnamestr = SwigType_namestr(smart); + String *bsmartnamestr = SwigType_namestr(bsmart); + Printv(upcasts_code, + "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", + " jlong baseptr = 0;\n" + " ", smartnamestr, " *argp1;\n" + " (void)jenv;\n" + " (void)jcls;\n" + " argp1 = *(", smartnamestr, " **)&jarg1;\n" + " *(", bsmartnamestr, " **)&baseptr = argp1 ? new ", bsmartnamestr, "(*argp1) : 0;\n" + " return baseptr;\n" + "}\n", "\n", NIL); + Delete(bsmartnamestr); + Delete(smartnamestr); + Delete(bsmart); } else { Printv(upcasts_code, "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", @@ -1922,6 +1915,7 @@ public: Delete(wname); Delete(jniname); Delete(upcast_method); + Delete(smart); } Delete(baseclass); } @@ -3486,7 +3480,7 @@ 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)) { + if (smartptr) { Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", smartptr, smartptr); Printf(code_wrap->code, " (void)jcls;\n"); Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n"); diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index e5f18cae8..0e3e16cbb 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -966,25 +966,13 @@ public: SwigType *t = Copy(Getattr(n, "name")); SwigType_add_pointer(t); - String *smartptr = Getattr(n, "feature:smartptr"); // Replace storing a pointer to underlying class with a smart pointer (intended for use with non-intrusive smart pointers) - SwigType *smart = 0; - if (smartptr) { - SwigType *cpt = Swig_cparse_type(smartptr); - if (cpt) { - smart = SwigType_typedef_resolve_all(cpt); - Delete(cpt); - } else { - // TODO: report line number of where the feature comes from - Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, class_name); - } - } + // Replace storing a pointer to underlying class with a smart pointer (intended for use with non-intrusive smart pointers) + SwigType *smart = Swig_cparse_smartptr(n); String *wrap_class = NewStringf("&_wrap_class_%s", class_name); - if(smart){ + if (smart) { SwigType_add_pointer(smart); SwigType_remember_clientdata(smart, wrap_class); } - Delete(smart); - Delete(smartptr); //String *wrap_class = NewStringf("&_wrap_class_%s", class_name); SwigType_remember_clientdata(t, wrap_class); @@ -1064,6 +1052,7 @@ public: Delete(base_class); Delete(base_class_names); + Delete(smart); Delete(t); Delete(s_members_tab); s_members_tab = 0; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index e0306d746..7bc565871 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4161,15 +4161,11 @@ public: Printf(clientdata, "&%s_clientdata", templ); SwigType_remember_mangleddata(pmname, clientdata); - String *smartptr = Getattr(n, "feature:smartptr"); - if (smartptr) { - SwigType *spt = Swig_cparse_type(smartptr); - SwigType *smart = SwigType_typedef_resolve_all(spt); + SwigType *smart = Swig_cparse_smartptr(n); + if (smart) { SwigType_add_pointer(smart); String *smart_pmname = SwigType_manglestr(smart); SwigType_remember_mangleddata(smart_pmname, clientdata); - Delete(spt); - Delete(smart); Delete(smart_pmname); } @@ -4195,6 +4191,7 @@ public: Printv(f_init, " d = md;\n", NIL); Delete(clientdata); + Delete(smart); Delete(rname); Delete(pname); Delete(mname); @@ -4392,18 +4389,8 @@ public: /* Complete the class */ if (shadow) { /* Generate a class registration function */ - String *smartptr = Getattr(n, "feature:smartptr"); // Replace storing a pointer to underlying class with a smart pointer (intended for use with non-intrusive smart pointers) - SwigType *smart = 0; - if (smartptr) { - SwigType *cpt = Swig_cparse_type(smartptr); - if (cpt) { - smart = SwigType_typedef_resolve_all(cpt); - Delete(cpt); - } else { - // TODO: report line number of where the feature comes from - Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, real_classname); - } - } + // Replace storing a pointer to underlying class with a smart pointer (intended for use with non-intrusive smart pointers) + SwigType *smart = Swig_cparse_smartptr(n); SwigType *ct = Copy(smart ? smart : real_classname); SwigType_add_pointer(ct); SwigType *realct = Copy(real_classname); diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index 3e323f910..2aa1b03e6 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -256,11 +256,8 @@ class TypePass:private Dispatcher { SwigType_inherit(clsname, bname, cast, 0); String *smartptr = Getattr(first, "feature:smartptr"); if (smartptr) { - SwigType *smart = 0; - SwigType *spt = Swig_cparse_type(smartptr); - if (spt) { - smart = SwigType_typedef_resolve_all(spt); - Delete(spt); + SwigType *smart = Swig_cparse_smartptr(first); + if (smart) { /* Record a (fake) inheritance relationship between smart pointer and smart pointer to base class, so that smart pointer upcasts are automatically generated. */ @@ -282,10 +279,8 @@ class TypePass:private Dispatcher { Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name"))); Delete(convcode); Delete(bsmart); - Delete(smart); - } else { - Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname)); } + Delete(smart); } else { if (GetFlag(bclass, "feature:smartptr")) Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name"))); From c482637167ee80c03771b93b0a1353731d23edb1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Sep 2015 07:18:39 +0100 Subject: [PATCH 121/732] Add Ruby shared_ptr support --- Source/Modules/ruby.cxx | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index f45010f6a..e44f0d214 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1830,10 +1830,19 @@ public: Wrapper_add_local(f, "classname", classname); } if (action) { - Printf(action, "\nDATA_PTR(self) = %s;", Swig_cresult_name()); - if (GetFlag(pn, "feature:trackobjects")) { - Printf(action, "\nSWIG_RubyAddTracking(%s, self);", Swig_cresult_name()); + SwigType *smart = Swig_cparse_smartptr(n); + String *result_name = NewStringf("%s%s", smart ? "smart" : "", Swig_cresult_name()); + if (smart) { + String *result_var = NewStringf("%s *%s = 0", SwigType_namestr(smart), result_name); + Wrapper_add_local(f, result_name, result_var); + Printf(action, "\n%s = new %s(%s);", result_name, SwigType_namestr(smart), Swig_cresult_name()); } + Printf(action, "\nDATA_PTR(self) = %s;", result_name); + if (GetFlag(pn, "feature:trackobjects")) { + Printf(action, "\nSWIG_RubyAddTracking(%s, self);", result_name); + } + Delete(result_name); + Delete(smart); } } @@ -1921,11 +1930,16 @@ public: /* Extra code needed for new and initialize methods */ if (current == CONSTRUCTOR_ALLOCATE) { + SwigType *smart = Swig_cparse_smartptr(n); + if (smart) + SwigType_add_pointer(smart); + String *classtype = smart ? smart : t; need_result = 1; - Printf(f->code, "VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE%s);\n", Char(SwigType_manglestr(t))); + Printf(f->code, "VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE%s);\n", Char(SwigType_manglestr(classtype))); Printf(f->code, "#ifndef HAVE_RB_DEFINE_ALLOC_FUNC\n"); Printf(f->code, "rb_obj_call_init(vresult, argc, argv);\n"); Printf(f->code, "#endif\n"); + Delete(smart); } else if (current == CONSTRUCTOR_INITIALIZE) { need_result = 1; } @@ -2431,11 +2445,17 @@ public: Printv(klass->init, "rb_include_module(", klass->mImpl, ", ", bmangle, ");\n", NIL); Delete(bmangle); } else { - String *bmangle = SwigType_manglestr(btype); + SwigType *smart = Swig_cparse_smartptr(base.item); + if (smart) { + SwigType_add_pointer(smart); + SwigType_remember(smart); + } + String *bmangle = SwigType_manglestr(smart ? smart : btype); Insert(bmangle, 0, "((swig_class *) SWIGTYPE"); Append(bmangle, "->clientdata)->klass"); Replaceall(klass->init, "$super", bmangle); Delete(bmangle); + Delete(smart); } Delete(btype); } @@ -2537,9 +2557,15 @@ public: SwigType *tt = NewString(name); SwigType_add_pointer(tt); SwigType_remember(tt); - String *tm = SwigType_manglestr(tt); + SwigType *smart = Swig_cparse_smartptr(n); + if (smart) { + SwigType_add_pointer(smart); + SwigType_remember(smart); + } + String *tm = SwigType_manglestr(smart ? smart : tt); Printf(klass->init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) &SwigClass%s);\n", tm, valid_name); Delete(tm); + Delete(smart); Delete(tt); Delete(valid_name); From fcb383b46b74df471491acdf3e9304147b4acf84 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 18 Sep 2015 07:48:51 +0100 Subject: [PATCH 122/732] shared_ptr typemap error message fix for global variables $argnum was not being expanded in the generated code Correct to use the error message from the standard typemaps --- Lib/octave/boost_shared_ptr.i | 6 ++++-- Lib/python/boost_shared_ptr.i | 6 ++++-- Lib/r/boost_shared_ptr.i | 6 ++++-- Lib/ruby/boost_shared_ptr.i | 6 ++++-- Lib/scilab/boost_shared_ptr.i | 6 ++++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Lib/octave/boost_shared_ptr.i b/Lib/octave/boost_shared_ptr.i index 052d48bb0..e91862057 100644 --- a/Lib/octave/boost_shared_ptr.i +++ b/Lib/octave/boost_shared_ptr.i @@ -41,7 +41,7 @@ %variable_fail(res, "$type", "$name"); } if (!argp) { - %argument_nullref("$type", $symname, $argnum); + %variable_nullref("$type", "$name"); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -126,7 +126,9 @@ %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; - if (!argp) { %argument_nullref("$type", $symname, $argnum); } + if (!argp) { + %variable_nullref("$type", "$name"); + } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); diff --git a/Lib/python/boost_shared_ptr.i b/Lib/python/boost_shared_ptr.i index 100ed3e82..40a1ae1ef 100644 --- a/Lib/python/boost_shared_ptr.i +++ b/Lib/python/boost_shared_ptr.i @@ -51,7 +51,7 @@ %variable_fail(res, "$type", "$name"); } if (!argp) { - %argument_nullref("$type", $symname, $argnum); + %variable_nullref("$type", "$name"); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -137,7 +137,9 @@ %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; - if (!argp) { %argument_nullref("$type", $symname, $argnum); } + if (!argp) { + %variable_nullref("$type", "$name"); + } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); diff --git a/Lib/r/boost_shared_ptr.i b/Lib/r/boost_shared_ptr.i index 17e9cfe8a..8ef8d2ef2 100644 --- a/Lib/r/boost_shared_ptr.i +++ b/Lib/r/boost_shared_ptr.i @@ -40,7 +40,7 @@ %variable_fail(res, "$type", "$name"); } if (!argp) { - %argument_nullref("$type", $symname, $argnum); + %variable_nullref("$type", "$name"); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -124,7 +124,9 @@ %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; - if (!argp) { %argument_nullref("$type", $symname, $argnum); } + if (!argp) { + %variable_nullref("$type", "$name"); + } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); diff --git a/Lib/ruby/boost_shared_ptr.i b/Lib/ruby/boost_shared_ptr.i index 8e3c0a13f..a58f0f828 100644 --- a/Lib/ruby/boost_shared_ptr.i +++ b/Lib/ruby/boost_shared_ptr.i @@ -51,7 +51,7 @@ %variable_fail(res, "$type", "$name"); } if (!argp) { - %argument_nullref("$type", $symname, $argnum); + %variable_nullref("$type", "$name"); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -137,7 +137,9 @@ %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; - if (!argp) { %argument_nullref("$type", $symname, $argnum); } + if (!argp) { + %variable_nullref("$type", "$name"); + } if (newmem.own & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); diff --git a/Lib/scilab/boost_shared_ptr.i b/Lib/scilab/boost_shared_ptr.i index 095b7fe43..b90422a66 100644 --- a/Lib/scilab/boost_shared_ptr.i +++ b/Lib/scilab/boost_shared_ptr.i @@ -47,7 +47,7 @@ %variable_fail(res, "$type", "$name"); } if (!argp) { - %argument_nullref("$type", $symname, $argnum); + %variable_nullref("$type", "$name"); } else { $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -133,7 +133,9 @@ %variable_fail(res, "$type", "$name"); } SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; - if (!argp) { %argument_nullref("$type", $symname, $argnum); } + if (!argp) { + %variable_nullref("$type", "$name"); + } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); From c089908f07d9a8bc8e9ef0d66fcf51625c149a47 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 18 Sep 2015 07:51:25 +0100 Subject: [PATCH 123/732] Turn on Ruby shared_ptr testing --- Examples/test-suite/director_smartptr.i | 2 +- Examples/test-suite/li_boost_shared_ptr.i | 2 +- Examples/test-suite/li_boost_shared_ptr_attribute.i | 2 +- Examples/test-suite/li_boost_shared_ptr_bits.i | 2 +- Examples/test-suite/li_boost_shared_ptr_template.i | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/director_smartptr.i b/Examples/test-suite/director_smartptr.i index 13eb745b6..058e2ca31 100644 --- a/Examples/test-suite/director_smartptr.i +++ b/Examples/test-suite/director_smartptr.i @@ -32,7 +32,7 @@ public: %} -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGRUBY) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i index 25ca6039b..4f86b5810 100644 --- a/Examples/test-suite/li_boost_shared_ptr.i +++ b/Examples/test-suite/li_boost_shared_ptr.i @@ -44,7 +44,7 @@ # define SWIG_SHARED_PTR_NAMESPACE SwigBoost #endif -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif diff --git a/Examples/test-suite/li_boost_shared_ptr_attribute.i b/Examples/test-suite/li_boost_shared_ptr_attribute.i index c4d3dca36..7a7679806 100644 --- a/Examples/test-suite/li_boost_shared_ptr_attribute.i +++ b/Examples/test-suite/li_boost_shared_ptr_attribute.i @@ -1,6 +1,6 @@ %module li_boost_shared_ptr_attribute -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGRUBY) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i index c0101b131..e35a3a3da 100644 --- a/Examples/test-suite/li_boost_shared_ptr_bits.i +++ b/Examples/test-suite/li_boost_shared_ptr_bits.i @@ -1,6 +1,6 @@ %module li_boost_shared_ptr_bits -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGRUBY) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif diff --git a/Examples/test-suite/li_boost_shared_ptr_template.i b/Examples/test-suite/li_boost_shared_ptr_template.i index c1cd32ec6..2ae8fbe66 100644 --- a/Examples/test-suite/li_boost_shared_ptr_template.i +++ b/Examples/test-suite/li_boost_shared_ptr_template.i @@ -29,7 +29,7 @@ %} -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGRUBY) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif From 155233bea6859fe45774be97a04a5bf967f88cfb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 18 Sep 2015 08:00:16 +0100 Subject: [PATCH 124/732] Turn on missing shared_ptr tests for Octave --- Examples/test-suite/director_smartptr.i | 2 +- Examples/test-suite/li_boost_shared_ptr_attribute.i | 2 +- Examples/test-suite/li_boost_shared_ptr_bits.i | 2 +- Examples/test-suite/li_boost_shared_ptr_template.i | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/director_smartptr.i b/Examples/test-suite/director_smartptr.i index 058e2ca31..bb44baaa1 100644 --- a/Examples/test-suite/director_smartptr.i +++ b/Examples/test-suite/director_smartptr.i @@ -32,7 +32,7 @@ public: %} -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGRUBY) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif diff --git a/Examples/test-suite/li_boost_shared_ptr_attribute.i b/Examples/test-suite/li_boost_shared_ptr_attribute.i index 7a7679806..f15baa693 100644 --- a/Examples/test-suite/li_boost_shared_ptr_attribute.i +++ b/Examples/test-suite/li_boost_shared_ptr_attribute.i @@ -1,6 +1,6 @@ %module li_boost_shared_ptr_attribute -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGRUBY) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i index e35a3a3da..34117a0c7 100644 --- a/Examples/test-suite/li_boost_shared_ptr_bits.i +++ b/Examples/test-suite/li_boost_shared_ptr_bits.i @@ -1,6 +1,6 @@ %module li_boost_shared_ptr_bits -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGRUBY) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif diff --git a/Examples/test-suite/li_boost_shared_ptr_template.i b/Examples/test-suite/li_boost_shared_ptr_template.i index 2ae8fbe66..f396b7ae0 100644 --- a/Examples/test-suite/li_boost_shared_ptr_template.i +++ b/Examples/test-suite/li_boost_shared_ptr_template.i @@ -29,7 +29,7 @@ %} -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGRUBY) +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY) #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif From 14e1c4728803dab5a4259eaffd1b31a3c880d590 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 23 Sep 2015 08:23:30 +0100 Subject: [PATCH 125/732] Fix Ruby smartptr feature for classes in a namespace --- Source/Modules/ruby.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index e44f0d214..bbb80c959 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1830,7 +1830,7 @@ public: Wrapper_add_local(f, "classname", classname); } if (action) { - SwigType *smart = Swig_cparse_smartptr(n); + SwigType *smart = Swig_cparse_smartptr(pn); String *result_name = NewStringf("%s%s", smart ? "smart" : "", Swig_cresult_name()); if (smart) { String *result_var = NewStringf("%s *%s = 0", SwigType_namestr(smart), result_name); @@ -1930,7 +1930,8 @@ public: /* Extra code needed for new and initialize methods */ if (current == CONSTRUCTOR_ALLOCATE) { - SwigType *smart = Swig_cparse_smartptr(n); + Node *pn = Swig_methodclass(n); + SwigType *smart = Swig_cparse_smartptr(pn); if (smart) SwigType_add_pointer(smart); String *classtype = smart ? smart : t; From 146252ff21c6137d455b231342cce0a938643ecc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 Sep 2015 19:06:12 +0100 Subject: [PATCH 126/732] SWIG_Ruby_ConvertPtrAndOwn changes for smartptr feature rb_obj_is_kind_of can no longer be used for type checking as the smartptr feature type, eg shared_ptr cannot be cast to a smartptr of the base class, eg shared_ptr. Previously Derived could be cast to Base as they were in an inheritance chain and the call to rb_define_class_under() used SWIGTYPE_p_Base->clientdata for all derived classes. Now SWIG_TypeCheck is always used. --- Lib/ruby/rubyrun.swg | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index 151798579..615d8ad38 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -263,7 +263,8 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; + if (ptr) + *ptr = 0; return SWIG_OK; } else { if (TYPE(obj) != T_DATA) { @@ -304,16 +305,6 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Do type-checking if type info was provided */ if (ty) { - if (ty->clientdata) { - if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) { - if (vptr == 0) { - /* The object has already been deleted */ - return SWIG_ObjectPreviouslyDeletedError; - } - *ptr = vptr; - return SWIG_OK; - } - } if ((c = SWIG_MangleStr(obj)) == NULL) { return SWIG_ERROR; } @@ -321,12 +312,27 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (vptr == 0) { + /* The object has already been deleted */ + return SWIG_ObjectPreviouslyDeletedError; + } + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; From 2506ccd4f4eb0aa43b5fd51a538848a1d7811622 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 Sep 2015 19:31:38 +0100 Subject: [PATCH 127/732] Add shared_ptr Ruby runtime test Reference count tests not quite complete yet - need to be sure of control of the garbage collector to test this reliably. --- .../ruby/li_boost_shared_ptr_runme.rb | 583 ++++++++++++++++++ 1 file changed, 583 insertions(+) create mode 100644 Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb diff --git a/Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb b/Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb new file mode 100644 index 000000000..8d3cba5e8 --- /dev/null +++ b/Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb @@ -0,0 +1,583 @@ +require 'li_boost_shared_ptr' + +debug = false + +# simple shared_ptr usage - created in C++ + + +class Li_boost_shared_ptr_runme + + def main(debug) + if (debug) + puts "Started" + end + + Li_boost_shared_ptr::debug_shared = debug + + # Change loop count to run for a long time to monitor memory + loopCount = 1 # 5000 + 1.upto(loopCount) do + self.runtest() + end + + # Expect 1 instance - the one global variable (GlobalValue) + if (Li_boost_shared_ptr::Klass.getTotal_count() != 1) +# raise RuntimeError, "Klass.total_count=#{Li_boost_shared_ptr::Klass.getTotal_count()}" + puts "Klass.total_count=#{Li_boost_shared_ptr::Klass.getTotal_count()}" + end + + wrapper_count = Li_boost_shared_ptr::shared_ptr_wrapper_count() + if (wrapper_count != Li_boost_shared_ptr.NOT_COUNTING) + # Expect 1 instance - the one global variable (GlobalSmartValue) + if (wrapper_count != 1) + raise RuntimeError, "shared_ptr wrapper count=#{wrapper_count}" + end + end + + if (debug) + puts "Finished" + end + end + + def runtest + # simple shared_ptr usage - created in C++ + k = Li_boost_shared_ptr::Klass.new("me oh my") + val = k.getValue() + self.verifyValue("me oh my", val) + self.verifyCount(1, k) + + # simple shared_ptr usage - not created in C++ + k = Li_boost_shared_ptr::factorycreate() + val = k.getValue() + self.verifyValue("factorycreate", val) + self.verifyCount(1, k) + + # pass by shared_ptr + k = Li_boost_shared_ptr::Klass.new("me oh my") + kret = Li_boost_shared_ptr::smartpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointertest", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by shared_ptr pointer + k = Li_boost_shared_ptr::Klass.new("me oh my") + kret = Li_boost_shared_ptr::smartpointerpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointerpointertest", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by shared_ptr reference + k = Li_boost_shared_ptr::Klass.new("me oh my") + kret = Li_boost_shared_ptr::smartpointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointerreftest", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by shared_ptr pointer reference + k = Li_boost_shared_ptr::Klass.new("me oh my") + kret = Li_boost_shared_ptr::smartpointerpointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointerpointerreftest", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # const pass by shared_ptr + k = Li_boost_shared_ptr::Klass.new("me oh my") + kret = Li_boost_shared_ptr::constsmartpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # const pass by shared_ptr pointer + k = Li_boost_shared_ptr::Klass.new("me oh my") + kret = Li_boost_shared_ptr::constsmartpointerpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # const pass by shared_ptr reference + k = Li_boost_shared_ptr::Klass.new("me oh my") + kret = Li_boost_shared_ptr::constsmartpointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by value + k = Li_boost_shared_ptr::Klass.new("me oh my") + kret = Li_boost_shared_ptr::valuetest(k) + val = kret.getValue() + self.verifyValue("me oh my valuetest", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # pass by pointer + k = Li_boost_shared_ptr::Klass.new("me oh my") + kret = Li_boost_shared_ptr::pointertest(k) + val = kret.getValue() + self.verifyValue("me oh my pointertest", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # pass by reference + k = Li_boost_shared_ptr::Klass.new("me oh my") + kret = Li_boost_shared_ptr::reftest(k) + val = kret.getValue() + self.verifyValue("me oh my reftest", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # pass by pointer reference + k = Li_boost_shared_ptr::Klass.new("me oh my") + kret = Li_boost_shared_ptr::pointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my pointerreftest", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # null tests + k = nil + + if (Li_boost_shared_ptr::smartpointertest(k) != nil) + raise RuntimeError, "return was not null" + end + + if (Li_boost_shared_ptr::smartpointerpointertest(k) != nil) + raise RuntimeError, "return was not null" + end + + if (Li_boost_shared_ptr::smartpointerreftest(k) != nil) + raise RuntimeError, "return was not null" + end + + if (Li_boost_shared_ptr::smartpointerpointerreftest(k) != nil) + raise RuntimeError, "return was not null" + end + + if (Li_boost_shared_ptr::nullsmartpointerpointertest(nil) != "null pointer") + raise RuntimeError, "not null smartpointer pointer" + end + + begin + Li_boost_shared_ptr::valuetest(k) + raise RuntimeError, "Failed to catch null pointer" + rescue ArgumentError + end + + if (Li_boost_shared_ptr::pointertest(k) != nil) + raise RuntimeError, "return was not null" + end + + begin + Li_boost_shared_ptr::reftest(k) + raise RuntimeError, "Failed to catch null pointer" + rescue ArgumentError + end + + # $owner + k = Li_boost_shared_ptr::pointerownertest() + val = k.getValue() + self.verifyValue("pointerownertest", val) + self.verifyCount(1, k) + k = Li_boost_shared_ptr::smartpointerpointerownertest() + val = k.getValue() + self.verifyValue("smartpointerpointerownertest", val) + self.verifyCount(1, k) + + # //////////////////////////////// Derived class ////////////////////// + # derived pass by shared_ptr + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::derivedsmartptrtest(k) + val = kret.getValue() + self.verifyValue("me oh my derivedsmartptrtest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # derived pass by shared_ptr pointer + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::derivedsmartptrpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my derivedsmartptrpointertest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # derived pass by shared_ptr ref + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::derivedsmartptrreftest(k) + val = kret.getValue() + self.verifyValue("me oh my derivedsmartptrreftest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # derived pass by shared_ptr pointer ref + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::derivedsmartptrpointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # derived pass by pointer + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::derivedpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my derivedpointertest-Derived", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # derived pass by ref + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::derivedreftest(k) + val = kret.getValue() + self.verifyValue("me oh my derivedreftest-Derived", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # //////////////////////////////// Derived and base class mixed /////// + # pass by shared_ptr (mixed) + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::smartpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointertest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by shared_ptr pointer (mixed) + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::smartpointerpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointerpointertest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by shared_ptr reference (mixed) + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::smartpointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointerreftest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by shared_ptr pointer reference (mixed) + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::smartpointerpointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointerpointerreftest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by value (mixed) + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::valuetest(k) + val = kret.getValue() + self.verifyValue("me oh my valuetest", val) # note slicing + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # pass by pointer (mixed) + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::pointertest(k) + val = kret.getValue() + self.verifyValue("me oh my pointertest-Derived", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # pass by ref (mixed) + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + kret = Li_boost_shared_ptr::reftest(k) + val = kret.getValue() + self.verifyValue("me oh my reftest-Derived", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # //////////////////////////////// Overloading tests ////////////////// + # Base class + k = Li_boost_shared_ptr::Klass.new("me oh my") + self.verifyValue(Li_boost_shared_ptr::overload_rawbyval(k), "rawbyval") + self.verifyValue(Li_boost_shared_ptr::overload_rawbyref(k), "rawbyref") + self.verifyValue(Li_boost_shared_ptr::overload_rawbyptr(k), "rawbyptr") + self.verifyValue( + Li_boost_shared_ptr::overload_rawbyptrref(k), "rawbyptrref") + + self.verifyValue( + Li_boost_shared_ptr::overload_smartbyval(k), "smartbyval") + self.verifyValue( + Li_boost_shared_ptr::overload_smartbyref(k), "smartbyref") + self.verifyValue( + Li_boost_shared_ptr::overload_smartbyptr(k), "smartbyptr") + self.verifyValue( + Li_boost_shared_ptr::overload_smartbyptrref(k), "smartbyptrref") + + # Derived class + k = Li_boost_shared_ptr::KlassDerived.new("me oh my") + self.verifyValue(Li_boost_shared_ptr::overload_rawbyval(k), "rawbyval") + self.verifyValue(Li_boost_shared_ptr::overload_rawbyref(k), "rawbyref") + self.verifyValue(Li_boost_shared_ptr::overload_rawbyptr(k), "rawbyptr") + self.verifyValue( + Li_boost_shared_ptr::overload_rawbyptrref(k), "rawbyptrref") + + self.verifyValue( + Li_boost_shared_ptr::overload_smartbyval(k), "smartbyval") + self.verifyValue( + Li_boost_shared_ptr::overload_smartbyref(k), "smartbyref") + self.verifyValue( + Li_boost_shared_ptr::overload_smartbyptr(k), "smartbyptr") + self.verifyValue( + Li_boost_shared_ptr::overload_smartbyptrref(k), "smartbyptrref") + + # 3rd derived class + k = Li_boost_shared_ptr::Klass3rdDerived.new("me oh my") + val = k.getValue() + self.verifyValue("me oh my-3rdDerived", val) + self.verifyCount(1, k) + val = Li_boost_shared_ptr::test3rdupcast(k) + self.verifyValue("me oh my-3rdDerived", val) + self.verifyCount(1, k) + + # //////////////////////////////// Member variables /////////////////// + # smart pointer by value + m = Li_boost_shared_ptr::MemberVariables.new() + k = Li_boost_shared_ptr::Klass.new("smart member value") + m.SmartMemberValue = k + val = k.getValue() + self.verifyValue("smart member value", val) + self.verifyCount(2, k) + + kmember = m.SmartMemberValue + val = kmember.getValue() + self.verifyValue("smart member value", val) + self.verifyCount(3, kmember) + self.verifyCount(3, k) + + puts "del m" + self.verifyCount(2, kmember) + self.verifyCount(2, k) + + # smart pointer by pointer + m = Li_boost_shared_ptr::MemberVariables.new() + k = Li_boost_shared_ptr::Klass.new("smart member pointer") + m.SmartMemberPointer = k + val = k.getValue() + self.verifyValue("smart member pointer", val) + self.verifyCount(1, k) + + kmember = m.SmartMemberPointer + val = kmember.getValue() + self.verifyValue("smart member pointer", val) + self.verifyCount(2, kmember) + self.verifyCount(2, k) + + puts "del m" + self.verifyCount(2, kmember) + self.verifyCount(2, k) + + # smart pointer by reference + m = Li_boost_shared_ptr::MemberVariables.new() + k = Li_boost_shared_ptr::Klass.new("smart member reference") + m.SmartMemberReference = k + val = k.getValue() + self.verifyValue("smart member reference", val) + self.verifyCount(2, k) + + kmember = m.SmartMemberReference + val = kmember.getValue() + self.verifyValue("smart member reference", val) + self.verifyCount(3, kmember) + self.verifyCount(3, k) + + # The C++ reference refers to SmartMemberValue... + kmemberVal = m.SmartMemberValue + val = kmember.getValue() + self.verifyValue("smart member reference", val) + self.verifyCount(4, kmemberVal) + self.verifyCount(4, kmember) + self.verifyCount(4, k) + + puts "del m" + self.verifyCount(3, kmemberVal) + self.verifyCount(3, kmember) + self.verifyCount(3, k) + + # plain by value + m = Li_boost_shared_ptr::MemberVariables.new() + k = Li_boost_shared_ptr::Klass.new("plain member value") + m.MemberValue = k + val = k.getValue() + self.verifyValue("plain member value", val) + self.verifyCount(1, k) + + kmember = m.MemberValue + val = kmember.getValue() + self.verifyValue("plain member value", val) + self.verifyCount(1, kmember) + self.verifyCount(1, k) + + puts "del m" + self.verifyCount(1, kmember) + self.verifyCount(1, k) + + # plain by pointer + m = Li_boost_shared_ptr::MemberVariables.new() + k = Li_boost_shared_ptr::Klass.new("plain member pointer") + m.MemberPointer = k + val = k.getValue() + self.verifyValue("plain member pointer", val) + self.verifyCount(1, k) + + kmember = m.MemberPointer + val = kmember.getValue() + self.verifyValue("plain member pointer", val) + self.verifyCount(1, kmember) + self.verifyCount(1, k) + + puts "del m" + self.verifyCount(1, kmember) + self.verifyCount(1, k) + + # plain by reference + m = Li_boost_shared_ptr::MemberVariables.new() + k = Li_boost_shared_ptr::Klass.new("plain member reference") + m.MemberReference = k + val = k.getValue() + self.verifyValue("plain member reference", val) + self.verifyCount(1, k) + + kmember = m.MemberReference + val = kmember.getValue() + self.verifyValue("plain member reference", val) + self.verifyCount(1, kmember) + self.verifyCount(1, k) + + puts "del m" + self.verifyCount(1, kmember) + self.verifyCount(1, k) + + # null member variables + m = Li_boost_shared_ptr::MemberVariables.new() + + # shared_ptr by value + k = m.SmartMemberValue + if (k != nil) + raise RuntimeError, "expected null" + end + m.SmartMemberValue = nil + k = m.SmartMemberValue + if (k != nil) + raise RuntimeError, "expected null" + end + self.verifyCount(0, k) + + # plain by value + begin + m.MemberValue = nil + raise RuntimeError, "Failed to catch null pointer" + rescue ArgumentError + end + + # ////////////////////////////////// Global variables ///////////////// + # smart pointer + kglobal = Li_boost_shared_ptr.GlobalSmartValue + if (kglobal != nil) + raise RuntimeError, "expected null" + end + + k = Li_boost_shared_ptr::Klass.new("smart global value") + Li_boost_shared_ptr.GlobalSmartValue = k + self.verifyCount(2, k) + + kglobal = Li_boost_shared_ptr.GlobalSmartValue + val = kglobal.getValue() + self.verifyValue("smart global value", val) + self.verifyCount(3, kglobal) + self.verifyCount(3, k) + self.verifyValue( + "smart global value", Li_boost_shared_ptr.GlobalSmartValue.getValue()) + Li_boost_shared_ptr.GlobalSmartValue = nil + + # plain value + k = Li_boost_shared_ptr::Klass.new("global value") + Li_boost_shared_ptr.GlobalValue = k + self.verifyCount(1, k) + + kglobal = Li_boost_shared_ptr.GlobalValue + val = kglobal.getValue() + self.verifyValue("global value", val) + self.verifyCount(1, kglobal) + self.verifyCount(1, k) + self.verifyValue( + "global value", Li_boost_shared_ptr.GlobalValue.getValue()) + + begin + Li_boost_shared_ptr.GlobalValue = nil + raise RuntimeError, "Failed to catch null pointer" + rescue ArgumentError + end + + # plain pointer + kglobal = Li_boost_shared_ptr.GlobalPointer + if (kglobal != nil) + raise RuntimeError, "expected null" + end + + k = Li_boost_shared_ptr::Klass.new("global pointer") + Li_boost_shared_ptr.GlobalPointer = k + self.verifyCount(1, k) + + kglobal = Li_boost_shared_ptr.GlobalPointer + val = kglobal.getValue() + self.verifyValue("global pointer", val) + self.verifyCount(1, kglobal) + self.verifyCount(1, k) + Li_boost_shared_ptr.GlobalPointer = nil + + # plain reference + kglobal + + k = Li_boost_shared_ptr::Klass.new("global reference") + Li_boost_shared_ptr.GlobalReference = k + self.verifyCount(1, k) + + kglobal = Li_boost_shared_ptr.GlobalReference + val = kglobal.getValue() + self.verifyValue("global reference", val) + self.verifyCount(1, kglobal) + self.verifyCount(1, k) + + begin + Li_boost_shared_ptr.GlobalReference = nil + raise RuntimeError, "Failed to catch null pointer" + rescue ArgumentError + end + + # ////////////////////////////////// Templates //////////////////////// + pid = Li_boost_shared_ptr::PairIntDouble.new(10, 20.2) + if (pid.baseVal1 != 20 or pid.baseVal2 != 40.4) + raise RuntimeError, "Base values wrong" + end + if (pid.val1 != 10 or pid.val2 != 20.2) + raise RuntimeError, "Derived Values wrong" + end + end + + def verifyValue(expected, got) + if (expected != got) + raise RuntimeError, "verify value failed. Expected: #{expected} Got: #{got}" + end + end + + def verifyCount(expected, k) + got = Li_boost_shared_ptr::use_count(k) + if (expected != got) + puts "skipped verifyCount expect/got: #{expected}/#{got}" +# raise RuntimeError, "verify use_count failed. Expected: #{expected} Got: #{got}" + end + end +end + +runme = Li_boost_shared_ptr_runme.new() +runme.main(debug) From f5a6e94466418dfc4224f7859c32f22315ebb701 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 Sep 2015 09:31:11 +0100 Subject: [PATCH 128/732] Ruby shared_ptr testing enhancements li_boost_shared_ptr_runme.rb: add garbage collection to properly check expected reference counts --- .../ruby/li_boost_shared_ptr_runme.rb | 50 +++++++++++++++---- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb b/Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb index 8d3cba5e8..fedd5908a 100644 --- a/Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb +++ b/Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb @@ -1,5 +1,7 @@ require 'li_boost_shared_ptr' +require 'swig_gc' +#debug = $VERBOSE debug = false # simple shared_ptr usage - created in C++ @@ -21,9 +23,18 @@ class Li_boost_shared_ptr_runme end # Expect 1 instance - the one global variable (GlobalValue) - if (Li_boost_shared_ptr::Klass.getTotal_count() != 1) -# raise RuntimeError, "Klass.total_count=#{Li_boost_shared_ptr::Klass.getTotal_count()}" - puts "Klass.total_count=#{Li_boost_shared_ptr::Klass.getTotal_count()}" + GC.track_class = Li_boost_shared_ptr::Klass + invokeGC("Final GC") + +# Actual count is 3 due to memory leaks calling rb_raise in the call to Li_boost_shared_ptr::valuetest(nil) +# as setjmp/longjmp are used thereby failing to call destructors of Klass instances on the stack in _wrap_valuetest +# This is a generic problem in Ruby wrappers, not shared_ptr specific +# expectedCount = 1 + expectedCount = 3 + actualCount = Li_boost_shared_ptr::Klass.getTotal_count() + if (actualCount != expectedCount) +# raise RuntimeError, "GC failed to run (li_boost_shared_ptr). Expected count: #{expectedCount} Actual count: #{actualCount}" + puts "GC failed to run (li_boost_shared_ptr). Expected count: #{expectedCount} Actual count: #{actualCount}" end wrapper_count = Li_boost_shared_ptr::shared_ptr_wrapper_count() @@ -39,6 +50,13 @@ class Li_boost_shared_ptr_runme end end + def invokeGC(debug_msg) + puts "invokeGC #{debug_msg} start" if $VERBOSE + GC.stats if $VERBOSE + GC.start + puts "invokeGC #{debug_msg} end" if $VERBOSE + end + def runtest # simple shared_ptr usage - created in C++ k = Li_boost_shared_ptr::Klass.new("me oh my") @@ -354,7 +372,10 @@ class Li_boost_shared_ptr_runme self.verifyCount(3, kmember) self.verifyCount(3, k) - puts "del m" + GC.track_class = Li_boost_shared_ptr::MemberVariables + m = nil + invokeGC("m = nil (A)") + self.verifyCount(2, kmember) self.verifyCount(2, k) @@ -372,7 +393,9 @@ class Li_boost_shared_ptr_runme self.verifyCount(2, kmember) self.verifyCount(2, k) - puts "del m" + m = nil + invokeGC("m = nil (B)") + self.verifyCount(2, kmember) self.verifyCount(2, k) @@ -398,7 +421,10 @@ class Li_boost_shared_ptr_runme self.verifyCount(4, kmember) self.verifyCount(4, k) - puts "del m" + m = nil + invokeGC("m = nil (C)") + + self.verifyCount(3, kmemberVal) self.verifyCount(3, kmember) self.verifyCount(3, k) @@ -417,7 +443,9 @@ class Li_boost_shared_ptr_runme self.verifyCount(1, kmember) self.verifyCount(1, k) - puts "del m" + m = nil + invokeGC("m = nil (D)") + self.verifyCount(1, kmember) self.verifyCount(1, k) @@ -435,7 +463,9 @@ class Li_boost_shared_ptr_runme self.verifyCount(1, kmember) self.verifyCount(1, k) - puts "del m" + m = nil + invokeGC("m = nil (E)") + self.verifyCount(1, kmember) self.verifyCount(1, k) @@ -453,7 +483,9 @@ class Li_boost_shared_ptr_runme self.verifyCount(1, kmember) self.verifyCount(1, k) - puts "del m" + m = nil + invokeGC("m = nil (F)") + self.verifyCount(1, kmember) self.verifyCount(1, k) From 4c2da8184ba89ab59b0ae5550e98719f9cd782bd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 Sep 2015 23:14:34 +0100 Subject: [PATCH 129/732] li_boost_shared_ptr tests cleanup Remove some cruft --- Examples/test-suite/octave/li_boost_shared_ptr_runme.m | 1 - Examples/test-suite/python/li_boost_shared_ptr_runme.py | 1 - Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb | 1 - 3 files changed, 3 deletions(-) diff --git a/Examples/test-suite/octave/li_boost_shared_ptr_runme.m b/Examples/test-suite/octave/li_boost_shared_ptr_runme.m index a9f4a82c0..1da0a5725 100644 --- a/Examples/test-suite/octave/li_boost_shared_ptr_runme.m +++ b/Examples/test-suite/octave/li_boost_shared_ptr_runme.m @@ -503,7 +503,6 @@ function runtest() #KTODO cvar.GlobalPointer = None # plain reference - kglobal; k = Klass("global reference"); cvar.GlobalReference = k; verifyCount(1, k) diff --git a/Examples/test-suite/python/li_boost_shared_ptr_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_runme.py index 7214add3e..c960625ad 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_runme.py @@ -521,7 +521,6 @@ class li_boost_shared_ptr_runme: li_boost_shared_ptr.cvar.GlobalPointer = None # plain reference - kglobal k = li_boost_shared_ptr.Klass("global reference") li_boost_shared_ptr.cvar.GlobalReference = k diff --git a/Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb b/Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb index fedd5908a..cc5c0cab0 100644 --- a/Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb +++ b/Examples/test-suite/ruby/li_boost_shared_ptr_runme.rb @@ -568,7 +568,6 @@ class Li_boost_shared_ptr_runme Li_boost_shared_ptr.GlobalPointer = nil # plain reference - kglobal k = Li_boost_shared_ptr::Klass.new("global reference") Li_boost_shared_ptr.GlobalReference = k From 004ae163e5a3a77ca6617ac8d5a6dfee37ffa083 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 Sep 2015 23:15:25 +0100 Subject: [PATCH 130/732] Add RUBYFLAGS for Ruby testing make check RUBYFLAGS=-v can be useful --- Examples/Makefile.in | 2 +- Examples/test-suite/ruby/Makefile.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 15e2e7ff1..3aae80bdd 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1096,7 +1096,7 @@ ruby_cpp_static: $(SRCDIR_SRCS) # ----------------------------------------------------------------- ruby_run: - $(RUNTOOL) $(RUBY) -I. $(RUBY_SCRIPT) $(RUNPIPE) + $(RUNTOOL) $(RUBY) $(RUBYFLAGS) -I. $(RUBY_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 6660f687f..ed00c6780 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 $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) -I$(srcdir):. $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) $(RUBYFLAGS) -I$(srcdir):. $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean From a7cc3267bc35236feb6437c2b38e519ae0a4105e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 26 Sep 2015 00:07:26 +0100 Subject: [PATCH 131/732] Add more Ruby shared_ptr runtime tests --- .../ruby/li_boost_shared_ptr_bits_runme.rb | 32 +++++++++++++ .../li_boost_shared_ptr_template_runme.rb | 45 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 Examples/test-suite/ruby/li_boost_shared_ptr_bits_runme.rb create mode 100644 Examples/test-suite/ruby/li_boost_shared_ptr_template_runme.rb diff --git a/Examples/test-suite/ruby/li_boost_shared_ptr_bits_runme.rb b/Examples/test-suite/ruby/li_boost_shared_ptr_bits_runme.rb new file mode 100644 index 000000000..bcd817e5a --- /dev/null +++ b/Examples/test-suite/ruby/li_boost_shared_ptr_bits_runme.rb @@ -0,0 +1,32 @@ +require 'li_boost_shared_ptr_bits' +require 'swig_gc' + +v = Li_boost_shared_ptr_bits::VectorIntHolder.new() +v.push(Li_boost_shared_ptr_bits::IntHolder.new(11)) +v.push(Li_boost_shared_ptr_bits::IntHolder.new(22)) +v.push(Li_boost_shared_ptr_bits::IntHolder.new(33)) + +sum = Li_boost_shared_ptr_bits::sum(v) +if (sum != 66) + raise RuntimeError, "sum is wrong" +end + +hidden = Li_boost_shared_ptr_bits::HiddenDestructor.create() +GC.track_class = Li_boost_shared_ptr_bits::HiddenPrivateDestructor +GC.stats if $VERBOSE +hidden = nil +GC.start + +hiddenPrivate = Li_boost_shared_ptr_bits::HiddenPrivateDestructor.create() +if (Li_boost_shared_ptr_bits::HiddenPrivateDestructor.DeleteCount != 0) + # GC doesn't always run +# raise RuntimeError, "Count should be zero" +end + +GC.stats if $VERBOSE +hiddenPrivate = nil +GC.start +if (Li_boost_shared_ptr_bits::HiddenPrivateDestructor.DeleteCount != 1) + # GC doesn't always run +# raise RuntimeError, "Count should be one" +end diff --git a/Examples/test-suite/ruby/li_boost_shared_ptr_template_runme.rb b/Examples/test-suite/ruby/li_boost_shared_ptr_template_runme.rb new file mode 100644 index 000000000..7d446a474 --- /dev/null +++ b/Examples/test-suite/ruby/li_boost_shared_ptr_template_runme.rb @@ -0,0 +1,45 @@ +require 'li_boost_shared_ptr_template' + +begin + b = Li_boost_shared_ptr_template::BaseINTEGER.new() + d = Li_boost_shared_ptr_template::DerivedINTEGER.new() + if (b.bar() != 1) + raise RuntimeError("test 1") + end + if (d.bar() != 2) + raise RuntimeError("test 2") + end + if (Li_boost_shared_ptr_template.bar_getter(b) != 1) + raise RuntimeError("test 3") + end +# Needs fixing as it does for Python +# if (Li_boost_shared_ptr_template.bar_getter(d) != 2) +# raise RuntimeError("test 4") +# end +end + +begin + b = Li_boost_shared_ptr_template::BaseDefaultInt.new() + d = Li_boost_shared_ptr_template::DerivedDefaultInt.new() + d2 = Li_boost_shared_ptr_template::DerivedDefaultInt2.new() + if (b.bar2() != 3) + raise RuntimeError("test 5") + end + if (d.bar2() != 4) + raise RuntimeError("test 6") + end + if (d2.bar2() != 4) + raise RuntimeError("test 6") + end + if (Li_boost_shared_ptr_template.bar2_getter(b) != 3) + raise RuntimeError("test 7") + end +# Needs fixing as it does for Python +# if (Li_boost_shared_ptr_template.bar2_getter(d) != 4) +# raise RuntimeError("test 8") +# end +# if (Li_boost_shared_ptr_template.bar2_getter(d2) != 4) +# raise RuntimeError("test 8") +# end +end + From aceb5743eca99db95d379465ce0b9e17f9b0ab87 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 26 Sep 2015 00:17:35 +0100 Subject: [PATCH 132/732] Ruby shared_ptr support added to changes file --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 2e3a969d0..dd3a22dfb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-09-26: wsfulton + [Ruby] Add shared_ptr support + 2015-09-13: kkaempf [Ruby] Resolve tracking bug - issue #225. The bug is that the tracking code uses a ruby hash and thus may From f266a588e0eba5271a8767bc25f38d44bc043709 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 30 Sep 2015 07:06:40 +0100 Subject: [PATCH 133/732] Cosmetic comment fix in testcase --- Examples/test-suite/csharp/special_variable_attributes_runme.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Examples/test-suite/csharp/special_variable_attributes_runme.cs b/Examples/test-suite/csharp/special_variable_attributes_runme.cs index 0365ba47c..eca1abfa3 100644 --- a/Examples/test-suite/csharp/special_variable_attributes_runme.cs +++ b/Examples/test-suite/csharp/special_variable_attributes_runme.cs @@ -1,6 +1,4 @@ -// This is the bool runtime testcase. It checks that the C++ bool type works. - using System; using special_variable_attributesNamespace; From 350eff36877acfe21c60a2e7bf8e8c2871733b84 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 30 Sep 2015 07:53:19 +0100 Subject: [PATCH 134/732] Director smartptr testing - Enhance Java and C# test - Add Ruby test --- .../csharp/director_smartptr_runme.cs | 34 ++++++++---- Examples/test-suite/director_smartptr.i | 8 ++- .../java/director_smartptr_runme.java | 36 ++++++++----- .../ruby/director_smartptr_runme.rb | 54 +++++++++++++++++++ 4 files changed, 107 insertions(+), 25 deletions(-) create mode 100644 Examples/test-suite/ruby/director_smartptr_runme.rb diff --git a/Examples/test-suite/csharp/director_smartptr_runme.cs b/Examples/test-suite/csharp/director_smartptr_runme.cs index ad33c4d34..559dff7a0 100644 --- a/Examples/test-suite/csharp/director_smartptr_runme.cs +++ b/Examples/test-suite/csharp/director_smartptr_runme.cs @@ -1,13 +1,13 @@ using director_smartptrNamespace; +using System; public class runme { - private class director_smartptr_MyBarFoo : Foo { public override string ping() { - return "director_smartptr_MyBarFoo.ping();"; + return "director_smartptr_MyBarFoo.ping()"; } public override string pong() @@ -15,27 +15,39 @@ public class runme return "director_smartptr_MyBarFoo.pong();" + ping(); } - public override string fooBar(FooBar fooBar) + public override string upcall(FooBar fooBarPtr) { - return fooBar.FooBarDo(); + return "override;" + fooBarPtr.FooBarDo(); } public override Foo makeFoo() { return new Foo(); } + } - public override FooBar makeFooBar() - { - return new FooBar(); - } + private static void check(string got, string expected) + { + if (got != expected) + throw new ApplicationException("Failed, got: " + got + " expected: " + expected); } static void Main() { - director_smartptr_MyBarFoo myBarFoo = - new director_smartptr_MyBarFoo(); + FooBar fooBar = new FooBar(); - myBarFoo.ping(); + Foo myBarFoo = new director_smartptr_MyBarFoo(); + check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()"); + check(Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()"); + check(Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()"); + + Foo myFoo = myBarFoo.makeFoo(); + check(myFoo.pong(), "Foo::pong();Foo::ping()"); + check(Foo.callPong(myFoo), "Foo::pong();Foo::ping()"); + check(myFoo.upcall(new FooBar()), "Bar::Foo2::Foo2Bar()"); + + Foo myFoo2 = new Foo().makeFoo(); + check(myFoo2.pong(), "Foo::pong();Foo::ping()"); + check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()"); } } diff --git a/Examples/test-suite/director_smartptr.i b/Examples/test-suite/director_smartptr.i index bb44baaa1..9d0be80f0 100644 --- a/Examples/test-suite/director_smartptr.i +++ b/Examples/test-suite/director_smartptr.i @@ -23,10 +23,12 @@ public: virtual ~Foo() {} virtual std::string ping() { return "Foo::ping()"; } virtual std::string pong() { return "Foo::pong();" + ping(); } - virtual std::string fooBar(FooBar* fooBarPtr) { return fooBarPtr->FooBarDo(); } + virtual std::string upcall(FooBar* fooBarPtr) { return fooBarPtr->FooBarDo(); } virtual Foo makeFoo() { return Foo(); } virtual FooBar makeFooBar() { return FooBar(); } + static std::string callPong(Foo &foo) { return foo.pong(); } + static std::string callUpcall(Foo &foo, FooBar* fooBarPtr) { return foo.upcall(fooBarPtr); } static Foo* get_self(Foo *self_) {return self_;} }; @@ -61,10 +63,12 @@ public: virtual ~Foo(); virtual std::string ping(); virtual std::string pong(); - virtual std::string fooBar(FooBar* fooBarPtr); + virtual std::string upcall(FooBar* fooBarPtr); virtual Foo makeFoo(); virtual FooBar makeFooBar(); + static std::string callPong(Foo &foo); + static std::string callUpcall(Foo &foo, FooBar* fooBarPtr); static Foo* get_self(Foo *self_); }; diff --git a/Examples/test-suite/java/director_smartptr_runme.java b/Examples/test-suite/java/director_smartptr_runme.java index 8c4ddc5d3..710ece710 100644 --- a/Examples/test-suite/java/director_smartptr_runme.java +++ b/Examples/test-suite/java/director_smartptr_runme.java @@ -12,18 +12,35 @@ public class director_smartptr_runme { } } - public static void main(String argv[]) { - director_smartptr_MyBarFoo myBarFoo = - new director_smartptr_MyBarFoo(); + private static void check(String got, String expected) { + if (!got.equals(expected)) + throw new RuntimeException("Failed, got: " + got + " expected: " + expected); } + public static void main(String argv[]) { + director_smartptr.FooBar fooBar = new director_smartptr.FooBar(); + + director_smartptr.Foo myBarFoo = new director_smartptr_MyBarFoo(); + check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()"); + check(director_smartptr.Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()"); + check(director_smartptr.Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()"); + + director_smartptr.Foo myFoo = myBarFoo.makeFoo(); + check(myFoo.pong(), "Foo::pong();Foo::ping()"); + check(director_smartptr.Foo.callPong(myFoo), "Foo::pong();Foo::ping()"); + check(myFoo.upcall(fooBar), "Bar::Foo2::Foo2Bar()"); + + director_smartptr.Foo myFoo2 = new director_smartptr.Foo().makeFoo(); + check(myFoo2.pong(), "Foo::pong();Foo::ping()"); + check(director_smartptr.Foo.callPong(myFoo2), "Foo::pong();Foo::ping()"); + } } class director_smartptr_MyBarFoo extends director_smartptr.Foo { @Override public String ping() { - return "director_smartptr_MyBarFoo.ping();"; + return "director_smartptr_MyBarFoo.ping()"; } @Override @@ -32,17 +49,12 @@ class director_smartptr_MyBarFoo extends director_smartptr.Foo { } @Override - public String fooBar(director_smartptr.FooBar fooBar) { - return fooBar.FooBarDo(); + public String upcall(director_smartptr.FooBar fooBarPtr) { + return "override;" + fooBarPtr.FooBarDo(); } @Override public director_smartptr.Foo makeFoo() { return new director_smartptr.Foo(); } - - @Override - public director_smartptr.FooBar makeFooBar() { - return new director_smartptr.FooBar(); - } -} \ No newline at end of file +} diff --git a/Examples/test-suite/ruby/director_smartptr_runme.rb b/Examples/test-suite/ruby/director_smartptr_runme.rb new file mode 100644 index 000000000..8b4bd3d6d --- /dev/null +++ b/Examples/test-suite/ruby/director_smartptr_runme.rb @@ -0,0 +1,54 @@ +#!/usr/bin/env ruby +# +# Put description here +# +# +# +# +# + +require 'director_smartptr' + +include Director_smartptr + +class Director_smartptr_MyBarFoo < Foo + + def ping() + return "director_smartptr_MyBarFoo.ping()" + end + + def pong() + return "director_smartptr_MyBarFoo.pong();" + ping() + end + + def upcall(fooBarPtr) + return "override;" + fooBarPtr.FooBarDo() + end + + def makeFoo() + return Foo.new() + end +end + +def check(got, expected) + if (got != expected) + raise RuntimeError, "Failed, got: #{got} expected: #{expected}" + end +end + +fooBar = Director_smartptr::FooBar.new() + +myBarFoo = Director_smartptr_MyBarFoo.new() +check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()") +check(Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()") +check(Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()") + +myFoo = myBarFoo.makeFoo() +check(myFoo.pong(), "Foo::pong();Foo::ping()") +check(Foo.callPong(myFoo), "Foo::pong();Foo::ping()") +check(myFoo.upcall(FooBar.new()), "Bar::Foo2::Foo2Bar()") + +myFoo2 = Foo.new().makeFoo() +check(myFoo2.pong(), "Foo::pong();Foo::ping()") +check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()") +check(myFoo2.upcall(FooBar.new()), "Bar::Foo2::Foo2Bar()") From ec93b01a09d0e2d1bfd88d83f9bd1447cddc36a5 Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Thu, 1 Oct 2015 15:06:42 +0300 Subject: [PATCH 135/732] Issue #508: Classprefix is not restored after nested structures processing. Also, Classprefix is incorrectly checked in some places. --- Examples/test-suite/nested_class.i | 10 ++++++++++ Source/CParse/parser.y | 12 +++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/nested_class.i b/Examples/test-suite/nested_class.i index ebfc65f3d..b10c33949 100644 --- a/Examples/test-suite/nested_class.i +++ b/Examples/test-suite/nested_class.i @@ -55,6 +55,10 @@ #pragma GCC diagnostic ignored "-Wpedantic" #endif +namespace bar { + int foo() { return 0; } +} + struct Outer { typedef int Integer; /////////////////////////////////////////// @@ -129,10 +133,16 @@ struct Outer { Integer x; } InnerClass4Typedef; +#ifdef _MSC_VER + int Outer::foo(){ return 1; } // should correctly ignore qualification here (#508) +#endif + typedef struct { Integer x; } InnerStruct4Typedef; + friend int bar::foo(); // should parse correctly (#508) + typedef union { Integer x; double y; diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index ef9a568c4..d0f1c8250 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -2925,8 +2925,8 @@ c_decl : storage_class type declarator initializer c_decl_tail { matches that of the declaration, then we will allow it. Otherwise, delete. */ String *p = Swig_scopename_prefix($3.id); if (p) { - if ((Namespaceprefix && Strcmp(p,Namespaceprefix) == 0) || - (inclass && Strcmp(p,Classprefix) == 0)) { + if ((Namespaceprefix && Strcmp(p, Namespaceprefix) == 0) || + (Classprefix && Strcmp(p, Classprefix) == 0)) { String *lstr = Swig_scopename_last($3.id); Setattr($$,"name",lstr); Delete(lstr); @@ -2981,8 +2981,8 @@ c_decl : storage_class type declarator initializer c_decl_tail { if (Strstr($3.id,"::")) { String *p = Swig_scopename_prefix($3.id); if (p) { - if ((Namespaceprefix && Strcmp(p,Namespaceprefix) == 0) || - (inclass && Strcmp(p,Classprefix) == 0)) { + if ((Namespaceprefix && Strcmp(p, Namespaceprefix) == 0) || + (Classprefix && Strcmp(p, Classprefix) == 0)) { String *lstr = Swig_scopename_last($3.id); Setattr($$,"name",lstr); Delete(lstr); @@ -3618,6 +3618,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { Swig_symbol_setscope(cscope); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); + Classprefix = currentOuterClass ? Getattr(currentOuterClass, "Classprefix") : 0; } /* An unnamed struct, possibly with a typedef */ @@ -3654,7 +3655,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { cparse_start_line = cparse_line; currentOuterClass = $$; inclass = 1; - Classprefix = NewStringEmpty(); + Classprefix = 0; Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); /* save the structure declaration to make a typedef for it later*/ @@ -3765,6 +3766,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { Delete($$); $$ = $6; /* pass member list to outer class/namespace (instead of self)*/ } + Classprefix = currentOuterClass ? Getattr(currentOuterClass, "Classprefix") : 0; } ; From 04fd4a9c685d251ec0513e7d604b193b0e99c248 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 30 Sep 2015 08:50:35 +0100 Subject: [PATCH 136/732] Director smartptr testing - add Python test --- .../python/director_smartptr_runme.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Examples/test-suite/python/director_smartptr_runme.py diff --git a/Examples/test-suite/python/director_smartptr_runme.py b/Examples/test-suite/python/director_smartptr_runme.py new file mode 100644 index 000000000..c8bab9d7a --- /dev/null +++ b/Examples/test-suite/python/director_smartptr_runme.py @@ -0,0 +1,37 @@ +from director_smartptr import * + + +class director_smartptr_MyBarFoo(Foo): + + def ping(self): + return "director_smartptr_MyBarFoo.ping()" + + def pong(self): + return "director_smartptr_MyBarFoo.pong();" + self.ping() + + def upcall(self, fooBarPtr): + return "override;" + fooBarPtr.FooBarDo() + + def makeFoo(self): + return Foo() + +def check(got, expected): + if (got != expected): + raise RuntimeError, "Failed, got: " + got + " expected: " + expected + +fooBar = FooBar() + +myBarFoo = director_smartptr_MyBarFoo() +check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()") +check(Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()") +check(Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()") + +myFoo = myBarFoo.makeFoo() +check(myFoo.pong(), "Foo::pong();Foo::ping()") +check(Foo.callPong(myFoo), "Foo::pong();Foo::ping()") +check(myFoo.upcall(FooBar()), "Bar::Foo2::Foo2Bar()") + +myFoo2 = Foo().makeFoo() +check(myFoo2.pong(), "Foo::pong();Foo::ping()") +check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()") +check(myFoo2.upcall(FooBar()), "Bar::Foo2::Foo2Bar()") From e12277a4698b2502702e64f18e44613d5b460d3a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 Oct 2015 20:27:29 +0100 Subject: [PATCH 137/732] Ruby shared_ptr fixes for use with minherit --- Examples/test-suite/ruby/Makefile.in | 1 + .../ruby/ruby_minherit_shared_ptr_runme.rb | 28 +++++++++++++ .../test-suite/ruby_minherit_shared_ptr.i | 39 +++++++++++++++++++ Source/Modules/ruby.cxx | 18 ++++----- 4 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 Examples/test-suite/ruby/ruby_minherit_shared_ptr_runme.rb create mode 100644 Examples/test-suite/ruby_minherit_shared_ptr.i diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index ed00c6780..69cacaab6 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -22,6 +22,7 @@ CPP_TEST_CASES = \ li_std_stack \ primitive_types \ ruby_keywords \ + ruby_minherit_shared_ptr \ ruby_naming \ ruby_track_objects \ ruby_track_objects_directors \ diff --git a/Examples/test-suite/ruby/ruby_minherit_shared_ptr_runme.rb b/Examples/test-suite/ruby/ruby_minherit_shared_ptr_runme.rb new file mode 100644 index 000000000..9381fee2b --- /dev/null +++ b/Examples/test-suite/ruby/ruby_minherit_shared_ptr_runme.rb @@ -0,0 +1,28 @@ +#!/usr/bin/env ruby +# +# Put description here +# +# +# +# +# + +require 'ruby_minherit_shared_ptr' + +md = Ruby_minherit_shared_ptr::MultiDerived.new(11, 22) + +if md.Base1Func != 11 then + raise RuntimeError +end +if md.Interface1Func != 22 then + raise RuntimeError +end +if Ruby_minherit_shared_ptr.BaseCheck(md) != 11 then + raise RuntimeError +end +if Ruby_minherit_shared_ptr.InterfaceCheck(md) != 22 then + raise RuntimeError +end +if Ruby_minherit_shared_ptr.DerivedCheck(md) != 33 then + raise RuntimeError +end diff --git a/Examples/test-suite/ruby_minherit_shared_ptr.i b/Examples/test-suite/ruby_minherit_shared_ptr.i new file mode 100644 index 000000000..6a0e3f94c --- /dev/null +++ b/Examples/test-suite/ruby_minherit_shared_ptr.i @@ -0,0 +1,39 @@ +// Test ruby_minherit (multiple inheritance support) and shared_ptr +%module(ruby_minherit="1") ruby_minherit_shared_ptr + +%include +%shared_ptr(Interface1) +%shared_ptr(Base1) +%shared_ptr(MultiDerived) + +%inline %{ +#include +class Interface1 { +public: + virtual int Interface1Func() const = 0; +}; + +class Base1 { + int val; +public: + Base1(int a = 0) : val(a) {} + virtual int Base1Func() const { return val; } +}; + +class MultiDerived : public Base1, public Interface1 { + int multi; +public: + MultiDerived(int v1, int v2) : Base1(v1), multi(v2) {} + virtual int Interface1Func() const { return multi; } +}; + +int BaseCheck(const Base1& b) { + return b.Base1Func(); +} +int InterfaceCheck(const Interface1& i) { + return i.Interface1Func(); +} +int DerivedCheck(const MultiDerived& m) { + return m.Interface1Func() + m.Base1Func(); +} +%} diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index bbb80c959..9dff4276a 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2439,25 +2439,23 @@ public: SwigType *btype = NewString(basename); SwigType_add_pointer(btype); SwigType_remember(btype); + SwigType *smart = Swig_cparse_smartptr(base.item); + if (smart) { + SwigType_add_pointer(smart); + SwigType_remember(smart); + } + String *bmangle = SwigType_manglestr(smart ? smart : btype); if (multipleInheritance) { - String *bmangle = SwigType_manglestr(btype); Insert(bmangle, 0, "((swig_class *) SWIGTYPE"); Append(bmangle, "->clientdata)->mImpl"); Printv(klass->init, "rb_include_module(", klass->mImpl, ", ", bmangle, ");\n", NIL); - Delete(bmangle); } else { - SwigType *smart = Swig_cparse_smartptr(base.item); - if (smart) { - SwigType_add_pointer(smart); - SwigType_remember(smart); - } - String *bmangle = SwigType_manglestr(smart ? smart : btype); Insert(bmangle, 0, "((swig_class *) SWIGTYPE"); Append(bmangle, "->clientdata)->klass"); Replaceall(klass->init, "$super", bmangle); - Delete(bmangle); - Delete(smart); } + Delete(bmangle); + Delete(smart); Delete(btype); } base = Next(base); From 803ba97a83e8e3ea55718bd38354334b46a78cb4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 Oct 2015 20:30:09 +0100 Subject: [PATCH 138/732] Update docs for shared_ptr --- Doc/Manual/Contents.html | 30 ++++++++++++++++++++++++++++-- Doc/Manual/Go.html | 1 + Doc/Manual/Java.html | 18 ++++++++++++++++++ Doc/Manual/Octave.html | 18 ++++++++++++++++++ Doc/Manual/Python.html | 18 ++++++++++++++++++ Doc/Manual/Ruby.html | 18 ++++++++++++++++++ 6 files changed, 101 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index e8b1e3477..21ba6eaad 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -847,8 +847,8 @@
  • Examples
  • Running SWIG with Go
  • A tour of basic C/C++ wrapping
      @@ -863,6 +863,16 @@
  • Go Templates
  • Go Director Classes +
  • Default Go primitive type mappings
  • Output arguments
  • Adding additional go code @@ -955,6 +965,10 @@
  • C++ namespaces
  • C++ templates
  • C++ Smart Pointers +
  • Further details on the generated Java classes
  • Further details on the Python class interface @@ -1633,6 +1655,10 @@
  • C++ STL Functors
  • C++ STL Iterators
  • C++ Smart Pointers +
  • Cross-Language Polymorphism
    • Exception Unrolling diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index a62efec43..f5463c8f0 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -618,6 +618,7 @@ completely to avoid common pitfalls with directors in Go.

      23.4.7.1 Example C++ code

      +

      The step by step guide is based on two example C++ classes. FooBarAbstract is an abstract C++ class and the FooBarCpp class inherits from it. This guide diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 9d5c447f7..c33c1c16c 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -52,6 +52,10 @@

    • C++ namespaces
    • C++ templates
    • C++ Smart Pointers +
  • Further details on the generated Java classes
  • Further details on the Python class interface @@ -2000,6 +2004,20 @@ examples will appear later.

    36.3.14 C++ Smart Pointers

    +

    36.3.14.1 The shared_ptr Smart Pointer

    + + +

    +The C++11 standard provides std::shared_ptr which was derived from the Boost +implementation, boost::shared_ptr. +Both of these are available for Python in the SWIG library and usage is outlined +in the shared_ptr smart pointer library section. +

    + + +

    36.3.14.2 Generic Smart Pointers

    + +

    In certain C++ programs, it is common to use classes that have been wrapped by so-called "smart pointers." Generally, this involves the use of a template class diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index d5faeb7b8..2de9f673e 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -42,6 +42,10 @@

  • C++ STL Functors
  • C++ STL Iterators
  • C++ Smart Pointers +
  • Cross-Language Polymorphism
    • Exception Unrolling @@ -1461,6 +1465,20 @@ i

      38.3.16 C++ Smart Pointers

      +

      38.3.16.1 The shared_ptr Smart Pointer

      + + +

      +The C++11 standard provides std::shared_ptr which was derived from the Boost +implementation, boost::shared_ptr. +Both of these are available for Ruby in the SWIG library and usage is outlined +in the shared_ptr smart pointer library section. +

      + + +

      38.3.16.2 Generic Smart Pointers

      + +

      In certain C++ programs, it is common to use classes that have been wrapped by so-called "smart pointers." Generally, this involves the use of a template class that implements operator->() From fc2205e64de95cabe18566675b8f78e0abe5b55f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 Oct 2015 22:31:38 +0100 Subject: [PATCH 139/732] %shared_ptr support improvements for classes in an inheritance chain Fix %shared_ptr support for private and protected inheritance. - Remove unnecessary Warning 520: Derived class 'Derived' of 'Base' is not similarly marked as a smart pointer - Do not generate code that attempts to cast up the inheritance chain in the type system runtime in such cases as it doesn't compile and can't be used. Remove unnecessary warning 520 for %shared_ptr when the base class is ignored. --- CHANGES.current | 8 +++ .../test-suite/li_boost_shared_ptr_bits.i | 48 +++++++++++++++ Source/Modules/typepass.cxx | 60 ++++++++++--------- 3 files changed, 87 insertions(+), 29 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index dd3a22dfb..24edfd374 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,14 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-10-01: wsfulton + Fix %shared_ptr support for private and protected inheritance. + - Remove unnecessary Warning 520: Derived class 'Derived' of 'Base' + is not similarly marked as a smart pointer + - Do not generate code that attempts to cast up the inheritance chain in the + type system runtime in such cases as it doesn't compile and can't be used. + Remove unnecessary warning 520 for %shared_ptr when the base class is ignored. + 2015-09-26: wsfulton [Ruby] Add shared_ptr support diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i index 34117a0c7..c785b6170 100644 --- a/Examples/test-suite/li_boost_shared_ptr_bits.i +++ b/Examples/test-suite/li_boost_shared_ptr_bits.i @@ -166,3 +166,51 @@ public: int HiddenPrivateDestructor::DeleteCount = 0; %} +///////////////////////////////////////////////// +// Non-public inheritance and shared_ptr +///////////////////////////////////////////////// + +#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) +%shared_ptr(Base) +// No %shared_ptr(DerivedPrivate1) to check Warning 520 does not appear +// No %shared_ptr(DerivedProtected1) to check Warning 520 does not appear +%shared_ptr(DerivedPrivate2) +%shared_ptr(DerivedProtected2) + +%ignore Base2; +%shared_ptr(DerivedPublic) +#endif + +%inline %{ +class Base { +public: + virtual int b() = 0; +}; + +class DerivedProtected1 : protected Base { +public: + virtual int b() { return 20; } +}; +class DerivedPrivate1 : private Base { +public: + virtual int b() { return 20; } +}; + +class DerivedProtected2 : protected Base { +public: + virtual int b() { return 20; } +}; +class DerivedPrivate2 : private Base { +public: + virtual int b() { return 20; } +}; + +class Base2 { +public: + virtual int b2() = 0; +}; +class DerivedPublic : public Base2 { +public: + virtual int b2() { return 20; } +}; +%} diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index 2aa1b03e6..da077fd07 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -254,36 +254,38 @@ class TypePass:private Dispatcher { Node *bclass = n; /* Getattr(n,"class"); */ Hash *scopes = Getattr(bclass, "typescope"); SwigType_inherit(clsname, bname, cast, 0); - String *smartptr = Getattr(first, "feature:smartptr"); - if (smartptr) { - SwigType *smart = Swig_cparse_smartptr(first); - if (smart) { - /* Record a (fake) inheritance relationship between smart pointer - and smart pointer to base class, so that smart pointer upcasts - are automatically generated. */ - SwigType *bsmart = Copy(smart); - SwigType *rclsname = SwigType_typedef_resolve_all(clsname); - SwigType *rbname = SwigType_typedef_resolve_all(bname); - Replaceall(bsmart, rclsname, rbname); - Delete(rclsname); - Delete(rbname); - String *smartnamestr = SwigType_namestr(smart); - String *bsmartnamestr = SwigType_namestr(bsmart); - /* construct casting code */ - String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr); - Delete(bsmartnamestr); - Delete(smartnamestr); - /* setup inheritance relationship between smart pointer templates */ - SwigType_inherit(smart, bsmart, 0, convcode); - if (!GetFlag(bclass, "feature:smartptr")) - Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name"))); - Delete(convcode); - Delete(bsmart); + if (ispublic && !GetFlag(bclass, "feature:ignore")) { + String *smartptr = Getattr(first, "feature:smartptr"); + if (smartptr) { + SwigType *smart = Swig_cparse_smartptr(first); + if (smart) { + /* Record a (fake) inheritance relationship between smart pointer + and smart pointer to base class, so that smart pointer upcasts + are automatically generated. */ + SwigType *bsmart = Copy(smart); + SwigType *rclsname = SwigType_typedef_resolve_all(clsname); + SwigType *rbname = SwigType_typedef_resolve_all(bname); + Replaceall(bsmart, rclsname, rbname); + Delete(rclsname); + Delete(rbname); + String *smartnamestr = SwigType_namestr(smart); + String *bsmartnamestr = SwigType_namestr(bsmart); + /* construct casting code */ + String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr); + Delete(bsmartnamestr); + Delete(smartnamestr); + /* setup inheritance relationship between smart pointer templates */ + SwigType_inherit(smart, bsmart, 0, convcode); + if (!GetFlag(bclass, "feature:smartptr")) + Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name"))); + Delete(convcode); + Delete(bsmart); + } + Delete(smart); + } else { + if (GetFlag(bclass, "feature:smartptr")) + Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name"))); } - Delete(smart); - } else { - if (GetFlag(bclass, "feature:smartptr")) - Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name"))); } if (!importmode) { String *btype = Copy(bname); From 3585fd475bd43fdf948e84ffd12e9da30064423b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 Oct 2015 22:40:09 +0100 Subject: [PATCH 140/732] Add changes entry for anonymous typedef nested class fix Issue #508 --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 24edfd374..af9168877 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -13,6 +13,9 @@ Version 3.0.8 (in progress) type system runtime in such cases as it doesn't compile and can't be used. Remove unnecessary warning 520 for %shared_ptr when the base class is ignored. +2015-10-01: vkalinin + Fix #508: Fix segfault parsing anonymous typedef nested classes. + 2015-09-26: wsfulton [Ruby] Add shared_ptr support From 9104adc60af111baf3a01ecfb5ae9a53dd313c33 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Oct 2015 12:10:14 +0100 Subject: [PATCH 141/732] Test case fix --- Examples/test-suite/li_boost_shared_ptr_bits.i | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i index c785b6170..b61fd2aa6 100644 --- a/Examples/test-suite/li_boost_shared_ptr_bits.i +++ b/Examples/test-suite/li_boost_shared_ptr_bits.i @@ -185,6 +185,7 @@ int HiddenPrivateDestructor::DeleteCount = 0; class Base { public: virtual int b() = 0; + virtual ~Base() {} }; class DerivedProtected1 : protected Base { @@ -208,6 +209,7 @@ public: class Base2 { public: virtual int b2() = 0; + virtual ~Base2() {} }; class DerivedPublic : public Base2 { public: From 7e40e523c3bce31e2dd1a0234fd36c64585c2d47 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 6 Oct 2015 13:54:27 -0700 Subject: [PATCH 142/732] [Go] Don't emit a constructor function for a director class with an abstract method, since the function will always panic. Fixes #435. --- CHANGES.current | 5 +++++ Source/Modules/go.cxx | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index af9168877..0d9e8ebd9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-10-06: ianlancetaylor + [Go] Don't emit a constructor function for a director + class with an abstract method, since the function will + always panic. + 2015-10-01: wsfulton Fix %shared_ptr support for private and protected inheritance. - Remove unnecessary Warning 520: Derived class 'Derived' of 'Base' diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 6b9ba760d..a214a4153 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -785,6 +785,13 @@ private: return SWIG_OK; } + // Don't emit constructors for abstract director classes. They + // will never succeed anyhow. + if (Swig_methodclass(n) && Swig_directorclass(n) + && Strcmp(Char(Getattr(n, "wrap:action")), director_prot_ctor_code) == 0) { + return SWIG_OK; + } + String *name = Getattr(n, "sym:name"); String *nodetype = Getattr(n, "nodeType"); bool is_static = is_static_member_function || isStatic(n); @@ -848,8 +855,7 @@ private: Delete(c2); Delete(c1); - if (Swig_methodclass(n) && Swig_directorclass(n) - && Strcmp(Char(Getattr(n, "wrap:action")), director_prot_ctor_code) != 0) { + if (Swig_methodclass(n) && Swig_directorclass(n)) { // The core SWIG code skips the first parameter when // generating the $nondirector_new string. Recreate the // action in this case. But don't it if we are using the From fee8f022e2f830166937bf4a2d112ef12d69a7eb Mon Sep 17 00:00:00 2001 From: Sameer Ajmani Date: Fri, 9 Oct 2015 17:01:37 -0400 Subject: [PATCH 143/732] Fix Go example in Go.html Missing "func" keyword. --- Doc/Manual/Go.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index f5463c8f0..7a411750b 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -445,7 +445,7 @@ type MyClass interface { MyMethod() int } -MyClassMyFactoryFunction() MyClass { +func MyClassMyFactoryFunction() MyClass { // swig magic here }

  • From ef001de5240c1e05494e23b933b687f3f266045c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 10 Oct 2015 00:38:52 +0100 Subject: [PATCH 144/732] Support Python 3.5 and -builtin. PyAsyncMethods is a new member in PyHeapTypeObject. Closes#539 --- CHANGES.current | 4 ++++ Source/Modules/python.cxx | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 0d9e8ebd9..17f31e661 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.8 (in progress) =========================== +2015-10-10: wsfulton + [Python] #539 - Support Python 2.5 and -builtin. PyAsyncMethods is a new + member in PyHeapTypeObject. + 2015-10-06: ianlancetaylor [Go] Don't emit a constructor function for a director class with an abstract method, since the function will diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 7bc565871..3395ebe68 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4052,6 +4052,15 @@ public: Printv(f, "#endif\n", NIL); Printf(f, " },\n"); + // PyAsyncMethods as_async + Printv(f, "#if PY_VERSION_HEX >= 0x03050000\n", NIL); + Printf(f, " {\n"); + printSlot(f, getSlot(n, "feature:python:am_await"), "am_await", "unaryfunc"); + printSlot(f, getSlot(n, "feature:python:am_aiter"), "am_aiter", "unaryfunc"); + printSlot(f, getSlot(n, "feature:python:am_anext"), "am_anext", "unaryfunc"); + Printf(f, " },\n"); + Printv(f, "#endif\n", NIL); + // PyNumberMethods as_number Printf(f, " {\n"); printSlot(f, getSlot(n, "feature:python:nb_add"), "nb_add", "binaryfunc"); From 3e9854d308b56488e3bcae69acb4618253b49a94 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 10 Oct 2015 01:17:32 +0100 Subject: [PATCH 145/732] Fix incorrect director_classic_runme.py test Python 3.5 and -builtin threw an error as the incorrect base was being initialized. --- Examples/test-suite/python/director_classic_runme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/director_classic_runme.py b/Examples/test-suite/python/director_classic_runme.py index 9dd5f5967..a4d78f19c 100644 --- a/Examples/test-suite/python/director_classic_runme.py +++ b/Examples/test-suite/python/director_classic_runme.py @@ -69,7 +69,7 @@ class TargetLangOrphanPerson(OrphanPerson): class TargetLangOrphanChild(OrphanChild): def __init__(self): - Child.__init__(self) + OrphanChild.__init__(self) def id(self): identifier = "TargetLangOrphanChild" From b093d4b7037d063ba1488bb2e6901db72cdcd464 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 10 Oct 2015 01:25:15 +0100 Subject: [PATCH 146/732] Travis testing - add Python 3.5 --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8de02e2b0..555711d01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,12 +74,18 @@ matrix: - compiler: gcc os: linux env: SWIGLANG=python PY3=3 VER=3.4 + - compiler: gcc + os: linux + env: SWIGLANG=python PY3=3 VER=3.5 - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 + - compiler: gcc + os: linux + env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.5 - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-O From d24694417f92dd82185ea9cc7e78c27c9a427e0a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 10 Oct 2015 13:59:54 +0100 Subject: [PATCH 147/732] Fix typo in changes file --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 17f31e661..aa0a115e0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -6,7 +6,7 @@ Version 3.0.8 (in progress) =========================== 2015-10-10: wsfulton - [Python] #539 - Support Python 2.5 and -builtin. PyAsyncMethods is a new + [Python] #539 - Support Python 3.5 and -builtin. PyAsyncMethods is a new member in PyHeapTypeObject. 2015-10-06: ianlancetaylor From 8173c5935ec8768fd93ce97522a646c772a9b73f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 10 Oct 2015 15:19:52 +0100 Subject: [PATCH 148/732] Show node pointer value when displaying a node tree For easier debugging when using -debug-module, -debug-top etc --- Source/Swig/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c index d817f1a85..78c04dc90 100644 --- a/Source/Swig/tree.c +++ b/Source/Swig/tree.c @@ -68,7 +68,7 @@ void Swig_print_node(Node *obj) { Node *cobj; print_indent(0); - Printf(stdout, "+++ %s ----------------------------------------\n", nodeType(obj)); + Printf(stdout, "+++ %s - %p ----------------------------------------\n", nodeType(obj), obj); ki = First(obj); while (ki.key) { String *k = ki.key; From 593c452c37e56ff2c96096711d88fb809bfb28ad Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 11 Oct 2015 00:36:19 +0100 Subject: [PATCH 149/732] Fix overloaded templates and default arguments The defaultargs attribute was not being correctly set for functions with default arguments when instantiated with %template. Closes #529 --- Examples/test-suite/common.mk | 1 + .../template_default_arg_overloaded_runme.py | 47 +++++++++++++ .../template_default_arg_overloaded.i | 67 +++++++++++++++++++ Source/CParse/parser.y | 30 ++++++++- 4 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/python/template_default_arg_overloaded_runme.py create mode 100644 Examples/test-suite/template_default_arg_overloaded.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 99fea03ed..1316876f8 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -393,6 +393,7 @@ CPP_TEST_CASES += \ template_default \ template_default2 \ template_default_arg \ + template_default_arg_overloaded \ template_default_arg_virtual_destructor \ template_default_class_parms \ template_default_class_parms_typedef \ diff --git a/Examples/test-suite/python/template_default_arg_overloaded_runme.py b/Examples/test-suite/python/template_default_arg_overloaded_runme.py new file mode 100644 index 000000000..22d46b39d --- /dev/null +++ b/Examples/test-suite/python/template_default_arg_overloaded_runme.py @@ -0,0 +1,47 @@ +from template_default_arg_overloaded import * + +def check(expected, got): + if expected != got: + raise RuntimeError("Expected: " + str(expected) + " got: " + str(got)) + + +pl = PropertyList() +check(1, pl.setInt("int", 10)) +check(1, pl.setInt("int", 10, False)) + +check(2, pl.set("int", pl)) +check(2, pl.set("int", pl, False)) + +check(3, pl.setInt("int", 10, "int")) +check(3, pl.setInt("int", 10, "int", False)) + + +pl = PropertyListGlobal() +check(1, pl.setIntGlobal("int", 10)) +check(1, pl.setIntGlobal("int", 10, False)) + +check(2, pl.set("int", pl)) +check(2, pl.set("int", pl, False)) + +check(3, pl.setIntGlobal("int", 10, "int")) +check(3, pl.setIntGlobal("int", 10, "int", False)) + + +check(1, GoopIntGlobal(10)) +check(1, GoopIntGlobal(10, True)) + +check(2, goopGlobal(3)) +check(2, goopGlobal()) + +check(3, GoopIntGlobal("int", False)) +check(3, GoopIntGlobal("int")) + + +check(1, GoopInt(10)) +check(1, GoopInt(10, True)) + +check(2, goop(3)) +check(2, goop()) + +check(3, GoopInt("int", False)) +check(3, GoopInt("int")) diff --git a/Examples/test-suite/template_default_arg_overloaded.i b/Examples/test-suite/template_default_arg_overloaded.i new file mode 100644 index 000000000..ef8320692 --- /dev/null +++ b/Examples/test-suite/template_default_arg_overloaded.i @@ -0,0 +1,67 @@ +%module template_default_arg_overloaded + +// Github issue #529 + +%include + +%inline %{ +#include + +namespace lsst { +namespace daf { +namespace bass { + +class PropertyList { +public: + PropertyList(void) {}; + + virtual ~PropertyList(void) {}; + + template int set(std::string const& name1, T const& value1, bool inPlace1=true) { return 1; } + + int set(std::string const& name2, PropertyList const& value2, bool inPlace2=true) { return 2; } + + template int set(std::string const& name3, T const& value3, std::string const& comment3, bool inPlace3=true) { return 3; } +}; + +}}} // namespace lsst::daf::bass + +// As above but in global namespace +class PropertyListGlobal { +public: + PropertyListGlobal(void) {}; + + virtual ~PropertyListGlobal(void) {}; + + template int set(std::string const& name1, T const& value1, bool inPlace1=true) { return 1; } + + int set(std::string const& name2, PropertyListGlobal const& value2, bool inPlace2=true) { return 2; } + + template int set(std::string const& name3, T const& value3, std::string const& comment3, bool inPlace3=true) { return 3; } +}; + +%} + +%template(setInt) lsst::daf::bass::PropertyList::set; +%template(setIntGlobal) PropertyListGlobal::set; + + +// Global functions +%inline %{ +template int goopGlobal(T i1, bool b1 = true) { return 1; } +int goopGlobal(short s2 = 0) { return 2; } +template int goopGlobal(const char *s3, bool b3 = true) { return 3; } +%} + +// Global functions in a namespace +%inline %{ +namespace lsst { +template int goop(T i1, bool b1 = true) { return 1; } +int goop(short s2 = 0) { return 2; } +template int goop(const char *s3, bool b3 = true) { return 3; } +} +%} + +%template(GoopIntGlobal) goopGlobal; +%template(GoopInt) lsst::goop; + diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index d0f1c8250..621d43421 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -142,6 +142,11 @@ static Node *copy_node(Node *n) { Setattr(nn, key, k.item); continue; } + /* defaultargs will be patched back in later */ + if (strcmp(ckey,"defaultargs") == 0) { + Setattr(nn, "needs_defaultargs", "1"); + continue; + } /* Looks okay. Just copy the data using Copy */ ci = Copy(k.item); Setattr(nn, key, ci); @@ -652,6 +657,25 @@ static void add_symbols_copy(Node *n) { } } +static void update_defaultargs(Node *n) { + if (n) { + Node *firstdefaultargs = n; + update_defaultargs(firstChild(n)); + n = nextSibling(n); + while (n) { + update_defaultargs(firstChild(n)); + assert(!Getattr(n, "defaultargs")); + if (Getattr(n, "needs_defaultargs")) { + Setattr(n, "defaultargs", firstdefaultargs); + Delattr(n, "needs_defaultargs"); + } else { + firstdefaultargs = n; + } + n = nextSibling(n); + } + } +} + /* Check a set of declarations to see if any are pure-abstract */ static List *pure_abstracts(Node *n) { @@ -2573,6 +2597,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va { Node *nn = n; Node *linklistend = 0; + Node *linkliststart = 0; while (nn) { Node *templnode = 0; if (Strcmp(nodeType(nn),"template") == 0) { @@ -2654,7 +2679,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va } templnode = copy_node(nn); - update_nested_classes(templnode); /* update classes nested withing template */ + update_nested_classes(templnode); /* update classes nested within template */ /* We need to set the node name based on name used to instantiate */ Setattr(templnode,"name",tname); Delete(tname); @@ -2771,6 +2796,8 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va } /* all the overloaded templated functions are added into a linked list */ + if (!linkliststart) + linkliststart = templnode; if (nscope_inner) { /* non-global namespace */ if (templnode) { @@ -2791,6 +2818,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va } nn = Getattr(nn,"sym:nextSibling"); /* repeat for overloaded templated functions. If a templated class there will never be a sibling. */ } + update_defaultargs(linkliststart); } Swig_symbol_setscope(tscope); Delete(Namespaceprefix); From d0dd63e4377ebc38b4e40c8f7e6149694438b35b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 17 Sep 2015 16:53:50 +1200 Subject: [PATCH 150/732] "concret" -> "concrete" --- Lib/javascript/jsc/javascriptcomplex.swg | 2 +- Lib/javascript/v8/javascriptcomplex.swg | 2 +- Lib/python/pycomplex.swg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/javascript/jsc/javascriptcomplex.swg b/Lib/javascript/jsc/javascriptcomplex.swg index 7d165dce4..7be120b3b 100644 --- a/Lib/javascript/jsc/javascriptcomplex.swg +++ b/Lib/javascript/jsc/javascriptcomplex.swg @@ -4,7 +4,7 @@ the complex Constructor method, and the Real and Imag complex accessor methods. - See the std_complex.i and ccomplex.i for concret examples. + See the std_complex.i and ccomplex.i for concrete examples. */ /* the common from converter */ diff --git a/Lib/javascript/v8/javascriptcomplex.swg b/Lib/javascript/v8/javascriptcomplex.swg index 683b972bc..1c0107beb 100644 --- a/Lib/javascript/v8/javascriptcomplex.swg +++ b/Lib/javascript/v8/javascriptcomplex.swg @@ -4,7 +4,7 @@ the complex Constructor method, and the Real and Imag complex accessor methods. - See the std_complex.i and ccomplex.i for concret examples. + See the std_complex.i and ccomplex.i for concrete examples. */ /* the common from converter */ diff --git a/Lib/python/pycomplex.swg b/Lib/python/pycomplex.swg index 74be5b970..087c50f90 100644 --- a/Lib/python/pycomplex.swg +++ b/Lib/python/pycomplex.swg @@ -4,7 +4,7 @@ the complex Constructor method, and the Real and Imag complex accessor methods. - See the std_complex.i and ccomplex.i for concret examples. + See the std_complex.i and ccomplex.i for concrete examples. */ /* the common from converter */ From e79349d8868b0ad93b7317437f0eb8f95825aa6e Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Tue, 27 Oct 2015 20:12:03 -0400 Subject: [PATCH 151/732] Adding tp_finalize field to PyTypeObject for Python version 3.4 and up --- Lib/python/builtin.swg | 3 +++ Lib/python/pyinit.swg | 3 +++ Lib/python/pyrun.swg | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 1d892375c..340037580 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -435,6 +435,9 @@ SwigPyStaticVar_Type(void) { #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index e71c72b27..26c1d7ed3 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -185,6 +185,9 @@ swig_varlink_type(void) { #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 5eedca483..47ac80492 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -806,6 +806,9 @@ SwigPyObject_TypeOnce(void) { #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif @@ -985,6 +988,9 @@ SwigPyPacked_TypeOnce(void) { #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif From b7a351680185c8a594c8ff0e720f62f229a81a6c Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Wed, 28 Oct 2015 16:42:53 -0400 Subject: [PATCH 152/732] Adding nb_matrix_multiply and nb_inplace_matrix_multiply fields to PyNumberMethods for Python version 3.5 and up --- Lib/python/pyrun.swg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 47ac80492..be3af3280 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -724,7 +724,9 @@ SwigPyObject_TypeOnce(void) { (unaryfunc)SwigPyObject_oct, /*nb_oct*/ (unaryfunc)SwigPyObject_hex, /*nb_hex*/ #endif -#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ +#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ +#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ #elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ From 2fa9454c9ff0bef874363bfec4a2d543ead41bf0 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 13 Nov 2015 21:07:44 -0800 Subject: [PATCH 153/732] Python - Save and restore exception state before calling destroy. PyObject_CallFunction has the potential to silently drop the active exception. In cases where the user just finished iterating a generator, StopIteration will be active. Most of the time this is fine because destroy() won't raise an exception. On Python 3 however, and with a debug interpreter, you will get an assertion failure inside of Python. And in the worst case scenario, if destroy() does throw an exception, the intepreter probably won't be able to correctly detect the end of the iteration. --- Lib/python/pyrun.swg | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 5eedca483..ba9d6ecca 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -537,14 +537,21 @@ SwigPyObject_dealloc(PyObject *v) /* destroy is always a VARARGS method */ PyObject *res; if (data->delargs) { - /* we need to create a temporary object to carry the destroy operation */ - PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + /* PyObject_CallFunction() has the potential to silently drop the active + active exception. In cases where we just finished iterating over a + generator StopIteration will be active right now, and this needs to + remain true upon return from SwigPyObject_dealloc. So save and restore. */ + PyObject *val = NULL, *type = NULL, *tb = NULL; + PyErr_Fetch(&val, &type, &tb); + res = SWIG_Python_CallFunctor(destroy, tmp); + PyErr_Restore(val, type, tb); + Py_DECREF(tmp); } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); } Py_XDECREF(res); } From 4e8ea4e853efeca6782e905a75f83a5e704a5fb0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Nov 2015 22:14:32 +0000 Subject: [PATCH 154/732] Python SystemError fix with -builtin Fix error when append on a SWIG Object with -builtin: x.append(10) SystemError: error return without exception set Having append and next methods on a SWIG object by default doesn't seem right to me though. --- Lib/python/pyrun.swg | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 5eedca483..d43b75202 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -569,6 +569,7 @@ SwigPyObject_append(PyObject* v, PyObject* next) next = tmp; #endif if (!SwigPyObject_Check(next)) { + PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); return NULL; } sobj->next = next; From 55bbf68512b9dabdf0571ab7430dfde7cf84650c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Nov 2015 07:27:48 +0000 Subject: [PATCH 155/732] Add std::array container wrappers for Python These work much like any of the other STL containers except Python slicing is somewhat limited because the array is a fixed size. Only slices of the full size are supported. --- Examples/test-suite/common.mk | 1 + Examples/test-suite/cpp11_li_std_array.i | 53 ++++++ .../python/cpp11_li_std_array_runme.py | 160 ++++++++++++++++++ Lib/python/pycontainer.swg | 77 ++++++--- Lib/python/std_array.i | 91 ++++++++++ Lib/std/std_array.i | 88 ++++++++++ Lib/std/std_container.i | 86 ++++++---- Lib/swig.swg | 1 + 8 files changed, 500 insertions(+), 57 deletions(-) create mode 100644 Examples/test-suite/cpp11_li_std_array.i create mode 100644 Examples/test-suite/python/cpp11_li_std_array_runme.py create mode 100644 Lib/python/std_array.i create mode 100644 Lib/std/std_array.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 1316876f8..114c568c5 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -531,6 +531,7 @@ CPP11_TEST_CASES = \ cpp11_initializer_list \ cpp11_initializer_list_extend \ cpp11_lambda_functions \ + cpp11_li_std_array \ cpp11_noexcept \ cpp11_null_pointer_constant \ cpp11_raw_string_literals \ diff --git a/Examples/test-suite/cpp11_li_std_array.i b/Examples/test-suite/cpp11_li_std_array.i new file mode 100644 index 000000000..cda2198ac --- /dev/null +++ b/Examples/test-suite/cpp11_li_std_array.i @@ -0,0 +1,53 @@ +%module cpp11_li_std_array + +#if defined(SWIGPYTHON) + +%include + +%template(ArrayInt6) std::array; + +%inline %{ +std::array arrayOutVal() { + return { -2, -1, 0, 0, 1, 2 }; +} + +std::array & arrayOutRef() { + static std::array a = { -2, -1, 0, 0, 1, 2 }; + return a; +} + +std::array * arrayOutPtr() { + static std::array a = { -2, -1, 0, 0, 1, 2 }; + return &a; +} + +std::array arrayInVal(std::array myarray) { + std::array a = myarray; + for (auto& val : a) { + val *= 10; + } + return a; +} + +const std::array & arrayInConstRef(const std::array & myarray) { + static std::array a = myarray; + for (auto& val : a) { + val *= 10; + } + return a; +} + +void arrayInRef(std::array & myarray) { + for (auto& val : myarray) { + val *= 10; + } +} + +void arrayInPtr(std::array * myarray) { + for (auto& val : *myarray) { + val *= 10; + } +} +%} + +#endif diff --git a/Examples/test-suite/python/cpp11_li_std_array_runme.py b/Examples/test-suite/python/cpp11_li_std_array_runme.py new file mode 100644 index 000000000..d6e1348e9 --- /dev/null +++ b/Examples/test-suite/python/cpp11_li_std_array_runme.py @@ -0,0 +1,160 @@ +from cpp11_li_std_array import * +import sys + + +def failed(a, b, msg): + raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b)) + + +def compare_sequences(a, b): + if len(a) != len(b): + failed(a, b, "different sizes") + for i in range(len(a)): + if a[i] != b[i]: + failed(a, b, "elements are different") + +def compare_containers(pythonlist, swigarray): + compare_sequences(pythonlist, swigarray) + +def steps_exception(swigarray, i, j, step): + try: + if i == None and j == None: + a = swigarray[::step] + elif i == None: + a = swigarray[:j:step] + elif j == None: + a = swigarray[i::step] + else: + a = swigarray[i:j:step] + raise RuntimeError, "swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed steps exception for " + str(list(swigarray)) + except ValueError, e: +# print("exception: {}".format(e)) + pass + +def del_exception(swigarray, i, j, step): + try: + if i == None and j == None: + del swigarray[::step] + elif j == None and step == None: + del swigarray[i] + elif i == None: + del swigarray[:j:step] + elif j == None: + del swigarray[i::step] + else: + del swigarray[i:j:step] + raise RuntimeError, "swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed del exception for " + str(list(swigarray)) + except ValueError, e: +# print("exception: {}".format(e)) + pass + +def setslice_exception(swigarray, newval): + try: + swigarray[::] = newval + raise RuntimeError, "swigarray[::] = " + str(newval) + " missed set exception for swigarray:" + str(list(swigarray)) + except TypeError, e: +# print("exception: {}".format(e)) + pass + + +# Check std::array has similar behaviour to a Python list +# except it is not resizable + +ps = [0, 1, 2, 3, 4, 5] + +ai = ArrayInt6(ps) + +# slices +compare_containers(ps[0:6], ai[0:6]) +compare_containers(ps[0:10], ai[0:10]) +compare_containers(ps[-10:6], ai[-10:6]) +compare_containers(ps[-10:10], ai[-10:10]) + +compare_containers(ps[0:6:1], ai[0:6:1]) +compare_containers(ps[::], ai[::]) +compare_containers(ps[::1], ai[::1]) + +compare_containers([x for x in ps], [x for x in ai]) + +# Reverse +compare_containers(ps[::-1], ai[::-1]) +compare_containers(ps[5::-1], ai[5::-1]) +compare_containers(ps[10::-1], ai[10::-1]) + +# Steps other than +1 and -1 not supported +steps_exception(ai, 0, 6, 3) +steps_exception(ai, None, None, 0) +steps_exception(ai, None, None, 2) +steps_exception(ai, None, None, -2) +steps_exception(ai, 1, 3, 1) +steps_exception(ai, 3, 1, -1) + +# Modify content +for i in range(len(ps)): + ps[i] = (ps[i] + 1) * 10 + ai[i] = (ai[i] + 1) * 10 +compare_containers(ps, ai) + +# Delete +del_exception(ai, 0, 6, 3) +del_exception(ai, None, None, 0) +del_exception(ai, None, None, 2) +del_exception(ai, None, None, -2) +del_exception(ai, 1, 3, 1) +del_exception(ai, 3, 1, -1) + +del_exception(ai, 0, None, None) +del_exception(ai, 5, None, None) + +# Empty +ai = ArrayInt6() +compare_containers([0, 0, 0, 0, 0, 0], ai) + +# Set slice +newvals = [10, 20, 30, 40, 50, 60] +ai[::] = newvals +compare_containers(ai, newvals) + +newvals = [100, 200, 300, 400, 500, 600] +ai[0:6:1] = newvals +compare_containers(ai, newvals) + +newvals = [1000, 2000, 3000, 4000, 5000, 6000] +ai[::-1] = newvals +compare_containers(ai, newvals[::-1]) + +newvals = [10000, 20000, 30000, 40000, 50000, 60000] +ai[-10:100:1] = newvals +compare_containers(ai, newvals[-10:100:1]) + +setslice_exception(ai, [1, 2, 3, 4, 5, 6, 7]) +setslice_exception(ai, [1, 2, 3, 4, 5]) +setslice_exception(ai, [1, 2, 3, 4]) +setslice_exception(ai, [1, 2, 3]) +setslice_exception(ai, [1, 2]) +setslice_exception(ai, [1]) +setslice_exception(ai, []) + +# Check return +compare_containers(arrayOutVal(), [-2, -1, 0, 0, 1, 2]) +compare_containers(arrayOutRef(), [-2, -1, 0, 0, 1, 2]) +compare_containers(arrayOutPtr(), [-2, -1, 0, 0, 1, 2]) + +# Check passing arguments +ai = arrayInVal([9, 8, 7, 6, 5, 4]) +compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +ai = arrayInConstRef([9, 8, 7, 6, 5, 4]) +compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +ai = ArrayInt6([9, 8, 7, 6, 5, 4]) +arrayInRef(ai) +compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +ai = ArrayInt6([9, 8, 7, 6, 5, 4]) +arrayInPtr(ai) +compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +# fill +ai.fill(111) +compare_containers(ai, [111, 111, 111, 111, 111, 111]) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 7168862f5..7c5cc37f9 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -252,6 +252,12 @@ namespace swig { return pos; } + template + inline void + erase(Sequence* seq, const typename Sequence::iterator& position) { + seq->erase(position); + } + template inline Sequence* getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) { @@ -552,6 +558,7 @@ namespace swig difference_type _index; }; + // STL container wrapper around a Python sequence template struct SwigPySequence_Cont { @@ -748,7 +755,6 @@ namespace swig return self->size(); } } - %enddef @@ -756,7 +762,7 @@ namespace swig %define %swig_sequence_methods_common(Sequence...) %swig_sequence_iterator(%arg(Sequence)) %swig_container_methods(%arg(Sequence)) - + %fragment("SwigPySequence_Base"); #if defined(SWIGPYTHON_BUILTIN) @@ -769,14 +775,6 @@ namespace swig #endif // SWIGPYTHON_BUILTIN %extend { - value_type pop() throw (std::out_of_range) { - if (self->size() == 0) - throw std::out_of_range("pop from empty container"); - Sequence::value_type x = self->back(); - self->pop_back(); - return x; - } - /* typemap for slice object support */ %typemap(in) PySliceObject* { if (!PySlice_Check($input)) { @@ -794,7 +792,11 @@ namespace swig return swig::getslice(self, i, j, 1); } - void __setslice__(difference_type i, difference_type j, const Sequence& v = Sequence()) throw (std::out_of_range, std::invalid_argument) { + void __setslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) { + swig::setslice(self, i, j, 1, Sequence()); + } + + void __setslice__(difference_type i, difference_type j, const Sequence& v) throw (std::out_of_range, std::invalid_argument) { swig::setslice(self, i, j, 1, v); } @@ -803,11 +805,10 @@ namespace swig } #endif - void __delitem__(difference_type i) throw (std::out_of_range) { - self->erase(swig::getpos(self,i)); + void __delitem__(difference_type i) throw (std::out_of_range, std::invalid_argument) { + swig::erase(self, swig::getpos(self, i)); } - /* Overloaded methods for Python 3 compatibility * (Also useful in Python 2.x) */ @@ -858,12 +859,11 @@ namespace swig Sequence::difference_type jd = j; swig::delslice(self, id, jd, step); } - - } + } %enddef -%define %swig_sequence_methods(Sequence...) +%define %swig_sequence_methods_non_resizable(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %extend { const value_type& __getitem__(difference_type i) const throw (std::out_of_range) { @@ -876,19 +876,32 @@ namespace swig #if defined(SWIGPYTHON_BUILTIN) // This will be called through the mp_ass_subscript slot to delete an entry. - void __setitem__(difference_type i) throw (std::out_of_range) { - self->erase(swig::getpos(self,i)); + void __setitem__(difference_type i) throw (std::out_of_range, std::invalid_argument) { + swig::erase(self, swig::getpos(self, i)); } #endif + } +%enddef + +%define %swig_sequence_methods(Sequence...) + %swig_sequence_methods_non_resizable(%arg(Sequence)) + %extend { + value_type pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty container"); + Sequence::value_type x = self->back(); + self->pop_back(); + return x; + } + void append(const value_type& x) { self->push_back(x); } - } - + } %enddef -%define %swig_sequence_methods_val(Sequence...) +%define %swig_sequence_methods_non_resizable_val(Sequence...) %swig_sequence_methods_common(%arg(Sequence)) %extend { value_type __getitem__(difference_type i) throw (std::out_of_range) { @@ -901,16 +914,28 @@ namespace swig #if defined(SWIGPYTHON_BUILTIN) // This will be called through the mp_ass_subscript slot to delete an entry. - void __setitem__(difference_type i) throw (std::out_of_range) { - self->erase(swig::getpos(self,i)); + void __setitem__(difference_type i) throw (std::out_of_range, std::invalid_argument) { + swig::erase(self, swig::getpos(self, i)); } #endif + } +%enddef + +%define %swig_sequence_methods_val(Sequence...) + %swig_sequence_methods_non_resizable_val(%arg(Sequence)) + %extend { + value_type pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty container"); + Sequence::value_type x = self->back(); + self->pop_back(); + return x; + } void append(value_type x) { self->push_back(x); } - } - + } %enddef diff --git a/Lib/python/std_array.i b/Lib/python/std_array.i new file mode 100644 index 000000000..b894868a0 --- /dev/null +++ b/Lib/python/std_array.i @@ -0,0 +1,91 @@ +/* + std::array +*/ + +%fragment("StdArrayTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template + struct traits_asptr > { + static int asptr(PyObject *obj, std::array **vec) { + return traits_asptr_stdseq >::asptr(obj, vec); + } + }; + + template + struct traits_from > { + static PyObject *from(const std::array& vec) { + return traits_from_stdseq >::from(vec); + } + }; + + template + inline void + assign(const SwigPySeq& swigpyseq, std::array* seq) { + if (swigpyseq.size() < seq->size()) + throw std::invalid_argument("std::array cannot be expanded in size"); + else if (swigpyseq.size() > seq->size()) + throw std::invalid_argument("std::array cannot be reduced in size"); + std::copy(swigpyseq.begin(), swigpyseq.end(), seq->begin()); + } + + template + inline void + erase(std::array* seq, const typename std::array::iterator& position) { + throw std::invalid_argument("std::array object does not support item deletion"); + } + + // Only limited slicing is supported as std::array is fixed in size + template + inline std::array* + getslice(const std::array* self, Difference i, Difference j, Py_ssize_t step) { + using Sequence = std::array; + typename Sequence::size_type size = self->size(); + Difference ii = 0; + Difference jj = 0; + swig::slice_adjust(i, j, step, size, ii, jj); + + if (step == 1 && ii == 0 && jj == size) { + Sequence *sequence = new Sequence(); + std::copy(self->begin(), self->end(), sequence->begin()); + return sequence; + } else if (step == -1 && ii == (size - 1) && jj == -1) { + Sequence *sequence = new Sequence(); + std::copy(self->rbegin(), self->rend(), sequence->begin()); + return sequence; + } else { + throw std::invalid_argument("std::array object only supports getting a slice that is the size of the array"); + } + } + + template + inline void + setslice(std::array* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) { + using Sequence = std::array; + typename Sequence::size_type size = self->size(); + Difference ii = 0; + Difference jj = 0; + swig::slice_adjust(i, j, step, size, ii, jj, true); + + if (step == 1 && ii == 0 && jj == size) { + std::copy(is.begin(), is.end(), self->begin()); + } else if (step == -1 && ii == (size - 1) && jj == -1) { + std::copy(is.rbegin(), is.rend(), self->begin()); + } else { + throw std::invalid_argument("std::array object only supports setting a slice that is the size of the array"); + } + } + + template + inline void + delslice(std::array* self, Difference i, Difference j, Py_ssize_t step) { + throw std::invalid_argument("std::array object does not support item deletion"); + } + } +%} + +#define %swig_array_methods(Type...) %swig_sequence_methods_non_resizable(Type) +#define %swig_array_methods_val(Type...) %swig_sequence_methods_non_resizable_val(Type); + +%include + diff --git a/Lib/std/std_array.i b/Lib/std/std_array.i new file mode 100644 index 000000000..0676f670e --- /dev/null +++ b/Lib/std/std_array.i @@ -0,0 +1,88 @@ +// +// std::array +// + +%include + +%define %std_array_methods(array...) + %std_sequence_methods_non_resizable(array) + void fill(const value_type& u); +%enddef + + +%define %std_array_methods_val(array...) + %std_sequence_methods_non_resizable_val(array) + void fill(const value_type& u); +%enddef + +// ------------------------------------------------------------------------ +// std::array +// +// The aim of all that follows would be to integrate std::array with +// as much as possible, namely, to allow the user to pass and +// be returned tuples or lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::array), f(const std::array&): +// the parameter being read-only, either a sequence or a +// previously wrapped std::array can be passed. +// -- f(std::array&), f(std::array*): +// the parameter may be modified; therefore, only a wrapped std::array +// can be passed. +// -- std::array f(), const std::array& f(): +// the array is returned by copy; therefore, a sequence of T:s +// is returned which is most easily used in other functions +// -- std::array& f(), std::array* f(): +// the array is returned by reference; therefore, a wrapped std::array +// is returned +// -- const std::array* f(), f(const std::array*): +// for consistency, they expect and return a plain array pointer. +// ------------------------------------------------------------------------ + +%{ +#include +%} + +// exported classes + +namespace std { + + template + class array { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + + %traits_swigtype(_Tp); + %traits_enum(_Tp); + + %fragment(SWIG_Traits_frag(std::array<_Tp, _Nm >), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdArrayTraits") { + namespace swig { + template <> struct traits > { + typedef pointer_category category; + static const char* type_name() { + return "std::array<" #_Tp "," #_Nm " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_STDARRAY, std::array<_Tp, _Nm >); + +#ifdef %swig_array_methods + // Add swig/language extra methods + %swig_array_methods(std::array<_Tp, _Nm >); +#endif + + %std_array_methods(array); + }; +} + diff --git a/Lib/std/std_container.i b/Lib/std/std_container.i index 8ed327bbe..fc46aed0c 100644 --- a/Lib/std/std_container.i +++ b/Lib/std/std_container.i @@ -6,20 +6,17 @@ #include %} -// Common container methods +// Common non-resizable container methods + +%define %std_container_methods_non_resizable(container...) -%define %std_container_methods(container...) container(); container(const container&); bool empty() const; size_type size() const; - void clear(); - void swap(container& v); - allocator_type get_allocator() const; - #ifdef SWIG_EXPORT_ITERATOR_METHODS class iterator; class reverse_iterator; @@ -34,17 +31,27 @@ %enddef +// Common container methods + +%define %std_container_methods(container...) + %std_container_methods_non_resizable(%arg(container)) + + void clear(); + allocator_type get_allocator() const; + +%enddef + // Common sequence %define %std_sequence_methods_common(sequence) - + %std_container_methods(%arg(sequence)); - + sequence(size_type size); void pop_back(); - + void resize(size_type new_size); - + #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 @@ -52,24 +59,31 @@ iterator erase(iterator first, iterator last) { return $self->erase(first, last); } } #endif - + %enddef +%define %std_sequence_methods_non_resizable(sequence) -%define %std_sequence_methods(sequence) - - %std_sequence_methods_common(%arg(sequence)); - - sequence(size_type size, const value_type& value); - void push_back(const value_type& x); + %std_container_methods_non_resizable(%arg(sequence)) const value_type& front() const; const value_type& back() const; - - void assign(size_type n, const value_type& x); +%enddef + +%define %std_sequence_methods(sequence) + + %std_sequence_methods_common(%arg(sequence)); + + sequence(size_type size, const value_type& value); + void push_back(const value_type& x); + + const value_type& front() const; + const value_type& back() const; + + void assign(size_type n, const value_type& x); void resize(size_type new_size, const value_type& x); - + #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 @@ -77,23 +91,33 @@ void insert(iterator pos, size_type n, const value_type& x) { $self->insert(pos, n, x); } } #endif - + %enddef -%define %std_sequence_methods_val(sequence...) - - %std_sequence_methods_common(%arg(sequence)); - - sequence(size_type size, value_type value); - void push_back(value_type x); +%define %std_sequence_methods_non_resizable_val(sequence...) + + %std_container_methods_non_resizable(%arg(sequence)) value_type front() const; value_type back() const; - - void assign(size_type n, value_type x); +#endif + +%enddef + +%define %std_sequence_methods_val(sequence...) + + %std_sequence_methods_common(%arg(sequence)); + + sequence(size_type size, value_type value); + void push_back(value_type x); + + value_type front() const; + value_type back() const; + + void assign(size_type n, value_type x); void resize(size_type new_size, value_type x); - + #ifdef SWIG_EXPORT_ITERATOR_METHODS %extend { // %extend wrapper used for differing definitions of these methods introduced in C++11 @@ -101,7 +125,7 @@ void insert(iterator pos, size_type n, value_type x) { $self->insert(pos, n, x); } } #endif - + %enddef diff --git a/Lib/swig.swg b/Lib/swig.swg index c33ae3854..6f48f0d20 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -359,6 +359,7 @@ static int NAME(TYPE x) { %define SWIG_TYPECHECK_STDSTRING 135 %enddef %define SWIG_TYPECHECK_STRING 140 %enddef %define SWIG_TYPECHECK_PAIR 150 %enddef +%define SWIG_TYPECHECK_STDARRAY 155 %enddef %define SWIG_TYPECHECK_VECTOR 160 %enddef %define SWIG_TYPECHECK_DEQUE 170 %enddef %define SWIG_TYPECHECK_LIST 180 %enddef From b8feb85f0e291506154c6bae98bd76c2223c2e36 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Nov 2015 21:12:16 +0000 Subject: [PATCH 156/732] Add Ruby std_array.i - std::array wrappers --- Examples/test-suite/cpp11_li_std_array.i | 2 +- .../ruby/cpp11_li_std_array_runme.rb | 127 ++++++++++++++++++ Lib/ruby/rubycontainer.swg | 99 ++++++++------ Lib/ruby/std_array.i | 103 ++++++++++++++ 4 files changed, 289 insertions(+), 42 deletions(-) create mode 100644 Examples/test-suite/ruby/cpp11_li_std_array_runme.rb create mode 100644 Lib/ruby/std_array.i diff --git a/Examples/test-suite/cpp11_li_std_array.i b/Examples/test-suite/cpp11_li_std_array.i index cda2198ac..e8e50105f 100644 --- a/Examples/test-suite/cpp11_li_std_array.i +++ b/Examples/test-suite/cpp11_li_std_array.i @@ -1,6 +1,6 @@ %module cpp11_li_std_array -#if defined(SWIGPYTHON) +#if defined(SWIGPYTHON) || defined(SWIGRUBY) %include diff --git a/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb b/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb new file mode 100644 index 000000000..41906f594 --- /dev/null +++ b/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb @@ -0,0 +1,127 @@ +#!/usr/bin/env ruby +# +# Put description here +# +# +# +# +# + +require 'swig_assert' + +require 'cpp11_li_std_array' + +include Cpp11_li_std_array + + +def failed(a, b, msg) + raise RuntimeError, "#{msg} #{a} #{b}" +end + +def compare_sequences(a, b) + if a.size != b.size + failed(a, b, "different sizes") + end + for i in 0..a.size-1 + failed(a, b, "elements are different:") if a[i] != b[i] + end +end + +def compare_containers(rubyarray, swigarray) + compare_sequences(rubyarray, swigarray) +end + +def setslice_exception(swigarray, newval) + begin + swigarray[0..swigarray.size] = newval + raise RuntimeError, "swigarray[] = #{newval} missed set exception for swigarray: #{swigarray}" + rescue ArgumentError => e +# print "exception: #{e}" + end +end + + +# Check std::array has similar behaviour to a Ruby array +# except it is not resizable + +ps = [0, 1, 2, 3, 4, 5] + +ai = ArrayInt6.new(ps) + +compare_containers(ps, ai) + +# slices +compare_containers(ps[0..5], ai[0..5]) +compare_containers(ps[-6..-1], ai[-6..-1]) +compare_containers(ps[0..10], ai[0..10]) + +# Reverse (.reverse is not provided) +rev = [] +ai.reverse_each { |i| rev.push i } +compare_containers(ps.reverse, rev) + +# Modify content +for i in 0..ps.size-1 + ps[i] = ps[i] * 10 + ai[i] = ai[i] * 10 +end +compare_containers(ps, ai) + +# Empty +ai = ArrayInt6.new() +compare_containers([0, 0, 0, 0, 0, 0], ai) + +# Set slice +#newvals = [10, 20, 30, 40, 50, 60] +#ai[0..5] = newvals +#compare_containers(ai, newvals) + +#newvals = [10000, 20000, 30000, 40000, 50000, 60000] +#ai[0..100] = newvals +#compare_containers(ai, newvals[0..100]) + +setslice_exception(ai, [1, 2, 3, 4, 5, 6, 7]) +setslice_exception(ai, [1, 2, 3, 4, 5]) +setslice_exception(ai, [1, 2, 3, 4]) +setslice_exception(ai, [1, 2, 3]) +setslice_exception(ai, [1, 2]) +setslice_exception(ai, [1]) +setslice_exception(ai, []) + +# Check return +compare_containers(arrayOutVal(), [-2, -1, 0, 0, 1, 2]) +compare_containers(arrayOutRef(), [-2, -1, 0, 0, 1, 2]) +compare_containers(arrayOutPtr(), [-2, -1, 0, 0, 1, 2]) + +# Check passing arguments +ai = arrayInVal([9, 8, 7, 6, 5, 4]) +compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +ai = arrayInConstRef([9, 8, 7, 6, 5, 4]) +compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +ai = ArrayInt6.new([9, 8, 7, 6, 5, 4]) +arrayInRef(ai) +compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +ai = ArrayInt6.new([9, 8, 7, 6, 5, 4]) +arrayInPtr(ai) +compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +# fill +ai.fill(111) +compare_containers(ai, [111, 111, 111, 111, 111, 111]) + +# various +ai = ArrayInt6.new([9, 8, 7, 6, 5, 4]) +swig_assert(ai.include? 9) +swig_assert(!ai.include?(99)) +swig_assert(ai.kind_of? ArrayInt6) +swig_assert(ai.find {|x| x == 6 } == 6) +swig_assert(ai.find {|x| x == 66 } == nil) +swig_assert(ai.respond_to?(:each)) +swig_assert(ai.respond_to?(:each_with_index)) + +ai = [0, 10, 20, 30, 40, 50] +ai.each_with_index { |e,i| swig_assert(e/10 == i) } + diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index 69db367d9..f8bb76e42 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -91,6 +91,12 @@ namespace swig { return pos; } + template + inline void + resize(Sequence *seq, typename Sequence::size_type n, typename Sequence::value_type x) { + seq->resize(n, x); + } + template inline Sequence* getslice(const Sequence* self, Difference i, Difference j) { @@ -164,7 +170,6 @@ namespace swig * of an element of a Ruby Array of stuff. * It can be used by RubySequence_InputIterator to make it work with STL * algorithms. - * */ template struct RubySequence_Ref @@ -210,7 +215,6 @@ namespace swig * RubySequence_Ref. * It can be used by RubySequence_InputIterator to make it work with STL * algorithms. - * */ template struct RubySequence_ArrowProxy @@ -225,7 +229,6 @@ namespace swig /** * Input Iterator. This adapator class is a random access iterator that * allows you to use STL algorithms with a Ruby class (a Ruby Array by default). - * */ template > struct RubySequence_InputIterator @@ -326,7 +329,6 @@ namespace swig /** * This adaptor class allows you to use a Ruby Array as if it was an STL * container, giving it begin(), end(), and iterators. - * */ template struct RubySequence_Cont @@ -419,7 +421,6 @@ namespace swig /** * Macros used to typemap an STL iterator -> SWIGIterator conversion. - * */ %define %swig_sequence_iterator(Sequence...) #if defined(SWIG_EXPORT_ITERATOR_METHODS) @@ -549,7 +550,6 @@ namespace swig /** * Macro used to define common Ruby printing methods for STL container - * */ %define %swig_sequence_printing_methods(Sequence...) @@ -609,9 +609,8 @@ namespace swig /** * Macro used to add common methods to all STL sequence-type containers - * */ -%define %swig_sequence_methods_common(Sequence...) +%define %swig_sequence_methods_non_resizable_common(Sequence...) %swig_container_methods(%arg(Sequence)) %swig_sequence_iterator(%arg(Sequence)) %swig_sequence_printing_methods(%arg(Sequence)) @@ -620,8 +619,7 @@ namespace swig %extend { - - VALUE slice( difference_type i, difference_type j ) + VALUE slice( difference_type i, difference_type j ) throw (std::invalid_argument) { if ( j <= 0 ) return Qnil; std::size_t len = $self->size(); @@ -657,12 +655,23 @@ namespace swig return self; } + VALUE __delete2__(const value_type& i) { + VALUE r = Qnil; + return r; + } + + } +%enddef + +%define %swig_sequence_methods_resizable_common(Sequence...) + %extend { + %newobject select; Sequence* select() { if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given" ); - Sequence* r = new Sequence; + Sequence* r = new Sequence(); Sequence::const_iterator i = $self->begin(); Sequence::const_iterator e = $self->end(); for ( ; i != e; ++i ) @@ -687,21 +696,17 @@ namespace swig } return r; } - - - VALUE __delete2__(const value_type& i) { - VALUE r = Qnil; - return r; - } - } %enddef +%define %swig_sequence_methods_common(Sequence...) + %swig_sequence_methods_non_resizable_common(%arg(Sequence)) + %swig_sequence_methods_resizable_common(%arg(Sequence)) +%enddef /** * Macro used to add functions for back insertion of values in - * STL Sequence containers - * + * STL sequence containers */ %define %swig_sequence_back_inserters( Sequence... ) %extend { @@ -724,7 +729,7 @@ namespace swig if ( !rb_block_given_p() ) rb_raise( rb_eArgError, "no block given" ); - Sequence* r = new Sequence; + Sequence* r = new Sequence(); std::remove_copy_if( $self->begin(), $self->end(), std::back_inserter(*r), swig::yield< Sequence::value_type >() ); @@ -748,15 +753,7 @@ namespace swig } %enddef -/** - * Macro used to add functions for Sequences - * - */ -%define %swig_sequence_methods(Sequence...) - %swig_sequence_methods_common(%arg(Sequence)); - %swig_sequence_methods_extra(%arg(Sequence)); - %swig_sequence_back_inserters(%arg(Sequence)); - +%define %swig_sequence_methods_non_resizable_accessors(Sequence...) %extend { VALUE at(difference_type i) const { @@ -770,7 +767,7 @@ namespace swig return r; } - VALUE __getitem__(difference_type i, difference_type j) const { + VALUE __getitem__(difference_type i, difference_type j) const throw (std::invalid_argument) { if ( j <= 0 ) return Qnil; std::size_t len = $self->size(); if ( i < 0 ) i = len - i; @@ -797,7 +794,7 @@ namespace swig return r; } - VALUE __getitem__(VALUE i) const { + VALUE __getitem__(VALUE i) const throw (std::invalid_argument) { if ( rb_obj_is_kind_of( i, rb_cRange ) == Qfalse ) { rb_raise( rb_eTypeError, "not a valid index or range" ); @@ -828,27 +825,27 @@ namespace swig return swig::from< Sequence* >( swig::getslice(self, s, e+1) ); } - VALUE __setitem__(difference_type i, const value_type& x) + VALUE __setitem__(difference_type i, const value_type& x) throw (std::invalid_argument) { std::size_t len = $self->size(); if ( i < 0 ) i = len - i; else if ( static_cast(i) >= len ) - $self->resize( i+1, x ); + swig::resize( $self, i+1, x ); else *(swig::getpos(self,i)) = x; return swig::from< Sequence::value_type >( x ); } - VALUE __setitem__(difference_type i, difference_type j, const Sequence& v) - throw (std::invalid_argument) { + VALUE __setitem__(difference_type i, difference_type j, const Sequence& v) throw (std::invalid_argument) + { if ( j <= 0 ) return Qnil; std::size_t len = $self->size(); if ( i < 0 ) i = len - i; j += i; if ( static_cast(j) >= len ) { - $self->resize( j+1, *(v.begin()) ); + swig::resize( $self, j+1, *(v.begin()) ); j = len-1; } @@ -857,10 +854,33 @@ namespace swig r = swig::from< const Sequence* >( &v ); return r; } - } %enddef +/** + * Macro used to add functions for non resizable sequences + */ +%define %swig_sequence_methods_non_resizable(Sequence...) + %swig_sequence_methods_non_resizable_common(%arg(Sequence)) + %swig_sequence_methods_non_resizable_accessors(%arg(Sequence)) +%enddef + + +/** + * Macro used to add functions for sequences + */ +%define %swig_sequence_methods(Sequence...) + %swig_sequence_methods_non_resizable_common(%arg(Sequence)) + %swig_sequence_methods_resizable_common(%arg(Sequence)) + %swig_sequence_methods_non_resizable_accessors(%arg(Sequence)) + %swig_sequence_methods_extra(%arg(Sequence)); + %swig_sequence_back_inserters(%arg(Sequence)); +%enddef + +%define %swig_sequence_methods_non_resizable_val(Sequence...) + %swig_sequence_methods_non_resizable(%arg(Sequence)) +%enddef + %define %swig_sequence_methods_val(Sequence...) %swig_sequence_methods(%arg(Sequence)) %enddef @@ -869,10 +889,8 @@ namespace swig /** * Macro used to add functions for front insertion of * elements in STL sequence containers that support it. - * */ %define %swig_sequence_front_inserters( Sequence... ) - %extend { VALUE shift() @@ -952,7 +970,6 @@ namespace swig return $self; } - } %enddef diff --git a/Lib/ruby/std_array.i b/Lib/ruby/std_array.i new file mode 100644 index 000000000..51ea09ba6 --- /dev/null +++ b/Lib/ruby/std_array.i @@ -0,0 +1,103 @@ +/* + std::array +*/ + +%fragment("StdArrayTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template + struct traits_asptr > { + static int asptr(VALUE obj, std::array **vec) { + return traits_asptr_stdseq >::asptr(obj, vec); + } + }; + + template + struct traits_from > { + static VALUE from(const std::array& vec) { + return traits_from_stdseq >::from(vec); + } + }; + + template + inline void + assign(const RubySeq& rubyseq, std::array* seq) { + if (rubyseq.size() < seq->size()) + throw std::invalid_argument("std::array cannot be expanded in size"); + else if (rubyseq.size() > seq->size()) + throw std::invalid_argument("std::array cannot be reduced in size"); + std::copy(rubyseq.begin(), rubyseq.end(), seq->begin()); + } + + template + inline void + resize(std::array *seq, typename std::array::size_type n, typename std::array::value_type x) { + throw std::invalid_argument("std::array is a fixed size container and does not support resizing"); + } + + // Only limited slicing is supported as std::array is fixed in size + template + inline std::array* + getslice(const std::array* self, Difference i, Difference j) { + using Sequence = std::array; + typename Sequence::size_type size = self->size(); + typename Sequence::size_type ii = swig::check_index(i, size); + typename Sequence::size_type jj = swig::slice_index(j, size); + + if (ii == 0 && jj == size) { + Sequence *sequence = new Sequence(); + std::copy(self->begin(), self->end(), sequence->begin()); + return sequence; + } else { + throw std::invalid_argument("std::array object only supports getting a slice that is the size of the array"); + } + } + + template + inline void + setslice(std::array* self, Difference i, Difference j, const InputSeq& v) { + using Sequence = std::array; + typename Sequence::size_type size = self->size(); + typename Sequence::size_type ii = swig::check_index(i, size, true); + typename Sequence::size_type jj = swig::slice_index(j, size); + +std::cout << "setslice " << v[0] << " " << v[1] << std::endl; + if (ii == 0 && jj == size) { + std::copy(v.begin(), v.end(), self->begin()); + } else { + throw std::invalid_argument("std::array object only supports setting a slice that is the size of the array"); + } + } + + template + inline void + delslice(std::array* self, Difference i, Difference j) { + throw std::invalid_argument("std::array object does not support item deletion"); + } + } +%} + + +%define %swig_array_methods(Type...) + %swig_sequence_methods_non_resizable(Type) +%enddef + +%define %swig_array_methods_val(Type...) + %swig_sequence_methods_non_resizable_val(Type); +%enddef + + +%mixin std::array "Enumerable"; +%ignore std::array::push_back; +%ignore std::array::pop_back; + + +%rename("delete") std::array::__delete__; +%rename("reject!") std::array::reject_bang; +%rename("map!") std::array::map_bang; +%rename("empty?") std::array::empty; +%rename("include?" ) std::array::__contains__ const; +%rename("has_key?" ) std::array::has_key const; + +%include + From 19c24a4f601b38cb3432636a1e3695a4ad0e58a3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 21 Nov 2015 21:13:56 +0000 Subject: [PATCH 157/732] Ruby container testing enhancement - setting slices --- Examples/test-suite/ruby/li_std_vector_runme.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Examples/test-suite/ruby/li_std_vector_runme.rb b/Examples/test-suite/ruby/li_std_vector_runme.rb index fe3d9e0ce..74eccdf6c 100644 --- a/Examples/test-suite/ruby/li_std_vector_runme.rb +++ b/Examples/test-suite/ruby/li_std_vector_runme.rb @@ -68,6 +68,17 @@ 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) +iv[1,2] = [-2, -4] +swig_assert_equal(iv.to_s, '1-2-45', binding) + +iv = IntVector.new([0,1,2,3]) +iv[0,1] = [-1, -2] +swig_assert_equal(iv.to_s, '-1-2123', binding) + +iv = IntVector.new([1,2,3,4]) +iv[1,3] = [6,7,8,9] +#__setitem__ needs fixing +#swig_assert_equal(iv.to_s, '16789', binding) dv = DoubleVector.new(10) From fe09f05bebbb94df256c9c5cd8257ec0171520ad Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 22 Nov 2015 10:16:28 +0000 Subject: [PATCH 158/732] Ruby STL container negative indexing support improved Using negative indexes to set values works the same as Ruby arrays, eg %template(IntVector) std::vector; iv = IntVector.new([1,2,3,4]) iv[-4] = 9 # => [1,2,3,9] iv[-5] = 9 # => IndexError --- Examples/test-suite/ruby/li_std_vector_runme.rb | 15 +++++++++++++++ Lib/ruby/rubycontainer.swg | 12 +++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/ruby/li_std_vector_runme.rb b/Examples/test-suite/ruby/li_std_vector_runme.rb index 74eccdf6c..49676ee3b 100644 --- a/Examples/test-suite/ruby/li_std_vector_runme.rb +++ b/Examples/test-suite/ruby/li_std_vector_runme.rb @@ -80,6 +80,21 @@ iv[1,3] = [6,7,8,9] #__setitem__ needs fixing #swig_assert_equal(iv.to_s, '16789', binding) +iv = IntVector.new([1,2,3,4]) + +iv[-1] = 9 +iv[-4] = 6 +swig_assert_equal(iv.to_s, '6239', binding) + +begin + iv[-5] = 99 + raise "exception missed" +rescue IndexError +end + +iv[6] = 5 +swig_assert_equal(iv.to_s, '6239555', 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 f8bb76e42..6f75fbb6e 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -825,14 +825,12 @@ namespace swig return swig::from< Sequence* >( swig::getslice(self, s, e+1) ); } - VALUE __setitem__(difference_type i, const value_type& x) throw (std::invalid_argument) + VALUE __setitem__(difference_type i, const value_type& x) throw (std::invalid_argument, std::out_of_range) { - std::size_t len = $self->size(); - if ( i < 0 ) i = len - i; - else if ( static_cast(i) >= len ) + if ( i >= static_cast( $self->size()) ) swig::resize( $self, i+1, x ); - else - *(swig::getpos(self,i)) = x; + else + *(swig::getpos($self, i)) = x; return swig::from< Sequence::value_type >( x ); } @@ -850,7 +848,7 @@ namespace swig } VALUE r = Qnil; - swig::setslice(self, i, j, v); + swig::setslice($self, i, j, v); r = swig::from< const Sequence* >( &v ); return r; } From 97b129de6c6766b92be32da5aab1e6610de56c58 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 22 Nov 2015 11:13:37 +0000 Subject: [PATCH 159/732] Add out of bounds Ruby std::vector and std::array access testing Also fix swig_assert_equal to work with nil as an expected input --- Examples/test-suite/ruby/cpp11_li_std_array_runme.rb | 7 +++++++ Examples/test-suite/ruby/li_std_vector_runme.rb | 5 +++++ Examples/test-suite/ruby/swig_assert.rb | 2 ++ 3 files changed, 14 insertions(+) diff --git a/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb b/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb index 41906f594..0898172cf 100644 --- a/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb +++ b/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb @@ -108,6 +108,13 @@ ai = ArrayInt6.new([9, 8, 7, 6, 5, 4]) arrayInPtr(ai) compare_containers(ai, [90, 80, 70, 60, 50, 40]) +# indexing +ai = ArrayInt6.new([9, 8, 7, 6, 5, 4]) +swig_assert_equal(ai[0], 9, binding) +swig_assert_equal(ai[5], 4, binding) +swig_assert_equal(ai[6], nil, binding) +swig_assert_equal(ai[-7], nil, binding) + # fill ai.fill(111) compare_containers(ai, [111, 111, 111, 111, 111, 111]) diff --git a/Examples/test-suite/ruby/li_std_vector_runme.rb b/Examples/test-suite/ruby/li_std_vector_runme.rb index 49676ee3b..b74b3c25a 100644 --- a/Examples/test-suite/ruby/li_std_vector_runme.rb +++ b/Examples/test-suite/ruby/li_std_vector_runme.rb @@ -82,6 +82,11 @@ iv[1,3] = [6,7,8,9] iv = IntVector.new([1,2,3,4]) +swig_assert_equal(iv[0], 1, binding) +swig_assert_equal(iv[3], 4, binding) +swig_assert_equal(iv[4], nil, binding) +swig_assert_equal(iv[-5], nil, binding) + iv[-1] = 9 iv[-4] = 6 swig_assert_equal(iv.to_s, '6239', binding) diff --git a/Examples/test-suite/ruby/swig_assert.rb b/Examples/test-suite/ruby/swig_assert.rb index 200b08384..69a1a0207 100644 --- a/Examples/test-suite/ruby/swig_assert.rb +++ b/Examples/test-suite/ruby/swig_assert.rb @@ -22,6 +22,8 @@ end # msg - optional additional message to print # def swig_assert_equal( a, b, scope = nil, msg = nil ) + a = 'nil' if a == nil + b = 'nil' if b == nil begin check = "#{a} == #{b}" if scope.kind_of? Binding From cd33aba4277a07b6a1b468239ab73897f6809187 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Nov 2015 18:58:06 +0000 Subject: [PATCH 160/732] Ruby STL container ranges and slices fixes. Access via ranges and slices now behave identically to Ruby arrays. The fixes are mostly for out of range indices and lengths. - Zero length slice requests return an empty container instead of nil. - Slices which request a length greater than the size of the container no longer chop off the last element. - Ranges which used to return nil now return an empty array when the the start element is a valid index. --- .../test-suite/ruby/li_std_vector_runme.rb | 64 ++++++++++++- Lib/ruby/rubycontainer.swg | 90 +++++++++++-------- Lib/ruby/std_array.i | 2 +- 3 files changed, 114 insertions(+), 42 deletions(-) diff --git a/Examples/test-suite/ruby/li_std_vector_runme.rb b/Examples/test-suite/ruby/li_std_vector_runme.rb index b74b3c25a..8d799a7f1 100644 --- a/Examples/test-suite/ruby/li_std_vector_runme.rb +++ b/Examples/test-suite/ruby/li_std_vector_runme.rb @@ -39,12 +39,12 @@ iv.each_with_index { |e,i| "iv.slice(1,2).to_s" => "12", "iv[0,-2]" => nil, "iv[0,3].to_s" => "012", - "iv[0,10].to_s" => "012", + "iv[0,10].to_s" => "0123", "iv[1..2].to_s" => '12', "iv[1..3].to_s" => '123', "iv[1..4].to_s" => '123', "iv[1..-2].to_s" => '12', - "iv[2..-3]" => nil, + "iv[2..-3].to_s" => '', }.each do |k,v| swig_assert( "#{k} == #{v.inspect}", binding ) end @@ -100,6 +100,66 @@ end iv[6] = 5 swig_assert_equal(iv.to_s, '6239555', binding) +def failed(a, b, msg) + a = 'nil' if a == nil + b = 'nil' if b == nil + raise RuntimeError, "#{msg}: #{a} ... #{b}" +end + +def compare_sequences(a, b) + if a != nil && b != nil + if a.size != b.size + failed(a, b, "different sizes") + end + for i in 0..a.size-1 + failed(a, b, "elements are different") if a[i] != b[i] + end + else + unless a == nil && b == nil + failed(a, b, "only one of the sequences is nil") + end + end +end + +def check_slice(i, length) + aa = [0,1,2,3] + iv = IntVector.new([0,1,2,3]) + + aa_slice = aa[i, length] + iv_slice = iv[i, length] + compare_sequences(aa_slice, iv_slice) + + aa_slice = aa.slice(i, length) + iv_slice = iv.slice(i, length) + compare_sequences(aa_slice, iv_slice) +end + +def check_range(i, j) + aa = [0,1,2,3] + iv = IntVector.new([0,1,2,3]) + + aa_range = aa[i..j] + iv_range = iv[i..j] + compare_sequences(aa_range, iv_range) + + aa_range = aa[Range.new(i, j, true)] + iv_range = iv[Range.new(i, j, true)] + compare_sequences(aa_range, iv_range) +end + +for i in -5..5 + for length in -5..5 + check_slice(i, length) + end +end + +for i in -5..5 + for j in -5..5 + check_range(i, j) + end +end + + 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 6f75fbb6e..2f355d71b 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -101,7 +101,7 @@ namespace swig { inline Sequence* getslice(const Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); - typename Sequence::size_type ii = swig::check_index(i, size); + typename Sequence::size_type ii = (i == size && j == size) ? i : swig::check_index(i, size); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { @@ -619,23 +619,28 @@ namespace swig %extend { - VALUE slice( difference_type i, difference_type j ) throw (std::invalid_argument) - { - if ( j <= 0 ) return Qnil; - std::size_t len = $self->size(); - if ( i < 0 ) i = len - i; - j += i; - if ( static_cast(j) >= len ) j = len-1; - - VALUE r = Qnil; - try { - r = swig::from< const Sequence* >( swig::getslice(self, i, j) ); - } - catch( std::out_of_range ) - { - } - return r; + VALUE slice( difference_type i, difference_type length ) throw (std::invalid_argument) { + if ( length < 0 ) + return Qnil; + std::size_t len = $self->size(); + if ( i < 0 ) { + if ( i + static_cast(len) < 0 ) + return Qnil; + else + i = len + i; } + Sequence::difference_type j = length + i; + if ( j > static_cast(len) ) + j = len; + + VALUE r = Qnil; + try { + r = swig::from< const Sequence* >( swig::getslice(self, i, j) ); + } + catch( std::out_of_range ) { + } + return r; + } Sequence* each() @@ -761,25 +766,31 @@ namespace swig try { r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) ); } - catch( std::out_of_range ) - { - } + catch( std::out_of_range ) { + } return r; } - VALUE __getitem__(difference_type i, difference_type j) const throw (std::invalid_argument) { - if ( j <= 0 ) return Qnil; + VALUE __getitem__(difference_type i, difference_type length) const throw (std::invalid_argument) { + if ( length < 0 ) + return Qnil; std::size_t len = $self->size(); - if ( i < 0 ) i = len - i; - j += i; if ( static_cast(j) >= len ) j = len-1; + if ( i < 0 ) { + if ( i + static_cast(len) < 0 ) + return Qnil; + else + i = len + i; + } + Sequence::difference_type j = length + i; + if ( j > static_cast(len) ) + j = len; VALUE r = Qnil; try { r = swig::from< const Sequence* >( swig::getslice(self, i, j) ); } - catch( std::out_of_range ) - { - } + catch( std::out_of_range ) { + } return r; } @@ -788,17 +799,15 @@ namespace swig try { r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) ); } - catch( std::out_of_range ) - { - } + catch( std::out_of_range ) { + } return r; } VALUE __getitem__(VALUE i) const throw (std::invalid_argument) { - if ( rb_obj_is_kind_of( i, rb_cRange ) == Qfalse ) - { - rb_raise( rb_eTypeError, "not a valid index or range" ); - } + if ( rb_obj_is_kind_of( i, rb_cRange ) == Qfalse ) { + rb_raise( rb_eTypeError, "not a valid index or range" ); + } static ID id_end = rb_intern("end"); static ID id_start = rb_intern("begin"); @@ -811,16 +820,19 @@ namespace swig int len = $self->size(); int s = NUM2INT( start ); - if ( s < 0 ) s = len + s; - else if ( s >= len ) return Qnil; + if ( s < 0 ) { + s = len + s; + if ( s < 0 ) + return Qnil; + } else if ( s > len ) + return Qnil; int e = NUM2INT( end ); if ( e < 0 ) e = len + e; - - if ( e < s ) return Qnil; //std::swap( s, e ); - if ( noend ) e -= 1; + if ( e < 0 ) e = -1; if ( e >= len ) e = len - 1; + if ( s == len ) e = len - 1; return swig::from< Sequence* >( swig::getslice(self, s, e+1) ); } diff --git a/Lib/ruby/std_array.i b/Lib/ruby/std_array.i index 51ea09ba6..da97a8c3c 100644 --- a/Lib/ruby/std_array.i +++ b/Lib/ruby/std_array.i @@ -41,7 +41,7 @@ getslice(const std::array* self, Difference i, Difference j) { using Sequence = std::array; typename Sequence::size_type size = self->size(); - typename Sequence::size_type ii = swig::check_index(i, size); + typename Sequence::size_type ii = (i == size && j == size) ? i : swig::check_index(i, size); typename Sequence::size_type jj = swig::slice_index(j, size); if (ii == 0 && jj == size) { From bb2523a0036256a07c2d40231ad9ee7db7261a29 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Nov 2015 23:58:30 +0000 Subject: [PATCH 161/732] Ruby STL container setting slices fixes Setting an STL container wrapper slice better matches the way Ruby arrays work. The behaviour is now the same as Ruby arrays. The only exception is the default value used when expanding a container cannot be nil as this is not a valid type/value for C++ container elements. --- .../ruby/cpp11_li_std_array_runme.rb | 11 ++-- .../test-suite/ruby/li_std_vector_runme.rb | 54 +++++++++++++++++-- Lib/ruby/rubycontainer.swg | 22 ++++---- Lib/ruby/std_array.i | 3 +- 4 files changed, 68 insertions(+), 22 deletions(-) diff --git a/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb b/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb index 0898172cf..a7e678596 100644 --- a/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb +++ b/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb @@ -72,13 +72,12 @@ ai = ArrayInt6.new() compare_containers([0, 0, 0, 0, 0, 0], ai) # Set slice -#newvals = [10, 20, 30, 40, 50, 60] -#ai[0..5] = newvals -#compare_containers(ai, newvals) +newvals = [10, 20, 30, 40, 50, 60] +ai[0, 6] = newvals +compare_containers(ai, newvals) -#newvals = [10000, 20000, 30000, 40000, 50000, 60000] -#ai[0..100] = newvals -#compare_containers(ai, newvals[0..100]) +ai[-6, 6] = newvals +compare_containers(ai, newvals) setslice_exception(ai, [1, 2, 3, 4, 5, 6, 7]) setslice_exception(ai, [1, 2, 3, 4, 5]) diff --git a/Examples/test-suite/ruby/li_std_vector_runme.rb b/Examples/test-suite/ruby/li_std_vector_runme.rb index 8d799a7f1..68feb8f1a 100644 --- a/Examples/test-suite/ruby/li_std_vector_runme.rb +++ b/Examples/test-suite/ruby/li_std_vector_runme.rb @@ -109,7 +109,7 @@ end def compare_sequences(a, b) if a != nil && b != nil if a.size != b.size - failed(a, b, "different sizes") + failed(a, b, "different sizes") end for i in 0..a.size-1 failed(a, b, "elements are different") if a[i] != b[i] @@ -121,9 +121,26 @@ def compare_sequences(a, b) end end +def compare_expanded_sequences(a, b) + # a can contain nil elements which indicate additional elements + # b won't contain nil for additional elements + if a != nil && b != nil + if a.size != b.size + failed(a, b, "different sizes") + end + for i in 0..a.size-1 + failed(a, b, "elements are different") if a[i] != b[i] && a[i] != nil + end + else + unless a == nil && b == nil + failed(a, b, "only one of the sequences is nil") + end + end +end + def check_slice(i, length) - aa = [0,1,2,3] - iv = IntVector.new([0,1,2,3]) + aa = [1,2,3,4] + iv = IntVector.new(aa) aa_slice = aa[i, length] iv_slice = iv[i, length] @@ -135,8 +152,8 @@ def check_slice(i, length) end def check_range(i, j) - aa = [0,1,2,3] - iv = IntVector.new([0,1,2,3]) + aa = [1,2,3,4] + iv = IntVector.new(aa) aa_range = aa[i..j] iv_range = iv[i..j] @@ -147,6 +164,21 @@ def check_range(i, j) compare_sequences(aa_range, iv_range) end +def set_slice(i, length, expect_nil_expanded_elements) + aa = [1,2,3,4] + iv = IntVector.new(aa) + aa_new = [8, 9] + iv_new = IntVector.new(aa_new) + + aa[i, length] = aa_new + iv[i, length] = iv_new + if expect_nil_expanded_elements + compare_expanded_sequences(aa, iv) + else + compare_sequences(aa, iv) + end +end + for i in -5..5 for length in -5..5 check_slice(i, length) @@ -159,6 +191,18 @@ for i in -5..5 end end +for i in -4..4 + for length in 0..4 + set_slice(i, length, false) + end +end + +for i in [5, 6] + for length in 0..5 + set_slice(i, length, true) + end +end + dv = DoubleVector.new(10) diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index 2f355d71b..2908ef7b7 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -101,7 +101,7 @@ namespace swig { inline Sequence* getslice(const Sequence* self, Difference i, Difference j) { typename Sequence::size_type size = self->size(); - typename Sequence::size_type ii = (i == size && j == size) ? i : swig::check_index(i, size); + typename Sequence::size_type ii = swig::check_index(i, size, (i == size && j == size)); typename Sequence::size_type jj = swig::slice_index(j, size); if (jj > ii) { @@ -847,16 +847,20 @@ namespace swig return swig::from< Sequence::value_type >( x ); } - VALUE __setitem__(difference_type i, difference_type j, const Sequence& v) throw (std::invalid_argument) - { + VALUE __setitem__(difference_type i, difference_type length, const Sequence& v) throw (std::invalid_argument) { - if ( j <= 0 ) return Qnil; + if ( length < 0 ) + return Qnil; std::size_t len = $self->size(); - if ( i < 0 ) i = len - i; - j += i; - if ( static_cast(j) >= len ) { - swig::resize( $self, j+1, *(v.begin()) ); - j = len-1; + if ( i < 0 ) { + if ( i + static_cast(len) < 0 ) + return Qnil; + else + i = len + i; + } + Sequence::difference_type j = length + i; + if ( j > static_cast(len) ) { + swig::resize( $self, j, *(v.begin()) ); } VALUE r = Qnil; diff --git a/Lib/ruby/std_array.i b/Lib/ruby/std_array.i index da97a8c3c..6fb537a17 100644 --- a/Lib/ruby/std_array.i +++ b/Lib/ruby/std_array.i @@ -41,7 +41,7 @@ getslice(const std::array* self, Difference i, Difference j) { using Sequence = std::array; typename Sequence::size_type size = self->size(); - typename Sequence::size_type ii = (i == size && j == size) ? i : swig::check_index(i, size); + typename Sequence::size_type ii = swig::check_index(i, size, (i == size && j == size)); typename Sequence::size_type jj = swig::slice_index(j, size); if (ii == 0 && jj == size) { @@ -61,7 +61,6 @@ typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); -std::cout << "setslice " << v[0] << " " << v[1] << std::endl; if (ii == 0 && jj == size) { std::copy(v.begin(), v.end(), self->begin()); } else { From b69719eb5b149b13fc797dee860c0bb4424bfe6e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 25 Nov 2015 19:20:36 +0000 Subject: [PATCH 162/732] changes file note and docs for std::array --- CHANGES.current | 38 ++++++++++++++++++++++++++++++++++++++ Doc/Manual/Library.html | 3 ++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index a000ffa44..76abe41db 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,44 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-11-25: wsfulton + [Ruby] STL ranges and slices fixes. + + Ruby STL container setting slices fixes: + + Setting an STL container wrapper slice better matches the way Ruby + arrays work. The behaviour is now the same as Ruby arrays. The only + exception is the default value used when expanding a container + cannot be nil as this is not a valid type/value for C++ container + elements. + + Obtaining a Ruby STL container ranges and slices fixes: + + Access via ranges and slices now behave identically to Ruby arrays. + The fixes are mostly for out of range indices and lengths. + - Zero length slice requests return an empty container instead of nil. + - Slices which request a length greater than the size of the container + no longer chop off the last element. + - Ranges which used to return nil now return an empty array when the + the start element is a valid index. + + Ruby STL container negative indexing support improved. + + Using negative indexes to set values works the same as Ruby arrays, eg + + %template(IntVector) std::vector; + + iv = IntVector.new([1,2,3,4]) + iv[-4] = 9 # => [1,2,3,9] + iv[-5] = 9 # => IndexError + +2015-11-21: wsfulton + [Ruby, Python] Add std::array container wrappers. + + These work much like any of the other STL containers except Python/Ruby slicing + is somewhat limited because the array is a fixed size. Only slices of + the full size are supported. + 2015-10-10: wsfulton [Python] #539 - Support Python 3.5 and -builtin. PyAsyncMethods is a new member in PyHeapTypeObject. diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 069707559..fb12e3ce8 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -1392,7 +1392,8 @@ The following table shows which C++ classes are supported and the equivalent SWI std::set set std_set.i std::string string std_string.i std::vector vector std_vector.i - std::shared_ptr shared_ptr std_shared_ptr.i + std::array array (C++11) std_array.i + std::shared_ptr shared_ptr (C++11) std_shared_ptr.i From 93eb7eae0b13e80430106d0ee2100ad097a2748c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 27 Nov 2015 19:30:22 +0000 Subject: [PATCH 163/732] Limited Python/Ruby support for boost::array Hack to use the std::array support for boost::array. Is limited as it currently exposes some 'using' bugs in SWIG. For example, the type system fails to see that pointers to std::array and pointers to boost::array are the same. This approach saves having to maintain separate boost::array support. The 'using' bug ought to be fixed, otherwise separate boost_array.i files could be easily made from the std_array.i files. --- Examples/test-suite/common.mk | 1 + Examples/test-suite/cpp11_li_std_array.i | 9 +++ Examples/test-suite/li_boost_array.i | 77 +++++++++++++++++++ .../python/cpp11_li_std_array_runme.py | 3 + .../test-suite/python/li_boost_array_runme.py | 55 +++++++++++++ .../ruby/cpp11_li_std_array_runme.rb | 1 + .../test-suite/ruby/li_boost_array_runme.rb | 70 +++++++++++++++++ Lib/python/std_array.i | 4 +- Lib/ruby/std_array.i | 4 +- Lib/std/std_array.i | 3 - 10 files changed, 220 insertions(+), 7 deletions(-) create mode 100644 Examples/test-suite/li_boost_array.i create mode 100644 Examples/test-suite/python/li_boost_array_runme.py create mode 100644 Examples/test-suite/ruby/li_boost_array_runme.rb diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 114c568c5..7b114fe7b 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -258,6 +258,7 @@ CPP_TEST_CASES += \ langobj \ li_attribute \ li_attribute_template \ + li_boost_array \ li_boost_shared_ptr \ li_boost_shared_ptr_bits \ li_boost_shared_ptr_template \ diff --git a/Examples/test-suite/cpp11_li_std_array.i b/Examples/test-suite/cpp11_li_std_array.i index e8e50105f..74e34370c 100644 --- a/Examples/test-suite/cpp11_li_std_array.i +++ b/Examples/test-suite/cpp11_li_std_array.i @@ -2,6 +2,10 @@ #if defined(SWIGPYTHON) || defined(SWIGRUBY) +%{ +#include +%} + %include %template(ArrayInt6) std::array; @@ -16,6 +20,11 @@ std::array & arrayOutRef() { return a; } +const std::array & arrayOutConstRef() { + static std::array a = { -2, -1, 0, 0, 1, 2 }; + return a; +} + std::array * arrayOutPtr() { static std::array a = { -2, -1, 0, 0, 1, 2 }; return &a; diff --git a/Examples/test-suite/li_boost_array.i b/Examples/test-suite/li_boost_array.i new file mode 100644 index 000000000..4458e780d --- /dev/null +++ b/Examples/test-suite/li_boost_array.i @@ -0,0 +1,77 @@ +%module li_boost_array + +#if defined(SWIGPYTHON) || defined(SWIGRUBY) + +// Hack to use the std::array support for boost::array. +// Is limited as it currently exposes some 'using' bugs in SWIG though. +// For example, the type system fails to see that pointers to std::array +// and pointers to boost::array are the same. + +%{ +#include +namespace std { + using boost::array; +} +%} +namespace boost { + using std::array; +} + +%include + +%template(ArrayInt6) std::array; + +%inline %{ +boost::array arrayOutVal() { + const char carray[] = { -2, -1, 0, 0, 1, 2 }; + boost::array myarray; + for (size_t i=0; i<6; ++i) { + myarray[i] = carray[i]; + } + return myarray; +} + +boost::array & arrayOutRef() { + static boost::array a = { -2, -1, 0, 0, 1, 2 }; + return a; +} + +const boost::array & arrayOutConstRef() { + static boost::array a = { -2, -1, 0, 0, 1, 2 }; + return a; +} + +boost::array * arrayOutPtr() { + static boost::array a = { -2, -1, 0, 0, 1, 2 }; + return &a; +} + +boost::array arrayInVal(boost::array myarray) { + for (boost::array::iterator it = myarray.begin(); it!=myarray.end(); ++it) { + *it *= 10; + } + return myarray; +} + +const boost::array & arrayInConstRef(const boost::array & myarray) { + static boost::array a = myarray; + for (boost::array::iterator it = a.begin(); it!=a.end(); ++it) { + *it *= 10; + } + return a; +} + +void arrayInRef(boost::array & myarray) { + for (boost::array::iterator it = myarray.begin(); it!=myarray.end(); ++it) { + *it *= 10; + } +} + +void arrayInPtr(boost::array * myarray) { + for (boost::array::iterator it = myarray->begin(); it!=myarray->end(); ++it) { + *it *= 10; + } +} +%} + +#endif diff --git a/Examples/test-suite/python/cpp11_li_std_array_runme.py b/Examples/test-suite/python/cpp11_li_std_array_runme.py index d6e1348e9..3b1ceb2f8 100644 --- a/Examples/test-suite/python/cpp11_li_std_array_runme.py +++ b/Examples/test-suite/python/cpp11_li_std_array_runme.py @@ -64,6 +64,8 @@ ps = [0, 1, 2, 3, 4, 5] ai = ArrayInt6(ps) +compare_containers(ps, ai) + # slices compare_containers(ps[0:6], ai[0:6]) compare_containers(ps[0:10], ai[0:10]) @@ -137,6 +139,7 @@ setslice_exception(ai, []) # Check return compare_containers(arrayOutVal(), [-2, -1, 0, 0, 1, 2]) +compare_containers(arrayOutConstRef(), [-2, -1, 0, 0, 1, 2]) compare_containers(arrayOutRef(), [-2, -1, 0, 0, 1, 2]) compare_containers(arrayOutPtr(), [-2, -1, 0, 0, 1, 2]) diff --git a/Examples/test-suite/python/li_boost_array_runme.py b/Examples/test-suite/python/li_boost_array_runme.py new file mode 100644 index 000000000..4fa7eb882 --- /dev/null +++ b/Examples/test-suite/python/li_boost_array_runme.py @@ -0,0 +1,55 @@ +from li_boost_array import * +import sys + + +def failed(a, b, msg): + raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b)) + + +def compare_sequences(a, b): + if len(a) != len(b): + failed(a, b, "different sizes") + for i in range(len(a)): + if a[i] != b[i]: + failed(a, b, "elements are different") + +def compare_containers(pythonlist, swigarray): + compare_sequences(pythonlist, swigarray) + +ps = [0, 1, 2, 3, 4, 5] + +ai = ArrayInt6(ps) + +compare_containers(ps, ai) + +# Modify content +for i in range(len(ps)): + ps[i] = (ps[i] + 1) * 10 + ai[i] = (ai[i] + 1) * 10 +compare_containers(ps, ai) + +# Empty +ai = ArrayInt6() +compare_containers([0, 0, 0, 0, 0, 0], ai) + +# Check return +compare_containers(arrayOutVal(), [-2, -1, 0, 0, 1, 2]) +compare_containers(arrayOutConstRef(), [-2, -1, 0, 0, 1, 2]) +#compare_containers(arrayOutRef(), [-2, -1, 0, 0, 1, 2]) +#compare_containers(arrayOutPtr(), [-2, -1, 0, 0, 1, 2]) + +# Check passing arguments +ai = arrayInVal([9, 8, 7, 6, 5, 4]) +compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +ai = arrayInConstRef([9, 8, 7, 6, 5, 4]) +compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +#ai = ArrayInt6([9, 8, 7, 6, 5, 4]) +#arrayInRef(ai) +#compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +#ai = ArrayInt6([9, 8, 7, 6, 5, 4]) +#arrayInPtr(ai) +#compare_containers(ai, [90, 80, 70, 60, 50, 40]) + diff --git a/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb b/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb index a7e678596..770f37c0f 100644 --- a/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb +++ b/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb @@ -89,6 +89,7 @@ setslice_exception(ai, []) # Check return compare_containers(arrayOutVal(), [-2, -1, 0, 0, 1, 2]) +compare_containers(arrayOutConstRef(), [-2, -1, 0, 0, 1, 2]) compare_containers(arrayOutRef(), [-2, -1, 0, 0, 1, 2]) compare_containers(arrayOutPtr(), [-2, -1, 0, 0, 1, 2]) diff --git a/Examples/test-suite/ruby/li_boost_array_runme.rb b/Examples/test-suite/ruby/li_boost_array_runme.rb new file mode 100644 index 000000000..a7b7720ea --- /dev/null +++ b/Examples/test-suite/ruby/li_boost_array_runme.rb @@ -0,0 +1,70 @@ +#!/usr/bin/env ruby +# +# Put description here +# +# +# +# +# + +require 'swig_assert' + +require 'li_boost_array' + +include Li_boost_array + + +def failed(a, b, msg) + raise RuntimeError, "#{msg} #{a} #{b}" +end + +def compare_sequences(a, b) + if a.size != b.size + failed(a, b, "different sizes") + end + for i in 0..a.size-1 + failed(a, b, "elements are different:") if a[i] != b[i] + end +end + +def compare_containers(rubyarray, swigarray) + compare_sequences(rubyarray, swigarray) +end + +ps = [0, 1, 2, 3, 4, 5] + +ai = ArrayInt6.new(ps) + +compare_containers(ps, ai) + +# Modify content +for i in 0..ps.size-1 + ps[i] = ps[i] * 10 + ai[i] = ai[i] * 10 +end +compare_containers(ps, ai) + +# Empty +ai = ArrayInt6.new() + +# Check return +compare_containers(arrayOutVal(), [-2, -1, 0, 0, 1, 2]) +compare_containers(arrayOutConstRef(), [-2, -1, 0, 0, 1, 2]) +#compare_containers(arrayOutRef(), [-2, -1, 0, 0, 1, 2]) +#compare_containers(arrayOutPtr(), [-2, -1, 0, 0, 1, 2]) + +# Check passing arguments +ai = arrayInVal([9, 8, 7, 6, 5, 4]) +compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +ai = arrayInConstRef([9, 8, 7, 6, 5, 4]) +compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +#ai = ArrayInt6.new([9, 8, 7, 6, 5, 4]) +#arrayInRef(ai) +#compare_containers(ai, [90, 80, 70, 60, 50, 40]) + +#ai = ArrayInt6.new([9, 8, 7, 6, 5, 4]) +#arrayInPtr(ai) +#compare_containers(ai, [90, 80, 70, 60, 50, 40]) + diff --git a/Lib/python/std_array.i b/Lib/python/std_array.i index b894868a0..19fb6cca1 100644 --- a/Lib/python/std_array.i +++ b/Lib/python/std_array.i @@ -39,7 +39,7 @@ template inline std::array* getslice(const std::array* self, Difference i, Difference j, Py_ssize_t step) { - using Sequence = std::array; + typedef std::array Sequence; typename Sequence::size_type size = self->size(); Difference ii = 0; Difference jj = 0; @@ -61,7 +61,7 @@ template inline void setslice(std::array* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) { - using Sequence = std::array; + typedef std::array Sequence; typename Sequence::size_type size = self->size(); Difference ii = 0; Difference jj = 0; diff --git a/Lib/ruby/std_array.i b/Lib/ruby/std_array.i index 6fb537a17..a4d3ef54b 100644 --- a/Lib/ruby/std_array.i +++ b/Lib/ruby/std_array.i @@ -39,7 +39,7 @@ template inline std::array* getslice(const std::array* self, Difference i, Difference j) { - using Sequence = std::array; + typedef std::array Sequence; typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, (i == size && j == size)); typename Sequence::size_type jj = swig::slice_index(j, size); @@ -56,7 +56,7 @@ template inline void setslice(std::array* self, Difference i, Difference j, const InputSeq& v) { - using Sequence = std::array; + typedef std::array Sequence; typename Sequence::size_type size = self->size(); typename Sequence::size_type ii = swig::check_index(i, size, true); typename Sequence::size_type jj = swig::slice_index(j, size); diff --git a/Lib/std/std_array.i b/Lib/std/std_array.i index 0676f670e..a308eccad 100644 --- a/Lib/std/std_array.i +++ b/Lib/std/std_array.i @@ -40,9 +40,6 @@ // for consistency, they expect and return a plain array pointer. // ------------------------------------------------------------------------ -%{ -#include -%} // exported classes From ed044e4b8c316138bfd94d5f8582a9176a116981 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 28 Nov 2015 18:47:11 +0000 Subject: [PATCH 164/732] Warning fix for Visual Studio --- Source/Modules/python.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3395ebe68..570f8fafe 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -802,8 +802,8 @@ public: const char *triple_double = "\"\"\""; // follow PEP257 rules: https://www.python.org/dev/peps/pep-0257/ // reported by pep257: https://github.com/GreenSteam/pep257 - const bool multi_line_ds = Strchr(mod_docstring, '\n'); - Printv(f_shadow, triple_double, multi_line_ds?"\n":"", mod_docstring, multi_line_ds?"\n":"", triple_double, "\n\n", NIL); + bool multi_line_ds = Strchr(mod_docstring, '\n') != 0; + Printv(f_shadow, triple_double, multi_line_ds ? "\n":"", mod_docstring, multi_line_ds ? "\n":"", triple_double, "\n\n", NIL); Delete(mod_docstring); mod_docstring = NULL; } From 80a8a7f0d8a8251b395b49c7c820061cbd093d76 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 28 Nov 2015 18:49:22 +0000 Subject: [PATCH 165/732] boost::array test fix when using C++11 --- Examples/test-suite/li_boost_array.i | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Examples/test-suite/li_boost_array.i b/Examples/test-suite/li_boost_array.i index 4458e780d..8ac717ed6 100644 --- a/Examples/test-suite/li_boost_array.i +++ b/Examples/test-suite/li_boost_array.i @@ -8,10 +8,18 @@ // and pointers to boost::array are the same. %{ +#if __cplusplus < 201103 #include namespace std { using boost::array; } +#else +// Use C++11 array as this is unfortunately is sometimes included by +#include +namespace boost { + using std::array; +} +#endif %} namespace boost { using std::array; From 4c0db9d83daeaf6fe0b7292ade512ba8da7f5571 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 28 Nov 2015 14:27:45 +0000 Subject: [PATCH 166/732] Python 3 on windows configure fix For Appveyor, don't use python-config which comes from Cygwin --- configure.ac | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index b6842e35c..f352b8201 100644 --- a/configure.ac +++ b/configure.ac @@ -624,6 +624,10 @@ else AC_MSG_RESULT($PYVER) if test -z "$PYVER"; then PYVER=0 + else + AC_MSG_CHECKING(for Python os.name) + PYOSNAME=`($PYTHON -c "import sys, os; sys.stdout.write(os.name)")` + AC_MSG_RESULT($PYOSNAME) fi fi @@ -634,9 +638,6 @@ else AC_MSG_CHECKING(for Python exec-prefix) PYEPREFIX=`($PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)") 2>/dev/null` AC_MSG_RESULT($PYEPREFIX) - AC_MSG_CHECKING(for Python os.name) - PYOSNAME=`($PYTHON -c "import sys, os; sys.stdout.write(os.name)")` - AC_MSG_RESULT($PYOSNAME) if test x"$PYOSNAME" = x"nt"; then # Windows installations are quite different to posix installations @@ -751,22 +752,28 @@ AS_HELP_STRING([--with-python3=path], [Set location of Python 3.x executable]),[ if test x"${PY3BIN}" = xno; then AC_MSG_NOTICE([Disabling Python 3.x support]) else + if test -z "$PYVER"; then + PYVER=0 + fi if test "x$PY3BIN" = xyes; then - for py_ver in 3 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 ""; do - AC_CHECK_PROGS(PYTHON3, [python$py_ver]) - if test -n "$PYTHON3"; then - AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config]) - if test -n "$PY3CONFIG"; then - break + if test x"$PYOSNAME" = x"nt" -a $PYVER -ge 3; then + PYTHON3="$PYTHON" + else + for py_ver in 3 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 ""; do + AC_CHECK_PROGS(PYTHON3, [python$py_ver]) + if test -n "$PYTHON3"; then + AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config]) + if test -n "$PY3CONFIG"; then + break + fi fi - fi - done + done + fi else PYTHON3="$PY3BIN" AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config]) fi - PYVER=0 if test -n "$PYTHON3"; then AC_MSG_CHECKING([for $PYTHON3 major version number]) PYVER=`($PYTHON3 -c "import sys; sys.stdout.write(sys.version[[0]])") 2>/dev/null` From 327b59a574c81437f79b168655feff04b12ce56d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 28 Nov 2015 23:52:32 +0000 Subject: [PATCH 167/732] size_type correction for SwigPySequence_Cont --- 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 7c5cc37f9..ceb3b667f 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -567,7 +567,7 @@ namespace swig typedef T value_type; typedef T* pointer; typedef int difference_type; - typedef int size_type; + typedef size_t size_type; typedef const pointer const_pointer; typedef SwigPySequence_InputIterator iterator; typedef SwigPySequence_InputIterator const_iterator; From 8c96b0de0b41c08abb030c986ca4f3aad37a700f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 29 Nov 2015 15:57:12 +0000 Subject: [PATCH 168/732] std::array unused parameter warning fixes --- Lib/python/std_array.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/python/std_array.i b/Lib/python/std_array.i index 19fb6cca1..bad818be7 100644 --- a/Lib/python/std_array.i +++ b/Lib/python/std_array.i @@ -31,7 +31,7 @@ template inline void - erase(std::array* seq, const typename std::array::iterator& position) { + erase(std::array* SWIGUNUSEDPARM(seq), const typename std::array::iterator& SWIGUNUSEDPARM(position)) { throw std::invalid_argument("std::array object does not support item deletion"); } @@ -78,7 +78,7 @@ template inline void - delslice(std::array* self, Difference i, Difference j, Py_ssize_t step) { + delslice(std::array* SWIGUNUSEDPARM(self), Difference SWIGUNUSEDPARM(i), Difference SWIGUNUSEDPARM(j), Py_ssize_t SWIGUNUSEDPARM(step)) { throw std::invalid_argument("std::array object does not support item deletion"); } } From 3bfffab9f98e8315a952c952838d1f1caef9afb1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 29 Nov 2015 19:42:35 +0000 Subject: [PATCH 169/732] Fix boost::array test for Visual Studio Visual Studio doesn't set __cplusplus correctly when supporting c++11 --- Examples/test-suite/li_boost_array.i | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/li_boost_array.i b/Examples/test-suite/li_boost_array.i index 8ac717ed6..ab40991a1 100644 --- a/Examples/test-suite/li_boost_array.i +++ b/Examples/test-suite/li_boost_array.i @@ -8,17 +8,17 @@ // and pointers to boost::array are the same. %{ -#if __cplusplus < 201103 -#include -namespace std { - using boost::array; -} -#else -// Use C++11 array as this is unfortunately is sometimes included by +#if __cplusplus >= 201103 || (defined(_MSC_VER) && _MSC_VER >= 1900) +// Use C++11 array as this is unfortunately sometimes included by #include namespace boost { using std::array; } +#else +#include +namespace std { + using boost::array; +} #endif %} namespace boost { From c5322a9ecb2b9b13ad6300cf1675192a54f952c1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 4 Dec 2015 23:32:46 +0000 Subject: [PATCH 170/732] Python use Py_ssize_t instead of int for better portability --- Lib/python/pycontainer.swg | 25 ++++++++++++------------- Lib/python/pyrun.swg | 12 +++++------- Lib/python/pystrings.swg | 6 +++--- Lib/python/pywstrings.swg | 2 +- Lib/python/std_map.i | 26 +++++++++++--------------- Lib/python/std_multimap.i | 5 ++--- Lib/python/std_unordered_map.i | 26 +++++++++++--------------- Lib/python/std_unordered_multimap.i | 5 ++--- Source/Modules/python.cxx | 6 +++--- 9 files changed, 50 insertions(+), 63 deletions(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index ceb3b667f..46d04388b 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -421,7 +421,7 @@ namespace swig template struct SwigPySequence_Ref { - SwigPySequence_Ref(PyObject* seq, int index) + SwigPySequence_Ref(PyObject* seq, Py_ssize_t index) : _seq(seq), _index(index) { } @@ -433,7 +433,7 @@ namespace swig return swig::as(item, true); } catch (std::exception& e) { char msg[1024]; - sprintf(msg, "in sequence element %d ", _index); + sprintf(msg, "in sequence element %d ", (int)_index); if (!PyErr_Occurred()) { ::%type_error(swig::type_name()); } @@ -451,7 +451,7 @@ namespace swig private: PyObject* _seq; - int _index; + Py_ssize_t _index; }; template @@ -472,13 +472,13 @@ namespace swig typedef Reference reference; typedef T value_type; typedef T* pointer; - typedef int difference_type; + typedef Py_ssize_t difference_type; SwigPySequence_InputIterator() { } - SwigPySequence_InputIterator(PyObject* seq, int index) + SwigPySequence_InputIterator(PyObject* seq, Py_ssize_t index) : _seq(seq), _index(index) { } @@ -566,7 +566,7 @@ namespace swig typedef const SwigPySequence_Ref const_reference; typedef T value_type; typedef T* pointer; - typedef int difference_type; + typedef Py_ssize_t difference_type; typedef size_t size_type; typedef const pointer const_pointer; typedef SwigPySequence_InputIterator iterator; @@ -628,13 +628,13 @@ namespace swig bool check(bool set_err = true) const { - int s = size(); - for (int i = 0; i < s; ++i) { + Py_ssize_t s = size(); + for (Py_ssize_t i = 0; i < s; ++i) { swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i); if (!swig::check(item)) { if (set_err) { char msg[1024]; - sprintf(msg, "in sequence element %d", i); + sprintf(msg, "in sequence element %d", (int)i); SWIG_Error(SWIG_RuntimeError, msg); } return false; @@ -1013,10 +1013,9 @@ namespace swig { %#endif size_type size = seq.size(); if (size <= (size_type)INT_MAX) { - PyObject *obj = PyTuple_New((int)size); - int i = 0; - for (const_iterator it = seq.begin(); - it != seq.end(); ++it, ++i) { + PyObject *obj = PyTuple_New((Py_ssize_t)size); + Py_ssize_t i = 0; + for (const_iterator it = seq.begin(); it != seq.end(); ++it, ++i) { PyTuple_SetItem(obj,i,swig::from(*it)); } return obj; diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index d43b75202..85ff2763e 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -161,7 +161,7 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { /* Unpack the argument tuple */ -SWIGINTERN int +SWIGINTERN Py_ssize_t SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { if (!args) { @@ -175,7 +175,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi } if (!PyTuple_Check(args)) { if (min <= 1 && max >= 1) { - int i; + Py_ssize_t i; objs[0] = args; for (i = 1; i < max; ++i) { objs[i] = 0; @@ -195,7 +195,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi name, (min == max ? "" : "at most "), (int)max, (int)l); return 0; } else { - int i; + Py_ssize_t i; for (i = 0; i < l; ++i) { objs[i] = PyTuple_GET_ITEM(args, i); } @@ -1515,13 +1515,11 @@ PyModule_AddObject(PyObject *m, char *name, PyObject *o) { PyObject *dict; if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs module as first arg"); + PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); return SWIG_ERROR; } if (!o) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs non-NULL value"); + PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); return SWIG_ERROR; } diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index 2b14547ad..2eefaefea 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -90,12 +90,12 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) } else { %#if PY_VERSION_HEX >= 0x03000000 %#if PY_VERSION_HEX >= 0x03010000 - return PyUnicode_DecodeUTF8(carray, %numeric_cast(size,int), "surrogateescape"); + return PyUnicode_DecodeUTF8(carray, %numeric_cast(size, Py_ssize_t), "surrogateescape"); %#else - return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int)); + return PyUnicode_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t)); %#endif %#else - return PyString_FromStringAndSize(carray, %numeric_cast(size,int)); + return PyString_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t)); %#endif } } else { diff --git a/Lib/python/pywstrings.swg b/Lib/python/pywstrings.swg index 864376b01..79f193b61 100644 --- a/Lib/python/pywstrings.swg +++ b/Lib/python/pywstrings.swg @@ -58,7 +58,7 @@ SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size) return pwchar_descriptor ? SWIG_InternalNewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : SWIG_Py_Void(); } else { - return PyUnicode_FromWideChar(carray, %numeric_cast(size,int)); + return PyUnicode_FromWideChar(carray, %numeric_cast(size, Py_ssize_t)); } } else { return SWIG_Py_Void(); diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index 454e821a5..65dd91d9c 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -119,10 +119,9 @@ static PyObject *asdict(const map_type& map) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; size_type size = map.size(); - int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { - PyErr_SetString(PyExc_OverflowError, - "map size not valid in python"); + PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } @@ -211,17 +210,16 @@ PyObject* keys() { Map::size_type size = self->size(); - int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { - PyErr_SetString(PyExc_OverflowError, - "map size not valid in python"); + PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* keyList = PyList_New(pysize); Map::const_iterator i = self->begin(); - for (int j = 0; j < pysize; ++i, ++j) { + for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(keyList, j, swig::from(i->first)); } SWIG_PYTHON_THREAD_END_BLOCK; @@ -230,17 +228,16 @@ PyObject* values() { Map::size_type size = self->size(); - int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { - PyErr_SetString(PyExc_OverflowError, - "map size not valid in python"); + PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* valList = PyList_New(pysize); Map::const_iterator i = self->begin(); - for (int j = 0; j < pysize; ++i, ++j) { + for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(valList, j, swig::from(i->second)); } SWIG_PYTHON_THREAD_END_BLOCK; @@ -249,17 +246,16 @@ PyObject* items() { Map::size_type size = self->size(); - int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { - PyErr_SetString(PyExc_OverflowError, - "map size not valid in python"); + PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* itemList = PyList_New(pysize); Map::const_iterator i = self->begin(); - for (int j = 0; j < pysize; ++i, ++j) { + for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(itemList, j, swig::from(*i)); } SWIG_PYTHON_THREAD_END_BLOCK; diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i index c81e2ac5d..2c539cf29 100644 --- a/Lib/python/std_multimap.i +++ b/Lib/python/std_multimap.i @@ -45,11 +45,10 @@ return SWIG_InternalNewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN); } else { size_type size = multimap.size(); - int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(PyExc_OverflowError, - "multimap size not valid in python"); + PyErr_SetString(PyExc_OverflowError, "multimap size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index e58a4e927..f956f4fb3 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -48,11 +48,10 @@ return SWIG_NewPointerObj(new unordered_map_type(unordered_map), desc, SWIG_POINTER_OWN); } else { size_type size = unordered_map.size(); - int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(PyExc_OverflowError, - "unordered_map size not valid in python"); + PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } @@ -164,17 +163,16 @@ PyObject* keys() { Map::size_type size = self->size(); - int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(PyExc_OverflowError, - "unordered_map size not valid in python"); + PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* keyList = PyList_New(pysize); Map::const_iterator i = self->begin(); - for (int j = 0; j < pysize; ++i, ++j) { + for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(keyList, j, swig::from(i->first)); } return keyList; @@ -182,17 +180,16 @@ PyObject* values() { Map::size_type size = self->size(); - int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(PyExc_OverflowError, - "unordered_map size not valid in python"); + PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* valList = PyList_New(pysize); Map::const_iterator i = self->begin(); - for (int j = 0; j < pysize; ++i, ++j) { + for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(valList, j, swig::from(i->second)); } return valList; @@ -200,17 +197,16 @@ PyObject* items() { Map::size_type size = self->size(); - int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(PyExc_OverflowError, - "unordered_map size not valid in python"); + PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } PyObject* itemList = PyList_New(pysize); Map::const_iterator i = self->begin(); - for (int j = 0; j < pysize; ++i, ++j) { + for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(itemList, j, swig::from(*i)); } return itemList; diff --git a/Lib/python/std_unordered_multimap.i b/Lib/python/std_unordered_multimap.i index adf86f251..b3b723637 100644 --- a/Lib/python/std_unordered_multimap.i +++ b/Lib/python/std_unordered_multimap.i @@ -45,11 +45,10 @@ return SWIG_NewPointerObj(new unordered_multimap_type(unordered_multimap), desc, SWIG_POINTER_OWN); } else { size_type size = unordered_multimap.size(); - int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; if (pysize < 0) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(PyExc_OverflowError, - "unordered_multimap size not valid in python"); + PyErr_SetString(PyExc_OverflowError, "unordered_multimap size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 570f8fafe..e91047a39 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2473,15 +2473,15 @@ public: Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args) {", NIL); - Wrapper_add_local(f, "argc", "int argc"); + Wrapper_add_local(f, "argc", "Py_ssize_t argc"); Printf(tmp, "PyObject *argv[%d] = {0}", maxargs + 1); Wrapper_add_local(f, "argv", tmp); if (!fastunpack) { - Wrapper_add_local(f, "ii", "int ii"); + Wrapper_add_local(f, "ii", "Py_ssize_t ii"); if (maxargs - (add_self ? 1 : 0) > 0) Append(f->code, "if (!PyTuple_Check(args)) SWIG_fail;\n"); - Append(f->code, "argc = args ? (int)PyObject_Length(args) : 0;\n"); + Append(f->code, "argc = args ? PyObject_Length(args) : 0;\n"); if (add_self) Append(f->code, "argv[0] = self;\n"); Printf(f->code, "for (ii = 0; (ii < %d) && (ii < argc); ii++) {\n", add_self ? maxargs - 1 : maxargs); From ffd32797cca0f22ba88c60b5d122fd91cfcb1a7f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 Dec 2015 11:28:24 +0000 Subject: [PATCH 171/732] Switch appveyor to test Python 3.4 instead of 3.5 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 1e60c37d4..d4ed6bbcf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,7 +15,7 @@ environment: VER: 27 - SWIGLANG: python VSVER: 12 - VER: 34 + VER: 35 PY3: 1 matrix: From 51ee23b580ca0cd088ff7adfdeec633d4caef937 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 Dec 2015 19:22:33 +0000 Subject: [PATCH 172/732] Link to distutils fix --- Doc/Manual/Python.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 77d0b7e81..373472d86 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -281,7 +281,7 @@ how you might go about compiling and using the generated files.

    The preferred approach to building an extension module for python is to compile it with distutils, which comes with all recent versions of python -(Distutils Docs). +(Distutils Docs).

    From 625a405b8e42f944fdc1a87e36725f03b8817a85 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 Dec 2015 19:23:14 +0000 Subject: [PATCH 173/732] Add python inplace operator caveats to pyopers.swg Observations reported in issue #562 --- Lib/python/pyopers.swg | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg index ecbe7834e..80a0d68c6 100644 --- a/Lib/python/pyopers.swg +++ b/Lib/python/pyopers.swg @@ -151,11 +151,11 @@ __bool__ = __nonzero__ They translate the inplace C++ operators (+=, -=, ...) into the corresponding python equivalents(__iadd__,__isub__), etc, - disabling the ownership of the input 'self' pointer, and assigning + disabling the ownership of the input 'this' pointer, and assigning it to the returning object: - %feature("del") *::Operator; - %feature("new") *::Operator; + %feature("del") *::Operator; // disables ownership by generating SWIG_POINTER_DISOWN + %feature("new") *::Operator; // claims ownership by generating SWIG_POINTER_OWN This makes the most common case safe, ie: @@ -174,8 +174,8 @@ __bool__ = __nonzero__ that never get deleted (maybe, not sure, it depends). But if that is the case, you could recover the old behaviour using - %feature("del","") A::operator+=; - %feature("new","") A::operator+=; + %feature("del","0") A::operator+=; + %feature("new","0") A::operator+=; which recovers the old behaviour for the class 'A', or if you are 100% sure your entire system works fine in the old way, use: @@ -183,6 +183,12 @@ __bool__ = __nonzero__ %feature("del","") *::operator+=; %feature("new","") *::operator+=; + The default behaviour assumes that the 'this' pointer's memory is + already owned by the SWIG object; it relinquishes ownership then + takes it back. This may not be the case though as the SWIG object + might be owned by memory managed elsewhere, eg after calling a + function that returns a C++ reference. In such case you will need + to use the features above to recover the old behaviour too. */ #if defined(SWIGPYTHON_BUILTIN) From 6b4e57245dcea7fb975aad8563bdbf5d9a786ce8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Dec 2015 14:05:05 +0000 Subject: [PATCH 174/732] Fix STL wrappers to not generate <: digraphs. For example std::vector<::X::Y> was sometimes generated, now corrected to std::vector< ::X::Y >. --- CHANGES.current | 5 ++ Examples/test-suite/li_std_pair.i | 17 +++++ Examples/test-suite/li_std_vector.i | 22 ++++++ Lib/guile/std_map.i | 104 +++++++++++++--------------- Lib/guile/std_pair.i | 16 ++--- Lib/guile/std_vector.i | 30 ++++---- Lib/octave/std_common.i | 16 ++--- Lib/perl5/std_list.i | 12 ++-- Lib/perl5/std_map.i | 6 +- Lib/perl5/std_vector.i | 12 ++-- Lib/python/std_common.i | 16 ++--- Lib/r/std_common.i | 16 ++--- Lib/ruby/std_common.i | 16 ++--- Lib/scilab/std_common.i | 12 ++-- Lib/std/_std_deque.i | 10 +-- Lib/std/std_array.i | 8 +-- Lib/std/std_basic_string.i | 12 ++-- Lib/std/std_common.i | 28 ++++---- Lib/std/std_container.i | 12 ++-- Lib/std/std_deque.i | 22 +++--- Lib/std/std_list.i | 24 +++---- Lib/std/std_map.i | 14 ++-- Lib/std/std_multimap.i | 16 ++--- Lib/std/std_multiset.i | 12 ++-- Lib/std/std_pair.i | 42 +++++------ Lib/std/std_queue.i | 22 +++--- Lib/std/std_set.i | 12 ++-- Lib/std/std_stack.i | 22 +++--- Lib/std/std_unordered_map.i | 16 ++--- Lib/std/std_unordered_multimap.i | 16 ++--- Lib/std/std_unordered_multiset.i | 12 ++-- Lib/std/std_unordered_set.i | 14 ++-- Lib/std/std_vector.i | 28 ++++---- 33 files changed, 339 insertions(+), 303 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 76abe41db..df5c7e1fb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-12-12: wsfulton + Fix STL wrappers to not generate <: digraphs. + For example std::vector<::X::Y> was sometimes generated, now + corrected to std::vector< ::X::Y >. + 2015-11-25: wsfulton [Ruby] STL ranges and slices fixes. diff --git a/Examples/test-suite/li_std_pair.i b/Examples/test-suite/li_std_pair.i index 9dea1d814..49ccb4aa4 100644 --- a/Examples/test-suite/li_std_pair.i +++ b/Examples/test-suite/li_std_pair.i @@ -60,3 +60,20 @@ int product3(const std::pair *p) { %} +// Test that the digraph <::aa::Holder> is not generated for stl containers +%include + +%inline %{ +namespace aa { + struct Holder { + Holder(int n = 0) : number(n) {} + int number; + }; +} +%} + +%template(PairTest) std::pair< ::aa::Holder, int >; + +%inline %{ +std::pair< ::aa::Holder, int > pair1(std::pair< ::aa::Holder, int > x) { return x; } +%} diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i index 55e0f4f6d..99fb88a52 100644 --- a/Examples/test-suite/li_std_vector.i +++ b/Examples/test-suite/li_std_vector.i @@ -108,3 +108,25 @@ const std::vector & vecstructconstptr(const std::vector LanguageVector; } #endif + + +// Test that the digraph <::aa::Holder> is not generated +%include + +%inline %{ +namespace aa { + struct Holder { + Holder(int n = 0) : number(n) {} + int number; + }; +} +%} + +#if !defined(SWIGOCTAVE) +// To fix: something different in Octave is preventing this from working +%template(VectorTest) std::vector< ::aa::Holder >; + +%inline %{ +std::vector< ::aa::Holder > vec1(std::vector< ::aa::Holder > x) { return x; } +%} +#endif diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i index 1e1014f54..fefbe2e77 100644 --- a/Lib/guile/std_map.i +++ b/Lib/guile/std_map.i @@ -43,9 +43,9 @@ namespace std { template class map { %typemap(in) map (std::map* m) { if (scm_is_null($input)) { - $1 = std::map(); + $1 = std::map< K, T >(); } else if (scm_is_pair($input)) { - $1 = std::map(); + $1 = std::map< K, T >(); SCM alist = $input; while (!scm_is_null(alist)) { K* k; @@ -77,10 +77,10 @@ namespace std { const map* (std::map temp, std::map* m) { if (scm_is_null($input)) { - temp = std::map(); + temp = std::map< K, T >(); $1 = &temp; } else if (scm_is_pair($input)) { - temp = std::map(); + temp = std::map< K, T >(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { @@ -109,8 +109,7 @@ namespace std { } %typemap(out) map { SCM alist = SCM_EOL; - for (std::map::reverse_iterator i=$i.rbegin(); - i!=$i.rend(); ++i) { + for (std::map< K, T >::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); @@ -156,7 +155,7 @@ namespace std { } } else { /* wrapped map? */ - std::map* m; + std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; @@ -201,7 +200,7 @@ namespace std { } } else { /* wrapped map? */ - std::map* m; + std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; @@ -222,14 +221,14 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map< K, T> &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& __getitem__(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -239,20 +238,19 @@ namespace std { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; - for (std::map::reverse_iterator i=self->rbegin(); - i!=self->rend(); ++i) { + for (std::map< K, T >::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); @@ -270,9 +268,9 @@ namespace std { template class map { %typemap(in) map (std::map* m) { if (scm_is_null($input)) { - $1 = std::map(); + $1 = std::map< K, T >(); } else if (scm_is_pair($input)) { - $1 = std::map(); + $1 = std::map< K, T >(); SCM alist = $input; while (!scm_is_null(alist)) { T* x; @@ -305,10 +303,10 @@ namespace std { const map* (std::map temp, std::map* m) { if (scm_is_null($input)) { - temp = std::map(); + temp = std::map< K, T >(); $1 = &temp; } else if (scm_is_pair($input)) { - temp = std::map(); + temp = std::map< K, T >(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { @@ -338,8 +336,7 @@ namespace std { } %typemap(out) map { SCM alist = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map< K, T >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { T* val = new T(i->second); SCM k = CONVERT_TO(i->first); SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); @@ -382,7 +379,7 @@ namespace std { } } else { // wrapped map? - std::map* m; + std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; @@ -425,7 +422,7 @@ namespace std { } } else { // wrapped map? - std::map* m; + std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; @@ -442,14 +439,14 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map &); + map(const map< K, T > &); unsigned int size() const; bool empty() const; void clear(); %extend { T& __getitem__(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -459,20 +456,19 @@ namespace std { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; - for (std::map::reverse_iterator i=self->rbegin(); - i!=self->rend(); ++i) { + for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { SCM k = CONVERT_TO(i->first); result = scm_cons(k,result); } @@ -486,9 +482,9 @@ namespace std { template class map { %typemap(in) map (std::map* m) { if (scm_is_null($input)) { - $1 = std::map(); + $1 = std::map< K, T >(); } else if (scm_is_pair($input)) { - $1 = std::map(); + $1 = std::map< K, T >(); SCM alist = $input; while (!scm_is_null(alist)) { K* k; @@ -520,10 +516,10 @@ namespace std { const map* (std::map temp, std::map* m) { if (scm_is_null($input)) { - temp = std::map(); + temp = std::map< K, T >(); $1 = &temp; } else if (scm_is_pair($input)) { - temp = std::map(); + temp = std::map< K, T >(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { @@ -552,8 +548,7 @@ namespace std { } %typemap(out) map { SCM alist = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map< K, T >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); SCM x = CONVERT_TO(i->second); @@ -595,7 +590,7 @@ namespace std { } } else { // wrapped map? - std::map* m; + std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; @@ -637,7 +632,7 @@ namespace std { } } else { // wrapped map? - std::map* m; + std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; @@ -654,14 +649,14 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map &); + map(const map< K, T > &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -671,20 +666,19 @@ namespace std { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; - for (std::map::reverse_iterator i=self->rbegin(); - i!=self->rend(); ++i) { + for (std::map< K, T >::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); @@ -700,9 +694,9 @@ namespace std { template<> class map { %typemap(in) map (std::map* m) { if (scm_is_null($input)) { - $1 = std::map(); + $1 = std::map< K, T >(); } else if (scm_is_pair($input)) { - $1 = std::map(); + $1 = std::map< K, T >(); SCM alist = $input; while (!scm_is_null(alist)) { SCM entry, key, val; @@ -736,10 +730,10 @@ namespace std { const map* (std::map temp, std::map* m) { if (scm_is_null($input)) { - temp = std::map(); + temp = std::map< K, T >(); $1 = &temp; } else if (scm_is_pair($input)) { - temp = std::map(); + temp = std::map< K, T >(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { @@ -769,8 +763,7 @@ namespace std { } %typemap(out) map { SCM alist = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map< K, T >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { SCM k = CONVERT_K_TO(i->first); SCM x = CONVERT_T_TO(i->second); SCM entry = scm_cons(k,x); @@ -809,7 +802,7 @@ namespace std { } } else { // wrapped map? - std::map* m; + std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; @@ -849,7 +842,7 @@ namespace std { } } else { // wrapped map? - std::map* m; + std::map< K, T >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; @@ -866,14 +859,14 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map &); + map(const map< K, T> &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -883,20 +876,19 @@ namespace std { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; - for (std::map::reverse_iterator i=self->rbegin(); - i!=self->rend(); ++i) { + for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { SCM k = CONVERT_K_TO(i->first); result = scm_cons(k,result); } diff --git a/Lib/guile/std_pair.i b/Lib/guile/std_pair.i index 512d0d555..92dec5fae 100644 --- a/Lib/guile/std_pair.i +++ b/Lib/guile/std_pair.i @@ -79,7 +79,7 @@ namespace std { } } else { /* wrapped pair? */ - std::pair* m; + std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; @@ -105,7 +105,7 @@ namespace std { } } else { /* wrapped pair? */ - std::pair* m; + std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; @@ -183,7 +183,7 @@ namespace std { } } else { /* wrapped pair? */ - std::pair* m; + std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; @@ -207,7 +207,7 @@ namespace std { } } else { /* wrapped pair? */ - std::pair* m; + std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; @@ -283,7 +283,7 @@ namespace std { } } else { /* wrapped pair? */ - std::pair* m; + std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; @@ -307,7 +307,7 @@ namespace std { } } else { /* wrapped pair? */ - std::pair* m; + std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; @@ -377,7 +377,7 @@ namespace std { } } else { /* wrapped pair? */ - std::pair* m; + std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; @@ -398,7 +398,7 @@ namespace std { } } else { /* wrapped pair? */ - std::pair* m; + std::pair< T, U >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; diff --git a/Lib/guile/std_vector.i b/Lib/guile/std_vector.i index 1c55239c1..d7a7140c6 100644 --- a/Lib/guile/std_vector.i +++ b/Lib/guile/std_vector.i @@ -44,17 +44,17 @@ namespace std { %typemap(in) vector { if (scm_is_vector($input)) { unsigned long size = scm_c_vector_length($input); - $1 = std::vector(size); + $1 = std::vector< T >(size); for (unsigned long i=0; i(); + $1 = std::vector< T >(); } else if (scm_is_pair($input)) { SCM head, tail; - $1 = std::vector(); + $1 = std::vector< T >(); tail = $input; while (!scm_is_null(tail)) { head = SCM_CAR(tail); @@ -72,7 +72,7 @@ namespace std { const vector* (std::vector temp) { if (scm_is_vector($input)) { unsigned long size = scm_c_vector_length($input); - temp = std::vector(size); + temp = std::vector< T >(size); $1 = &temp; for (unsigned long i=0; i(); + temp = std::vector< T >(); $1 = &temp; } else if (scm_is_pair($input)) { - temp = std::vector(); + temp = std::vector< T >(); $1 = &temp; SCM head, tail; tail = $input; @@ -138,7 +138,7 @@ namespace std { $1 = 0; } else { /* wrapped vector? */ - std::vector* v; + std::vector< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor, 0) != -1) $1 = 1; @@ -178,7 +178,7 @@ namespace std { $1 = 0; } else { /* wrapped vector? */ - std::vector* v; + std::vector< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor, 0) != -1) $1 = 1; @@ -232,7 +232,7 @@ namespace std { %typemap(in) vector { if (scm_is_vector($input)) { unsigned long size = scm_c_vector_length($input); - $1 = std::vector(size); + $1 = std::vector< T >(size); for (unsigned long i=0; i(size); + $1 = std::vector< T >(size); for (unsigned long i=0; i* (std::vector temp) { if (scm_is_vector($input)) { unsigned long size = scm_c_vector_length($input); - temp = std::vector(size); + temp = std::vector< T >(size); $1 = &temp; for (unsigned long i=0; i(); + temp = std::vector< T >(); $1 = &temp; } else if (scm_is_pair($input)) { SCM v = scm_vector($input); unsigned long size = scm_c_vector_length(v); - temp = std::vector(size); + temp = std::vector< T >(size); $1 = &temp; for (unsigned long i=0; i* v; + std::vector< T >* v; $1 = (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor, 0) != -1) ? 1 : 0; } @@ -345,7 +345,7 @@ namespace std { $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ - std::vector* v; + std::vector< T >* v; $1 = (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor, 0) != -1) ? 1 : 0; } diff --git a/Lib/octave/std_common.i b/Lib/octave/std_common.i index 9aebf7f45..c8f17ba7f 100644 --- a/Lib/octave/std_common.i +++ b/Lib/octave/std_common.i @@ -11,17 +11,17 @@ fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { - template <> struct traits { + template <> struct traits< Type > { typedef value_category category; static const char* type_name() { return #Type; } - }; - template <> struct traits_asval { + }; + template <> struct traits_asval< Type > { typedef Type value_type; - static int asval(octave_value obj, value_type *val) { + static int asval(octave_value obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; - template <> struct traits_from { + template <> struct traits_from< Type > { typedef Type value_type; static octave_value from(const value_type& val) { return SWIG_From(Type)(val); @@ -44,13 +44,13 @@ namespace swig { fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { - template <> struct traits_asval { + template <> struct traits_asval< Type > { typedef Type value_type; - static int asval(octave_value obj, value_type *val) { + static int asval(octave_value obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; - template <> struct traits_from { + template <> struct traits_from< Type > { typedef Type value_type; static octave_value from(const value_type& val) { return SWIG_From(int)((int)val); diff --git a/Lib/perl5/std_list.i b/Lib/perl5/std_list.i index 8248ca679..cd5a61120 100644 --- a/Lib/perl5/std_list.i +++ b/Lib/perl5/std_list.i @@ -106,7 +106,7 @@ namespace std { } } %typemap(out) list { - std::list::const_iterator i; + std::list< T >::const_iterator i; unsigned int j; int len = $1.size(); SV **svs = new SV*[len]; @@ -125,7 +125,7 @@ namespace std { %typecheck(SWIG_TYPECHECK_LIST) list { { /* wrapped list? */ - std::list* v; + std::list< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_&descriptor,0) != -1) { $1 = 1; @@ -158,7 +158,7 @@ namespace std { const list* { { /* wrapped list? */ - std::list* v; + std::list< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0) != -1) { $1 = 1; @@ -265,7 +265,7 @@ namespace std { } } %typemap(out) list { - std::list::const_iterator i; + std::list< T >::const_iterator i; unsigned int j; int len = $1.size(); SV **svs = new SV*[len]; @@ -282,7 +282,7 @@ namespace std { %typecheck(SWIG_TYPECHECK_LIST) list { { /* wrapped list? */ - std::list* v; + std::list< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_&descriptor,0) != -1) { $1 = 1; @@ -313,7 +313,7 @@ namespace std { const list* { { /* wrapped list? */ - std::list* v; + std::list< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0) != -1) { $1 = 1; diff --git a/Lib/perl5/std_map.i b/Lib/perl5/std_map.i index 493307dd9..af49ed38e 100644 --- a/Lib/perl5/std_map.i +++ b/Lib/perl5/std_map.i @@ -35,7 +35,7 @@ namespace std { void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -45,14 +45,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T >::iterator i = self->find(key); return i != self->end(); } } diff --git a/Lib/perl5/std_vector.i b/Lib/perl5/std_vector.i index 860cdba7e..ec8449464 100644 --- a/Lib/perl5/std_vector.i +++ b/Lib/perl5/std_vector.i @@ -119,7 +119,7 @@ namespace std { %typecheck(SWIG_TYPECHECK_VECTOR) vector { { /* wrapped vector? */ - std::vector* v; + std::vector< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0) != -1) { $1 = 1; @@ -151,7 +151,7 @@ namespace std { const vector* { { /* wrapped vector? */ - std::vector* v; + std::vector< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0) != -1) { $1 = 1; @@ -292,7 +292,7 @@ namespace std { %typecheck(SWIG_TYPECHECK_VECTOR) vector { { /* wrapped vector? */ - std::vector* v; + std::vector< T *>* v; int res = SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0); if (SWIG_IsOK(res)) { $1 = 1; @@ -323,7 +323,7 @@ namespace std { %typecheck(SWIG_TYPECHECK_VECTOR) const vector&,const vector* { { /* wrapped vector? */ - std::vector *v; + std::vector< T *> *v; int res = SWIG_ConvertPtr($input,%as_voidptrptr(&v), $1_descriptor,0); if (SWIG_IsOK(res)) { $1 = 1; @@ -466,7 +466,7 @@ namespace std { %typecheck(SWIG_TYPECHECK_VECTOR) vector { { /* wrapped vector? */ - std::vector* v; + std::vector< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0) != -1) { $1 = 1; @@ -496,7 +496,7 @@ namespace std { const vector* { { /* wrapped vector? */ - std::vector* v; + std::vector< T >* v; if (SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0) != -1) { $1 = 1; diff --git a/Lib/python/std_common.i b/Lib/python/std_common.i index 401bbde7f..605766238 100644 --- a/Lib/python/std_common.i +++ b/Lib/python/std_common.i @@ -13,17 +13,17 @@ fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { - template <> struct traits { + template <> struct traits< Type > { typedef value_category category; static const char* type_name() { return #Type; } - }; - template <> struct traits_asval { + }; + template <> struct traits_asval< Type > { typedef Type value_type; - static int asval(PyObject *obj, value_type *val) { + static int asval(PyObject *obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; - template <> struct traits_from { + template <> struct traits_from< Type > { typedef Type value_type; static PyObject *from(const value_type& val) { return SWIG_From(Type)(val); @@ -46,13 +46,13 @@ namespace swig { fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { - template <> struct traits_asval { + template <> struct traits_asval< Type > { typedef Type value_type; - static int asval(PyObject *obj, value_type *val) { + static int asval(PyObject *obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; - template <> struct traits_from { + template <> struct traits_from< Type > { typedef Type value_type; static PyObject *from(const value_type& val) { return SWIG_From(int)((int)val); diff --git a/Lib/r/std_common.i b/Lib/r/std_common.i index 8e97521b0..cda262310 100644 --- a/Lib/r/std_common.i +++ b/Lib/r/std_common.i @@ -12,17 +12,17 @@ fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { - template <> struct traits { + template <> struct traits< Type > { typedef value_category category; static const char* type_name() { return #Type; } - }; - template <> struct traits_asval { + }; + template <> struct traits_asval< Type > { typedef Type value_type; - static int asval(SEXP obj, value_type *val) { + static int asval(SEXP obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; - template <> struct traits_from { + template <> struct traits_from< Type > { typedef Type value_type; static SEXP from(const value_type& val) { return SWIG_From(Type)(val); @@ -45,13 +45,13 @@ namespace swig { fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { - template <> struct traits_asval { + template <> struct traits_asval< Type > { typedef Type value_type; - static int asval(SEXP obj, value_type *val) { + static int asval(SEXP obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; - template <> struct traits_from { + template <> struct traits_from< Type > { typedef Type value_type; static SEXP from(const value_type& val) { return SWIG_From(int)((int)val); diff --git a/Lib/ruby/std_common.i b/Lib/ruby/std_common.i index 14fba0df3..0cf9ce109 100644 --- a/Lib/ruby/std_common.i +++ b/Lib/ruby/std_common.i @@ -14,17 +14,17 @@ fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { - template <> struct traits { + template <> struct traits< Type > { typedef value_category category; static const char* type_name() { return #Type; } - }; - template <> struct traits_asval { + }; + template <> struct traits_asval< Type > { typedef Type value_type; - static int asval(VALUE obj, value_type *val) { + static int asval(VALUE obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; - template <> struct traits_from { + template <> struct traits_from< Type > { typedef Type value_type; static VALUE from(const value_type& val) { return SWIG_From(Type)(val); @@ -47,13 +47,13 @@ namespace swig { fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { - template <> struct traits_asval { + template <> struct traits_asval< Type > { typedef Type value_type; - static int asval(VALUE obj, value_type *val) { + static int asval(VALUE obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; - template <> struct traits_from { + template <> struct traits_from< Type > { typedef Type value_type; static VALUE from(const value_type& val) { return SWIG_From(int)((int)val); diff --git a/Lib/scilab/std_common.i b/Lib/scilab/std_common.i index 4524ffd6b..97cfa7b07 100644 --- a/Lib/scilab/std_common.i +++ b/Lib/scilab/std_common.i @@ -11,17 +11,17 @@ fragment=SWIG_From_frag(Type), fragment="StdTraits") { namespace swig { - template <> struct traits { + template <> struct traits< Type > { typedef value_category category; static const char* type_name() { return #Type; } - }; - template <> struct traits_asval { + }; + template <> struct traits_asval< Type > { typedef Type value_type; static int asval(SwigSciObject obj, value_type *val) { return SWIG_AsVal(Type)(obj, val); } }; - template <> struct traits_from { + template <> struct traits_from< Type > { typedef Type value_type; static SwigSciObject from(const value_type& val) { return SWIG_From(Type)(val); @@ -44,13 +44,13 @@ namespace swig { fragment=SWIG_From_frag(int), fragment="StdTraits") { namespace swig { - template <> struct traits_asval { + template <> struct traits_asval< Type > { typedef Type value_type; static int asval(SwigSciObject obj, value_type *val) { return SWIG_AsVal(int)(obj, (int *)val); } }; - template <> struct traits_from { + template <> struct traits_from< Type > { typedef Type value_type; static SwigSciObject from(const value_type& val) { return SWIG_From(int)((int)val); diff --git a/Lib/std/_std_deque.i b/Lib/std/_std_deque.i index 7dd3552db..e860e947f 100644 --- a/Lib/std/_std_deque.i +++ b/Lib/std/_std_deque.i @@ -35,11 +35,11 @@ deque(); deque(unsigned int size, const T& value=T()); - deque(const deque &); + deque(const deque< T > &); ~deque(); void assign(unsigned int n, const T& value); - void swap(deque &x); + void swap(deque< T > &x); unsigned int size() const; unsigned int max_size() const; void resize(unsigned int n, T c = T()); @@ -78,17 +78,17 @@ throw std::out_of_range("deque index out of range"); } } - std::deque getslice(int i, int j) { + std::deque< T > getslice(int i, int j) { int size = int(self->size()); if (i<0) i = size+i; if (j<0) j = size+j; if (i<0) i = 0; if (j>size) j = size; - std::deque tmp(j-i); + std::deque< T > tmp(j-i); std::copy(self->begin()+i,self->begin()+j,tmp.begin()); return tmp; } - void setslice(int i, int j, const std::deque& v) { + void setslice(int i, int j, const std::deque< T >& v) { int size = int(self->size()); if (i<0) i = size+i; if (j<0) j = size+j; diff --git a/Lib/std/std_array.i b/Lib/std/std_array.i index a308eccad..aadc3b80c 100644 --- a/Lib/std/std_array.i +++ b/Lib/std/std_array.i @@ -59,11 +59,11 @@ namespace std { %traits_swigtype(_Tp); %traits_enum(_Tp); - %fragment(SWIG_Traits_frag(std::array<_Tp, _Nm >), "header", + %fragment(SWIG_Traits_frag(std::array< _Tp, _Nm >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdArrayTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::array<" #_Tp "," #_Nm " >"; @@ -72,11 +72,11 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_STDARRAY, std::array<_Tp, _Nm >); + %typemap_traits_ptr(SWIG_TYPECHECK_STDARRAY, std::array< _Tp, _Nm >); #ifdef %swig_array_methods // Add swig/language extra methods - %swig_array_methods(std::array<_Tp, _Nm >); + %swig_array_methods(std::array< _Tp, _Nm >); #endif %std_array_methods(array); diff --git a/Lib/std/std_basic_string.i b/Lib/std/std_basic_string.i index 1aa5721c9..fb7afc1e6 100644 --- a/Lib/std/std_basic_string.i +++ b/Lib/std/std_basic_string.i @@ -200,7 +200,7 @@ namespace std { #ifdef %swig_basic_string // Add swig/language extra methods - %swig_basic_string(std::basic_string<_CharT, _Traits, _Alloc >); + %swig_basic_string(std::basic_string< _CharT, _Traits, _Alloc >); #endif #ifdef SWIG_EXPORT_ITERATOR_METHODS @@ -238,19 +238,19 @@ namespace std { %newobject __radd__; %extend { - std::basic_string<_CharT,_Traits,_Alloc >* __add__(const basic_string& v) { - std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(*self); + std::basic_string< _CharT,_Traits,_Alloc >* __add__(const basic_string& v) { + std::basic_string< _CharT,_Traits,_Alloc >* res = new std::basic_string< _CharT,_Traits,_Alloc >(*self); *res += v; return res; } - std::basic_string<_CharT,_Traits,_Alloc >* __radd__(const basic_string& v) { - std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(v); + std::basic_string< _CharT,_Traits,_Alloc >* __radd__(const basic_string& v) { + std::basic_string< _CharT,_Traits,_Alloc >* res = new std::basic_string< _CharT,_Traits,_Alloc >(v); *res += *self; return res; } - std::basic_string<_CharT,_Traits,_Alloc > __str__() { + std::basic_string< _CharT,_Traits,_Alloc > __str__() { return *self; } diff --git a/Lib/std/std_common.i b/Lib/std/std_common.i index 6e93e29f6..b79eaff3a 100644 --- a/Lib/std/std_common.i +++ b/Lib/std/std_common.i @@ -72,7 +72,7 @@ namespace std { %} %fragment("StdTraitsCommon","header",fragment="") %{ -namespace swig { +namespace swig { template struct noconst_traits { typedef Type noconst_type; @@ -86,7 +86,7 @@ namespace swig { /* type categories */ - struct pointer_category { }; + struct pointer_category { }; struct value_category { }; /* @@ -99,12 +99,12 @@ namespace swig { return traits::noconst_type >::type_name(); } - template + template struct traits_info { static swig_type_info *type_query(std::string name) { name += " *"; return SWIG_TypeQuery(name.c_str()); - } + } static swig_type_info *type_info() { static swig_type_info *info = type_query(type_name()); return info; @@ -125,22 +125,22 @@ namespace swig { std::string ptrname = name; ptrname += " *"; return ptrname; - } + } static const char* type_name() { static std::string name = make_ptr_name(swig::type_name()); return name.c_str(); } }; - template + template struct traits_as { }; - - template + + template struct traits_check { }; } %} - + /* Generate the traits for a swigtype */ @@ -148,7 +148,7 @@ namespace swig { %define %traits_swigtype(Type...) %fragment(SWIG_Traits_frag(Type),"header",fragment="StdTraits") { namespace swig { - template <> struct traits { + template <> struct traits< Type > { typedef pointer_category category; static const char* type_name() { return #Type; } }; @@ -164,7 +164,7 @@ namespace swig { %define %typemap_traits(Code,Type...) %typemaps_asvalfrom(%arg(Code), - %arg(swig::asval), + %arg(swig::asval< Type >), %arg(swig::from), %arg(SWIG_Traits_frag(Type)), %arg(SWIG_Traits_frag(Type)), @@ -194,10 +194,10 @@ namespace swig { bool operator == (const Type& v) { return *self == v; } - + bool operator != (const Type& v) { return *self != v; - } + } } %enddef @@ -211,7 +211,7 @@ namespace swig { bool operator > (const Type& v) { return *self > v; } - + bool operator < (const Type& v) { return *self < v; } diff --git a/Lib/std/std_container.i b/Lib/std/std_container.i index fc46aed0c..5fa085afa 100644 --- a/Lib/std/std_container.i +++ b/Lib/std/std_container.i @@ -133,10 +133,10 @@ // Ignore member methods for Type with no default constructor // %define %std_nodefconst_type(Type...) -%feature("ignore") std::vector::vector(size_type size); -%feature("ignore") std::vector::resize(size_type size); -%feature("ignore") std::deque::deque(size_type size); -%feature("ignore") std::deque::resize(size_type size); -%feature("ignore") std::list::list(size_type size); -%feature("ignore") std::list::resize(size_type size); +%feature("ignore") std::vector< Type >::vector(size_type size); +%feature("ignore") std::vector< Type >::resize(size_type size); +%feature("ignore") std::deque< Type >::deque(size_type size); +%feature("ignore") std::deque< Type >::resize(size_type size); +%feature("ignore") std::list< Type >::list(size_type size); +%feature("ignore") std::list< Type >::resize(size_type size); %enddef diff --git a/Lib/std/std_deque.i b/Lib/std/std_deque.i index a99763b79..29560caed 100644 --- a/Lib/std/std_deque.i +++ b/Lib/std/std_deque.i @@ -49,7 +49,7 @@ namespace std { - template > + template > class deque { public: typedef size_t size_type; @@ -63,11 +63,11 @@ namespace std { %traits_swigtype(_Tp); - %fragment(SWIG_Traits_frag(std::deque<_Tp, _Alloc >), "header", + %fragment(SWIG_Traits_frag(std::deque< _Tp, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdDequeTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::deque<" #_Tp " >"; @@ -76,18 +76,18 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque< _Tp, _Alloc >); #ifdef %swig_deque_methods // Add swig/language extra methods - %swig_deque_methods(std::deque<_Tp, _Alloc >); + %swig_deque_methods(std::deque< _Tp, _Alloc >); #endif %std_deque_methods(deque); }; template - class deque<_Tp*, _Alloc > { + class deque< _Tp*, _Alloc > { public: typedef size_t size_type; typedef ptrdiff_t difference_type; @@ -100,11 +100,11 @@ namespace std { %traits_swigtype(_Tp); - %fragment(SWIG_Traits_frag(std::deque<_Tp*, _Alloc >), "header", + %fragment(SWIG_Traits_frag(std::deque< _Tp*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdDequeTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::deque<" #_Tp " * >"; @@ -113,14 +113,14 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp*, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque< _Tp*, _Alloc >); #ifdef %swig_deque_methods_val // Add swig/language extra methods - %swig_deque_methods_val(std::deque<_Tp*, _Alloc >); + %swig_deque_methods_val(std::deque< _Tp*, _Alloc >); #endif - %std_deque_methods_val(std::deque<_Tp*, _Alloc >); + %std_deque_methods_val(std::deque< _Tp*, _Alloc >); }; } diff --git a/Lib/std/std_list.i b/Lib/std/std_list.i index e08935170..1aaec0aa9 100644 --- a/Lib/std/std_list.i +++ b/Lib/std/std_list.i @@ -61,7 +61,7 @@ namespace std { - template > + template > class list { public: typedef size_t size_type; @@ -75,11 +75,11 @@ namespace std { %traits_swigtype(_Tp); - %fragment(SWIG_Traits_frag(std::list<_Tp, _Alloc >), "header", + %fragment(SWIG_Traits_frag(std::list< _Tp, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdListTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::list<" #_Tp ", " #_Alloc " >"; @@ -88,18 +88,18 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<_Tp, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list< _Tp, _Alloc >); #ifdef %swig_list_methods // Add swig/language extra methods - %swig_list_methods(std::list<_Tp, _Alloc >); + %swig_list_methods(std::list< _Tp, _Alloc >); #endif %std_list_methods(list); }; template - class list<_Tp*, _Alloc> { + class list< _Tp*, _Alloc> { public: typedef size_t size_type; typedef ptrdiff_t difference_type; @@ -112,11 +112,11 @@ namespace std { %traits_swigtype(_Tp); - %fragment(SWIG_Traits_frag(std::list<_Tp*, _Alloc >), "header", + %fragment(SWIG_Traits_frag(std::list< _Tp*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdListTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::list<" #_Tp " *," #_Alloc " >"; @@ -125,11 +125,11 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<_Tp*, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list< _Tp*, _Alloc >); #ifdef %swig_list_methods_val // Add swig/language extra methods - %swig_list_methods_val(std::list<_Tp*, _Alloc >); + %swig_list_methods_val(std::list< _Tp*, _Alloc >); #endif %std_list_methods_val(list); @@ -138,9 +138,9 @@ namespace std { } %define %std_extequal_list(...) -%extend std::list<__VA_ARGS__ > { +%extend std::list< __VA_ARGS__ > { void remove(const value_type& x) { self->remove(x); } - void merge(std::list<__VA_ARGS__ >& x){ self->merge(x); } + void merge(std::list< __VA_ARGS__ >& x){ self->merge(x); } void unique() { self->unique(); } void sort() { self->sort(); } } diff --git a/Lib/std/std_map.i b/Lib/std/std_map.i index d1f6b3a16..8043f924c 100644 --- a/Lib/std/std_map.i +++ b/Lib/std/std_map.i @@ -66,14 +66,14 @@ namespace std { template, - class _Alloc = allocator > > + class _Alloc = allocator > > class map { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key key_type; typedef _Tp mapped_type; - typedef std::pair value_type; + typedef std::pair< const _Key, _Tp > value_type; typedef value_type* pointer; typedef const value_type* const_pointer; @@ -98,11 +98,11 @@ namespace std { } } - %fragment(SWIG_Traits_frag(std::map<_Key, _Tp, _Compare, _Alloc >), "header", - fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >), + %fragment(SWIG_Traits_frag(std::map< _Key, _Tp, _Compare, _Alloc >), "header", + fragment=SWIG_Traits_frag(std::pair< _Key, _Tp >), fragment="StdMapTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; @@ -111,13 +111,13 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map<_Key, _Tp, _Compare, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map< _Key, _Tp, _Compare, _Alloc >); map( const _Compare& ); #ifdef %swig_map_methods // Add swig/language extra methods - %swig_map_methods(std::map<_Key, _Tp, _Compare, _Alloc >); + %swig_map_methods(std::map< _Key, _Tp, _Compare, _Alloc >); #endif %std_map_methods(map); diff --git a/Lib/std/std_multimap.i b/Lib/std/std_multimap.i index 39f674da5..7aa949907 100644 --- a/Lib/std/std_multimap.i +++ b/Lib/std/std_multimap.i @@ -41,15 +41,15 @@ namespace std { - template, - class _Alloc = allocator > > + template, + class _Alloc = allocator > > class multimap { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key key_type; typedef _Tp mapped_type; - typedef std::pair value_type; + typedef std::pair< const _Key, _Tp > value_type; typedef value_type* pointer; typedef const value_type* const_pointer; @@ -74,11 +74,11 @@ namespace std { } } - %fragment(SWIG_Traits_frag(std::multimap<_Key, _Tp, _Compare, _Alloc >), "header", - fragment=SWIG_Traits_frag(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") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; @@ -87,13 +87,13 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::multimap<_Key, _Tp, _Compare, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::multimap< _Key, _Tp, _Compare, _Alloc >); multimap( const _Compare& ); #ifdef %swig_multimap_methods // Add swig/language extra methods - %swig_multimap_methods(std::multimap<_Key, _Tp, _Compare, _Alloc >); + %swig_multimap_methods(std::multimap< _Key, _Tp, _Compare, _Alloc >); #endif %std_multimap_methods(multimap); diff --git a/Lib/std/std_multiset.i b/Lib/std/std_multiset.i index b63fb92b9..1aa7ccce8 100644 --- a/Lib/std/std_multiset.i +++ b/Lib/std/std_multiset.i @@ -40,8 +40,8 @@ namespace std { //multiset - template , - class _Alloc = allocator<_Key> > + template , + class _Alloc = allocator< _Key > > class multiset { public: typedef size_t size_type; @@ -56,11 +56,11 @@ namespace std { %traits_swigtype(_Key); - %fragment(SWIG_Traits_frag(std::multiset<_Key, _Compare, _Alloc >), "header", + %fragment(SWIG_Traits_frag(std::multiset< _Key, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(_Key), fragment="StdMultisetTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::multiset<" #_Key "," #_Compare "," #_Alloc " >"; @@ -69,13 +69,13 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::multiset<_Key, _Compare, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::multiset< _Key, _Compare, _Alloc >); multiset( const _Compare& ); #ifdef %swig_multiset_methods // Add swig/language extra methods - %swig_multiset_methods(std::multiset<_Key, _Compare, _Alloc >); + %swig_multiset_methods(std::multiset< _Key, _Compare, _Alloc >); #endif %std_multiset_methods(multiset); diff --git a/Lib/std/std_pair.i b/Lib/std/std_pair.i index 2743430e9..001cd6738 100644 --- a/Lib/std/std_pair.i +++ b/Lib/std/std_pair.i @@ -13,12 +13,12 @@ namespace std { %traits_swigtype(T); %traits_swigtype(U); - %fragment(SWIG_Traits_frag(std::pair), "header", + %fragment(SWIG_Traits_frag(std::pair< T, U >), "header", fragment=SWIG_Traits_frag(T), fragment=SWIG_Traits_frag(U), fragment="StdPairTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #T "," #U " >"; @@ -28,23 +28,23 @@ namespace std { } #ifndef SWIG_STD_PAIR_ASVAL - %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair); + %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair< T, U >); #else - %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair); + %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair< T, U >); #endif pair(); pair(T first, U second); pair(const pair& p); - template pair(const pair &p); + template pair(const pair< U1, U2 > &p); T first; U second; #ifdef %swig_pair_methods // Add swig/language extra methods - %swig_pair_methods(std::pair) + %swig_pair_methods(std::pair< T, U >) #endif }; @@ -52,19 +52,19 @@ namespace std { // The following specializations should disappear or get // simplified when a 'const SWIGTYPE*&' can be defined // *** - template struct pair { + template struct pair< T, U* > { typedef T first_type; typedef U* second_type; %traits_swigtype(T); %traits_swigtype(U); - %fragment(SWIG_Traits_frag(std::pair), "header", + %fragment(SWIG_Traits_frag(std::pair< T, U* >), "header", fragment=SWIG_Traits_frag(T), fragment=SWIG_Traits_frag(U), fragment="StdPairTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #T "," #U " * >"; @@ -73,7 +73,7 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair); + %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair< T, U* >); pair(); pair(T __a, U* __b); @@ -84,23 +84,23 @@ namespace std { #ifdef %swig_pair_methods // Add swig/language extra methods - %swig_pair_methods(std::pair) + %swig_pair_methods(std::pair< T, U* >) #endif }; - template struct pair { + template struct pair< T*, U > { typedef T* first_type; typedef U second_type; %traits_swigtype(T); %traits_swigtype(U); - %fragment(SWIG_Traits_frag(std::pair), "header", + %fragment(SWIG_Traits_frag(std::pair< T*, U >), "header", fragment=SWIG_Traits_frag(T), fragment=SWIG_Traits_frag(U), fragment="StdPairTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #T " *," #U " >"; @@ -109,7 +109,7 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair); + %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair< T*, U >); pair(); pair(T* __a, U __b); @@ -120,23 +120,23 @@ namespace std { #ifdef %swig_pair_methods // Add swig/language extra methods - %swig_pair_methods(std::pair) + %swig_pair_methods(std::pair< T*, U >) #endif }; - template struct pair { + template struct pair< T*, U* > { typedef T* first_type; typedef U* second_type; %traits_swigtype(T); %traits_swigtype(U); - %fragment(SWIG_Traits_frag(std::pair), "header", + %fragment(SWIG_Traits_frag(std::pair< T*, U* >), "header", fragment=SWIG_Traits_frag(T), fragment=SWIG_Traits_frag(U), fragment="StdPairTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::pair<" #T " *," #U " * >"; @@ -145,7 +145,7 @@ namespace std { } } - %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair); + %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair< T*, U* >); pair(); pair(T* __a, U* __b); @@ -156,7 +156,7 @@ namespace std { #ifdef %swig_pair_methods // Add swig/language extra methods - %swig_pair_methods(std::pair) + %swig_pair_methods(std::pair< T*, U* >) #endif }; diff --git a/Lib/std/std_queue.i b/Lib/std/std_queue.i index 42273eee6..7452a4b60 100644 --- a/Lib/std/std_queue.i +++ b/Lib/std/std_queue.i @@ -57,7 +57,7 @@ namespace std { - template > + template > class queue { public: typedef size_t size_type; @@ -68,11 +68,11 @@ namespace std { %traits_swigtype(_Tp); - %fragment(SWIG_Traits_frag(std::queue<_Tp, _Sequence >), "header", + %fragment(SWIG_Traits_frag(std::queue< _Tp, _Sequence >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdQueueTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::queue<" #_Tp "," #_Sequence " >"; @@ -81,18 +81,18 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue<_Tp, _Sequence >); + %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue< _Tp, _Sequence >); #ifdef %swig_queue_methods // Add swig/language extra methods - %swig_queue_methods(std::queue<_Tp, _Sequence >); + %swig_queue_methods(std::queue< _Tp, _Sequence >); #endif %std_queue_methods(queue); }; template - class queue<_Tp*, _Sequence > { + class queue< _Tp*, _Sequence > { public: typedef size_t size_type; typedef _Tp value_type; @@ -102,11 +102,11 @@ namespace std { %traits_swigtype(_Tp); - %fragment(SWIG_Traits_frag(std::queue<_Tp*, _Sequence >), "header", + %fragment(SWIG_Traits_frag(std::queue< _Tp*, _Sequence >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdQueueTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::queue<" #_Tp "," #_Sequence " * >"; @@ -115,14 +115,14 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue<_Tp*, _Sequence >); + %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue< _Tp*, _Sequence >); #ifdef %swig_queue_methods_val // Add swig/language extra methods - %swig_queue_methods_val(std::queue<_Tp*, _Sequence >); + %swig_queue_methods_val(std::queue< _Tp*, _Sequence >); #endif - %std_queue_methods_val(std::queue<_Tp*, _Sequence >); + %std_queue_methods_val(std::queue< _Tp*, _Sequence >); }; } diff --git a/Lib/std/std_set.i b/Lib/std/std_set.i index f96ddd9f1..107a23c71 100644 --- a/Lib/std/std_set.i +++ b/Lib/std/std_set.i @@ -79,8 +79,8 @@ namespace std { - template , - class _Alloc = allocator<_Key> > + template , + class _Alloc = allocator< _Key > > class set { public: typedef size_t size_type; @@ -95,11 +95,11 @@ namespace std { %traits_swigtype(_Key); - %fragment(SWIG_Traits_frag(std::set<_Key, _Compare, _Alloc >), "header", + %fragment(SWIG_Traits_frag(std::set< _Key, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(_Key), fragment="StdSetTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::set<" #_Key "," #_Compare "," #_Alloc " >"; @@ -108,13 +108,13 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::set<_Key, _Compare, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::set< _Key, _Compare, _Alloc >); set( const _Compare& ); #ifdef %swig_set_methods // Add swig/language extra methods - %swig_set_methods(std::set<_Key, _Compare, _Alloc >); + %swig_set_methods(std::set< _Key, _Compare, _Alloc >); #endif %std_set_methods(set); diff --git a/Lib/std/std_stack.i b/Lib/std/std_stack.i index fb900a57c..48dae0585 100644 --- a/Lib/std/std_stack.i +++ b/Lib/std/std_stack.i @@ -56,7 +56,7 @@ namespace std { - template > + template > class stack { public: typedef size_t size_type; @@ -67,11 +67,11 @@ namespace std { %traits_swigtype(_Tp); - %fragment(SWIG_Traits_frag(std::stack<_Tp, _Sequence >), "header", + %fragment(SWIG_Traits_frag(std::stack< _Tp, _Sequence >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdStackTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::stack<" #_Tp "," #_Sequence " >"; @@ -80,18 +80,18 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack<_Tp, _Sequence >); + %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack< _Tp, _Sequence >); #ifdef %swig_stack_methods // Add swig/language extra methods - %swig_stack_methods(std::stack<_Tp, _Sequence >); + %swig_stack_methods(std::stack< _Tp, _Sequence >); #endif %std_stack_methods(stack); }; template - class stack<_Tp*, _Sequence > { + class stack< _Tp*, _Sequence > { public: typedef size_t size_type; typedef _Sequence::value_type value_type; @@ -101,11 +101,11 @@ namespace std { %traits_swigtype(_Tp); - %fragment(SWIG_Traits_frag(std::stack<_Tp*, _Sequence >), "header", + %fragment(SWIG_Traits_frag(std::stack< _Tp*, _Sequence >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdStackTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::stack<" #_Tp "," #_Sequence " * >"; @@ -114,14 +114,14 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack<_Tp*, _Sequence >); + %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack< _Tp*, _Sequence >); #ifdef %swig_stack_methods_val // Add swig/language extra methods - %swig_stack_methods_val(std::stack<_Tp*, _Sequence >); + %swig_stack_methods_val(std::stack< _Tp*, _Sequence >); #endif - %std_stack_methods_val(std::stack<_Tp*, _Sequence >); + %std_stack_methods_val(std::stack< _Tp*, _Sequence >); }; } diff --git a/Lib/std/std_unordered_map.i b/Lib/std/std_unordered_map.i index 8c276172a..1cb714821 100644 --- a/Lib/std/std_unordered_map.i +++ b/Lib/std/std_unordered_map.i @@ -68,15 +68,15 @@ namespace std { - template, - class _Alloc = allocator > > + template, + class _Alloc = allocator > > class unordered_map { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key key_type; typedef _Tp mapped_type; - typedef std::pair value_type; + typedef std::pair< const _Key, _Tp > value_type; typedef value_type* pointer; typedef const value_type* const_pointer; @@ -101,11 +101,11 @@ namespace std { } } - %fragment(SWIG_Traits_frag(std::unordered_map<_Key, _Tp, _Compare, _Alloc >), "header", - fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >), + %fragment(SWIG_Traits_frag(std::unordered_map< _Key, _Tp, _Compare, _Alloc >), "header", + fragment=SWIG_Traits_frag(std::pair< _Key, _Tp >), fragment="StdMapTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::unordered_map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; @@ -114,13 +114,13 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::unordered_map<_Key, _Tp, _Compare, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::unordered_map< _Key, _Tp, _Compare, _Alloc >); unordered_map( const _Compare& ); #ifdef %swig_unordered_map_methods // Add swig/language extra methods - %swig_unordered_map_methods(std::unordered_map<_Key, _Tp, _Compare, _Alloc >); + %swig_unordered_map_methods(std::unordered_map< _Key, _Tp, _Compare, _Alloc >); #endif %std_unordered_map_methods(unordered_map); diff --git a/Lib/std/std_unordered_multimap.i b/Lib/std/std_unordered_multimap.i index 74efb2896..46b56d88a 100644 --- a/Lib/std/std_unordered_multimap.i +++ b/Lib/std/std_unordered_multimap.i @@ -44,15 +44,15 @@ namespace std { - template, - class _Alloc = allocator > > + template, + class _Alloc = allocator > > class unordered_multimap { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Key key_type; typedef _Tp mapped_type; - typedef std::pair value_type; + typedef std::pair< const _Key, _Tp > value_type; typedef value_type* pointer; typedef const value_type* const_pointer; @@ -63,11 +63,11 @@ namespace std { %traits_swigtype(_Key); %traits_swigtype(_Tp); - %fragment(SWIG_Traits_frag(std::unordered_multimap<_Key, _Tp, _Compare, _Alloc >), "header", - fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >), + %fragment(SWIG_Traits_frag(std::unordered_multimap< _Key, _Tp, _Compare, _Alloc >), "header", + fragment=SWIG_Traits_frag(std::pair< _Key, _Tp >), fragment="StdMultimapTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::unordered_multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; @@ -76,13 +76,13 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::unordered_multimap<_Key, _Tp, _Compare, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::unordered_multimap< _Key, _Tp, _Compare, _Alloc >); unordered_multimap( const _Compare& ); #ifdef %swig_unordered_multimap_methods // Add swig/language extra methods - %swig_unordered_multimap_methods(std::unordered_multimap<_Key, _Tp, _Compare, _Alloc >); + %swig_unordered_multimap_methods(std::unordered_multimap< _Key, _Tp, _Compare, _Alloc >); #endif %std_unordered_multimap_methods(unordered_multimap); diff --git a/Lib/std/std_unordered_multiset.i b/Lib/std/std_unordered_multiset.i index 56b971011..725ca2fe7 100644 --- a/Lib/std/std_unordered_multiset.i +++ b/Lib/std/std_unordered_multiset.i @@ -43,8 +43,8 @@ namespace std { //unordered_multiset - template , - class _Alloc = allocator<_Key> > + template , + class _Alloc = allocator< _Key > > class unordered_multiset { public: typedef size_t size_type; @@ -59,11 +59,11 @@ namespace std { %traits_swigtype(_Key); - %fragment(SWIG_Traits_frag(std::unordered_multiset<_Key, _Compare, _Alloc >), "header", + %fragment(SWIG_Traits_frag(std::unordered_multiset< _Key, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(_Key), fragment="StdMultisetTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::unordered_multiset<" #_Key "," #_Compare "," #_Alloc " >"; @@ -72,13 +72,13 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::unordered_multiset<_Key, _Compare, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::unordered_multiset< _Key, _Compare, _Alloc >); unordered_multiset( const _Compare& ); #ifdef %swig_unordered_multiset_methods // Add swig/language extra methods - %swig_unordered_multiset_methods(std::unordered_multiset<_Key, _Compare, _Alloc >); + %swig_unordered_multiset_methods(std::unordered_multiset< _Key, _Compare, _Alloc >); #endif %std_unordered_multiset_methods(unordered_multiset); diff --git a/Lib/std/std_unordered_set.i b/Lib/std/std_unordered_set.i index ed8888eb4..98e792040 100644 --- a/Lib/std/std_unordered_set.i +++ b/Lib/std/std_unordered_set.i @@ -77,9 +77,9 @@ namespace std { - template , - class _Compare = std::equal_to<_Key>, - class _Alloc = allocator<_Key> > + template , + class _Compare = std::equal_to< _Key >, + class _Alloc = allocator< _Key > > class unordered_set { public: typedef size_t size_type; @@ -95,11 +95,11 @@ namespace std { %traits_swigtype(_Key); - %fragment(SWIG_Traits_frag(std::unordered_set<_Key, _Hash, _Compare, _Alloc >), "header", + %fragment(SWIG_Traits_frag(std::unordered_set< _Key, _Hash, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(_Key), fragment="StdUnorderedSetTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::unordered_set<" #_Key "," #_Hash "," #_Compare "," #_Alloc " >"; @@ -108,13 +108,13 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::unordered_set<_Key, _Hash, _Compare, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::unordered_set< _Key, _Hash, _Compare, _Alloc >); unordered_set( const _Compare& ); #ifdef %swig_unordered_set_methods // Add swig/language extra methods - %swig_unordered_set_methods(std::unordered_set<_Key, _Hash, _Compare, _Alloc >); + %swig_unordered_set_methods(std::unordered_set< _Key, _Hash, _Compare, _Alloc >); #endif %std_unordered_set_methods(unordered_set); diff --git a/Lib/std/std_vector.i b/Lib/std/std_vector.i index baecf8507..fae759a36 100644 --- a/Lib/std/std_vector.i +++ b/Lib/std/std_vector.i @@ -71,11 +71,11 @@ namespace std { %traits_swigtype(_Tp); %traits_enum(_Tp); - %fragment(SWIG_Traits_frag(std::vector<_Tp, _Alloc >), "header", + %fragment(SWIG_Traits_frag(std::vector< _Tp, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdVectorTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef pointer_category category; static const char* type_name() { return "std::vector<" #_Tp "," #_Alloc " >"; @@ -84,11 +84,11 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector< _Tp, _Alloc >); #ifdef %swig_vector_methods // Add swig/language extra methods - %swig_vector_methods(std::vector<_Tp, _Alloc >); + %swig_vector_methods(std::vector< _Tp, _Alloc >); #endif %std_vector_methods(vector); @@ -99,7 +99,7 @@ namespace std { // a 'const SWIGTYPE*&' can be defined // *** template - class vector<_Tp*, _Alloc > { + class vector< _Tp*, _Alloc > { public: typedef size_t size_type; typedef ptrdiff_t difference_type; @@ -112,11 +112,11 @@ namespace std { %traits_swigtype(_Tp); - %fragment(SWIG_Traits_frag(std::vector<_Tp*, _Alloc >), "header", + %fragment(SWIG_Traits_frag(std::vector< _Tp*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdVectorTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::vector<" #_Tp " *," #_Alloc " >"; @@ -125,11 +125,11 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp*, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector< _Tp*, _Alloc >); #ifdef %swig_vector_methods_val // Add swig/language extra methods - %swig_vector_methods_val(std::vector<_Tp*, _Alloc >); + %swig_vector_methods_val(std::vector< _Tp*, _Alloc >); #endif %std_vector_methods_val(vector); @@ -139,7 +139,7 @@ namespace std { // const pointer specialization // *** template - class vector<_Tp const *, _Alloc > { + class vector< _Tp const *, _Alloc > { public: typedef size_t size_type; typedef ptrdiff_t difference_type; @@ -152,11 +152,11 @@ namespace std { %traits_swigtype(_Tp); - %fragment(SWIG_Traits_frag(std::vector<_Tp const*, _Alloc >), "header", + %fragment(SWIG_Traits_frag(std::vector< _Tp const*, _Alloc >), "header", fragment=SWIG_Traits_frag(_Tp), fragment="StdVectorTraits") { namespace swig { - template <> struct traits > { + template <> struct traits > { typedef value_category category; static const char* type_name() { return "std::vector<" #_Tp " const*," #_Alloc " >"; @@ -165,11 +165,11 @@ namespace std { } } - %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp const*, _Alloc >); + %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector< _Tp const*, _Alloc >); #ifdef %swig_vector_methods_val // Add swig/language extra methods - %swig_vector_methods_val(std::vector<_Tp const*, _Alloc >); + %swig_vector_methods_val(std::vector< _Tp const*, _Alloc >); #endif %std_vector_methods_val(vector); From 5724195b8b42f89a7c615f025165dea4736890e2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Dec 2015 21:41:33 +0000 Subject: [PATCH 175/732] Adding tp_finalize field to PyTypeObject for Python 3.4 and -builtin --- Source/Modules/python.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3395ebe68..98302d2d8 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4050,6 +4050,9 @@ public: Printv(f, "#if PY_VERSION_HEX >= 0x02060000\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_version_tag"), "tp_version_tag", "int"); Printv(f, "#endif\n", NIL); + Printv(f, "#if PY_VERSION_HEX >= 0x03040000\n", NIL); + printSlot(f, getSlot(n, "feature:python:tp_finalize"), "tp_finalize", "destructor"); + Printv(f, "#endif\n", NIL); Printf(f, " },\n"); // PyAsyncMethods as_async From f7b9466dff0bc7904e4ab7ac6f9ea46908f5e5cd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 13 Dec 2015 14:13:32 +0000 Subject: [PATCH 176/732] Python 3.3 builtin missing field initializers added Add in ht_qualname and ht_cached_keys for Python 3.3 and later --- Source/Modules/python.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 98302d2d8..75d8ffafa 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4164,9 +4164,15 @@ public: Printv(f, "#endif\n", NIL); Printf(f, " },\n"); - // PyObject *ht_name, *ht_slots + // PyObject *ht_name, *ht_slots, *ht_qualname; printSlot(f, getSlot(n, "feature:python:ht_name"), "ht_name", "PyObject*"); printSlot(f, getSlot(n, "feature:python:ht_slots"), "ht_slots", "PyObject*"); + Printv(f, "#if PY_VERSION_HEX >= 0x03030000\n", NIL); + printSlot(f, getSlot(n, "feature:python:ht_qualname"), "ht_qualname", "PyObject*"); + + // struct _dictkeysobject *ht_cached_keys; + printSlot(f, getSlot(n, "feature:python:ht_cached_keys"), "ht_cached_keys", "struct _dictkeysobject*"); + Printv(f, "#endif\n", NIL); Printf(f, "};\n\n"); String *clientdata = NewString(""); From fcb2ed1d1065429c692a28bb2ee873821444cd56 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 13 Dec 2015 14:18:03 +0000 Subject: [PATCH 177/732] Add -Wmissing-field-initializers to python Travis testing --- Tools/testflags.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/testflags.py b/Tools/testflags.py index 76389f046..63a3b4645 100755 --- a/Tools/testflags.py +++ b/Tools/testflags.py @@ -15,7 +15,7 @@ def get_cflags(language, std, compiler): "octave":"-Werror " + c_common, "perl5":"-Werror " + c_common, "php":"-Werror " + c_common, - "python":"-Werror " + c_common, + "python":"-Werror " + c_common + " -Wmissing-field-initializers", "r":"-Werror " + c_common, "ruby":"-Werror " + c_common, "scilab":"-Werror " + c_common, @@ -44,7 +44,7 @@ def get_cxxflags(language, std, compiler): "octave":"-Werror " + cxx_common, "perl5":"-Werror " + cxx_common, "php":"-Werror " + cxx_common, - "python":"-Werror " + cxx_common, + "python":"-Werror " + cxx_common + " -Wmissing-field-initializers", "r":"-Werror " + cxx_common, "ruby":"-Werror " + cxx_common, "scilab": cxx_common, From 24b4a0fb945885c009923ca029fc5542570132ac Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Dec 2015 01:29:43 +0000 Subject: [PATCH 178/732] Cosmetic correction for Python tp_version -> tp_version_tag --- Lib/python/builtin.swg | 2 +- Lib/python/pyinit.swg | 2 +- Lib/python/pyrun.swg | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 340037580..4604e4397 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -433,7 +433,7 @@ SwigPyStaticVar_Type(void) { 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ + 0, /* tp_version_tag */ #endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 26c1d7ed3..9398443e3 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -183,7 +183,7 @@ swig_varlink_type(void) { 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ + 0, /* tp_version_tag */ #endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index be3af3280..f13154794 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -806,7 +806,7 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ + 0, /* tp_version_tag */ #endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ @@ -988,7 +988,7 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ + 0, /* tp_version_tag */ #endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ From 5f93c94e879f636867733aaff1a209c6535e4583 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Dec 2015 01:56:11 +0000 Subject: [PATCH 179/732] Python tp_allocs -> tp_next corrections Updates for Python 2.5 and later and for -builtin. --- Lib/python/builtin.swg | 8 +++++++- Lib/python/pyinit.swg | 8 +++++++- Lib/python/pyrun.swg | 16 ++++++++++++++-- Source/Modules/python.cxx | 9 +++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 4604e4397..0107c52d5 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -439,7 +439,13 @@ SwigPyStaticVar_Type(void) { 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ #endif }; staticvar_type = tmp; diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 9398443e3..2e21b8265 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -189,7 +189,13 @@ swig_varlink_type(void) { 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ #endif }; varlink_type = tmp; diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index f13154794..1326ed775 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -812,7 +812,13 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ #endif }; swigpyobject_type = tmp; @@ -994,7 +1000,13 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ #endif }; swigpypacked_type = tmp; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 75d8ffafa..eff263be6 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4053,6 +4053,15 @@ public: Printv(f, "#if PY_VERSION_HEX >= 0x03040000\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_finalize"), "tp_finalize", "destructor"); Printv(f, "#endif\n", NIL); + Printv(f, "#ifdef COUNT_ALLOCS\n", NIL); + printSlot(f, getSlot(), "tp_allocs", "Py_ssize_t"); + printSlot(f, getSlot(), "tp_frees", "Py_ssize_t"); + printSlot(f, getSlot(), "tp_maxalloc", "Py_ssize_t"); + Printv(f, "#if PY_VERSION_HEX >= 0x02050000\n", NIL); + printSlot(f, getSlot(), "tp_prev", "struct _typeobject*"); + Printv(f, "#endif\n", NIL); + printSlot(f, getSlot(), "tp_next", "struct _typeobject*"); + Printv(f, "#endif\n", NIL); Printf(f, " },\n"); // PyAsyncMethods as_async From 0c307b8a991e99beb957448b7a98372094213a84 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Dec 2015 02:04:08 +0000 Subject: [PATCH 180/732] changes entry for missing initializers --- CHANGES.current | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index df5c7e1fb..646302476 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-12-14: ahnolds/wsfulton + [Python] Add in missing initializers for tp_finalize, + nb_matrix_multiply, nb_inplace_matrix_multiply, ht_qualname + ht_cached_keys and tp_prev. + 2015-12-12: wsfulton Fix STL wrappers to not generate <: digraphs. For example std::vector<::X::Y> was sometimes generated, now From a863e98874ab751eb9d75677c51449e5c9cea6c3 Mon Sep 17 00:00:00 2001 From: Brian Cole Date: Tue, 15 Dec 2015 08:39:55 -0700 Subject: [PATCH 181/732] Extended zjturner's changes to encompass all function dispatch and use PyErr_WriteUnraisable to handle exceptions during __del__. Also added test cases for the unnamed temporary destruction that is throwing assertions in Python 3.5. --- Examples/test-suite/python/Makefile.in | 1 + .../python_destructor_exception_runme.py | 14 +++++++++++ .../test-suite/python_destructor_exception.i | 17 ++++++++++++++ Lib/python/pyrun.swg | 23 +++++++++++++------ 4 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 Examples/test-suite/python/python_destructor_exception_runme.py create mode 100644 Examples/test-suite/python_destructor_exception.i diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 47535f569..096e624ac 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -58,6 +58,7 @@ CPP_TEST_CASES += \ primitive_types \ python_abstractbase \ python_append \ + python_destructor_exception \ python_director \ python_docstring \ python_nondynamic \ diff --git a/Examples/test-suite/python/python_destructor_exception_runme.py b/Examples/test-suite/python/python_destructor_exception_runme.py new file mode 100644 index 000000000..a19b48633 --- /dev/null +++ b/Examples/test-suite/python/python_destructor_exception_runme.py @@ -0,0 +1,14 @@ +import python_destructor_exception +from StringIO import StringIO +import sys + +#buffer = StringIO() +#sys.stderr = buffer + +attributeErrorOccurred = False +try: + python_destructor_exception.ClassWithThrowingDestructor().GetBlah() +except AttributeError, e: + attributeErrorOccurred = True + +assert attributeErrorOccurred diff --git a/Examples/test-suite/python_destructor_exception.i b/Examples/test-suite/python_destructor_exception.i new file mode 100644 index 000000000..4d2745ac8 --- /dev/null +++ b/Examples/test-suite/python_destructor_exception.i @@ -0,0 +1,17 @@ +/* File : example.i */ +%module python_destructor_exception +%include exception.i + +%exception ClassWithThrowingDestructor::~ClassWithThrowingDestructor() +{ + $action + SWIG_exception(SWIG_RuntimeError, "I am the ClassWithThrowingDestructor dtor doing bad things"); +} + +%inline %{ +class ClassWithThrowingDestructor +{ +}; + +%} + diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index ba9d6ecca..f25d5ab9c 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -536,23 +536,32 @@ SwigPyObject_dealloc(PyObject *v) if (destroy) { /* destroy is always a VARARGS method */ PyObject *res; + + /* PyObject_CallFunction() has the potential to silently drop + the active active exception. In cases of unnamed temporary + variable or where we just finished iterating over a generator + StopIteration will be active right now, and this needs to + remain true upon return from SwigPyObject_dealloc. So save + and restore. */ + + PyObject *val = NULL, *type = NULL, *tb = NULL; + PyErr_Fetch(&val, &type, &tb); + if (data->delargs) { /* we need to create a temporary object to carry the destroy operation */ PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); - /* PyObject_CallFunction() has the potential to silently drop the active - active exception. In cases where we just finished iterating over a - generator StopIteration will be active right now, and this needs to - remain true upon return from SwigPyObject_dealloc. So save and restore. */ - PyObject *val = NULL, *type = NULL, *tb = NULL; - PyErr_Fetch(&val, &type, &tb); res = SWIG_Python_CallFunctor(destroy, tmp); - PyErr_Restore(val, type, tb); Py_DECREF(tmp); } else { PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); PyObject *mself = PyCFunction_GET_SELF(destroy); res = ((*meth)(mself, v)); } + if (!res) + PyErr_WriteUnraisable(destroy); + + PyErr_Restore(val, type, tb); + Py_XDECREF(res); } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) From 790c72944746ddcd6948daca89ecb4f758ac4493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= Date: Sun, 6 Dec 2015 14:00:54 +0100 Subject: [PATCH 182/732] Ignore locally installed ccache when running CCache unit tests original patch by David Sommerseth --- CCache/test.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CCache/test.sh b/CCache/test.sh index 6e5d26703..d8640ccaa 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -15,6 +15,12 @@ else SWIG=swig fi +# fix: Remove ccache from $PATH if it exists +# as it will influence the unit tests +PATH="`echo $PATH | \ + awk -v RS=: -v ORS=: '/\/usr\/lib(64|)\/ccache(:|)/ {next} {print}' | \ + sed 's/:*$//'`" + CCACHE=../ccache-swig TESTDIR=test.$$ From 1a977a21922cb418de42c568aee418df3582f842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= Date: Wed, 16 Dec 2015 11:01:59 +0100 Subject: [PATCH 183/732] use sed only to filter CCache from $PATH --- CCache/test.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CCache/test.sh b/CCache/test.sh index d8640ccaa..438e782cd 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -18,8 +18,7 @@ fi # fix: Remove ccache from $PATH if it exists # as it will influence the unit tests PATH="`echo $PATH | \ - awk -v RS=: -v ORS=: '/\/usr\/lib(64|)\/ccache(:|)/ {next} {print}' | \ - sed 's/:*$//'`" + sed -e 's!:/usr\(/local\)*/lib\([0-9]\)*/ccache\(/\)*!!g'`" CCACHE=../ccache-swig TESTDIR=test.$$ From e4264e7ba8d504cd0a83e64d4be392052a53eb8c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 Dec 2015 20:52:50 +0000 Subject: [PATCH 184/732] Call PyErr_WriteUnraisable if a destructor sets a Python exception (-builtin) This fixes the python_destructor_exception testcase for -builtin --- Lib/python/builtin.swg | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 1d892375c..66c120605 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -9,9 +9,17 @@ SWIGINTERN void \ wrapper##_closure(PyObject *a) { \ SwigPyObject *sobj; \ sobj = (SwigPyObject *)a; \ - Py_XDECREF(sobj->dict); \ + Py_XDECREF(sobj->dict); \ if (sobj->own) { \ + PyObject *val = 0, *type = 0, *tb = 0; \ + PyErr_Fetch(&val, &type, &tb); \ PyObject *o = wrapper(a, NULL); \ + if (!o) { \ + PyObject *deallocname = PyString_FromString(#wrapper); \ + PyErr_WriteUnraisable(deallocname); \ + Py_DECREF(deallocname); \ + } \ + PyErr_Restore(val, type, tb); \ Py_XDECREF(o); \ } \ if (PyType_IS_GC(a->ob_type)) { \ @@ -64,7 +72,7 @@ wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) { \ #define SWIGPY_TERNARYCALLFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ -wrapper##_closure(PyObject *callable_object, PyObject *args, PyObject *) { \ +wrapper##_closure(PyObject *callable_object, PyObject *args, PyObject *) { \ return wrapper(callable_object, args); \ } @@ -124,7 +132,7 @@ wrapper##_closure(PyObject *a, Py_ssize_t b) { \ return result; \ } -#define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \ +#define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \ SWIGINTERN PyObject * \ wrapper##_closure(PyObject *a, Py_ssize_t b) { \ PyObject *arg, *result; \ From dd73d81933e31e6c493e8e215ef803fcfc29cd06 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 Dec 2015 21:54:04 +0000 Subject: [PATCH 185/732] Amend python_destructor_exception runtime test Suppress the message that PyErr_WriteUnraisable writes to stderr, but check that it is called by checking some of the expected message contents. The output varies slightly for different versions of Python and -builtin --- .../python_destructor_exception_runme.py | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/Examples/test-suite/python/python_destructor_exception_runme.py b/Examples/test-suite/python/python_destructor_exception_runme.py index a19b48633..f9db37a13 100644 --- a/Examples/test-suite/python/python_destructor_exception_runme.py +++ b/Examples/test-suite/python/python_destructor_exception_runme.py @@ -2,13 +2,31 @@ import python_destructor_exception from StringIO import StringIO import sys -#buffer = StringIO() -#sys.stderr = buffer - -attributeErrorOccurred = False -try: +def error_function(): python_destructor_exception.ClassWithThrowingDestructor().GetBlah() -except AttributeError, e: - attributeErrorOccurred = True -assert attributeErrorOccurred +def runtest(): + attributeErrorOccurred = False + try: + error_function() + except AttributeError, e: + attributeErrorOccurred = True + return attributeErrorOccurred + +def runtestcaller(): + stderr_saved = sys.stderr + buffer = StringIO() + attributeErrorOccurred = False + try: + # Suppress stderr while making this call to suppress the output shown by PyErr_WriteUnraisable + sys.stderr = buffer + + attributeErrorOccurred = runtest() + finally: + sys.stderr.flush() + sys.stderr = stderr_saved + + assert attributeErrorOccurred + assert buffer.getvalue().count("I am the ClassWithThrowingDestructor dtor doing bad things") >= 1 + +runtestcaller() From 26f52c53f416e24f5151f84187c4cf687695fb78 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 Dec 2015 22:25:13 +0000 Subject: [PATCH 186/732] Add test case for Python 3.5 assertion with a pending StopIteration Testcase for issue #559 #560 #573 --- .../python_destructor_exception_runme.py | 36 +++++++++++++++++-- .../test-suite/python_destructor_exception.i | 2 ++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/python/python_destructor_exception_runme.py b/Examples/test-suite/python/python_destructor_exception_runme.py index f9db37a13..671eff3cc 100644 --- a/Examples/test-suite/python/python_destructor_exception_runme.py +++ b/Examples/test-suite/python/python_destructor_exception_runme.py @@ -13,7 +13,7 @@ def runtest(): attributeErrorOccurred = True return attributeErrorOccurred -def runtestcaller(): +def test1(): stderr_saved = sys.stderr buffer = StringIO() attributeErrorOccurred = False @@ -29,4 +29,36 @@ def runtestcaller(): assert attributeErrorOccurred assert buffer.getvalue().count("I am the ClassWithThrowingDestructor dtor doing bad things") >= 1 -runtestcaller() +class VectorHolder(object): + def __init__(self, v): + self.v = v + def gen(self): + for e in self.v: + yield e + +# See issue #559, #560, #573 - In Python 3.5, test2() call to the generator 'gen' was +# resulting in the following (not for -builtin where there is no call to SWIG_Python_CallFunctor +# as SwigPyObject_dealloc is not used): +# +# StopIteration +# +# During handling of the above exception, another exception occurred: +# ... +# SystemError: returned a result with an error set + +def addup(): + sum = 0 + for i in VectorHolder(python_destructor_exception.VectorInt([1, 2, 3])).gen(): + sum = sum + i + return sum + +def test2(): + sum = addup() + + if sum != 6: + raise RuntimeError("Sum is incorrect") + +# These two tests are different are two different ways to recreate essentially the same problem +# reported by Python 3.5 that an exception was already set when destroying a wrapped object +test1() +test2() diff --git a/Examples/test-suite/python_destructor_exception.i b/Examples/test-suite/python_destructor_exception.i index 4d2745ac8..150a396de 100644 --- a/Examples/test-suite/python_destructor_exception.i +++ b/Examples/test-suite/python_destructor_exception.i @@ -15,3 +15,5 @@ class ClassWithThrowingDestructor %} +%include +%template(VectorInt) std::vector; From a39e2a07fbc73e5be9f94179889b7605e3a8a35c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Dec 2015 13:23:38 +0000 Subject: [PATCH 187/732] Changes file entry for Python exception fixes. --- CHANGES.current | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 646302476..ec49d2ab9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,14 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-12-16: zturner/coleb + [Python] Fix Python3.5 interpreter assertions when objects are being + deleted due to an existing exception. Most notably in generators + which terminate using a StopIteration exception. Fixes #559 #560 #573. + If a further exception is raised during an object destruction, + PyErr_WriteUnraisable is used on this second exception and the + original exception bubbles through. + 2015-12-14: ahnolds/wsfulton [Python] Add in missing initializers for tp_finalize, nb_matrix_multiply, nb_inplace_matrix_multiply, ht_qualname From 7dc5b224cb912d9d976766f971845a2e889bd872 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Dec 2015 18:13:31 +0000 Subject: [PATCH 188/732] Fix recent Python -builtin changes for C code --- Lib/python/builtin.swg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 5dd1be12f..5767a1422 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -11,9 +11,10 @@ wrapper##_closure(PyObject *a) { \ sobj = (SwigPyObject *)a; \ Py_XDECREF(sobj->dict); \ if (sobj->own) { \ + PyObject *o; \ PyObject *val = 0, *type = 0, *tb = 0; \ PyErr_Fetch(&val, &type, &tb); \ - PyObject *o = wrapper(a, NULL); \ + o = wrapper(a, NULL); \ if (!o) { \ PyObject *deallocname = PyString_FromString(#wrapper); \ PyErr_WriteUnraisable(deallocname); \ From f77839dfbf6e92578365a5be43a7319d5a54a6c5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Dec 2015 18:32:21 +0000 Subject: [PATCH 189/732] Initialize missing PyNumberMethods for Python 3.5 and -builtin Add nb_matrix_multiply nb_inplace_matrix_multiply --- Source/Modules/python.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 5aff24278..3bdb38984 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4128,6 +4128,10 @@ public: Printv(f, "#if PY_VERSION_HEX >= 0x02050000\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_index"), "nb_index", "unaryfunc"); Printv(f, "#endif\n", NIL); + Printv(f, "#if PY_VERSION_HEX >= 0x03050000\n", NIL); + printSlot(f, getSlot(n, "feature:python:nb_matrix_multiply"), "nb_matrix_multiply", "binaryfunc"); + printSlot(f, getSlot(n, "feature:python:nb_inplace_matrix_multiply"), "nb_inplace_matrix_multiply", "binaryfunc"); + Printv(f, "#endif\n", NIL); Printf(f, " },\n"); // PyMappingMethods as_mapping; From 8d4a1f02fd2eb346cc94fa338778b0f252905dd0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Dec 2015 19:30:20 +0000 Subject: [PATCH 190/732] Show Travis hardware info --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 555711d01..c9af37ff4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -176,6 +176,8 @@ matrix: before_install: - date -u - uname -a + - if test "$TRAVIS_OS_NAME" = "linux"; then lscpu && cat /proc/cpuinfo | grep "model name" && cat /proc/meminfo | grep MemTotal; fi + - if test "$TRAVIS_OS_NAME" = "osx"; then sysctl -a | grep brand_string; fi # Travis overrides CC environment with compiler predefined values - if test -n "$SWIG_CC"; then export CC="$SWIG_CC"; fi - if test -n "$SWIG_CXX"; then export CXX="$SWIG_CXX"; fi From 9acf18939c5752d0b57add9b952ad5b663f4f869 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Dec 2015 19:31:08 +0000 Subject: [PATCH 191/732] Travis octave parallel builds change Use the number of cpus available on Travis (currently 2) for parallel builds --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index c9af37ff4..27eed5d6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,13 +40,13 @@ matrix: env: SWIGLANG=lua - compiler: gcc os: linux - env: SWIGLANG=octave SWIGJOBS=-j3 # 3.2 + env: SWIGLANG=octave SWIGJOBS=-j # 3.2 - compiler: gcc os: linux - env: SWIGLANG=octave SWIGJOBS=-j3 VER=3.8 + env: SWIGLANG=octave SWIGJOBS=-j VER=3.8 - compiler: gcc os: linux - env: SWIGLANG=octave SWIGJOBS=-j3 VER=4.0 + env: SWIGLANG=octave SWIGJOBS=-j VER=4.0 - compiler: gcc os: linux env: SWIGLANG=perl5 @@ -157,11 +157,11 @@ matrix: # Occasional gcc internal compiler error - compiler: gcc os: linux - env: SWIGLANG=octave SWIGJOBS=-j3 VER=3.8 + env: SWIGLANG=octave SWIGJOBS=-j VER=3.8 # Occasional gcc internal compiler error - compiler: gcc os: linux - env: SWIGLANG=octave SWIGJOBS=-j3 VER=4.0 + env: SWIGLANG=octave SWIGJOBS=-j VER=4.0 # Not quite working yet - compiler: gcc os: linux From 64dcd50b9953cad388db44f772c7dbee1cb34b7d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Dec 2015 02:32:11 +0000 Subject: [PATCH 192/732] Remove dependency on yodl tools and remove ccache-swig man page Use the CCache.html docs instead of the ccache-swig man page. The yodl2man and yodl2html tools are no longer used and so SWIG no longer has a dependency on these packages which were required when building from git. Closes #286 Closes #128 --- .gitignore | 3 - .travis.yml | 3 +- CCache/Makefile.in | 8 +- CHANGES.current | 7 + Doc/Manual/CCache.html | 473 ++++++++++++++++++++++++++++++++++ Doc/Manual/Makefile | 4 +- Makefile.in | 5 +- Tools/mkdist.py | 2 - Tools/travis-linux-install.sh | 4 +- configure.ac | 14 - 10 files changed, 491 insertions(+), 32 deletions(-) create mode 100644 Doc/Manual/CCache.html diff --git a/.gitignore b/.gitignore index 4001af7c3..715c95ea0 100644 --- a/.gitignore +++ b/.gitignore @@ -85,8 +85,6 @@ swig.spec # Build Artifacts .dirstamp CCache/ccache-swig -CCache/ccache-swig.1 -CCache/web/ccache-man.html Lib/swigwarn.swg Source/CParse/parser.c Source/CParse/parser.h @@ -96,7 +94,6 @@ swig Tools/javascript/javascript # Generated documentation -Doc/Manual/CCache.html Doc/Manual/SWIGDocumentation.html Doc/Manual/SWIGDocumentation.pdf Doc/Manual/*.book diff --git a/.travis.yml b/.travis.yml index 27eed5d6e..225e4abb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -201,8 +201,7 @@ script: - if test -z "$SWIGLANG"; then make -s $SWIGJOBS check-ccache; fi - if test -z "$SWIGLANG"; then make -s $SWIGJOBS check-errors-test-suite; fi - echo 'Installing...' && echo -en 'travis_fold:start:script.2\\r' - # make install doesn't work on os x due to missing yodl2man - - if test -z "$SWIGLANG" -a "$TRAVIS_OS_NAME" = "linux"; then sudo make -s install && swig -version && ccache-swig -V; fi + - if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi - echo -en 'travis_fold:end:script.2\\r' # Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic. - if test -n "$SWIGLANG"; then cflags=$($TRAVIS_BUILD_DIR/Tools/testflags.py --language $SWIGLANG --cflags --std=$CSTD --compiler=$CC) && echo $cflags; fi diff --git a/CCache/Makefile.in b/CCache/Makefile.in index 6cded08d4..67fd3f363 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -43,17 +43,21 @@ $(srcdir)/$(PACKAGE_NAME).1: $(srcdir)/ccache.yo $(srcdir)/web/ccache-man.html: $(srcdir)/ccache.yo yodl2html -o $(srcdir)/web/ccache-man.html $(srcdir)/ccache.yo -install: $(PACKAGE_NAME)$(EXEEXT) $(srcdir)/$(PACKAGE_NAME).1 +install: $(PACKAGE_NAME)$(EXEEXT) @echo "Installing $(PACKAGE_NAME)" @echo "Installing $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)" ${INSTALLCMD} -d $(DESTDIR)${bindir} ${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT) + +install-docs: $(srcdir)/$(PACKAGE_NAME).1 @echo "Installing $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1" ${INSTALLCMD} -d $(DESTDIR)${mandir}/man1 ${INSTALLCMD} -m 644 $(srcdir)/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1 -uninstall: $(PACKAGE_NAME)$(EXEEXT) $(srcdir)/$(PACKAGE_NAME).1 +uninstall: $(PACKAGE_NAME)$(EXEEXT) rm -f $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT) + +uninstall-docs: $(srcdir)/$(PACKAGE_NAME).1 rm -f $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1 clean: diff --git a/CHANGES.current b/CHANGES.current index ec49d2ab9..a0e6dfa2b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,13 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-12-17: wsfulton + Issues #286, #128 + Remove ccache-swig.1 man page - please use the CCache.html docs instead. + The yodl2man and yodl2html tools are no longer used and so SWIG no + longer has a dependency on these packages which were required when + building from git. + 2015-12-16: zturner/coleb [Python] Fix Python3.5 interpreter assertions when objects are being deleted due to an existing exception. Most notably in generators diff --git a/Doc/Manual/CCache.html b/Doc/Manual/CCache.html new file mode 100644 index 000000000..0ee94c172 --- /dev/null +++ b/Doc/Manual/CCache.html @@ -0,0 +1,473 @@ + + + +ccache-swig(1) manpage + + + + +

    17 Using SWIG with ccache - ccache-swig(1) manpage

    + + + + + + +

    +

    17.1 NAME

    + + +

    + +ccache-swig - a fast compiler cache + +

    +

    17.2 SYNOPSIS

    + + +

    +ccache-swig [OPTION] +

    +ccache-swig <compiler> [COMPILER OPTIONS] +

    +<compiler> [COMPILER OPTIONS] +

    +

    17.3 DESCRIPTION

    + + +

    +ccache-swig is a compiler cache. It speeds up re-compilation of C/C++/SWIG code +by caching previous compiles and detecting when the same compile is +being done again. ccache-swig is ccache plus support for SWIG. ccache +and ccache-swig are used interchangeably in this document. +

    +

    17.4 OPTIONS SUMMARY

    + + +

    +Here is a summary of the options to ccache-swig. +

    +

    +
    +-s                      show statistics summary
    +-z                      zero statistics
    +-c                      run a cache cleanup
    +-C                      clear the cache completely
    +-F <n>                  set maximum files in cache
    +-M <n>                  set maximum size of cache (use G, M or K)
    +-h                      this help page
    +-V                      print version number
    +
    +
    + +

    +

    17.5 OPTIONS

    + + +

    +These options only apply when you invoke ccache as "ccache-swig". When +invoked as a compiler none of these options apply. In that case your +normal compiler options apply and you should refer to your compilers +documentation. +

    +

    +

    -h
    Print a options summary page +

    +

    -s
    Print the current statistics summary for the cache. The +statistics are stored spread across the subdirectories of the +cache. Using "ccache-swig -s" adds up the statistics across all +subdirectories and prints the totals. +

    +

    -z
    Zero the cache statistics. +

    +

    -V
    Print the ccache version number +

    +

    -c
    Clean the cache and re-calculate the cache file count and +size totals. Normally the -c option should not be necessary as ccache +keeps the cache below the specified limits at runtime and keeps +statistics up to date on each compile. This option is mostly useful +if you manually modify the cache contents or believe that the cache +size statistics may be inaccurate. +

    +

    -C
    Clear the entire cache, removing all cached files. +

    +

    -F <maxfiles>
    This sets the maximum number of files allowed in +the cache. The value is stored inside the cache directory and applies +to all future compiles. Due to the way the value is stored the actual +value used is always rounded down to the nearest multiple of 16. +

    +

    -M <maxsize>
    This sets the maximum cache size. You can specify +a value in gigabytes, megabytes or kilobytes by appending a G, M or K +to the value. The default is gigabytes. The actual value stored is +rounded down to the nearest multiple of 16 kilobytes. +

    +

    +

    +

    17.6 INSTALLATION

    + + +

    +There are two ways to use ccache. You can either prefix your compile +commands with "ccache-swig" or you can create a symbolic link between +ccache-swig and the names of your compilers. The first method is most +convenient if you just want to try out ccache or wish to use it for +some specific projects. The second method is most useful for when you +wish to use ccache for all your compiles. +

    +To install for usage by the first method just copy ccache-swig to somewhere +in your path. +

    +To install for the second method do something like this: +

    +
    +  cp ccache-swig /usr/local/bin/
    +  ln -s /usr/local/bin/ccache-swig /usr/local/bin/gcc
    +  ln -s /usr/local/bin/ccache-swig /usr/local/bin/g++
    +  ln -s /usr/local/bin/ccache-swig /usr/local/bin/cc
    +  ln -s /usr/local/bin/ccache-swig /usr/local/bin/swig
    +
    +
    + +This will work as long as /usr/local/bin comes before the path to gcc +(which is usually in /usr/bin). After installing you may wish to run +"which gcc" to make sure that the correct link is being used. +

    +Note! Do not use a hard link, use a symbolic link. A hardlink will +cause "interesting" problems. +

    +

    17.7 EXTRA OPTIONS

    + + +

    +When run as a compiler front end ccache usually just takes the same +command line options as the compiler you are using. The only exception +to this is the option '--ccache-skip'. That option can be used to tell +ccache that the next option is definitely not a input filename, and +should be passed along to the compiler as-is. +

    +The reason this can be important is that ccache does need to parse the +command line and determine what is an input filename and what is a +compiler option, as it needs the input filename to determine the name +of the resulting object file (among other things). The heuristic +ccache uses in this parse is that any string on the command line that +exists as a file is treated as an input file name (usually a C +file). By using --ccache-skip you can force an option to not be +treated as an input file name and instead be passed along to the +compiler as a command line option. +

    +

    17.8 ENVIRONMENT VARIABLES

    + + +

    +ccache uses a number of environment variables to control operation. In +most cases you won't need any of these as the defaults will be fine. +

    +

    +

    +

    CCACHE_DIR
    the CCACHE_DIR environment variable specifies +where ccache will keep its cached compiler output. The default is +"$HOME/.ccache". +

    +

    CCACHE_TEMPDIR
    the CCACHE_TEMPDIR environment variable specifies +where ccache will put temporary files. The default is the same as +CCACHE_DIR. Note that the CCACHE_TEMPDIR path must be on the same +filesystem as the CCACHE_DIR path, so that renames of files between +the two directories can work. +

    +

    CCACHE_LOGFILE
    If you set the CCACHE_LOGFILE environment +variable then ccache will write some log information on cache hits +and misses in that file. This is useful for tracking down problems. +

    +

    CCACHE_VERBOSE
    If you set the CCACHE_VERBOSE environment +variable then ccache will display on stdout all the compiler invocations +that it makes. This can useful for debugging unexpected problems. +

    +

    CCACHE_PATH
    You can optionally set CCACHE_PATH to a colon +separated path where ccache will look for the real compilers. If you +don't do this then ccache will look for the first executable matching +the compiler name in the normal PATH that isn't a symbolic link to +ccache itself. +

    +

    CCACHE_CC
    You can optionally set CCACHE_CC to force the name +of the compiler to use. If you don't do this then ccache works it out +from the command line. +

    +

    CCACHE_PREFIX
    This option adds a prefix to the command line +that ccache runs when invoking the compiler. Also see the section +below on using ccache with distcc. +

    +

    CCACHE_DISABLE
    If you set the environment variable +CCACHE_DISABLE then ccache will just call the real compiler, +bypassing the cache completely. +

    +

    CCACHE_READONLY
    the CCACHE_READONLY environment variable +tells ccache to attempt to use existing cached object files, but not +to try to add anything new to the cache. If you are using this because +your CCACHE_DIR is read-only, then you may find that you also need to +set CCACHE_TEMPDIR as otherwise ccache will fail to create the +temporary files. +

    +

    CCACHE_CPP2
    If you set the environment variable CCACHE_CPP2 +then ccache will not use the optimisation of avoiding the 2nd call to +the pre-processor by compiling the pre-processed output that was used +for finding the hash in the case of a cache miss. This is primarily a +debugging option, although it is possible that some unusual compilers +will have problems with the intermediate filename extensions used in +this optimisation, in which case this option could allow ccache to be +used. +

    +

    CCACHE_NOCOMPRESS
    If you set the environment variable +CCACHE_NOCOMPRESS then there is no compression used on files that go +into the cache. However, this setting has no effect on how files are +retrieved from the cache, compressed results will still be usable. +

    +

    CCACHE_NOSTATS
    If you set the environment variable +CCACHE_NOSTATS then ccache will not update the statistics files on +each compile. +

    +

    CCACHE_NLEVELS
    The environment variable CCACHE_NLEVELS allows +you to choose the number of levels of hash in the cache directory. The +default is 2. The minimum is 1 and the maximum is 8. +

    +

    CCACHE_HARDLINK
    If you set the environment variable +CCACHE_HARDLINK then ccache will attempt to use hard links from the +cache directory when creating the compiler output rather than using a +file copy. Using hard links is faster, but can confuse programs like +'make' that rely on modification times. Hard links are never made for +compressed cache files. +

    +

    CCACHE_RECACHE
    This forces ccache to not use any cached +results, even if it finds them. New results are still cached, but +existing cache entries are ignored. +

    +

    CCACHE_UMASK
    This sets the umask for ccache and all child +processes (such as the compiler). This is mostly useful when you wish +to share your cache with other users. Note that this also affects the +file permissions set on the object files created from your +compilations. +

    +

    CCACHE_HASHDIR
    This tells ccache to hash the current working +directory when calculating the hash that is used to distinguish two +compiles. This prevents a problem with the storage of the current +working directory in the debug info of a object file, which can lead +ccache to give a cached object file that has the working directory in +the debug info set incorrectly. This option is off by default as the +incorrect setting of this debug info rarely causes problems. If you +strike problems with gdb not using the correct directory then enable +this option. +

    +

    CCACHE_UNIFY
    If you set the environment variable CCACHE_UNIFY +then ccache will use the C/C++ unifier when hashing the pre-processor +output if -g is not used in the compile. The unifier is slower than a +normal hash, so setting this environment variable loses a little bit +of speed, but it means that ccache can take advantage of not +recompiling when the changes to the source code consist of +reformatting only. Note that using CCACHE_UNIFY changes the hash, so +cached compiles with CCACHE_UNIFY set cannot be used when +CCACHE_UNIFY is not set and vice versa. The reason the unifier is off +by default is that it can give incorrect line number information in +compiler warning messages. +

    +

    CCACHE_EXTENSION
    Normally ccache tries to automatically +determine the extension to use for intermediate C pre-processor files +based on the type of file being compiled. Unfortunately this sometimes +doesn't work, for example when using the aCC compiler on HP-UX. On +systems like this you can use the CCACHE_EXTENSION option to override +the default. On HP-UX set this environment variable to "i" if you use +the aCC compiler. +

    +

    CCACHE_STRIPC
    If you set the environment variable +CCACHE_STRIPC then ccache will strip the -c option when invoking +the preprocessor. This option is primarily for the Sun Workshop +C++ compiler as without this option an unwarranted warning is displayed: +CC: Warning: "-E" redefines product from "object" to "source (stdout)" +when -E and -c is used together. +

    +

    CCACHE_SWIG
    When using SWIG as the compiler and it does not +have 'swig' in the executable name, then the CCACHE_SWIG environment +variable needs to be set in order for ccache to work correctly with +SWIG. The use of CCACHE_CPP2 is also recommended for SWIG due to some +preprocessor quirks, however, use of CCACHE_CPP2 can often be skipped +-- check your generated code with and without this option set. Known +problems are using preprocessor directives within %inline blocks and +the use of '#pragma SWIG'. +

    +

    +

    +

    17.9 CACHE SIZE MANAGEMENT

    + + +

    +By default ccache has a one gigabyte limit on the cache size and no +maximum number of files. You can set a different limit using the +"ccache -M" and "ccache -F" options, which set the size and number of +files limits. +

    +When these limits are reached ccache will reduce the cache to 20% +below the numbers you specified in order to avoid doing the cache +clean operation too often. +

    +

    17.10 CACHE COMPRESSION

    + + +

    +By default on most platforms ccache will compress all files it puts +into the cache +using the zlib compression. While this involves a negligible +performance slowdown, it significantly increases the number of files +that fit in the cache. You can turn off compression setting the +CCACHE_NOCOMPRESS environment variable. +

    +

    17.11 HOW IT WORKS

    + + +

    +The basic idea is to detect when you are compiling exactly the same +code a 2nd time and use the previously compiled output. You detect +that it is the same code by forming a hash of: +

    +

      +
    • the pre-processor output from running the compiler with -E +
    • the command line options +
    • the real compilers size and modification time +
    • any stderr output generated by the compiler +
    +

    +These are hashed using md4 (a strong hash) and a cache file is formed +based on that hash result. When the same compilation is done a second +time ccache is able to supply the correct compiler output (including +all warnings etc) from the cache. +

    +ccache has been carefully written to always produce exactly the same +compiler output that you would get without the cache. If you ever +discover a case where ccache changes the output of your compiler then +please let me know. +

    +

    17.12 USING CCACHE WITH DISTCC

    + + +

    +distcc is a very useful program for distributing compilation across a +range of compiler servers. It is often useful to combine distcc with +ccache, so that compiles that are done are sped up by distcc, but that +ccache avoids the compile completely where possible. +

    +To use distcc with ccache I recommend using the CCACHE_PREFIX +option. You just need to set the environment variable CCACHE_PREFIX to +'distcc' and ccache will prefix the command line used with the +compiler with the command 'distcc'. +

    +

    17.13 SHARING A CACHE

    + + +

    +A group of developers can increase the cache hit rate by sharing a +cache directory. The hard links however cause unwanted side effects, +as all links to a cached file share the file's modification timestamp. +This results in false dependencies to be triggered by timestamp-based +build systems whenever another user links to an existing +file. Typically, users will see that their libraries and binaries are +relinked without reason. To share a cache without side effects, the +following conditions need to be met: +

    +

      +
    • Use the same CCACHE_DIR environment variable setting +
    • Unset the CCACHE_HARDLINK environment variable +
    • Make sure everyone sets the CCACHE_UMASK environment variable + to 002, this ensures that cached files are accessible to everyone in + the group. +
    • Make sure that all users have write permission in the entire + cache directory (and that you trust all users of the shared cache). +
    • Make sure that the setgid bit is set on all directories in the + cache. This tells the filesystem to inherit group ownership for new + directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might + be useful for this. +
    • Set CCACHE_NOCOMPRESS for all users, if there are users with + versions of ccache that do not support compression. +
    +

    +

    17.14 HISTORY

    + + +

    +ccache was inspired by the compilercache shell script script written +by Erik Thiele and I would like to thank him for an excellent piece of +work. See +http://www.erikyyy.de/compilercache/ +for the Erik's scripts. +ccache-swig is a port of the original ccache with support added for use +with SWIG. +

    +I wrote ccache because I wanted to get a bit more speed out of a +compiler cache and I wanted to remove some of the limitations of the +shell-script version. +

    +

    17.15 DIFFERENCES FROM COMPILERCACHE

    + + +

    +The biggest differences between Erik's compilercache script and ccache +are: +

      +
    • ccache is written in C, which makes it a bit faster (calling out to + external programs is mostly what slowed down the scripts). +
    • ccache can automatically find the real compiler +
    • ccache keeps statistics on hits/misses +
    • ccache can do automatic cache management +
    • ccache can cache compiler output that includes warnings. In many + cases this gives ccache a much higher cache hit rate. +
    • ccache can handle a much wider ranger of compiler options +
    • ccache avoids a double call to cpp on a cache miss +
    +

    +

    17.16 CREDITS

    + + +

    +Thanks to the following people for their contributions to ccache +

      +
    • Erik Thiele for the original compilercache script +
    • Luciano Rocha for the idea of compiling the pre-processor output + to avoid a 2nd cpp pass +
    • Paul Russell for many suggestions and the debian packaging +
    +

    +

    17.17 AUTHOR

    + + +

    +ccache was written by Andrew Tridgell +http://samba.org/~tridge/. +ccache was adapted to create ccache-swig for use with SWIG by William Fulton. +

    +If you wish to report a problem or make a suggestion then please email +the SWIG developers on the swig-devel mailing list, see +http://www.swig.org/mail.html +

    +ccache is released under the GNU General Public License version 2 or +later. Please see the file COPYING for license details. +

    + + + + diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile index 5112afa33..893b4a05d 100644 --- a/Doc/Manual/Makefile +++ b/Doc/Manual/Makefile @@ -19,9 +19,10 @@ HTMLDOC_OPTIONS = "--book --toclevels 4 --no-numbered --toctitle \"Table of Cont all: maketoc check generate -maketoc: CCache.html +maketoc: python maketoc.py +# Use this to regenerate CCache.html should this ever be needed CCache.html: ../../CCache/ccache.yo yodl2html -o CCache.html ../../CCache/ccache.yo @@ -53,7 +54,6 @@ swightml.book: chapters Sections.html maintainer-clean: clean-baks rm -f swightml.book rm -f swigpdf.book - rm -f CCache.html rm -f SWIGDocumentation.html rm -f SWIGDocumentation.pdf diff --git a/Makefile.in b/Makefile.in index d9d2c3f18..c79e83815 100644 --- a/Makefile.in +++ b/Makefile.in @@ -49,15 +49,12 @@ maintainer: libfiles # Documentation ##################################################################### -docs: docs-main docs-ccache +docs: docs-main docs-main: @echo making docs @test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) all clean-baks -docs-ccache: - test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) docs) - ##################################################################### # All the languages SWIG speaks (when it wants to) ##################################################################### diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 2e69dbece..98f9912a4 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -95,8 +95,6 @@ os.system("find "+dirname+" -name autom4te.cache -exec rm -rf {} \\;") # Build documentation print "Building html documentation" os.system("cd "+dirname+"/Doc/Manual && make all clean-baks") == 0 or failed() -print "Building man pages" -os.system("cd "+dirname+"/CCache && yodl2man -o ccache-swig.1 ccache.yo") == 0 or failed() # Build the tar-ball os.system("tar -cf "+dirname+".tar "+dirname) == 0 or failed() diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 0b5172b6d..6c0831521 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -12,9 +12,7 @@ else fi case "$SWIGLANG" in - "") - sudo apt-get -qq install yodl - ;; + "") ;; "csharp") sudo apt-get -qq install mono-devel ;; diff --git a/configure.ac b/configure.ac index f352b8201..f03702058 100644 --- a/configure.ac +++ b/configure.ac @@ -117,20 +117,6 @@ echo "Note : None of the following packages are required for users to compile an echo "" AC_PROG_YACC -AC_CHECK_PROGS(YODL2MAN, yodl2man) -AC_CHECK_PROGS(YODL2HTML, yodl2html) - -if test -n "$YODL2MAN"; then - AC_MSG_CHECKING([yodl2man version >= 2.02]) - [yodl_version=`$YODL2MAN --version 2>&1 | grep 'yodl version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.*[0-9]*\).*/\1/g'`] - AX_COMPARE_VERSION([$yodl_version],[ge],[2.02], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no - $yodl_version found])]) -fi - -if test -n "$YODL2HTML"; then - AC_MSG_CHECKING([yodl2html version >= 2.02]) - [yodl_version=`$YODL2HTML --version 2>&1 | grep 'yodl version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] - AX_COMPARE_VERSION([$yodl_version],[ge],[2.02], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no - $yodl_version found])]) -fi echo "" echo "Checking for installed target languages and other information in order to compile and run" From 53f4c92de67c765c19a1077ae2a19fc027a283b7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Dec 2015 04:02:22 +0000 Subject: [PATCH 193/732] Travis octave parallel builds set to 2 as -j quickly ran out of memory --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 225e4abb9..32a29d37e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,13 +40,13 @@ matrix: env: SWIGLANG=lua - compiler: gcc os: linux - env: SWIGLANG=octave SWIGJOBS=-j # 3.2 + env: SWIGLANG=octave SWIGJOBS=-j2 # 3.2 - compiler: gcc os: linux - env: SWIGLANG=octave SWIGJOBS=-j VER=3.8 + env: SWIGLANG=octave SWIGJOBS=-j2 VER=3.8 - compiler: gcc os: linux - env: SWIGLANG=octave SWIGJOBS=-j VER=4.0 + env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.0 - compiler: gcc os: linux env: SWIGLANG=perl5 @@ -157,11 +157,11 @@ matrix: # Occasional gcc internal compiler error - compiler: gcc os: linux - env: SWIGLANG=octave SWIGJOBS=-j VER=3.8 + env: SWIGLANG=octave SWIGJOBS=-j2 VER=3.8 # Occasional gcc internal compiler error - compiler: gcc os: linux - env: SWIGLANG=octave SWIGJOBS=-j VER=4.0 + env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.0 # Not quite working yet - compiler: gcc os: linux From e069365775cb23dd0442c8a0e00845b35f500d58 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Dec 2015 13:57:17 +0000 Subject: [PATCH 194/732] html fixes --- Doc/Manual/Go.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index f5463c8f0..f60e4d3f5 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -607,7 +607,7 @@ This is complicated by the fact that C++ and Go define inheritance differently. SWIG normally represents the C++ class inheritance automatically in Go via interfaces but with a Go type representing a subclass of a C++ class some manual work is necessary. -

    +

    This subchapter gives a step by step guide how to properly sublass a C++ class From 862b4c61386bc147a4612fe072871d6dbdcc1495 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 18 Dec 2015 20:18:11 +0000 Subject: [PATCH 195/732] Add a linkchecker target for checking broken links in SWIGDocumentation.html --- Doc/Manual/Android.html | 2 +- Doc/Manual/CSharp.html | 2 +- Doc/Manual/D.html | 22 +++++++++++----------- Doc/Manual/Introduction.html | 2 +- Doc/Manual/Java.html | 4 ++-- Doc/Manual/Makefile | 10 +++++++++- Doc/Manual/Preface.html | 4 ++-- Doc/Manual/Scilab.html | 2 +- Doc/Manual/Typemaps.html | 2 +- 9 files changed, 29 insertions(+), 21 deletions(-) diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index 2890e2415..ae610b7d8 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -36,7 +36,7 @@ This chapter describes SWIG's support of Android.

    The Android chapter is fairly short as support for Android is the same as for Java, where the Java Native Interface (JNI) is used to call from Android Java into C or C++ compiled code. -Everything in the Java chapter applies to generating code for access from Android Java code. +Everything in the Java chapter applies to generating code for access from Android Java code. This chapter contains a few Android specific notes and examples.

    diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 18fc3037e..e55013b1c 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -1740,7 +1740,7 @@ should pass the call on to CSharpDefaults.DefaultMethod(int)using the C

    -When using multiple modules it is is possible to compile each SWIG generated wrapper +When using multiple modules it is is possible to compile each SWIG generated wrapper into a different assembly. However, by default the generated code may not compile if generated classes in one assembly use generated classes in another assembly. diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index 47dab50f1..984b81bb8 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -50,7 +50,7 @@

    While these issues can be worked around relatively easy by hand-coding a thin wrapper layer around the C library in question, there is another issue where writing wrapper code per hand is not feasible: C++ libraries. D did not support interfacing to C++ in version 1 at all, and even if extern(C++) has been added to D2, the support is still very limited, and a custom wrapper layer is still required in many cases.

    -

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

    +

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

    22.2 Command line invocation

    @@ -64,7 +64,7 @@

    By default, SWIG generates code for D1/Tango. Use the -d2 flag to target D2/Phobos instead.

    -
    -splitproxy
    +
    -splitproxy

    By default, SWIG generates two D modules: the proxy module, named like the source module (either specified via the %module directive or via the module command line switch), which contains all the proxy classes, functions, enums, etc., and the intermediary module (named like the proxy module, but suffixed with _im), which contains all the extern(C) function declarations and other private parts only used internally by the proxy module.

    If the split proxy mode is enabled by passing this switch at the command line, all proxy classes and enums are emitted to their own D module instead. The main proxy module only contains free functions and constants in this case.

    @@ -125,7 +125,7 @@

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

    -

    The code from the in typemap is used to convert arguments to the C wrapper function to the type used in the wrapped code (ctype->original C++ type), the out typemap is utilized to convert values from the wrapped code to wrapper function return types (original C++ type->ctype).

    +

    The code from the in typemap is used to convert arguments to the C wrapper function to the type used in the wrapped code (ctype->original C++ type), the out typemap is utilized to convert values from the wrapped code to wrapper function return types (original C++ type->ctype).

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

    @@ -135,11 +135,11 @@

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

    -

    The din typemap is used for converting function parameter types from the type used in the proxy module or class to the type used in the intermediary D module (the $dinput macro is replaced). To inject further parameter processing code before or after the call to the intermediary layer, the pre, post and terminator attributes can be used (please refer to the C# date marshalling example for more information on these).

    +

    The din typemap is used for converting function parameter types from the type used in the proxy module or class to the type used in the intermediary D module (the $dinput macro is replaced). To inject further parameter processing code before or after the call to the intermediary layer, the pre, post and terminator attributes can be used (please refer to the C# date marshalling example for more information on these).

    -

    The dout typemap is used for converting function return values from the return type used in the intermediary D module to the type returned by the proxy function. The $excode special variable in dout typemaps is replaced by the excode typemap attribute code if the method can throw any exceptions from unmanaged code, otherwise by nothing (the $imcall and $owner macros are replaced).

    +

    The dout typemap is used for converting function return values from the return type used in the intermediary D module to the type returned by the proxy function. The $excode special variable in dout typemaps is replaced by the excode typemap attribute code if the method can throw any exceptions from unmanaged code, otherwise by nothing (the $imcall and $owner macros are replaced).

    -

    The code from the ddirectorin and ddirectorout typemaps is used for conversion in director callback functions. Arguments are converted to the type used in the proxy class method they are calling by using the code from ddirectorin, the proxy class method return value is converted to the type the C++ code expects via the ddirectorout typemap (the $dcall and $winput macros are replaced).

    +

    The code from the ddirectorin and ddirectorout typemaps is used for conversion in director callback functions. Arguments are converted to the type used in the proxy class method they are calling by using the code from ddirectorin, the proxy class method return value is converted to the type the C++ code expects via the ddirectorout typemap (the $dcall and $winput macros are replaced).

    The full chain of type conversions when a director callback is invoked looks like this:

    @@ -172,7 +172,7 @@

    Using dcode and dimports, you can specify additional D code which will be emitted into the class body respectively the imports section of the D module the class is written to.

    -

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

    +

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

    22.3.7 Special variable macros

    @@ -197,7 +197,7 @@
    $null

    In code inserted into the generated C/C++ wrapper functions, this variable is replaced by either 0 or nothing at all, depending on whether the function has a return value or not. It can be used to bail out early e.g. in case of errors (return $null;).

    -
    $dinput (C#: $csinput)
    +
    $dinput (C#: $csinput)

    This variable is used in din typemaps and is replaced by the expression which is to be passed to C/C++.

    For example, this input

    @@ -214,7 +214,7 @@ void foo(SomeClass arg) { example_im.foo(SomeClass.getCPointer(arg)); }
    -
    $imcall and $owner (C#: $imcall)
    +
    $imcall and $owner (C#: $imcall)

    These variables are used in dout typemaps. $imcall contains the call to the intermediary module which provides the value to be used, and $owner signals if the caller is responsible for managing the object lifetime (that is, if the called method is a constructor or has been marked via %newobject).

    Consider the following example:

    @@ -243,7 +243,7 @@ SomeClass bar() {
    $dcall and $winput (C#: $cscall, $iminput)
    -

    These variables are used in the director-specific typemaps ddirectorin and ddirectorout. They are more or less the reverse of the $imcall and $dinput macros: $dcall contains the invocation of the D proxy method of which the return value is to be passed back to C++, $winput contains the parameter value from C++.

    +

    These variables are used in the director-specific typemaps ddirectorin and ddirectorout. They are more or less the reverse of the $imcall and $dinput macros: $dcall contains the invocation of the D proxy method of which the return value is to be passed back to C++, $winput contains the parameter value from C++.

    $excode

    This variable is used in dout and dconstructor typemaps and is filled with the contents of the excode typemap attribute if an exception could be thrown from the C++ side. See the C# documentation for details.

    @@ -263,7 +263,7 @@ SomeClass bar() {
    -
    $importtype(SomeDType)
    +
    $importtype(SomeDType)

    This macro is used in the dimports typemap if a dependency on another D type generated by SWIG is added by a custom typemap.

    Consider the following code snippet:

    diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index 02a41169a..e0dd3c044 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -334,7 +334,7 @@ major features include:

    -Most of C++11 is also supported. Details are in the C++11 section. +Most of C++11 is also supported. Details are in the C++11 section.

    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index c33c1c16c..b6885b94f 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -213,7 +213,7 @@ The Java module requires your system to support shared libraries and dynamic loa This is the commonly used method to load JNI code so your system will more than likely support this.

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

    25.2.1 Running SWIG

    @@ -5969,7 +5969,7 @@ Again this is the same that is in "java.swg", barring the method modifi

    -When using multiple modules or the nspace feature it is common to invoke SWIG with a different -package +When using multiple modules or the nspace feature it is common to invoke SWIG with a different -package command line option for each module. However, by default the generated code may not compile if generated classes in one package use generated classes in another package. diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile index 893b4a05d..d7011db06 100644 --- a/Doc/Manual/Makefile +++ b/Doc/Manual/Makefile @@ -9,7 +9,7 @@ # validation. # # Additional html validation can be done using the validate target. -# Additional link checking can be done using the linkchecker target. +# Additional link checking can be done using the linkchecker1 and linkchecker2 target. # # Note the # and " are escaped @@ -34,6 +34,14 @@ check: tidy -errors --gnu-emacs yes -quiet Sections.html all=`sed '/^#/d' chapters | grep -v CCache.html`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done; +# Check for links which don't work including those generated from the individual .html files into SWIGDocumentation.html +linkchecker: + rm -rf linkchecker-tmp + mkdir linkchecker-tmp + cp SWIGDocumentation.html linkchecker-tmp + cp *.png linkchecker-tmp + (cd linkchecker-tmp && linkchecker -F text --no-warnings SWIGDocumentation.html) + generate: swightml.book swigpdf.book htmldoc --batch swightml.book || true htmldoc --batch swigpdf.book || true diff --git a/Doc/Manual/Preface.html b/Doc/Manual/Preface.html index d17dc229c..23481d751 100644 --- a/Doc/Manual/Preface.html +++ b/Doc/Manual/Preface.html @@ -255,7 +255,7 @@ can only fix bugs if we know about them.

    -Please see the dedicated Windows chapter for instructions on installing +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 @@ -332,7 +332,7 @@ 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 Modules chapter. The CHANGES file shipped with SWIG in the top level directory also lists some examples which build the runtime library.

    diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index cb4a3af90..5a894d587 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -321,7 +321,7 @@ $ swig -scilab -help

    -SWIG for Scilab provides only a low-level C interface for Scilab (see Scripting Languages for the general approach to wrapping). +SWIG for Scilab provides only a low-level C interface for Scilab (see Scripting Languages for the general approach to wrapping). This means that functions, structs, classes, variables, etc... are interfaced through C functions. These C functions are mapped as Scilab functions. There are a few exceptions, such as constants and enumerations, which can be wrapped directly as Scilab variables.

    diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 51fadb095..3d6abf88e 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -655,7 +655,7 @@ The %feature. +SWIG can also be viewed as has having a second set of aspects based around %feature. Features such as %exception are also cross-cutting concerns as they encapsulate code that can be used to add logging or exception handling to any function.

    From 0ae5bfa6e21add4a06068e48cc2f74462c34e1a7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 18 Dec 2015 21:12:30 +0000 Subject: [PATCH 196/732] html links updates --- Doc/Manual/Android.html | 2 +- Doc/Manual/CSharp.html | 2 +- Doc/Manual/Introduction.html | 2 +- Doc/Manual/Java.html | 2 -- Doc/Manual/Javascript.html | 2 +- Doc/Manual/Makefile | 23 ++++++++++++----------- Doc/Manual/Ocaml.html | 2 +- Doc/Manual/Preface.html | 2 +- Doc/Manual/Python.html | 10 +++++----- Doc/Manual/Varargs.html | 2 +- Doc/Manual/linkchecker.config | 4 +--- 11 files changed, 25 insertions(+), 28 deletions(-) diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index ae610b7d8..c90da21b4 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -47,7 +47,7 @@ This chapter contains a few Android specific notes and examples.

    -The examples require the Android SDK and Android NDK which can be installed as per instructions in the links. +The examples require the Android SDK and Android NDK which can be installed as per instructions in the links. The Eclipse version is not required for these examples as just the command line tools are used (shown for Linux as the host, but Windows will be very similar, if not identical in most places). Add the SDK tools and NDK tools to your path and create a directory somewhere for your Android projects (adjust PATH as necessary to where you installed the tools):

    diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index e55013b1c..76590d1cc 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -70,7 +70,7 @@ SWIG C# works equally well on non-Microsoft operating systems such as Linux, Sol

    To get the most out of this chapter an understanding of interop is required. The Microsoft Developer Network (MSDN) has a good reference guide in a section titled "Interop Marshaling". -Monodoc, available from the Mono project, has a very useful section titled Interop with native libraries. +Monodoc, available from the Mono project, has a very useful section titled Interop with native libraries.

    20.1.1 SWIG 2 Compatibility

    diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index e0dd3c044..dc68bff43 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -383,7 +383,7 @@ for further information on this and other Autoconf macros.

    -There is growing support for SWIG in some build tools, for example CMake +There is growing support for SWIG in some build tools, for example CMake is a cross-platform, open-source build manager with built in support for SWIG. CMake can detect the SWIG executable and many of the target language libraries for linking against. CMake knows how to build shared libraries and loadable modules on many different operating systems. diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index b6885b94f..b953eb518 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -349,8 +349,6 @@ directory. If that doesn't work, you will need to read the man-pages for your compiler and linker to get the right set of options. You might also check the SWIG Wiki for additional information. -JNI compilation -is a useful reference for compiling on different platforms.

    diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 613ca99ed..69e6665ea 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -166,7 +166,7 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8

  • 26.3.1 Creating node.js Extensions

    -

    To install node.js you can download an installer from their web-site for Mac OS X and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

    +

    To install node.js you can download an installer from their web-site for Mac OS X and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

     $ sudo add-apt-repository ppa:chris-lea/node.js
    diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
    index d7011db06..7347691cd 100644
    --- a/Doc/Manual/Makefile
    +++ b/Doc/Manual/Makefile
    @@ -34,14 +34,6 @@ check:
     	tidy -errors --gnu-emacs yes -quiet Sections.html
     	all=`sed '/^#/d' chapters | grep -v CCache.html`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done;
     
    -# Check for links which don't work including those generated from the individual .html files into SWIGDocumentation.html
    -linkchecker:
    -	rm -rf linkchecker-tmp
    -	mkdir linkchecker-tmp
    -	cp SWIGDocumentation.html linkchecker-tmp
    -	cp *.png linkchecker-tmp
    -	(cd linkchecker-tmp && linkchecker -F text --no-warnings SWIGDocumentation.html)
    -
     generate: swightml.book swigpdf.book
     	htmldoc --batch swightml.book || true
     	htmldoc --batch swigpdf.book || true
    @@ -77,9 +69,18 @@ test:
     validate:
     	all=`sed '/^#/d' chapters`; for a in $$all; do validate --emacs $$a; done;
     
    -# Link checking using linkchecker
    -linkchecker:
    +# Link checking using linkchecker of the index.html only file (including anchors)
    +linkchecker1:
     	@echo -----------------------------------------------------------------------
     	@echo Note linkchecker versions prior to 6.1 do not work properly wrt anchors
     	@echo -----------------------------------------------------------------------
    -	linkchecker --config=./linkchecker.config index.html
    +	linkchecker --config=./linkchecker.config --anchors index.html
    +
    +# Check for links which don't work including those generated from the individual .html files into SWIGDocumentation.html
    +linkchecker2:
    +	rm -rf linkchecker-tmp
    +	mkdir linkchecker-tmp
    +	cp SWIGDocumentation.html linkchecker-tmp
    +	cp *.png linkchecker-tmp
    +	(cd linkchecker-tmp && linkchecker --config=../linkchecker.config -F text --no-warnings SWIGDocumentation.html)
    +
    diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html
    index da20b8da3..b927a7d8f 100644
    --- a/Doc/Manual/Ocaml.html
    +++ b/Doc/Manual/Ocaml.html
    @@ -80,7 +80,7 @@ variants, functions, classes, etc.
     
     

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

    31.1 Preliminaries

    diff --git a/Doc/Manual/Preface.html b/Doc/Manual/Preface.html index 23481d751..6ddea588a 100644 --- a/Doc/Manual/Preface.html +++ b/Doc/Manual/Preface.html @@ -370,7 +370,7 @@ installation of software you might have. However, this is generally not the rec 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. +Understanding Two-Level Namespaces.

    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 373472d86..962ee6843 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -2738,7 +2738,7 @@ in Python-2.2, an entirely new type of class system was introduced. This new-style class system offers many enhancements including static member functions, properties (managed attributes), and class methods. Details about all of these changes can be found on www.python.org and is not repeated here. +href="https://www.python.org">www.python.org and is not repeated here.

    @@ -5690,7 +5690,7 @@ import foo

    refers to a top-level module or to another module inside the current package. In Python 3 it always refers to a top-level module -(see PEP 328). +(see PEP 328). To instruct Python 2.5 through 2.7 to use new semantics (that is import foo is interpreted as absolute import), one has to put the following line @@ -5881,7 +5881,7 @@ all overloaded functions share the same function in SWIG generated proxy class.

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

    36.12.2 Buffer interface

    @@ -6074,7 +6074,7 @@ used to define an abstract base class for your own C++ class:

    For details of abstract base class, please see -PEP 3119. +PEP 3119.

    36.12.4 Byte string output conversion

    @@ -6160,7 +6160,7 @@ in Python 3 code.

    For more details about the surrogateescape error handler, please see -PEP 383. +PEP 383.

    diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index dac1ad7bc..360bbaa12 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -605,7 +605,7 @@ you need to bring out some bigger guns.

    One way to do this is to use a special purpose library such as libffi (http://sources.redhat.com/libffi). +href="http://www.sourceware.org/libffi/">http://www.sourceware.org/libffi/). libffi is a library that allows you to dynamically construct call-stacks and invoke procedures in a relatively platform independent manner. Details about the library can be found in the libffi diff --git a/Doc/Manual/linkchecker.config b/Doc/Manual/linkchecker.config index a947b278a..9317a8940 100644 --- a/Doc/Manual/linkchecker.config +++ b/Doc/Manual/linkchecker.config @@ -1,5 +1,3 @@ -[checking] -anchors=1 - [filtering] ignorewarnings=http-robots-denied +ignorewarnings=https-certificate-error From edd36b28d2d70031642e780e6e05962430a60378 Mon Sep 17 00:00:00 2001 From: Brian Cole Date: Fri, 6 Jun 2014 13:58:45 -0600 Subject: [PATCH 197/732] Automatically coerce python 2.x unicode objects into UTF8 when passing to underlying code. --- Lib/python/pystrings.swg | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index 2eefaefea..813895e4c 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -63,6 +63,24 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) %#endif return SWIG_OK; } else { +%#if PY_VERSION_HEX<0x03000000 + if (PyUnicode_Check(obj)) { + char *cstr; Py_ssize_t len; + obj = PyUnicode_AsUTF8String(obj); + if (PyString_AsStringAndSize(obj, &cstr, &len) == -1) { + Py_XDECREF(obj); + return SWIG_TypeError; + } + + if (alloc) *alloc = SWIG_NEWOBJ; + if (psize) *psize = len + 1; + *cptr = %new_copy_array(cstr, len + 1, char); + + Py_XDECREF(obj); + return SWIG_OK; + } +%#endif + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; From 291186cfaf39497a42f6ed6395ddaeb2b466ed04 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Dec 2015 03:46:44 +0000 Subject: [PATCH 198/732] Refine Python 2 unicode strings patch --- Lib/python/pystrings.swg | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index 813895e4c..33c00329d 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -63,22 +63,28 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) %#endif return SWIG_OK; } else { +%#if defined(SWIG_PYTHON_2_UNICODE) %#if PY_VERSION_HEX<0x03000000 if (PyUnicode_Check(obj)) { char *cstr; Py_ssize_t len; - obj = PyUnicode_AsUTF8String(obj); - if (PyString_AsStringAndSize(obj, &cstr, &len) == -1) { - Py_XDECREF(obj); - return SWIG_TypeError; + if (!alloc && cptr) { + return SWIG_RuntimeError; } + obj = PyUnicode_AsUTF8String(obj); + if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { + if (cptr) { + if (alloc) *alloc = SWIG_NEWOBJ; + *cptr = %new_copy_array(cstr, len + 1, char); + } + if (psize) *psize = len + 1; - if (alloc) *alloc = SWIG_NEWOBJ; - if (psize) *psize = len + 1; - *cptr = %new_copy_array(cstr, len + 1, char); - - Py_XDECREF(obj); - return SWIG_OK; + Py_XDECREF(obj); + return SWIG_OK; + } else { + Py_XDECREF(obj); + } } +%#endif %#endif swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); @@ -122,4 +128,3 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) } } - From 01611702ec04fa70445fd2c7d37b9b312d3f7561 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Dec 2015 03:52:33 +0000 Subject: [PATCH 199/732] Python 2 Unicode strings can be used as inputs to char * or std::string types Requires SWIG_PYTHON_2_UNICODE to be defined when compiling generated code. --- CHANGES.current | 4 ++ Doc/Manual/Contents.html | 1 + Doc/Manual/Python.html | 66 +++++++++++++++++++ .../python/unicode_strings_runme.py | 9 +++ Examples/test-suite/unicode_strings.i | 8 +++ 5 files changed, 88 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index a0e6dfa2b..050ff54cc 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.8 (in progress) =========================== +2015-12-19: wsfulton + [Python] Python 2 Unicode UTF-8 strings can be used as inputs to char * or + std::string types if the generated C/C++ code has SWIG_PYTHON_2_UNICODE defined. + 2015-12-17: wsfulton Issues #286, #128 Remove ccache-swig.1 man page - please use the CCache.html docs instead. diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 21ba6eaad..6d2cdaa76 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1598,6 +1598,7 @@

  • Buffer interface
  • Abstract base classes
  • Byte string output conversion +
  • Python 2 Unicode
  • diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 962ee6843..c5219b693 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -122,6 +122,7 @@
  • Buffer interface
  • Abstract base classes
  • Byte string output conversion +
  • Python 2 Unicode
  • @@ -6163,6 +6164,71 @@ For more details about the surrogateescape error handler, please see PEP 383.

    +

    36.12.5 Python 2 Unicode

    + + +

    +A Python 3 string is a Unicode string so by default a Python 3 string that contains Unicode +characters passed to C/C++ will be accepted and converted to a C/C++ string +(char * or std::string types). +A Python 2 string is not a unicode string by default and should a Unicode string be +passed to C/C++ it will fail to convert to a C/C++ string +(char * or std::string types). +The Python 2 behavior can be made more like Python 3 by defining +SWIG_PYTHON_2_UNICODE when compiling the generated C/C++ code. +By default when the following is wrapped: +

    + +
    +%module unicode_strings
    +char *charstring(char *s) {
    +  return s;
    +}
    +
    + +

    +An error will occur when using Unicode strings in Python 2: +

    + +
    +>>> from unicode_strings import *
    +>>> charstring("hi")
    +'hi'
    +>>> charstring(u"hi")
    +Traceback (most recent call last):
    +  File "<stdin>", line 1, in ?
    +TypeError: in method 'charstring', argument 1 of type 'char *'
    +
    + +

    +When the SWIG_PYTHON_2_UNICODE macro is added to the generated code: +

    + +
    +%module unicode_strings
    +%begin %{
    +#define SWIG_PYTHON_2_UNICODE
    +%}
    +
    +char *charstring(char *s) {
    +  return s;
    +}
    +
    + +

    +Unicode strings will be successfully accepted and converted from UTF-8, +but note that they are returned as a normal Python 2 string: +

    + +
    +>>> from unicode_strings import *
    +>>> charstring("hi")
    +'hi'
    +>>> charstring(u"hi")
    +'hi'
    +>>>
    +
    + diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py index e1fc7adec..3ce98bcdb 100644 --- a/Examples/test-suite/python/unicode_strings_runme.py +++ b/Examples/test-suite/python/unicode_strings_runme.py @@ -12,3 +12,12 @@ if sys.version_info[0:2] >= (3, 1): raise ValueError('Test comparison mismatch') if unicode_strings.non_utf8_std_string() != test_string: raise ValueError('Test comparison mismatch') + +# Testing SWIG_PYTHON_2_UNICODE flag which allows unicode strings to be passed to C +if sys.version_info[0:2] < (3, 0): + assert unicode_strings.charstring("hello1") == "hello1" + assert unicode_strings.charstring(str(u"hello2")) == "hello2" + assert unicode_strings.charstring(u"hello3") == "hello3" + assert unicode_strings.charstring(unicode("hello4")) == "hello4" + unicode_strings.charstring(u"hell\xb05") + unicode_strings.charstring(u"hell\u00f66") diff --git a/Examples/test-suite/unicode_strings.i b/Examples/test-suite/unicode_strings.i index 56063c8a4..9be3748e6 100644 --- a/Examples/test-suite/unicode_strings.i +++ b/Examples/test-suite/unicode_strings.i @@ -2,6 +2,10 @@ %include +%begin %{ +#define SWIG_PYTHON_2_UNICODE +%} + %inline %{ const char* non_utf8_c_str(void) { @@ -12,4 +16,8 @@ std::string non_utf8_std_string(void) { return std::string("h\xe9llo w\xc3\xb6rld"); } +char *charstring(char *s) { + return s; +} + %} From e07938ae8e1a7793ab381b85d0a9a1348d6fecc3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Dec 2015 04:11:48 +0000 Subject: [PATCH 200/732] pystrings.swg cosmetic formatting --- Lib/python/pystrings.swg | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index 33c00329d..a088c4cea 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -42,18 +42,17 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) %#else if (*alloc == SWIG_NEWOBJ) %#endif - { - *cptr = %new_copy_array(cstr, len + 1, char); - *alloc = SWIG_NEWOBJ; - } - else { + { + *cptr = %new_copy_array(cstr, len + 1, char); + *alloc = SWIG_NEWOBJ; + } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } else { - %#if PY_VERSION_HEX>=0x03000000 - assert(0); /* Should never reach here in Python 3 */ - %#endif + %#if PY_VERSION_HEX>=0x03000000 + assert(0); /* Should never reach here in Python 3 */ + %#endif *cptr = SWIG_Python_str_AsChar(obj); } } From aa3e2c82c786224c36e765f2d2b20e5df78c83d3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Dec 2015 11:55:26 +0000 Subject: [PATCH 201/732] Use -Wmissing-field-initializers warning testing all languages on Travis --- Tools/testflags.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tools/testflags.py b/Tools/testflags.py index 63a3b4645..9aafd8eb7 100755 --- a/Tools/testflags.py +++ b/Tools/testflags.py @@ -3,7 +3,7 @@ def get_cflags(language, std, compiler): if std == None or len(std) == 0: std = "gnu89" - c_common = "-fdiagnostics-show-option -std=" + std + " -Wno-long-long -Wreturn-type -Wdeclaration-after-statement" + c_common = "-fdiagnostics-show-option -std=" + std + " -Wno-long-long -Wreturn-type -Wdeclaration-after-statement -Wmissing-field-initializers" cflags = { "csharp":"-Werror " + c_common, "d":"-Werror " + c_common, @@ -15,7 +15,7 @@ def get_cflags(language, std, compiler): "octave":"-Werror " + c_common, "perl5":"-Werror " + c_common, "php":"-Werror " + c_common, - "python":"-Werror " + c_common + " -Wmissing-field-initializers", + "python":"-Werror " + c_common, "r":"-Werror " + c_common, "ruby":"-Werror " + c_common, "scilab":"-Werror " + c_common, @@ -32,7 +32,7 @@ def get_cflags(language, std, compiler): def get_cxxflags(language, std, compiler): if std == None or len(std) == 0: std = "c++98" - cxx_common = "-fdiagnostics-show-option -std=" + std + " -Wno-long-long -Wreturn-type" + cxx_common = "-fdiagnostics-show-option -std=" + std + " -Wno-long-long -Wreturn-type -Wmissing-field-initializers" cxxflags = { "csharp":"-Werror " + cxx_common, "d":"-Werror " + cxx_common, @@ -44,7 +44,7 @@ def get_cxxflags(language, std, compiler): "octave":"-Werror " + cxx_common, "perl5":"-Werror " + cxx_common, "php":"-Werror " + cxx_common, - "python":"-Werror " + cxx_common + " -Wmissing-field-initializers", + "python":"-Werror " + cxx_common, "r":"-Werror " + cxx_common, "ruby":"-Werror " + cxx_common, "scilab": cxx_common, From 04539a930d0979859e90432e680af1a9c084aa68 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 Dec 2015 13:39:57 +0000 Subject: [PATCH 202/732] R test case warning fixes --- Examples/test-suite/r_copy_struct.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/r_copy_struct.i b/Examples/test-suite/r_copy_struct.i index fda321afb..6a79b5422 100644 --- a/Examples/test-suite/r_copy_struct.i +++ b/Examples/test-suite/r_copy_struct.i @@ -48,7 +48,7 @@ getA() return a; } -static struct A fixed = {20, 3, 42.0}; +static struct A fixed = {20, 3, 42.0, 0, 0}; struct A * getARef() From 4f2dcfaeeb32b22af3424c5b7a4cd2847b7875f5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 Dec 2015 14:22:05 +0000 Subject: [PATCH 203/732] Fixes for Ruby and using -Wmissing-field-initializers --- Lib/ruby/boost_shared_ptr.i | 24 ++++++++++++------------ Lib/ruby/director.swg | 4 ++-- Lib/ruby/rubyrun.swg | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Lib/ruby/boost_shared_ptr.i b/Lib/ruby/boost_shared_ptr.i index a58f0f828..938074d81 100644 --- a/Lib/ruby/boost_shared_ptr.i +++ b/Lib/ruby/boost_shared_ptr.i @@ -26,7 +26,7 @@ // plain value %typemap(in) CONST TYPE (void *argp, int res = 0) { - swig_ruby_owntype newmem = {0}; + swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); @@ -45,7 +45,7 @@ %typemap(varin) CONST TYPE { void *argp = 0; - swig_ruby_owntype newmem = {0}; + swig_ruby_owntype newmem = {0, 0}; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); @@ -65,7 +65,7 @@ // plain pointer // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { - swig_ruby_owntype newmem = {0}; + swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); @@ -87,7 +87,7 @@ %typemap(varin) CONST TYPE * { void *argp = 0; - swig_ruby_owntype newmem = {0}; + swig_ruby_owntype newmem = {0, 0}; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); @@ -110,7 +110,7 @@ // plain reference %typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { - swig_ruby_owntype newmem = {0}; + swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); @@ -131,7 +131,7 @@ %typemap(varin) CONST TYPE & { void *argp = 0; - swig_ruby_owntype newmem = {0}; + swig_ruby_owntype newmem = {0, 0}; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); @@ -156,7 +156,7 @@ // plain pointer by reference // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { - swig_ruby_owntype newmem = {0}; + swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); @@ -184,7 +184,7 @@ // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { - swig_ruby_owntype newmem = {0}; + swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); @@ -198,7 +198,7 @@ } %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { - swig_ruby_owntype newmem = {0}; + swig_ruby_owntype newmem = {0, 0}; void *argp = 0; int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { @@ -214,7 +214,7 @@ // shared_ptr by reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { - swig_ruby_owntype newmem = {0}; + swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); @@ -241,7 +241,7 @@ // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { - swig_ruby_owntype newmem = {0}; + swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); @@ -269,7 +269,7 @@ // shared_ptr by pointer reference %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { - swig_ruby_owntype newmem = {0}; + swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg index 5d5161db4..c6c53a343 100644 --- a/Lib/ruby/director.swg +++ b/Lib/ruby/director.swg @@ -30,7 +30,7 @@ namespace Swig { } virtual swig_ruby_owntype get_own() const { - swig_ruby_owntype own = {0}; + swig_ruby_owntype own = {0, 0}; return own; } }; @@ -332,7 +332,7 @@ namespace Swig { } swig_ruby_owntype swig_release_ownership(void *vptr) const { - swig_ruby_owntype own = {0}; + swig_ruby_owntype own = {0, 0}; if (vptr) { SWIG_GUARD(swig_mutex_own); swig_ownership_map::iterator iter = swig_owner.find(vptr); diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index 615d8ad38..e18208f90 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -245,7 +245,7 @@ typedef struct { SWIGRUNTIME swig_ruby_owntype SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { - swig_ruby_owntype oldown = {0}; + swig_ruby_owntype oldown = {0, 0}; if (obj) { oldown.datafree = RDATA(obj)->dfree; RDATA(obj)->dfree = own.datafree; From ec8a5c71cbcc09e820d4d4d2e212b8d1b4f418b8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 Dec 2015 14:33:20 +0000 Subject: [PATCH 204/732] Fixes for Octave and missing -Wmissing-field-initializers in swig_octave_member --- Source/Modules/octave.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 0e3e16cbb..fcbdb97e2 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -234,7 +234,7 @@ public: } Printf(f_init, "return true;\n}\n"); - Printf(s_global_tab, "{0,0,0,0,0}\n};\n"); + Printf(s_global_tab, "{0,0,0,0,0,0}\n};\n"); Printv(f_wrappers, s_global_tab, NIL); SwigType_emit_type_table(f_runtime, f_wrappers); @@ -998,7 +998,7 @@ public: Delete(cnameshdw); } - Printf(s_members_tab, "{0,0,0,0}\n};\n"); + Printf(s_members_tab, "{0,0,0,0,0,0}\n};\n"); Printv(f_wrappers, s_members_tab, NIL); String *base_class_names = NewString(""); From 6a61f8271f372e74aa0d2d44533dd1d7295eff64 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Dec 2015 13:44:36 +0000 Subject: [PATCH 205/732] Php fix for -Wmissing-field-initializers warning Use ZEND_FE_END (introduced sometime around 5.2) to obtain the correct number of arguments for zend_function_entry. Fallback to the original 3 argument initializer if not defined, however, this will not fix the initializer warning though for some older versions of PHP. --- Lib/php/phprun.swg | 4 ++++ Source/Modules/php.cxx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index 00d8bc560..3f0aa7ac6 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -24,6 +24,10 @@ extern "C" { # define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_NAMED_FE(ZN, N, A) #endif +#ifndef ZEND_FE_END +# define ZEND_FE_END { NULL, NULL, NULL } +#endif + #ifndef Z_SET_ISREF_P /* For PHP < 5.3 */ # define Z_SET_ISREF_P(z) (z)->is_ref = 1 diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 37a8f9628..64f03ab21 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -639,7 +639,7 @@ public: Printv(f_begin, all_cs_entry, "\n\n", s_arginfo, "\n\n", s_entry, " SWIG_ZEND_NAMED_FE(swig_", module, "_alter_newobject,_wrap_swig_", module, "_alter_newobject,NULL)\n" " SWIG_ZEND_NAMED_FE(swig_", module, "_get_newobject,_wrap_swig_", module, "_get_newobject,NULL)\n" - "{NULL, NULL, NULL}\n};\n\n", NIL); + " ZEND_FE_END\n};\n\n", NIL); Printv(f_begin, s_init, NIL); Delete(s_header); Delete(s_wrappers); From e9176365751d41c5ff9faa7074d1b48acf3fc59e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Dec 2015 14:53:11 +0000 Subject: [PATCH 206/732] Tcl fix when using -Wmissing-field-initializers warnings Only fixed for Tcl >= 8.5 as prior to this version the Tcl_HashTable structure changed a few times. --- Lib/tcl/tclrun.swg | 6 ++++++ Source/Modules/tcl8.cxx | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Lib/tcl/tclrun.swg b/Lib/tcl/tclrun.swg index c91a7e511..fd1052a28 100644 --- a/Lib/tcl/tclrun.swg +++ b/Lib/tcl/tclrun.swg @@ -67,6 +67,12 @@ #define SWIG_GetConstant SWIG_GetConstantObj #define SWIG_Tcl_GetConstant SWIG_Tcl_GetConstantObj +#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 5 +#define SWIG_TCL_HASHTABLE_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#else +#define SWIG_TCL_HASHTABLE_INIT {0} +#endif + #include "assert.h" #ifdef __cplusplus diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 2e32fc808..72eba0594 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -968,7 +968,7 @@ public: Printf(f_wrappers, ",0"); } Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname, "_bases,", - "swig_", mangled_classname, "_base_names, &swig_module };\n", NIL); + "swig_", mangled_classname, "_base_names, &swig_module, SWIG_TCL_HASHTABLE_INIT };\n", NIL); if (!itcl) { Printv(cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, (ClientData)&_wrap_class_", mangled_classname, From 0a07cd4c3018618dfc8b73c98e619ac5c155c607 Mon Sep 17 00:00:00 2001 From: Petre Eftime Date: Tue, 22 Dec 2015 14:33:21 +0200 Subject: [PATCH 207/732] Prevent redefinition warnings when compiling with SWIG defined Signed-off-by: Petre Eftime --- Source/Modules/allegrocl.cxx | 4 +--- Source/Modules/cffi.cxx | 4 +--- Source/Modules/chicken.cxx | 3 +-- Source/Modules/csharp.cxx | 3 +-- Source/Modules/d.cxx | 3 +-- Source/Modules/guile.cxx | 3 +-- Source/Modules/java.cxx | 2 +- Source/Modules/lua.cxx | 3 +-- Source/Modules/modula3.cxx | 4 +--- Source/Modules/mzscheme.cxx | 4 +--- Source/Modules/ocaml.cxx | 4 ++-- Source/Modules/octave.cxx | 4 ++-- Source/Modules/perl5.cxx | 4 ++-- Source/Modules/php.cxx | 4 +--- Source/Modules/pike.cxx | 4 +--- Source/Modules/python.cxx | 3 +-- Source/Modules/r.cxx | 4 +--- Source/Modules/ruby.cxx | 3 +-- Source/Modules/scilab.cxx | 3 +-- Source/Modules/tcl8.cxx | 4 +--- 20 files changed, 23 insertions(+), 47 deletions(-) diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 4b2f325ba..fae255b7f 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1635,9 +1635,7 @@ int ALLEGROCL::top(Node *n) { Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGALLEGROCL\n"); - Printf(f_runtime, "\n"); + Printf(f_runtime, "\n\n#ifndef SWIGALLEGROCL\n#define SWIGALLEGROCL\n#endif\n\n"); Swig_banner_target_lang(f_cl, ";;"); diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 174bc123c..5d2b8435c 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -174,9 +174,7 @@ int CFFI::top(Node *n) { Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGCFFI\n"); - Printf(f_runtime, "\n"); + Printf(f_runtime, "\n\n#ifndef SWIGCFFI\n#define SWIGCFFI\n#endif\n\n"); Swig_banner_target_lang(f_lisp, ";;;"); diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index 986638cf3..68a42a29b 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -222,8 +222,7 @@ int CHICKEN::top(Node *n) { Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGCHICKEN\n"); + Printf(f_runtime, "\n\n#ifndef SWIGCHICKEN\n#define SWIGCHICKEN\n#endif\n\n"); if (no_collection) Printf(f_runtime, "#define SWIG_CHICKEN_NO_COLLECTION 1\n"); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index baed0c260..eaa027f2a 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -392,8 +392,7 @@ public: Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGCSHARP\n"); + Printf(f_runtime, "\n\n#ifndef SWIGCSHARP\n#define SWIGCSHARP\n#endif\n\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 267dd8c03..5fc21ad18 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -472,8 +472,7 @@ public: Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGD\n"); + Printf(f_runtime, "\n\n#ifndef SWIGD\n#define SWIGD\n#endif\n\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 61f79c1d0..7b42ff94f 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -322,8 +322,7 @@ public: Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGGUILE\n"); + Printf(f_runtime, "\n\n#ifndef SWIGGUILE\n#define SWIGGUILE\n#endif\n\n"); /* Write out directives and declarations */ diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 636189989..afe8ca841 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -425,7 +425,7 @@ public: Swig_banner(f_begin); - Printf(f_runtime, "\n#define SWIGJAVA\n"); + Printf(f_runtime, "\n\n#ifndef SWIGJAVA\n#define SWIGJAVA\n#endif\n\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index 8211fb317..12e8d10ba 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -329,8 +329,7 @@ public: /* Standard stuff for the SWIG runtime section */ Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGLUA\n"); + Printf(f_runtime, "\n\n#ifndef SWIGLUA\n#define SWIGLUA\n#endif\n\n"); emitLuaFlavor(f_runtime); diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index d9a0c922b..307c7857d 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -958,9 +958,7 @@ MODULA3(): Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGMODULA3\n"); - Printf(f_runtime, "\n"); + Printf(f_runtime, "\n\n#ifndef SWIGMODULA3\n#define SWIGMODULA3\n#endif\n\n"); Swig_name_register("wrapper", "Modula3_%f"); if (old_variable_names) { diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index ed9641b30..dd3aecc40 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -150,9 +150,7 @@ public: Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGMZSCHEME\n"); - Printf(f_runtime, "\n"); + Printf(f_runtime, "\n\n#ifndef SWIGMZSCHEME\n#define SWIGMZSCHEME\n#endif\n\n"); module = Getattr(n, "name"); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 87b430b02..1c5ceefaa 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -269,8 +269,8 @@ public: Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGOCAML\n"); + Printf(f_runtime, "\n\n#ifndef SWIGOCAML\n#define SWIGOCAML\n#endif\n\n"); + Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module); /* Module name */ Printf(f_mlbody, "let module_name = \"%s\"\n", module); diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index fcbdb97e2..37cfeee64 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -194,8 +194,8 @@ public: Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGOCTAVE\n"); + Printf(f_runtime, "\n\n#ifndef SWIGOCTAVE\n#define SWIGOCTAVE\n#endif\n\n"); + Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module); Printf(f_runtime, "#define SWIG_name %s\n", module); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 2ff7c6f91..9182ce46b 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -325,8 +325,8 @@ public: Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGPERL\n"); + Printf(f_runtime, "\n\n#ifndef SWIGPERL\n#define SWIGPERL\n#endif\n\n"); + if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); } diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 64f03ab21..fbece2715 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -320,9 +320,7 @@ public: Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGPHP\n"); - Printf(f_runtime, "\n"); + Printf(f_runtime, "\n\n#ifndef SWIGPHP\n#define SWIGPHP\n#endif\n\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index 22c5a638b..6a74851c8 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -149,9 +149,7 @@ public: /* Standard stuff for the SWIG runtime section */ Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGPIKE\n"); - Printf(f_runtime, "\n"); + Printf(f_runtime, "\n\n#ifndef SWIGPIKE\n#define SWIGPIKE\n#endif\n\n"); Printf(f_header, "#define SWIG_init pike_module_init\n"); Printf(f_header, "#define SWIG_name \"%s\"\n\n", module); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3bdb38984..58f5e52fd 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -659,8 +659,7 @@ public: Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGPYTHON\n"); + Printf(f_runtime, "\n\n#ifndef SWIGPYTHON\n#define SWIGPYTHON\n#endif\n\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 0e8e23063..758cb00ee 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -793,9 +793,7 @@ int R::top(Node *n) { Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGR\n"); - Printf(f_runtime, "\n"); + Printf(f_runtime, "\n\n#ifndef SWIGR\n#define SWIGR\n#endif\n\n"); Swig_banner_target_lang(s_init, "#"); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 9dff4276a..f28ba9fd9 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1097,8 +1097,7 @@ public: Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGRUBY\n"); + Printf(f_runtime, "\n\n#ifndef SWIGRUBY\n#define SWIGRUBY\n#endif\n\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx index dd0645bd2..63f689eaa 100644 --- a/Source/Modules/scilab.cxx +++ b/Source/Modules/scilab.cxx @@ -195,8 +195,7 @@ public: /* Output module initialization code */ Swig_banner(beginSection); - Printf(runtimeSection, "\n#define SWIGSCILAB\n"); - Printf(runtimeSection, "\n"); + Printf(runtimeSection, "\n\n#ifndef SWIGSCILAB\n#define SWIGSCILAB\n#endif\n\n"); // Gateway header source merged with wrapper source in nobuilder mode if (!generateBuilder) diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 72eba0594..1227af79c 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -165,9 +165,7 @@ public: Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGTCL\n"); - Printf(f_runtime, "\n"); + Printf(f_runtime, "\n\n#ifndef SWIGTCL\n#define SWIGTCL\n#endif\n\n"); /* Set the module name, namespace, and prefix */ From ba01182ec4806667f4b220b88cc7e25da08d834d Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Mon, 14 Dec 2015 22:38:40 -0500 Subject: [PATCH 208/732] Fixing Python primitive conversions Don't mistakenly treat PyLong objects as PyInt objects in Python3. This resolves issues of large integers being incorrectly treated as -1 while also having an OverflowError set internally for converting PyLong->long and PyLong->double Conversions from PyLong to long, unsigned long, long long, and unsigned long long now raise OverflowError rather than TypeError when given an out of range value. Removing unnecessary check for PyLong_AsLong when converting PyLong->unsigned long since the call to PyLong_AsUnsignedLong will have covered this case. --- Lib/python/pyprimtypes.swg | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg index 30bb64f66..73a97bc5a 100644 --- a/Lib/python/pyprimtypes.swg +++ b/Lib/python/pyprimtypes.swg @@ -75,16 +75,20 @@ SWIGINTERNINLINE PyObject* SWIGINTERN int SWIG_AsVal_dec(long)(PyObject *obj, long* val) { +%#if PY_VERSION_HEX < 0x03000000 if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; - } else if (PyLong_Check(obj)) { + } else +%#endif + if (PyLong_Check(obj)) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); + return SWIG_OverflowError; } } %#ifdef SWIG_PYTHON_CAST_MODE @@ -146,18 +150,7 @@ 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 + return SWIG_OverflowError; } } %#ifdef SWIG_PYTHON_CAST_MODE @@ -212,6 +205,7 @@ SWIG_AsVal_dec(long long)(PyObject *obj, long long *val) return SWIG_OK; } else { PyErr_Clear(); + res = SWIG_OverflowError; } } else { long v; @@ -266,6 +260,7 @@ SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val) return SWIG_OK; } else { PyErr_Clear(); + res = SWIG_OverflowError; } } else { unsigned long v; @@ -305,9 +300,11 @@ SWIG_AsVal_dec(double)(PyObject *obj, double *val) if (PyFloat_Check(obj)) { if (val) *val = PyFloat_AsDouble(obj); return SWIG_OK; +%#if PY_VERSION_HEX < 0x03000000 } else if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; +%#endif } else if (PyLong_Check(obj)) { double v = PyLong_AsDouble(obj); if (!PyErr_Occurred()) { From 2f8a7b822d1a78c421dd4398d4f5ef21ab69ff0c Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Wed, 23 Dec 2015 18:46:46 -0500 Subject: [PATCH 209/732] Adding unit tests for Python primitive type conversions Adding unit tests for operator overloading to determine which overload was chosen Allow TypeError when testing overloads since it is generated instead of NotImplementedError when swig is run with -O or -fastdispatch --- Examples/test-suite/primitive_types.i | 1 + .../python/primitive_types_runme.py | 137 ++++++++++++++++++ 2 files changed, 138 insertions(+) diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i index 82a673536..29b44ec8c 100644 --- a/Examples/test-suite/primitive_types.i +++ b/Examples/test-suite/primitive_types.i @@ -365,6 +365,7 @@ macro(size_t, pfx, sizet) %define ovr_decl(type, pfx, name) virtual int pfx##_##val(type x) { return 1; } virtual int pfx##_##ref(const type& x) { return 1; } + virtual const char* pfx##_##str(type x) { return "name"; } %enddef diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py index 2e7ed7db7..2f8b2d99c 100644 --- a/Examples/test-suite/python/primitive_types_runme.py +++ b/Examples/test-suite/python/primitive_types_runme.py @@ -1,3 +1,5 @@ +import ctypes +import sys from primitive_types import * var_init() @@ -436,3 +438,138 @@ if s != "hello": v = SetPos(1, 3) if v != 4: raise RuntimeError, "bad int typemap" + +# +# Check the bounds for converting various types +# + +# Get the minimum and maximum values that fit in signed char, short, int, long, and long long +overchar = 2 ** 7 +while ctypes.c_byte(overchar).value > 0: + overchar *= 2 +minchar = -overchar +maxchar = overchar - 1 +maxuchar = 2 * maxchar + 1 +overshort = overchar +while ctypes.c_short(overshort).value > 0: + overshort *= 2 +minshort = -overshort +maxshort = overshort - 1 +maxushort = 2 * maxshort + 1 +overint = overshort +while ctypes.c_int(overint).value > 0: + overint *= 2 +minint = -overint +maxint = overint - 1 +maxuint = 2 * maxint + 1 +overlong = overint +while ctypes.c_long(overlong).value > 0: + overlong *= 2 +minlong = -overlong +maxlong = overlong - 1 +maxulong = 2 * maxlong + 1 +overllong = overlong +while ctypes.c_longlong(overllong).value > 0: + overllong *= 2 +minllong = -overllong +maxllong = overllong - 1 +maxullong = 2 * maxllong + 1 + +# Make sure Python 2's sys.maxint is the same as the maxlong we calculated +if sys.version_info[0] <= 2 and maxlong != sys.maxint: + raise RuntimeError, "sys.maxint is not the maximum value of a signed long" + +def checkType(t, e, val, delta): + """t = Test object, e = type name (e.g. ulong), val = max or min allowed value, delta = +1 for max, -1 for min""" + error = 0 + # Set the extreme valid value for var_* + setattr(t, 'var_' + e, val) + # Make sure it was set properly and works properly in the val_* and ref_* methods + if getattr(t, 'var_' + e) != val or getattr(t, 'val_' + e)(val) != val or getattr(t, 'ref_' + e)(val) != val: + error = 1 + # Make sure setting a more extreme value fails without changing the value + try: + a = getattr(t, 'var_' + e) + setattr(t, 'var_' + e, val + delta) + error = 1 + except OverflowError: + if a != getattr(t, 'var_' + e): + error = 1 + # Make sure the val_* and ref_* methods fail with a more extreme value + try: + getattr(t, 'val_' + e)(val + delta) + error = 1 + except OverflowError: + pass + try: + getattr(t, 'ref_' + e)(val + delta) + error = 1 + except OverflowError: + pass + if error: + raise RuntimeError, "bad " + e + " typemap" + +def checkFull(t, e, maxval, minval): + """Check the maximum and minimum bounds for the type given by e""" + checkType(t, e, maxval, 1) + checkType(t, e, minval, -1) + +checkFull(t, 'llong', maxllong, minllong) +checkFull(t, 'long', maxlong, minlong) +checkFull(t, 'int', maxint, minint) +checkFull(t, 'short', maxshort, minshort) +checkFull(t, 'schar', maxchar, minchar) +checkFull(t, 'ullong', maxullong, 0) +checkFull(t, 'ulong', maxulong, 0) +checkFull(t, 'uint', maxuint, 0) +checkFull(t, 'ushort', maxushort, 0) +checkFull(t, 'uchar', maxuchar, 0) + +def checkOverload(t, name, val, delta, prevval, limit): + """ + Check that overloading works + t = Test object + name = type name (e.g. ulong) + val = max or min allowed value + delta = +1 for max, -1 for min + prevval = corresponding value for one smaller type + limit = most extreme value for any type + """ + # If val == prevval, then the smaller typemap will win + if val != prevval: + # Make sure the most extreme value of this type gives the name of this type + if t.ovr_str(val) != name: + raise RuntimeError, "bad " + name + " typemap" + # Make sure a more extreme value doesn't give the name of this type + try: + if t.ovr_str(val + delta) == name: + raise RuntimeError, "bad " + name + " typemap" + if val == limit: + # Should raise NotImplementedError here since this is the largest integral type + raise RuntimeError, "bad " + name + " typemap" + except NotImplementedError: + # NotImplementedError is expected only if this is the most extreme type + if val != limit: + raise RuntimeError, "bad " + name + " typemap" + except TypeError: + # TypeError is raised instead if swig is run with -O or -fastdispatch + if val != limit: + raise RuntimeError, "bad " + name + " typemap" + +# Check that overloading works: uchar > schar > ushort > short > uint > int > ulong > long > ullong > llong +checkOverload(t, 'uchar', maxuchar, +1, 0, maxullong) +checkOverload(t, 'ushort', maxushort, +1, maxuchar, maxullong) +checkOverload(t, 'uint', maxuint, +1, maxushort, maxullong) +checkOverload(t, 'ulong', maxulong, +1, maxuint, maxullong) +checkOverload(t, 'ullong', maxullong, +1, maxulong, maxullong) +checkOverload(t, 'schar', minchar, -1, 0, minllong) +checkOverload(t, 'short', minshort, -1, minchar, minllong) +checkOverload(t, 'int', minint, -1, minshort, minllong) +checkOverload(t, 'long', minlong, -1, minint, minllong) +checkOverload(t, 'llong', minllong, -1, minlong, minllong) + +# Make sure that large ints can be converted to doubles properly +if val_double(sys.maxint + 1) != float(sys.maxint + 1): + raise RuntimeError, "bad double typemap" +if val_double(-sys.maxint - 2) != float(-sys.maxint - 2): + raise RuntimeError, "bad double typemap" From 79371b9a797bbf41c55250242ebf2fbb3c776b0d Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Wed, 23 Dec 2015 18:38:31 -0500 Subject: [PATCH 210/732] Adding information about PyInt/PyLong conversion updates to CHANGES.current --- CHANGES.current | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 050ff54cc..e501bf836 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,25 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.8 (in progress) =========================== +2015-12-23: ahnolds + [Python] Fixes for conversion of signed and unsigned integer types: + + No longer check for PyInt objects in Python3. Because PyInt_Check + and friends are #defined to the corresponding PyLong methods, this + had caused errors in Python3 where values greater than what could be + stored in a long were incorrectly interpreted as the value -1 with + the Python error indicator set to OverflowError. This applies to + both the conversions PyLong->long and PyLong->double. + + Conversion from PyLong to long, unsigned long, long long, and + unsigned long long now raise OverflowError instead of TypeError in + both Python2 and Python3 for PyLong values outside the range + expressible by the corresponding C type. This matches the existing + behavior for other integral types (signed and unsigned ints, shorts, + and chars), as well as the conversion for PyInt to all numeric + types. This also indirectly applies to the size_t and ptrdiff_t + types, which depend on the conversions for unsigned long and long. + 2015-12-19: wsfulton [Python] Python 2 Unicode UTF-8 strings can be used as inputs to char * or std::string types if the generated C/C++ code has SWIG_PYTHON_2_UNICODE defined. From abe42bbb162396b4440c096b33b2bd98514af84e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 21 Dec 2015 17:51:55 +0000 Subject: [PATCH 211/732] Correct html documentation linking generated by makechap.py script Corrects position of heading text to be as mentioned in the 4.01 transitional standard, see http://www.w3.org/TR/html4/struct/links.html#h-12.1.1. For example, changes

    2 Introduction

    to

    2 Introduction

    The changes will convert the old incorrect usage should an html file using the old approach be added in the future. --- Doc/Manual/makechap.py | 45 +++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/Doc/Manual/makechap.py b/Doc/Manual/makechap.py index 8225bfc79..61994e2a0 100644 --- a/Doc/Manual/makechap.py +++ b/Doc/Manual/makechap.py @@ -21,7 +21,7 @@ import string ############################################################################### # Regexs for -alink = re.compile(r"", re.IGNORECASE) +alink = re.compile(r".*", re.IGNORECASE) heading = re.compile(r"(_nn\d)", re.IGNORECASE) def getheadingname(m): @@ -38,6 +38,19 @@ def getheadingname(m): headingname = "%s_nn%d" % (filenamebase, nameindex) return headingname +# Return heading - 1.1. Introduction in the examples below: +# old style example:

    1.1 Introduction

    +# new style example:

    1.1 Introduction

    +def getheadingtext(m, s): + prevheadingtext_newstyle = m.group(2) + prevheadingtext_oldstyle = m.group(3) + if len(prevheadingtext_oldstyle) == 0 and len(prevheadingtext_newstyle) == 0: + raise RuntimeError("No heading text in line:\n%s" % s) + if len(prevheadingtext_oldstyle) > 0 and len(prevheadingtext_newstyle) > 0: + raise RuntimeError("Two heading texts, only one should be specified in line:\n%s" % s) + prevheadingtext = prevheadingtext_oldstyle if len(prevheadingtext_oldstyle) > 0 else prevheadingtext_newstyle + return prevheadingtext + ############################################################################### # Main program ############################################################################### @@ -59,11 +72,11 @@ name = "" # Regexs for

    ,...

    sections -h1 = re.compile(r".*?

    ()*[\d\.\s]*(.*?)

    ", re.IGNORECASE) -h2 = re.compile(r".*?

    ()*[\d\.\s]*(.*?)

    ", re.IGNORECASE) -h3 = re.compile(r".*?

    ()*[\d\.\s]*(.*?)

    ", re.IGNORECASE) -h4 = re.compile(r".*?

    ()*[\d\.\s]*(.*?)

    ", re.IGNORECASE) -h5 = re.compile(r".*?
    ()*[\d\.\s]*(.*?)
    ", re.IGNORECASE) +h1 = re.compile(r".*?

    (\s*[\d\s]*(.*?))*[\d\s]*(.*?)

    ", re.IGNORECASE) +h2 = re.compile(r".*?

    (\s*[\d\.\s]*(.*?))*[\d\.\s]*(.*?)

    ", re.IGNORECASE) +h3 = re.compile(r".*?

    (\s*[\d\.\s]*(.*?))*[\d\.\s]*(.*?)

    ", re.IGNORECASE) +h4 = re.compile(r".*?

    (\s*[\d\.\s]*(.*?))*[\d\.\s]*(.*?)

    ", re.IGNORECASE) +h5 = re.compile(r".*?
    (\s*[\d\.\s]*(.*?))*[\d\.\s]*(.*?)
    ", re.IGNORECASE) data = open(filename).read() # Read data open(filename+".bak","w").write(data) # Make backup @@ -95,10 +108,10 @@ for s in lines: m = h1.match(s) if m: - prevheadingtext = m.group(2) + prevheadingtext = getheadingtext(m, s) nameindex += 1 headingname = getheadingname(m) - result.append("""

    %d %s

    """ % (headingname,num,prevheadingtext)) + result.append("""

    %d %s

    """ % (headingname,num,prevheadingtext)) result.append("@INDEX@") section = 0 subsection = 0 @@ -109,11 +122,11 @@ for s in lines: continue m = h2.match(s) if m: - prevheadingtext = m.group(2) + prevheadingtext = getheadingtext(m, s) nameindex += 1 section += 1 headingname = getheadingname(m) - result.append("""

    %d.%d %s

    """ % (headingname,num,section, prevheadingtext)) + result.append("""

    %d.%d %s

    """ % (headingname,num,section, prevheadingtext)) if subsubsubsection: index += "\n" @@ -132,11 +145,11 @@ for s in lines: continue m = h3.match(s) if m: - prevheadingtext = m.group(2) + prevheadingtext = getheadingtext(m, s) nameindex += 1 subsection += 1 headingname = getheadingname(m) - result.append("""

    %d.%d.%d %s

    """ % (headingname,num,section, subsection, prevheadingtext)) + result.append("""

    %d.%d.%d %s

    """ % (headingname,num,section, subsection, prevheadingtext)) if subsubsubsection: index += "\n" @@ -151,12 +164,12 @@ for s in lines: continue m = h4.match(s) if m: - prevheadingtext = m.group(2) + prevheadingtext = getheadingtext(m, s) nameindex += 1 subsubsection += 1 headingname = getheadingname(m) - result.append("""

    %d.%d.%d.%d %s

    """ % (headingname,num,section, subsection, subsubsection, prevheadingtext)) + result.append("""

    %d.%d.%d.%d %s

    """ % (headingname,num,section, subsection, subsubsection, prevheadingtext)) if subsubsubsection: index += "\n" @@ -169,11 +182,11 @@ for s in lines: continue m = h5.match(s) if m: - prevheadingtext = m.group(2) + prevheadingtext = getheadingtext(m, s) nameindex += 1 subsubsubsection += 1 headingname = getheadingname(m) - result.append("""
    %d.%d.%d.%d.%d %s
    """ % (headingname,num,section, subsection, subsubsection, subsubsubsection, prevheadingtext)) + result.append("""
    %d.%d.%d.%d.%d %s
    """ % (headingname,num,section, subsection, subsubsection, subsubsubsection, prevheadingtext)) if subsubsubsection == 1: index += "
      \n" From 8288ac15a030b851c18dee2cf5e4e5769f0bc024 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 22 Dec 2015 07:54:57 +0000 Subject: [PATCH 212/732] Correct links in html documentation using new version of makechap.py Corrects position of heading text within A and H1, H2, ... elements. --- Doc/Manual/Allegrocl.html | 108 ++++++++--------- Doc/Manual/Android.html | 16 +-- Doc/Manual/Arguments.html | 22 ++-- Doc/Manual/CCache.html | 36 +++--- Doc/Manual/CPlusPlus11.html | 84 ++++++------- Doc/Manual/CSharp.html | 58 ++++----- Doc/Manual/Chicken.html | 40 +++---- Doc/Manual/Contract.html | 10 +- Doc/Manual/Customization.html | 32 ++--- Doc/Manual/D.html | 44 +++---- Doc/Manual/Extending.html | 100 ++++++++-------- Doc/Manual/Go.html | 56 ++++----- Doc/Manual/Guile.html | 42 +++---- Doc/Manual/Introduction.html | 28 ++--- Doc/Manual/Java.html | 214 +++++++++++++++++----------------- Doc/Manual/Javascript.html | 44 +++---- Doc/Manual/Library.html | 40 +++---- Doc/Manual/Lisp.html | 22 ++-- Doc/Manual/Lua.html | 88 +++++++------- Doc/Manual/Modula3.html | 40 +++---- Doc/Manual/Modules.html | 16 +-- Doc/Manual/Mzscheme.html | 8 +- Doc/Manual/Ocaml.html | 62 +++++----- Doc/Manual/Octave.html | 52 ++++----- Doc/Manual/Perl5.html | 108 ++++++++--------- Doc/Manual/Php.html | 50 ++++---- Doc/Manual/Pike.html | 24 ++-- Doc/Manual/Preface.html | 36 +++--- Doc/Manual/Preprocessor.html | 26 ++--- Doc/Manual/Python.html | 174 +++++++++++++-------------- Doc/Manual/R.html | 16 +-- Doc/Manual/Ruby.html | 200 +++++++++++++++---------------- Doc/Manual/SWIG.html | 108 ++++++++--------- Doc/Manual/SWIGPlus.html | 90 +++++++------- Doc/Manual/Scilab.html | 90 +++++++------- Doc/Manual/Scripting.html | 24 ++-- Doc/Manual/Tcl.html | 92 +++++++-------- Doc/Manual/Typemaps.html | 128 ++++++++++---------- Doc/Manual/Varargs.html | 20 ++-- Doc/Manual/Warnings.html | 36 +++--- Doc/Manual/Windows.html | 40 +++---- 41 files changed, 1262 insertions(+), 1262 deletions(-) diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index 8295bad1c..e76d67e4c 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -8,7 +8,7 @@ -

      18 SWIG and Allegro Common Lisp

      +

      18 SWIG and Allegro Common Lisp

    -

    18.2.2 Foreign Wrappers

    +

    18.2.2 Foreign Wrappers

    @@ -512,7 +512,7 @@ interested in generating an interface to C++. typemap.

    -

    18.2.3 FFI Wrappers

    +

    18.2.3 FFI Wrappers

    @@ -593,7 +593,7 @@ char *xxx(); ff:def-foreign-call's.

    -

    18.2.4 Non-overloaded Defuns

    +

    18.2.4 Non-overloaded Defuns

    @@ -606,7 +606,7 @@ char *xxx(); this function can be manipulated via the lout typemap.

    -

    18.2.5 Overloaded Defuns

    +

    18.2.5 Overloaded Defuns

    @@ -622,7 +622,7 @@ char *xxx(); can be manipulated via the lout typemap.

    -

    18.2.6 What about constant and variable access?

    +

    18.2.6 What about constant and variable access?

    @@ -635,7 +635,7 @@ char *xxx(); into the foreign module.

    -

    18.2.7 Object Wrapping

    +

    18.2.7 Object Wrapping

    @@ -657,7 +657,7 @@ char *xxx(); foreign function interface.

    -

    18.3 Wrapping Details

    +

    18.3 Wrapping Details

    @@ -665,7 +665,7 @@ char *xxx(); translated into lisp.

    -

    18.3.1 Namespaces

    +

    18.3.1 Namespaces

    @@ -742,7 +742,7 @@ namespace car { function such as (car '(1 2 3).

    -

    18.3.2 Constants

    +

    18.3.2 Constants

    @@ -803,7 +803,7 @@ namespace car { not use the -nocwrap command-line option.

    -

    18.3.3 Variables

    +

    18.3.3 Variables

    @@ -881,7 +881,7 @@ globalvar> (globalvar.nnn::glob_float)

  • -

    18.3.4 Enumerations

    +

    18.3.4 Enumerations

    @@ -957,7 +957,7 @@ EXPORT const int ACL_ENUM___FOO3__SWIG_0 = FOO3; -

    18.3.5 Arrays

    +

    18.3.5 Arrays

    @@ -1105,10 +1105,10 @@ namespace BAR { -

    18.3.6 Classes and Structs and Unions (oh my!)

    +

    18.3.6 Classes and Structs and Unions (oh my!)

    -

    18.3.6.1 CLOS wrapping of

    +

    18.3.6.1 CLOS wrapping of

    @@ -1123,7 +1123,7 @@ namespace BAR { integer values.

    -

    18.3.6.2 CLOS Inheritance

    +

    18.3.6.2 CLOS Inheritance

    @@ -1136,7 +1136,7 @@ namespace BAR { parameter.

    -

    18.3.6.3 Member fields and functions

    +

    18.3.6.3 Member fields and functions

    @@ -1152,7 +1152,7 @@ namespace BAR { the interface does nothing for friend directives,

    -

    18.3.6.4 Why not directly access C++ classes using foreign types?

    +

    18.3.6.4 Why not directly access C++ classes using foreign types?

    @@ -1170,11 +1170,11 @@ namespace BAR { use the more robust wrapper functions.

    -

    18.3.7 Templates

    +

    18.3.7 Templates

    -

    18.3.7.1 Generating wrapper code for templates

    +

    18.3.7.1 Generating wrapper code for templates

    @@ -1187,7 +1187,7 @@ namespace BAR { directive.

    -

    18.3.7.2 Implicit Template instantiation

    +

    18.3.7.2 Implicit Template instantiation

    @@ -1197,7 +1197,7 @@ namespace BAR { class schema.

    -

    18.3.8 Typedef, Templates, and Synonym Types

    +

    18.3.8 Typedef, Templates, and Synonym Types

    @@ -1277,7 +1277,7 @@ synonym> -

    18.3.8.1 Choosing a primary type

    +

    18.3.8.1 Choosing a primary type

    @@ -1298,7 +1298,7 @@ synonym> -

    18.3.9 Function overloading/Parameter defaulting

    +

    18.3.9 Function overloading/Parameter defaulting

    @@ -1461,7 +1461,7 @@ overload> -

    18.3.10 Operator wrapping and Operator overloading

    +

    18.3.10 Operator wrapping and Operator overloading

    @@ -1607,7 +1607,7 @@ opoverload> -

    18.3.11 Varargs

    +

    18.3.11 Varargs

    @@ -1628,7 +1628,7 @@ opoverload> with other ways such functions can be wrapped.

    -

    18.3.12 C++ Exceptions

    +

    18.3.12 C++ Exceptions

    @@ -1640,7 +1640,7 @@ opoverload> implemented.

    -

    18.3.13 Pass by value, pass by reference

    +

    18.3.13 Pass by value, pass by reference

    @@ -1652,7 +1652,7 @@ opoverload> newly defined types.

    -

    18.4 Typemaps

    +

    18.4 Typemaps

    @@ -1663,7 +1663,7 @@ opoverload> on Typemaps for more information.

    -

    18.4.1 Code Generation in the C++ Wrapper

    +

    18.4.1 Code Generation in the C++ Wrapper

    @@ -1693,7 +1693,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    18.4.1.1 IN Typemap

    +

    18.4.1.1 IN Typemap

    @@ -1728,7 +1728,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    18.4.1.2 OUT Typemap

    +

    18.4.1.2 OUT Typemap

    @@ -1752,7 +1752,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    18.4.1.3 CTYPE Typemap

    +

    18.4.1.3 CTYPE Typemap

    @@ -1784,7 +1784,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) these common typemaps here.

    -

    18.4.2 Code generation in Lisp wrappers

    +

    18.4.2 Code generation in Lisp wrappers

    @@ -1803,7 +1803,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) 16.3.1 Namespaces for details.

    -

    18.4.2.1 LIN Typemap

    +

    18.4.2.1 LIN Typemap

    @@ -1846,7 +1846,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    18.4.2.2 LOUT Typemap

    +

    18.4.2.2 LOUT Typemap

    @@ -1889,7 +1889,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    18.4.2.3 FFITYPE Typemap

    +

    18.4.2.3 FFITYPE Typemap

    @@ -1939,7 +1939,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    18.4.2.4 LISPTYPE Typemap

    +

    18.4.2.4 LISPTYPE Typemap

    @@ -1959,7 +1959,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    18.4.2.5 LISPCLASS Typemap

    +

    18.4.2.5 LISPCLASS Typemap

    @@ -1983,7 +1983,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    18.4.3 Modifying SWIG behavior using typemaps

    +

    18.4.3 Modifying SWIG behavior using typemaps

    @@ -2017,10 +2017,10 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    18.5 Identifier Converter functions

    +

    18.5 Identifier Converter functions

    -

    18.5.1 Creating symbols in the lisp environment

    +

    18.5.1 Creating symbols in the lisp environment

    @@ -2041,11 +2041,11 @@ return-val wrapper-name(parm0, parm1, ..., parmN) of arguments.

    -

    18.5.2 Existing identifier-converter functions

    +

    18.5.2 Existing identifier-converter functions

    Two basic identifier routines have been defined. -

    18.5.2.1 identifier-convert-null

    +

    18.5.2.1 identifier-convert-null

    @@ -2054,7 +2054,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) strings, from which a symbol will be created.

    -

    18.5.2.2 identifier-convert-lispify

    +

    18.5.2.2 identifier-convert-lispify

    @@ -2063,7 +2063,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) same symbol transformations.

    -

    18.5.2.3 Default identifier to symbol conversions

    +

    18.5.2.3 Default identifier to symbol conversions

    @@ -2072,7 +2072,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) default naming conventions.

    -

    18.5.3 Defining your own identifier-converter

    +

    18.5.3 Defining your own identifier-converter

    @@ -2128,7 +2128,7 @@ indicating the number of arguments passed to the routine indicated by this identifier.

    -

    18.5.4 Instructing SWIG to use a particular identifier-converter

    +

    18.5.4 Instructing SWIG to use a particular identifier-converter

    diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index c90da21b4..2973f1de1 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -5,7 +5,7 @@ -

    19 SWIG and Android

    +

    19 SWIG and Android

      @@ -30,7 +30,7 @@ This chapter describes SWIG's support of Android. -

      19.1 Overview

      +

      19.1 Overview

      @@ -40,10 +40,10 @@ Everything in the Java chapter applies to generatin This chapter contains a few Android specific notes and examples.

      -

      19.2 Android examples

      +

      19.2 Android examples

      -

      19.2.1 Examples introduction

      +

      19.2.1 Examples introduction

      @@ -76,7 +76,7 @@ $ android list targets The following examples are shipped with SWIG under the Examples/android directory and include a Makefile to build and install each example.

      -

      19.2.2 Simple C example

      +

      19.2.2 Simple C example

      @@ -398,7 +398,7 @@ Run the app again and this time you will see the output pictured below, showing

      Android screenshot of SwigSimple example
      -

      19.2.3 C++ class example

      +

      19.2.3 C++ class example

      @@ -746,7 +746,7 @@ Run the app to see the result of calling the C++ code from Java:

      Android screenshot of SwigClass example
      -

      19.2.4 Other examples

      +

      19.2.4 Other examples

      @@ -758,7 +758,7 @@ Note that the 'extend' example is demonstrates the directors feature. Normally C++ exception handling and the STL is not available by default in the version of g++ shipped with Android, but this example turns these features on as described in the next section.

      -

      19.3 C++ STL

      +

      19.3 C++ STL

      diff --git a/Doc/Manual/Arguments.html b/Doc/Manual/Arguments.html index 3b7713686..21da790b7 100644 --- a/Doc/Manual/Arguments.html +++ b/Doc/Manual/Arguments.html @@ -6,7 +6,7 @@ -

      10 Argument Handling

      +

      10 Argument Handling

        @@ -42,7 +42,7 @@ return multiple values through the arguments of a function. This chapter describes some of the techniques for doing this.

        -

        10.1 The typemaps.i library

        +

        10.1 The typemaps.i library

        @@ -50,7 +50,7 @@ This section describes the typemaps.i library file--commonly used to change certain properties of argument conversion.

        -

        10.1.1 Introduction

        +

        10.1.1 Introduction

        @@ -194,7 +194,7 @@ else. To clear a typemap, the %clear directive should be used. For e

      -

      10.1.2 Input parameters

      +

      10.1.2 Input parameters

      @@ -247,7 +247,7 @@ When the function is used in the scripting language interpreter, it will work li result = add(3,4)

    -

    10.1.3 Output parameters

    +

    10.1.3 Output parameters

    @@ -314,7 +314,7 @@ iresult, dresult = foo(3.5, 2) -

    10.1.4 Input/Output parameters

    +

    10.1.4 Input/Output parameters

    @@ -379,7 +379,7 @@ rather than directly overwriting the value of the original input object. SWIG. Backwards compatibility is preserved, but deprecated.

    -

    10.1.5 Using different names

    +

    10.1.5 Using different names

    @@ -413,7 +413,7 @@ Typemap declarations are lexically scoped so a typemap takes effect from the poi file or a matching %clear declaration.

    -

    10.2 Applying constraints to input values

    +

    10.2 Applying constraints to input values

    @@ -423,7 +423,7 @@ insure that a value is positive, or that a pointer is non-NULL. This can be accomplished including the constraints.i library file.

    -

    10.2.1 Simple constraint example

    +

    10.2.1 Simple constraint example

    @@ -449,7 +449,7 @@ the arguments violate the constraint condition, a scripting language exception will be raised. As a result, it is possible to catch bad values, prevent mysterious program crashes and so on.

    -

    10.2.2 Constraint methods

    +

    10.2.2 Constraint methods

    @@ -465,7 +465,7 @@ NONNULL Non-NULL pointer (pointers only). -

    10.2.3 Applying constraints to new datatypes

    +

    10.2.3 Applying constraints to new datatypes

    diff --git a/Doc/Manual/CCache.html b/Doc/Manual/CCache.html index 0ee94c172..88922a8ea 100644 --- a/Doc/Manual/CCache.html +++ b/Doc/Manual/CCache.html @@ -6,7 +6,7 @@ -

    17 Using SWIG with ccache - ccache-swig(1) manpage

    +

    17 Using SWIG with ccache - ccache-swig(1) manpage

      @@ -34,7 +34,7 @@

      -

      17.1 NAME

      +

      17.1 NAME

      @@ -42,7 +42,7 @@ ccache-swig - a fast compiler cache

      -

      17.2 SYNOPSIS

      +

      17.2 SYNOPSIS

      @@ -52,7 +52,7 @@ ccache-swig <compiler> [COMPILER OPTIONS]

      <compiler> [COMPILER OPTIONS]

      -

      17.3 DESCRIPTION

      +

      17.3 DESCRIPTION

      @@ -61,7 +61,7 @@ by caching previous compiles and detecting when the same compile is being done again. ccache-swig is ccache plus support for SWIG. ccache and ccache-swig are used interchangeably in this document.

      -

      17.4 OPTIONS SUMMARY

      +

      17.4 OPTIONS SUMMARY

      @@ -81,7 +81,7 @@ Here is a summary of the options to ccache-swig.

      -

      17.5 OPTIONS

      +

      17.5 OPTIONS

      @@ -123,7 +123,7 @@ rounded down to the nearest multiple of 16 kilobytes.

      -

      17.6 INSTALLATION

      +

      17.6 INSTALLATION

      @@ -155,7 +155,7 @@ This will work as long as /usr/local/bin comes before the path to gcc Note! Do not use a hard link, use a symbolic link. A hardlink will cause "interesting" problems.

      -

      17.7 EXTRA OPTIONS

      +

      17.7 EXTRA OPTIONS

      @@ -175,7 +175,7 @@ file). By using --ccache-skip you can force an option to not be treated as an input file name and instead be passed along to the compiler as a command line option.

      -

      17.8 ENVIRONMENT VARIABLES

      +

      17.8 ENVIRONMENT VARIABLES

      @@ -314,7 +314,7 @@ the use of '#pragma SWIG'.

      -

      17.9 CACHE SIZE MANAGEMENT

      +

      17.9 CACHE SIZE MANAGEMENT

      @@ -327,7 +327,7 @@ When these limits are reached ccache will reduce the cache to 20% below the numbers you specified in order to avoid doing the cache clean operation too often.

      -

      17.10 CACHE COMPRESSION

      +

      17.10 CACHE COMPRESSION

      @@ -338,7 +338,7 @@ performance slowdown, it significantly increases the number of files that fit in the cache. You can turn off compression setting the CCACHE_NOCOMPRESS environment variable.

      -

      17.11 HOW IT WORKS

      +

      17.11 HOW IT WORKS

      @@ -363,7 +363,7 @@ compiler output that you would get without the cache. If you ever discover a case where ccache changes the output of your compiler then please let me know.

      -

      17.12 USING CCACHE WITH DISTCC

      +

      17.12 USING CCACHE WITH DISTCC

      @@ -377,7 +377,7 @@ option. You just need to set the environment variable CCACHE_PREFIX to 'distcc' and ccache will prefix the command line used with the compiler with the command 'distcc'.

      -

      17.13 SHARING A CACHE

      +

      17.13 SHARING A CACHE

      @@ -406,7 +406,7 @@ following conditions need to be met: versions of ccache that do not support compression.

    -

    17.14 HISTORY

    +

    17.14 HISTORY

    @@ -422,7 +422,7 @@ I wrote ccache because I wanted to get a bit more speed out of a compiler cache and I wanted to remove some of the limitations of the shell-script version.

    -

    17.15 DIFFERENCES FROM COMPILERCACHE

    +

    17.15 DIFFERENCES FROM COMPILERCACHE

    @@ -440,7 +440,7 @@ are:

  • ccache avoids a double call to cpp on a cache miss

    -

    17.16 CREDITS

    +

    17.16 CREDITS

    @@ -452,7 +452,7 @@ Thanks to the following people for their contributions to ccache

  • Paul Russell for many suggestions and the debian packaging

    -

    17.17 AUTHOR

    +

    17.17 AUTHOR

    diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html index b7e1d638c..021ad418d 100644 --- a/Doc/Manual/CPlusPlus11.html +++ b/Doc/Manual/CPlusPlus11.html @@ -6,7 +6,7 @@ -

    7 SWIG and C++11

    +

    7 SWIG and C++11

      @@ -61,7 +61,7 @@ -

      7.1 Introduction

      +

      7.1 Introduction

      This chapter gives you a brief overview about the SWIG @@ -76,10 +76,10 @@ users are welcome to help by adapting the existing container interface files and as a patch for inclusion in future versions of SWIG.

      -

      7.2 Core language changes

      +

      7.2 Core language changes

      -

      7.2.1 Rvalue reference and move semantics

      +

      7.2.1 Rvalue reference and move semantics

      @@ -121,7 +121,7 @@ example.i:18: Warning 503: Can't wrap 'operator =' unless renamed to a valid ide

    -

    7.2.2 Generalized constant expressions

    +

    7.2.2 Generalized constant expressions

    SWIG parses and identifies the keyword constexpr, but cannot fully utilise it. @@ -138,7 +138,7 @@ constexpr int YYY = XXX() + 100; When either of these is used from a target language, a runtime call is made to obtain the underlying constant.

    -

    7.2.3 Extern template

    +

    7.2.3 Extern template

    SWIG correctly parses the keywords extern template. @@ -151,7 +151,7 @@ extern template class std::vector<int>; // C++11 explicit instantiation su %template(VectorInt) std::vector<int>; // SWIG instantiation

  • -

    7.2.4 Initializer lists

    +

    7.2.4 Initializer lists

    @@ -283,7 +283,7 @@ Note that the default typemap for std::initializer_list does nothing bu and hence any user supplied typemaps will override it and suppress the warning.

    -

    7.2.5 Uniform initialization

    +

    7.2.5 Uniform initialization

    The curly brackets {} for member initialization are fully @@ -316,7 +316,7 @@ AltStruct var2{2, 4.3}; // calls the constructor 142.15 -

    7.2.6 Type inference

    +

    7.2.6 Type inference

    SWIG supports decltype() with some limitations. Single @@ -333,13 +333,13 @@ int i; int j; decltype(i+j) k; // syntax error -

    7.2.7 Range-based for-loop

    +

    7.2.7 Range-based for-loop

    This feature is part of the implementation block only. SWIG ignores it.

    -

    7.2.8 Lambda functions and expressions

    +

    7.2.8 Lambda functions and expressions

    SWIG correctly parses most of the Lambda functions syntax. For example:

    @@ -365,7 +365,7 @@ auto six = [](int x, int y) { return x+y; }(4, 2); Better support should be available in a later release.

    -

    7.2.9 Alternate function syntax

    +

    7.2.9 Alternate function syntax

    SWIG fully supports the new definition of functions. For example:

    @@ -400,7 +400,7 @@ auto SomeStruct::FuncName(int x, int y) -> int { auto square(float a, float b) -> decltype(a); -

    7.2.10 Object construction improvement

    +

    7.2.10 Object construction improvement

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

    7.2.11 Explicit overrides and final

    +

    7.2.11 Explicit overrides and final

    @@ -487,12 +487,12 @@ struct DerivedStruct : BaseStruct { -

    7.2.12 Null pointer constant

    +

    7.2.12 Null pointer constant

    The nullptr constant is mostly unimportant in wrappers. In the few places it has an effect, it is treated like NULL.

    -

    7.2.13 Strongly typed enumerations

    +

    7.2.13 Strongly typed enumerations

    SWIG supports strongly typed enumerations and parses the new enum class syntax and forward declarator for the enums, such as:

    @@ -548,7 +548,7 @@ The equivalent in Java is: System.out.println(Color.RainbowColors.Red.swigValue() + " " + Color.WarmColors.Red.swigValue() + " " + Color.PrimeColors.Red.swigValue()); -

    7.2.14 Double angle brackets

    +

    7.2.14 Double angle brackets

    SWIG correctly parses the symbols >> as closing the @@ -559,7 +559,7 @@ shift operator >> otherwise.

    std::vector<std::vector<int>> myIntTable; -

    7.2.15 Explicit conversion operators

    +

    7.2.15 Explicit conversion operators

    SWIG correctly parses the keyword explicit for operators in addition to constructors now. @@ -602,7 +602,7 @@ Conversion operators either with or without explicit need renaming to a them available as a normal proxy method.

    -

    7.2.16 Alias templates

    +

    7.2.16 Alias templates

    @@ -656,7 +656,7 @@ example.i:17: Warning 341: The 'using' keyword in type aliasing is not fully sup typedef void (*PFD)(double); // The old style -

    7.2.17 Unrestricted unions

    +

    7.2.17 Unrestricted unions

    SWIG fully supports any type inside a union even if it does not @@ -682,7 +682,7 @@ union P { } p1; -

    7.2.18 Variadic templates

    +

    7.2.18 Variadic templates

    SWIG supports the variadic templates syntax (inside the <> @@ -717,7 +717,7 @@ const int SIZE = sizeof...(ClassName<int, int>); In the above example SIZE is of course wrapped as a constant.

    -

    7.2.19 New string literals

    +

    7.2.19 New string literals

    SWIG supports wide string and Unicode string constants and raw string literals.

    @@ -747,7 +747,7 @@ Note: There is a bug currently where SWIG's preprocessor incorrectly parses an o inside raw string literals.

    -

    7.2.20 User-defined literals

    +

    7.2.20 User-defined literals

    @@ -814,7 +814,7 @@ OutputType var2 = 1234_suffix; OutputType var3 = 3.1416_suffix; -

    7.2.21 Thread-local storage

    +

    7.2.21 Thread-local storage

    SWIG correctly parses the thread_local keyword. For example, variables @@ -834,7 +834,7 @@ A variable will be thread local if accessed from different threads from the targ same way that it will be thread local if accessed from C++ code.

    -

    7.2.22 Explicitly defaulted functions and deleted functions

    +

    7.2.22 Explicitly defaulted functions and deleted functions

    SWIG handles explicitly defaulted functions, that is, = default added to a function declaration. Deleted definitions, which are also called deleted functions, have = delete added to the function declaration. @@ -872,12 +872,12 @@ This is a C++ compile time check and SWIG does not make any attempt to detect if so in this case it is entirely possible to pass an int instead of a double to f from Java, Python etc.

    -

    7.2.23 Type long long int

    +

    7.2.23 Type long long int

    SWIG correctly parses and uses the new long long type already introduced in C99 some time ago.

    -

    7.2.24 Static assertions

    +

    7.2.24 Static assertions

    @@ -892,7 +892,7 @@ struct Check { }; -

    7.2.25 Allow sizeof to work on members of classes without an explicit object

    +

    7.2.25 Allow sizeof to work on members of classes without an explicit object

    @@ -913,7 +913,7 @@ const int SIZE = sizeof(A::member); // does not work with C++03. Okay with C++11 8 -

    7.2.26 Exception specifications and noexcept

    +

    7.2.26 Exception specifications and noexcept

    @@ -929,7 +929,7 @@ int noex2(int) noexcept(true); int noex3(int, bool) noexcept(false); -

    7.2.27 Control and query object alignment

    +

    7.2.27 Control and query object alignment

    @@ -961,7 +961,7 @@ Use the preprocessor to work around this for now: -

    7.2.28 Attributes

    +

    7.2.28 Attributes

    @@ -974,10 +974,10 @@ int [[attr1]] i [[attr2, attr3]]; [[noreturn, nothrow]] void f [[noreturn]] (); -

    7.3 Standard library changes

    +

    7.3 Standard library changes

    -

    7.3.1 Threading facilities

    +

    7.3.1 Threading facilities

    SWIG does not currently wrap or use any of the new threading @@ -985,7 +985,7 @@ classes introduced (thread, mutex, locks, condition variables, task). The main r SWIG target languages offer their own threading facilities so there is limited use for them.

    -

    7.3.2 Tuple types

    +

    7.3.2 Tuple types

    @@ -993,7 +993,7 @@ SWIG does not provide library files for the new tuple types yet. Variadic template support requires further work to provide substantial tuple wrappers.

    -

    7.3.3 Hash tables

    +

    7.3.3 Hash tables

    @@ -1001,14 +1001,14 @@ The new hash tables in the STL are unordered_set, unordered_multise These are not available in SWIG, but in principle should be easily implemented by adapting the current STL containers.

    -

    7.3.4 Regular expressions

    +

    7.3.4 Regular expressions

    While SWIG could provide wrappers for the new C++11 regular expressions classes, there is little need as the target languages have their own regular expression facilities.

    -

    7.3.5 General-purpose smart pointers

    +

    7.3.5 General-purpose smart pointers

    @@ -1017,12 +1017,12 @@ Please see the shared_ptr smart po There is no special smart pointer handling available for std::weak_ptr and std::unique_ptr yet.

    -

    7.3.6 Extensible random number facility

    +

    7.3.6 Extensible random number facility

    This feature extends and standardizes the standard library only and does not effect the C++ language nor SWIG.

    -

    7.3.7 Wrapper reference

    +

    7.3.7 Wrapper reference

    @@ -1033,7 +1033,7 @@ Users would need to write their own typemaps if wrapper references are being use

    -

    7.3.8 Polymorphous wrappers for function objects

    +

    7.3.8 Polymorphous wrappers for function objects

    @@ -1064,7 +1064,7 @@ t = Test() b = t(1,2) # invoke C++ function object -

    7.3.9 Type traits for metaprogramming

    +

    7.3.9 Type traits for metaprogramming

    The type_traits functions to support C++ metaprogramming is useful at compile time and is aimed specifically at C++ development:

    @@ -1114,7 +1114,7 @@ Then the appropriate algorithm can be called for the subset of types given by th 2 -

    7.3.10 Uniform method for computing return type of function objects

    +

    7.3.10 Uniform method for computing return type of function objects

    diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 76590d1cc..e6829aabc 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -5,7 +5,7 @@ -

    20 SWIG and C#

    +

    20 SWIG and C#

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

      20.1 Introduction

      +

      20.1 Introduction

      @@ -73,7 +73,7 @@ The Microsoft Developer Network (MSDN) h Monodoc, available from the Mono project, has a very useful section titled Interop with native libraries.

      -

      20.1.1 SWIG 2 Compatibility

      +

      20.1.1 SWIG 2 Compatibility

      @@ -81,7 +81,7 @@ In order to minimize name collisions between names generated based on input to S

      -

      20.1.2 Additional command line options

      +

      20.1.2 Additional command line options

      @@ -133,7 +133,7 @@ Note that the file extension (.cs) will not be automatically added and needs to Due to possible compiler limits it is not advisable to use -outfile for large projects.

      -

      20.2 Differences to the Java module

      +

      20.2 Differences to the Java module

      @@ -546,7 +546,7 @@ Windows users can also get the examples working using a Cygwin or MinGW environment for automatic configuration of the example makefiles. Any one of the three C# compilers (Portable.NET, Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path. -

      20.3 Void pointers

      +

      20.3 Void pointers

      @@ -564,7 +564,7 @@ void * f(void *v);

    -

    20.4 C# Arrays

    +

    20.4 C# Arrays

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

    -

    20.4.1 The SWIG C arrays library

    +

    20.4.1 The SWIG C arrays library

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

    20.4.2 Managed arrays using P/Invoke default array marshalling

    +

    20.4.2 Managed arrays using P/Invoke default array marshalling

    @@ -740,7 +740,7 @@ and intermediary class method -

    20.4.3 Managed arrays using pinning

    +

    20.4.3 Managed arrays using pinning

    @@ -835,7 +835,7 @@ public static extern void myArrayCopy(global::System.IntPtr jarg1, global::Syste -

    20.5 C# Exceptions

    +

    20.5 C# Exceptions

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

    -

    20.5.1 C# exception example using "check" typemap

    +

    20.5.1 C# exception example using "check" typemap

    @@ -1114,7 +1114,7 @@ method and C# code does not handle pending exceptions via the canthrow attribute Actually it will issue this warning for any function beginning with SWIG_CSharpSetPendingException.

    -

    20.5.2 C# exception example using %exception

    +

    20.5.2 C# exception example using %exception

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

    20.5.3 C# exception example using exception specifications

    +

    20.5.3 C# exception example using exception specifications

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

    -

    20.5.4 Custom C# ApplicationException example

    +

    20.5.4 Custom C# ApplicationException example

    @@ -1371,7 +1371,7 @@ try { -

    20.6 C# Directors

    +

    20.6 C# Directors

    @@ -1384,7 +1384,7 @@ The following sections provide information on the C# director implementation and However, the Java directors section should also be read in order to gain more insight into directors.

    -

    20.6.1 Directors example

    +

    20.6.1 Directors example

    @@ -1505,7 +1505,7 @@ CSharpDerived - UIntMethod(123) -

    20.6.2 Directors implementation

    +

    20.6.2 Directors implementation

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

    20.6.3 Director caveats

    +

    20.6.3 Director caveats

    @@ -1736,7 +1736,7 @@ However, a call from C# to CSharpDefaults.DefaultMethod() will of cours should pass the call on to CSharpDefaults.DefaultMethod(int)using the C++ default value, as shown above.

    -

    20.7 Multiple modules

    +

    20.7 Multiple modules

    @@ -1771,7 +1771,7 @@ the [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrows if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.

    -

    20.8 C# Typemap examples

    +

    20.8 C# Typemap examples

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

    20.8.1 Memory management when returning references to member variables

    +

    20.8.1 Memory management when returning references to member variables

    @@ -1903,7 +1903,7 @@ public class Bike : global::System.IDisposable { Note the addReference call.

    -

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

    +

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

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

    20.8.3 Date marshalling using the csin typemap and associated attributes

    +

    20.8.3 Date marshalling using the csin typemap and associated attributes

    @@ -2308,7 +2308,7 @@ public class example { -

    20.8.4 A date example demonstrating marshalling of C# properties

    +

    20.8.4 A date example demonstrating marshalling of C# properties

    @@ -2408,7 +2408,7 @@ Some points to note:

  • The 'csin' typemap has 'pre', 'post' and 'cshin' attributes, and these are all ignored in the property set. The code in these attributes must instead be replicated within the 'csvarin' typemap. The line creating the temp$csinput variable is such an example; it is identical to what is in the 'pre' attribute. -

    20.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    +

    20.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    @@ -2470,7 +2470,7 @@ Pay special attention to the memory management issues, using these attributes.

    -

    20.8.6 Turning wrapped classes into partial classes

    +

    20.8.6 Turning wrapped classes into partial classes

    @@ -2570,7 +2570,7 @@ demonstrating that the class contains methods calling both unmanaged code - The following example is an alternative approach to adding managed code to the generated proxy class.

    -

    20.8.7 Extending proxy classes with additional C# code

    +

    20.8.7 Extending proxy classes with additional C# code

    @@ -2609,7 +2609,7 @@ public class ExtendMe : global::System.IDisposable { -

    20.8.8 Underlying type for enums

    +

    20.8.8 Underlying type for enums

    diff --git a/Doc/Manual/Chicken.html b/Doc/Manual/Chicken.html index 82861c31c..88cff55a9 100644 --- a/Doc/Manual/Chicken.html +++ b/Doc/Manual/Chicken.html @@ -8,7 +8,7 @@ -

    21 SWIG and Chicken

    +

    21 SWIG and Chicken

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

      -

      21.1 Preliminaries

      +

      21.1 Preliminaries

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

      -

      21.1.1 Running SWIG in C mode

      +

      21.1.1 Running SWIG in C mode

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

      -

      21.1.2 Running SWIG in C++ mode

      +

      21.1.2 Running SWIG in C++ mode

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

      -

      21.2 Code Generation

      +

      21.2 Code Generation

      -

      21.2.1 Naming Conventions

      +

      21.2.1 Naming Conventions

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

      -

      21.2.2 Modules

      +

      21.2.2 Modules

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

      -

      21.2.3 Constants and Variables

      +

      21.2.3 Constants and Variables

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

      -

      21.2.4 Functions

      +

      21.2.4 Functions

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

      -

      21.2.5 Exceptions

      +

      21.2.5 Exceptions

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

    -

    21.3 TinyCLOS

    +

    21.3 TinyCLOS

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

    -

    21.4 Linkage

    +

    21.4 Linkage

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

    -

    21.4.1 Static binary or shared library linked at compile time

    +

    21.4.1 Static binary or shared library linked at compile time

    We can easily use csc to build a static binary.

    @@ -395,7 +395,7 @@ in which case the test script does not need to be linked with example.so. The t be run with csi.

    -

    21.4.2 Building chicken extension libraries

    +

    21.4.2 Building chicken extension libraries

    Building a shared library like in the above section only works if the library @@ -453,7 +453,7 @@ distributed and used by anyone, even if SWIG is not installed.

    See the Examples/chicken/egg directory in the SWIG source for an example that builds two eggs, one using the first method and one using the second method.

    -

    21.4.3 Linking multiple SWIG modules with TinyCLOS

    +

    21.4.3 Linking multiple SWIG modules with TinyCLOS

    Linking together multiple modules that share type information using the %import @@ -477,7 +477,7 @@ with (declare (uses ...)). To create an extension library or an egg, just create a module_load.scm file that (declare (uses ...)) all the modules.

    -

    21.5 Typemaps

    +

    21.5 Typemaps

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

    Lib/chicken/chicken.swg.

    -

    21.6 Pointers

    +

    21.6 Pointers

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

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

    -

    21.6.1 Garbage collection

    +

    21.6.1 Garbage collection

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

    must be called manually.

    -

    21.7 Unsupported features and known problems

    +

    21.7 Unsupported features and known problems

    -

    21.7.1 TinyCLOS problems with Chicken version <= 1.92

    +

    21.7.1 TinyCLOS problems with Chicken version <= 1.92

    In Chicken versions equal to or below 1.92, TinyCLOS has a limitation such that generic methods do not properly work on methods diff --git a/Doc/Manual/Contract.html b/Doc/Manual/Contract.html index 35bc874ef..660daf9fc 100644 --- a/Doc/Manual/Contract.html +++ b/Doc/Manual/Contract.html @@ -6,7 +6,7 @@ -

    13 Contracts

    +

    13 Contracts

      @@ -38,7 +38,7 @@ When one of the rules is violated by a script, a runtime exception is generated rather than having the program continue to execute.

      -

      13.1 The %contract directive

      +

      13.1 The %contract directive

      @@ -94,7 +94,7 @@ RuntimeError: Contract violation: require: (arg1>=0)

    -

    13.2 %contract and classes

    +

    13.2 %contract and classes

    @@ -173,7 +173,7 @@ specified for the derived class all must hold. In the above example, this means that both the arguments to Spam::bar must be positive.

    -

    13.3 Constant aggregation and %aggregate_check

    +

    13.3 Constant aggregation and %aggregate_check

    @@ -262,7 +262,7 @@ Regrettably, there is no automatic way to perform similar checks with enums valu release.

    -

    13.4 Notes

    +

    13.4 Notes

    diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 8e26a7e8a..9ab0a6269 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -6,7 +6,7 @@ -

    12 Customization Features

    +

    12 Customization Features

      @@ -45,7 +45,7 @@ of exception handling is presented. Then, a more general-purpose customization mechanism known as "features" is described.

      -

      12.1 Exception handling with %exception

      +

      12.1 Exception handling with %exception

      @@ -100,7 +100,7 @@ for exception handling. That directive is deprecated--%exception provides the same functionality, but is substantially more flexible.

      -

      12.1.1 Handling exceptions in C code

      +

      12.1.1 Handling exceptions in C code

      @@ -166,7 +166,7 @@ Each target language has its own approach to creating a runtime error/exception and for Perl it is the croak method shown above.

      -

      12.1.2 Exception handling with longjmp()

      +

      12.1.2 Exception handling with longjmp()

      @@ -240,7 +240,7 @@ Note: This implementation is only intended to illustrate the general idea. To m modify it to handle nested try declarations.

      -

      12.1.3 Handling C++ exceptions

      +

      12.1.3 Handling C++ exceptions

      @@ -275,7 +275,7 @@ class OutOfMemory {};

    -

    12.1.4 Exception handlers for variables

    +

    12.1.4 Exception handlers for variables

    @@ -300,7 +300,7 @@ The %allowexception feature works like any other feature and so can be -

    12.1.5 Defining different exception handlers

    +

    12.1.5 Defining different exception handlers

    @@ -437,7 +437,7 @@ declarations. However, it never really worked that well and the new %exception directive is much better.

    -

    12.1.6 Special variables for %exception

    +

    12.1.6 Special variables for %exception

    @@ -540,7 +540,7 @@ Below shows the expansions for the 1st of the overloaded something wrap -

    12.1.7 Using The SWIG exception library

    +

    12.1.7 Using The SWIG exception library

    @@ -595,7 +595,7 @@ SWIG_NullReferenceError The SWIG_exception() function can also be used in typemaps.

    -

    12.2 Object ownership and %newobject

    +

    12.2 Object ownership and %newobject

    @@ -752,7 +752,7 @@ char *strdup(const char *s); The results might not be what you expect.

    -

    12.3 Features and the %feature directive

    +

    12.3 Features and the %feature directive

    @@ -834,7 +834,7 @@ The following are all equivalent: The syntax in the first variation will generate the { } delimiters used whereas the other variations will not.

    -

    12.3.1 Feature attributes

    +

    12.3.1 Feature attributes

    @@ -875,7 +875,7 @@ In the following example, MyExceptionClass is the name of the Java clas Further details can be obtained from the Java exception handling section.

    -

    12.3.2 Feature flags

    +

    12.3.2 Feature flags

    @@ -973,7 +973,7 @@ in the swig.swg Library file. The following shows the alternative synta The concept of clearing features is discussed next.

    -

    12.3.3 Clearing features

    +

    12.3.3 Clearing features

    @@ -1066,7 +1066,7 @@ The three macros below show this for the "except" feature: -

    12.3.4 Features and default arguments

    +

    12.3.4 Features and default arguments

    @@ -1141,7 +1141,7 @@ specifying or not specifying default arguments in a feature is not applicable as in SWIG-1.3.23 when the approach to wrapping methods with default arguments was changed.

    -

    12.3.5 Feature example

    +

    12.3.5 Feature example

    diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index 984b81bb8..8007ccbb6 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -6,7 +6,7 @@ -

    22 SWIG and D

    +

    22 SWIG and D

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

      22.1 Introduction

      +

      22.1 Introduction

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

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

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

      -

      22.2 Command line invocation

      +

      22.2 Command line invocation

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

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

      22.3 Typemaps

      +

      22.3 Typemaps

      -

      22.3.1 C# <-> D name comparison

      +

      22.3.1 C# <-> D name comparison

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

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

    22.3.2 ctype, imtype, dtype

    +

    22.3.2 ctype, imtype, dtype

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

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

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

    -

    22.3.3 in, out, directorin, directorout

    +

    22.3.3 in, out, directorin, directorout

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

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

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

    -

    22.3.4 din, dout, ddirectorin, ddirectorout

    +

    22.3.4 din, dout, ddirectorin, ddirectorout

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

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

    22.3.5 typecheck typemaps

    +

    22.3.5 typecheck typemaps

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

    -

    22.3.6 Code injection typemaps

    +

    22.3.6 Code injection typemaps

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

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

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

    -

    22.3.7 Special variable macros

    +

    22.3.7 Special variable macros

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

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

    22.4 %features

    +

    22.4 %features

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

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

    22.5 Pragmas

    +

    22.5 Pragmas

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

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

    22.6 D Exceptions

    +

    22.6 D Exceptions

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

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

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

    -

    22.7 D Directors

    +

    22.7 D Directors

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

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

    -

    22.8 Other features

    +

    22.8 Other features

    -

    22.8.1 Extended namespace support (nspace)

    +

    22.8.1 Extended namespace support (nspace)

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

    -

    22.8.2 Native pointer support

    +

    22.8.2 Native pointer support

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

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

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

    -

    22.8.3 Operator overloading

    +

    22.8.3 Operator overloading

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

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

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

    -

    22.8.4 Running the test-suite

    +

    22.8.4 Running the test-suite

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

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

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

    -

    22.9 D Typemap examples

    +

    22.9 D Typemap examples

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

    -

    22.10 Work in progress and planned features

    +

    22.10 Work in progress and planned features

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

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 59c63403d..7519dca94 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -6,7 +6,7 @@ -

    41 Extending SWIG to support new languages

    +

    41 Extending SWIG to support new languages

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

      41.1 Introduction

      +

      41.1 Introduction

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

      -

      41.2 Prerequisites

      +

      41.2 Prerequisites

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

      -

      41.3 The Big Picture

      +

      41.3 The Big Picture

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

      -

      41.4 Execution Model

      +

      41.4 Execution Model

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

      -

      41.4.1 Preprocessing

      +

      41.4.1 Preprocessing

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

      -

      41.4.2 Parsing

      +

      41.4.2 Parsing

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

      -

      41.4.3 Parse Trees

      +

      41.4.3 Parse Trees

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

    -

    41.4.4 Attribute namespaces

    +

    41.4.4 Attribute namespaces

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

    -

    41.4.5 Symbol Tables

    +

    41.4.5 Symbol Tables

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

    41.4.6 The %feature directive

    +

    41.4.6 The %feature directive

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

    -

    41.4.7 Code Generation

    +

    41.4.7 Code Generation

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

    -

    41.4.8 SWIG and XML

    +

    41.4.8 SWIG and XML

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

    -

    41.5 Primitive Data Structures

    +

    41.5 Primitive Data Structures

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

    41.5.1 Strings

    +

    41.5.1 Strings

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

    41.5.2 Hashes

    +

    41.5.2 Hashes

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

    41.5.3 Lists

    +

    41.5.3 Lists

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

    41.5.4 Common operations

    +

    41.5.4 Common operations

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

    41.5.5 Iterating over Lists and Hashes

    +

    41.5.5 Iterating over Lists and Hashes

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

    41.5.6 I/O

    +

    41.5.6 I/O

    Special I/O functions are used for all internal I/O. These operations @@ -1528,7 +1528,7 @@ Printf(f, "%s\n", s); Similarly, the preprocessor and parser all operate on string-files.

    -

    41.6 Navigating and manipulating parse trees

    +

    41.6 Navigating and manipulating parse trees

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

    41.7 Working with attributes

    +

    41.7 Working with attributes

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

    41.8 Type system

    +

    41.8 Type system

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

    -

    41.8.1 String encoding of types

    +

    41.8.1 String encoding of types

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

    -

    41.8.2 Type construction

    +

    41.8.2 Type construction

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

    41.8.3 Type tests

    +

    41.8.3 Type tests

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

    41.8.4 Typedef and inheritance

    +

    41.8.4 Typedef and inheritance

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

    41.8.5 Lvalues

    +

    41.8.5 Lvalues

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

    41.8.6 Output functions

    +

    41.8.6 Output functions

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

    41.9 Parameters

    +

    41.9 Parameters

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

    41.10 Writing a Language Module

    +

    41.10 Writing a Language Module

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

    -

    41.10.1 Execution model

    +

    41.10.1 Execution model

    @@ -2470,7 +2470,7 @@ the parsing of command line options, all aspects of code generation are controll different methods of the Language that must be defined by your module.

    -

    41.10.2 Starting out

    +

    41.10.2 Starting out

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

    -

    41.10.3 Command line options

    +

    41.10.3 Command line options

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

    -

    41.10.4 Configuration and preprocessing

    +

    41.10.4 Configuration and preprocessing

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

    -

    41.10.5 Entry point to code generation

    +

    41.10.5 Entry point to code generation

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

    41.10.6 Module I/O and wrapper skeleton

    +

    41.10.6 Module I/O and wrapper skeleton

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

    41.10.7 Low-level code generators

    +

    41.10.7 Low-level code generators

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

    -

    41.10.8 Configuration files

    +

    41.10.8 Configuration files

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

    41.10.9 Runtime support

    +

    41.10.9 Runtime support

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

    -

    41.10.10 Standard library files

    +

    41.10.10 Standard library files

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

    -

    41.10.11 User examples

    +

    41.10.11 User examples

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

    -

    41.10.12 Test driven development and the test-suite

    +

    41.10.12 Test driven development and the test-suite

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

    -

    41.10.12.1 Running the test-suite

    +

    41.10.12.1 Running the test-suite

    @@ -3498,7 +3498,7 @@ It can be run in the same way as the other language test-suites, replacing [lang The test cases used and the way it works is described in Examples/test-suite/errors/Makefile.in.

    -

    41.10.13 Documentation

    +

    41.10.13 Documentation

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

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

    +

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

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

    -

    41.10.15 Coding style guidelines

    +

    41.10.15 Coding style guidelines

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

    -

    41.11 Debugging Options

    +

    41.11 Debugging Options

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

    -

    41.12 Guide to parse tree nodes

    +

    41.12 Guide to parse tree nodes

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

    41.13 Further Development Information

    +

    41.13 Further Development Information

    diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index f60e4d3f5..2fff4edf5 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -5,7 +5,7 @@ -

    23 SWIG and Go

    +

    23 SWIG and Go

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

      -

      23.1 Overview

      +

      23.1 Overview

      @@ -85,7 +85,7 @@ type-safe as well. In case of type issues the build will fail and hence SWIG's are not used.

      -

      23.2 Examples

      +

      23.2 Examples

      @@ -100,7 +100,7 @@ SWIG interface file extension for backwards compatibility with Go 1.

      -

      23.3 Running SWIG with Go

      +

      23.3 Running SWIG with Go

      @@ -180,7 +180,7 @@ sequence for this approach would look like this:

    -

    23.3.1 Go-specific Commandline Options

    +

    23.3.1 Go-specific Commandline Options

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

    23.3.2 Generated Wrapper Files

    +

    23.3.2 Generated Wrapper Files

    There are two different approaches to generating wrapper files, @@ -307,7 +307,7 @@ combined with the compiled MODULE.go using go tool pack. -

    23.4 A tour of basic C/C++ wrapping

    +

    23.4 A tour of basic C/C++ wrapping

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

    -

    23.4.1 Go Package Name

    +

    23.4.1 Go Package Name

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

    -

    23.4.2 Go Names

    +

    23.4.2 Go Names

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

    -

    23.4.3 Go Constants

    +

    23.4.3 Go Constants

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

    23.4.4 Go Enumerations

    +

    23.4.4 Go Enumerations

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

    -

    23.4.5 Go Classes

    +

    23.4.5 Go Classes

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

    -

    23.4.5.1 Go Class Memory Management

    +

    23.4.5.1 Go Class Memory Management

    @@ -577,7 +577,7 @@ func (o *GoClassName) Close() { -

    23.4.5.2 Go Class Inheritance

    +

    23.4.5.2 Go Class Inheritance

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

    -

    23.4.6 Go Templates

    +

    23.4.6 Go Templates

    @@ -598,7 +598,7 @@ wrappers for a particular template instantation. To do this, use the %template directive. -

    23.4.7 Go Director Classes

    +

    23.4.7 Go Director Classes

    @@ -616,7 +616,7 @@ completely to avoid common pitfalls with directors in Go.

    -

    23.4.7.1 Example C++ code

    +

    23.4.7.1 Example C++ code

    @@ -688,7 +688,7 @@ be found in the end of the guide.

    -

    23.4.7.2 Enable director feature

    +

    23.4.7.2 Enable director feature

    @@ -723,7 +723,7 @@ documentation on directors.

    -

    23.4.7.3 Constructor and destructor

    +

    23.4.7.3 Constructor and destructor

    @@ -776,7 +776,7 @@ embedding.

    -

    23.4.7.4 Override virtual methods

    +

    23.4.7.4 Override virtual methods

    @@ -842,7 +842,7 @@ the Go methods.

    -

    23.4.7.5 Call base methods

    +

    23.4.7.5 Call base methods

    @@ -879,7 +879,7 @@ be found in the end of the guide.

    -

    23.4.7.6 Subclass via embedding

    +

    23.4.7.6 Subclass via embedding

    @@ -947,7 +947,7 @@ class.

    -

    23.4.7.7 Memory management with runtime.SetFinalizer

    +

    23.4.7.7 Memory management with runtime.SetFinalizer

    @@ -1012,7 +1012,7 @@ before using runtime.SetFinalizer to know all of its gotchas.

    -

    23.4.7.8 Complete FooBarGo example class

    +

    23.4.7.8 Complete FooBarGo example class

    @@ -1141,7 +1141,7 @@ SWIG/Examples/go/director/.

    -

    23.4.8 Default Go primitive type mappings

    +

    23.4.8 Default Go primitive type mappings

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

    -

    23.4.9 Output arguments

    +

    23.4.9 Output arguments

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

    23.4.10 Adding additional go code

    +

    23.4.10 Adding additional go code

    Often the APIs generated by swig are not very natural in go, especially if @@ -1396,7 +1396,7 @@ func bar() { -

    23.4.11 Go typemaps

    +

    23.4.11 Go typemaps

    diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 4c1126c7f..b424df6e2 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -8,7 +8,7 @@ -

    24 SWIG and Guile

    +

    24 SWIG and Guile

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

      This section details guile-specific support in SWIG. -

      24.1 Supported Guile Versions

      +

      24.1 Supported Guile Versions

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

      24.2 Meaning of "Module"

      +

      24.2 Meaning of "Module"

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

      24.3 Old GH Guile API

      +

      24.3 Old GH Guile API

      Guile 1.8 and older could be interfaced using two different api's, the SCM @@ -80,7 +80,7 @@ or the GH API. The GH interface to guile is deprecated. Read more about why in 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. -

      24.4 Linkage

      +

      24.4 Linkage

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

      24.4.1 Simple Linkage

      +

      24.4.1 Simple Linkage

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

      24.4.2 Passive Linkage

      +

      24.4.2 Passive Linkage

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

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

      24.4.3 Native Guile Module Linkage

      +

      24.4.3 Native Guile Module Linkage

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

    -

    24.4.4 Old Auto-Loading Guile Module Linkage

    +

    24.4.4 Old Auto-Loading Guile Module Linkage

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

    24.4.5 Hobbit4D Linkage

    +

    24.4.5 Hobbit4D Linkage

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

    -

    24.5 Underscore Folding

    +

    24.5 Underscore Folding

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

    24.6 Typemaps

    +

    24.6 Typemaps

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

    -

    24.7 Representation of pointers as smobs

    +

    24.7 Representation of pointers as smobs

    @@ -420,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. -

    24.7.1 Smobs

    +

    24.7.1 Smobs

    @@ -439,7 +439,7 @@ structure describing this type. If a generated GOOPS module has been loaded, sm the corresponding GOOPS class.

    -

    24.7.2 Garbage Collection

    +

    24.7.2 Garbage Collection

    Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8, @@ -453,7 +453,7 @@ is exactly like described in 24.8 Exception Handling +

    24.8 Exception Handling

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

    24.9 Procedure documentation

    +

    24.9 Procedure documentation

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

    24.10 Procedures with setters

    +

    24.10 Procedures with setters

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

    24.11 GOOPS Proxy Classes

    +

    24.11 GOOPS Proxy Classes

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

    -

    24.11.1 Naming Issues

    +

    24.11.1 Naming Issues

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

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

    24.11.2 Linking

    +

    24.11.2 Linking

    The guile-modules generated above all need to be linked together. GOOPS support requires diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index dc68bff43..db35d8425 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -6,7 +6,7 @@ -

    2 Introduction

    +

    2 Introduction

      @@ -31,7 +31,7 @@ -

      2.1 What is SWIG?

      +

      2.1 What is SWIG?

      @@ -71,7 +71,7 @@ small; especially the research and development work that is commonly found in scientific and engineering projects. However, nowadays SWIG is known to be used in many large open source and commercial projects. -

      2.2 Why use SWIG?

      +

      2.2 Why use SWIG?

      @@ -143,7 +143,7 @@ it provides a wide variety of customization features that let you change almost every aspect of the language bindings. This is the main reason why SWIG has such a large user manual ;-). -

      2.3 A SWIG example

      +

      2.3 A SWIG example

      @@ -174,7 +174,7 @@ variable My_variable from Tcl. You start by making a SWIG interface file as shown below (by convention, these files carry a .i suffix) : -

      2.3.1 SWIG interface file

      +

      2.3.1 SWIG interface file

      @@ -199,7 +199,7 @@ module that will be created by SWIG.  The %{ %} block
       provides a location for inserting additional code, such as C header
       files or additional C declarations, into the generated C wrapper code.
       
      -

      2.3.2 The swig command

      +

      2.3.2 The swig command

      @@ -233,7 +233,7 @@ and variables declared in the SWIG interface. A look at the file example_wrap.c reveals a hideous mess. However, you almost never need to worry about it. -

      2.3.3 Building a Perl5 module

      +

      2.3.3 Building a Perl5 module

      @@ -259,7 +259,7 @@ unix >

      -

      2.3.4 Building a Python module

      +

      2.3.4 Building a Python module

      @@ -283,7 +283,7 @@ Type "copyright", "credits" or "license" for more information. 7.5

    -

    2.3.5 Shortcuts

    +

    2.3.5 Shortcuts

    @@ -309,7 +309,7 @@ print $example::My_variable + 4.5, "\n"; 7.5 -

    2.4 Supported C/C++ language features

    +

    2.4 Supported C/C++ language features

    @@ -348,7 +348,7 @@ wrapping simple C++ code. In fact, SWIG is able to handle C++ code that stresses the very limits of many C++ compilers. -

    2.5 Non-intrusive interface building

    +

    2.5 Non-intrusive interface building

    @@ -360,7 +360,7 @@ interface and reuse the code in other applications. It is also possible to support different types of interfaces depending on the application.

    -

    2.6 Incorporating SWIG into a build system

    +

    2.6 Incorporating SWIG into a build system

    @@ -418,7 +418,7 @@ which will invoke SWIG and compile the generated C++ files into _example.so (UNI For other target languages on Windows a dll, instead of a .pyd file, is usually generated.

    -

    2.7 Hands off code generation

    +

    2.7 Hands off code generation

    @@ -431,7 +431,7 @@ it allows others to forget about the low-level implementation details.

    -

    2.8 SWIG and freedom

    +

    2.8 SWIG and freedom

    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index b953eb518..9b18c4aa9 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -5,7 +5,7 @@ -

    25 SWIG and Java

    +

    25 SWIG and Java

      @@ -161,7 +161,7 @@ It covers most SWIG features, but certain low-level details are covered in less

      -

      25.1 Overview

      +

      25.1 Overview

      @@ -196,7 +196,7 @@ Various customisation tips and techniques using SWIG directives are covered. The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.

      -

      25.2 Preliminaries

      +

      25.2 Preliminaries

      @@ -216,7 +216,7 @@ This is the commonly used method to load JNI code so your system will more than Android uses Java JNI and also works with SWIG. Please read the Android chapter in conjunction with this one if you are targeting Android.

      -

      25.2.1 Running SWIG

      +

      25.2.1 Running SWIG

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

      -

      25.2.2 Additional Commandline Options

      +

      25.2.2 Additional Commandline Options

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

      -

      25.2.3 Getting the right header files

      +

      25.2.3 Getting the right header files

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

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

      -

      25.2.4 Compiling a dynamic module

      +

      25.2.4 Compiling a dynamic module

      @@ -362,7 +362,7 @@ The name of the shared library output file is important. If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information). The name of the module is specified using the %module directive or -module command line option.

      -

      25.2.5 Using your module

      +

      25.2.5 Using your module

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

      -

      25.2.6 Dynamic linking problems

      +

      25.2.6 Dynamic linking problems

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

      -

      25.2.7 Compilation problems and compiling with C++

      +

      25.2.7 Compilation problems and compiling with C++

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

      -

      25.2.8 Building on Windows

      +

      25.2.8 Building on Windows

      @@ -545,7 +545,7 @@ You will want to produce a DLL that can be loaded by the Java Virtual Machine. This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers. In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.

      -

      25.2.8.1 Running SWIG from Visual Studio

      +

      25.2.8.1 Running SWIG from Visual Studio

      @@ -584,7 +584,7 @@ To run the native code in the DLL (example.dll), make sure that it is in your pa If the library fails to load have a look at Dynamic linking problems.

      -

      25.2.8.2 Using NMAKE

      +

      25.2.8.2 Using NMAKE

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

      -

      25.3 A tour of basic C/C++ wrapping

      +

      25.3 A tour of basic C/C++ wrapping

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

      -

      25.3.1 Modules, packages and generated Java classes

      +

      25.3.1 Modules, packages and generated Java classes

      @@ -689,7 +689,7 @@ swig -java -package com.bloggs.swig -outdir com/bloggs/swig example.i SWIG won't create the directory, so make sure it exists beforehand.

      -

      25.3.2 Functions

      +

      25.3.2 Functions

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

    -

    25.3.3 Global variables

    +

    25.3.3 Global variables

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

    25.3.4 Constants

    +

    25.3.4 Constants

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

    -

    25.3.5 Enumerations

    +

    25.3.5 Enumerations

    @@ -964,7 +964,7 @@ The final two approaches use simple integers for each enum item. Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.

    -

    25.3.5.1 Anonymous enums

    +

    25.3.5.1 Anonymous enums

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

    -

    25.3.5.2 Typesafe enums

    +

    25.3.5.2 Typesafe enums

    @@ -1121,7 +1121,7 @@ When upgrading to JDK 1.5 or later, proper Java enums could be used instead, wit The following section details proper Java enum generation.

    -

    25.3.5.3 Proper Java enums

    +

    25.3.5.3 Proper Java enums

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

    -

    25.3.5.4 Type unsafe enums

    +

    25.3.5.4 Type unsafe enums

    @@ -1222,7 +1222,7 @@ Note that unlike typesafe enums, this approach requires users to mostly use diff Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.

    -

    25.3.5.5 Simple enums

    +

    25.3.5.5 Simple enums

    @@ -1241,7 +1241,7 @@ SWIG-1.3.21 and earlier versions wrapped all enums using this approach. The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.

    -

    25.3.6 Pointers

    +

    25.3.6 Pointers

    @@ -1329,7 +1329,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return a NULL pointer if the conversion can't be performed.

    -

    25.3.7 Structures

    +

    25.3.7 Structures

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

    25.3.8 C++ classes

    +

    25.3.8 C++ classes

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

    25.3.9 C++ inheritance

    +

    25.3.9 C++ inheritance

    @@ -1621,7 +1621,7 @@ Note that Java does not support multiple inheritance so any multiple inheritance A warning is given when multiple inheritance is detected and only the first base class is used.

    -

    25.3.10 Pointers, references, arrays and pass by value

    +

    25.3.10 Pointers, references, arrays and pass by value

    @@ -1676,7 +1676,7 @@ to hold the result and a pointer is returned (Java will release this memory when the returned object's finalizer is run by the garbage collector).

    -

    25.3.10.1 Null pointers

    +

    25.3.10.1 Null pointers

    @@ -1700,7 +1700,7 @@ For spam1 and spam4 above the Java null gets translat The converse also occurs, that is, NULL pointers are translated into null Java objects when returned from a C/C++ function.

    -

    25.3.11 C++ overloaded functions

    +

    25.3.11 C++ overloaded functions

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

    25.3.12 C++ default arguments

    +

    25.3.12 C++ default arguments

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

    -

    25.3.13 C++ namespaces

    +

    25.3.13 C++ namespaces

    @@ -1948,7 +1948,7 @@ If the resulting use of the nspace feature and hence packages results in a proxy you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps.

    -

    25.3.14 C++ templates

    +

    25.3.14 C++ templates

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

    -

    25.3.15 C++ Smart Pointers

    +

    25.3.15 C++ Smart Pointers

    -

    25.3.15.1 The shared_ptr Smart Pointer

    +

    25.3.15.1 The shared_ptr Smart Pointer

    @@ -2011,7 +2011,7 @@ in the shared_ptr smart pointer -

    25.3.15.2 Generic Smart Pointers

    +

    25.3.15.2 Generic Smart Pointers

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

    25.4 Further details on the generated Java classes

    +

    25.4 Further details on the generated Java classes

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

    -

    25.4.1 The intermediary JNI class

    +

    25.4.1 The intermediary JNI class

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

    -

    25.4.1.1 The intermediary JNI class pragmas

    +

    25.4.1.1 The intermediary JNI class pragmas

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

    -

    25.4.2 The Java module class

    +

    25.4.2 The Java module class

    @@ -2343,7 +2343,7 @@ example.egg(new Foo()); The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a Foo can be passed to the egg function, whereas any long can be passed to the egg function in the intermediary JNI class.

    -

    25.4.2.1 The Java module class pragmas

    +

    25.4.2.1 The Java module class pragmas

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

    -

    25.4.3 Java proxy classes

    +

    25.4.3 Java proxy classes

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

    25.4.3.1 Memory management

    +

    25.4.3.1 Memory management

    @@ -2632,7 +2632,7 @@ and

    -

    25.4.3.2 Inheritance

    +

    25.4.3.2 Inheritance

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

    25.4.3.3 Proxy classes and garbage collection

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

    -

    25.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    25.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

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

    -

    25.4.3.5 Single threaded applications and thread safety

    +

    25.4.3.5 Single threaded applications and thread safety

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

    25.4.4 Type wrapper classes

    +

    25.4.4 Type wrapper classes

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

    25.4.5 Enum classes

    +

    25.4.5 Enum classes

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

    -

    25.4.5.1 Typesafe enum classes

    +

    25.4.5.1 Typesafe enum classes

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

    -

    25.4.5.2 Proper Java enum classes

    +

    25.4.5.2 Proper Java enum classes

    @@ -3299,7 +3299,7 @@ These needn't be generated if the enum being wrapped does not have any initializ Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this.

    -

    25.4.5.3 Type unsafe enum classes

    +

    25.4.5.3 Type unsafe enum classes

    @@ -3330,7 +3330,7 @@ public final class Beverage { -

    25.5 Cross language polymorphism using directors

    +

    25.5 Cross language polymorphism using directors

    @@ -3352,7 +3352,7 @@ The upshot is that C++ classes can be extended in Java and from C++ these extens Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.

    -

    25.5.1 Enabling directors

    +

    25.5.1 Enabling directors

    @@ -3420,7 +3420,7 @@ public: -

    25.5.2 Director classes

    +

    25.5.2 Director classes

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

    -

    25.5.3 Overhead and code bloat

    +

    25.5.3 Overhead and code bloat

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

    -

    25.5.4 Simple directors example

    +

    25.5.4 Simple directors example

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

    25.5.5 Director threading issues

    +

    25.5.5 Director threading issues

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

    25.5.6 Director performance tuning

    +

    25.5.6 Director performance tuning

    @@ -3571,7 +3571,7 @@ However, if all director methods are expected to usually be overridden by Java s The disadvantage is that invocation of director methods from C++ when Java doesn't actually override the method will require an additional call up into Java and back to C++. As such, this option is only useful when overrides are extremely common and instantiation is frequent enough that its performance is critical.

    -

    25.5.7 Java exceptions from directors

    +

    25.5.7 Java exceptions from directors

    @@ -3879,7 +3879,7 @@ See the Exception handling with %exception an section for more on converting C++ exceptions to Java exceptions.

    -

    25.6 Accessing protected members

    +

    25.6 Accessing protected members

    @@ -3975,7 +3975,7 @@ class MyProtectedBase extends ProtectedBase -

    25.7 Common customization features

    +

    25.7 Common customization features

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

    -

    25.7.1 C/C++ helper functions

    +

    25.7.1 C/C++ helper functions

    @@ -4053,7 +4053,7 @@ hard to implement. It is possible to improve on this using Java code, typemaps, customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.

    -

    25.7.2 Class extension with %extend

    +

    25.7.2 Class extension with %extend

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

    -

    25.7.3 Exception handling with %exception and %javaexception

    +

    25.7.3 Exception handling with %exception and %javaexception

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

    -

    25.7.4 Method access with %javamethodmodifiers

    +

    25.7.4 Method access with %javamethodmodifiers

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

    25.8 Tips and techniques

    +

    25.8 Tips and techniques

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

    -

    25.8.1 Input and output parameters using primitive pointers and references

    +

    25.8.1 Input and output parameters using primitive pointers and references

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

    -

    25.8.2 Simple pointers

    +

    25.8.2 Simple pointers

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

    -

    25.8.3 Wrapping C arrays with Java arrays

    +

    25.8.3 Wrapping C arrays with Java arrays

    @@ -4618,7 +4618,7 @@ Please be aware that the typemaps in this library are not efficient as all the e There is an alternative approach using the SWIG array library and this is covered in the next section.

    -

    25.8.4 Unbounded C Arrays

    +

    25.8.4 Unbounded C Arrays

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

    -

    25.8.5 Binary data vs Strings

    +

    25.8.5 Binary data vs Strings

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

    25.8.6 Overriding new and delete to allocate from Java heap

    +

    25.8.6 Overriding new and delete to allocate from Java heap

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

    -

    25.9 Java typemaps

    +

    25.9 Java typemaps

    @@ -4945,7 +4945,7 @@ Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the generated code. -

    25.9.1 Default primitive type mappings

    +

    25.9.1 Default primitive type mappings

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

    -

    25.9.2 Default typemaps for non-primitive types

    +

    25.9.2 Default typemaps for non-primitive types

    @@ -5112,7 +5112,7 @@ So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit The Java type is either the proxy class or type wrapper class.

    -

    25.9.3 Sixty four bit JVMs

    +

    25.9.3 Sixty four bit JVMs

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

    -

    25.9.4 What is a typemap?

    +

    25.9.4 What is a typemap?

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

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

    +

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

    @@ -5517,7 +5517,7 @@ These are listed below: -

    25.9.6 Java typemap attributes

    +

    25.9.6 Java typemap attributes

    @@ -5563,7 +5563,7 @@ The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes. Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action.

    -

    25.9.7 Java special variables

    +

    25.9.7 Java special variables

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

    -

    25.9.8 Typemaps for both C and C++ compilation

    +

    25.9.8 Typemaps for both C and C++ compilation

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

    -

    25.9.9 Java code typemaps

    +

    25.9.9 Java code typemaps

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

    25.9.10 Director specific typemaps

    +

    25.9.10 Director specific typemaps

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

    25.10 Typemap Examples

    +

    25.10 Typemap Examples

    @@ -6263,7 +6263,7 @@ the SWIG library.

    -

    25.10.1 Simpler Java enums for enums without initializers

    +

    25.10.1 Simpler Java enums for enums without initializers

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

    -

    25.10.2 Handling C++ exception specifications as Java exceptions

    +

    25.10.2 Handling C++ exception specifications as Java exceptions

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

    -

    25.10.3 NaN Exception - exception handling for a particular type

    +

    25.10.3 NaN Exception - exception handling for a particular type

    @@ -6622,7 +6622,7 @@ If we were a martyr to the JNI cause, we could replace the succinct code within If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.

    -

    25.10.4 Converting Java String arrays to char **

    +

    25.10.4 Converting Java String arrays to char **

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

    -

    25.10.5 Expanding a Java object to multiple arguments

    +

    25.10.5 Expanding a Java object to multiple arguments

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

    25.10.6 Using typemaps to return arguments

    +

    25.10.6 Using typemaps to return arguments

    @@ -6966,7 +6966,7 @@ $ java runme 1 12.0 340.0 -

    25.10.7 Adding Java downcasts to polymorphic return types

    +

    25.10.7 Adding Java downcasts to polymorphic return types

    @@ -7172,7 +7172,7 @@ SWIG usually generates code which constructs the proxy classes using Java code a Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.

    -

    25.10.8 Adding an equals method to the Java classes

    +

    25.10.8 Adding an equals method to the Java classes

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

    25.10.9 Void pointers and a common Java base class

    +

    25.10.9 Void pointers and a common Java base class

    @@ -7275,7 +7275,7 @@ This example contains some useful functionality which you may want in your code.

  • It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer. -

    25.10.10 Struct pointer to pointer

    +

    25.10.10 Struct pointer to pointer

    @@ -7455,7 +7455,7 @@ The C functional interface has been completely morphed into an object-oriented i the Butler class would behave much like any pure Java class and feel more natural to Java users.

    -

    25.10.11 Memory management when returning references to member variables

    +

    25.10.11 Memory management when returning references to member variables

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

    -

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

    +

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

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

    25.10.13 Date marshalling using the javain typemap and associated attributes

    +

    25.10.13 Date marshalling using the javain typemap and associated attributes

    @@ -7871,7 +7871,7 @@ A few things to note: -

    25.11 Living with Java Directors

    +

    25.11 Living with Java Directors

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

  • -

    25.12 Odds and ends

    +

    25.12 Odds and ends

    -

    25.12.1 JavaDoc comments

    +

    25.12.1 JavaDoc comments

    @@ -8111,7 +8111,7 @@ public class Barmy { -

    25.12.2 Functional interface without proxy classes

    +

    25.12.2 Functional interface without proxy classes

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

    25.12.3 Using your own JNI functions

    +

    25.12.3 Using your own JNI functions

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

    -

    25.12.4 Performance concerns and hints

    +

    25.12.4 Performance concerns and hints

    @@ -8243,7 +8243,7 @@ However, you will have to be careful about memory management and make sure that This method normally calls the C++ destructor or free() for C code.

    -

    25.12.5 Debugging

    +

    25.12.5 Debugging

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

    -

    25.13 Java Examples

    +

    25.13 Java Examples

    diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 69e6665ea..a3b6cf0c5 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -6,7 +6,7 @@ -

    26 SWIG and Javascript

    +

    26 SWIG and Javascript

      @@ -51,7 +51,7 @@

      This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.

      -

      26.1 Overview

      +

      26.1 Overview

      Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development. @@ -62,10 +62,10 @@ Javascript has gone beyond being a browser-based scripting language and with node-webkit there is a platform which uses Google's Chromium as Web-Browser widget and node.js for javascript extensions.

      -

      26.2 Preliminaries

      +

      26.2 Preliminaries

      -

      26.2.1 Running SWIG

      +

      26.2.1 Running SWIG

      Suppose that you defined a SWIG module such as the following:

      @@ -109,7 +109,7 @@ void example_initialize(v8::Handle<v8::Object> exports) Note: be aware that v8 has a C++ API, and thus, the generated modules must be compiled as C++.

      -

      26.2.2 Running Tests and Examples

      +

      26.2.2 Running Tests and Examples

      The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.

      @@ -141,7 +141,7 @@ $ make check-javascript-test-suite ENGINE=jsc $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8
    -

    26.2.3 Known Issues

    +

    26.2.3 Known Issues

    At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.

    @@ -158,12 +158,12 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8

    The primary development environment has been Linux (Ubuntu 12.04). Windows and Mac OS X have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.

    -

    26.3 Integration

    +

    26.3 Integration

    This chapter gives a short introduction how to use a native Javascript extension: as a node.js module, and as an extension for an embedded Webkit.

    -

    26.3.1 Creating node.js Extensions

    +

    26.3.1 Creating node.js Extensions

    To install node.js you can download an installer from their web-site for Mac OS X and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

    @@ -209,7 +209,7 @@ require("./build/Release/example")

    A more detailed explanation is given in the Examples section.

    -

    26.3.1.1 Troubleshooting

    +

    26.3.1.1 Troubleshooting

      @@ -221,12 +221,12 @@ require("./build/Release/example") $ sudo apt-get remove gyp -

      26.3.2 Embedded Webkit

      +

      26.3.2 Embedded Webkit

      Webkit is pre-installed on Mac OS X and available as a library for GTK.

      -

      26.3.2.1 Mac OS X

      +

      26.3.2.1 Mac OS X

      There is general information about programming with WebKit on Apple Developer Documentation. Details about Cocoa programming are not covered here.

      @@ -274,7 +274,7 @@ extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports) @end -

      26.3.2.2 GTK

      +

      26.3.2.2 GTK

      There is general information about programming GTK at GTK documentation and in the GTK tutorial, and for Webkit there is a Webkit GTK+ API Reference.

      @@ -319,7 +319,7 @@ int main(int argc, char* argv[]) } -

      26.3.3 Creating Applications with node-webkit

      +

      26.3.3 Creating Applications with node-webkit

      To get started with node-webkit there is a very informative set of wiki pages.

      @@ -410,12 +410,12 @@ open new windows, and many more things. }; -

      26.4 Examples

      +

      26.4 Examples

      Some basic examples are shown here in more detail.

      -

      26.4.1 Simple

      +

      26.4.1 Simple

      The common example simple looks like this:

      @@ -465,7 +465,7 @@ example.Foo = 3.1415926;

      Note: ECMAScript 5, the currently implemented Javascript standard, does not have modules. node.js and other implementations provide this mechanism defined by the CommonJS group. For browsers this is provided by Browserify, for instance.

      -

      26.4.2 Class

      +

      26.4.2 Class

      The common example class defines three classes, Shape, Circle, and Square:

      @@ -595,12 +595,12 @@ at emitKey (readline.js:1095:12) Note: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property prototype of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in Inheritance and the prototype chain, for instance.

      -

      26.5 Implementation

      +

      26.5 Implementation

      The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.

      -

      26.5.1 Source Code

      +

      26.5.1 Source Code

      The Javascript module is implemented in Source/Modules/javascript.cxx. It dispatches the code generation to a JSEmitter instance, V8Emitter or JSCEmitter. Additionally there are some helpers: Template, for templated code generation, and JSEmitterState, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:

      @@ -701,7 +701,7 @@ Template::Template(const String *code_) { ... } ... -

      26.5.2 Code Templates

      +

      26.5.2 Code Templates

      All generated code is created on the basis of code templates. The templates for JavascriptCore can be found in Lib/javascript/jsc/javascriptcode.swg, for v8 in Lib/javascript/v8/javascriptcode.swg.

      @@ -740,7 +740,7 @@ t_register.replace("$jsparent", state.clazz(NAME_MANGLED))

      Template creates a copy of that string and Template::replace uses Swig's Replaceall to replace variables in the template. Template::trim can be used to eliminate leading and trailing whitespaces. Template::print is used to write the final template string to a Swig DOH (based on Printv). All methods allow chaining.

      -

      26.5.3 Emitter

      +

      26.5.3 Emitter

      The Javascript module delegates code generation to a JSEmitter instance. The following extract shows the essential interface:

      @@ -859,7 +859,7 @@ int JAVASCRIPT::classHandler(Node *n) {

      In enterClass the emitter stores state information that is necessary when processing class members. In exitClass the wrapper code for the whole class is generated.

      -

      26.5.4 Emitter states

      +

      26.5.4 Emitter states

      For storing information during the AST traversal the emitter provides a JSEmitterState with different slots to store data representing the scopes global, class, function, and variable.

      @@ -903,7 +903,7 @@ state.clazz(NAME, Getattr(n, "sym:name"));

      State information can be retrieved using state.clazz(NAME) or with Getattr on state.clazz() which actually returns a Hash instance.

      -

      26.5.5 Handling Exceptions in JavascriptCore

      +

      26.5.5 Handling Exceptions in JavascriptCore

      Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.

      diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index fb12e3ce8..203ea6d46 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -6,7 +6,7 @@ -

      9 SWIG library

      +

      9 SWIG library

        @@ -59,7 +59,7 @@ Alternative libraries provide similar functionality. Please read this chapter carefully if you used the old libraries.

        -

        9.1 The %include directive and library search path

        +

        9.1 The %include directive and library search path

        @@ -91,7 +91,7 @@ Set the environment variable to hold an alternative library directory. The directories that are searched are displayed when using -verbose commandline option.

        -

        9.2 C Arrays and Pointers

        +

        9.2 C Arrays and Pointers

        @@ -103,7 +103,7 @@ pointers as class-like objects. Since these functions provide direct access to memory, their use is potentially unsafe and you should exercise caution.

        -

        9.2.1 cpointer.i

        +

        9.2.1 cpointer.i

        @@ -319,7 +319,7 @@ In this example, the function int_to_uint() would be used to cast type Note: When working with simple pointers, typemaps can often be used to provide more seamless operation.

        -

        9.2.2 carrays.i

        +

        9.2.2 carrays.i

        @@ -497,7 +497,7 @@ you should consider using a special array object rather than a bare pointer. used with types of char or char *.

        -

        9.2.3 cmalloc.i

        +

        9.2.3 cmalloc.i

        @@ -658,7 +658,7 @@ Now, in a script:

      -

      9.2.4 cdata.i

      +

      9.2.4 cdata.i

      @@ -760,7 +760,7 @@ char *cdata_name(type* ptr, int nitems) Clearly they are unsafe.

      -

      9.3 C String Handling

      +

      9.3 C String Handling

      @@ -780,7 +780,7 @@ morality. The modules in this section provide basic functionality for manipulating raw C strings.

      -

      9.3.1 Default string handling

      +

      9.3.1 Default string handling

      @@ -821,7 +821,7 @@ interpreter and lead to a crash). Furthermore, the default behavior does not work well with binary data. Instead, strings are assumed to be NULL-terminated.

      -

      9.3.2 Passing binary data

      +

      9.3.2 Passing binary data

      @@ -863,7 +863,7 @@ In the wrapper function, the passed string will be expanded to a pointer and len The (char *STRING, int LENGTH) multi-argument typemap is also available in addition to (char *STRING, size_t LENGTH).

      -

      9.3.3 Using %newobject to release memory

      +

      9.3.3 Using %newobject to release memory

      @@ -904,7 +904,7 @@ however, you may need to provide your own "newfree" typemap for other types. See Object ownership and %newobject for more details.

      -

      9.3.4 cstring.i

      +

      9.3.4 cstring.i

      @@ -1364,7 +1364,7 @@ structure or class instead.

    -

    9.4 STL/C++ Library

    +

    9.4 STL/C++ Library

    @@ -1403,7 +1403,7 @@ Please look for the library files in the appropriate language library directory.

    -

    9.4.1 std::string

    +

    9.4.1 std::string

    @@ -1487,7 +1487,7 @@ void foo(string s, const String &t); // std_string typemaps still applie -

    9.4.2 std::vector

    +

    9.4.2 std::vector

    @@ -1666,7 +1666,7 @@ if you want to make their head explode. details and the public API exposed to the interpreter vary.

    -

    9.4.3 STL exceptions

    +

    9.4.3 STL exceptions

    @@ -1716,7 +1716,7 @@ The %exception directive can be used by placing the following code befo Any thrown STL exceptions will then be gracefully handled instead of causing a crash.

    -

    9.4.4 shared_ptr smart pointer

    +

    9.4.4 shared_ptr smart pointer

    @@ -1907,7 +1907,7 @@ Please help to improve this support by providing patches with improvements.

    -

    9.4.5 auto_ptr smart pointer

    +

    9.4.5 auto_ptr smart pointer

    @@ -1956,10 +1956,10 @@ int value = k.getValue(); -

    9.5 Utility Libraries

    +

    9.5 Utility Libraries

    -

    9.5.1 exception.i

    +

    9.5.1 exception.i

    diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index d2bf316a4..ccb424e50 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -6,7 +6,7 @@ -

    27 SWIG and Common Lisp

    +

    27 SWIG and Common Lisp

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

      -

      27.1 Allegro Common Lisp

      +

      27.1 Allegro Common Lisp

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

      -

      27.2 Common Foreign Function Interface(CFFI)

      +

      27.2 Common Foreign Function Interface(CFFI)

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

      -

      27.2.1 Additional Commandline Options

      +

      27.2.1 Additional Commandline Options

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

      27.2.2 Generating CFFI bindings

      +

      27.2.2 Generating CFFI bindings

      As we mentioned earlier the ideal way to use SWIG is to use interface @@ -395,7 +395,7 @@ The feature intern_function ensures that all C names are
    -

    27.2.3 Generating CFFI bindings for C++ code

    +

    27.2.3 Generating CFFI bindings for C++ code

    This feature to SWIG (for CFFI) is very new and still far from @@ -571,7 +571,7 @@ If you have any questions, suggestions, patches, etc., related to CFFI module feel free to contact us on the SWIG mailing list, and also please add a "[CFFI]" tag in the subject line. -

    27.2.4 Inserting user code into generated files

    +

    27.2.4 Inserting user code into generated files

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

    -

    27.3 CLISP

    +

    27.3 CLISP

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

    -

    27.3.1 Additional Commandline Options

    +

    27.3.1 Additional Commandline Options

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

    27.3.2 Details on CLISP bindings

    +

    27.3.2 Details on CLISP bindings

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

    27.4 UFFI

    +

    27.4 UFFI

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 2e1515c43..1b6b87e51 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -6,7 +6,7 @@ -

    28 SWIG and Lua

    +

    28 SWIG and Lua

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

      -

      28.1 Preliminaries

      +

      28.1 Preliminaries

      The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.

      -

      28.2 Running SWIG

      +

      28.2 Running SWIG

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

      -

      28.2.1 Additional command line options

      +

      28.2.1 Additional command line options

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

      28.2.2 Compiling and Linking and Interpreter

      +

      28.2.2 Compiling and Linking and Interpreter

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

      -

      28.2.3 Compiling a dynamic module

      +

      28.2.3 Compiling a dynamic module

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

      28.2.4 Using your module

      +

      28.2.4 Using your module

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

    -

    28.3 A tour of basic C/C++ wrapping

    +

    28.3 A tour of basic C/C++ wrapping

    By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.

    -

    28.3.1 Modules

    +

    28.3.1 Modules

    The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.

    -

    28.3.2 Functions

    +

    28.3.2 Functions

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

    28.3.3 Global variables

    +

    28.3.3 Global variables

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

    -

    28.3.4 Constants and enums

    +

    28.3.4 Constants and enums

    @@ -511,7 +511,7 @@ If you're using eLua and have used -elua or -eluac to generate Hello World -

    28.3.4.1 Constants/enums and classes/structures

    +

    28.3.4.1 Constants/enums and classes/structures

    @@ -567,7 +567,7 @@ If the -no-old-metatable-bindings option is used, then these old-style It is worth mentioning, that example.Test.TEST1 and example.Test_TEST1 are different entities and changing one does not change the other. Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.

    -

    28.3.5 Pointers

    +

    28.3.5 Pointers

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

    28.3.6 Structures

    +

    28.3.6 Structures

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

    -

    28.3.7 C++ classes

    +

    28.3.7 C++ classes

    @@ -784,7 +784,7 @@ Both style names are generated by default now. However, if the -no-old-metatable-bindings option is used, then the backward compatible names are not generated in addition to ordinary ones.

    -

    28.3.8 C++ inheritance

    +

    28.3.8 C++ inheritance

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

    It is safe to use multiple inheritance with SWIG.

    -

    28.3.9 Pointers, references, values, and arrays

    +

    28.3.9 Pointers, references, values, and arrays

    @@ -840,7 +840,7 @@ Foo spam7();

    then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.

    -

    28.3.10 C++ overloaded functions

    +

    28.3.10 C++ overloaded functions

    @@ -926,7 +926,7 @@ Please refer to the "SWIG and C++" chapter for more information about overloadin

    Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.

    -

    28.3.11 C++ operators

    +

    28.3.11 C++ operators

    @@ -1060,7 +1060,7 @@ operators and pseudo-operators):

    No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. __tostring is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.

    -

    28.3.12 Class extension with %extend

    +

    28.3.12 Class extension with %extend

    @@ -1116,7 +1116,7 @@ true Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).

    -

    28.3.13 Using %newobject to release memory

    +

    28.3.13 Using %newobject to release memory

    If you have a function that allocates memory like this,

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

    This will release the allocated memory.

    -

    28.3.14 C++ templates

    +

    28.3.14 C++ templates

    @@ -1175,7 +1175,7 @@ In Lua:

    Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.

    -

    28.3.15 C++ Smart Pointers

    +

    28.3.15 C++ Smart Pointers

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

    28.3.16 C++ Exceptions

    +

    28.3.16 C++ Exceptions

    @@ -1370,7 +1370,7 @@ and the "Exception handling add exception specification to functions or globally (respectively).

    -

    28.3.17 Namespaces

    +

    28.3.17 Namespaces

    @@ -1421,7 +1421,7 @@ Now, from Lua usage is as follows: 19 > -

    28.3.17.1 Compatibility Note

    +

    28.3.17.1 Compatibility Note

    @@ -1437,7 +1437,7 @@ If SWIG is running in a backwards compatible way, i.e. without the -no-old-m -

    28.3.17.2 Names

    +

    28.3.17.2 Names

    If SWIG is launched without -no-old-metatable-bindings option, then it enters backward-compatible mode. While in this mode, it tries @@ -1481,7 +1481,7 @@ surrounding scope without any prefixing. Pretending that Test2 is a struct, not > -

    28.3.17.3 Inheritance

    +

    28.3.17.3 Inheritance

    The internal organization of inheritance has changed. @@ -1522,12 +1522,12 @@ function > -

    28.4 Typemaps

    +

    28.4 Typemaps

    This section explains what typemaps are and how to use them. The default wrapping behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrapping. This section will be explaining how to use typemaps to best effect

    -

    28.4.1 What is a typemap?

    +

    28.4.1 What is a typemap?

    A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:

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

    28.4.2 Using typemaps

    +

    28.4.2 Using typemaps

    There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.

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

    Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a const int& as an input parameter (since that it obviously input).

    -

    28.4.3 Typemaps and arrays

    +

    28.4.3 Typemaps and arrays

    Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor @@ -1672,7 +1672,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In

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

    -

    28.4.4 Typemaps and pointer-pointer functions

    +

    28.4.4 Typemaps and pointer-pointer functions

    Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:

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

    28.5 Writing typemaps

    +

    28.5 Writing typemaps

    This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "Typemaps" chapter.

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

    Before proceeding, you should read the previous section on using typemaps, and look at the existing typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you an idea to base your work on).

    -

    28.5.1 Typemaps you can write

    +

    28.5.1 Typemaps you can write

    There are many different types of typemap that can be written, the full list can be found in the "Typemaps" chapter. However the following are the most commonly used ones.

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

    28.5.2 SWIG's Lua-C API

    +

    28.5.2 SWIG's Lua-C API

    This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.

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

    28.6 Customization of your Bindings

    +

    28.6 Customization of your Bindings

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

    28.6.1 Writing your own custom wrappers

    +

    28.6.1 Writing your own custom wrappers

    @@ -1805,7 +1805,7 @@ int native_function(lua_State*L) // my native code The %native directive in the above example, tells SWIG that there is a function int native_function(lua_State*L); which is to be added into the module under the name 'my_func'. SWIG will not add any wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.

    -

    28.6.2 Adding additional Lua code

    +

    28.6.2 Adding additional Lua code

    @@ -1843,7 +1843,7 @@ Good uses for this feature is adding of new code, or writing helper functions to See Examples/lua/arrays for an example of this code.

    -

    28.7 Details on the Lua binding

    +

    28.7 Details on the Lua binding

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

    -

    28.7.1 Binding global data into the module.

    +

    28.7.1 Binding global data into the module.

    @@ -1914,7 +1914,7 @@ end

    That way when you call 'a=example.Foo', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code 'example.Foo=10', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.

    -

    28.7.2 Userdata and Metatables

    +

    28.7.2 Userdata and Metatables

    @@ -1994,7 +1994,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrapped classes/str

    Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.

    -

    28.7.3 Memory management

    +

    28.7.3 Memory management

    diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index ffbf6132d..ed6e596e7 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -5,7 +5,7 @@ -

    29 SWIG and Modula-3

    +

    29 SWIG and Modula-3

    -

    29.4.5 Exceptions

    +

    29.4.5 Exceptions

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

    -

    29.4.6 Example

    +

    29.4.6 Example

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

    29.5 More hints to the generator

    +

    29.5 More hints to the generator

    -

    29.5.1 Features

    +

    29.5.1 Features

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

    29.5.2 Pragmas

    +

    29.5.2 Pragmas

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

    29.6 Remarks

    +

    29.6 Remarks

      diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 4846aedc1..d12383a1d 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -6,7 +6,7 @@ -

      16 Working with Modules

      +

      16 Working with Modules

        @@ -23,7 +23,7 @@ -

        16.1 Modules Introduction

        +

        16.1 Modules Introduction

        @@ -77,7 +77,7 @@ where you want to create a collection of modules. Each module in the collection is created via separate invocations of SWIG.

        -

        16.2 Basics

        +

        16.2 Basics

        @@ -176,7 +176,7 @@ in parallel from multiple threads as SWIG provides no locking - for more on that issue, read on.

        -

        16.3 The SWIG runtime code

        +

        16.3 The SWIG runtime code

        @@ -242,7 +242,7 @@ can peacefully coexist. So the type structures are separated by the is empty. Only modules compiled with the same pair will share type information.

        -

        16.4 External access to the runtime

        +

        16.4 External access to the runtime

        As described in The run-time type checker, @@ -281,7 +281,7 @@ SWIG_TYPE_TABLE to be the same as the module whose types you are trying to access.

        -

        16.5 A word of caution about static libraries

        +

        16.5 A word of caution about static libraries

        @@ -292,7 +292,7 @@ into it. This is very often NOT what you want and it can lead to unexpect behavior. When working with dynamically loadable modules, you should try to work exclusively with shared libraries.

        -

        16.6 References

        +

        16.6 References

        @@ -300,7 +300,7 @@ Due to the complexity of working with shared libraries and multiple modules, it an outside reference. John Levine's "Linkers and Loaders" is highly recommended.

        -

        16.7 Reducing the wrapper file size

        +

        16.7 Reducing the wrapper file size

        diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html index fadda5fc9..358942a35 100644 --- a/Doc/Manual/Mzscheme.html +++ b/Doc/Manual/Mzscheme.html @@ -8,7 +8,7 @@ -

        30 SWIG and MzScheme/Racket

        +

        30 SWIG and MzScheme/Racket

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

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

          30.1 Creating native structures

          +

          30.1 Creating native structures

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

        -

        30.2 Simple example

        +

        30.2 Simple example

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

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

      30.3 External documentation

      +

      30.3 External documentation

      diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index b927a7d8f..789bbae53 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -6,7 +6,7 @@ -

      31 SWIG and Ocaml

      +

      31 SWIG and Ocaml

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

        -

        31.1 Preliminaries

        +

        31.1 Preliminaries

        @@ -101,7 +101,7 @@ file Examples/Makefile illustrate how to compile and link SWIG modules that will be loaded dynamically. This has only been tested on Linux so far.

        -

        31.1.1 Running SWIG

        +

        31.1.1 Running SWIG

        @@ -124,7 +124,7 @@ you will compile the file example_wrap.c with ocamlc or the resulting .ml and .mli files as well, and do the final link with -custom (not needed for native link).

        -

        31.1.2 Compiling the code

        +

        31.1.2 Compiling the code

        @@ -161,7 +161,7 @@ in C++ mode, you must:

      -

      31.1.3 The camlp4 module

      +

      31.1.3 The camlp4 module

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

      31.1.4 Using your module

      +

      31.1.4 Using your module

      @@ -251,7 +251,7 @@ option to build your functions into the primitive list. This option is not needed when you build native code.

      -

      31.1.5 Compilation problems and compiling with C++

      +

      31.1.5 Compilation problems and compiling with C++

      @@ -262,7 +262,7 @@ liberal with pointer types may not compile under the C++ compiler. Most code meant to be compiled as C++ will not have problems.

      -

      31.2 The low-level Ocaml/C interface

      +

      31.2 The low-level Ocaml/C interface

      @@ -362,7 +362,7 @@ value items pass through directly, but you must make your own type signature for a function that uses value in this way.

      -

      31.2.1 The generated module

      +

      31.2.1 The generated module

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

      31.2.2 Enums

      +

      31.2.2 Enums

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

      -

      31.2.2.1 Enum typing in Ocaml

      +

      31.2.2.1 Enum typing in Ocaml

      @@ -472,10 +472,10 @@ functions imported from different modules. You must convert values to master values using the swig_val function before sharing them with another module.

      -

      31.2.3 Arrays

      +

      31.2.3 Arrays

      -

      31.2.3.1 Simple types of bounded arrays

      +

      31.2.3.1 Simple types of bounded arrays

      @@ -496,7 +496,7 @@ arrays of simple types with known bounds in your code, but this only works for arrays whose bounds are completely specified.

      -

      31.2.3.2 Complex and unbounded arrays

      +

      31.2.3.2 Complex and unbounded arrays

      @@ -509,7 +509,7 @@ SWIG can't predict which of these methods will be used in the array, so you have to specify it for yourself in the form of a typemap.

      -

      31.2.3.3 Using an object

      +

      31.2.3.3 Using an object

      @@ -523,7 +523,7 @@ Consider writing an object when the ending condition of your array is complex, such as using a required sentinel, etc.

      -

      31.2.3.4 Example typemap for a function taking float * and int

      +

      31.2.3.4 Example typemap for a function taking float * and int

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

      31.2.4 C++ Classes

      +

      31.2.4 C++ Classes

      @@ -617,7 +617,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the returned value for the same object.

      -

      31.2.4.1 STL vector and string Example

      +

      31.2.4.1 STL vector and string Example

      @@ -697,7 +697,7 @@ baz # -

      31.2.4.2 C++ Class Example

      +

      31.2.4.2 C++ Class Example

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

      31.2.4.3 Compiling the example

      +

      31.2.4.3 Compiling the example

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

      31.2.4.4 Sample Session

      +

      31.2.4.4 Sample Session

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

      -

      31.2.5 Director Classes

      +

      31.2.5 Director Classes

      -

      31.2.5.1 Director Introduction

      +

      31.2.5.1 Director Introduction

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

      -

      31.2.5.2 Overriding Methods in Ocaml

      +

      31.2.5.2 Overriding Methods in Ocaml

      @@ -830,7 +830,7 @@ In this example, I'll examine the objective caml code involved in providing an overloaded class. This example is contained in Examples/ocaml/shapes.

      -

      31.2.5.3 Director Usage Example

      +

      31.2.5.3 Director Usage Example

      @@ -889,7 +889,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the program in C++.

      -

      31.2.5.4 Creating director objects

      +

      31.2.5.4 Creating director objects

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

      -

      31.2.5.5 Typemaps for directors, directorin, directorout, directorargout

      +

      31.2.5.5 Typemaps for directors, directorin, directorout, directorargout

      @@ -941,7 +941,7 @@ well as a function return value in the same way you provide function arguments, and to receive arguments the same way you normally receive function returns.

      -

      31.2.5.6 directorin typemap

      +

      31.2.5.6 directorin typemap

      @@ -952,7 +952,7 @@ code receives when you are called. In general, a simple directorin typ can use the same body as a simple out typemap.

      -

      31.2.5.7 directorout typemap

      +

      31.2.5.7 directorout typemap

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

      -

      31.2.5.8 directorargout typemap

      +

      31.2.5.8 directorargout typemap

      @@ -980,7 +980,7 @@ In the event that you don't specify all of the necessary values, integral values will read zero, and struct or object returns have undefined results.

      -

      31.2.6 Exceptions

      +

      31.2.6 Exceptions

      diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index 53ee86f7c..df484103d 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -8,7 +8,7 @@ -

      32 SWIG and Octave

      +

      32 SWIG and Octave

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

        -

        32.1 Preliminaries

        +

        32.1 Preliminaries

        @@ -67,7 +67,7 @@ As of SWIG 3.0.7, the Octave module is regularly tested with Octave versions 3.2 Use of older Octave versions is not recommended, as these versions are no longer tested with SWIG.

        -

        32.2 Running SWIG

        +

        32.2 Running SWIG

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

        -

        32.2.1 Command-line options

        +

        32.2.1 Command-line options

        @@ -122,7 +122,7 @@ The special name "." loads C global variables into the module namespace, i.e. al The -opprefix options sets the prefix of the names of global/friend operator functions.

        -

        32.2.2 Compiling a dynamic module

        +

        32.2.2 Compiling a dynamic module

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

        octave:1> swigexample
        -

        32.2.3 Using your module

        +

        32.2.3 Using your module

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

      -

      32.3 A tour of basic C/C++ wrapping

      +

      32.3 A tour of basic C/C++ wrapping

      -

      32.3.1 Modules

      +

      32.3.1 Modules

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

      32.3.2 Functions

      +

      32.3.2 Functions

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

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

      32.3.3 Global variables

      +

      32.3.3 Global variables

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

      32.3.4 Constants and enums

      +

      32.3.4 Constants and enums

      @@ -307,7 +307,7 @@ swigexample.SCONST="Hello World" swigexample.SUNDAY=0 .... -

      32.3.5 Pointers

      +

      32.3.5 Pointers

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

      32.3.6 Structures and C++ classes

      +

      32.3.6 Structures and C++ classes

      @@ -489,7 +489,7 @@ ans = 1 Depending on the ownership setting of a swig_ref, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.

      -

      32.3.7 C++ inheritance

      +

      32.3.7 C++ inheritance

      @@ -498,7 +498,7 @@ This information contains the full class hierarchy. When an indexing operation ( the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the swig_ref.

      -

      32.3.8 C++ overloaded functions

      +

      32.3.8 C++ overloaded functions

      @@ -508,7 +508,7 @@ The dispatch function selects which overload to call (if any) based on the passe typecheck typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.

      -

      32.3.9 C++ operators

      +

      32.3.9 C++ operators

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

      -

      32.3.10 Class extension with %extend

      +

      32.3.10 Class extension with %extend

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

      32.3.11 C++ templates

      +

      32.3.11 C++ templates

      @@ -719,10 +719,10 @@ ans = -

      32.3.12 C++ Smart Pointers

      +

      32.3.12 C++ Smart Pointers

      -

      32.3.12.1 The shared_ptr Smart Pointer

      +

      32.3.12.1 The shared_ptr Smart Pointer

      @@ -733,14 +733,14 @@ in the shared_ptr smart pointer -

      32.3.12.2 Generic Smart Pointers

      +

      32.3.12.2 Generic Smart Pointers

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

      -

      32.3.13 Directors (calling Octave from C++ code)

      +

      32.3.13 Directors (calling Octave from C++ code)

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

      32.3.14 Threads

      +

      32.3.14 Threads

      The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.

      -

      32.3.15 Memory management

      +

      32.3.15 Memory management

      @@ -862,14 +862,14 @@ The %newobject directive may be used to control this behavior for pointers retur In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/subclass()'ing).

      -

      32.3.16 STL support

      +

      32.3.16 STL support

      Various STL library files are provided for wrapping STL containers.

      -

      32.3.17 Matrix typemaps

      +

      32.3.17 Matrix typemaps

      diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 8bc7cbfd3..bb912ec8e 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -6,7 +6,7 @@ -

      33 SWIG and Perl5

      +

      33 SWIG and Perl5

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

        -

        33.1 Overview

        +

        33.1 Overview

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

        -

        33.2 Preliminaries

        +

        33.2 Preliminaries

        @@ -142,7 +142,7 @@ To build the module, you will need to compile the file example_wrap.c and link it with the rest of your program.

        -

        33.2.1 Getting the right header files

        +

        33.2.1 Getting the right header files

        @@ -174,7 +174,7 @@ $ perl -e 'use Config; print "$Config{archlib}\n";'

      -

      33.2.2 Compiling a dynamic module

      +

      33.2.2 Compiling a dynamic module

      @@ -207,7 +207,7 @@ the target should be named `example.so', `example.sl', or the appropriate dynamic module name on your system.

      -

      33.2.3 Building a dynamic module with MakeMaker

      +

      33.2.3 Building a dynamic module with MakeMaker

      @@ -241,7 +241,7 @@ the preferred approach to compilation. More information about MakeMaker can be found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen, and Randal Schwartz.

      -

      33.2.4 Building a static version of Perl

      +

      33.2.4 Building a static version of Perl

      @@ -310,7 +310,7 @@ added to it. Depending on your machine, you may need to link with additional libraries such as -lsocket, -lnsl, -ldl, etc.

      -

      33.2.5 Using the module

      +

      33.2.5 Using the module

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

      -

      33.2.6 Compilation problems and compiling with C++

      +

      33.2.6 Compilation problems and compiling with C++

      @@ -606,7 +606,7 @@ have to find the macro that conflicts and add an #undef into the .i file. Pleas any conflicting macros you find to swig-user mailing list.

      -

      33.2.7 Compiling for 64-bit platforms

      +

      33.2.7 Compiling for 64-bit platforms

      @@ -633,7 +633,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

      -

      33.3 Building Perl Extensions under Windows

      +

      33.3 Building Perl Extensions under Windows

      @@ -644,7 +644,7 @@ section assumes you are using SWIG with Microsoft Visual C++ although the procedure may be similar with other compilers.

      -

      33.3.1 Running SWIG from Developer Studio

      +

      33.3.1 Running SWIG from Developer Studio

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

      33.3.2 Using other compilers

      +

      33.3.2 Using other compilers

      @@ -715,7 +715,7 @@ SWIG is known to work with Cygwin and may work with other compilers on Windows. For general hints and suggestions refer to the Windows chapter.

      -

      33.4 The low-level interface

      +

      33.4 The low-level interface

      @@ -725,7 +725,7 @@ can be used to control your application. However, it is also used to construct more user-friendly proxy classes as described in the next section.

      -

      33.4.1 Functions

      +

      33.4.1 Functions

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

      33.4.2 Global variables

      +

      33.4.2 Global variables

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

      33.4.3 Constants

      +

      33.4.3 Constants

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

      33.4.4 Pointers

      +

      33.4.4 Pointers

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

      -

      33.4.5 Structures

      +

      33.4.5 Structures

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

      33.4.6 C++ classes

      +

      33.4.6 C++ classes

      @@ -1166,7 +1166,7 @@ provides direct access to C++ objects. A higher level interface using Perl prox can be built using these low-level accessors. This is described shortly.

      -

      33.4.7 C++ classes and type-checking

      +

      33.4.7 C++ classes and type-checking

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

      -

      33.4.8 C++ overloaded functions

      +

      33.4.8 C++ overloaded functions

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

      -

      33.4.9 Operators

      +

      33.4.9 Operators

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

    • operator or
    • -

      33.4.10 Modules and packages

      +

      33.4.10 Modules and packages

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

      33.5 Input and output parameters

      +

      33.5 Input and output parameters

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

      -

      33.6 Exception handling

      +

      33.6 Exception handling

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

      -

      33.7 Remapping datatypes with typemaps

      +

      33.7 Remapping datatypes with typemaps

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

      -

      33.7.1 A simple typemap example

      +

      33.7.1 A simple typemap example

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

      33.7.2 Perl5 typemaps

      +

      33.7.2 Perl5 typemaps

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

      33.7.3 Typemap variables

      +

      33.7.3 Typemap variables

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

      33.7.4 Useful functions

      +

      33.7.4 Useful functions

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

      33.8 Typemap Examples

      +

      33.8 Typemap Examples

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

      -

      33.8.1 Converting a Perl5 array to a char **

      +

      33.8.1 Converting a Perl5 array to a char **

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

      33.8.2 Return values

      +

      33.8.2 Return values

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

      33.8.3 Returning values from arguments

      +

      33.8.3 Returning values from arguments

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

      33.8.4 Accessing array structure members

      +

      33.8.4 Accessing array structure members

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

      -

      33.8.5 Turning Perl references into C pointers

      +

      33.8.5 Turning Perl references into C pointers

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

      33.8.6 Pointer handling

      +

      33.8.6 Pointer handling

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

      33.9 Proxy classes

      +

      33.9 Proxy classes

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

      -

      33.9.1 Preliminaries

      +

      33.9.1 Preliminaries

      @@ -2547,7 +2547,7 @@ SWIG creates a collection of high-level Perl wrappers. In your scripts, you wil high level wrappers. The wrappers, in turn, interact with the low-level procedural module.

      -

      33.9.2 Structure and class wrappers

      +

      33.9.2 Structure and class wrappers

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

      33.9.3 Object Ownership

      +

      33.9.3 Object Ownership

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

      -

      33.9.4 Nested Objects

      +

      33.9.4 Nested Objects

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

      33.9.5 Proxy Functions

      +

      33.9.5 Proxy Functions

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

      -

      33.9.6 Inheritance

      +

      33.9.6 Inheritance

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

      -

      33.9.7 Modifying the proxy methods

      +

      33.9.7 Modifying the proxy methods

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

      33.10 Adding additional Perl code

      +

      33.10 Adding additional Perl code

      @@ -3002,7 +3002,7 @@ set_transform($im, $a); -

      33.11 Cross language polymorphism

      +

      33.11 Cross language polymorphism

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

      -

      33.11.1 Enabling directors

      +

      33.11.1 Enabling directors

      @@ -3126,7 +3126,7 @@ sub one { -

      33.11.2 Director classes

      +

      33.11.2 Director classes

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

      -

      33.11.3 Ownership and object destruction

      +

      33.11.3 Ownership and object destruction

      @@ -3255,7 +3255,7 @@ sub DESTROY { -

      33.11.4 Exception unrolling

      +

      33.11.4 Exception unrolling

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

      -

      33.11.5 Overhead and code bloat

      +

      33.11.5 Overhead and code bloat

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

      -

      33.11.6 Typemaps

      +

      33.11.6 Typemaps

      diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 623adb68a..e1adce5ad 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -7,7 +7,7 @@ -

      34 SWIG and PHP

      +

      34 SWIG and PHP

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

        -

        34.1 Generating PHP Extensions

        +

        34.1 Generating PHP Extensions

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

        -

        34.1.1 Building a loadable extension

        +

        34.1.1 Building a loadable extension

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

      -

      34.1.2 Using PHP Extensions

      +

      34.1.2 Using PHP Extensions

      @@ -188,7 +188,7 @@ This PHP module also defines the PHP classes for the wrapped API, so you'll almost certainly want to include it anyway.

      -

      34.2 Basic PHP interface

      +

      34.2 Basic PHP interface

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

      -

      34.2.1 Constants

      +

      34.2.1 Constants

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

      -

      34.2.2 Global Variables

      +

      34.2.2 Global Variables

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

      -

      34.2.3 Functions

      +

      34.2.3 Functions

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

      34.2.4 Overloading

      +

      34.2.4 Overloading

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

      --> -

      34.2.5 Pointers and References

      +

      34.2.5 Pointers and References

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

      -

      34.2.6 Structures and C++ classes

      +

      34.2.6 Structures and C++ classes

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

      -

      34.2.6.1 Using -noproxy

      +

      34.2.6.1 Using -noproxy

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

      34.2.6.2 Constructors and Destructors

      +

      34.2.6.2 Constructors and Destructors

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

      -

      34.2.6.3 Static Member Variables

      +

      34.2.6.3 Static Member Variables

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

      34.2.6.4 Static Member Functions

      +

      34.2.6.4 Static Member Functions

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

      34.2.6.5 Specifying Implemented Interfaces

      +

      34.2.6.5 Specifying Implemented Interfaces

      @@ -790,7 +790,7 @@ so: If there are multiple interfaces, just list them separated by commas.

      -

      34.2.7 PHP Pragmas, Startup and Shutdown code

      +

      34.2.7 PHP Pragmas, Startup and Shutdown code

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

      -

      34.3 Cross language polymorphism

      +

      34.3 Cross language polymorphism

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

      -

      34.3.1 Enabling directors

      +

      34.3.1 Enabling directors

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

      34.3.2 Director classes

      +

      34.3.2 Director classes

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

      -

      34.3.3 Ownership and object destruction

      +

      34.3.3 Ownership and object destruction

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

      -

      34.3.4 Exception unrolling

      +

      34.3.4 Exception unrolling

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

      -

      34.3.5 Overhead and code bloat

      +

      34.3.5 Overhead and code bloat

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

      -

      34.3.6 Typemaps

      +

      34.3.6 Typemaps

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

      -

      34.3.7 Miscellaneous

      +

      34.3.7 Miscellaneous

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

      35 SWIG and Pike

      +

      35 SWIG and Pike

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

        -

        35.1 Preliminaries

        +

        35.1 Preliminaries

        -

        35.1.1 Running SWIG

        +

        35.1.1 Running SWIG

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

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

        35.1.2 Getting the right header files

        +

        35.1.2 Getting the right header files

        @@ -114,7 +114,7 @@ You're looking for files with the names global.h, program.h and so on.

        -

        35.1.3 Using your module

        +

        35.1.3 Using your module

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

      -

      35.2 Basic C/C++ Mapping

      +

      35.2 Basic C/C++ Mapping

      -

      35.2.1 Modules

      +

      35.2.1 Modules

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

      -

      35.2.2 Functions

      +

      35.2.2 Functions

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

      35.2.3 Global variables

      +

      35.2.3 Global variables

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

      35.2.4 Constants and enumerated types

      +

      35.2.4 Constants and enumerated types

      @@ -205,7 +205,7 @@ Enumerated types in C/C++ declarations are wrapped as Pike constants, not as Pike enums.

      -

      35.2.5 Constructors and Destructors

      +

      35.2.5 Constructors and Destructors

      @@ -213,7 +213,7 @@ Constructors are wrapped as create() methods, and destructors are wrapped as destroy() methods, for Pike classes.

      -

      35.2.6 Static Members

      +

      35.2.6 Static Members

      diff --git a/Doc/Manual/Preface.html b/Doc/Manual/Preface.html index 6ddea588a..186bc415d 100644 --- a/Doc/Manual/Preface.html +++ b/Doc/Manual/Preface.html @@ -6,7 +6,7 @@ -

      1 Preface

      +

      1 Preface

        @@ -35,7 +35,7 @@ -

        1.1 Introduction

        +

        1.1 Introduction

        @@ -58,7 +58,7 @@ has since evolved into a general purpose tool that is used in a wide variety of applications--in fact almost anything where C/C++ programming is involved. -

        1.2 SWIG Versions

        +

        1.2 SWIG Versions

        @@ -70,7 +70,7 @@ An official stable version was released along with the decision to make SWIG license changes and this gave rise to version 2.0.0 in 2010.

        -

        1.3 SWIG License

        +

        1.3 SWIG License

        @@ -86,7 +86,7 @@ under license terms of the user's choice/requirements and at the same time the S source was placed under the GNU General Public License version 3.

        -

        1.4 SWIG resources

        +

        1.4 SWIG resources

        @@ -126,7 +126,7 @@ about this can be obtained at: -

        1.5 Prerequisites

        +

        1.5 Prerequisites

        @@ -151,7 +151,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.6 Organization of this manual

        +

        1.6 Organization of this manual

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

        -

        1.7 How to avoid reading the manual

        +

        1.7 How to avoid reading the manual

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

        -

        1.8 Backwards compatibility

        +

        1.8 Backwards compatibility

        @@ -211,7 +211,7 @@ 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.9 Release notes

        +

        1.9 Release notes

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

        +

        1.10 Credits

        @@ -233,7 +233,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.11 Bug reports

        +

        1.11 Bug reports

        @@ -248,10 +248,10 @@ 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 Installation

        -

        1.12.1 Windows installation

        +

        1.12.1 Windows installation

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

        +

        1.12.2 Unix installation

        @@ -350,7 +350,7 @@ a number of packages to be installed. Full instructions at

      -

      1.12.3 Macintosh OS X installation

      +

      1.12.3 Macintosh OS X installation

      @@ -378,7 +378,7 @@ Darwin's two-level namespaces. Some details about this can be found here Needless to say, you might have to experiment a bit to get things working at first.

      -

      1.12.4 Testing

      +

      1.12.4 Testing

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

      +

      1.12.5 Examples

      diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index e188fc0be..b8a6e9b0e 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -6,7 +6,7 @@ -

      8 Preprocessing

      +

      8 Preprocessing

        @@ -37,7 +37,7 @@ However, a number of modifications and enhancements have been made. This chapter describes some of these modifications.

        -

        8.1 File inclusion

        +

        8.1 File inclusion

        @@ -63,7 +63,7 @@ By default, the #include is ignored unless you run SWIG with the is that you often don't want SWIG to try and wrap everything included in standard header system headers and auxiliary files. -

        8.2 File imports

        +

        8.2 File imports

        @@ -92,7 +92,7 @@ The -importall directive tells SWIG to follow all #include sta as imports. This might be useful if you want to extract type definitions from system header files without generating any wrappers. -

        8.3 Conditional Compilation

        +

        8.3 Conditional Compilation

        @@ -156,7 +156,7 @@ SWIG (except for the symbol `SWIG' which is only defined within the SWIG compiler).

        -

        8.4 Macro Expansion

        +

        8.4 Macro Expansion

        @@ -211,7 +211,7 @@ like #x. This is a non-standard SWIG extension.

      -

      8.5 SWIG Macros

      +

      8.5 SWIG Macros

      @@ -257,7 +257,7 @@ many of SWIG's advanced features and libraries are built using this mechanism (s support).

      -

      8.6 C99 and GNU Extensions

      +

      8.6 C99 and GNU Extensions

      @@ -313,14 +313,14 @@ interface building. However, they are used internally to implement a number of SWIG directives and are provided to make SWIG more compatible with C99 code.

      -

      8.7 Preprocessing and delimiters

      +

      8.7 Preprocessing and delimiters

      The preprocessor handles { }, " " and %{ %} delimiters differently.

      -

      8.7.1 Preprocessing and %{ ... %} & " ... " delimiters

      +

      8.7.1 Preprocessing and %{ ... %} & " ... " delimiters

      @@ -345,7 +345,7 @@ the contents of the %{ ... %} block are copied without modification to the output (including all preprocessor directives).

      -

      8.7.2 Preprocessing and { ... } delimiters

      +

      8.7.2 Preprocessing and { ... } delimiters

      @@ -387,7 +387,7 @@ to actually go into the wrapper file, prefix the preprocessor directives with % and leave the preprocessor directive in the code.

      -

      8.8 Preprocessor and Typemaps

      +

      8.8 Preprocessor and Typemaps

      @@ -458,7 +458,7 @@ would generate

      -

      8.9 Viewing preprocessor output

      +

      8.9 Viewing preprocessor output

      @@ -468,7 +468,7 @@ Instead the results after the preprocessor has run are displayed. This might be useful as an aid to debugging and viewing the results of macro expansions.

      -

      8.10 The #error and #warning directives

      +

      8.10 The #error and #warning directives

      diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index c5219b693..c288581b7 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6,7 +6,7 @@ -

      36 SWIG and Python

      +

      36 SWIG and Python

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

        -

        36.1 Overview

        +

        36.1 Overview

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

        -

        36.2 Preliminaries

        +

        36.2 Preliminaries

        -

        36.2.1 Running SWIG

        +

        36.2.1 Running SWIG

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

        -

        36.2.2 Using distutils

        +

        36.2.2 Using distutils

        @@ -368,7 +368,7 @@ This same approach works on all platforms if the appropriate compiler is install can even build extensions to the standard Windows Python using MingGW)

        -

        36.2.3 Hand compiling a dynamic module

        +

        36.2.3 Hand compiling a dynamic module

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

        -

        36.2.4 Static linking

        +

        36.2.4 Static linking

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

        -

        36.2.5 Using your module

        +

        36.2.5 Using your module

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

        -

        36.2.6 Compilation of C++ extensions

        +

        36.2.6 Compilation of C++ extensions

        @@ -744,7 +744,7 @@ erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

        -

        36.2.7 Compiling for 64-bit platforms

        +

        36.2.7 Compiling for 64-bit platforms

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

        -

        36.2.8 Building Python Extensions under Windows

        +

        36.2.8 Building Python Extensions under Windows

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

        -

        36.3 A tour of basic C/C++ wrapping

        +

        36.3 A tour of basic C/C++ wrapping

        @@ -919,7 +919,7 @@ to your C/C++ code. Functions are wrapped as functions, classes are wrapped as This section briefly covers the essential aspects of this wrapping.

        -

        36.3.1 Modules

        +

        36.3.1 Modules

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

        -

        36.3.2 Functions

        +

        36.3.2 Functions

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

      -

      36.3.3 Global variables

      +

      36.3.3 Global variables

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

      -

      36.3.4 Constants and enums

      +

      36.3.4 Constants and enums

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

      -

      36.3.5 Pointers

      +

      36.3.5 Pointers

      @@ -1275,7 +1275,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return None if the conversion can't be performed.

      -

      36.3.6 Structures

      +

      36.3.6 Structures

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

      -

      36.3.7 C++ classes

      +

      36.3.7 C++ classes

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

      36.3.8 C++ inheritance

      +

      36.3.8 C++ inheritance

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

      -

      36.3.9 Pointers, references, values, and arrays

      +

      36.3.9 Pointers, references, values, and arrays

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

      -

      36.3.10 C++ overloaded functions

      +

      36.3.10 C++ overloaded functions

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

      -

      36.3.11 C++ operators

      +

      36.3.11 C++ operators

      @@ -1881,7 +1881,7 @@ Also, be aware that certain operators don't map cleanly to Python. For instance overloaded assignment operators don't map to Python semantics and will be ignored.

      -

      36.3.12 C++ namespaces

      +

      36.3.12 C++ namespaces

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

      -

      36.3.13 C++ templates

      +

      36.3.13 C++ templates

      @@ -2002,10 +2002,10 @@ Some more complicated examples will appear later.

      -

      36.3.14 C++ Smart Pointers

      +

      36.3.14 C++ Smart Pointers

      -

      36.3.14.1 The shared_ptr Smart Pointer

      +

      36.3.14.1 The shared_ptr Smart Pointer

      @@ -2016,7 +2016,7 @@ in the shared_ptr smart pointer -

      36.3.14.2 Generic Smart Pointers

      +

      36.3.14.2 Generic Smart Pointers

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

      36.3.15 C++ reference counted objects

      +

      36.3.15 C++ reference counted objects

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

      -

      36.4 Further details on the Python class interface

      +

      36.4 Further details on the Python class interface

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

      -

      36.4.1 Proxy classes

      +

      36.4.1 Proxy classes

      @@ -2221,7 +2221,7 @@ you can attach new Python methods to the class and you can even inherit from it by Python built-in types until Python 2.2).

      -

      36.4.2 Built-in Types

      +

      36.4.2 Built-in Types

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

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

      -

      36.4.2.1 Limitations

      +

      36.4.2.1 Limitations

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

      36.4.2.2 Operator overloads -- use them!

      +

      36.4.2.2 Operator overloads -- use them!

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

      -

      36.4.3 Memory management

      +

      36.4.3 Memory management

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

      -

      36.4.4 Python 2.2 and classic classes

      +

      36.4.4 Python 2.2 and classic classes

      @@ -2766,7 +2766,7 @@ class itself. In Python-2.1 and earlier, they have to be accessed as a global function or through an instance (see the earlier section).

      -

      36.5 Cross language polymorphism

      +

      36.5 Cross language polymorphism

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

      -

      36.5.1 Enabling directors

      +

      36.5.1 Enabling directors

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

      36.5.2 Director classes

      +

      36.5.2 Director classes

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

      -

      36.5.3 Ownership and object destruction

      +

      36.5.3 Ownership and object destruction

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

      -

      36.5.4 Exception unrolling

      +

      36.5.4 Exception unrolling

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

      -

      36.5.5 Overhead and code bloat

      +

      36.5.5 Overhead and code bloat

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

      -

      36.5.6 Typemaps

      +

      36.5.6 Typemaps

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

      -

      36.5.7 Miscellaneous

      +

      36.5.7 Miscellaneous

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

      -

      36.6 Common customization features

      +

      36.6 Common customization features

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

      -

      36.6.1 C/C++ helper functions

      +

      36.6.1 C/C++ helper functions

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

      -

      36.6.2 Adding additional Python code

      +

      36.6.2 Adding additional Python code

      @@ -3541,7 +3541,7 @@ The same applies for overloaded constructors.

      -

      36.6.3 Class extension with %extend

      +

      36.6.3 Class extension with %extend

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

      -

      36.6.4 Exception handling with %exception

      +

      36.6.4 Exception handling with %exception

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

      -

      36.7 Tips and techniques

      +

      36.7 Tips and techniques

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

      -

      36.7.1 Input and output parameters

      +

      36.7.1 Input and output parameters

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

      -

      36.7.2 Simple pointers

      +

      36.7.2 Simple pointers

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

      -

      36.7.3 Unbounded C Arrays

      +

      36.7.3 Unbounded C Arrays

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

      -

      36.7.4 String handling

      +

      36.7.4 String handling

      @@ -4180,7 +4180,7 @@ also be used to extra binary data from arbitrary pointers.

      -

      36.7.5 Default arguments

      +

      36.7.5 Default arguments

      @@ -4279,7 +4279,7 @@ Versions of SWIG prior to this varied in their ability to convert C++ default va equivalent Python default argument values.

      -

      36.8 Typemaps

      +

      36.8 Typemaps

      @@ -4296,7 +4296,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Python interface or if you want to elevate your guru status.

      -

      36.8.1 What is a typemap?

      +

      36.8.1 What is a typemap?

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

      36.8.2 Python typemaps

      +

      36.8.2 Python typemaps

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

      -

      36.8.3 Typemap variables

      +

      36.8.3 Typemap variables

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

      36.8.4 Useful Python Functions

      +

      36.8.4 Useful Python Functions

      @@ -4652,7 +4652,7 @@ write me -

      36.9 Typemap Examples

      +

      36.9 Typemap Examples

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

      -

      36.9.1 Converting Python list to a char **

      +

      36.9.1 Converting Python list to a char **

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

      -

      36.9.2 Expanding a Python object into multiple arguments

      +

      36.9.2 Expanding a Python object into multiple arguments

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

      36.9.3 Using typemaps to return arguments

      +

      36.9.3 Using typemaps to return arguments

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

      36.9.4 Mapping Python tuples into small arrays

      +

      36.9.4 Mapping Python tuples into small arrays

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

      -

      36.9.5 Mapping sequences to C arrays

      +

      36.9.5 Mapping sequences to C arrays

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

      36.9.6 Pointer handling

      +

      36.9.6 Pointer handling

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

      36.10 Docstring Features

      +

      36.10 Docstring Features

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

      -

      36.10.1 Module docstring

      +

      36.10.1 Module docstring

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

      36.10.2 %feature("autodoc")

      +

      36.10.2 %feature("autodoc")

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

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

      +

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

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

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

      +

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

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

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

      +

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

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

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

      +

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

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

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

      +

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

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

      36.10.3 %feature("docstring")

      +

      36.10.3 %feature("docstring")

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

      36.11 Python Packages

      +

      36.11 Python Packages

      Python has concepts of modules and packages. Modules are separate units of @@ -5484,7 +5484,7 @@ users may need to use special features such as the package option in th %module directive or import related command line options. These are explained in the following sections.

      -

      36.11.1 Setting the Python package

      +

      36.11.1 Setting the Python package

      @@ -5538,7 +5538,7 @@ pkg1/pkg2/_foo.so # (shared library built from C/C++ code generated by SWI -

      36.11.2 Absolute and relative imports

      +

      36.11.2 Absolute and relative imports

      Suppose, we have the following hierarchy of files:

      @@ -5677,7 +5677,7 @@ uses relative imports. Second case is, when one puts import directives in __init__.py to import symbols from submodules or subpackages and the submodule depends on other submodules (discussed later).

      -

      36.11.3 Enforcing absolute import semantics

      +

      36.11.3 Enforcing absolute import semantics

      As you may know, there is an incompatibility in import semantics (for the @@ -5714,7 +5714,7 @@ from __future__ import absolute_import -

      36.11.4 Importing from __init__.py

      +

      36.11.4 Importing from __init__.py

      Imports in __init__.py are handy when you want to populate a @@ -5825,7 +5825,7 @@ effect (note, that the Python 2 case also needs the -relativeimport workaround).

      -

      36.12 Python 3 Support

      +

      36.12 Python 3 Support

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

      -

      36.12.1 Function annotation

      +

      36.12.1 Function annotation

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

      -

      36.12.2 Buffer interface

      +

      36.12.2 Buffer interface

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

      36.12.3 Abstract base classes

      +

      36.12.3 Abstract base classes

      @@ -6078,7 +6078,7 @@ For details of abstract base class, please see PEP 3119.

      -

      36.12.4 Byte string output conversion

      +

      36.12.4 Byte string output conversion

      @@ -6164,7 +6164,7 @@ For more details about the surrogateescape error handler, please see PEP 383.

      -

      36.12.5 Python 2 Unicode

      +

      36.12.5 Python 2 Unicode

      diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index 50e861b22..fc60f368e 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -6,7 +6,7 @@ -

      37 SWIG and R

      +

      37 SWIG and R

        @@ -33,7 +33,7 @@ compile and run an R interface to QuantLib running on Mandriva Linux with gcc. The R bindings also work on Microsoft Windows using Visual C++.

        -

        37.1 Bugs

        +

        37.1 Bugs

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

      • C Array wrappings
      -

      37.2 Using R and SWIG

      +

      37.2 Using R and SWIG

      @@ -136,7 +136,7 @@ Error in .Call("R_swig_fact", s_arg1, as.logical(.copy), PACKAGE = "example") :

    • Make sure the architecture of the shared library(x64 for instance), matches the architecture of the R program you want to load your shared library into -

      37.3 Precompiling large R files

      +

      37.3 Precompiling large R files

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

      37.4 General policy

      +

      37.4 General policy

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

      -

      37.5 Language conventions

      +

      37.5 Language conventions

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

      -

      37.6 C++ classes

      +

      37.6 C++ classes

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

      -

      37.7 Enumerations

      +

      37.7 Enumerations

      diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 2de9f673e..4663b4c95 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -7,7 +7,7 @@ -

      38 SWIG and Ruby

      +

      38 SWIG and Ruby

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

        This chapter describes SWIG's support of Ruby.

        -

        38.1 Preliminaries

        +

        38.1 Preliminaries

        SWIG 3.0 is known to work with Ruby versions 1.8 and later. @@ -163,7 +163,7 @@ read the "SWIG Basics" chapter. It is also assumed that the reader has a basic understanding of Ruby.

        -

        38.1.1 Running SWIG

        +

        38.1.1 Running SWIG

        To build a Ruby module, run SWIG using the -ruby @@ -187,7 +187,7 @@ 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.

        -

        38.1.2 Getting the right header files

        +

        38.1.2 Getting the right header files

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

      -

      38.1.3 Compiling a dynamic module

      +

      38.1.3 Compiling a dynamic module

      Ruby extension modules are typically compiled into shared @@ -289,7 +289,7 @@ manual pages for your compiler and linker to determine the correct set of options. You might also check the SWIG Wiki for additional information.

      -

      38.1.4 Using your module

      +

      38.1.4 Using your module

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

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

      -

      38.1.5 Static linking

      +

      38.1.5 Static linking

      An alternative approach to dynamic linking is to rebuild the @@ -334,7 +334,7 @@ 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.

      -

      38.1.6 Compilation of C++ extensions

      +

      38.1.6 Compilation of C++ extensions

      On most machines, C++ extension modules should be linked @@ -366,7 +366,7 @@ $libs = append_library($libs, "supc++") create_makefile('example')

    • -

      38.2 Building Ruby Extensions under Windows 95/NT

      +

      38.2 Building Ruby Extensions under Windows 95/NT

      Building a SWIG extension to Ruby under Windows 95/NT is @@ -391,7 +391,7 @@ order to build extensions, you may need to download the source distribution to the Ruby package, as you will need the Ruby header files.

      -

      38.2.1 Running SWIG from Developer Studio

      +

      38.2.1 Running SWIG from Developer Studio

      If you are developing your application within Microsoft @@ -455,13 +455,13 @@ Foo = 3.0 -

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

      +

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

      -

      38.3.1 Modules

      +

      38.3.1 Modules

      The SWIG %module directive specifies @@ -533,7 +533,7 @@ 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.

      -

      38.3.2 Functions

      +

      38.3.2 Functions

      Global functions are wrapped as Ruby module methods. For @@ -567,7 +567,7 @@ irb(main):002:0> Example.fact(4) 24 -

      38.3.3 Variable Linking

      +

      38.3.3 Variable Linking

      C/C++ global variables are wrapped as a pair of singleton @@ -629,7 +629,7 @@ directive. For example:

      effect until it is explicitly disabled using %mutable.

      -

      38.3.4 Constants

      +

      38.3.4 Constants

      C/C++ constants are wrapped as module constants initialized @@ -657,7 +657,7 @@ irb(main):002:0> Example::PI 3.14159 -

      38.3.5 Pointers

      +

      38.3.5 Pointers

      "Opaque" pointers to arbitrary C/C++ types (i.e. types that @@ -681,7 +681,7 @@ returns an instance of an internally generated Ruby class:

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

      -

      38.3.6 Structures

      +

      38.3.6 Structures

      C/C++ structs are wrapped as Ruby classes, with accessor @@ -786,7 +786,7 @@ void Bar_f_set(Bar *b, Foo *val) { } -

      38.3.7 C++ classes

      +

      38.3.7 C++ classes

      Like structs, C++ classes are wrapped by creating a new Ruby @@ -841,7 +841,7 @@ Ale 3 -

      38.3.8 C++ Inheritance

      +

      38.3.8 C++ Inheritance

      The SWIG type-checker is fully aware of C++ inheritance. @@ -994,7 +994,7 @@ inherit from both Base1 and Base2 (i.e. they exhibit "Duck Typing").

      -

      38.3.9 C++ Overloaded Functions

      +

      38.3.9 C++ Overloaded Functions

      C++ overloaded functions, methods, and constructors are @@ -1084,7 +1084,7 @@ arises--in this case, the first declaration takes precedence.

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

      -

      38.3.10 C++ Operators

      +

      38.3.10 C++ Operators

      For the most part, overloaded operators are handled @@ -1126,7 +1126,7 @@ c = Example.add_complex(a, b) is discussed in the section on operator overloading.

      -

      38.3.11 C++ namespaces

      +

      38.3.11 C++ namespaces

      SWIG is aware of C++ namespaces, but namespace names do not @@ -1183,7 +1183,7 @@ 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.

      -

      38.3.12 C++ templates

      +

      38.3.12 C++ templates

      C++ templates don't present a huge problem for SWIG. However, @@ -1225,7 +1225,7 @@ irb(main):004:0> p.second 4 -

      38.3.13 C++ Standard Template Library (STL)

      +

      38.3.13 C++ Standard Template Library (STL)

      On a related note, the standard SWIG library contains a @@ -1318,7 +1318,7 @@ puts v shown in these examples. More details can be found in the SWIG and C++ chapter.

      -

      38.3.14 C++ STL Functors

      +

      38.3.14 C++ STL Functors

      Some containers in the STL allow you to modify their default @@ -1379,7 +1379,7 @@ b -

      38.3.15 C++ STL Iterators

      +

      38.3.15 C++ STL Iterators

      The STL is well known for the use of iterators. There @@ -1462,10 +1462,10 @@ i

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

      -

      38.3.16 C++ Smart Pointers

      +

      38.3.16 C++ Smart Pointers

      -

      38.3.16.1 The shared_ptr Smart Pointer

      +

      38.3.16.1 The shared_ptr Smart Pointer

      @@ -1476,7 +1476,7 @@ in the shared_ptr smart pointer -

      38.3.16.2 Generic Smart Pointers

      +

      38.3.16.2 Generic Smart Pointers

      In certain C++ programs, it is common to use classes that @@ -1541,7 +1541,7 @@ method. For example:

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

      38.3.17 Cross-Language Polymorphism

      +

      38.3.17 Cross-Language Polymorphism

      SWIG's Ruby module supports cross-language polymorphism @@ -1550,7 +1550,7 @@ module. Rather than duplicate the information presented in the 38.3.17.1 Exception Unrolling +

      38.3.17.1 Exception Unrolling

      Whenever a C++ director class routes one of its virtual @@ -1573,7 +1573,7 @@ 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.

      -

      38.4 Naming

      +

      38.4 Naming

      Ruby has several common naming conventions. Constants are @@ -1611,7 +1611,7 @@ 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.

      -

      38.4.1 Defining Aliases

      +

      38.4.1 Defining Aliases

      It's a fairly common practice in the Ruby built-ins and @@ -1681,7 +1681,7 @@ matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

      -

      38.4.2 Predicate Methods

      +

      38.4.2 Predicate Methods

      Ruby methods that return a boolean value and end in a @@ -1730,7 +1730,7 @@ 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).

      -

      38.4.3 Bang Methods

      +

      38.4.3 Bang Methods

      Ruby methods that modify an object in-place and end in an @@ -1762,7 +1762,7 @@ 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).

      -

      38.4.4 Getters and Setters

      +

      38.4.4 Getters and Setters

      Often times a C++ library will expose properties through @@ -1797,7 +1797,7 @@ irb(main):003:0> puts foo.value %rename("value=") Foo::setValue(int value); -

      38.5 Input and output parameters

      +

      38.5 Input and output parameters

      A common problem in some C programs is handling parameters @@ -1936,10 +1936,10 @@ void get_dimensions(Matrix *m, int *rows, int*columns);

      r, c = Example.get_dimensions(m)
      -

      38.6 Exception handling

      +

      38.6 Exception handling

      -

      38.6.1 Using the %exception directive

      +

      38.6.1 Using the %exception directive

      The SWIG %exception directive can be @@ -2048,7 +2048,7 @@ methods and functions named getitem and setitem. limited to C++ exception handling. See the chapter on Customization Features for more examples.

      -

      38.6.2 Handling Ruby Blocks

      +

      38.6.2 Handling Ruby Blocks

      One of the highlights of Ruby and most of its standard library @@ -2115,7 +2115,7 @@ a special in typemap, like:

      For more information on typemaps, see Typemaps.

      -

      38.6.3 Raising exceptions

      +

      38.6.3 Raising exceptions

      There are three ways to raise exceptions from C++ code to @@ -2272,7 +2272,7 @@ 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.

      -

      38.6.4 Exception classes

      +

      38.6.4 Exception classes

      Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass @@ -2309,7 +2309,7 @@ end

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

      -

      38.7 Typemaps

      +

      38.7 Typemaps

      This section describes how you can modify SWIG's default @@ -2324,7 +2324,7 @@ 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.

      -

      38.7.1 What is a typemap?

      +

      38.7.1 What is a typemap?

      A typemap is nothing more than a code generation rule that is @@ -2481,7 +2481,7 @@ to be used as follows (notice how the length parameter is omitted):

      2 -

      38.7.2 Typemap scope

      +

      38.7.2 Typemap scope

      Once defined, a typemap remains in effect for all of the @@ -2527,7 +2527,7 @@ where the class itself is defined. For example:

      }; -

      38.7.3 Copying a typemap

      +

      38.7.3 Copying a typemap

      A typemap is copied by using assignment. For example:

      @@ -2569,7 +2569,7 @@ rules as for %apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments -

      38.7.4 Deleting a typemap

      +

      38.7.4 Deleting a typemap

      A typemap can be deleted by simply defining no code. For @@ -2594,7 +2594,7 @@ 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.

      -

      38.7.5 Placement of typemaps

      +

      38.7.5 Placement of typemaps

      Typemap declarations can be declared in the global scope, @@ -2665,13 +2665,13 @@ In this example, this is done using the class declaration class string .

      -

      38.7.6 Ruby typemaps

      +

      38.7.6 Ruby typemaps

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

      -

      38.7.6.1 "in" typemap

      +

      38.7.6.1 "in" typemap

      Converts Ruby objects to input @@ -2738,7 +2738,7 @@ arguments to be specified. For example:

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

      -

      38.7.6.2 "typecheck" typemap

      +

      38.7.6.2 "typecheck" typemap

      The "typecheck" typemap is used to support overloaded @@ -2760,7 +2760,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."

      -

      38.7.6.3 "out" typemap

      +

      38.7.6.3 "out" typemap

      Converts return value of a C function @@ -2811,7 +2811,7 @@ version of the C datatype matched by the typemap.

      -

      38.7.6.4 "arginit" typemap

      +

      38.7.6.4 "arginit" typemap

      The "arginit" typemap is used to set the initial value of a @@ -2826,7 +2826,7 @@ applications. For example:

      } -

      38.7.6.5 "default" typemap

      +

      38.7.6.5 "default" typemap

      The "default" typemap is used to turn an argument into a @@ -2851,7 +2851,7 @@ arguments that follow must have default values. See the 38.7.6.6 "check" typemap +

      38.7.6.6 "check" typemap

      The "check" typemap is used to supply value checking code @@ -2866,7 +2866,7 @@ arguments have been converted. For example:

      } -

      38.7.6.7 "argout" typemap

      +

      38.7.6.7 "argout" typemap

      The "argout" typemap is used to return values from arguments. @@ -2920,7 +2920,7 @@ some function like SWIG_Ruby_AppendOutput.

      See the typemaps.i library for examples.

      -

      38.7.6.8 "freearg" typemap

      +

      38.7.6.8 "freearg" typemap

      The "freearg" typemap is used to cleanup argument data. It is @@ -2947,7 +2947,7 @@ 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.

      -

      38.7.6.9 "newfree" typemap

      +

      38.7.6.9 "newfree" typemap

      The "newfree" typemap is used in conjunction with the %newobject @@ -2971,7 +2971,7 @@ string *foo();

      See Object ownership and %newobject for further details.

      -

      38.7.6.10 "memberin" typemap

      +

      38.7.6.10 "memberin" typemap

      The "memberin" typemap is used to copy data from an @@ -2989,21 +2989,21 @@ example:

      already provides a default implementation for arrays, strings, and other objects.

      -

      38.7.6.11 "varin" typemap

      +

      38.7.6.11 "varin" typemap

      The "varin" typemap is used to convert objects in the target language to C for the purposes of assigning to a C/C++ global variable. This is implementation specific.

      -

      38.7.6.12 "varout" typemap

      +

      38.7.6.12 "varout" typemap

      The "varout" typemap is used to convert a C/C++ object to an object in the target language when reading a C/C++ global variable. This is implementation specific.

      -

      38.7.6.13 "throws" typemap

      +

      38.7.6.13 "throws" typemap

      The "throws" typemap is only used when SWIG parses a C++ @@ -3044,7 +3044,7 @@ 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.

      -

      38.7.6.14 directorin typemap

      +

      38.7.6.14 directorin typemap

      Converts C++ objects in director @@ -3103,7 +3103,7 @@ referring to the class itself. -

      38.7.6.15 directorout typemap

      +

      38.7.6.15 directorout typemap

      Converts Ruby objects in director @@ -3176,7 +3176,7 @@ exception.

      -

      38.7.6.16 directorargout typemap

      +

      38.7.6.16 directorargout typemap

      Output argument processing in director @@ -3234,19 +3234,19 @@ referring to the instance of the class itself -

      38.7.6.17 ret typemap

      +

      38.7.6.17 ret typemap

      Cleanup of function return values

      -

      38.7.6.18 globalin typemap

      +

      38.7.6.18 globalin typemap

      Setting of C global variables

      -

      38.7.7 Typemap variables

      +

      38.7.7 Typemap variables

      @@ -3296,7 +3296,7 @@ so that their values can be properly assigned.

      The Ruby name of the wrapper function being created.
      -

      38.7.8 Useful Functions

      +

      38.7.8 Useful Functions

      When you write a typemap, you usually have to work directly @@ -3311,7 +3311,7 @@ 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.

      -

      38.7.8.1 C Datatypes to Ruby Objects

      +

      38.7.8.1 C Datatypes to Ruby Objects

      @@ -3353,7 +3353,7 @@ SWIG_From_float(float)
      -

      38.7.8.2 Ruby Objects to C Datatypes

      +

      38.7.8.2 Ruby Objects to C Datatypes

      Here, while the Ruby versions return the value directly, the SWIG @@ -3421,7 +3421,7 @@ versions do not, but return a status value to indicate success (SWIG_OK -

      38.7.8.3 Macros for VALUE

      +

      38.7.8.3 Macros for VALUE

      RSTRING_LEN(str)

      @@ -3444,7 +3444,7 @@ versions do not, but return a status value to indicate success (SWIG_OK
      pointer to array storage
      -

      38.7.8.4 Exceptions

      +

      38.7.8.4 Exceptions

      void rb_raise(VALUE exception, const char *fmt, @@ -3523,7 +3523,7 @@ 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(). -

      38.7.8.5 Iterators

      +

      38.7.8.5 Iterators

      void rb_iter_break()

      @@ -3569,14 +3569,14 @@ VALUE), VALUE value)

      Equivalent to Ruby's throw.
      -

      38.7.9 Typemap Examples

      +

      38.7.9 Typemap Examples

      This section includes a few examples of typemaps. For more examples, you might look at the examples in the Example/ruby directory.

      -

      38.7.10 Converting a Ruby array to a char **

      +

      38.7.10 Converting a Ruby array to a char **

      A common problem in many C programs is the processing of @@ -3641,7 +3641,7 @@ 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.

      -

      38.7.11 Collecting arguments in a hash

      +

      38.7.11 Collecting arguments in a hash

      Ruby's solution to the "keyword arguments" capability of some @@ -3855,7 +3855,7 @@ memory leak. Fortunately, this typemap is a lot easier to write:

      program that uses the extension, can be found in the Examples/ruby/hashargs directory of the SWIG distribution.

      -

      38.7.12 Pointer handling

      +

      38.7.12 Pointer handling

      Occasionally, it might be necessary to convert pointer values @@ -3914,7 +3914,7 @@ For example:

      } -

      38.7.12.1 Ruby Datatype Wrapping

      +

      38.7.12.1 Ruby Datatype Wrapping

      VALUE Data_Wrap_Struct(VALUE class, void @@ -3941,7 +3941,7 @@ as above. type c-type from the data object obj and assigns that pointer to ptr. -

      38.7.13 Example: STL Vector to Ruby Array

      +

      38.7.13 Example: STL Vector to Ruby Array

      Another use for macros and type maps is to create a Ruby array @@ -4033,7 +4033,7 @@ 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. -

      38.8 Docstring Features

      +

      38.8 Docstring Features

      @@ -4067,7 +4067,7 @@ generate ri documentation from a c wrap file, you could do:

      $ rdoc -r file_wrap.c -

      38.8.1 Module docstring

      +

      38.8.1 Module docstring

      @@ -4097,7 +4097,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." %module(docstring=DOCSTRING) xrc -

      38.8.2 %feature("autodoc")

      +

      38.8.2 %feature("autodoc")

      Since SWIG does know everything about the function it wraps, @@ -4118,7 +4118,7 @@ several options for autodoc controlled by the value given to the feature, described below.

      -

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

      +

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

      @@ -4142,7 +4142,7 @@ Then Ruby code like this will be generated: ... -

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

      +

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

      @@ -4162,7 +4162,7 @@ this: ... -

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

      +

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

      @@ -4174,7 +4174,7 @@ parameter types with the "2" option will result in Ruby code like this:

      -

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

      +

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

      @@ -4195,7 +4195,7 @@ Parameters: bar - Bar -

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

      +

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

      @@ -4211,7 +4211,7 @@ generated string. For example: void GetPosition(int* OUTPUT, int* OUTPUT); -

      38.8.3 %feature("docstring")

      +

      38.8.3 %feature("docstring")

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

      -

      38.9 Advanced Topics

      +

      38.9 Advanced Topics

      -

      38.9.1 Operator overloading

      +

      38.9.1 Operator overloading

      SWIG allows operator overloading with, by using the %extend @@ -4406,7 +4406,7 @@ separate method for handling inequality since Ruby parses the expression a != b as !(a == b).

      -

      38.9.2 Creating Multi-Module Packages

      +

      38.9.2 Creating Multi-Module Packages

      The chapter on Working @@ -4532,7 +4532,7 @@ irb(main):005:0> c.getX() 5.0 -

      38.9.3 Specifying Mixin Modules

      +

      38.9.3 Specifying Mixin Modules

      The Ruby language doesn't support multiple inheritance, but @@ -4599,7 +4599,7 @@ matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

      -

      38.10 Memory Management

      +

      38.10 Memory Management

      One of the most common issues in generating SWIG bindings for @@ -4622,7 +4622,7 @@ 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.

      -

      38.10.1 Mark and Sweep Garbage Collector

      +

      38.10.1 Mark and Sweep Garbage Collector

      Ruby uses a mark and sweep garbage collector. When the garbage @@ -4654,7 +4654,7 @@ 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.

      -

      38.10.2 Object Ownership

      +

      38.10.2 Object Ownership

      As described above, memory management depends on clearly @@ -4799,7 +4799,7 @@ public:

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

      -

      38.10.3 Object Tracking

      +

      38.10.3 Object Tracking

      The remaining parts of this section will use the class library @@ -5025,7 +5025,7 @@ However, if you implement your own free functions (see below) you may also have to call the SWIG_RubyRemoveTracking and RubyUnlinkObjects methods.

      -

      38.10.4 Mark Functions

      +

      38.10.4 Mark Functions

      With a bit more testing, we see that our class library still @@ -5154,7 +5154,7 @@ irb(main):016:0>

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

      -

      38.10.5 Free Functions

      +

      38.10.5 Free Functions

      By default, SWIG creates a "free" function that is called when @@ -5323,7 +5323,7 @@ been freed, and thus raises a runtime exception.

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

      -

      38.10.6 Embedded Ruby and the C++ Stack

      +

      38.10.6 Embedded Ruby and the C++ Stack

      As has been said, the Ruby GC runs and marks objects before diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 774e00b23..c31d8255f 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -6,7 +6,7 @@ -

      5 SWIG Basics

      +

      5 SWIG Basics

        @@ -94,7 +94,7 @@ Specific details about each target language are described in later chapters.

        -

        5.1 Running SWIG

        +

        5.1 Running SWIG

        @@ -156,7 +156,7 @@ can be obtained by typing swig -help or swig

      -

      5.1.1 Input format

      +

      5.1.1 Input format

      @@ -203,7 +203,7 @@ semantics in SWIG is analogous to that of the declarations section used in input files to parser generation tools such as yacc or bison.

      -

      5.1.2 SWIG Output

      +

      5.1.2 SWIG Output

      @@ -263,7 +263,7 @@ as the output directory for the language files is the same directory as the generated C/C++ file if not overridden with -outdir.

      -

      5.1.3 Comments

      +

      5.1.3 Comments

      @@ -273,7 +273,7 @@ documentation files. However, this feature is currently under repair and will reappear in a later SWIG release.

      -

      5.1.4 C Preprocessor

      +

      5.1.4 C Preprocessor

      @@ -297,7 +297,7 @@ make it more powerful than the normal C preprocessor. These extensions are described in the "Preprocessor" chapter.

      -

      5.1.5 SWIG Directives

      +

      5.1.5 SWIG Directives

      @@ -328,7 +328,7 @@ included in C header files using conditional compilation like this: it is parsing an input file.

      -

      5.1.6 Parser Limitations

      +

      5.1.6 Parser Limitations

      @@ -426,7 +426,7 @@ does not utilize a separate typedef-name terminal symbol as described on p. 234 of K&R).

      -

      5.2 Wrapping Simple C Declarations

      +

      5.2 Wrapping Simple C Declarations

      @@ -489,7 +489,7 @@ environments, and semantics, it is not always possible to do so. The next few sections describe various aspects of this mapping.

      -

      5.2.1 Basic Type Handling

      +

      5.2.1 Basic Type Handling

      @@ -614,7 +614,7 @@ will use the same internal representation (e.g., UCS-2 vs. UCS-4). You may need to write some special conversion functions.

      -

      5.2.2 Global Variables

      +

      5.2.2 Global Variables

      @@ -669,7 +669,7 @@ Earlier versions of SWIG incorrectly handled const and created constants instead.

      -

      5.2.3 Constants

      +

      5.2.3 Constants

      @@ -758,7 +758,7 @@ is only used when you want to add constants to the scripting language interface that are not defined in the original header file.

      -

      5.2.4 A brief word about const

      +

      5.2.4 A brief word about const

      @@ -860,7 +860,7 @@ const int spam = 42; -

      5.2.5 A cautionary tale of char *

      +

      5.2.5 A cautionary tale of char *

      @@ -899,7 +899,7 @@ input values. However, it must be noted that you could change the behavior of using typemaps.

      -

      5.3 Pointers and complex objects

      +

      5.3 Pointers and complex objects

      @@ -907,7 +907,7 @@ Most C programs manipulate arrays, structures, and other types of objects. This discusses the handling of these datatypes.

      -

      5.3.1 Simple pointers

      +

      5.3.1 Simple pointers

      @@ -973,7 +973,7 @@ simplified and less prone to error.

    -

    5.3.2 Run time pointer type checking

    +

    5.3.2 Run time pointer type checking

    @@ -995,7 +995,7 @@ as sentinel values or to denote a missing/empty value. Therefore, SWIG leaves NULL pointer checking up to the application.

    -

    5.3.3 Derived types, structs, and classes

    +

    5.3.3 Derived types, structs, and classes

    @@ -1052,7 +1052,7 @@ In this case f1, f2, and buffer are all opaque objects containing C pointers. It doesn't matter what value they contain--our program works just fine without this knowledge.

    -

    5.3.4 Undefined datatypes

    +

    5.3.4 Undefined datatypes

    @@ -1112,7 +1112,7 @@ The only way to fix this problem is to make sure you properly declare type names -

    5.3.5 Typedef

    +

    5.3.5 Typedef

    @@ -1201,7 +1201,7 @@ The corresponding wrapper function will accept arguments of type unsigned int * or size_t *.

    -

    5.4 Other Practicalities

    +

    5.4 Other Practicalities

    @@ -1211,7 +1211,7 @@ more difficult to map to a scripting language interface. This section describes some of these issues.

    -

    5.4.1 Passing structures by value

    +

    5.4.1 Passing structures by value

    @@ -1242,7 +1242,7 @@ to Vectors instead of Vectors. For the most part, this transformation is transparent so you might not notice.

    -

    5.4.2 Return by value

    +

    5.4.2 Return by value

    @@ -1297,7 +1297,7 @@ don't work correctly if Vector doesn't define a default constructor. The section on SWIG and C++ has more information about this case.

    -

    5.4.3 Linking to structure variables

    +

    5.4.3 Linking to structure variables

    @@ -1329,7 +1329,7 @@ C++ classes must supply a properly defined copy constructor in order for assignment to work correctly.

    -

    5.4.4 Linking to char *

    +

    5.4.4 Linking to char *

    @@ -1458,7 +1458,7 @@ value is not released. -

    5.4.5 Arrays

    +

    5.4.5 Arrays

    @@ -1594,7 +1594,7 @@ void pathname_set(char *value) { In the target language, the value can be set like a normal variable.

    -

    5.4.6 Creating read-only variables

    +

    5.4.6 Creating read-only variables

    @@ -1668,10 +1668,10 @@ generate a warning message. Simply change the directives to %immutable;%mutable; to silence the warning. Don't forget the extra semicolon!

    -

    5.4.7 Renaming and ignoring declarations

    +

    5.4.7 Renaming and ignoring declarations

    -

    5.4.7.1 Simple renaming of specific identifiers

    +

    5.4.7.1 Simple renaming of specific identifiers

    @@ -1769,7 +1769,7 @@ This directive is still supported, but it is deprecated and should probably be a directive is more powerful and better supports wrapping of raw header file information.

    -

    5.4.7.2 Advanced renaming support

    +

    5.4.7.2 Advanced renaming support

    @@ -1971,7 +1971,7 @@ are exactly equivalent and %rename can be used to selectively ignore multiple declarations using the previously described matching possibilities.

    -

    5.4.7.3 Limiting global renaming rules

    +

    5.4.7.3 Limiting global renaming rules

    @@ -2069,7 +2069,7 @@ wrap C++ overloaded functions and methods or C++ methods which use default argum

    -

    5.4.7.4 Ignoring everything then wrapping a few selected symbols

    +

    5.4.7.4 Ignoring everything then wrapping a few selected symbols

    @@ -2111,7 +2111,7 @@ members of the class, so when the chosen class is unignored, all of its methods -

    5.4.8 Default/optional arguments

    +

    5.4.8 Default/optional arguments

    @@ -2148,7 +2148,7 @@ Please refer to the section on def in the C++ chapter for further details.

    -

    5.4.9 Pointers to functions and callbacks

    +

    5.4.9 Pointers to functions and callbacks

    @@ -2301,7 +2301,7 @@ See the Typemaps chapter for more about typ and individual target language chapters for more on callbacks and the 'director' feature.

    -

    5.5 Structures and unions

    +

    5.5 Structures and unions

    @@ -2383,7 +2383,7 @@ delete_Vector(v) However, most of SWIG's language modules also provide a high-level interface that is more convenient. Keep reading.

    -

    5.5.1 Typedef and structures

    +

    5.5.1 Typedef and structures

    @@ -2429,7 +2429,7 @@ vector_struct, SWIG knows that this is the same as Vector and it generates the appropriate type-checking code.

    -

    5.5.2 Character strings and structures

    +

    5.5.2 Character strings and structures

    @@ -2476,7 +2476,7 @@ Note: If the -c++ option is used, new and delete are perform memory allocation.

    -

    5.5.3 Array members

    +

    5.5.3 Array members

    @@ -2498,7 +2498,7 @@ discussed in a later chapter. In many cases, the warning message is harmless.

    -

    5.5.4 Structure data members

    +

    5.5.4 Structure data members

    @@ -2604,7 +2604,7 @@ class, or union. This is unlikely to break existing code. However, if you need datatype is really a struct, simply use a forward struct declaration such as "struct Foo;".

    -

    5.5.5 C constructors and destructors

    +

    5.5.5 C constructors and destructors

    @@ -2693,7 +2693,7 @@ the target languages, and it is highly recommended you don't use them.

    -

    5.5.6 Adding member functions to C structures

    +

    5.5.6 Adding member functions to C structures

    @@ -2966,7 +2966,7 @@ be used to extend a structure with more than just methods, a more suitable directive name has been chosen.

    -

    5.5.7 Nested structures

    +

    5.5.7 Nested structures

    @@ -3050,7 +3050,7 @@ Finally, note that nesting is handled differently in C++ mode, see Nested classes.

    -

    5.5.8 Other things to note about structure wrapping

    +

    5.5.8 Other things to note about structure wrapping

    @@ -3112,7 +3112,7 @@ interface described here, most of SWIG's language modules use it in some way or another.

    -

    5.6 Code Insertion

    +

    5.6 Code Insertion

    @@ -3122,7 +3122,7 @@ additional C code to perform initialization or other operations. There are four common ways to insert code, but it's useful to know how the output of SWIG is structured first.

    -

    5.6.1 The output of SWIG

    +

    5.6.1 The output of SWIG

    @@ -3158,7 +3158,7 @@ the module upon loading. -

    5.6.2 Code insertion blocks

    +

    5.6.2 Code insertion blocks

    @@ -3236,7 +3236,7 @@ static Vector *new_Vector() { Vector *new_Vector(); -

    5.6.3 Inlined code blocks

    +

    5.6.3 Inlined code blocks

    @@ -3263,7 +3263,7 @@ declaration. Since the code inside an %inline %{ ... %} block is given to both the C compiler and SWIG, it is illegal to include any SWIG directives inside a %{ ... %} block.

    -

    5.6.4 Initialization blocks

    +

    5.6.4 Initialization blocks

    @@ -3278,7 +3278,7 @@ initialization on module loading, you could write this: %} -

    5.7 An Interface Building Strategy

    +

    5.7 An Interface Building Strategy

    @@ -3286,7 +3286,7 @@ This section describes the general approach for building interfaces with SWIG. The specifics related to a particular scripting language are found in later chapters.

    -

    5.7.1 Preparing a C program for SWIG

    +

    5.7.1 Preparing a C program for SWIG

    @@ -3340,7 +3340,7 @@ to the swig-devel mailing list or to SWIG bug tracker.

    -

    5.7.2 The SWIG interface file

    +

    5.7.2 The SWIG interface file

    @@ -3393,7 +3393,7 @@ The main advantage of this approach is minimal maintenance of an interface file In more complex projects, an interface file containing numerous %include and #include statements like this is one of the most common approaches to interface file design due to lower maintenance overhead.

    -

    5.7.3 Why use separate interface files?

    +

    5.7.3 Why use separate interface files?

    @@ -3422,7 +3422,7 @@ and immediately see what is available without having to dig it out of header files. -

    5.7.4 Getting the right header files

    +

    5.7.4 Getting the right header files

    @@ -3442,7 +3442,7 @@ include certain header files by using a %{,%} block like this: ... -

    5.7.5 What to do with main()

    +

    5.7.5 What to do with main()

    diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index d138073d9..1127a8ee8 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -6,7 +6,7 @@ -

    6 SWIG and C++

    +

    6 SWIG and C++

      @@ -75,7 +75,7 @@ how SWIG wraps ANSI C. Support for C++ builds upon ANSI C wrapping and that material will be useful in understanding this chapter.

      -

      6.1 Comments on C++ Wrapping

      +

      6.1 Comments on C++ Wrapping

      @@ -117,7 +117,7 @@ crossing language boundaries and provides many opportunities to shoot yourself in the foot. You will just have to be careful.

      -

      6.2 Approach

      +

      6.2 Approach

      @@ -158,7 +158,7 @@ proxy classes. More detailed coverage can be found in the documentation for each target language.

      -

      6.3 Supported C++ features

      +

      6.3 Supported C++ features

      @@ -197,7 +197,7 @@ in future releases. However, we make no promises. Also, submitting a bug repor good way to get problems fixed (wink).

      -

      6.4 Command line options and compilation

      +

      6.4 Command line options and compilation

      @@ -231,7 +231,7 @@ details. The SWIG Wiki also has further details. The -noproxy commandline option is recognised by many target languages and will generate just this interface as in earlier versions. -

      6.5 Proxy classes

      +

      6.5 Proxy classes

      @@ -243,7 +243,7 @@ wrapped by a Python proxy class. Or if you're building a Java module, each C++ class is wrapped by a Java proxy class.

      -

      6.5.1 Construction of proxy classes

      +

      6.5.1 Construction of proxy classes

      @@ -325,7 +325,7 @@ Whenever possible, proxies try to take advantage of language features that are s might include operator overloading, exception handling, and other features.

      -

      6.5.2 Resource management in proxies

      +

      6.5.2 Resource management in proxies

      @@ -479,7 +479,7 @@ every possible memory management problem. However, proxies do provide a mechani can be used (if necessary) to address some of the more tricky memory management problems.

      -

      6.5.3 Language specific details

      +

      6.5.3 Language specific details

      @@ -487,7 +487,7 @@ Language specific details on proxy classes are contained in the chapters describ chapter has merely introduced the topic in a very general way.

      -

      6.6 Simple C++ wrapping

      +

      6.6 Simple C++ wrapping

      @@ -520,7 +520,7 @@ To generate wrappers for this class, SWIG first reduces the class to a collectio accessor functions which are then used by the proxy classes.

      -

      6.6.1 Constructors and destructors

      +

      6.6.1 Constructors and destructors

      @@ -537,7 +537,7 @@ void delete_List(List *l) {

    -

    6.6.2 Default constructors, copy constructors and implicit destructors

    +

    6.6.2 Default constructors, copy constructors and implicit destructors

    @@ -686,7 +686,7 @@ leaks, and so it is strongly recommended to not use them.

    -

    6.6.3 When constructor wrappers aren't created

    +

    6.6.3 When constructor wrappers aren't created

    @@ -763,7 +763,7 @@ public: More information about %feature can be found in the Customization features chapter.

    -

    6.6.4 Copy constructors

    +

    6.6.4 Copy constructors

    @@ -865,7 +865,7 @@ constructor is set to new_CopyFoo(). This is the same as in older versions.

    -

    6.6.5 Member functions

    +

    6.6.5 Member functions

    @@ -891,7 +891,7 @@ wrapper functions. However, the name and calling convention of the low-level procedural wrappers match the accessor function prototype described above.

    -

    6.6.6 Static members

    +

    6.6.6 Static members

    @@ -901,7 +901,7 @@ transformations. For example, the static member function in the generated wrapper code.

    -

    6.6.7 Member data

    +

    6.6.7 Member data

    @@ -1093,7 +1093,7 @@ a few problems related to structure wrapping and some of SWIG's customization features.

    -

    6.7 Default arguments

    +

    6.7 Default arguments

    @@ -1199,7 +1199,7 @@ Keyword arguments are a language feature of some scripting languages, for exampl SWIG is unable to support kwargs when wrapping overloaded methods, so the default approach cannot be used.

    -

    6.8 Protection

    +

    6.8 Protection

    @@ -1219,7 +1219,7 @@ until you explicitly give a `public:' declaration (This is the same convention used by C++).

    -

    6.9 Enums and constants

    +

    6.9 Enums and constants

    @@ -1249,7 +1249,7 @@ Swig_STOUT = Swig::STOUT Members declared as const are wrapped as read-only members and do not create constants.

    -

    6.10 Friends

    +

    6.10 Friends

    @@ -1310,7 +1310,7 @@ namespace bar { and a wrapper for the method 'blah' will not be generated.

    -

    6.11 References and pointers

    +

    6.11 References and pointers

    @@ -1410,7 +1410,7 @@ templates and the STL. This was first added in SWIG-1.3.12.

    -

    6.12 Pass and return by value

    +

    6.12 Pass and return by value

    @@ -1514,7 +1514,7 @@ classes that don't define a default constructor. It is not used for C++ pointers or references.

    -

    6.13 Inheritance

    +

    6.13 Inheritance

    @@ -1700,7 +1700,7 @@ functions for virtual members that are already defined in a base class.

    -

    6.14 A brief discussion of multiple inheritance, pointers, and type checking

    +

    6.14 A brief discussion of multiple inheritance, pointers, and type checking

    @@ -1832,7 +1832,7 @@ int y = B_function((B *) pB); In practice, the pointer is held as an integral number in the target language proxy class.

    -

    6.15 Wrapping Overloaded Functions and Methods

    +

    6.15 Wrapping Overloaded Functions and Methods

    @@ -1895,7 +1895,7 @@ it might be used like this -

    6.15.1 Dispatch function generation

    +

    6.15.1 Dispatch function generation

    @@ -2020,7 +2020,7 @@ checked in the same order as they appear in this ranking. If you're still confused, don't worry about it---SWIG is probably doing the right thing.

    -

    6.15.2 Ambiguity in Overloading

    +

    6.15.2 Ambiguity in Overloading

    @@ -2138,7 +2138,7 @@ it means that the target language module has not yet implemented support for ove functions and methods. The only way to fix the problem is to read the next section.

    -

    6.15.3 Ambiguity resolution and renaming

    +

    6.15.3 Ambiguity resolution and renaming

    @@ -2567,7 +2567,7 @@ to wrapping methods with default arguments was introduced. -

    6.15.4 Comments on overloading

    +

    6.15.4 Comments on overloading

    @@ -2584,7 +2584,7 @@ As a general rule, statically typed languages like Java are able to provide more than dynamically typed languages like Perl, Python, Ruby, and Tcl.

    -

    6.16 Wrapping overloaded operators

    +

    6.16 Wrapping overloaded operators

    @@ -2768,7 +2768,7 @@ are ignored as well as conversion operators. -

    6.17 Class extension

    +

    6.17 Class extension

    @@ -2867,7 +2867,7 @@ be used to extend a structure with more than just methods, a more suitable directive name has been chosen.

    -

    6.18 Templates

    +

    6.18 Templates

    @@ -3701,7 +3701,7 @@ as the class name. For example: Similar changes apply to typemaps and other customization features.

    -

    6.19 Namespaces

    +

    6.19 Namespaces

    @@ -4150,7 +4150,7 @@ with any namespace awareness. In the future, language modules may or may not p more advanced namespace support.

    -

    6.19.1 The nspace feature for namespaces

    +

    6.19.1 The nspace feature for namespaces

    @@ -4231,7 +4231,7 @@ namespace MyWorld { Compatibility Note: The nspace feature was first introduced in SWIG-2.0.0.

    -

    6.20 Renaming templated types in namespaces

    +

    6.20 Renaming templated types in namespaces

    @@ -4309,7 +4309,7 @@ namespace Space { -

    6.21 Exception specifications

    +

    6.21 Exception specifications

    @@ -4360,7 +4360,7 @@ Consult the "Exception hand The next section details a way of simulating an exception specification or replacing an existing one.

    -

    6.22 Exception handling with %catches

    +

    6.22 Exception handling with %catches

    @@ -4410,7 +4410,7 @@ just a single catch handler for the base class, EBase will be generated

    -

    6.23 Pointers to Members

    +

    6.23 Pointers to Members

    @@ -4460,7 +4460,7 @@ when checking types. However, no such support is currently provided for member pointers.

    -

    6.24 Smart pointers and operator->()

    +

    6.24 Smart pointers and operator->()

    @@ -4672,7 +4672,7 @@ p = f.__deref__() # Raw pointer from operator-> Note: Smart pointer support was first added in SWIG-1.3.14.

    -

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

    +

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

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

    6.26 Using declarations and inheritance

    +

    6.26 Using declarations and inheritance

    @@ -5007,7 +5007,7 @@ public: -

    6.27 Nested classes

    +

    6.27 Nested classes

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

    -

    6.28 A brief rant about const-correctness

    +

    6.28 A brief rant about const-correctness

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

    -

    6.29 Where to go for more information

    +

    6.29 Where to go for more information

    diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 5a894d587..1f5876270 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -8,7 +8,7 @@ -

    39 SWIG and Scilab

    +

    39 SWIG and Scilab

      @@ -87,7 +87,7 @@ This chapter explains how to use SWIG for Scilab. After this introduction, you s

      -

      39.1 Preliminaries

      +

      39.1 Preliminaries

      @@ -104,7 +104,7 @@ SWIG for Scilab supports C language. C++ is partially supported. See 39.2 Running SWIG +

      39.2 Running SWIG

      @@ -138,7 +138,7 @@ Note: a code in an %inline section is both parsed and wrapped by SWIG,

      -

      39.2.1 Generating the module

      +

      39.2.1 Generating the module

      @@ -181,7 +181,7 @@ The swig executable has several other command line options you can use.

      -

      39.2.2 Building the module

      +

      39.2.2 Building the module

      @@ -201,7 +201,7 @@ $ gcc -shared example_wrap.o -o libexample.so Note: we supposed in this example that the path to the Scilab include directory is /usr/local/include/scilab (which is the case in a Debian environment), this should be changed for another environment.

      -

      39.2.3 Loading the module

      +

      39.2.3 Loading the module

      @@ -225,7 +225,7 @@ Link done. which means that Scilab has successfully loaded the shared library. The module functions and other symbols are now available in Scilab.

      -

      39.2.4 Using the module

      +

      39.2.4 Using the module

      @@ -259,7 +259,7 @@ ans = Note: for conciseness, we assume in the subsequent Scilab code examples that the modules have been beforehand built and loaded in Scilab.

      -

      39.2.5 Scilab command line options

      +

      39.2.5 Scilab command line options

      @@ -314,10 +314,10 @@ $ swig -scilab -help

    -

    39.3 A basic tour of C/C++ wrapping

    +

    39.3 A basic tour of C/C++ wrapping

    -

    39.3.1 Overview

    +

    39.3.1 Overview

    @@ -326,7 +326,7 @@ This means that functions, structs, classes, variables, etc... are interfaced th There are a few exceptions, such as constants and enumerations, which can be wrapped directly as Scilab variables.

    -

    39.3.2 Identifiers

    +

    39.3.2 Identifiers

    @@ -337,7 +337,7 @@ In Scilab 5.x, identifier names are composed of 24 characters maximum (this limi In these cases, the %rename directive can be used to choose a different Scilab name.

    -

    39.3.3 Functions

    +

    39.3.3 Functions

    @@ -368,7 +368,7 @@ ans = 24. -

    39.3.3.1 Argument passing

    +

    39.3.3.1 Argument passing

    @@ -421,7 +421,7 @@ In Scilab, parameters are passed by value. The output (and inout) parameters are 7. -

    39.3.3.2 Multiple output arguments

    +

    39.3.3.2 Multiple output arguments

    @@ -469,7 +469,7 @@ int divide(int n, int d, int q*, int *r) { -

    39.3.4 Global variables

    +

    39.3.4 Global variables

    @@ -538,10 +538,10 @@ It works the same:

    -

    39.3.5 Constants and enumerations

    +

    39.3.5 Constants and enumerations

    -

    39.3.5.1 Constants

    +

    39.3.5.1 Constants

    @@ -682,7 +682,7 @@ are mapped to Scilab variables, with the same name: 3.14 -

    39.3.5.2 Enumerations

    +

    39.3.5.2 Enumerations

    @@ -747,7 +747,7 @@ typedef enum { RED, BLUE, GREEN } color; -

    39.3.6 Pointers

    +

    39.3.6 Pointers

    @@ -789,7 +789,7 @@ These functions can be used in a natural way from Scilab: The user of a pointer is responsible for freeing it or, like in the example, closing any resources associated with it (just as is required in a C program).

    -

    39.3.6.1 Utility functions

    +

    39.3.6.1 Utility functions

    @@ -820,7 +820,7 @@ SWIG comes with two pointer utility functions: --> fclose(f); -

    39.3.6.2 Null pointers

    +

    39.3.6.2 Null pointers

    By default, Scilab does not provide a way to test or create null pointers. @@ -836,7 +836,7 @@ But it is possible to have a null pointer by using the previous functions SW -

    39.3.7 Structures

    +

    39.3.7 Structures

    @@ -931,7 +931,7 @@ ans = -

    39.3.8 C++ classes

    +

    39.3.8 C++ classes

    @@ -981,7 +981,7 @@ ans = --> delete_Point(p2); -

    39.3.9 C++ inheritance

    +

    39.3.9 C++ inheritance

    @@ -1056,7 +1056,7 @@ But we can use either use the get_perimeter() function of the parent cl 18.84 -

    39.3.10 Pointers, references, values, and arrays

    +

    39.3.10 Pointers, references, values, and arrays

    @@ -1114,7 +1114,7 @@ All these functions will return a pointer to an instance of Foo. As the function spam7 returns a value, new instance of Foo has to be allocated, and a pointer on this instance is returned.

    -

    39.3.11 C++ templates

    +

    39.3.11 C++ templates

    @@ -1174,7 +1174,7 @@ Then in Scilab: More details on template support can be found in the templates documentation.

    -

    39.3.12 C++ operators

    +

    39.3.12 C++ operators

    @@ -1227,7 +1227,7 @@ private: -

    39.3.13 C++ namespaces

    +

    39.3.13 C++ namespaces

    @@ -1305,7 +1305,7 @@ Note: the nspace feature is

    -

    39.3.14 C++ exceptions

    +

    39.3.14 C++ exceptions

    @@ -1388,17 +1388,17 @@ More complex or custom exception types require specific exception typemaps to be See the SWIG C++ documentation for more details.

    -

    39.3.15 C++ STL

    +

    39.3.15 C++ STL

    The Standard Template Library (STL) is partially supported. See STL for more details.

    -

    39.4 Type mappings and libraries

    +

    39.4 Type mappings and libraries

    -

    39.4.1 Default primitive type mappings

    +

    39.4.1 Default primitive type mappings

    @@ -1447,7 +1447,7 @@ The default behaviour is for SWIG to generate code that will give a runtime erro -

    39.4.2 Default type mappings for non-primitive types

    +

    39.4.2 Default type mappings for non-primitive types

    @@ -1455,7 +1455,7 @@ The default mapped type for C/C++ non-primitive types is the Scilab pointer, for

    -

    39.4.3 Arrays

    +

    39.4.3 Arrays

    @@ -1510,7 +1510,7 @@ void printArray(int values[], int len) { [ 0 1 2 3 ] -

    39.4.4 Pointer-to-pointers

    +

    39.4.4 Pointer-to-pointers

    @@ -1583,7 +1583,7 @@ void print_matrix(double **M, int nbRows, int nbCols) { -

    39.4.5 Matrices

    +

    39.4.5 Matrices

    @@ -1676,7 +1676,7 @@ The remarks made earlier for arrays also apply here:

  • There is no control while converting double values to integers, double values are truncated without any checking or warning.
  • -

    39.4.6 STL

    +

    39.4.6 STL

    @@ -1876,7 +1876,7 @@ ans = --> delete_PersonPtrSet(p); -

    39.5 Module initialization

    +

    39.5 Module initialization

    @@ -1900,7 +1900,7 @@ For example, to initialize the module example: --> example_Init(); -

    39.6 Building modes

    +

    39.6 Building modes

    @@ -1915,7 +1915,7 @@ To produce a dynamic module, when generating the wrapper, there are two possibil

  • the builder mode. In this mode, Scilab is responsible of building. -

    39.6.1 No-builder mode

    +

    39.6.1 No-builder mode

    @@ -1928,7 +1928,7 @@ This mode is the best option to use when you have to integrate the module build

    -

    39.6.2 Builder mode

    +

    39.6.2 Builder mode

    @@ -1968,14 +1968,14 @@ The command is: $ swig -scilab -builder -buildercflags -I/opt/foo/include -builderldflags "-L/opt/foo/lib -lfoo" -buildersources baa1.cxx,baa2.cxx example.i -

    39.7 Generated scripts

    +

    39.7 Generated scripts

    In this part we give some details about the generated Scilab scripts.

    -

    39.7.1 Builder script

    +

    39.7.1 Builder script

    @@ -2000,7 +2000,7 @@ ilib_build(ilib_name,table,files,libs);

  • table: two column string matrix containing a table of pairs of 'scilab function name', 'C function name'.
  • -

    39.7.2 Loader script

    +

    39.7.2 Loader script

    @@ -2039,7 +2039,7 @@ clear get_file_path; -

    39.8 Other resources

    +

    39.8 Other resources

      diff --git a/Doc/Manual/Scripting.html b/Doc/Manual/Scripting.html index c714fa0d7..9e5e85e7d 100644 --- a/Doc/Manual/Scripting.html +++ b/Doc/Manual/Scripting.html @@ -6,7 +6,7 @@ -

      4 Scripting Languages

      +

      4 Scripting Languages

        @@ -37,7 +37,7 @@ programming and the mechanisms by which scripting language interpreters access C and C++ code.

        -

        4.1 The two language view of the world

        +

        4.1 The two language view of the world

        @@ -68,7 +68,7 @@ languages can be used for rapid prototyping, interactive debugging, scripting, and access to high-level data structures such associative arrays.

        -

        4.2 How does a scripting language talk to C?

        +

        4.2 How does a scripting language talk to C?

        @@ -93,7 +93,7 @@ function, arguments, and so forth. The next few sections illustrate the process.

        -

        4.2.1 Wrapper functions

        +

        4.2.1 Wrapper functions

        @@ -165,7 +165,7 @@ Python. Both require special wrappers to be written and both need additional initialization code. Only the specific details are different.

        -

        4.2.2 Variable linking

        +

        4.2.2 Variable linking

        @@ -201,7 +201,7 @@ typing $Foo = 4 would call the underlying set function to change the value.

        -

        4.2.3 Constants

        +

        4.2.3 Constants

        @@ -222,7 +222,7 @@ functions for creating variables so installing constants is usually a trivial exercise.

        -

        4.2.4 Structures and classes

        +

        4.2.4 Structures and classes

        @@ -283,7 +283,7 @@ internals of an object, the interpreter does not need to know anything about the actual representation of a Vector.

        -

        4.2.5 Proxy classes

        +

        4.2.5 Proxy classes

        @@ -345,7 +345,7 @@ affect both objects equally and for all practical purposes, it appears as if you are simply manipulating a C/C++ object.

        -

        4.3 Building scripting language extensions

        +

        4.3 Building scripting language extensions

        @@ -358,7 +358,7 @@ recompile the scripting language interpreter with your extensions added to it.

        -

        4.3.1 Shared libraries and dynamic loading

        +

        4.3.1 Shared libraries and dynamic loading

        @@ -400,7 +400,7 @@ changing the link line to the following :

        c++ -shared example.o example_wrap.o -o example.so
      -

      4.3.2 Linking with shared libraries

      +

      4.3.2 Linking with shared libraries

      @@ -447,7 +447,7 @@ the path using linker options instead.

    -

    4.3.3 Static linking

    +

    4.3.3 Static linking

    diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index 874a5325a..a3e6ae99a 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -6,7 +6,7 @@ -

    40 SWIG and Tcl

    +

    40 SWIG and Tcl

      @@ -83,7 +83,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but this is no longer supported.

      -

      40.1 Preliminaries

      +

      40.1 Preliminaries

      @@ -109,7 +109,7 @@ build a Tcl extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

      -

      40.1.1 Getting the right header files

      +

      40.1.1 Getting the right header files

      @@ -127,7 +127,7 @@ this is the case, you should probably make a symbolic link so that tcl.h -

      40.1.2 Compiling a dynamic module

      +

      40.1.2 Compiling a dynamic module

      @@ -163,7 +163,7 @@ The name of the module is specified using the %module directive or the -module command line option.

      -

      40.1.3 Static linking

      +

      40.1.3 Static linking

      @@ -229,7 +229,7 @@ minimal in most situations (and quite frankly not worth the extra hassle in the opinion of this author).

      -

      40.1.4 Using your module

      +

      40.1.4 Using your module

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

      -

      40.1.5 Compilation of C++ extensions

      +

      40.1.5 Compilation of C++ extensions

      @@ -440,7 +440,7 @@ erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

      -

      40.1.6 Compiling for 64-bit platforms

      +

      40.1.6 Compiling for 64-bit platforms

      @@ -467,7 +467,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

      -

      40.1.7 Setting a package prefix

      +

      40.1.7 Setting a package prefix

      @@ -486,7 +486,7 @@ option will append the prefix to the name when creating a command and call it "Foo_bar".

      -

      40.1.8 Using namespaces

      +

      40.1.8 Using namespaces

      @@ -508,7 +508,7 @@ When the -namespace option is used, objects in the module are always accessed with the namespace name such as Foo::bar.

      -

      40.2 Building Tcl/Tk Extensions under Windows 95/NT

      +

      40.2 Building Tcl/Tk Extensions under Windows 95/NT

      @@ -519,7 +519,7 @@ covers the process of using SWIG with Microsoft Visual C++. although the procedure may be similar with other compilers.

      -

      40.2.1 Running SWIG from Developer Studio

      +

      40.2.1 Running SWIG from Developer Studio

      @@ -577,7 +577,7 @@ MSDOS > tclsh80 %

    -

    40.2.2 Using NMAKE

    +

    40.2.2 Using NMAKE

    @@ -640,7 +640,7 @@ to get you started. With a little practice, you'll be making lots of Tcl extensions.

    -

    40.3 A tour of basic C/C++ wrapping

    +

    40.3 A tour of basic C/C++ wrapping

    @@ -651,7 +651,7 @@ classes. This section briefly covers the essential aspects of this wrapping.

    -

    40.3.1 Modules

    +

    40.3.1 Modules

    @@ -685,7 +685,7 @@ To fix this, supply an extra argument to load like this: -

    40.3.2 Functions

    +

    40.3.2 Functions

    @@ -710,7 +710,7 @@ like you think it does: % -

    40.3.3 Global variables

    +

    40.3.3 Global variables

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

    40.3.4 Constants and enums

    +

    40.3.4 Constants and enums

    @@ -874,7 +874,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l conversion. This allows the global statement to be omitted.

    -

    40.3.5 Pointers

    +

    40.3.5 Pointers

    @@ -970,7 +970,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return None if the conversion can't be performed.

    -

    40.3.6 Structures

    +

    40.3.6 Structures

    @@ -1252,7 +1252,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the memory management section that appears shortly.

    -

    40.3.7 C++ classes

    +

    40.3.7 C++ classes

    @@ -1319,7 +1319,7 @@ In Tcl, the static member is accessed as follows: -

    40.3.8 C++ inheritance

    +

    40.3.8 C++ inheritance

    @@ -1368,7 +1368,7 @@ For instance: It is safe to use multiple inheritance with SWIG.

    -

    40.3.9 Pointers, references, values, and arrays

    +

    40.3.9 Pointers, references, values, and arrays

    @@ -1422,7 +1422,7 @@ to hold the result and a pointer is returned (Tcl will release this memory when the return value is garbage collected).

    -

    40.3.10 C++ overloaded functions

    +

    40.3.10 C++ overloaded functions

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

    -

    40.3.11 C++ operators

    +

    40.3.11 C++ operators

    @@ -1647,7 +1647,7 @@ There are ways to make this operator appear as part of the class using the % Keep reading.

    -

    40.3.12 C++ namespaces

    +

    40.3.12 C++ namespaces

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

    -

    40.3.13 C++ templates

    +

    40.3.13 C++ templates

    @@ -1763,7 +1763,7 @@ More details can be found in the SWIG and C++ -

    40.3.14 C++ Smart Pointers

    +

    40.3.14 C++ Smart Pointers

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

    40.4 Further details on the Tcl class interface

    +

    40.4 Further details on the Tcl class interface

    @@ -1860,7 +1860,7 @@ of low-level details were omitted. This section provides a brief overview of how the proxy classes work.

    -

    40.4.1 Proxy classes

    +

    40.4.1 Proxy classes

    @@ -1925,7 +1925,7 @@ function. This allows objects to be encapsulated objects that look a lot like as shown in the last section.

    -

    40.4.2 Memory management

    +

    40.4.2 Memory management

    @@ -2113,7 +2113,7 @@ typemaps--an advanced topic discussed later.

    -

    40.5 Input and output parameters

    +

    40.5 Input and output parameters

    @@ -2301,7 +2301,7 @@ set c [lindex $dim 1] -

    40.6 Exception handling

    +

    40.6 Exception handling

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

    -

    40.7 Typemaps

    +

    40.7 Typemaps

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

    -

    40.7.1 What is a typemap?

    +

    40.7.1 What is a typemap?

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

    40.7.2 Tcl typemaps

    +

    40.7.2 Tcl typemaps

    @@ -2707,7 +2707,7 @@ Initialize an argument to a value before any conversions occur. Examples of these methods will appear shortly.

    -

    40.7.3 Typemap variables

    +

    40.7.3 Typemap variables

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

    40.7.4 Converting a Tcl list to a char **

    +

    40.7.4 Converting a Tcl list to a char **

    @@ -2840,7 +2840,7 @@ argv[2] = Larry 3 -

    40.7.5 Returning values in arguments

    +

    40.7.5 Returning values in arguments

    @@ -2882,7 +2882,7 @@ result, a Tcl function using these typemaps will work like this : % -

    40.7.6 Useful functions

    +

    40.7.6 Useful functions

    @@ -2958,7 +2958,7 @@ int Tcl_IsShared(Tcl_Obj *obj); -

    40.7.7 Standard typemaps

    +

    40.7.7 Standard typemaps

    @@ -3043,7 +3043,7 @@ work) -

    40.7.8 Pointer handling

    +

    40.7.8 Pointer handling

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

    40.8 Turning a SWIG module into a Tcl Package.

    +

    40.8 Turning a SWIG module into a Tcl Package.

    @@ -3191,7 +3191,7 @@ As a final note, most SWIG examples do not yet use the to use the load command instead.

    -

    40.9 Building new kinds of Tcl interfaces (in Tcl)

    +

    40.9 Building new kinds of Tcl interfaces (in Tcl)

    @@ -3290,7 +3290,7 @@ danger of blowing something up (although it is easily accomplished with an out of bounds array access).

    -

    40.9.1 Proxy classes

    +

    40.9.1 Proxy classes

    @@ -3411,7 +3411,7 @@ short, but clever Tcl script can be combined with SWIG to do many interesting things.

    -

    40.10 Tcl/Tk Stubs

    +

    40.10 Tcl/Tk Stubs

    diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 3d6abf88e..770604684 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -6,7 +6,7 @@ -

    11 Typemaps

    +

    11 Typemaps

      @@ -97,7 +97,7 @@ -

      11.1 Introduction

      +

      11.1 Introduction

      @@ -114,7 +114,7 @@ to re-read the earlier chapters if you have found your way to this chapter with only a vague idea of what SWIG already does by default.

      -

      11.1.1 Type conversion

      +

      11.1.1 Type conversion

      @@ -207,7 +207,7 @@ to read the extension documentation for your favorite language to know how it works (an exercise left to the reader).

      -

      11.1.2 Typemaps

      +

      11.1.2 Typemaps

      @@ -308,7 +308,7 @@ parts of the generated wrapper functions. Because arbitrary code can be insert possible to completely change the way in which values are converted.

      -

      11.1.3 Pattern matching

      +

      11.1.3 Pattern matching

      @@ -410,7 +410,7 @@ In this case, a single input object is expanded into a pair of C arguments. Thi provides a hint to the unusual variable naming scheme involving $1, $2, and so forth.

      -

      11.1.4 Reusing typemaps

      +

      11.1.4 Reusing typemaps

      @@ -466,7 +466,7 @@ typedef int size_t; then SWIG already knows that the int typemaps apply. You don't have to do anything.

      -

      11.1.5 What can be done with typemaps?

      +

      11.1.5 What can be done with typemaps?

      @@ -578,7 +578,7 @@ typemaps that expand upon this list. For example, the Java module defines a var aspects of the Java bindings. Consult language specific documentation for further details.

      -

      11.1.6 What can't be done with typemaps?

      +

      11.1.6 What can't be done with typemaps?

      @@ -641,7 +641,7 @@ void wrap_foo(char *s, int x) {

    -

    11.1.7 Similarities to Aspect Oriented Programming

    +

    11.1.7 Similarities to Aspect Oriented Programming

    @@ -659,7 +659,7 @@ SWIG can also be viewed as has having a second set of aspects based around %exception are also cross-cutting concerns as they encapsulate code that can be used to add logging or exception handling to any function.

    -

    11.1.8 The rest of this chapter

    +

    11.1.8 The rest of this chapter

    @@ -679,14 +679,14 @@ of "The C Programming Language" by Kernighan and Ritchie or "The C++ Programming Language" by Stroustrup before going any further.

    -

    11.2 Typemap specifications

    +

    11.2 Typemap specifications

    This section describes the behavior of the %typemap directive itself.

    -

    11.2.1 Defining a typemap

    +

    11.2.1 Defining a typemap

    @@ -799,7 +799,7 @@ Admittedly, it's not the most readable syntax at first glance. However, the pur individual pieces will become clear.

    -

    11.2.2 Typemap scope

    +

    11.2.2 Typemap scope

    @@ -849,7 +849,7 @@ class Foo { -

    11.2.3 Copying a typemap

    +

    11.2.3 Copying a typemap

    @@ -907,7 +907,7 @@ The patterns for %apply follow the same rules as for %typemap. -

    11.2.4 Deleting a typemap

    +

    11.2.4 Deleting a typemap

    @@ -940,7 +940,7 @@ For example: after the clear operation.

    -

    11.2.5 Placement of typemaps

    +

    11.2.5 Placement of typemaps

    @@ -1020,7 +1020,7 @@ It should be noted that for scoping to work, SWIG has to know that stringclass string.

    -

    11.3 Pattern matching rules

    +

    11.3 Pattern matching rules

    @@ -1028,7 +1028,7 @@ The section describes the pattern matching rules by which C/C++ datatypes are as The matching rules can be observed in practice by using the debugging options also described.

    -

    11.3.1 Basic matching rules

    +

    11.3.1 Basic matching rules

    @@ -1127,7 +1127,7 @@ void F(int x[1000]); // int [ANY] rule (typemap 5) stripped all qualifiers in one step.

    -

    11.3.2 Typedef reductions matching

    +

    11.3.2 Typedef reductions matching

    @@ -1302,7 +1302,7 @@ void go(Struct aStruct); -

    11.3.3 Default typemap matching rules

    +

    11.3.3 Default typemap matching rules

    @@ -1440,7 +1440,7 @@ Finally the best way to view the typemap matching rules in action is via the -

    11.3.4 Multi-arguments typemaps

    +

    11.3.4 Multi-arguments typemaps

    @@ -1470,7 +1470,7 @@ but all subsequent arguments must match exactly.

    -

    11.3.5 Matching rules compared to C++ templates

    +

    11.3.5 Matching rules compared to C++ templates

    @@ -1629,7 +1629,7 @@ are similar to those for specialized template handling.

    -

    11.3.6 Debugging typemap pattern matching

    +

    11.3.6 Debugging typemap pattern matching

    @@ -1842,7 +1842,7 @@ Also the types may be displayed slightly differently - char const * and -

    11.4 Code generation rules

    +

    11.4 Code generation rules

    @@ -1850,7 +1850,7 @@ This section describes rules by which typemap code is inserted into the generated wrapper code.

    -

    11.4.1 Scope

    +

    11.4.1 Scope

    @@ -1928,7 +1928,7 @@ a block scope when it is emitted. This sometimes results in a less complicated Note that only the third of the three typemaps have the typemap code passed through the SWIG preprocessor.

    -

    11.4.2 Declaring new local variables

    +

    11.4.2 Declaring new local variables

    @@ -2095,7 +2095,7 @@ each type must have its own local variable declaration. -

    11.4.3 Special variables

    +

    11.4.3 Special variables

    @@ -2347,7 +2347,7 @@ Another approach, which only works for arrays is to use the $1_basetype -

    11.4.4 Special variable macros

    +

    11.4.4 Special variable macros

    @@ -2359,7 +2359,7 @@ it is done during the SWIG parsing/compilation stages. The following special variable macros are available across all language modules.

    -

    11.4.4.1 $descriptor(type)

    +

    11.4.4.1 $descriptor(type)

    @@ -2370,7 +2370,7 @@ For example, $descriptor(std::vector<int> *) will expand into Run-time type checker usage section.

    -

    11.4.4.2 $typemap(method, typepattern)

    +

    11.4.4.2 $typemap(method, typepattern)

    @@ -2428,7 +2428,7 @@ The result is the following expansion -

    11.4.5 Special variables and typemap attributes

    +

    11.4.5 Special variables and typemap attributes

    @@ -2455,7 +2455,7 @@ is equivalent to the following as $*1_ltype expands to unsigned int -

    11.4.6 Special variables combined with special variable macros

    +

    11.4.6 Special variables combined with special variable macros

    @@ -2497,7 +2497,7 @@ which then expands to: -

    11.5 Common typemap methods

    +

    11.5 Common typemap methods

    @@ -2505,7 +2505,7 @@ The set of typemaps recognized by a language module may vary. However, the following typemap methods are nearly universal:

    -

    11.5.1 "in" typemap

    +

    11.5.1 "in" typemap

    @@ -2565,7 +2565,7 @@ Usually numinputs is not specified, whereupon the default value is 1, t is the same as the old "ignore" typemap.

    -

    11.5.2 "typecheck" typemap

    +

    11.5.2 "typecheck" typemap

    @@ -2591,7 +2591,7 @@ If you define new "in" typemaps and your program uses overloaded method "typecheck" typemaps. More details about this follow in the Typemaps and overloading section.

    -

    11.5.3 "out" typemap

    +

    11.5.3 "out" typemap

    @@ -2622,7 +2622,7 @@ $symname - Name of function/method being wrapped The "out" typemap supports an optional attribute flag called "optimal". This is for code optimisation and is detailed in the Optimal code generation when returning by value section.

    -

    11.5.4 "arginit" typemap

    +

    11.5.4 "arginit" typemap

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

    11.5.5 "default" typemap

    +

    11.5.5 "default" typemap

    @@ -2674,7 +2674,7 @@ See the Default/optional arguments sec for further information on default argument wrapping.

    -

    11.5.6 "check" typemap

    +

    11.5.6 "check" typemap

    @@ -2693,7 +2693,7 @@ converted. For example: -

    11.5.7 "argout" typemap

    +

    11.5.7 "argout" typemap

    @@ -2739,7 +2739,7 @@ return values are often appended to return value of the function. See the typemaps.i library file for examples.

    -

    11.5.8 "freearg" typemap

    +

    11.5.8 "freearg" typemap

    @@ -2772,7 +2772,7 @@ be used in other typemaps whenever a wrapper function needs to abort prematurely.

    -

    11.5.9 "newfree" typemap

    +

    11.5.9 "newfree" typemap

    @@ -2801,7 +2801,7 @@ string *foo(); See Object ownership and %newobject for further details.

    -

    11.5.10 "memberin" typemap

    +

    11.5.10 "memberin" typemap

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

    -

    11.5.11 "varin" typemap

    +

    11.5.11 "varin" typemap

    @@ -2831,7 +2831,7 @@ The "varin" typemap is used to convert objects in the target language to C for t purposes of assigning to a C/C++ global variable. This is implementation specific.

    -

    11.5.12 "varout" typemap

    +

    11.5.12 "varout" typemap

    @@ -2839,7 +2839,7 @@ The "varout" typemap is used to convert a C/C++ object to an object in the targe language when reading a C/C++ global variable. This is implementation specific.

    -

    11.5.13 "throws" typemap

    +

    11.5.13 "throws" typemap

    @@ -2885,7 +2885,7 @@ Note that if your methods do not have an exception specification yet they do thr For a neat way to handle these, see the Exception handling with %exception section.

    -

    11.6 Some typemap examples

    +

    11.6 Some typemap examples

    @@ -2893,7 +2893,7 @@ This section contains a few examples. Consult language module documentation for more examples.

    -

    11.6.1 Typemaps for arrays

    +

    11.6.1 Typemaps for arrays

    @@ -3152,7 +3152,7 @@ Now, you will find that member access is quite nice: useless and has since been eliminated. To return structure members, simply use the "out" typemap.

    -

    11.6.2 Implementing constraints with typemaps

    +

    11.6.2 Implementing constraints with typemaps

    @@ -3200,7 +3200,7 @@ a NULL pointer. As a result, SWIG can often prevent a potential segmentation faults or other run-time problems by raising an exception rather than blindly passing values to the underlying C/C++ program.

    -

    11.7 Typemaps for multiple target languages

    +

    11.7 Typemaps for multiple target languages

    @@ -3230,7 +3230,7 @@ The example above also shows a common approach of issuing a warning for an as ye %typemap(ruby,in) int "$1 = NUM2INT($input);".

    -

    11.8 Optimal code generation when returning by value

    +

    11.8 Optimal code generation when returning by value

    @@ -3419,7 +3419,7 @@ example.i:7: Warning 475: optimal attribute usage in the out typemap. However, it doesn't always get it right, for example when $1 is within some commented out code.

    -

    11.9 Multi-argument typemaps

    +

    11.9 Multi-argument typemaps

    @@ -3686,7 +3686,7 @@ with non-consecutive C/C++ arguments; a workaround such as a helper function re- the arguments to make them consecutive will need to be written.

    -

    11.10 Typemap warnings

    +

    11.10 Typemap warnings

    @@ -3695,7 +3695,7 @@ See the information in the issuing warnings

    -

    11.11 Typemap fragments

    +

    11.11 Typemap fragments

    @@ -3948,7 +3948,7 @@ fragment usage unless a desire to really get to grips with some powerful but tricky macro and fragment usage that is used in parts of the SWIG typemap library.

    -

    11.11.1 Fragment type specialization

    +

    11.11.1 Fragment type specialization

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

    11.11.2 Fragments and automatic typemap specialization

    +

    11.11.2 Fragments and automatic typemap specialization

    @@ -4027,7 +4027,7 @@ The interested (or very brave) reader can take a look at the fragments.swg file

    -

    11.12 The run-time type checker

    +

    11.12 The run-time type checker

    @@ -4053,7 +4053,7 @@ language modules.

  • Modules can be unloaded from the type system.
  • -

    11.12.1 Implementation

    +

    11.12.1 Implementation

    @@ -4239,7 +4239,7 @@ structures rather than creating new ones. These swig_module_info structures are chained together in a circularly linked list.

    -

    11.12.2 Usage

    +

    11.12.2 Usage

    This section covers how to use these functions from typemaps. To learn how to @@ -4333,7 +4333,7 @@ probably just look at the output of SWIG to get a better sense for how types are managed.

    -

    11.13 Typemaps and overloading

    +

    11.13 Typemaps and overloading

    @@ -4664,7 +4664,7 @@ Subsequent "in" typemaps would then perform more extensive type-checking. -

    11.14 More about %apply and %clear

    +

    11.14 More about %apply and %clear

    @@ -4750,7 +4750,7 @@ example: -

    11.15 Passing data between typemaps

    +

    11.15 Passing data between typemaps

    @@ -4787,7 +4787,7 @@ sure that the typemaps sharing information have exactly the same types and names

    -

    11.16 C++ "this" pointer

    +

    11.16 C++ "this" pointer

    @@ -4847,7 +4847,7 @@ will also match the typemap. One work around is to create an interface file tha the method, but gives the argument a name other than self.

    -

    11.17 Where to go for more information?

    +

    11.17 Where to go for more information?

    diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index 360bbaa12..c2f55b019 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -6,7 +6,7 @@ -

    14 Variable Length Arguments

    +

    14 Variable Length Arguments

      @@ -42,7 +42,7 @@ added in SWIG-1.3.12. Most other wrapper generation tools have wisely chosen to avoid this issue.

      -

      14.1 Introduction

      +

      14.1 Introduction

      @@ -139,7 +139,7 @@ List make_list(const char *s, ...) {

    -

    14.2 The Problem

    +

    14.2 The Problem

    @@ -232,7 +232,7 @@ can also support real varargs wrapping (with stack-frame manipulation) if you are willing to get hands dirty. Keep reading.

    -

    14.3 Default varargs support

    +

    14.3 Default varargs support

    @@ -301,7 +301,7 @@ Read on for further solutions.

    -

    14.4 Argument replacement using %varargs

    +

    14.4 Argument replacement using %varargs

    @@ -412,7 +412,7 @@ mixed argument types such as printf(). Providing general purpose wrappers to such functions presents special problems (covered shortly).

    -

    14.5 Varargs and typemaps

    +

    14.5 Varargs and typemaps

    @@ -589,7 +589,7 @@ really want to elevate your guru status and increase your job security, continue to the next section.

    -

    14.6 Varargs wrapping with libffi

    +

    14.6 Varargs wrapping with libffi

    @@ -841,7 +841,7 @@ provide an argument number for the first extra argument. This can be used to in values. Please consult the chapter on each language module for more details.

    -

    14.7 Wrapping of va_list

    +

    14.7 Wrapping of va_list

    @@ -895,7 +895,7 @@ int my_vprintf(const char *fmt, ...) { -

    14.8 C++ Issues

    +

    14.8 C++ Issues

    @@ -964,7 +964,7 @@ design or to provide an alternative interface using a helper function than it is fully general wrapper to a varargs C++ member function.

    -

    14.9 Discussion

    +

    14.9 Discussion

    diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 2336120d3..92ec5000c 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -6,7 +6,7 @@ -

    15 Warning Messages

    +

    15 Warning Messages

      @@ -35,7 +35,7 @@ -

      15.1 Introduction

      +

      15.1 Introduction

      @@ -55,7 +55,7 @@ where the generated wrapper code will probably compile, but it may not work like you expect.

      -

      15.2 Warning message suppression

      +

      15.2 Warning message suppression

      @@ -147,7 +147,7 @@ your interface. Ignore the warning messages at your own peril.

      -

      15.3 Enabling extra warnings

      +

      15.3 Enabling extra warnings

      @@ -220,7 +220,7 @@ that is, any warnings suppressed or added in %warnfilter, #pragma S or the -w option.

      -

      15.4 Issuing a warning message

      +

      15.4 Issuing a warning message

      @@ -274,7 +274,7 @@ example.i:24: Warning 901: You are really going to regret this usage of blah * s

    -

    15.5 Symbolic symbols

    +

    15.5 Symbolic symbols

    @@ -309,7 +309,7 @@ or -

    15.6 Commentary

    +

    15.6 Commentary

    @@ -326,7 +326,7 @@ no obvious recovery. There is no mechanism for suppressing error messages.

    -

    15.7 Warnings as errors

    +

    15.7 Warnings as errors

    @@ -335,7 +335,7 @@ option. This will cause SWIG to exit with a non successful exit code if a warning is encountered.

    -

    15.8 Message output format

    +

    15.8 Message output format

    @@ -354,10 +354,10 @@ $ swig -python -Fmicrosoft example.i example.i(4) : Syntax error in input(1). -

    15.9 Warning number reference

    +

    15.9 Warning number reference

    -

    15.9.1 Deprecated features (100-199)

    +

    15.9.1 Deprecated features (100-199)

      @@ -385,7 +385,7 @@ example.i(4) : Syntax error in input(1).
    • 126. The 'nestedworkaround' feature is deprecated.
    -

    15.9.2 Preprocessor (200-299)

    +

    15.9.2 Preprocessor (200-299)

      @@ -397,7 +397,7 @@ example.i(4) : Syntax error in input(1).
    • 206. Unexpected tokens after #directive directive.
    -

    15.9.3 C/C++ Parser (300-399)

    +

    15.9.3 C/C++ Parser (300-399)

      @@ -474,7 +474,7 @@ example.i(4) : Syntax error in input(1).
    • 395. operator delete[] ignored.
    -

    15.9.4 Types and typemaps (400-499)

    +

    15.9.4 Types and typemaps (400-499)

      @@ -505,7 +505,7 @@ example.i(4) : Syntax error in input(1). -

      15.9.5 Code generation (500-599)

      +

      15.9.5 Code generation (500-599)

        @@ -534,7 +534,7 @@ example.i(4) : Syntax error in input(1).
      • 523. Use of an illegal destructor name 'name' in %extend is deprecated, the destructor name should be 'name'.
      -

      15.9.6 Language module specific (700-899)

      +

      15.9.6 Language module specific (700-899)

        @@ -585,14 +585,14 @@ example.i(4) : Syntax error in input(1).
      • 871. Unrecognized pragma pragma. (Php).
      -

      15.9.7 User defined (900-999)

      +

      15.9.7 User defined (900-999)

      These numbers can be used by your own application.

      -

      15.10 History

      +

      15.10 History

      diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index d85737e52..fecdf48ed 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -6,7 +6,7 @@ -

      3 Getting started on Windows

      +

      3 Getting started on Windows

        @@ -52,7 +52,7 @@ Usage within the Unix like environments MinGW and Cygwin is also detailed.

        -

        3.1 Installation on Windows

        +

        3.1 Installation on Windows

        @@ -63,7 +63,7 @@ SWIG does not come with the usual Windows type installation program, however it

      • Set environment variables as described in the SWIG Windows Examples section in order to run examples using Visual C++.
      -

      3.1.1 Windows Executable

      +

      3.1.1 Windows Executable

      @@ -72,7 +72,7 @@ If you want to build your own swig.exe have a look at 3.2 SWIG Windows Examples +

      3.2 SWIG Windows Examples

      @@ -87,7 +87,7 @@ Alternatively run the examples using Cygwin More information on each of the examples is available with the examples distributed with SWIG (Examples/index.html). -

      3.2.1 Instructions for using the Examples with Visual Studio

      +

      3.2.1 Instructions for using the Examples with Visual Studio

      @@ -105,7 +105,7 @@ If you don't want to use environment variables then change all occurrences of th If you are interested in how the project files are set up there is explanatory information in some of the language module's documentation.

      -

      3.2.1.1 C#

      +

      3.2.1.1 C#

      @@ -115,7 +115,7 @@ The accompanying C# and C++ project files are automatically used by the solution

      -

      3.2.1.2 Java

      +

      3.2.1.2 Java

      @@ -129,7 +129,7 @@ JAVA_BIN: D:\jdk1.3\bin

      -

      3.2.1.3 Perl

      +

      3.2.1.3 Perl

      @@ -143,7 +143,7 @@ PERL5_LIB: D:\nsPerl5.004_04\lib\CORE\perl.lib

      -

      3.2.1.4 Python

      +

      3.2.1.4 Python

      @@ -157,7 +157,7 @@ PYTHON_LIB: D:\python21\libs\python21.lib

      -

      3.2.1.5 TCL

      +

      3.2.1.5 TCL

      @@ -171,7 +171,7 @@ TCL_LIB: D:\tcl\lib\tcl83.lib

      -

      3.2.1.6 R

      +

      3.2.1.6 R

      @@ -185,7 +185,7 @@ R_LIB: C:\Program Files\R\R-2.5.1\bin\Rdll.lib

      -

      3.2.1.7 Ruby

      +

      3.2.1.7 Ruby

      @@ -199,21 +199,21 @@ RUBY_LIB: D:\ruby\lib\mswin32-ruby16.lib

      -

      3.2.2 Instructions for using the Examples with other compilers

      +

      3.2.2 Instructions for using the Examples with other compilers

      If you do not have access to Visual C++ you will have to set up project files / Makefiles for your chosen compiler. There is a section in each of the language modules detailing what needs setting up using Visual C++ which may be of some guidance. Alternatively you may want to use Cygwin as described in the following section.

      -

      3.3 SWIG on Cygwin and MinGW

      +

      3.3 SWIG on Cygwin and MinGW

      SWIG can also be compiled and run using Cygwin or MinGW which provides a Unix like front end to Windows and comes free with gcc, an ANSI C/C++ compiler. However, this is not a recommended approach as the prebuilt executable is supplied.

      -

      3.3.1 Building swig.exe on Windows

      +

      3.3.1 Building swig.exe on Windows

      @@ -223,7 +223,7 @@ This information is provided for those that want to modify the SWIG source code Normally this is not needed, so most people will want to ignore this section.

      -

      3.3.1.1 Building swig.exe using MinGW and MSYS

      +

      3.3.1.1 Building swig.exe using MinGW and MSYS

      @@ -341,7 +341,7 @@ make -

      3.3.1.2 Building swig.exe using Cygwin

      +

      3.3.1.2 Building swig.exe using Cygwin

      @@ -352,7 +352,7 @@ Note that the Cygwin environment will also allow one to regenerate the autotool These files are generated using the autogen.sh script and will only need regenerating in circumstances such as changing the build system.

      -

      3.3.1.3 Building swig.exe alternatives

      +

      3.3.1.3 Building swig.exe alternatives

      @@ -362,7 +362,7 @@ file in order to build swig.exe from the Visual C++ IDE.

      -

      3.3.2 Running the examples on Windows using Cygwin

      +

      3.3.2 Running the examples on Windows using Cygwin

      @@ -371,7 +371,7 @@ The modules which are known to work are Python, Tcl, Perl, Ruby, Java and C#. Follow the Unix instructions in the README file in the SWIG root directory to build the examples.

      -

      3.4 Microsoft extensions and other Windows quirks

      +

      3.4 Microsoft extensions and other Windows quirks

      From cacb36bedb09cbc1f20d1132020f43972f3cdc47 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 22 Dec 2015 19:06:25 +0000 Subject: [PATCH 213/732] Docs - remove html tags from headings --- Doc/Manual/Contents.html | 22 +++++++++++----------- Doc/Manual/D.html | 8 ++++---- Doc/Manual/Ocaml.html | 16 ++++++++-------- Doc/Manual/Php.html | 4 ++-- Doc/Manual/SWIG.html | 12 ++++++------ Doc/Manual/Typemaps.html | 4 ++-- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 6d2cdaa76..54fa30637 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -142,8 +142,8 @@

    • Basic Type Handling
    • Global Variables
    • Constants -
    • A brief word about const -
    • A cautionary tale of char * +
    • A brief word about const +
    • A cautionary tale of char *
  • Pointers and complex objects
  • Typemaps and overloading -
  • More about %apply and %clear +
  • More about %apply and %clear
  • Passing data between typemaps
  • C++ "this" pointer
  • Where to go for more information? @@ -821,13 +821,13 @@
  • Code injection typemaps
  • Special variable macros -
  • %features +
  • D and %feature
  • Pragmas
  • D Exceptions
  • D Directors
  • Other features
  • Exceptions @@ -1435,7 +1435,7 @@
  • Pointers and References
  • Structures and C++ classes -
  • %features +
  • D and %feature
  • Pragmas
  • D Exceptions
  • D Directors
  • Other features
  • Exceptions @@ -930,7 +930,7 @@ object from causing a core dump, as long as the object is destroyed properly.

    -

    31.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    +

    31.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    @@ -941,7 +941,7 @@ well as a function return value in the same way you provide function arguments, and to receive arguments the same way you normally receive function returns.

    -

    31.2.5.6 directorin typemap

    +

    31.2.5.6 typemap

    @@ -952,7 +952,7 @@ code receives when you are called. In general, a simple directorin typ can use the same body as a simple out typemap.

    -

    31.2.5.7 directorout typemap

    +

    31.2.5.7 directorout typemap

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

    -

    31.2.5.8 directorargout typemap

    +

    31.2.5.8 directorargout typemap

    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index e1adce5ad..b332da552 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -25,7 +25,7 @@

  • Pointers and References
  • Structures and C++ classes
  • Pointers and complex objects
  • Typemaps and overloading -
  • More about %apply and %clear +
  • More about %apply and %clear
  • Passing data between typemaps
  • C++ "this" pointer
  • Where to go for more information? @@ -4664,7 +4664,7 @@ Subsequent "in" typemaps would then perform more extensive type-checking.
  • -

    11.14 More about %apply and %clear

    +

    11.14 More about %apply and %clear

    From 41a02723e6ddb810978c33a9f67ff2490112f2cc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 22 Dec 2015 22:42:44 +0000 Subject: [PATCH 214/732] Remove broken link in docs --- Doc/Manual/Ruby.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 4663b4c95..cac123fe4 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -4636,8 +4636,7 @@ objects that have already been marked). Those objects, in turn, may reference other objects. This process will continue until all active objects have been "marked." After the mark phase comes the sweep phase. 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.

    +garbage collected.

    The Ruby C/API provides extension developers two hooks into the garbage collector - a "mark" function and a "sweep" function. By From 019bdf9067b75d56962ab5e6174adb5ccf595192 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 22 Dec 2015 22:45:07 +0000 Subject: [PATCH 215/732] More link fixes in the docs --- Doc/Manual/Contents.html | 2 +- Doc/Manual/Scilab.html | 2 +- Doc/Manual/Sections.html | 2 +- Doc/Manual/index.html | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 54fa30637..fa44cab87 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -5,7 +5,7 @@ SWIG Users Manual -

    SWIG Users Manual

    +

    SWIG Users Manual

    diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 1f5876270..1ffeb4e61 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -1301,7 +1301,7 @@ namespace Bar {

    -Note: the nspace feature is not supported. +Note: the nspace feature is not supported.

    diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index b917c4cd8..aeebda60e 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -4,7 +4,7 @@ SWIG-3.0 Documentation -

    SWIG-3.0 Documentation

    +

    SWIG-3.0 Documentation

    Last update : SWIG-3.0.8 (in progress) diff --git a/Doc/Manual/index.html b/Doc/Manual/index.html index fbe105a7e..eabcb315e 100644 --- a/Doc/Manual/index.html +++ b/Doc/Manual/index.html @@ -4,7 +4,7 @@ SWIG-3.0 Documentation -

    SWIG-3.0 Documentation

    +

    SWIG-3.0 Documentation

    The SWIG documentation is available in one of the following formats.
      From fc68136880534361e9e82af823066b73000a9bc8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 28 Dec 2015 21:45:47 +0000 Subject: [PATCH 216/732] link fixes --- Doc/Manual/Contents.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index fa44cab87..54fa30637 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -5,7 +5,7 @@ SWIG Users Manual -

      SWIG Users Manual

      +

      SWIG Users Manual

      From 925b2a336f748d52344b4335b98dce90b4d7f5c4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 28 Dec 2015 22:27:13 +0000 Subject: [PATCH 217/732] HTML fixes for documentation - add meta tag and loose.dtd --- Doc/Manual/Allegrocl.html | 4 ++-- Doc/Manual/Android.html | 3 ++- Doc/Manual/Arguments.html | 3 ++- Doc/Manual/CCache.html | 3 ++- Doc/Manual/CPlusPlus11.html | 3 ++- Doc/Manual/CSharp.html | 3 ++- Doc/Manual/Chicken.html | 4 ++-- Doc/Manual/Contents.html | 4 ++-- Doc/Manual/Contract.html | 3 ++- Doc/Manual/Customization.html | 3 ++- Doc/Manual/D.html | 2 +- Doc/Manual/Extending.html | 3 ++- Doc/Manual/Go.html | 3 ++- Doc/Manual/Guile.html | 4 ++-- Doc/Manual/Introduction.html | 3 ++- Doc/Manual/Java.html | 3 ++- Doc/Manual/Javascript.html | 7 ++++--- Doc/Manual/Library.html | 3 ++- Doc/Manual/Lisp.html | 3 ++- Doc/Manual/Lua.html | 3 ++- Doc/Manual/Modula3.html | 3 ++- Doc/Manual/Modules.html | 3 ++- Doc/Manual/Mzscheme.html | 4 ++-- Doc/Manual/Ocaml.html | 3 ++- Doc/Manual/Octave.html | 3 ++- Doc/Manual/Perl5.html | 3 ++- Doc/Manual/Php.html | 4 ++-- Doc/Manual/Pike.html | 3 ++- Doc/Manual/Preface.html | 3 ++- Doc/Manual/Preprocessor.html | 3 ++- Doc/Manual/Python.html | 3 ++- Doc/Manual/R.html | 3 ++- Doc/Manual/Ruby.html | 7 ++++--- Doc/Manual/SWIG.html | 3 ++- Doc/Manual/SWIGPlus.html | 3 ++- Doc/Manual/Scilab.html | 3 ++- Doc/Manual/Scripting.html | 3 ++- Doc/Manual/Sections.html | 3 ++- Doc/Manual/Tcl.html | 3 ++- Doc/Manual/Typemaps.html | 3 ++- Doc/Manual/Varargs.html | 3 ++- Doc/Manual/Warnings.html | 3 ++- Doc/Manual/Windows.html | 3 ++- Doc/Manual/index.html | 3 ++- Doc/Manual/maketoc.py | 4 +++- 45 files changed, 94 insertions(+), 55 deletions(-) diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index e76d67e4c..9f37d4fc5 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -1,9 +1,9 @@ - - + SWIG and Allegro Common Lisp + diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index 2973f1de1..2d3658009 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -1,8 +1,9 @@ - + SWIG and Android +

      19 SWIG and Android

      diff --git a/Doc/Manual/Arguments.html b/Doc/Manual/Arguments.html index 21da790b7..db46359d5 100644 --- a/Doc/Manual/Arguments.html +++ b/Doc/Manual/Arguments.html @@ -1,8 +1,9 @@ - + Argument Handling + diff --git a/Doc/Manual/CCache.html b/Doc/Manual/CCache.html index 88922a8ea..d23b0cb2f 100644 --- a/Doc/Manual/CCache.html +++ b/Doc/Manual/CCache.html @@ -1,8 +1,9 @@ - + ccache-swig(1) manpage + diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html index 021ad418d..714845bba 100644 --- a/Doc/Manual/CPlusPlus11.html +++ b/Doc/Manual/CPlusPlus11.html @@ -1,8 +1,9 @@ - + SWIG and C++11 + diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index e6829aabc..0cbc9ec24 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -1,8 +1,9 @@ - + SWIG and C# +

      20 SWIG and C#

      diff --git a/Doc/Manual/Chicken.html b/Doc/Manual/Chicken.html index 88cff55a9..2d800ad6a 100644 --- a/Doc/Manual/Chicken.html +++ b/Doc/Manual/Chicken.html @@ -1,9 +1,9 @@ - - + SWIG and Chicken + diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 54fa30637..316f8f249 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1,8 +1,8 @@ - - + SWIG Users Manual +

      SWIG Users Manual

      diff --git a/Doc/Manual/Contract.html b/Doc/Manual/Contract.html index 660daf9fc..4b4995819 100644 --- a/Doc/Manual/Contract.html +++ b/Doc/Manual/Contract.html @@ -1,8 +1,9 @@ - + Contract Checking + diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 9ab0a6269..d3ddecbb1 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -1,8 +1,9 @@ - + Customization Features + diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index 540d1fdda..9e8e65358 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -1,4 +1,4 @@ - + SWIG and D diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 7519dca94..14dcbdccd 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -1,8 +1,9 @@ - + Extending SWIG to support new languages + diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 2fff4edf5..52f023f92 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -1,8 +1,9 @@ - + SWIG and Go +

      23 SWIG and Go

      diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index b424df6e2..5c8792150 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -1,9 +1,9 @@ - - + SWIG and Guile + diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index db35d8425..677784d9a 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -1,8 +1,9 @@ - + Introduction + diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 9b18c4aa9..eeedc5d68 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -1,8 +1,9 @@ - + SWIG and Java +

      25 SWIG and Java

      diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index a3b6cf0c5..3a4b6d69b 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -1,8 +1,9 @@ - + - - + + + diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 203ea6d46..954de54f7 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -1,8 +1,9 @@ - + SWIG Library + diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index ccb424e50..baee4ddf1 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -1,8 +1,9 @@ - + SWIG and Common Lisp + diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 1b6b87e51..8639e5f9e 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -1,8 +1,9 @@ - + SWIG and Lua + diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index ed6e596e7..f324495a3 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -1,8 +1,9 @@ - + SWIG and Modula-3 +

      29 SWIG and Modula-3

      diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index d12383a1d..089b1a4ad 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -1,8 +1,9 @@ - + Working with Modules + diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html index 358942a35..5b589cef1 100644 --- a/Doc/Manual/Mzscheme.html +++ b/Doc/Manual/Mzscheme.html @@ -1,9 +1,9 @@ - - + SWIG and MzScheme/Racket + diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 293789656..07b3ffc1f 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -1,8 +1,9 @@ - + SWIG and Ocaml + diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index df484103d..611f172e3 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -1,8 +1,9 @@ - + SWIG and Octave + diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index bb912ec8e..4bb2b84c7 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -1,8 +1,9 @@ - + SWIG and Perl5 + diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index b332da552..36f8ca981 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -1,9 +1,9 @@ - - + SWIG and PHP + diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html index c7e75d00c..22ab4e2a2 100644 --- a/Doc/Manual/Pike.html +++ b/Doc/Manual/Pike.html @@ -1,8 +1,9 @@ - + SWIG and Pike + diff --git a/Doc/Manual/Preface.html b/Doc/Manual/Preface.html index 186bc415d..4a9ad5ba9 100644 --- a/Doc/Manual/Preface.html +++ b/Doc/Manual/Preface.html @@ -1,8 +1,9 @@ - + Preface + diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index b8a6e9b0e..2538f8f18 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -1,8 +1,9 @@ - + SWIG Preprocessor + diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index c288581b7..c8148fbdc 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -1,8 +1,9 @@ - + SWIG and Python + diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index fc60f368e..9b5993bff 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -1,8 +1,9 @@ - + SWIG and R + diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index cac123fe4..4d7f92a0f 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -1,8 +1,9 @@ - + - SWIG and Ruby - +SWIG and Ruby + + diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index d6228ef34..16cdd0e8f 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1,8 +1,9 @@ - + SWIG Basics + diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 1127a8ee8..07048320b 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -1,8 +1,9 @@ - + SWIG and C++ + diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 1ffeb4e61..3e9e1c1a2 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -1,8 +1,9 @@ - + SWIG and Scilab + diff --git a/Doc/Manual/Scripting.html b/Doc/Manual/Scripting.html index 9e5e85e7d..f178033e4 100644 --- a/Doc/Manual/Scripting.html +++ b/Doc/Manual/Scripting.html @@ -1,8 +1,9 @@ - + Scripting Languages + diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index aeebda60e..8f2ba46bf 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -1,7 +1,8 @@ - + SWIG-3.0 Documentation +

      SWIG-3.0 Documentation

      diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index a3e6ae99a..77ea5f3b6 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -1,8 +1,9 @@ - + SWIG and Tcl + diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 1cadd4ae3..6dfc5d05d 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -1,8 +1,9 @@ - + Typemaps + diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index c2f55b019..78689c2fb 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -1,8 +1,9 @@ - + Variable Length Arguments + diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 92ec5000c..3ec1af757 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -1,8 +1,9 @@ - + Warning Messages + diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index fecdf48ed..d7c1932b7 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -1,8 +1,9 @@ - + Getting started on Windows + diff --git a/Doc/Manual/index.html b/Doc/Manual/index.html index eabcb315e..26cc81ea1 100644 --- a/Doc/Manual/index.html +++ b/Doc/Manual/index.html @@ -1,7 +1,8 @@ - + SWIG-3.0 Documentation +

      SWIG-3.0 Documentation

      diff --git a/Doc/Manual/maketoc.py b/Doc/Manual/maketoc.py index d8c4aa759..dc8626434 100644 --- a/Doc/Manual/maketoc.py +++ b/Doc/Manual/maketoc.py @@ -6,12 +6,14 @@ chs = open("chapters").readlines() f = open("Contents.html","w") print >>f, """ - + SWIG Users Manual + +

      SWIG Users Manual

      From 870b0f15056d663e3a4ef3736cac0358d4b4cf39 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 29 Dec 2015 07:48:01 +0000 Subject: [PATCH 218/732] html fixes --- Doc/Manual/Sections.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 8f2ba46bf..e2615c3d2 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -7,11 +7,13 @@

      SWIG-3.0 Documentation

      +

      Last update : SWIG-3.0.8 (in progress) +

      -

      Sections

      +

      Sections

      -

      SWIG Core Documentation

      +

      SWIG Core Documentation

      -

      Language Module Documentation

      +

      Language Module Documentation

      -

      Developer Documentation

      +

      Developer Documentation

      • Extending SWIG
      • From 4e67d5c7a810048d9024a699a4d5d676f5a69b82 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 29 Dec 2015 07:55:30 +0000 Subject: [PATCH 219/732] Minor html fixes --- Doc/Manual/Contents.html | 2 ++ Doc/Manual/SWIGPlus.html | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 316f8f249..55d16ee1a 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1,3 +1,4 @@ + @@ -5,6 +6,7 @@ +

        SWIG Users Manual

        diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 07048320b..82f720b21 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -2482,6 +2482,7 @@ above:

      • Currently no resolution is performed in order to match function parameters. This means function parameter types must match exactly. For example, namespace qualifiers and typedefs will not work. The following usage of typedefs demonstrates this: +

        @@ -4678,6 +4679,7 @@ p = f.__deref__()       # Raw pointer from operator->
         
         

        Another similar idiom in C++ is the use of reference counted objects. Consider for example: +

        
        From 3763beb4898b89eb7021fcd4427d2944cd9bc575 Mon Sep 17 00:00:00 2001
        From: William S Fulton 
        Date: Tue, 29 Dec 2015 19:10:57 +0000
        Subject: [PATCH 220/732] Replace tabs with spaces in html docs
        
        wkhtmltopdf is not expanding tabs within 
         elements to 8 spaces as it
        should. Workaround the problem by converting all tabs to an appropriate
        number of spaces.
        ---
         Doc/Manual/Allegrocl.html     | 230 +++++++++++++++++-----------------
         Doc/Manual/Android.html       |   4 +-
         Doc/Manual/Arguments.html     |  10 +-
         Doc/Manual/Chicken.html       |  42 +++----
         Doc/Manual/Customization.html |  88 ++++++-------
         Doc/Manual/Go.html            | 220 ++++++++++++++++----------------
         Doc/Manual/Guile.html         |  24 ++--
         Doc/Manual/Introduction.html  |  19 +--
         Doc/Manual/Java.html          |  18 +--
         Doc/Manual/Javascript.html    |   6 +-
         Doc/Manual/Lisp.html          |  82 ++++++------
         Doc/Manual/Lua.html           |   8 +-
         Doc/Manual/Mzscheme.html      |  12 +-
         Doc/Manual/Ocaml.html         |  56 ++++-----
         Doc/Manual/Perl5.html         | 201 ++++++++++++++---------------
         Doc/Manual/Php.html           |  30 ++---
         Doc/Manual/Python.html        |  50 ++++----
         Doc/Manual/Ruby.html          |  11 +-
         Doc/Manual/SWIG.html          | 190 ++++++++++++++--------------
         Doc/Manual/SWIGPlus.html      |  76 +++++------
         Doc/Manual/Scripting.html     |  47 +++----
         Doc/Manual/Tcl.html           |  47 +++----
         Doc/Manual/Typemaps.html      |  32 ++---
         Doc/Manual/Varargs.html       |   2 +-
         Doc/Manual/Windows.html       |   2 +-
         25 files changed, 758 insertions(+), 749 deletions(-)
        
        diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html
        index 9f37d4fc5..4b6bad421 100644
        --- a/Doc/Manual/Allegrocl.html
        +++ b/Doc/Manual/Allegrocl.html
        @@ -373,21 +373,21 @@ swig -allegrocl [ options ] filename
         
            -identifier-converter [name] - Binds the variable swig:*swig-identifier-convert* 
                                           in the generated .cl file to name.
        -				  This function is used to generate symbols
        -				  for the lisp side of the interface. 
        +                                  This function is used to generate symbols
        +                                  for the lisp side of the interface.
         
            -cwrap - [default] Generate a .cxx file containing C wrapper function when
                     wrapping C code. The interface generated is similar to what is
        -	    done for C++ code.
        +            done for C++ code.
            -nocwrap - Explicitly turn off generation of .cxx wrappers for C code. Reasonable
                       for modules with simple interfaces. Can not handle all legal enum
        -	      and constant constructs, or take advantage of SWIG customization features.
        +              and constant constructs, or take advantage of SWIG customization features.
         
            -isolate - With this command-line argument, all lisp helper functions are defined
                       in a unique package named swig.<module-name> rather than
        -	      swig. This prevents conflicts when the module is
        -	      intended to be used with other swig generated interfaces that may, 
        -	      for instance, make use of different identifier converters.
        +              swig. This prevents conflicts when the module is
        +              intended to be used with other swig generated interfaces that may,
        +              for instance, make use of different identifier converters.
         
        @@ -472,7 +472,7 @@ interested in generating an interface to C++. | Foreign Code | What we're generating an interface to. |______________| | - | + | _______v______ | | (foreign side) | Wrapper code | extern "C" wrappers calling C++ @@ -484,18 +484,18 @@ interested in generating an interface to C++. | FFI Layer | Low level lisp interface. ff:def-foreign-call, |______________| ff:def-foreign-variable | - +---------------------------- + +---------------------------- _______v______ _______v______ | | | | (lisp side) | Defuns | | Defmethods | wrapper for overloaded |______________| |______________| functions or those with (lisp side) | defaulted arguments - Wrapper for non-overloaded | - functions and methods _______v______ - | | (lisp side) - | Defuns | dispatch function - |______________| to overloads based - on arity + Wrapper for non-overloaded | + functions and methods _______v______ + | | (lisp side) + | Defuns | dispatch function + |______________| to overloads based + on arity
        @@ -799,8 +799,8 @@ namespace car {

        - Users are cautioned to get to know their constants before use, or - not use the -nocwrap command-line option. + Users are cautioned to get to know their constants before use, or + not use the -nocwrap command-line option.

        18.3.3 Variables

        @@ -907,7 +907,7 @@ globalvar> (globalvar.nnn::glob_float)

        For example, the following header file

        enum.h:
        -enum COL { RED, GREEN, BLUE };	
        +enum COL { RED, GREEN, BLUE };
         enum FOO { FOO1 = 10, FOO2, FOO3 };
               
        @@ -1177,25 +1177,25 @@ namespace BAR {

        18.3.7.1 Generating wrapper code for templates

        -

        - SWIG provides support for dealing with templates, but by - default, it will not generate any member variable or function - wrappers for templated classes. In order to create these - wrappers, you need to explicitly tell SWIG to instantiate - them. This is done via the - %template - directive. -

        +

        +SWIG provides support for dealing with templates, but by +default, it will not generate any member variable or function +wrappers for templated classes. In order to create these +wrappers, you need to explicitly tell SWIG to instantiate +them. This is done via the +%template +directive. +

        18.3.7.2 Implicit Template instantiation

        -

        - While no wrapper code is generated for accessing member - variables, or calling member functions, type code is generated - to include these templated classes in the foreign-type and CLOS - class schema. -

        +

        +While no wrapper code is generated for accessing member +variables, or calling member functions, type code is generated +to include these templated classes in the foreign-type and CLOS +class schema. +

        18.3.8 Typedef, Templates, and Synonym Types

        @@ -1243,7 +1243,7 @@ int zzz(A *inst = 0); /* return inst->x + inst->y */ definition, we generate a form that expands to:

        - (setf (find-class <synonym>) <primary>) + (setf (find-class <synonym>) <primary>)

        The result is that all references to synonym types in foreign @@ -1285,17 +1285,17 @@ synonym> criteria from a set of synonym types.

          -
        • - If a synonym type has a class definition, it is the primary type. -
        • -
        • - If a synonym type is a class template and has been explicitly - instantiated via %template, it is the primary type. -
        • -
        • - For all other sets of synonymous types, the synonym which is - parsed first becomes the primary type. -
        • +
        • + If a synonym type has a class definition, it is the primary type. +
        • +
        • + If a synonym type is a class template and has been explicitly + instantiated via %template, it is the primary type. +
        • +
        • + For all other sets of synonymous types, the synonym which is + parsed first becomes the primary type. +

        18.3.9 Function overloading/Parameter defaulting

        @@ -1472,68 +1472,68 @@ overload>
         /* name conversion for overloaded operators. */
         #ifdef __cplusplus
        -%rename(__add__)	     *::operator+;
        -%rename(__pos__)	     *::operator+();
        -%rename(__pos__)	     *::operator+() const;
        +%rename(__add__)             *::operator+;
        +%rename(__pos__)             *::operator+();
        +%rename(__pos__)             *::operator+() const;
         
        -%rename(__sub__)	     *::operator-;
        -%rename(__neg__)	     *::operator-() const;
        -%rename(__neg__)	     *::operator-();
        +%rename(__sub__)             *::operator-;
        +%rename(__neg__)             *::operator-() const;
        +%rename(__neg__)             *::operator-();
         
        -%rename(__mul__)	     *::operator*;
        -%rename(__deref__)	     *::operator*();
        -%rename(__deref__)	     *::operator*() const;
        +%rename(__mul__)             *::operator*;
        +%rename(__deref__)           *::operator*();
        +%rename(__deref__)           *::operator*() const;
         
        -%rename(__div__)	     *::operator/;
        -%rename(__mod__)	     *::operator%;
        -%rename(__logxor__)	     *::operator^;
        -%rename(__logand__)	     *::operator&;
        -%rename(__logior__)	     *::operator|;
        -%rename(__lognot__)	     *::operator~();
        -%rename(__lognot__)	     *::operator~() const;
        +%rename(__div__)             *::operator/;
        +%rename(__mod__)             *::operator%;
        +%rename(__logxor__)          *::operator^;
        +%rename(__logand__)          *::operator&;
        +%rename(__logior__)          *::operator|;
        +%rename(__lognot__)          *::operator~();
        +%rename(__lognot__)          *::operator~() const;
         
        -%rename(__not__)	     *::operator!();
        -%rename(__not__)	     *::operator!() const;
        +%rename(__not__)             *::operator!();
        +%rename(__not__)             *::operator!() const;
         
        -%rename(__assign__)	     *::operator=;
        +%rename(__assign__)          *::operator=;
         
         %rename(__add_assign__)      *::operator+=;
        -%rename(__sub_assign__)	     *::operator-=;
        -%rename(__mul_assign__)	     *::operator*=;
        -%rename(__div_assign__)	     *::operator/=;
        -%rename(__mod_assign__)	     *::operator%=;
        +%rename(__sub_assign__)      *::operator-=;
        +%rename(__mul_assign__)      *::operator*=;
        +%rename(__div_assign__)      *::operator/=;
        +%rename(__mod_assign__)      *::operator%=;
         %rename(__logxor_assign__)   *::operator^=;
         %rename(__logand_assign__)   *::operator&=;
         %rename(__logior_assign__)   *::operator|=;
         
        -%rename(__lshift__)	     *::operator<<;
        +%rename(__lshift__)          *::operator<<;
         %rename(__lshift_assign__)   *::operator<<=;
        -%rename(__rshift__)	     *::operator>>;
        +%rename(__rshift__)          *::operator>>;
         %rename(__rshift_assign__)   *::operator>>=;
         
        -%rename(__eq__)		     *::operator==;
        -%rename(__ne__)		     *::operator!=;
        -%rename(__lt__)		     *::operator<;
        -%rename(__gt__)		     *::operator>;
        -%rename(__lte__)	     *::operator<=;
        -%rename(__gte__)	     *::operator>=;
        +%rename(__eq__)              *::operator==;
        +%rename(__ne__)              *::operator!=;
        +%rename(__lt__)              *::operator<;
        +%rename(__gt__)              *::operator>;
        +%rename(__lte__)             *::operator<=;
        +%rename(__gte__)             *::operator>=;
         
        -%rename(__and__)	     *::operator&&;
        -%rename(__or__)		     *::operator||;
        +%rename(__and__)             *::operator&&;
        +%rename(__or__)              *::operator||;
         
        -%rename(__preincr__)	     *::operator++();
        -%rename(__postincr__)	     *::operator++(int);
        -%rename(__predecr__)	     *::operator--();
        -%rename(__postdecr__)	     *::operator--(int);
        +%rename(__preincr__)         *::operator++();
        +%rename(__postincr__)        *::operator++(int);
        +%rename(__predecr__)         *::operator--();
        +%rename(__postdecr__)        *::operator--(int);
         
        -%rename(__comma__)	     *::operator,();
        -%rename(__comma__)	     *::operator,() const;
        +%rename(__comma__)           *::operator,();
        +%rename(__comma__)           *::operator,() const;
         
         %rename(__member_ref__)      *::operator->;
         %rename(__member_func_ref__) *::operator->*;
         
        -%rename(__funcall__)	     *::operator();
        -%rename(__aref__)	     *::operator[];
        +%rename(__funcall__)         *::operator();
        +%rename(__aref__)            *::operator[];
             
        @@ -1821,28 +1821,28 @@ return-val wrapper-name(parm0, parm1, ..., parmN)

        The LIN typemap accepts the following $variable references.

          -
        • $in - expands to the name of the parameter being - applied to this typemap -
        • -
        • $out - expands to the name of the local variable - assigned to this typemap -
        • -
        • $in_fftype - the foreign function type of the C type.
        • -
        • $*in_fftype - the foreign function type of the C type - with one pointer removed. If there is no pointer, then $*in_fftype - is the same as $in_fftype. -
        • -
        • $body - very important. Instructs SWIG where - subsequent code generation steps should be inserted into the - current typemap. Leaving out a $body reference - will result in lisp wrappers that do very little by way of - calling into foreign code. Not recommended. -
        • +
        • $in - expands to the name of the parameter being + applied to this typemap +
        • +
        • $out - expands to the name of the local variable + assigned to this typemap +
        • +
        • $in_fftype - the foreign function type of the C type.
        • +
        • $*in_fftype - the foreign function type of the C type + with one pointer removed. If there is no pointer, then $*in_fftype + is the same as $in_fftype. +
        • +
        • $body - very important. Instructs SWIG where + subsequent code generation steps should be inserted into the + current typemap. Leaving out a $body reference + will result in lisp wrappers that do very little by way of + calling into foreign code. Not recommended. +
        -%typemap(lin)	SWIGTYPE 	"(cl:let (($out $in))\n  $body)";
        +%typemap(lin) SWIGTYPE "(cl:let (($out $in))\n  $body)";
             
        @@ -1858,17 +1858,17 @@ return-val wrapper-name(parm0, parm1, ..., parmN)

        The LOUT typemap uses the following $variable

          -
        • $lclass - Expands to the CLOS class that - represents foreign-objects of the return type matching this - typemap. -
        • -
        • $body - Same as for the LIN map. Place this - variable where you want the foreign-function call to occur. -
        • -
        • $ldestructor - Expands to the symbol naming the destructor for this - class ($lclass) of object. Allows you to insert finalization or automatic garbage - collection into the wrapper code (see default mappings below). -
        • +
        • $lclass - Expands to the CLOS class that + represents foreign-objects of the return type matching this + typemap. +
        • +
        • $body - Same as for the LIN map. Place this + variable where you want the foreign-function call to occur. +
        • +
        • $ldestructor - Expands to the symbol naming the destructor for this + class ($lclass) of object. Allows you to insert finalization or automatic garbage + collection into the wrapper code (see default mappings below). +
        diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index 2d3658009..8838e67a9 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -210,7 +210,7 @@ When complete your device should be listed in those attached, something like:
         $ adb devices
         List of devices attached 
        -A32-6DBE0001-9FF80000-015D62C3-02018028	device
        +A32-6DBE0001-9FF80000-015D62C3-02018028 device
         
        @@ -222,7 +222,7 @@ This means you are now ready to install the application...
         $ adb install bin/SwigSimple-debug.apk 
         95 KB/s (4834 bytes in 0.049s)
        -	pkg: /data/local/tmp/SwigSimple-debug.apk
        +        pkg: /data/local/tmp/SwigSimple-debug.apk
         Success
         
        diff --git a/Doc/Manual/Arguments.html b/Doc/Manual/Arguments.html index db46359d5..48ec5c629 100644 --- a/Doc/Manual/Arguments.html +++ b/Doc/Manual/Arguments.html @@ -60,7 +60,7 @@ Suppose you had a C function like this:
         void add(double a, double b, double *result) {
        -	*result = a + b;
        +  *result = a + b;
         }
         
        @@ -204,7 +204,7 @@ input value:

        -int *INPUT		
        +int *INPUT
         short *INPUT
         long *INPUT
         unsigned int *INPUT
        @@ -221,7 +221,7 @@ function:
         
         
         double add(double *a, double *b) {
        -	return *a+*b;
        +  return *a+*b;
         }
         
        @@ -273,7 +273,7 @@ These methods can be used as shown in an earlier example. For example, if you ha
         void add(double a, double b, double *c) {
        -	*c = a+b;
        +  *c = a+b;
         }
         
        @@ -339,7 +339,7 @@ A C function that uses this might be something like this:

         void negate(double *x) {
        -	*x = -(*x);
        +  *x = -(*x);
         }
         
         
        diff --git a/Doc/Manual/Chicken.html b/Doc/Manual/Chicken.html index 2d800ad6a..820d01fde 100644 --- a/Doc/Manual/Chicken.html +++ b/Doc/Manual/Chicken.html @@ -55,10 +55,10 @@

          -
        1. generates portable C code
        2. -
        3. includes a customizable interpreter
        4. -
        5. links to C libraries with a simple Foreign Function Interface
        6. -
        7. supports full tail-recursion and first-class continuations
        8. +
        9. generates portable C code
        10. +
        11. includes a customizable interpreter
        12. +
        13. links to C libraries with a simple Foreign Function Interface
        14. +
        15. supports full tail-recursion and first-class continuations

        @@ -98,7 +98,7 @@

        -
        % swig -chicken example.i
        +
        % swig -chicken example.i

        @@ -131,7 +131,7 @@

        -
        % swig -chicken -c++ example.i
        +
        % swig -chicken -c++ example.i

        @@ -142,7 +142,7 @@

        -
        % chicken example.scm -output-file oexample.c
        +
        % chicken example.scm -output-file oexample.c

        @@ -176,10 +176,10 @@

        The name of the module must be declared one of two ways:

          -
        • Placing %module example in the SWIG interface - file.
        • -
        • Using -module example on the SWIG command - line.
        • +
        • Placing %module example in the SWIG interface + file.
        • +
        • Using -module example on the SWIG command + line.

        @@ -189,7 +189,7 @@

        CHICKEN will be able to access the module using the (declare - (uses modulename)) CHICKEN Scheme form. + (uses modulename)) CHICKEN Scheme form.

        21.2.3 Constants and Variables

        @@ -200,10 +200,10 @@ the interface file:

          -
        1. #define MYCONSTANT1 ...
        2. -
        3. %constant int MYCONSTANT2 = ...
        4. -
        5. const int MYCONSTANT3 = ...
        6. -
        7. enum { MYCONSTANT4 = ... };
        8. +
        9. #define MYCONSTANT1 ...
        10. +
        11. %constant int MYCONSTANT2 = ...
        12. +
        13. const int MYCONSTANT3 = ...
        14. +
        15. enum { MYCONSTANT4 = ... };

        @@ -295,11 +295,11 @@

        The author of TinyCLOS, Gregor Kiczales, describes TinyCLOS as: - "Tiny CLOS is a Scheme implementation of a `kernelized' CLOS, with a - metaobject protocol. The implementation is even simpler than - the simple CLOS found in `The Art of the Metaobject Protocol,' - weighing in at around 850 lines of code, including (some) - comments and documentation." + "Tiny CLOS is a Scheme implementation of a `kernelized' CLOS, with a + metaobject protocol. The implementation is even simpler than + the simple CLOS found in `The Art of the Metaobject Protocol,' + weighing in at around 850 lines of code, including (some) + comments and documentation."

        diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index d3ddecbb1..8705534f9 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -116,16 +116,18 @@ static char error_message[256]; static int error_status = 0; void throw_exception(char *msg) { - strncpy(error_message,msg,256); - error_status = 1; + strncpy(error_message,msg,256); + error_status = 1; } void clear_exception() { - error_status = 0; + error_status = 0; } char *check_exception() { - if (error_status) return error_message; - else return NULL; + if (error_status) + return error_message; + else + return NULL; }

        @@ -137,13 +139,13 @@ To use these functions, functions simply call
         double inv(double x) {
        -	if (x != 0) return 1.0/x;
        -	else {
        -		throw_exception("Division by zero");
        -		return 0;
        -	}
        +  if (x != 0)
        +    return 1.0/x;
        +  else {
        +    throw_exception("Division by zero");
        +    return 0;
        +  }
         }
        -
         

        @@ -152,12 +154,12 @@ as the following (shown for Perl5) :

         %exception {
        -    char *err;
        -    clear_exception();
        -    $action
        -    if ((err = check_exception())) {
        -       croak(err);
        -    }
        +  char *err;
        +  clear_exception();
        +  $action
        +  if ((err = check_exception())) {
        +    croak(err);
        +  }
         }
         
        @@ -207,8 +209,10 @@ Now, within a C program, you can do the following :

         double inv(double x) {
        -	if (x) return 1.0/x;
        -	else throw(DivisionByZero);
        +  if (x)
        +    return 1.0/x;
        +  else
        +    throw(DivisionByZero);
         }
         
         
        @@ -222,17 +226,17 @@ Finally, to create a SWIG exception handler, write the following :

        %} %exception { - try { - $action - } catch(RangeError) { - croak("Range Error"); - } catch(DivisionByZero) { - croak("Division by zero"); - } catch(OutOfMemory) { - croak("Out of memory"); - } finally { - croak("Unknown exception"); - } + try { + $action + } catch(RangeError) { + croak("Range Error"); + } catch(DivisionByZero) { + croak("Division by zero"); + } catch(OutOfMemory) { + croak("Out of memory"); + } finally { + croak("Unknown exception"); + } } @@ -250,17 +254,17 @@ Handling C++ exceptions is also straightforward. For example:
         %exception {
        -	try {
        -		$action
        -	} catch(RangeError) {
        -		croak("Range Error");
        -	} catch(DivisionByZero) {
        -		croak("Division by zero");
        -	} catch(OutOfMemory) {
        -		croak("Out of memory");
        -	} catch(...) {
        -		croak("Unknown exception");
        -	}
        +  try {
        +    $action
        +  } catch(RangeError) {
        +    croak("Range Error");
        +  } catch(DivisionByZero) {
        +    croak("Division by zero");
        +  } catch(OutOfMemory) {
        +    croak("Out of memory");
        +  } catch(...) {
        +    croak("Unknown exception");
        +  }
         }
         
         
        @@ -320,7 +324,7 @@ critical pieces of code. For example:
         %exception {
        -	... your exception handler ...
        +  ... your exception handler ...
         }
         /* Define critical operations that can throw exceptions here */
         
        diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html
        index 52f023f92..ced046c66 100644
        --- a/Doc/Manual/Go.html
        +++ b/Doc/Manual/Go.html
        @@ -477,10 +477,10 @@ objects and fits nicely C++'s RAII idiom.  Example:
         
         func UseClassName(...) ... {
        -	o := NewClassName(...)
        -	defer DeleteClassName(o)
        -	// Use the ClassName object
        -	return ...
        +  o := NewClassName(...)
        +  defer DeleteClassName(o)
        +  // Use the ClassName object
        +  return ...
         }
         
        @@ -495,17 +495,17 @@ that creates a C++ object and functions called by this function. Example:
         func WithClassName(constructor args, f func(ClassName, ...interface{}) error, data ...interface{}) error {
        -	o := NewClassName(constructor args)
        -	defer DeleteClassName(o)
        -	return f(o, data...)
        +  o := NewClassName(constructor args)
        +  defer DeleteClassName(o)
        +  return f(o, data...)
         }
         
         func UseClassName(o ClassName, data ...interface{}) (err error) {
        -	// Use the ClassName object and additional data and return error.
        +  // Use the ClassName object and additional data and return error.
         }
         
         func main() {
        -	WithClassName(constructor args, UseClassName, additional data)
        +  WithClassName(constructor args, UseClassName, additional data)
         }
         
        @@ -547,33 +547,33 @@ problematic with C++ code that uses thread-local storage.
         import (
        -	"runtime"
        -	"wrap" // SWIG generated wrapper code
        +  "runtime"
        +  "wrap" // SWIG generated wrapper code
         )
         
         type GoClassName struct {
        -	wcn wrap.ClassName
        +  wcn wrap.ClassName
         }
         
         func NewGoClassName() *GoClassName {
        -	o := &GoClassName{wcn: wrap.NewClassName()}
        -	runtime.SetFinalizer(o, deleteGoClassName)
        -	return o
        +  o := &GoClassName{wcn: wrap.NewClassName()}
        +  runtime.SetFinalizer(o, deleteGoClassName)
        +  return o
         }
         
         func deleteGoClassName(o *GoClassName) {
        -	// Runs typically in a different OS thread!
        -	wrap.DeleteClassName(o.wcn)
        -	o.wcn = nil
        +  // Runs typically in a different OS thread!
        +  wrap.DeleteClassName(o.wcn)
        +  o.wcn = nil
         }
         
         func (o *GoClassName) Close() {
        -	// If the C++ object has a Close method.
        -	o.wcn.Close()
        +  // If the C++ object has a Close method.
        +  o.wcn.Close()
         
        -	// If the GoClassName object is no longer in an usable state.
        -	runtime.SetFinalizer(o, nil) // Remove finalizer.
        -	deleteGoClassName() // Free the C++ object.
        +  // If the GoClassName object is no longer in an usable state.
        +  runtime.SetFinalizer(o, nil) // Remove finalizer.
        +  deleteGoClassName() // Free the C++ object.
         }
         
        @@ -635,19 +635,19 @@ explains how to implement a FooBarGo class similar to the FooBarCpp class. class FooBarAbstract { public: - FooBarAbstract() {}; - virtual ~FooBarAbstract() {}; + FooBarAbstract() {}; + virtual ~FooBarAbstract() {}; - std::string FooBar() { - return this->Foo() + ", " + this->Bar(); - }; + std::string FooBar() { + return this->Foo() + ", " + this->Bar(); + }; protected: - virtual std::string Foo() { - return "Foo"; - }; + virtual std::string Foo() { + return "Foo"; + }; - virtual std::string Bar() = 0; + virtual std::string Bar() = 0; };
        @@ -661,13 +661,13 @@ protected: class FooBarCpp : public FooBarAbstract { protected: - virtual std::string Foo() { - return "C++ " + FooBarAbstract::Foo(); - } + virtual std::string Foo() { + return "C++ " + FooBarAbstract::Foo(); + } - virtual std::string Bar() { - return "C++ Bar"; - } + virtual std::string Bar() { + return "C++ Bar"; + } }; @@ -758,9 +758,9 @@ determine if an object instance was created via NewDirectorClassName:
         if o.DirectorInterface() != nil {
        -	DeleteDirectorClassName(o)
        +  DeleteDirectorClassName(o)
         } else {
        -	DeleteClassName(o)
        +  DeleteClassName(o)
         }
         
        @@ -798,22 +798,22 @@ As an example see part of the FooBarGo class:
         type overwrittenMethodsOnFooBarAbstract struct {
        -	fb FooBarAbstract
        +  fb FooBarAbstract
         }
         
         func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
        -	...
        +  ...
         }
         
         func (om *overwrittenMethodsOnFooBarAbstract) Bar() string {
        -	...
        +  ...
         }
         
         func NewFooBarGo() FooBarGo {
        -	om := &overwrittenMethodsOnFooBarAbstract{}
        -	fb := NewDirectorFooBarAbstract(om)
        -	om.fb = fb
        -	...
        +  om := &overwrittenMethodsOnFooBarAbstract{}
        +  fb := NewDirectorFooBarAbstract(om)
        +  om.fb = fb
        +  ...
         }
         
        @@ -855,7 +855,7 @@ the method in the base class. This is also the case for the
         virtual std::string Foo() {
        -	return "C++ " + FooBarAbstract::Foo();
        +  return "C++ " + FooBarAbstract::Foo();
         }
         
        @@ -869,7 +869,7 @@ The FooBarGo.Foo implementation in the example looks like this:
         func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
        -	return "Go " + DirectorFooBarAbstractFoo(om.fb)
        +  return "Go " + DirectorFooBarAbstractFoo(om.fb)
         }
         
        @@ -902,31 +902,31 @@ this:
         type FooBarGo interface {
        -	FooBarAbstract
        -	deleteFooBarAbstract()
        -	IsFooBarGo()
        +  FooBarAbstract
        +  deleteFooBarAbstract()
        +  IsFooBarGo()
         }
         
         type fooBarGo struct {
        -	FooBarAbstract
        +  FooBarAbstract
         }
         
         func (fbgs *fooBarGo) deleteFooBarAbstract() {
        -	DeleteDirectorFooBarAbstract(fbgs.FooBarAbstract)
        +  DeleteDirectorFooBarAbstract(fbgs.FooBarAbstract)
         }
         
         func (fbgs *fooBarGo) IsFooBarGo() {}
         
         func NewFooBarGo() FooBarGo {
        -	om := &overwrittenMethodsOnFooBarAbstract{}
        -	fb := NewDirectorFooBarAbstract(om)
        -	om.fb = fb
        +  om := &overwrittenMethodsOnFooBarAbstract{}
        +  fb := NewDirectorFooBarAbstract(om)
        +  om.fb = fb
         
        -	return &fooBarGo{FooBarAbstract: fb}
        +  return &fooBarGo{FooBarAbstract: fb}
         }
         
         func DeleteFooBarGo(fbg FooBarGo) {
        -	fbg.deleteFooBarAbstract()
        +  fbg.deleteFooBarAbstract()
         }
         
        @@ -962,14 +962,14 @@ in the FooBarGo class is here:
         type overwrittenMethodsOnFooBarAbstract struct {
        -	fb FooBarAbstract
        +  fb FooBarAbstract
         }
         
         func NewFooBarGo() FooBarGo {
        -	om := &overwrittenMethodsOnFooBarAbstract{}
        -	fb := NewDirectorFooBarAbstract(om) // fb.v = om
        -	om.fb = fb // Backlink causes cycle as fb.v = om!
        -	...
        +  om := &overwrittenMethodsOnFooBarAbstract{}
        +  fb := NewDirectorFooBarAbstract(om) // fb.v = om
        +  om.fb = fb // Backlink causes cycle as fb.v = om!
        +  ...
         }
         
        @@ -985,21 +985,21 @@ the finalizer on fooBarGo:
         type fooBarGo struct {
        -	FooBarAbstract
        +  FooBarAbstract
         }
         
         type overwrittenMethodsOnFooBarAbstract struct {
        -	fb FooBarAbstract
        +  fb FooBarAbstract
         }
         
         func NewFooBarGo() FooBarGo {
        -	om := &overwrittenMethodsOnFooBarAbstract{}
        -	fb := NewDirectorFooBarAbstract(om)
        -	om.fb = fb // Backlink causes cycle as fb.v = om!
        +  om := &overwrittenMethodsOnFooBarAbstract{}
        +  fb := NewDirectorFooBarAbstract(om)
        +  om.fb = fb // Backlink causes cycle as fb.v = om!
         
        -	fbgs := &fooBarGo{FooBarAbstract: fb}
        -	runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract)
        -	return fbgs
        +  fbgs := &fooBarGo{FooBarAbstract: fb}
        +  runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract)
        +  return fbgs
         }
         
        @@ -1026,18 +1026,18 @@ The complete and annotated FooBarGo class looks like this: // drop in replacement for FooBarAbstract but the reverse causes a compile time // error. type FooBarGo interface { - FooBarAbstract - deleteFooBarAbstract() - IsFooBarGo() + FooBarAbstract + deleteFooBarAbstract() + IsFooBarGo() } // Via embedding fooBarGo "inherits" all methods of FooBarAbstract. type fooBarGo struct { - FooBarAbstract + FooBarAbstract } func (fbgs *fooBarGo) deleteFooBarAbstract() { - DeleteDirectorFooBarAbstract(fbgs.FooBarAbstract) + DeleteDirectorFooBarAbstract(fbgs.FooBarAbstract) } // The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbstract. @@ -1049,48 +1049,48 @@ func (fbgs *fooBarGo) IsFooBarGo() {} // Go type that defines the DirectorInterface. It contains the Foo and Bar // methods that overwrite the respective virtual C++ methods on FooBarAbstract. type overwrittenMethodsOnFooBarAbstract struct { - // Backlink to FooBarAbstract so that the rest of the class can be used by - // the overridden methods. - fb FooBarAbstract + // Backlink to FooBarAbstract so that the rest of the class can be used by + // the overridden methods. + fb FooBarAbstract - // If additional constructor arguments have been given they are typically - // stored here so that the overriden methods can use them. + // If additional constructor arguments have been given they are typically + // stored here so that the overriden methods can use them. } func (om *overwrittenMethodsOnFooBarAbstract) Foo() string { - // DirectorFooBarAbstractFoo calls the base method FooBarAbstract::Foo. - return "Go " + DirectorFooBarAbstractFoo(om.fb) + // DirectorFooBarAbstractFoo calls the base method FooBarAbstract::Foo. + return "Go " + DirectorFooBarAbstractFoo(om.fb) } func (om *overwrittenMethodsOnFooBarAbstract) Bar() string { - return "Go Bar" + return "Go Bar" } func NewFooBarGo() FooBarGo { - // Instantiate FooBarAbstract with selected methods overridden. The methods - // that will be overwritten are defined on - // overwrittenMethodsOnFooBarAbstract and have a compatible signature to the - // respective virtual C++ methods. Furthermore additional constructor - // arguments will be typically stored in the - // overwrittenMethodsOnFooBarAbstract struct. - om := &overwrittenMethodsOnFooBarAbstract{} - fb := NewDirectorFooBarAbstract(om) - om.fb = fb // Backlink causes cycle as fb.v = om! + // Instantiate FooBarAbstract with selected methods overridden. The methods + // that will be overwritten are defined on + // overwrittenMethodsOnFooBarAbstract and have a compatible signature to the + // respective virtual C++ methods. Furthermore additional constructor + // arguments will be typically stored in the + // overwrittenMethodsOnFooBarAbstract struct. + om := &overwrittenMethodsOnFooBarAbstract{} + fb := NewDirectorFooBarAbstract(om) + om.fb = fb // Backlink causes cycle as fb.v = om! - fbgs := &fooBarGo{FooBarAbstract: fb} - // The memory of the FooBarAbstract director object instance can be - // automatically freed once the FooBarGo instance is garbage collected by - // uncommenting the following line. Please make sure to understand the - // runtime.SetFinalizer specific gotchas before doing this. Furthemore - // DeleteFooBarGo should be deleted if a finalizer is in use or the fooBarGo - // struct needs additional data to prevent double deletion. - // runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract) - return fbgs + fbgs := &fooBarGo{FooBarAbstract: fb} + // The memory of the FooBarAbstract director object instance can be + // automatically freed once the FooBarGo instance is garbage collected by + // uncommenting the following line. Please make sure to understand the + // runtime.SetFinalizer specific gotchas before doing this. Furthemore + // DeleteFooBarGo should be deleted if a finalizer is in use or the fooBarGo + // struct needs additional data to prevent double deletion. + // runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract) + return fbgs } // Recommended to be removed if runtime.SetFinalizer is in use. func DeleteFooBarGo(fbg FooBarGo) { - fbg.deleteFooBarAbstract() + fbg.deleteFooBarAbstract() } @@ -1114,13 +1114,13 @@ For comparison the FooBarCpp class looks like this: class FooBarCpp : public FooBarAbstract { protected: - virtual std::string Foo() { - return "C++ " + FooBarAbstract::Foo(); - } + virtual std::string Foo() { + return "C++ " + FooBarAbstract::Foo(); + } - virtual std::string Bar() { - return "C++ Bar"; - } + virtual std::string Bar() { + return "C++ Bar"; + } }; diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 5c8792150..f30e139e5 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -158,8 +158,8 @@ following module-system hack:
         (module-map (lambda (sym var)
        -	      (module-export! (current-module) (list sym)))
        -	    (current-module))
        +              (module-export! (current-module) (list sym)))
        +            (current-module))
         
        @@ -462,16 +462,16 @@ mapping:
        -      MAP(SWIG_MemoryError,	"swig-memory-error");
        -      MAP(SWIG_IOError,		"swig-io-error");
        -      MAP(SWIG_RuntimeError,	"swig-runtime-error");
        -      MAP(SWIG_IndexError,	"swig-index-error");
        -      MAP(SWIG_TypeError,	"swig-type-error");
        -      MAP(SWIG_DivisionByZero,	"swig-division-by-zero");
        -      MAP(SWIG_OverflowError,	"swig-overflow-error");
        -      MAP(SWIG_SyntaxError,	"swig-syntax-error");
        -      MAP(SWIG_ValueError,	"swig-value-error");
        -      MAP(SWIG_SystemError,	"swig-system-error");
        +      MAP(SWIG_MemoryError,     "swig-memory-error");
        +      MAP(SWIG_IOError,         "swig-io-error");
        +      MAP(SWIG_RuntimeError,    "swig-runtime-error");
        +      MAP(SWIG_IndexError,      "swig-index-error");
        +      MAP(SWIG_TypeError,       "swig-type-error");
        +      MAP(SWIG_DivisionByZero,  "swig-division-by-zero");
        +      MAP(SWIG_OverflowError,   "swig-overflow-error");
        +      MAP(SWIG_SyntaxError,     "swig-syntax-error");
        +      MAP(SWIG_ValueError,      "swig-value-error");
        +      MAP(SWIG_SystemError,     "swig-system-error");
         
        diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index 677784d9a..1c29f4760 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -158,14 +158,16 @@ following C code: double My_variable = 3.0; /* Compute factorial of n */ -int fact(int n) { - if (n <= 1) return 1; - else return n*fact(n-1); +int fact(int n) { + if (n <= 1) + return 1; + else + return n*fact(n-1); } /* Compute n mod m */ int my_mod(int n, int m) { - return(n % m); + return(n % m); } @@ -222,8 +224,7 @@ unix > tclsh 7.5 % -

        - +

        The swig command produced a new file called example_wrap.c that should be compiled along with the example.c file. Most operating systems and scripting @@ -245,8 +246,8 @@ any changes type the following (shown for Solaris):

         unix > swig -perl5 example.i
         unix > gcc -c example.c example_wrap.c \
        -	-I/usr/local/lib/perl5/sun4-solaris/5.003/CORE
        -unix > ld -G example.o example_wrap.o -o example.so		# This is for Solaris
        +        -I/usr/local/lib/perl5/sun4-solaris/5.003/CORE
        +unix > ld -G example.o example_wrap.o -o example.so # This is for Solaris
         unix > perl5.003
         use example;
         print example::fact(4), "\n";
        @@ -297,7 +298,7 @@ SWIG on the C header file and specifying a module name as follows
         
         unix > swig -perl5 -module example example.h
         unix > gcc -c example.c example_wrap.c \
        -	-I/usr/local/lib/perl5/sun4-solaris/5.003/CORE
        +        -I/usr/local/lib/perl5/sun4-solaris/5.003/CORE
         unix > ld -G example.o example_wrap.o -o example.so
         unix > perl5.003
         use example;
        diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
        index eeedc5d68..83d14ed64 100644
        --- a/Doc/Manual/Java.html
        +++ b/Doc/Manual/Java.html
        @@ -464,9 +464,9 @@ If you forget to compile and link in the SWIG wrapper file into your native libr
         
         $ java runme
         Exception in thread "main" java.lang.UnsatisfiedLinkError: exampleJNI.gcd(II)I
        -	at exampleJNI.gcd(Native Method)
        -	at example.gcd(example.java:12)
        -	at runme.main(runme.java:18)
        +        at exampleJNI.gcd(Native Method)
        +        at example.gcd(example.java:12)
        +        at runme.main(runme.java:18)
         

        @@ -630,11 +630,11 @@ CFLAGS = /Z7 /Od /c /nologo JAVA_INCLUDE = -ID:\jdk1.3\include -ID:\jdk1.3\include\win32 java:: - swig -java -o $(WRAPFILE) $(INTERFACE) - $(CC) $(CFLAGS) $(JAVA_INCLUDE) $(SRCS) $(WRAPFILE) - set LIB=$(TOOLS)\lib - $(LINK) $(LOPT) -out:example.dll $(LIBS) example.obj example_wrap.obj - javac *.java + swig -java -o $(WRAPFILE) $(INTERFACE) + $(CC) $(CFLAGS) $(JAVA_INCLUDE) $(SRCS) $(WRAPFILE) + set LIB=$(TOOLS)\lib + $(LINK) $(LOPT) -out:example.dll $(LIBS) example.obj example_wrap.obj + javac *.java

        @@ -1340,7 +1340,7 @@ member variables. For example,

         struct Vector {
        -	double x,y,z;
        +  double x,y,z;
         };
         
         
        diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 3a4b6d69b..56f83b763 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -349,7 +349,7 @@ It has some extras to configure node-webkit. See the
        @@ -369,7 +369,7 @@ The 'main' property of package.json specifies a web-pa
         the main window.

        - app.html: +app.html:

        @@ -396,7 +396,7 @@ open new windows, and many more things.

        - app.js: +app.js:

        diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index baee4ddf1..0867ba926 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -220,19 +220,19 @@ The generated SWIG Code will be: (cl:defconstant x (cl:ash 5 -1)) (cffi:defcstruct bar - (p :short) - (q :short) - (a :char) - (b :char) - (z :pointer) - (n :pointer)) + (p :short) + (q :short) + (a :char) + (b :char) + (z :pointer) + (n :pointer)) (cffi:defcvar ("my_struct" my_struct) :pointer) (cffi:defcstruct foo - (a :int) - (b :pointer)) + (a :int) + (b :pointer)) (cffi:defcfun ("pointer_func" pointer_func) :int (ClosureFun :pointer) @@ -248,9 +248,9 @@ The generated SWIG Code will be: (array :pointer)) (cffi:defcenum color - :RED - :BLUE - :GREEN) + :RED + :BLUE + :GREEN)

        @@ -336,12 +336,12 @@ The feature intern_function ensures that all C names are (cl:export '#.(swig-lispify "x" 'constant)) (cffi:defcstruct #.(swig-lispify "bar" 'classname) - (#.(swig-lispify "p" 'slotname) :short) - (#.(swig-lispify "q" 'slotname) :short) - (#.(swig-lispify "a" 'slotname) :char) - (#.(swig-lispify "b" 'slotname) :char) - (#.(swig-lispify "z" 'slotname) :pointer) - (#.(swig-lispify "n" 'slotname) :pointer)) + (#.(swig-lispify "p" 'slotname) :short) + (#.(swig-lispify "q" 'slotname) :short) + (#.(swig-lispify "a" 'slotname) :char) + (#.(swig-lispify "b" 'slotname) :char) + (#.(swig-lispify "z" 'slotname) :pointer) + (#.(swig-lispify "n" 'slotname) :pointer)) (cl:export '#.(swig-lispify "bar" 'classname)) @@ -363,8 +363,8 @@ The feature intern_function ensures that all C names are (cl:export '#.(swig-lispify "my_struct" 'variable)) (cffi:defcstruct #.(swig-lispify "foo" 'classname) - (#.(swig-lispify "a" 'slotname) :int) - (#.(swig-lispify "b" 'slotname) :pointer)) + (#.(swig-lispify "a" 'slotname) :int) + (#.(swig-lispify "b" 'slotname) :pointer)) (cl:export '#.(swig-lispify "foo" 'classname)) @@ -388,9 +388,9 @@ The feature intern_function ensures that all C names are (cl:export '#.(my-lispify "lispsort_double" 'function) 'some-other-package) (cffi:defcenum #.(swig-lispify "color" 'enumname) - #.(swig-lispify "RED" 'enumvalue :keyword) - #.(swig-lispify "BLUE" 'enumvalue :keyword) - #.(swig-lispify "GREEN" 'enumvalue :keyword)) + #.(swig-lispify "RED" 'enumvalue :keyword) + #.(swig-lispify "BLUE" 'enumvalue :keyword) + #.(swig-lispify "GREEN" 'enumvalue :keyword)) (cl:export '#.(swig-lispify "color" 'enumname)) @@ -662,14 +662,14 @@ swig -clisp -help -extern-all If this option is given then clisp definitions for all the functions
        and global variables will be created otherwise only definitions for
        - externed functions and variables are created. +externed functions and variables are created. -generate-typedef If this option is given then def-c-type will be used to generate
        - shortcuts according to the typedefs in the input. +shortcuts according to the typedefs in the input. @@ -680,15 +680,15 @@ and global variables will be created otherwise only definitions for

        As mentioned earlier the CLISP bindings generated by SWIG may need - some modifications. The clisp module creates a lisp file with - the same name as the module name. This - lisp file contains a 'defpackage' declaration, with the - package name same as the module name. This package uses the - 'common-lisp' and 'ffi' packages. Also, package exports all - the functions, structures and variables for which an ffi - binding was generated.
        - After generating the defpackage statement, the clisp module also - sets the default language. +some modifications. The clisp module creates a lisp file with +the same name as the module name. This +lisp file contains a 'defpackage' declaration, with the +package name same as the module name. This package uses the +'common-lisp' and 'ffi' packages. Also, package exports all +the functions, structures and variables for which an ffi +binding was generated.
        +After generating the defpackage statement, the clisp module also +sets the default language.

         (defpackage :test
        @@ -738,18 +738,18 @@ void test123(float x , double y);
         (ffi:def-call-out pointer_func
             (:name "pointer_func")
           (:arguments (ClosureFun (ffi:c-function (:arguments (arg0 (ffi:c-pointer NIL))
        -						      (arg1 (ffi:c-pointer NIL))
        -						      (arg2 (ffi:c-pointer NIL)))
        -					  (:return-type NIL)))
        -	      (y ffi:int))
        +                                                      (arg1 (ffi:c-pointer NIL))
        +                                                      (arg2 (ffi:c-pointer NIL)))
        +                                          (:return-type NIL)))
        +              (y ffi:int))
           (:return-type ffi:int)
           (:library +library-name+))
         
         (ffi:def-call-out func123
             (:name "func123")
           (:arguments (x (ffi:c-pointer div_t))
        -	      (z (ffi:c-ptr (ffi:c-array (ffi:c-ptr (ffi:c-ptr ffi:int)) 100)))
        -	      (y (ffi:c-ptr (ffi:c-ptr (ffi:c-array ffi:int (1000 10))))))
        +              (z (ffi:c-ptr (ffi:c-array (ffi:c-ptr (ffi:c-ptr ffi:int)) 100)))
        +              (y (ffi:c-ptr (ffi:c-ptr (ffi:c-array ffi:int (1000 10))))))
           (:return-type ffi:int)
           (:library +library-name+))
         
        @@ -757,14 +757,14 @@ void test123(float x , double y);
         (ffi:def-call-out lispsort_double
             (:name "lispsort_double")
           (:arguments (n ffi:int)
        -	      (array (ffi:c-ptr DOUBLE-FLOAT)))
        +              (array (ffi:c-ptr DOUBLE-FLOAT)))
           (:return-type NIL)
           (:library +library-name+))
         
         (ffi:def-call-out test123
             (:name "test")
           (:arguments (x SINGLE-FLOAT)
        -	      (y DOUBLE-FLOAT))
        +              (y DOUBLE-FLOAT))
           (:return-type NIL)
           (:library +library-name+))
         
        diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html
        index 8639e5f9e..004ca6f2b 100644
        --- a/Doc/Manual/Lua.html
        +++ b/Doc/Manual/Lua.html
        @@ -202,8 +202,8 @@ int main(int argc,char* argv[])
           return 0;
          }
          L=lua_open();
        - luaopen_base(L);	// load basic libs (eg. print)
        - luaopen_example(L);	// load the wrapped module
        + luaopen_base(L);       // load basic libs (eg. print)
        + luaopen_example(L);    // load the wrapped module
          if (luaL_loadfile(L,argv[1])==0) // load and run the file
           lua_pcall(L,0,0,0);
          else
        @@ -1536,8 +1536,8 @@ function
         
        %module example
         
         %typemap(in) int {
        -	$1 = (int) lua_tonumber(L,$input);
        -	printf("Received an integer : %d\n",$1);
        +  $1 = (int) lua_tonumber(L,$input);
        +  printf("Received an integer : %d\n",$1);
         }
         %inline %{
         extern int fact(int n);
        diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html
        index 5b589cef1..c5c199262 100644
        --- a/Doc/Manual/Mzscheme.html
        +++ b/Doc/Manual/Mzscheme.html
        @@ -56,12 +56,12 @@ Then in scheme, you can use regular struct access procedures like
         
         
        -	; suppose a function created a struct foo as 
        -	; (define foo (make-diag-cntrs (#x1 #x2 #x3) (make-inspector))
        -	; Then you can do
        -	(format "0x~x" (diag-cntrs-field1 foo))
        -	(format "0x~x" (diag-cntrs-field2 foo))
        -	;etc...
        +        ; suppose a function created a struct foo as
        +        ; (define foo (make-diag-cntrs (#x1 #x2 #x3) (make-inspector))
        +        ; Then you can do
        +        (format "0x~x" (diag-cntrs-field1 foo))
        +        (format "0x~x" (diag-cntrs-field2 foo))
        +        ;etc...
         
        diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 07b3ffc1f..e489c4147 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -308,19 +308,19 @@ A few functions exist which generate and return these:
        • caml_ptr_val receives a c_obj and returns a void *. This - should be used for all pointer purposes.
        • + should be used for all pointer purposes.
        • caml_long_val receives a c_obj and returns a long. This - should be used for most integral purposes.
        • + should be used for most integral purposes.
        • caml_val_ptr receives a void * and returns a c_obj.
        • caml_val_bool receives a C int and returns a c_obj representing - its bool value.
        • + its bool value.
        • caml_val_(u)?(char|short|int|long|float|double) receives an - appropriate C value and returns a c_obj representing it.
        • + appropriate C value and returns a c_obj representing it.
        • caml_val_string receives a char * and returns a string value.
        • caml_val_string_len receives a char * and a length and returns - a string value.
        • + a string value.
        • caml_val_obj receives a void * and an object type and returns - a C_obj, which contains a closure giving method access.
        • + a C_obj, which contains a closure giving method access.

        @@ -544,24 +544,24 @@ into this type of function convenient. #include <stdio.h> void printfloats( float *tab, int len ) { - int i; + int i; - for( i = 0; i < len; i++ ) { - printf( "%f ", tab[i] ); - } + for( i = 0; i < len; i++ ) { + printf( "%f ", tab[i] ); + } - printf( "\n" ); + printf( "\n" ); } %} %typemap(in) (float *tab, int len) { - int i; - /* $*1_type */ - $2 = caml_array_len($input); - $1 = ($*1_type *)malloc( $2 * sizeof( float ) ); - for( i = 0; i < $2; i++ ) { - $1[i] = caml_double_val(caml_array_nth($input,i)); - } + int i; + /* $*1_type */ + $2 = caml_array_len($input); + $1 = ($*1_type *)malloc( $2 * sizeof( float ) ); + for( i = 0; i < $2; i++ ) { + $1[i] = caml_double_val(caml_array_nth($input,i)); + } } void printfloats( float *tab, int len ); @@ -640,7 +640,7 @@ length. Instead, use multiple returns, as in the argout_ref example. %include <stl.i> namespace std { - %template(StringVector) std::vector < string >; + %template(StringVector) std::vector < string >; }; %include "example.h" @@ -715,16 +715,16 @@ Here's a simple example using Trolltech's Qt Library: %} class QApplication { public: - QApplication( int argc, char **argv ); - void setMainWidget( QWidget *widget ); - void exec(); + QApplication( int argc, char **argv ); + void setMainWidget( QWidget *widget ); + void exec(); }; class QPushButton { public: - QPushButton( char *str, QWidget *w ); - void resize( int x, int y ); - void show(); + QPushButton( char *str, QWidget *w ); + void resize( int x, int y ); + void show(); };

        @@ -848,9 +848,9 @@ let triangle_class pts ob meth args = "cover" -> (match args with C_list [ x_arg ; y_arg ] -> - let xa = x_arg as float - and ya = y_arg as float in - (point_in_triangle pts xa ya) to bool + let xa = x_arg as float + and ya = y_arg as float in + (point_in_triangle pts xa ya) to bool | _ -> raise (Failure "cover needs two double arguments.")) | _ -> (invoke ob) meth args ;; diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 4bb2b84c7..8d7b866d6 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -220,9 +220,9 @@ script such as the following:

        # File : Makefile.PL use ExtUtils::MakeMaker; WriteMakefile( - `NAME' => `example', # Name of package - `LIBS' => [`-lm'], # Name of custom libraries - `OBJECT' => `example.o example_wrap.o' # Object files + `NAME' => `example', # Name of package + `LIBS' => [`-lm'], # Name of custom libraries + `OBJECT' => `example.o example_wrap.o' # Object files );
        @@ -301,7 +301,7 @@ for a dynamic module, but change the link line to something like this:
         $ gcc example.o example_wrap.o -L/usr/lib/perl/5.14/CORE \
        -	-lperl -lsocket -lnsl -lm -o myperl
        +        -lperl -lsocket -lnsl -lm -o myperl
         

        @@ -892,9 +892,9 @@ To check to see if a value is the NULL pointer, use the

         if (defined($ptr)) {
        -	print "Not a NULL pointer.";
        +  print "Not a NULL pointer.";
         } else {
        -	print "Is a NULL pointer.";
        +  print "Is a NULL pointer.";
         }
         
         
        @@ -917,9 +917,9 @@ dereference them as follows:
         if ($$a == $$b) {
        -	print "a and b point to the same thing in C";
        +  print "a and b point to the same thing in C";
         } else {
        -	print "a and b point to different objects.";
        +  print "a and b point to different objects.";
         }
         
         
        @@ -978,7 +978,7 @@ accessor functions as described in the "SWIG Basics" chapter. For example,
         struct Vector {
        -	double x,y,z;
        +  double x,y,z;
         };
         
        @@ -1259,17 +1259,17 @@ The following C++ operators are currently supported by the Perl module:

          -
        • operator++
        • -
        • operator--
        • -
        • operator+
        • -
        • operator-
        • -
        • operator*
        • -
        • operator/
        • -
        • operator==
        • -
        • operator!=
        • -
        • operator%
        • -
        • operator>
        • -
        • operator<
        • +
        • operator++
        • +
        • operator--
        • +
        • operator+
        • +
        • operator-
        • +
        • operator*
        • +
        • operator/
        • +
        • operator==
        • +
        • operator!=
        • +
        • operator%
        • +
        • operator>
        • +
        • operator<
        • operator and
        • operator or
        @@ -1783,8 +1783,8 @@ you might define a typemap like this: %module example %typemap(in) int { - $1 = (int) SvIV($input); - printf("Received an integer : %d\n", $1); + $1 = (int) SvIV($input); + printf("Received an integer : %d\n", $1); } ... %inline %{ @@ -1829,8 +1829,8 @@ the typemap system follows typedef declarations. For example:
         %typemap(in) int n {
        -	$1 = (int) SvIV($input);
        -	printf("n = %d\n",$1);
        +  $1 = (int) SvIV($input);
        +  printf("n = %d\n",$1);
         }
         %inline %{
         typedef int Integer;
        @@ -2143,47 +2143,47 @@ reference to be used as a char ** datatype.
         
         // This tells SWIG to treat char ** as a special case
         %typemap(in) char ** {
        -	AV *tempav;
        -	I32 len;
        -	int i;
        -	SV  **tv;
        -	if (!SvROK($input))
        -	    croak("Argument $argnum is not a reference.");
        -        if (SvTYPE(SvRV($input)) != SVt_PVAV)
        -	    croak("Argument $argnum is not an array.");
        -        tempav = (AV*)SvRV($input);
        -	len = av_len(tempav);
        -	$1 = (char **) malloc((len+2)*sizeof(char *));
        -	for (i = 0; i <= len; i++) {
        -	    tv = av_fetch(tempav, i, 0);	
        -	    $1[i] = (char *) SvPV(*tv,PL_na);
        -        }
        -	$1[i] = NULL;
        +  AV *tempav;
        +  I32 len;
        +  int i;
        +  SV  **tv;
        +  if (!SvROK($input))
        +    croak("Argument $argnum is not a reference.");
        +  if (SvTYPE(SvRV($input)) != SVt_PVAV)
        +    croak("Argument $argnum is not an array.");
        +  tempav = (AV*)SvRV($input);
        +  len = av_len(tempav);
        +  $1 = (char **) malloc((len+2)*sizeof(char *));
        +  for (i = 0; i <= len; i++) {
        +    tv = av_fetch(tempav, i, 0);
        +    $1[i] = (char *) SvPV(*tv,PL_na);
        +  }
        +  $1[i] = NULL;
         };
         
         // This cleans up the char ** array after the function call
         %typemap(freearg) char ** {
        -	free($1);
        +  free($1);
         }
         
         // Creates a new Perl array and places a NULL-terminated char ** into it
         %typemap(out) char ** {
        -	AV *myav;
        -	SV **svs;
        -	int i = 0,len = 0;
        -	/* Figure out how many elements we have */
        -	while ($1[len])
        -	   len++;
        -	svs = (SV **) malloc(len*sizeof(SV *));
        -	for (i = 0; i < len ; i++) {
        -	    svs[i] = sv_newmortal();
        -	    sv_setpv((SV*)svs[i],$1[i]);
        -	};
        -	myav =	av_make(len,svs);
        -	free(svs);
        -        $result = newRV_noinc((SV*)myav);
        -        sv_2mortal($result);
        -        argvi++;
        +  AV *myav;
        +  SV **svs;
        +  int i = 0,len = 0;
        +  /* Figure out how many elements we have */
        +  while ($1[len])
        +     len++;
        +  svs = (SV **) malloc(len*sizeof(SV *));
        +  for (i = 0; i < len ; i++) {
        +      svs[i] = sv_newmortal();
        +      sv_setpv((SV*)svs[i],$1[i]);
        +  };
        +  myav = av_make(len,svs);
        +  free(svs);
        +  $result = newRV_noinc((SV*)myav);
        +  sv_2mortal($result);
        +  argvi++;
         }
         
         // Now a few test functions
        @@ -2240,12 +2240,12 @@ can be done using the EXTEND() macro as in:
         
         
         %typemap(argout) int *OUTPUT {
        -	if (argvi >= items) {            
        -		EXTEND(sp,1);              /* Extend the stack by 1 object */
        -	}
        -	$result = sv_newmortal();
        -	sv_setiv($target,(IV) *($1));
        -	argvi++;
        +  if (argvi >= items) {
        +    EXTEND(sp,1);              /* Extend the stack by 1 object */
        +  }
        +  $result = sv_newmortal();
        +  sv_setiv($target,(IV) *($1));
        +  argvi++;
         }
         
        @@ -2264,24 +2264,24 @@ its arguments. This example describes the implementation of the OUTPUT // an output value. %typemap(argout) double *OUTPUT { - $result = sv_newmortal(); - sv_setnv($result, *$input); - argvi++; /* Increment return count -- important! */ + $result = sv_newmortal(); + sv_setnv($result, *$input); + argvi++; /* Increment return count -- important! */ } // We don't care what the input value is. Ignore, but set to a temporary variable %typemap(in,numinputs=0) double *OUTPUT(double junk) { - $1 = &junk; + $1 = &junk; } // Now a function to test it %{ /* Returns the first two input arguments */ int multout(double a, double b, double *out1, double *out2) { - *out1 = a; - *out2 = b; - return 0; + *out1 = a; + *out2 = b; + return 0; }; %} @@ -2377,7 +2377,7 @@ have a C function that modifies its arguments like this:
         void add(double a, double b, double *c) {
        -	*c = a + b;
        +  *c = a + b;
         }
         
        @@ -2558,9 +2558,9 @@ Suppose you have the following SWIG interface file:
         %module example
         struct Vector {
        -	Vector(double x, double y, double z);
        -	~Vector();
        -	double x,y,z;
        +  Vector(double x, double y, double z);
        +  ~Vector();
        +  double x,y,z;
         };
         
         
        @@ -2610,8 +2610,9 @@ sub DESTROY { my $self = tied(%{$_[0]}); delete $ITERATORS{$self}; if (exists $OWNER{$self}) { - examplec::delete_Vector($self)); - delete $OWNER{$self}; + examplec::delete_Vector($self)); + delete $OWNER{$self}; + } } sub FETCH { @@ -2663,8 +2664,8 @@ $v->{x} = 7.5; # Assignment of all members %$v = ( x=>3, - y=>9, - z=>-2); + y=>9, + z=>-2); # Reading members $x = $v->{x}; @@ -2685,7 +2686,7 @@ problem---suppose you had a function like this:
         Vector *Vector_get(Vector *v, int index) {
        -	return &v[i];
        +  return &v[i];
         }
         
        @@ -2698,9 +2699,9 @@ Vector object:
         Vector *new_Vector(double x, double y, double z) {
        -	Vector *v;
        -	v = new Vector(x,y,z);        // Call C++ constructor
        -	return v;
        +  Vector *v;
        +  v = new Vector(x,y,z);        // Call C++ constructor
        +  return v;
         }
         
        @@ -2770,10 +2771,10 @@ Suppose that we have a new object that looks like this:
         struct Particle {
        -	Vector r;
        -	Vector v;
        -	Vector f;
        -	int	type;
        +  Vector r;
        +  Vector v;
        +  Vector f;
        +  int type;
         }
         
         
        @@ -2789,9 +2790,9 @@ look like this (along with some supporting code): package Particle; ... %BLESSEDMEMBERS = ( - r => `Vector', - v => `Vector', - f => `Vector', + r => `Vector', + v => `Vector', + f => `Vector', );
        @@ -2867,23 +2868,23 @@ interface file: class Shape { public: - virtual double area() = 0; - virtual double perimeter() = 0; - void set_location(double x, double y); + virtual double area() = 0; + virtual double perimeter() = 0; + void set_location(double x, double y); }; class Circle : public Shape { public: - Circle(double radius); - ~Circle(); - double area(); - double perimeter(); + Circle(double radius); + ~Circle(); + double area(); + double perimeter(); }; class Square : public Shape { public: - Square(double size); - ~Square(); - double area(); - double perimeter(); + Square(double size); + ~Square(); + double area(); + double perimeter(); } diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 36f8ca981..8c483b7a0 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -136,8 +136,8 @@ least work for Linux though):

        -	gcc `php-config --includes` -fpic -c example_wrap.c example.c
        -	gcc -shared example_wrap.o example.o -o example.so
        +        gcc `php-config --includes` -fpic -c example_wrap.c example.c
        +        gcc -shared example_wrap.o example.o -o example.so
         

        34.1.2 Using PHP Extensions

        @@ -150,7 +150,7 @@ load it. To do this, add a line like this to the [PHP] section of

        -	extension=/path/to/modulename.so
        +        extension=/path/to/modulename.so
         

        @@ -165,7 +165,7 @@ PHP script which uses your extension:

        -	dl("/path/to/modulename.so");	// Load the module
        +        dl("/path/to/modulename.so"); // Load the module
         

        @@ -180,7 +180,7 @@ call for you if the extension isn't already loaded:

        -	include("example.php");
        +        include("example.php");
         

        @@ -249,7 +249,7 @@ For example,

         %module example
         
        -#define EASY_TO_MISPELL	0
        +#define EASY_TO_MISPELL 0
         
        @@ -262,9 +262,9 @@ accessed incorrectly in PHP, include("example.php"); if(EASY_TO_MISPEL) { - .... + ... } else { - .... + ... } @@ -303,7 +303,7 @@ is accessed as follows:
         include("example.php");
         print seki_get();
        -seki_set( seki_get() * 2);	# The C variable is now 4.
        +seki_set( seki_get() * 2); # The C variable is now 4.
         print seki_get();
         
        @@ -348,7 +348,7 @@ Will be accessed in PHP like this : include("example.php"); $a = foo(2); $b = bar(3.5, -1.5); -$c = bar(3.5); # Use default argument for 2nd parameter +$c = bar(3.5); # Use default argument for 2nd parameter @@ -599,10 +599,10 @@ This interface file class Vector { public: - double x,y,z; - Vector(); - ~Vector(); - double magnitude(); + double x,y,z; + Vector(); + ~Vector(); + double magnitude(); }; struct Complex { @@ -722,7 +722,7 @@ returns the current value of the class variable. For example %module example class Ko { - static int threats; + static int threats; }; diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index c8148fbdc..abb3c5f18 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -466,9 +466,9 @@ $ swig -python example.i $ gcc example.c example_wrap.c \ -Xlinker -export-dynamic \ -DHAVE_CONFIG_H -I/usr/local/include/python2.1 \ - -I/usr/local/lib/python2.1/config \ - -L/usr/local/lib/python2.1/config -lpython2.1 -lm -ldl \ - -o mypython + -I/usr/local/lib/python2.1/config \ + -L/usr/local/lib/python2.1/config -lpython2.1 -lm -ldl \ + -o mypython

        @@ -1286,7 +1286,7 @@ a very natural interface. For example,

         struct Vector {
        -	double x,y,z;
        +  double x,y,z;
         };
         
         
        @@ -4310,8 +4310,8 @@ you might define a typemap like this: %module example %typemap(in) int { - $1 = (int) PyLong_AsLong($input); - printf("Received an integer : %d\n",$1); + $1 = (int) PyLong_AsLong($input); + printf("Received an integer : %d\n",$1); } %inline %{ extern int fact(int n); @@ -4348,11 +4348,11 @@ You can refine this by supplying an optional parameter name. For example: %module example %typemap(in) int nonnegative { - $1 = (int) PyLong_AsLong($input); - if ($1 < 0) { - PyErr_SetString(PyExc_ValueError,"Expected a nonnegative value."); - return NULL; - } + $1 = (int) PyLong_AsLong($input); + if ($1 < 0) { + PyErr_SetString(PyExc_ValueError,"Expected a nonnegative value."); + return NULL; + } } %inline %{ extern int fact(int nonnegative); @@ -4374,8 +4374,8 @@ the typemap system follows typedef declarations. For example:
         %typemap(in) int n {
        -	$1 = (int) PyLong_AsLong($input);
        -	printf("n = %d\n",$1);
        +  $1 = (int) PyLong_AsLong($input);
        +  printf("n = %d\n",$1);
         }
         %inline %{
         typedef int Integer;
        @@ -4685,11 +4685,11 @@ object to be used as a char ** object.
             for (i = 0; i < size; i++) {
               PyObject *o = PyList_GetItem($input,i);
               if (PyString_Check(o))
        -	$1[i] = PyString_AsString(PyList_GetItem($input,i));
        +        $1[i] = PyString_AsString(PyList_GetItem($input,i));
               else {
        -	PyErr_SetString(PyExc_TypeError,"list must contain strings");
        -	free($1);
        -	return NULL;
        +        PyErr_SetString(PyExc_TypeError,"list must contain strings");
        +        free($1);
        +        return NULL;
               }
             }
             $1[i] = 0;
        @@ -4784,11 +4784,11 @@ previous example:
             for (i = 0; i < $1; i++) {
               PyObject *o = PyList_GetItem($input,i);
               if (PyString_Check(o))
        -	$2[i] = PyString_AsString(PyList_GetItem($input,i));
        +        $2[i] = PyString_AsString(PyList_GetItem($input,i));
               else {
        -	PyErr_SetString(PyExc_TypeError,"list must contain strings");
        -	free($2);
        -	return NULL;
        +        PyErr_SetString(PyExc_TypeError,"list must contain strings");
        +        free($2);
        +        return NULL;
               }
             }
             $2[i] = 0;
        @@ -4832,10 +4832,10 @@ arguments rather than in the return value of a function.  For example:
         
         /* Returns a status value and two values in out1 and out2 */
         int spam(double a, double b, double *out1, double *out2) {
        -	... Do a bunch of stuff ...
        -	*out1 = result1;
        -	*out2 = result2;
        -	return status;
        +  ... Do a bunch of stuff ...
        +  *out1 = result1;
        +  *out2 = result2;
        +  return status;
         }
         
        diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 4d7f92a0f..27580387b 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -4190,10 +4190,10 @@ this:
        function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool
         
         Parameters:
        -	x - int
        -	y - int
        -	foo - Foo
        -	bar - Bar
        + x - int + y - int + foo - Foo + bar - Bar

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

        @@ -5251,8 +5251,7 @@ existing Ruby object to the destroyed C++ object and raise an exception. #include "example.h" %} -/* Specify that ownership is transferred to the zoo - when calling add_animal */ +/* Specify that ownership is transferred to the zoo when calling add_animal */ %apply SWIGTYPE *DISOWN { Animal* animal }; /* Track objects */ diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 16cdd0e8f..be26c94b4 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1037,15 +1037,14 @@ expect :

         # Copy a file 
         def filecopy(source,target):
        -	f1 = fopen(source,"r")
        -	f2 = fopen(target,"w")
        -	buffer = malloc(8192)
        -	nbytes = fread(buffer,8192,1,f1)
        -	while (nbytes > 0):
        -		fwrite(buffer,8192,1,f2)
        -		nbytes = fread(buffer,8192,1,f1)
        -	free(buffer)
        -
        +  f1 = fopen(source,"r")
        +  f2 = fopen(target,"w")
        +  buffer = malloc(8192)
        +  nbytes = fread(buffer,8192,1,f1)
        +  while (nbytes > 0):
        +    fwrite(buffer,8192,1,f2)
        +          nbytes = fread(buffer,8192,1,f1)
        +  free(buffer)
         

        @@ -1315,10 +1314,10 @@ gets mapped to an underlying pair of set/get functions like this :

         Vector *unit_i_get() {
        -	return &unit_i;
        +  return &unit_i;
         }
         void unit_i_set(Vector *value) {
        -	unit_i = *value;
        +  unit_i = *value;
         }
         
        @@ -1605,11 +1604,11 @@ directive as shown :

         // File : interface.i
         
        -int 	a; 			// Can read/write
        +int a;       // Can read/write
         %immutable;
        -int	b,c,d			// Read only variables
        +int b,c,d;   // Read only variables
         %mutable;
        -double	x,y			// read/write
        +double x,y;  // read/write
         

        @@ -2129,8 +2128,8 @@ default arguments are optional in the target language. For example, this functio used in Tcl as follows :

        -% plot -3.4 7.5 				# Use default value
        -% plot -3.4 7.5 10				# set color to 10 instead
        +% plot -3.4 7.5    # Use default value
        +% plot -3.4 7.5 10 # set color to 10 instead
         
         
        @@ -2320,7 +2319,7 @@ to an individual member. For example, the declaration :

         struct Vector {
        -	double x,y,z;
        +  double x,y,z;
         }
         
         
        @@ -2330,22 +2329,22 @@ gets transformed into the following set of accessor functions :

         double Vector_x_get(struct Vector *obj) {
        -	return obj->x;
        +  return obj->x;
         }
         double Vector_y_get(struct Vector *obj) { 
        -	return obj->y;
        +  return obj->y;
         }
         double Vector_z_get(struct Vector *obj) { 
        -	return obj->z;
        +  return obj->z;
         }
         void Vector_x_set(struct Vector *obj, double value) {
        -	obj->x = value;
        +  obj->x = value;
         }
         void Vector_y_set(struct Vector *obj, double value) {
        -	obj->y = value;
        +  obj->y = value;
         }
         void Vector_z_set(struct Vector *obj, double value) {
        -	obj->z = value;
        +  obj->z = value;
         }
         
        @@ -2393,7 +2392,7 @@ programs :

         typedef struct {
        -	double x,y,z;
        +  double x,y,z;
         } Vector;
         
         
        @@ -2408,7 +2407,7 @@ that the use of typedef allows SWIG to drop the
         double Vector_x_get(Vector *obj) {
        -	return obj->x;
        +  return obj->x;
         }
         
        @@ -2418,7 +2417,7 @@ If two different names are used like this :

         typedef struct vector_struct {
        -	double x,y,z;
        +  double x,y,z;
         } Vector;
         
         
        @@ -2444,8 +2443,8 @@ will be released, and the new contents allocated. For example :

        %module mymodule ... struct Foo { - char *name; - ... + char *name; + ... } @@ -2455,14 +2454,15 @@ This results in the following accessor functions :

         char *Foo_name_get(Foo *obj) {
        -	return Foo->name;
        +  return Foo->name;
         }
         
         char *Foo_name_set(Foo *obj, char *c) {
        -	if (obj->name) free(obj->name);
        -	obj->name = (char *) malloc(strlen(c)+1);
        -	strcpy(obj->name,c);
        -	return obj->name;
        +  if (obj->name)
        +    free(obj->name);
        +  obj->name = (char *) malloc(strlen(c)+1);
        +  strcpy(obj->name,c);
        +  return obj->name;
         }
         
        @@ -2714,7 +2714,7 @@ the following declaration :

        /* file : vector.h */ ... typedef struct Vector { - double x,y,z; + double x,y,z; } Vector; @@ -2732,23 +2732,23 @@ You can make a Vector look a lot like a class by writing a SWIG interfa %include "vector.h" // Just grab original C header file %extend Vector { // Attach these functions to struct Vector - Vector(double x, double y, double z) { - Vector *v; - v = (Vector *) malloc(sizeof(Vector)); - v->x = x; - v->y = y; - v->z = z; - return v; - } - ~Vector() { - free($self); - } - double magnitude() { - return sqrt($self->x*$self->x+$self->y*$self->y+$self->z*$self->z); - } - void print() { - printf("Vector [%g, %g, %g]\n", $self->x,$self->y,$self->z); - } + Vector(double x, double y, double z) { + Vector *v; + v = (Vector *) malloc(sizeof(Vector)); + v->x = x; + v->y = y; + v->z = z; + return v; + } + ~Vector() { + free($self); + } + double magnitude() { + return sqrt($self->x*$self->x+$self->y*$self->y+$self->z*$self->z); + } + void print() { + printf("Vector [%g, %g, %g]\n", $self->x,$self->y,$self->z); + } }; @@ -2787,12 +2787,12 @@ of the Vector structure. For example:

        %} typedef struct Vector { - double x,y,z; - %extend { - Vector(double x, double y, double z) { ... } - ~Vector() { ... } - ... - } + double x,y,z; + %extend { + Vector(double x, double y, double z) { ... } + ~Vector() { ... } + ... + } } Vector; @@ -2806,19 +2806,19 @@ example :

        /* Vector methods */ #include "vector.h" Vector *new_Vector(double x, double y, double z) { - Vector *v; - v = (Vector *) malloc(sizeof(Vector)); - v->x = x; - v->y = y; - v->z = z; - return v; + Vector *v; + v = (Vector *) malloc(sizeof(Vector)); + v->x = x; + v->y = y; + v->z = z; + return v; } void delete_Vector(Vector *v) { - free(v); + free(v); } double Vector_magnitude(Vector *v) { - return sqrt(v->x*v->x+v->y*v->y+v->z*v->z); + return sqrt(v->x*v->x+v->y*v->y+v->z*v->z); } // File : vector.i @@ -2829,13 +2829,13 @@ double Vector_magnitude(Vector *v) { %} typedef struct Vector { - double x,y,z; - %extend { - Vector(int,int,int); // This calls new_Vector() - ~Vector(); // This calls delete_Vector() - double magnitude(); // This will call Vector_magnitude() - ... - } + double x,y,z; + %extend { + Vector(int,int,int); // This calls new_Vector() + ~Vector(); // This calls delete_Vector() + double magnitude(); // This will call Vector_magnitude() + ... + } } Vector; @@ -2847,13 +2847,13 @@ For example:
         typedef struct Integer {
        -	int value;
        +  int value;
         } Int;
         %extend Integer { ...  } /* Correct name */
         %extend Int { ...  } /* Incorrect name */
         
         struct Float {
        -	float value;
        +  float value;
         };
         typedef struct Float FloatValue;
         %extend Float { ...  } /* Correct name */
        @@ -2866,7 +2866,7 @@ There is one exception to this rule and that is when the struct is anonymously n
         
         
         typedef struct {
        -	double value;
        +  double value;
         } Double;
         %extend Double { ...  } /* Okay */
         
        @@ -2975,13 +2975,13 @@ Occasionally, a C program will involve structures like this :

         typedef struct Object {
        -	int objtype;
        -	union {
        -		int 	ivalue;
        -		double	dvalue;
        -		char	*strvalue;
        -		void	*ptrvalue;
        -	} intRep;
        +  int objtype;
        +  union {
        +    int ivalue;
        +    double dvalue;
        +    char *strvalue;
        +    void *ptrvalue;
        +  } intRep;
         } Object;
         
         
        @@ -2993,15 +2993,15 @@ following:

         typedef union {
        -	int 		ivalue;
        -	double		dvalue;
        -	char		*strvalue;
        -	void		*ptrvalue;
        +  int ivalue;
        +  double dvalue;
        +  char *strvalue;
        +  void *ptrvalue;
         } Object_intRep;
         
         typedef struct Object {
        -	int objType;
        -	Object_intRep intRep;
        +  int objType;
        +  Object_intRep intRep;
         } Object;
         
         
        @@ -3013,16 +3013,16 @@ structures. In this case, functions like this would be created :

         Object_intRep *Object_intRep_get(Object *o) {
        -	return (Object_intRep *) &o->intRep;
        +  return (Object_intRep *) &o->intRep;
         }
         int Object_intRep_ivalue_get(Object_intRep *o) {
        -	return o->ivalue;
        +  return o->ivalue;
         }
         int Object_intRep_ivalue_set(Object_intRep *o, int value) {
        -	return (o->ivalue = value);
        +  return (o->ivalue = value);
         }
         double Object_intRep_dvalue_get(Object_intRep *o) {
        -	return o->dvalue;
        +  return o->dvalue;
         }
         ... etc ...
         
        @@ -3229,7 +3229,7 @@ program. For example :

        %{ /* Create a new vector */ static Vector *new_Vector() { - return (Vector *) malloc(sizeof(Vector)); + return (Vector *) malloc(sizeof(Vector)); } %} @@ -3249,7 +3249,7 @@ there is a special inlined form of code block that is used as follows %inline %{ /* Create a new vector */ Vector *new_Vector() { - return (Vector *) malloc(sizeof(Vector)); + return (Vector *) malloc(sizeof(Vector)); } %} @@ -3275,7 +3275,7 @@ initialization on module loading, you could write this:
         %init %{
        -	init_variables();
        +  init_variables();
         %}
         
        diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 82f720b21..73b242fa3 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -530,10 +530,10 @@ functions such as the following :

         List * new_List(void) {
        -	return new List;
        +  return new List;
         }
         void delete_List(List *l) {
        -	delete l;
        +  delete l;
         }
         
         
        @@ -874,7 +874,7 @@ All member functions are roughly translated into accessor functions like this :<
         int List_search(List *obj, char *value) {
        -	return obj->search(value);
        +  return obj->search(value);
         }
         
         
        @@ -912,11 +912,11 @@ structures. A pair of accessor functions are effectively created. For example
         int List_length_get(List *obj) {
        -	return obj->length;
        +  return obj->length;
         }
         int List_length_set(List *obj, int value) {
        -	obj->length = value;
        -	return value;
        +  obj->length = value;
        +  return value;
         }
         
         
        @@ -933,7 +933,7 @@ class List { public: ... %immutable; - int length; + int length; %mutable; ... }; @@ -1231,7 +1231,7 @@ into constants with the classname as a prefix. For example :

         class Swig {
         public:
        -	enum {ALE, LAGER, PORTER, STOUT};
        +  enum {ALE, LAGER, PORTER, STOUT};
         };
         
         
        @@ -1321,7 +1321,7 @@ a declaration like this :

         class Foo {
         public:
        -	double bar(double &a);
        +  double bar(double &a);
         }
         
        @@ -1331,7 +1331,7 @@ has a low-level accessor
         double Foo_bar(Foo *obj, double *a) {
        -	obj->bar(*a);
        +  obj->bar(*a);
         }
         
        @@ -1550,24 +1550,24 @@ the full C++ code has been omitted.

        class Shape { public: - double x,y; - virtual double area() = 0; - virtual double perimeter() = 0; - void set_location(double x, double y); + double x,y; + virtual double area() = 0; + virtual double perimeter() = 0; + void set_location(double x, double y); }; class Circle : public Shape { public: - Circle(double radius); - ~Circle(); - double area(); - double perimeter(); + Circle(double radius); + ~Circle(); + double area(); + double perimeter(); }; class Square : public Shape { public: - Square(double size); - ~Square(); - double area(); - double perimeter(); + Square(double size); + ~Square(); + double area(); + double perimeter(); }
        @@ -2615,7 +2615,7 @@ public: } Complex operator*(const Complex &c) const { return Complex(rpart*c.rpart - ipart*c.ipart, - rpart*c.ipart + c.rpart*ipart); + rpart*c.ipart + c.rpart*ipart); } Complex operator-() const { return Complex(-rpart, -ipart); @@ -2788,17 +2788,17 @@ example : class Vector { public: - double x,y,z; - Vector(); - ~Vector(); - ... bunch of C++ methods ... - %extend { - char *__str__() { - static char temp[256]; - sprintf(temp,"[ %g, %g, %g ]", $self->x,$self->y,$self->z); - return &temp[0]; - } - } + double x,y,z; + Vector(); + ~Vector(); + ... bunch of C++ methods ... + %extend { + char *__str__() { + static char temp[256]; + sprintf(temp,"[ %g, %g, %g ]", $self->x,$self->y,$self->z); + return &temp[0]; + } + } };
        @@ -4696,11 +4696,11 @@ public: return add_ref(); } - int unref() const { + int unref() const { if (ref_count() == 0 || del_ref() == 0 ) { - delete this; - return 0; - } + delete this; + return 0; + } return ref_count(); } }; diff --git a/Doc/Manual/Scripting.html b/Doc/Manual/Scripting.html index f178033e4..18af78a68 100644 --- a/Doc/Manual/Scripting.html +++ b/Doc/Manual/Scripting.html @@ -102,8 +102,10 @@ Suppose you have an ordinary C function like this :

         int fact(int n) {
        -	if (n <= 1) return 1;
        -	else return n*fact(n-1);
        +  if (n <= 1)
        +    return 1;
        +  else
        +    return n*fact(n-1);
         }
         
        @@ -124,18 +126,17 @@ As an example, the Tcl wrapper function for the fact() function above example might look like the following :

        -int wrap_fact(ClientData clientData, Tcl_Interp *interp,
        -		int argc, char *argv[]) {
        -	int result;
        -	int arg0;
        -	if (argc != 2) {
        -		interp->result = "wrong # args";
        -		return TCL_ERROR;
        -	}
        -	arg0 = atoi(argv[1]);
        -	result = fact(arg0);
        -	sprintf(interp->result,"%d", result);
        -	return TCL_OK;
        +int wrap_fact(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) {
        +  int result;
        +  int arg0;
        +  if (argc != 2) {
        +    interp->result = "wrong # args";
        +    return TCL_ERROR;
        +  }
        +  arg0 = atoi(argv[1]);
        +  result = fact(arg0);
        +  sprintf(interp->result,"%d", result);
        +  return TCL_OK;
         }
         
         
        @@ -149,9 +150,9 @@ requires code like the following :

         int Wrap_Init(Tcl_Interp *interp) {
        -	Tcl_CreateCommand(interp, "fact", wrap_fact, (ClientData) NULL,
        -				(Tcl_CmdDeleteProc *) NULL);
        -	return TCL_OK;
        +  Tcl_CreateCommand(interp, "fact", wrap_fact, (ClientData) NULL,
        +                    (Tcl_CmdDeleteProc *) NULL);
        +  return TCL_OK;
         }
         
        @@ -244,9 +245,9 @@ representation of a structure. For example,
         struct Vector {
        -	Vector();
        -	~Vector();
        -	double x,y,z;
        +  Vector();
        +  ~Vector();
        +  double x,y,z;
         };
         
         
        @@ -299,9 +300,9 @@ have the following C++ definition :

         class Vector {
         public:
        -	Vector();
        -	~Vector();
        -	double x,y,z;
        +  Vector();
        +  ~Vector();
        +  double x,y,z;
         };
         
        diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index 77ea5f3b6..31fae0321 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -208,8 +208,8 @@ $ swig -tcl example.i $ gcc example.c example_wrap.c \ -Xlinker -export-dynamic \ -DHAVE_CONFIG_H -I/usr/local/include/ \ - -L/usr/local/lib -ltcl -lm -ldl \ - -o mytclsh + -L/usr/local/lib -ltcl -lm -ldl \ + -o mytclsh @@ -626,11 +626,11 @@ CFLAGS = /Z7 /Od /c /nologo TCL_INCLUDES = -Id:\tcl8.0a2\generic -Id:\tcl8.0a2\win TCLLIB = d:\tcl8.0a2\win\tcl80.lib -tcl:: - ..\..\swig -tcl -o $(WRAPFILE) $(INTERFACE) - $(CC) $(CFLAGS) $(TCL_INCLUDES) $(SRCS) $(WRAPFILE) - set LIB=$(TOOLS)\lib - $(LINK) $(LOPT) -out:example.dll $(LIBS) $(TCLLIB) example.obj example_wrap.obj +tcl: + ..\..\swig -tcl -o $(WRAPFILE) $(INTERFACE) + $(CC) $(CFLAGS) $(TCL_INCLUDES) $(SRCS) $(WRAPFILE) + set LIB=$(TOOLS)\lib + $(LINK) $(LOPT) -out:example.dll $(LIBS) $(TCLLIB) example.obj example_wrap.obj @@ -981,7 +981,7 @@ This provides a very natural interface. For example,
         struct Vector {
        -	double x,y,z;
        +  double x,y,z;
         };
         
         
        @@ -2466,8 +2466,9 @@ you might define a typemap like this: %module example %typemap(in) int { - if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR) return TCL_ERROR; - printf("Received an integer : %d\n",$1); + if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR) + return TCL_ERROR; + printf("Received an integer : %d\n",$1); } %inline %{ extern int fact(int n); @@ -2504,8 +2505,9 @@ You can refine this by supplying an optional parameter name. For example: %module example %typemap(in) int n { - if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR) return TCL_ERROR; - printf("n = %d\n",$1); + if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR) + return TCL_ERROR; + printf("n = %d\n",$1); } %inline %{ extern int fact(int n); @@ -2527,8 +2529,9 @@ the typemap system follows typedef declarations. For example:
         %typemap(in) int n {
        -        if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR) return TCL_ERROR;
        -	printf("n = %d\n",$1);
        +  if (Tcl_GetIntFromObj(interp,$input,&$1) == TCL_ERROR)
        +    return TCL_ERROR;
        +  printf("n = %d\n",$1);
         }
         %inline %{
         typedef int Integer;
        @@ -2976,10 +2979,10 @@ work)
         
         %typemap(in) int, short, long {
        -   int temp;
        -   if (Tcl_GetIntFromObj(interp, $input, &temp) == TCL_ERROR)
        -      return TCL_ERROR;
        -   $1 = ($1_ltype) temp;
        +  int temp;
        +  if (Tcl_GetIntFromObj(interp, $input, &temp) == TCL_ERROR)
        +    return TCL_ERROR;
        +  $1 = ($1_ltype) temp;
         }
         
        @@ -3154,8 +3157,8 @@ subdirectory which has the same name as the package. For example :
         ./example/
        -	   pkgIndex.tcl           # The file created by pkg_mkIndex
        -	   example.so             # The SWIG generated module
        +           pkgIndex.tcl           # The file created by pkg_mkIndex
        +           example.so             # The SWIG generated module
         

        @@ -3265,14 +3268,14 @@ Our script allows easy array access as follows :

         set a [Array double 100]                   ;# Create a double [100]
         for {set i 0} {$i < 100} {incr i 1} {      ;# Clear the array
        -	$a set $i 0.0
        +        $a set $i 0.0
         }
         $a set 3 3.1455                            ;# Set an individual element
         set b [$a get 10]                          ;# Retrieve an element
         
         set ia [Array int 50]                      ;# Create an int[50]
         for {set i 0} {$i < 50} {incr i 1} {       ;# Clear it
        -	$ia set $i 0
        +        $ia set $i 0
         }
         $ia set 3 7                                ;# Set an individual element
         set ib [$ia get 10]                        ;# Get an individual element
        diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
        index 6dfc5d05d..0dc725a9f 100644
        --- a/Doc/Manual/Typemaps.html
        +++ b/Doc/Manual/Typemaps.html
        @@ -3051,8 +3051,8 @@ For example, suppose you had a structure like this:
         
         
         struct SomeObject {
        -	float  value[4];
        -        ...
        +  float  value[4];
        +  ...
         };
         
        @@ -3166,9 +3166,9 @@ checking the values of function arguments. For example:

        %module math %typemap(check) double posdouble { - if ($1 < 0) { - croak("Expecting a positive number"); - } + if ($1 < 0) { + croak("Expecting a positive number"); + } } ... @@ -4511,22 +4511,22 @@ The following excerpt from the Python module illustrates this: /* Note: %typecheck(X) is a macro for %typemap(typecheck,precedence=X) */ %typecheck(SWIG_TYPECHECK_INTEGER) - int, short, long, - unsigned int, unsigned short, unsigned long, - signed char, unsigned char, - long long, unsigned long long, - const int &, const short &, const long &, - const unsigned int &, const unsigned short &, const unsigned long &, - const long long &, const unsigned long long &, - enum SWIGTYPE, - bool, const bool & + int, short, long, + unsigned int, unsigned short, unsigned long, + signed char, unsigned char, + long long, unsigned long long, + const int &, const short &, const long &, + const unsigned int &, const unsigned short &, const unsigned long &, + const long long &, const unsigned long long &, + enum SWIGTYPE, + bool, const bool & { $1 = (PyInt_Check($input) || PyLong_Check($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_DOUBLE) - float, double, - const float &, const double & + float, double, + const float &, const double & { $1 = (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input)) ? 1 : 0; } diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index 78689c2fb..1c99804f1 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -636,7 +636,7 @@ example. For example: PyObject *o = PyTuple_GetItem(varargs,i); if (!PyString_Check(o)) { PyErr_SetString(PyExc_ValueError,"Expected a string"); - free(argv); + free(argv); return NULL; } argv[i] = PyString_AsString(o); diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index d7c1932b7..b95105bdd 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -164,7 +164,7 @@ PYTHON_LIB: D:\python21\libs\python21.lib

        TCL_INCLUDE : Set this to the directory containing tcl.h
        TCL_LIB : Set this to the TCL library including path for linking

        -Example using ActiveTcl 8.3.3.3
        +Example using ActiveTcl 8.3.3.3
        TCL_INCLUDE: D:\tcl\include
        TCL_LIB: D:\tcl\lib\tcl83.lib
        From f278fdac59471711dd4753c73e795c1cd4683c13 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 29 Dec 2015 19:16:08 +0000 Subject: [PATCH 221/732] Replace pdf documentation generation tool with wkhtmltopdf from htmldoc htmldoc does not seem to be generating pdfs properly any more (on Ubuntu 14.04). It has been replaced with wkhtmltopdf which is better as it supports css and so the patched version of htmldoc with the simple css support is no longer required. wkhtmldoc does have have a few problems though which have been addressed in prior commits: -

        Text

        style links need changing to:

        Text

        - tabs in
         elements should be expanded to 8 spaces by default, but
          are expanded to just one space and css expand-tab is not recognised.
        
        The 
           elements do not always select a fixed-width font -
        try installing a Courier font.
        ---
         Doc/Manual/Makefile | 26 ++++++++++++++------------
         1 file changed, 14 insertions(+), 12 deletions(-)
        
        diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
        index 7347691cd..2c90e91e5 100644
        --- a/Doc/Manual/Makefile
        +++ b/Doc/Manual/Makefile
        @@ -26,25 +26,27 @@ maketoc:
         CCache.html: ../../CCache/ccache.yo
         	yodl2html -o CCache.html ../../CCache/ccache.yo
         
        +# Tabs in the html files will stop the build as wkhtmltopdf does not expand them correctly - replace them with the appropriate number of tabs
         # Use htmltidy to warn about some HTML errors. Note that it is not used to clean/tidy the HTML,
         # it is just used as a primitive HTML checker.
         # CCache.html is generated by yodl2html and has a few insignificant problems, so we don't put it through tidy
         check:
        -	tidy -errors --gnu-emacs yes -quiet index.html
        -	tidy -errors --gnu-emacs yes -quiet Sections.html
        -	all=`sed '/^#/d' chapters | grep -v CCache.html`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done;
        +	all="index.html Sections.html `sed '/^#/d' chapters | grep -v CCache.html`" && for a in $$all; do echo "Check for tabs $$a" && if grep -P '\t' $$a; then echo "Please delete the tabs from the lines above" && exit 1; fi; done && for a in $$all; do echo "HTML tidy check $$a" && tidy -errors --gnu-emacs yes -quiet $$a; done;
         
        -generate: swightml.book swigpdf.book
        +# Note wkhtmltopdf limitations for generating pdf docs:
        +#  1) 

        Text

        style links don't work and need changing to +#

        Text

        +# 2) Tabs in
         elements should be expanded to 8 spaces by default, but
        +#     are expanded to just one space and css tab-size is not working.
        +#  3) 
           elements do not always select a fixed-width font - try installing the
        +#     Courier font to fix.
        +generate: SWIGDocumentation.html
        +	wkhtmltopdf --margin-top 20mm --margin-bottom 20mm --margin-left 10mm --margin-right 10mm --header-font-size 6 --footer-font-size 6 --header-spacing 6 --footer-spacing 6 --header-center '[doctitle]' --footer-left '[subsection]' --footer-right '[page]' SWIGDocumentation.html SWIGDocumentation.pdf
        +
        +SWIGDocumentation.html: swightml.book
         	htmldoc --batch swightml.book || true
        -	htmldoc --batch swigpdf.book || true
         	python fixstyle.py SWIGDocumentation.html
         
        -swigpdf.book: chapters Sections.html
        -	echo "#HTMLDOC 1.8.24" > swigpdf.book
        -	echo -t pdf13 -f SWIGDocumentation.pdf $(HTMLDOC_OPTIONS) --stylesheet style.css >> swigpdf.book
        -	echo "Sections.html" >> swigpdf.book
        -	cat chapters >> swigpdf.book
        -
         swightml.book: chapters Sections.html
         	echo "#HTMLDOC 1.8.24" > swightml.book
         	echo -t html -f SWIGDocumentation.html $(HTMLDOC_OPTIONS) >> swightml.book
        @@ -53,9 +55,9 @@ swightml.book: chapters Sections.html
         
         maintainer-clean: clean-baks
         	rm -f swightml.book
        -	rm -f swigpdf.book
         	rm -f SWIGDocumentation.html
         	rm -f SWIGDocumentation.pdf
        +	rm -rf linkchecker-tmp
         
         clean-baks:
         	rm -f *.bak
        
        From 58279a46279d4598a370329bd068fe2235130010 Mon Sep 17 00:00:00 2001
        From: William S Fulton 
        Date: Wed, 30 Dec 2015 00:27:56 +0000
        Subject: [PATCH 222/732] HTML pdf doc generation fixes
        
        wkhtmltopdf isn't using a fixed-width font for CSS font-family:monospace.
        Nor is it using one for 
          or  elements.
        Add in some Courier fonts for it to use - note that Courier 10 Pitch is
        installed on Ubuntu by default. Note these fonts need to be installed on
        the system that generates the pdf documentation.
        
        Previously the htmldoc stylesheet was kept in place and the SWIG
        stylesheet was prepended to it inline in SWIGDocumentation.html.
        Now the SWIG stylesheet has been amended with most of the htmldoc
        stylesheet changes and completely replaced after htmldoc is run.
        ---
         Doc/Manual/Makefile    |  2 +-
         Doc/Manual/fixstyle.py | 15 ++++++++++-----
         Doc/Manual/style.css   | 10 +++++++++-
         3 files changed, 20 insertions(+), 7 deletions(-)
        
        diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
        index 2c90e91e5..c7769dc97 100644
        --- a/Doc/Manual/Makefile
        +++ b/Doc/Manual/Makefile
        @@ -39,7 +39,7 @@ check:
         #  2) Tabs in 
         elements should be expanded to 8 spaces by default, but
         #     are expanded to just one space and css tab-size is not working.
         #  3) 
           elements do not always select a fixed-width font - try installing the
        -#     Courier font to fix.
        +#     Courier font to fix - these have been added to style.css.
         generate: SWIGDocumentation.html
         	wkhtmltopdf --margin-top 20mm --margin-bottom 20mm --margin-left 10mm --margin-right 10mm --header-font-size 6 --footer-font-size 6 --header-spacing 6 --footer-spacing 6 --header-center '[doctitle]' --footer-left '[subsection]' --footer-right '[page]' SWIGDocumentation.html SWIGDocumentation.pdf
         
        diff --git a/Doc/Manual/fixstyle.py b/Doc/Manual/fixstyle.py
        index 1007d5949..a36096890 100644
        --- a/Doc/Manual/fixstyle.py
        +++ b/Doc/Manual/fixstyle.py
        @@ -1,6 +1,6 @@
         #!/usr/bin/python
         
        -# Adds the SWIG stylesheet to the generated documentation on a single page
        +# Replace the inline htmldoc stylesheet with the SWIG stylesheet
         
         import sys
         import string
        @@ -14,11 +14,16 @@ swigstyle = "\n" + open("style.css").read()
         
         lines = data.splitlines()
         result = [ ]
        +skip = False
         for s in lines:
        -	if s == "":
        +        result.append(s)
        +        skip = False
         
         data = "\n".join(result)
         
        diff --git a/Doc/Manual/style.css b/Doc/Manual/style.css
        index 02329e56f..45e51e35b 100644
        --- a/Doc/Manual/style.css
        +++ b/Doc/Manual/style.css
        @@ -32,6 +32,7 @@ div.code {
           margin-left: 4em;
           margin-right: 4em;
           background-color: #F0FFFF;
        +  font-family: "Courier New", Courier, "Courier 10 Pitch", monospace;
         }
         
         div.targetlang {
        @@ -41,9 +42,9 @@ div.targetlang {
           margin-left: 4em;
           margin-right: 4em;
           background-color: #d7f6bb;
        +  font-family: "Courier New", Courier, "Courier 10 Pitch", monospace;
         }
         
        -
         div.shell {
           border-style: solid; 
           border-width: 1px; 
        @@ -51,6 +52,7 @@ div.shell {
           margin-left: 4em;
           margin-right: 4em;
           background-color: #DCDCDC;
        +  font-family: "Courier New", Courier, "Courier 10 Pitch", monospace;
         }
         
         div.diagram {
        @@ -60,6 +62,7 @@ div.diagram {
           margin-left: 4em;
           margin-right: 4em;
           background-color: #FFEBCD;
        +  font-family: "Courier New", Courier, "Courier 10 Pitch", monospace;
         }
         
         ul li p {
        @@ -82,3 +85,8 @@ div.indent p {
           margin-right: 0;
         }
         
        +pre, code, tt {
        +  font-family: "Courier New", Courier, "Courier 10 Pitch", monospace;
        +}
        +
        +body { font-family: serif; }
        
        From 28e1a64dcb1a2499f1fcac5b6fe4de34b36a69c3 Mon Sep 17 00:00:00 2001
        From: William S Fulton 
        Date: Wed, 30 Dec 2015 22:04:52 +0000
        Subject: [PATCH 223/732] html docs update
        
        ---
         Doc/Manual/SWIG.html | 9 +++++++--
         1 file changed, 7 insertions(+), 2 deletions(-)
        
        diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
        index be26c94b4..178247e42 100644
        --- a/Doc/Manual/SWIG.html
        +++ b/Doc/Manual/SWIG.html
        @@ -111,7 +111,7 @@ where filename is a SWIG interface file or a C/C++ header file.
         Below is a subset of options that can be used.
         Additional options are also defined for each target language.  A full list
         can be obtained by typing swig -help or swig
        --lang -help.
        +-<lang> -help for language <lang> specific options.
         

        @@ -120,26 +120,31 @@ can be obtained by typing swig -help or swig
         -clisp                Generate CLISP wrappers
         -cffi                 Generate CFFI wrappers
         -csharp               Generate C# wrappers
        +-d                    Generate D wrappers
         -go                   Generate Go wrappers
         -guile                Generate Guile wrappers
         -java                 Generate Java wrappers
        +-javascript           Generate Javascript wrappers
         -lua                  Generate Lua wrappers
         -modula3              Generate Modula 3 wrappers
         -mzscheme             Generate Mzscheme wrappers
         -ocaml                Generate Ocaml wrappers
        +-octave               Generate Octave wrappers
         -perl                 Generate Perl wrappers
         -php                  Generate PHP wrappers
         -pike                 Generate Pike wrappers
         -python               Generate Python wrappers
         -r                    Generate R (aka GNU S) wrappers
         -ruby                 Generate Ruby wrappers
        +-scilab               Generate Scilab wrappers
         -sexp                 Generate Lisp S-Expressions wrappers
         -tcl                  Generate Tcl wrappers
         -uffi                 Generate Common Lisp / UFFI wrappers
         -xml                  Generate XML wrappers
         
         -c++                  Enable C++ parsing
        --cppext ext           Change file extension of C++ generated files to ext (default is cxx, except for PHP which uses cpp)
        +-cppext ext           Change file extension of C++ generated files to ext
        +                      (default is cxx, except for PHP which uses cpp)
         -Dsymbol              Define a preprocessor symbol
         -Fstandard            Display error/warning messages in commonly used format
         -Fmicrosoft           Display error/warning messages in Microsoft format
        
        From 0aad186ea2eb52beb47d227b4b30b9ba2b08d657 Mon Sep 17 00:00:00 2001
        From: William S Fulton 
        Date: Wed, 30 Dec 2015 22:08:35 +0000
        Subject: [PATCH 224/732] changes file update for the pdf documentation
        
        ---
         CHANGES.current | 4 ++++
         1 file changed, 4 insertions(+)
        
        diff --git a/CHANGES.current b/CHANGES.current
        index e501bf836..983fd2e32 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.8 (in progress)
         ===========================
         
        +2015-12-30: wsfulton
        +            The pdf documentation is now generated by wkhtmltopdf and has colour
        +            for the code snippets just like the html documentation!
        +
         2015-12-23: ahnolds
                     [Python] Fixes for conversion of signed and unsigned integer types:
         
        
        From ec91de75b72ccb7ec20fffd5568dd38a966806e7 Mon Sep 17 00:00:00 2001
        From: William S Fulton 
        Date: Wed, 30 Dec 2015 22:22:02 +0000
        Subject: [PATCH 225/732] swig-3.0.8 release update
        
        ---
         ANNOUNCE                 | 2 +-
         CHANGES.current          | 2 +-
         Doc/Manual/Sections.html | 2 +-
         README                   | 2 +-
         RELEASENOTES             | 7 +++++++
         5 files changed, 11 insertions(+), 4 deletions(-)
        
        diff --git a/ANNOUNCE b/ANNOUNCE
        index d9b932e2c..6d21b23fb 100644
        --- a/ANNOUNCE
        +++ b/ANNOUNCE
        @@ -1,4 +1,4 @@
        -*** ANNOUNCE: SWIG 3.0.8 (in progress) ***
        +*** ANNOUNCE: SWIG 3.0.8 (31 Dec 2015) ***
         
         http://www.swig.org
         
        diff --git a/CHANGES.current b/CHANGES.current
        index 983fd2e32..68a301d68 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 3.0.8 (in progress)
        +Version 3.0.8 (31 Dec 2015)
         ===========================
         
         2015-12-30: wsfulton
        diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
        index e2615c3d2..f0cfd151c 100644
        --- a/Doc/Manual/Sections.html
        +++ b/Doc/Manual/Sections.html
        @@ -8,7 +8,7 @@
         

        SWIG-3.0 Documentation

        -Last update : SWIG-3.0.8 (in progress) +Last update : SWIG-3.0.8 (31 Dec 2015)

        Sections

        diff --git a/README b/README index e3f15e4da..86c4fef2d 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 3.0.8 (in progress) +Version: 3.0.8 (31 Dec 2015) 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 895caa2dd..3f08074ab 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -7,6 +7,13 @@ Release Notes Detailed release notes are available with the release and are also published on the SWIG web site at http://swig.org/release.html. +SWIG-3.0.8 summary: +- pdf documentation enhancements. +- Various Python 3.5 issues fixed. +- std::array support added for Ruby and Python. +- shared_ptr support added for Ruby. +- Minor improvements for CFFI, Go, Java, Perl, Python, Ruby. + SWIG-3.0.7 summary: - Add support for Octave-4.0.0. - Remove potential Android security exploit in generated Java classes. From 6b4d9d7bfada322717f25d0e190a11ff77fa62d1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 31 Dec 2015 07:50:57 +0000 Subject: [PATCH 226/732] Add check that mingw gcc is installed when making release --- Tools/mkwindows.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tools/mkwindows.sh b/Tools/mkwindows.sh index 6042361b3..f3a20409a 100755 --- a/Tools/mkwindows.sh +++ b/Tools/mkwindows.sh @@ -44,6 +44,9 @@ else zip=zip fi extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux" + echo "Checking that mingw gcc is installed/available" + i586-mingw32msvc-gcc --version || exit 1 + i586-mingw32msvc-g++ --version || exit 1 else if test "$cygwin"; then echo "Building native Windows executable on Cygwin" From 719c7d532ccf8489fb218ed1337ecfd9c8e15f33 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 31 Dec 2015 18:00:39 +0000 Subject: [PATCH 227/732] htmldoc patch no longer needed since pdf docs are now generated by wkhtmltopdf --- Doc/Manual/margin-left.patch | 277 ----------------------------------- 1 file changed, 277 deletions(-) delete mode 100644 Doc/Manual/margin-left.patch diff --git a/Doc/Manual/margin-left.patch b/Doc/Manual/margin-left.patch deleted file mode 100644 index 8bef6305c..000000000 --- a/Doc/Manual/margin-left.patch +++ /dev/null @@ -1,277 +0,0 @@ -# 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 -# 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. -# -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 *); - - /* - * Output options... -@@ -4230,9 +4231,24 @@ - para->child = para->last_child = NULL; - } - -- parse_doc(t->child, left, right, bottom, top, x, y, page, NULL, -+ { -+ int num_indent = 0; -+ uchar *cname; -+ -+ if (cname = htmlGetVariable(t, (uchar *)"class")) { -+ num_indent = lookup_div_class(cname); -+ *left += 5.0f * num_indent; -+ *x = *left; -+ } -+ -+ parse_doc(t->child, left, right, bottom, top, x, y, page, NULL, - needspace); - -+ if (num_indent > 0) { -+ *left -= 5.0f * num_indent; -+ } -+ } -+ - if (para->child != NULL) - { - parse_paragraph(para, *left, *right, *bottom, *top, x, y, page, *needspace); -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 -+ * for margin-left: em; -+ * -+ * Copyright (C) 2005 John Lenz -+ * -+ * Released under GNU GPL v2 or above. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "types.h" -+ -+#define BUFF_SIZE 512 -+ -+struct div_entry { -+ uchar class_name[BUFF_SIZE]; -+ int indent; -+ struct div_entry *next; -+}; -+ -+static struct div_entry *head = 0; -+ -+/* These are the parsing states */ -+#define IGNORE_TILL_SEMI 0 -+#define IGNORE_TILL_CLOSE_BRACE 1 -+#define READING_DIV 2 -+#define READING_CLASS 3 -+#define READING_ATTRIBUTE 4 -+#define READING_NUM 5 -+#define CHECKING_ONLY_DIV 6 -+ -+static int at_eof = 0; -+ -+static int strucmp(uchar *a, uchar *b) { -+ int i; -+ for (i = 0; a[i] && b[i]; i++) { -+ if (a[i] < b[i]) return -1; -+ if (a[i] > b[i]) return 1; -+ } -+ /* This isn't right, but who cares...*/ -+ if (a[i] || b[i]) return 1; -+ return 0; -+} -+ -+static int read_word(FILE *f, const char *word) { -+ char c; -+ for (int idx = 0; word[idx]; idx++) { -+ c = getc(f); -+ if (c == EOF) { -+ at_eof = 1; -+ return 0; -+ } -+ if (c != word[idx]) -+ return 0; -+ } -+ return 1; -+} -+ -+int lookup_div_class(uchar *name) { -+ struct div_entry *node = head; -+ -+ while (node) { -+ if (strucmp(node->class_name, name) == 0) -+ return node->indent; -+ node = node->next; -+ } -+ -+ return 0; -+} -+ -+void parse_style(char *fname) { -+ FILE *f; -+ char c; -+ int state; -+ struct div_entry *cur = 0; -+ int class_idx = 0; -+ char num[BUFF_SIZE]; -+ int num_idx = 0; -+ -+ if (!fname) return; -+ -+ f = fopen(fname, "r"); -+ if (!f) { -+ fprintf(stderr, "Unable to parse style\n"); -+ return; -+ } -+ -+ state = READING_DIV; -+ while (!at_eof && (c = getc(f)) != EOF) { -+ switch (state) { -+ -+ case IGNORE_TILL_SEMI: -+ if (c == ';') -+ state = READING_ATTRIBUTE; -+ break; -+ -+ case IGNORE_TILL_CLOSE_BRACE: -+ if (c == '}') -+ state = READING_DIV; -+ break; -+ -+ case READING_DIV: -+ if (c != ' ' && c != '\t' && c != '\n') { -+ if (c == 'd' && read_word(f, "iv.")) { -+ state = READING_CLASS; -+ cur = (struct div_entry *) malloc(sizeof(struct div_entry)); -+ memset(cur, 0, sizeof(struct div_entry)); -+ class_idx = 0; -+ } else -+ state = IGNORE_TILL_CLOSE_BRACE; -+ } -+ break; -+ -+ case READING_CLASS: -+ if (isalpha(c)) { -+ if (class_idx >= BUFF_SIZE-1) { -+ fprintf(stderr, "class size %s too long\n", cur->class_name); -+ free(cur); -+ state = IGNORE_TILL_CLOSE_BRACE; -+ } else { -+ cur->class_name[class_idx++] = c; -+ } -+ } else { -+ if (c == '{') { -+ cur->next = head; -+ head = cur; -+ state = READING_ATTRIBUTE; -+ } else -+ state = CHECKING_ONLY_DIV; -+ } -+ break; -+ -+ case READING_ATTRIBUTE: -+ if (c != ' ' && c != '\t' && c != '\n') { -+ if (c == '}') -+ state = READING_DIV; -+ else { -+ if (c == 'm' && read_word(f, "argin-left:")) { -+ num_idx = 0; -+ memset(num, 0, sizeof(num)); -+ state = READING_NUM; -+ } else { -+ state = IGNORE_TILL_SEMI; -+ } -+ } -+ } -+ break; -+ -+ case READING_NUM: -+ if (isdigit(c)) { -+ if (num_idx >= BUFF_SIZE - 1) { -+ fprintf(stderr, "Number too long\n"); -+ state = IGNORE_TILL_SEMI; -+ } else { -+ num[num_idx++] = c; -+ } -+ } else if (c != ' ' && c != '\t') { -+ if (num_idx > 0 && c == 'e' && read_word(f, "m")) -+ cur->indent = atoi(num); -+ state = IGNORE_TILL_SEMI; -+ } -+ break; -+ -+ case CHECKING_ONLY_DIV: -+ if (c != ' ' && c != '\t' && c != '\n') { -+ if (c == '{') { -+ cur->next = head; -+ head = cur; -+ state = READING_ATTRIBUTE; -+ } else { -+ free(cur); -+ state = IGNORE_TILL_CLOSE_BRACE; -+ } -+ } -+ break; -+ } -+ } -+ -+ fclose(f); -+} From a8cf1eddf8007eb6eb9080a77289cdc5c6873e6c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 31 Dec 2015 18:04:16 +0000 Subject: [PATCH 228/732] Bump version to 3.0.9 --- ANNOUNCE | 8 +- CHANGES | 158 +++++++++++++++++++++++++++++++++++++++ CHANGES.current | 156 +------------------------------------- Doc/Manual/Sections.html | 2 +- README | 2 +- configure.ac | 2 +- 6 files changed, 166 insertions(+), 162 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 6d21b23fb..b06aa53d2 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,8 +1,8 @@ -*** ANNOUNCE: SWIG 3.0.8 (31 Dec 2015) *** +*** ANNOUNCE: SWIG 3.0.9 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-3.0.8, the latest SWIG release. +We're pleased to announce SWIG-3.0.9, the latest SWIG release. What is SWIG? ============= @@ -27,11 +27,11 @@ Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-3.0.8.tar.gz + http://prdownloads.sourceforge.net/swig/swig-3.0.9.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-3.0.8.zip + http://prdownloads.sourceforge.net/swig/swigwin-3.0.9.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 29b36352c..9d110cad2 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,164 @@ 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 3.0.8 (31 Dec 2015) +=========================== + +2015-12-30: wsfulton + The pdf documentation is now generated by wkhtmltopdf and has colour + for the code snippets just like the html documentation! + +2015-12-23: ahnolds + [Python] Fixes for conversion of signed and unsigned integer types: + + No longer check for PyInt objects in Python3. Because PyInt_Check + and friends are #defined to the corresponding PyLong methods, this + had caused errors in Python3 where values greater than what could be + stored in a long were incorrectly interpreted as the value -1 with + the Python error indicator set to OverflowError. This applies to + both the conversions PyLong->long and PyLong->double. + + Conversion from PyLong to long, unsigned long, long long, and + unsigned long long now raise OverflowError instead of TypeError in + both Python2 and Python3 for PyLong values outside the range + expressible by the corresponding C type. This matches the existing + behavior for other integral types (signed and unsigned ints, shorts, + and chars), as well as the conversion for PyInt to all numeric + types. This also indirectly applies to the size_t and ptrdiff_t + types, which depend on the conversions for unsigned long and long. + +2015-12-19: wsfulton + [Python] Python 2 Unicode UTF-8 strings can be used as inputs to char * or + std::string types if the generated C/C++ code has SWIG_PYTHON_2_UNICODE defined. + +2015-12-17: wsfulton + Issues #286, #128 + Remove ccache-swig.1 man page - please use the CCache.html docs instead. + The yodl2man and yodl2html tools are no longer used and so SWIG no + longer has a dependency on these packages which were required when + building from git. + +2015-12-16: zturner/coleb + [Python] Fix Python3.5 interpreter assertions when objects are being + deleted due to an existing exception. Most notably in generators + which terminate using a StopIteration exception. Fixes #559 #560 #573. + If a further exception is raised during an object destruction, + PyErr_WriteUnraisable is used on this second exception and the + original exception bubbles through. + +2015-12-14: ahnolds/wsfulton + [Python] Add in missing initializers for tp_finalize, + nb_matrix_multiply, nb_inplace_matrix_multiply, ht_qualname + ht_cached_keys and tp_prev. + +2015-12-12: wsfulton + Fix STL wrappers to not generate <: digraphs. + For example std::vector<::X::Y> was sometimes generated, now + corrected to std::vector< ::X::Y >. + +2015-11-25: wsfulton + [Ruby] STL ranges and slices fixes. + + Ruby STL container setting slices fixes: + + Setting an STL container wrapper slice better matches the way Ruby + arrays work. The behaviour is now the same as Ruby arrays. The only + exception is the default value used when expanding a container + cannot be nil as this is not a valid type/value for C++ container + elements. + + Obtaining a Ruby STL container ranges and slices fixes: + + Access via ranges and slices now behave identically to Ruby arrays. + The fixes are mostly for out of range indices and lengths. + - Zero length slice requests return an empty container instead of nil. + - Slices which request a length greater than the size of the container + no longer chop off the last element. + - Ranges which used to return nil now return an empty array when the + the start element is a valid index. + + Ruby STL container negative indexing support improved. + + Using negative indexes to set values works the same as Ruby arrays, eg + + %template(IntVector) std::vector; + + iv = IntVector.new([1,2,3,4]) + iv[-4] = 9 # => [1,2,3,9] + iv[-5] = 9 # => IndexError + +2015-11-21: wsfulton + [Ruby, Python] Add std::array container wrappers. + + These work much like any of the other STL containers except Python/Ruby slicing + is somewhat limited because the array is a fixed size. Only slices of + the full size are supported. + +2015-10-10: wsfulton + [Python] #539 - Support Python 3.5 and -builtin. PyAsyncMethods is a new + member in PyHeapTypeObject. + +2015-10-06: ianlancetaylor + [Go] Don't emit a constructor function for a director + class with an abstract method, since the function will + always panic. + +2015-10-01: wsfulton + Fix %shared_ptr support for private and protected inheritance. + - Remove unnecessary Warning 520: Derived class 'Derived' of 'Base' + is not similarly marked as a smart pointer + - Do not generate code that attempts to cast up the inheritance chain in the + type system runtime in such cases as it doesn't compile and can't be used. + Remove unnecessary warning 520 for %shared_ptr when the base class is ignored. + +2015-10-01: vkalinin + Fix #508: Fix segfault parsing anonymous typedef nested classes. + +2015-09-26: wsfulton + [Ruby] Add shared_ptr support + +2015-09-13: kkaempf + [Ruby] Resolve tracking bug - issue #225. + The bug is that the tracking code uses a ruby hash and thus may + allocate objects (Bignum) while running the GC. This was tolerated in + 1.8 but is invalid (raises an exception) in 1.9. + The patch uses a C hash (also used by ruby) instead. + +2015-09-09: lyze + [CFFI] Extend the "export" feature in the CFFI module to support + exporting to a specified package. + +2015-09-04: olly + [Python] Fix docstrings for %callback functions. + +2015-09-03: demi-rluddy + [Go] Removed golang stringing for signed/unsigned char + + Changed default handling of signed char* and unsigned char* to be + opaque pointers rather than strings, similarly to how other + languages work. + + Any existing code relying on treating signed char* or unsigned + char* as a string can restore the old behavior with typemaps.i by + using %apply to copy the [unchanged] char* behavior. + + *** POTENTIAL INCOMPATIBILITY *** + +2015-08-07: talby + [Perl] tidy -Wtautological-constant-out-of-range-compare warnings when building generated code under clang + +2015-08-07: xantares + [Python] pep257 & numpydoc conforming docstrings: + - Mono-line module docsstring + - Rewrite autodoc parameters section in numpydoc style: + https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt + - One line summary should end with "." + - Adds a blank line after class docstring + +2015-08-05: vadz + [Java] Make (char* STRING, size_t LENGTH) typemaps usable for + strings of other types, e.g. "unsigned char*". + Version 3.0.7 (3 Aug 2015) ========================== diff --git a/CHANGES.current b/CHANGES.current index 68a301d68..4985bffa0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,160 +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 3.0.8 (31 Dec 2015) +Version 3.0.9 (in progress) =========================== -2015-12-30: wsfulton - The pdf documentation is now generated by wkhtmltopdf and has colour - for the code snippets just like the html documentation! - -2015-12-23: ahnolds - [Python] Fixes for conversion of signed and unsigned integer types: - - No longer check for PyInt objects in Python3. Because PyInt_Check - and friends are #defined to the corresponding PyLong methods, this - had caused errors in Python3 where values greater than what could be - stored in a long were incorrectly interpreted as the value -1 with - the Python error indicator set to OverflowError. This applies to - both the conversions PyLong->long and PyLong->double. - - Conversion from PyLong to long, unsigned long, long long, and - unsigned long long now raise OverflowError instead of TypeError in - both Python2 and Python3 for PyLong values outside the range - expressible by the corresponding C type. This matches the existing - behavior for other integral types (signed and unsigned ints, shorts, - and chars), as well as the conversion for PyInt to all numeric - types. This also indirectly applies to the size_t and ptrdiff_t - types, which depend on the conversions for unsigned long and long. - -2015-12-19: wsfulton - [Python] Python 2 Unicode UTF-8 strings can be used as inputs to char * or - std::string types if the generated C/C++ code has SWIG_PYTHON_2_UNICODE defined. - -2015-12-17: wsfulton - Issues #286, #128 - Remove ccache-swig.1 man page - please use the CCache.html docs instead. - The yodl2man and yodl2html tools are no longer used and so SWIG no - longer has a dependency on these packages which were required when - building from git. - -2015-12-16: zturner/coleb - [Python] Fix Python3.5 interpreter assertions when objects are being - deleted due to an existing exception. Most notably in generators - which terminate using a StopIteration exception. Fixes #559 #560 #573. - If a further exception is raised during an object destruction, - PyErr_WriteUnraisable is used on this second exception and the - original exception bubbles through. - -2015-12-14: ahnolds/wsfulton - [Python] Add in missing initializers for tp_finalize, - nb_matrix_multiply, nb_inplace_matrix_multiply, ht_qualname - ht_cached_keys and tp_prev. - -2015-12-12: wsfulton - Fix STL wrappers to not generate <: digraphs. - For example std::vector<::X::Y> was sometimes generated, now - corrected to std::vector< ::X::Y >. - -2015-11-25: wsfulton - [Ruby] STL ranges and slices fixes. - - Ruby STL container setting slices fixes: - - Setting an STL container wrapper slice better matches the way Ruby - arrays work. The behaviour is now the same as Ruby arrays. The only - exception is the default value used when expanding a container - cannot be nil as this is not a valid type/value for C++ container - elements. - - Obtaining a Ruby STL container ranges and slices fixes: - - Access via ranges and slices now behave identically to Ruby arrays. - The fixes are mostly for out of range indices and lengths. - - Zero length slice requests return an empty container instead of nil. - - Slices which request a length greater than the size of the container - no longer chop off the last element. - - Ranges which used to return nil now return an empty array when the - the start element is a valid index. - - Ruby STL container negative indexing support improved. - - Using negative indexes to set values works the same as Ruby arrays, eg - - %template(IntVector) std::vector; - - iv = IntVector.new([1,2,3,4]) - iv[-4] = 9 # => [1,2,3,9] - iv[-5] = 9 # => IndexError - -2015-11-21: wsfulton - [Ruby, Python] Add std::array container wrappers. - - These work much like any of the other STL containers except Python/Ruby slicing - is somewhat limited because the array is a fixed size. Only slices of - the full size are supported. - -2015-10-10: wsfulton - [Python] #539 - Support Python 3.5 and -builtin. PyAsyncMethods is a new - member in PyHeapTypeObject. - -2015-10-06: ianlancetaylor - [Go] Don't emit a constructor function for a director - class with an abstract method, since the function will - always panic. - -2015-10-01: wsfulton - Fix %shared_ptr support for private and protected inheritance. - - Remove unnecessary Warning 520: Derived class 'Derived' of 'Base' - is not similarly marked as a smart pointer - - Do not generate code that attempts to cast up the inheritance chain in the - type system runtime in such cases as it doesn't compile and can't be used. - Remove unnecessary warning 520 for %shared_ptr when the base class is ignored. - -2015-10-01: vkalinin - Fix #508: Fix segfault parsing anonymous typedef nested classes. - -2015-09-26: wsfulton - [Ruby] Add shared_ptr support - -2015-09-13: kkaempf - [Ruby] Resolve tracking bug - issue #225. - The bug is that the tracking code uses a ruby hash and thus may - allocate objects (Bignum) while running the GC. This was tolerated in - 1.8 but is invalid (raises an exception) in 1.9. - The patch uses a C hash (also used by ruby) instead. - -2015-09-09: lyze - [CFFI] Extend the "export" feature in the CFFI module to support - exporting to a specified package. - -2015-09-04: olly - [Python] Fix docstrings for %callback functions. - -2015-09-03: demi-rluddy - [Go] Removed golang stringing for signed/unsigned char - - Changed default handling of signed char* and unsigned char* to be - opaque pointers rather than strings, similarly to how other - languages work. - - Any existing code relying on treating signed char* or unsigned - char* as a string can restore the old behavior with typemaps.i by - using %apply to copy the [unchanged] char* behavior. - - *** POTENTIAL INCOMPATIBILITY *** - -2015-08-07: talby - [Perl] tidy -Wtautological-constant-out-of-range-compare warnings when building generated code under clang - -2015-08-07: xantares - [Python] pep257 & numpydoc conforming docstrings: - - Mono-line module docsstring - - Rewrite autodoc parameters section in numpydoc style: - https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt - - One line summary should end with "." - - Adds a blank line after class docstring - -2015-08-05: vadz - [Java] Make (char* STRING, size_t LENGTH) typemaps usable for - strings of other types, e.g. "unsigned char*". diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index f0cfd151c..bfa58f1ae 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -8,7 +8,7 @@

        SWIG-3.0 Documentation

        -Last update : SWIG-3.0.8 (31 Dec 2015) +Last update : SWIG-3.0.9 (in progress)

        Sections

        diff --git a/README b/README index 86c4fef2d..b24475d61 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 3.0.8 (31 Dec 2015) +Version: 3.0.9 (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 f03702058..9dfdcbd9b 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],[3.0.8],[http://www.swig.org]) +AC_INIT([swig],[3.0.9],[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 5e141dedcec0ba50e9cd79fdff3a0e3f2f10e5fb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 5 Jan 2016 20:35:31 +0000 Subject: [PATCH 229/732] Octave tests on Travis now working reliably There is more memory (4GB) on new infra and running with -j2 instead of -j3 is less demanding on the memory. I think this has solved the gcc internal errors as they were probably due to lack of memory. --- .travis.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 32a29d37e..97cfc2df1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -154,14 +154,6 @@ matrix: - compiler: gcc os: linux env: SWIGLANG=ocaml - # Occasional gcc internal compiler error - - compiler: gcc - os: linux - env: SWIGLANG=octave SWIGJOBS=-j2 VER=3.8 - # Occasional gcc internal compiler error - - compiler: gcc - os: linux - env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.0 # Not quite working yet - compiler: gcc os: linux From d2ab7e8bad6bbc140e745d74ab2b07447512d612 Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Fri, 1 Jan 2016 15:29:35 -0500 Subject: [PATCH 230/732] Add support for ptrdiff_t and size_t == long long New fragment to check if long long is available using LLONG_MAX AsVal and From functions for ptrdiff_t and size_t now use long long if available and sizeof(ptrdiff_t) > sizeof(long) --- Lib/typemaps/primtypes.swg | 70 +++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/Lib/typemaps/primtypes.swg b/Lib/typemaps/primtypes.swg index 45632c31f..dd80eb775 100644 --- a/Lib/typemaps/primtypes.swg +++ b/Lib/typemaps/primtypes.swg @@ -148,6 +148,12 @@ SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val) /* long long/unsigned long long */ +%fragment("SWIG_LongLongAvailable","header", fragment="") %{ +#if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE) +# define SWIG_LONG_LONG_AVAILABLE +#endif +%} + %ensure_type_fragments(long long) %ensure_type_fragments(unsigned long long) @@ -157,42 +163,82 @@ SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val) /* size_t */ -%fragment(SWIG_From_frag(size_t),"header",fragment=SWIG_From_frag(unsigned long)) { +%fragment(SWIG_From_frag(size_t),"header",fragment=SWIG_From_frag(unsigned long),fragment=SWIG_From_frag(unsigned long long)) { SWIGINTERNINLINE SWIG_Object SWIG_From_dec(size_t)(size_t value) { - return SWIG_From(unsigned long)(%numeric_cast(value, unsigned long)); +%#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(size_t) <= sizeof(unsigned long)) { +%#endif + return SWIG_From(unsigned long)(%numeric_cast(value, unsigned long)); +%#ifdef SWIG_LONG_LONG_AVAILABLE + } else { + /* assume sizeof(size_t) <= sizeof(unsigned long long) */ + return SWIG_From(unsigned long long)(%numeric_cast(value, unsigned long long)); + } +%#endif } } -%fragment(SWIG_AsVal_frag(size_t),"header",fragment=SWIG_AsVal_frag(unsigned long)) { +%fragment(SWIG_AsVal_frag(size_t),"header",fragment=SWIG_AsVal_frag(unsigned long),fragment=SWIG_AsVal_frag(unsigned long long)) { SWIGINTERNINLINE int SWIG_AsVal_dec(size_t)(SWIG_Object obj, size_t *val) { - unsigned long v; - int res = SWIG_AsVal(unsigned long)(obj, val ? &v : 0); - if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, size_t); + int res = SWIG_TypeError; +%#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(size_t) <= sizeof(unsigned long)) { +%#endif + unsigned long v; + res = SWIG_AsVal(unsigned long)(obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, size_t); +%#ifdef SWIG_LONG_LONG_AVAILABLE + } else if (sizeof(size_t) <= sizeof(unsigned long long)) { + unsigned long long v; + res = SWIG_AsVal(unsigned long long)(obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, size_t); + } +%#endif return res; } } /* ptrdiff_t */ -%fragment(SWIG_From_frag(ptrdiff_t),"header",fragment=SWIG_From_frag(long)) { +%fragment(SWIG_From_frag(ptrdiff_t),"header",fragment=SWIG_From_frag(long),fragment=SWIG_From_frag(long long)) { SWIGINTERNINLINE SWIG_Object SWIG_From_dec(ptrdiff_t)(ptrdiff_t value) { - return SWIG_From(long)(%numeric_cast(value,long)); +%#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(ptrdiff_t) <= sizeof(long)) { +%#endif + return SWIG_From(long)(%numeric_cast(value, long)); +%#ifdef SWIG_LONG_LONG_AVAILABLE + } else { + /* assume sizeof(ptrdiff_t) <= sizeof(long long) */ + return SWIG_From(long long)(%numeric_cast(value, long long)); + } +%#endif } } -%fragment(SWIG_AsVal_frag(ptrdiff_t),"header",fragment=SWIG_AsVal_frag(long)) { +%fragment(SWIG_AsVal_frag(ptrdiff_t),"header",fragment=SWIG_AsVal_frag(long),fragment=SWIG_AsVal_frag(long long)) { SWIGINTERNINLINE int SWIG_AsVal_dec(ptrdiff_t)(SWIG_Object obj, ptrdiff_t *val) { - long v; - int res = SWIG_AsVal(long)(obj, val ? &v : 0); - if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, ptrdiff_t); + int res = SWIG_TypeError; +%#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(ptrdiff_t) <= sizeof(long)) { +%#endif + long v; + res = SWIG_AsVal(long)(obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, ptrdiff_t); +%#ifdef SWIG_LONG_LONG_AVAILABLE + } else if (sizeof(ptrdiff_t) <= sizeof(long long)) { + long long v; + res = SWIG_AsVal(long long)(obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, ptrdiff_t); + } +%#endif return res; } } From 4e2fc7d1159d0023d9bce496599d56429dde9216 Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Fri, 1 Jan 2016 15:32:53 -0500 Subject: [PATCH 231/732] Don't use long long if it isn't available Adds preprocessor checks to avoid defining functions that use long long if it isn't available Effects the following languages: javascript, octave, perl, python, r, ruby, tcl --- Lib/javascript/jsc/javascriptprimtypes.swg | 16 ++++++++++++---- Lib/javascript/v8/javascriptprimtypes.swg | 16 ++++++++++++---- Lib/octave/octprimtypes.swg | 20 ++++++++++++++++---- Lib/perl5/perlprimtypes.swg | 17 ++++++++++++----- Lib/python/pyprimtypes.swg | 18 ++++++++++++------ Lib/r/rfragments.swg | 20 ++++++++++++++++---- Lib/ruby/rubyprimtypes.swg | 21 ++++++++++++++++----- Lib/tcl/tclprimtypes.swg | 16 ++++++++++++---- 8 files changed, 108 insertions(+), 36 deletions(-) diff --git a/Lib/javascript/jsc/javascriptprimtypes.swg b/Lib/javascript/jsc/javascriptprimtypes.swg index 814805b95..20d575d9e 100644 --- a/Lib/javascript/jsc/javascriptprimtypes.swg +++ b/Lib/javascript/jsc/javascriptprimtypes.swg @@ -98,18 +98,21 @@ SWIG_AsVal_dec(unsigned long)(JSValueRef obj, unsigned long *val) %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE JSValueRef SWIG_From_dec(long long)(long long value) { return JSValueMakeNumber(context, value); } +%#endif } %fragment(SWIG_AsVal_frag(long long),"header", fragment=SWIG_AsVal_frag(long), fragment="SWIG_CanCastAsInteger", - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN int SWIG_AsVal_dec(long long)(JSValueRef obj, long long* val) { @@ -120,6 +123,7 @@ SWIG_AsVal_dec(long long)(JSValueRef obj, long long* val) return SWIG_OK; } +%#endif } /* unsigned long long */ @@ -127,19 +131,22 @@ SWIG_AsVal_dec(long long)(JSValueRef obj, long long* val) %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN JSValueRef SWIG_From_dec(unsigned long long)(unsigned long long value) { return (value > LONG_MAX) ? JSValueMakeNumber(context, value) : JSValueMakeNumber(context, %numeric_cast(value,long)); } +%#endif } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment=SWIG_AsVal_frag(unsigned long), fragment="SWIG_CanCastAsInteger", - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(JSValueRef obj, unsigned long long *val) { @@ -158,6 +165,7 @@ SWIG_AsVal_dec(unsigned long long)(JSValueRef obj, unsigned long long *val) return SWIG_OK; } +%#endif } /* double */ diff --git a/Lib/javascript/v8/javascriptprimtypes.swg b/Lib/javascript/v8/javascriptprimtypes.swg index fe826b863..c0055c48e 100644 --- a/Lib/javascript/v8/javascriptprimtypes.swg +++ b/Lib/javascript/v8/javascriptprimtypes.swg @@ -112,18 +112,21 @@ int SWIG_AsVal_dec(unsigned long)(v8::Handle obj, unsigned long *val) %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE v8::Handle SWIG_From_dec(long long)(long long value) { return SWIGV8_NUMBER_NEW(value); } +%#endif } %fragment(SWIG_AsVal_frag(long long),"header", fragment=SWIG_AsVal_frag(long), fragment="SWIG_CanCastAsInteger", - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN int SWIG_AsVal_dec(long long)(v8::Handle obj, long long* val) { @@ -134,6 +137,7 @@ int SWIG_AsVal_dec(long long)(v8::Handle obj, long long* val) return SWIG_OK; } +%#endif } /* unsigned long long */ @@ -141,19 +145,22 @@ int SWIG_AsVal_dec(long long)(v8::Handle obj, long long* val) %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE v8::Handle SWIG_From_dec(unsigned long long)(unsigned long long value) { return (value > LONG_MAX) ? SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long)); } +%#endif } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment=SWIG_AsVal_frag(unsigned long), fragment="SWIG_CanCastAsInteger", - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(v8::Handle obj, unsigned long long *val) { @@ -171,6 +178,7 @@ int SWIG_AsVal_dec(unsigned long long)(v8::Handle obj, unsigned long return SWIG_OK; } +%#endif } /* double */ diff --git a/Lib/octave/octprimtypes.swg b/Lib/octave/octprimtypes.swg index 6f43f21b0..663d1fe10 100644 --- a/Lib/octave/octprimtypes.swg +++ b/Lib/octave/octprimtypes.swg @@ -97,15 +97,20 @@ SWIG_AsVal_dec(bool)(const octave_value& ov, bool *val) // long long -%fragment(SWIG_From_frag(long long),"header") { +%fragment(SWIG_From_frag(long long),"header", + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE octave_value SWIG_From_dec(long long) (long long value) { return octave_int64(value); } +%#endif } -%fragment(SWIG_AsVal_frag(long long),"header") { +%fragment(SWIG_AsVal_frag(long long),"header", + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN int SWIG_AsVal_dec(long long)(const octave_value& ov, long long* val) { if (!ov.is_scalar_type()) @@ -127,16 +132,22 @@ SWIG_AsVal_dec(bool)(const octave_value& ov, bool *val) } return SWIG_OK; } +%#endif } -%fragment(SWIG_From_frag(unsigned long long),"header") { +%fragment(SWIG_From_frag(unsigned long long),"header", + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE octave_value SWIG_From_dec(unsigned long long) (unsigned long long value) { return octave_uint64(value); } +%#endif } -%fragment(SWIG_AsVal_frag(unsigned long long),"header") { +%fragment(SWIG_AsVal_frag(unsigned long long),"header", + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(const octave_value& ov, unsigned long long* val) { if (!ov.is_scalar_type()) @@ -171,6 +182,7 @@ SWIG_AsVal_dec(bool)(const octave_value& ov, bool *val) } return SWIG_OK; } +%#endif } // double diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg index 6dd18b61f..4cb675671 100644 --- a/Lib/perl5/perlprimtypes.swg +++ b/Lib/perl5/perlprimtypes.swg @@ -167,8 +167,9 @@ SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val) /* long long */ %fragment(SWIG_From_frag(long long),"header", - fragment=SWIG_From_frag(long), + fragment="SWIG_LongLongAvailable", fragment="") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE SV * SWIG_From_dec(long long)(long long value) { @@ -183,13 +184,14 @@ SWIG_From_dec(long long)(long long value) } return sv_2mortal(sv); } +%#endif } %fragment(SWIG_AsVal_frag(long long),"header", - fragment="", + fragment="SWIG_LongLongAvailable", fragment="", fragment="SWIG_CanCastAsInteger") { - +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN int SWIG_AsVal_dec(long long)(SV *obj, long long *val) { @@ -239,13 +241,15 @@ SWIG_AsVal_dec(long long)(SV *obj, long long *val) } return SWIG_TypeError; } +%#endif } /* unsigned long long */ %fragment(SWIG_From_frag(unsigned long long),"header", - fragment=SWIG_From_frag(long long), + fragment="SWIG_LongLongAvailable", fragment="") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE SV * SWIG_From_dec(unsigned long long)(unsigned long long value) { @@ -260,12 +264,14 @@ SWIG_From_dec(unsigned long long)(unsigned long long value) } return sv_2mortal(sv); } +%#endif } %fragment(SWIG_AsVal_frag(unsigned long long),"header", - fragment="", + fragment="SWIG_LongLongAvailable", fragment="", fragment="SWIG_CanCastAsInteger") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(SV *obj, unsigned long long *val) { @@ -312,6 +318,7 @@ SWIG_AsVal_dec(unsigned long long)(SV *obj, unsigned long long *val) } return SWIG_TypeError; } +%#endif } /* double */ diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg index 73a97bc5a..2ef09a1ba 100644 --- a/Lib/python/pyprimtypes.swg +++ b/Lib/python/pyprimtypes.swg @@ -180,20 +180,22 @@ SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val) /* long long */ %fragment(SWIG_From_frag(long long),"header", - fragment=SWIG_From_frag(long), - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE PyObject* SWIG_From_dec(long long)(long long value) { return ((value < LONG_MIN) || (value > LONG_MAX)) ? PyLong_FromLongLong(value) : PyLong_FromLong(%numeric_cast(value,long)); } +%#endif } %fragment(SWIG_AsVal_frag(long long),"header", fragment=SWIG_AsVal_frag(long), fragment="SWIG_CanCastAsInteger", - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN int SWIG_AsVal_dec(long long)(PyObject *obj, long long *val) { @@ -230,25 +232,28 @@ SWIG_AsVal_dec(long long)(PyObject *obj, long long *val) %#endif return res; } +%#endif } /* unsigned long long */ %fragment(SWIG_From_frag(unsigned long long),"header", - fragment=SWIG_From_frag(long long), - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE PyObject* SWIG_From_dec(unsigned long long)(unsigned long long value) { return (value > LONG_MAX) ? PyLong_FromUnsignedLongLong(value) : PyLong_FromLong(%numeric_cast(value,long)); } +%#endif } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment=SWIG_AsVal_frag(unsigned long), fragment="SWIG_CanCastAsInteger", - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val) { @@ -284,6 +289,7 @@ SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val) %#endif return res; } +%#endif } /* double */ diff --git a/Lib/r/rfragments.swg b/Lib/r/rfragments.swg index 2ec8f867f..b89212b05 100644 --- a/Lib/r/rfragments.swg +++ b/Lib/r/rfragments.swg @@ -44,21 +44,27 @@ SWIG_AsVal_dec(long)(SEXP obj, long *val) } -%fragment(SWIG_From_frag(long long),"header") { +%fragment(SWIG_From_frag(long long),"header", + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE SEXP SWIG_From_dec(long long)(long long value) { return Rf_ScalarInteger((int)value); } +%#endif } -%fragment(SWIG_AsVal_frag(long long),"header") { +%fragment(SWIG_AsVal_frag(long long),"header", + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE int SWIG_AsVal_dec(long long)(SEXP obj, long long *val) { if (val) *val = Rf_asInteger(obj); return SWIG_OK; } +%#endif } %fragment(SWIG_From_frag(unsigned long),"header") { @@ -80,22 +86,28 @@ SWIG_AsVal_dec(unsigned long)(SEXP obj, unsigned long *val) } -%fragment(SWIG_From_frag(unsigned long long),"header") { +%fragment(SWIG_From_frag(unsigned long long),"header", + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE SEXP SWIG_From_dec(unsigned long long)(unsigned long long value) { return Rf_ScalarInteger((int)value); } +%#endif } -%fragment(SWIG_AsVal_frag(unsigned long long),"header") { +%fragment(SWIG_AsVal_frag(unsigned long long),"header", + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE int SWIG_AsVal_dec(unsigned long long)(SEXP obj, unsigned long long *val) { if (val) *val = Rf_asInteger(obj); return SWIG_OK; } +%#endif } %fragment(SWIG_From_frag(double),"header") { diff --git a/Lib/ruby/rubyprimtypes.swg b/Lib/ruby/rubyprimtypes.swg index aa4f7ad37..3a848191c 100644 --- a/Lib/ruby/rubyprimtypes.swg +++ b/Lib/ruby/rubyprimtypes.swg @@ -124,15 +124,20 @@ SWIG_AsVal_dec(unsigned long)(VALUE obj, unsigned long *val) %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE VALUE SWIG_From_dec(long long)(long long value) { return LL2NUM(value); } +%#endif } -%fragment(SWIG_AsVal_frag(long long),"header",fragment="SWIG_ruby_failed") { +%fragment(SWIG_AsVal_frag(long long),"header", + fragment="SWIG_ruby_failed", + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE %ruby_aux_method(long long, NUM2LL, type == T_FIXNUM ? NUM2LL(obj) : rb_big2ll(obj)) SWIGINTERN int @@ -151,21 +156,26 @@ SWIG_AsVal_dec(long long)(VALUE obj, long long *val) } return SWIG_TypeError; } +%#endif } /* unsigned long long */ %fragment(SWIG_From_frag(unsigned long long),"header", - fragment=SWIG_From_frag(long long), - fragment="") { + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE VALUE SWIG_From_dec(unsigned long long)(unsigned long long value) { return ULL2NUM(value); } +%#endif } -%fragment(SWIG_AsVal_frag(unsigned long long),"header",fragment="SWIG_ruby_failed") { +%fragment(SWIG_AsVal_frag(unsigned long long),"header", + fragment="SWIG_ruby_failed", + fragment="SWIG_LongLongAvailable") { +%#ifdef SWIG_LONG_LONG_AVAILABLE %ruby_aux_method(long long, NUM2ULL, type == T_FIXNUM ? NUM2ULL(obj) : rb_big2ull(obj)) SWIGINTERN int @@ -184,6 +194,7 @@ SWIG_AsVal_dec(unsigned long long)(VALUE obj, unsigned long long *val) } return SWIG_TypeError; } +%#endif } /* double */ diff --git a/Lib/tcl/tclprimtypes.swg b/Lib/tcl/tclprimtypes.swg index e781798e0..3b6d04f59 100644 --- a/Lib/tcl/tclprimtypes.swg +++ b/Lib/tcl/tclprimtypes.swg @@ -112,8 +112,9 @@ SWIG_AsVal_dec(unsigned long)(Tcl_Obj *obj, unsigned long *val) { %fragment(SWIG_From_frag(long long),"header", fragment=SWIG_From_frag(long), - fragment="", + fragment="SWIG_LongLongAvailable", fragment="") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE Tcl_Obj* SWIG_From_dec(long long)(long long value) { @@ -125,11 +126,13 @@ SWIG_From_dec(long long)(long long value) return Tcl_NewStringObj(temp,-1); } } +%#endif } %fragment(SWIG_AsVal_frag(long long),"header", - fragment="", + fragment="SWIG_LongLongAvailable", fragment="") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN int SWIG_AsVal_dec(long long)(Tcl_Obj *obj, long long *val) { @@ -160,14 +163,16 @@ SWIG_AsVal_dec(long long)(Tcl_Obj *obj, long long *val) } return SWIG_TypeError; } +%#endif } /* unsigned long long */ %fragment(SWIG_From_frag(unsigned long long),"header", fragment=SWIG_From_frag(long long), - fragment="", + fragment="SWIG_LongLongAvailable", fragment="") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE Tcl_Obj* SWIG_From_dec(unsigned long long)(unsigned long long value) { @@ -179,12 +184,14 @@ SWIG_From_dec(unsigned long long)(unsigned long long value) return Tcl_NewStringObj(temp,-1); } } +%#endif } %fragment(SWIG_AsVal_frag(unsigned long long),"header", fragment=SWIG_AsVal_frag(unsigned long), - fragment="", + fragment="SWIG_LongLongAvailable", fragment="") { +%#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(Tcl_Obj *obj, unsigned long long *val) { @@ -216,6 +223,7 @@ SWIG_AsVal_dec(unsigned long long)(Tcl_Obj *obj, unsigned long long *val) } return SWIG_TypeError; } +%#endif } /* double */ From 12b62a562d0f4ac78ace09935140dc8833653f10 Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Tue, 22 Dec 2015 07:41:00 -0500 Subject: [PATCH 232/732] Python2 build on x64 should no longer fail --- appveyor.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d4ed6bbcf..9f2068903 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,13 +18,6 @@ environment: VER: 35 PY3: 1 -matrix: - allow_failures: - - platform: x64 - SWIGLANG: python - VSVER: 12 - VER: 27 - install: - date /T & time /T - set PATH=C:\cygwin\bin;%PATH% From fc8e76544c8fd9845a25903ca7d3074c487205b7 Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Wed, 6 Jan 2016 17:45:21 -0500 Subject: [PATCH 233/732] Unit tests for ptrdiff_t/size_t max/min in Python --- Examples/test-suite/primitive_types.i | 11 +++++++ .../python/primitive_types_runme.py | 31 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i index 29b44ec8c..17b7a8335 100644 --- a/Examples/test-suite/primitive_types.i +++ b/Examples/test-suite/primitive_types.i @@ -368,6 +368,17 @@ macro(size_t, pfx, sizet) virtual const char* pfx##_##str(type x) { return "name"; } %enddef +/* checking size_t and ptrdiff_t typemaps */ +%include "stdint.i" +%inline { + size_t get_size_min() { return 0; } + size_t get_size_max() { return SIZE_MAX; } + ptrdiff_t get_ptrdiff_min() { return PTRDIFF_MIN; } + ptrdiff_t get_ptrdiff_max() { return PTRDIFF_MAX; } + + size_t size_echo (size_t val) { return val; } + ptrdiff_t ptrdiff_echo(ptrdiff_t val) { return val; } +} %inline { struct Foo diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py index 2f8b2d99c..c04dc9552 100644 --- a/Examples/test-suite/python/primitive_types_runme.py +++ b/Examples/test-suite/python/primitive_types_runme.py @@ -573,3 +573,34 @@ if val_double(sys.maxint + 1) != float(sys.maxint + 1): raise RuntimeError, "bad double typemap" if val_double(-sys.maxint - 2) != float(-sys.maxint - 2): raise RuntimeError, "bad double typemap" + + +# Check the minimum and maximum values that fit in ptrdiff_t and size_t +def checkType(name, maxfunc, maxval, minfunc, minval, echofunc): + if maxfunc() != maxval: + raise RuntimeError, "bad " + name + " typemap" + if minfunc() != minval: + raise RuntimeError, "bad " + name + " typemap" + if echofunc(maxval) != maxval: + raise RuntimeError, "bad " + name + " typemap" + if echofunc(minval) != minval: + raise RuntimeError, "bad " + name + " typemap" + error = 0 + try: + echofunc(maxval + 1) + error = 1 + except OverflowError: + pass + if error == 1: + raise RuntimeError, "bad " + name + " typemap" + try: + echofunc(minval - 1) + error = 1 + except OverflowError: + pass + if error == 1: + raise RuntimeError, "bad " + name + " typemap" + +# sys.maxsize is the largest value supported by Py_ssize_t, which should be the same as ptrdiff_t +checkType("ptrdiff_t", get_ptrdiff_max, sys.maxsize, get_ptrdiff_min, -(sys.maxsize + 1), ptrdiff_echo) +checkType("size_t", get_size_max, (2 * sys.maxsize) + 1, get_size_min, 0, size_echo) From b1f45053bb7953fa6e0cb0492c0ffc796caf50fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20D=C3=B6nmez?= Date: Fri, 8 Jan 2016 12:00:03 +0200 Subject: [PATCH 234/732] Fix test failure on PPC{64} where the char is unsigned by default --- Examples/test-suite/li_boost_array.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/li_boost_array.i b/Examples/test-suite/li_boost_array.i index ab40991a1..be51d15e0 100644 --- a/Examples/test-suite/li_boost_array.i +++ b/Examples/test-suite/li_boost_array.i @@ -31,7 +31,7 @@ namespace boost { %inline %{ boost::array arrayOutVal() { - const char carray[] = { -2, -1, 0, 0, 1, 2 }; + const signed char carray[] = { -2, -1, 0, 0, 1, 2 }; boost::array myarray; for (size_t i=0; i<6; ++i) { myarray[i] = carray[i]; From 1875ff9002360a05f3461340e78bc12b3fd0ace8 Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Sat, 9 Jan 2016 10:41:24 -0500 Subject: [PATCH 235/732] Adding required define at beginning --- Examples/test-suite/primitive_types.i | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i index 17b7a8335..8eb2a13f2 100644 --- a/Examples/test-suite/primitive_types.i +++ b/Examples/test-suite/primitive_types.i @@ -369,6 +369,10 @@ macro(size_t, pfx, sizet) %enddef /* checking size_t and ptrdiff_t typemaps */ +%begin %{ +// Must be defined before Python.h is included, since this may indirectly include stdint.h +#define __STDC_LIMIT_MACROS +%} %include "stdint.i" %inline { size_t get_size_min() { return 0; } From 982b14370f2132463ebe0666d329854a807fc269 Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Sat, 9 Jan 2016 21:14:59 +0100 Subject: [PATCH 236/732] Ruby fix unbalanced braces causing issue with the YARD parser --- Source/Modules/ruby.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index f28ba9fd9..d21fe0fbb 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1744,6 +1744,9 @@ public: Printf(f->def, "#else\n"); Printv(f->def, "SWIGINTERN VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL); Printf(f->def, "#endif\n"); + Printf(f->def, "#if 0\n"); + Printf(f->def, "} /* c-mode */\n"); + Printf(f->def, "#endif\n"); } else if (current == CONSTRUCTOR_INITIALIZE) { Printv(f->def, "SWIGINTERN VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL); if (!varargs) { From 58550acc431585682b52f0363a9a839e61d92e65 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Jan 2016 17:35:41 +0000 Subject: [PATCH 237/732] Add changes entry for ptrdiff_t and size_t improvements --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 4985bffa0..5872d6161 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,3 +5,7 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.9 (in progress) =========================== +2016-01-10: ahnolds + Improved size_t and ptrdiff_t typemaps to support large values + on platforms where sizeof(size_t) > sizeof(unsigned long) and + sizeof(ptrdiff_t) > sizeof(long). From 2d094d7d9ffb14e25258025c3b44c001b466468f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Jan 2016 20:19:35 +0000 Subject: [PATCH 238/732] Alternative solution for Ruby unbalanced braces --- Source/Modules/ruby.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index d21fe0fbb..216d4ef27 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1739,14 +1739,13 @@ public: /* Now write the wrapper function itself */ if (current == CONSTRUCTOR_ALLOCATE) { + Printv(f->def, "SWIGINTERN VALUE\n", NIL); Printf(f->def, "#ifdef HAVE_RB_DEFINE_ALLOC_FUNC\n"); - Printv(f->def, "SWIGINTERN VALUE\n", wname, "(VALUE self) {", NIL); + Printv(f->def, wname, "(VALUE self)\n", NIL); Printf(f->def, "#else\n"); - Printv(f->def, "SWIGINTERN VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL); - Printf(f->def, "#endif\n"); - Printf(f->def, "#if 0\n"); - Printf(f->def, "} /* c-mode */\n"); + Printv(f->def, wname, "(int argc, VALUE *argv, VALUE self)\n", NIL); Printf(f->def, "#endif\n"); + Printv(f->def, "{\n", NIL); } else if (current == CONSTRUCTOR_INITIALIZE) { Printv(f->def, "SWIGINTERN VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL); if (!varargs) { From c63562744b3041639465cd271681e7cdb6ec7eda Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Mon, 11 Jan 2016 16:33:26 +0100 Subject: [PATCH 239/732] Ruby add support for docstring option in %module() This was already documented but not actually implemented. --- Source/Modules/ruby.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 216d4ef27..05852c232 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1011,6 +1011,8 @@ public: virtual int top(Node *n) { + String *mod_docstring = NULL; + /** * See if any Ruby module options have been specified as options * to the %module directive. @@ -1032,6 +1034,7 @@ public: multipleInheritance = true; director_multiple_inheritance = 1; } + mod_docstring = Getattr(options, "docstring"); } } @@ -1146,6 +1149,13 @@ public: Printf(f_header, "#define SWIG_init Init_%s\n", feature); Printf(f_header, "#define SWIG_name \"%s\"\n\n", module); + + if (mod_docstring && Len(mod_docstring)) { + Printf(f_header, "/*\n Document-module: %s\n\n%s\n*/\n", module, mod_docstring); + Delete(mod_docstring); + mod_docstring = NULL; + } + Printf(f_header, "static VALUE %s;\n", modvar); /* Start generating the initialization function */ From b3bedc210c723b29314688a87385797f7888fad3 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 12 Jan 2016 09:33:13 +1300 Subject: [PATCH 240/732] [Javascript] For v8 >= 4.3.0, use V8_MAJOR_VERSION. Fixes https://github.com/swig/swig/issues/561. --- CHANGES.current | 4 + Doc/Manual/Javascript.html | 13 ++- Lib/javascript/v8/javascriptcode.swg | 32 ++++---- Lib/javascript/v8/javascripthelpers.swg | 2 +- Lib/javascript/v8/javascriptrun.swg | 100 ++++++++++++------------ Lib/javascript/v8/javascriptruntime.swg | 17 +++- Tools/javascript/v8_shell.cxx | 20 ++--- 7 files changed, 107 insertions(+), 81 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 5872d6161..d925e5ffc 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.9 (in progress) =========================== +2016-01-12: olly + [Javascript] For v8 >= 4.3.0, use V8_MAJOR_VERSION. + Fixes https://github.com/swig/swig/issues/561. + 2016-01-10: ahnolds Improved size_t and ptrdiff_t typemaps to support large values on platforms where sizeof(size_t) > sizeof(unsigned long) and diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 56f83b763..405583b4f 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -90,11 +90,22 @@ $ swig -javascript -jsc example.i
        $ swig -c++ -javascript -jsc example.i

        The V8 code that SWIG generates should work with most versions from 3.11.10 up to 3.29.14 and later.

        -

        Specify the V8 version when running SWIG (e.g. 3.25.30)

        +

        The API headers for V8 >= 4.3.0 define constants which SWIG can use to +determine the V8 version it is compiling for. For versions < 4.3.0, you +need to specify the V8 version when running SWIG. This is specified as a hex +constant, but the constant is read as pairs of decimal digits, so for V8 +3.25.30 use constant 0x032530. This scheme can't represent components > 99, +but this constant is only useful for V8 < 4.3.0, and no V8 versions from +that era had a component > 99. For example:

         $ swig -c++ -javascript -v8 -DV8_VERSION=0x032530 example.i
        +

        If you're targetting V8 >= 4.3.0, you would just run swig like so:

        +

        +
        +$ swig -c++ -javascript -v8 example.i
        +

        This creates a C/C++ source file example_wrap.c or example_wrap.cxx. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module.

        The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrapped module will export one function which must be called to register the module with the Javascript interpreter. For example, if your module is named example the corresponding initializer for JavascriptCore would be

        diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg index 12db9b4ab..0bcb508f3 100644 --- a/Lib/javascript/v8/javascriptcode.swg +++ b/Lib/javascript/v8/javascriptcode.swg @@ -102,7 +102,7 @@ fail: %{ if(args.Length() == $jsargcount) { errorHandler.err.Clear(); -#if (SWIG_V8_VERSION < 0x031903) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) self = $jswrapper(args, errorHandler); if(errorHandler.err.IsEmpty()) { SWIGV8_ESCAPE(self); @@ -124,13 +124,13 @@ fail: %fragment ("js_dtor", "templates") %{ -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) static void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); -#elif (SWIG_V8_VERSION < 0x031900) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) static void $jswrapper(v8::Isolate *isolate, v8::Persistent object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); -#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) static void $jswrapper(v8::Isolate *isolate, v8::Persistent *object, SWIGV8_Proxy *proxy) { #else static void $jswrapper(const v8::WeakCallbackData &data) { @@ -148,11 +148,11 @@ static void $jswrapper(const v8::WeakCallbackData &dat object.Clear(); -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) object.Dispose(); -#elif (SWIG_V8_VERSION < 0x031900) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) object.Dispose(isolate); -#elif (SWIG_V8_VERSION < 0x032100) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100) object->Dispose(isolate); #else object->Dispose(); @@ -168,13 +168,13 @@ static void $jswrapper(const v8::WeakCallbackData &dat * ----------------------------------------------------------------------------- */ %fragment ("js_dtoroverride", "templates") %{ -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) static void $jswrapper(v8::Persistent object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); -#elif (SWIG_V8_VERSION < 0x031900) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) static void $jswrapper(v8::Isolate *isolate, v8::Persistent object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); -#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) static void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object> *object, SWIGV8_Proxy *proxy) { #else static void $jswrapper(const v8::WeakCallbackData &data) { @@ -188,13 +188,13 @@ static void $jswrapper(const v8::WeakCallbackData &dat } delete proxy; -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) object.Dispose(); -#elif (SWIG_V8_VERSION < 0x031900) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) object.Dispose(isolate); -#elif (SWIG_V8_VERSION < 0x032100) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100) object->Dispose(isolate); -#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) object->Dispose(); #else object.Clear(); @@ -326,7 +326,7 @@ fail: if(args.Length() == $jsargcount) { errorHandler.err.Clear(); -#if (SWIG_V8_VERSION < 0x031903) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) jsresult = $jswrapper(args, errorHandler); if(errorHandler.err.IsEmpty()) { SWIGV8_ESCAPE(jsresult); @@ -376,7 +376,7 @@ fail: %{ if (SWIGTYPE_p$jsbaseclass->clientdata && !(static_cast(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ.IsEmpty())) { -#if (SWIG_V8_VERSION < 0x031903) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) $jsmangledname_class->Inherit(static_cast(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ); #else $jsmangledname_class->Inherit( diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg index 969225401..f9901fb02 100644 --- a/Lib/javascript/v8/javascripthelpers.swg +++ b/Lib/javascript/v8/javascripthelpers.swg @@ -1,7 +1,7 @@ %insert(runtime) %{ // Note: since 3.19 there are new CallBack types, since 03.21.9 the old ones have been removed -#if (SWIG_V8_VERSION < 0x031903) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) typedef v8::InvocationCallback SwigV8FunctionCallback; typedef v8::AccessorGetter SwigV8AccessorGetterCallback; typedef v8::AccessorSetter SwigV8AccessorSetterCallback; diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index dc4d37a48..57c5afcd6 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -7,13 +7,13 @@ #define SWIGV8_SETWEAK_VERSION 0x032224 -#if (SWIG_V8_VERSION < 0x031803) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031803) #define SWIGV8_STRING_NEW2(cstr, len) v8::String::New(cstr, len) #else #define SWIGV8_STRING_NEW2(cstr, len) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::String::kNormalString, len) #endif -#if (SWIG_V8_VERSION < 0x031903) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) typedef v8::Handle SwigV8ReturnValue; typedef v8::Arguments SwigV8Arguments; typedef v8::AccessorInfo SwigV8PropertyCallbackInfo; @@ -27,11 +27,11 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return #endif -#if (SWIG_V8_VERSION < 0x032117) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032117) #define SWIGV8_HANDLESCOPE() v8::HandleScope scope #define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope #define SWIGV8_ESCAPE(val) return scope.Close(val) -#elif (SWIG_V8_VERSION < 0x032224) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032224) #define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent()); #define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope(v8::Isolate::GetCurrent()); #define SWIGV8_ESCAPE(val) return scope.Close(val) @@ -41,7 +41,7 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_ESCAPE(val) return scope.Escape(val) #endif -#if (SWIG_V8_VERSION < 0x032224) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032224) #define SWIGV8_ADJUST_MEMORY(size) v8::V8::AdjustAmountOfExternalAllocatedMemory(size) #define SWIGV8_CURRENT_CONTEXT() v8::Context::GetCurrent() #define SWIGV8_THROW_EXCEPTION(err) v8::ThrowException(err) @@ -55,7 +55,7 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym) #endif -#if (SWIG_V8_VERSION < 0x032318) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318) #define SWIGV8_ARRAY_NEW() v8::Array::New() #define SWIGV8_BOOLEAN_NEW(bool) v8::Boolean::New(bool) #define SWIGV8_EXTERNAL_NEW(val) v8::External::New(val) @@ -83,9 +83,9 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_NULL() v8::Null(v8::Isolate::GetCurrent()) #endif -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) #define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ = v8::Persistent::New(class); -#elif (SWIG_V8_VERSION < 0x031900) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) #define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ = v8::Persistent::New(v8::Isolate::GetCurrent(), class); #else #define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ.Reset(v8::Isolate::GetCurrent(), class); @@ -156,13 +156,13 @@ public: }; ~SWIGV8_Proxy() { -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) handle.ClearWeak(); handle.Dispose(); -#elif (SWIG_V8_VERSION < 0x032100) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100) handle.ClearWeak(v8::Isolate::GetCurrent()); handle.Dispose(v8::Isolate::GetCurrent()); -#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) handle.ClearWeak(); handle.Dispose(); #else @@ -170,7 +170,7 @@ public: handle.Reset(); #endif -#if (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) handle.Clear(); #endif @@ -187,11 +187,11 @@ class SWIGV8_ClientData { public: v8::Persistent class_templ; -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) void (*dtor) (v8::Persistent< v8::Value> object, void *parameter); -#elif (SWIG_V8_VERSION < 0x031900) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Value> object, void *parameter); -#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy); #else void (*dtor) (const v8::WeakCallbackData &data); @@ -205,7 +205,7 @@ SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Handle objRef, void * if(objRef->InternalFieldCount() < 1) return SWIG_ERROR; -#if (SWIG_V8_VERSION < 0x031511) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511) v8::Handle cdataRef = objRef->GetInternalField(0); SWIGV8_Proxy *cdata = static_cast(v8::External::Unwrap(cdataRef)); #else @@ -233,13 +233,13 @@ SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Handle objRef, void * } -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Persistent< v8::Value > object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); -#elif (SWIG_V8_VERSION < 0x031900) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Value > object, void *parameter) { SWIGV8_Proxy *proxy = static_cast(parameter); -#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy) { #else SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackData &data) { @@ -257,7 +257,7 @@ SWIGRUNTIME int SWIG_V8_GetInstancePtr(v8::Handle valRef, void **ptr) if(objRef->InternalFieldCount() < 1) return SWIG_ERROR; -#if (SWIG_V8_VERSION < 0x031511) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511) v8::Handle cdataRef = objRef->GetInternalField(0); SWIGV8_Proxy *cdata = static_cast(v8::External::Unwrap(cdataRef)); #else @@ -279,34 +279,34 @@ SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Handle obj, void *ptr, sw cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0; cdata->info = info; -#if (SWIG_V8_VERSION < 0x031511) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511) obj->SetPointerInInternalField(0, cdata); #else obj->SetAlignedPointerInInternalField(0, cdata); #endif -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) cdata->handle = v8::Persistent::New(obj); -#elif (SWIG_V8_VERSION < 0x031900) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) cdata->handle = v8::Persistent::New(v8::Isolate::GetCurrent(), obj); #else cdata->handle.Reset(v8::Isolate::GetCurrent(), obj); #endif -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) // clientdata must be set for owned data as we need to register the dtor if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) { cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor); } else { cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor); } -#elif (SWIG_V8_VERSION < 0x031918) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031918) if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) { cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor); } else { cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, SWIGV8_Proxy_DefaultDtor); } -#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) { cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor); } else { @@ -320,9 +320,9 @@ SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Handle obj, void *ptr, sw } #endif -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) cdata->handle.MarkIndependent(); -#elif (SWIG_V8_VERSION < 0x032100) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100) cdata->handle.MarkIndependent(v8::Isolate::GetCurrent()); #else cdata->handle.MarkIndependent(); @@ -351,15 +351,15 @@ SWIGRUNTIME v8::Handle SWIG_V8_NewPointerObj(void *ptr, swig_type_inf v8::Handle class_templ; if (ptr == NULL) { -#if (SWIG_V8_VERSION < 0x031903) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) SWIGV8_ESCAPE(SWIGV8_NULL()); #else v8::Local result = SWIGV8_NULL(); SWIGV8_ESCAPE(result); -#endif +#endif } -#if (SWIG_V8_VERSION < 0x031903) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) if(info->clientdata != 0) { class_templ = ((SWIGV8_ClientData*) info->clientdata)->class_templ; } else { @@ -483,7 +483,7 @@ swig_type_info *SwigV8Packed_UnpackData(v8::Handle valRef, void *ptr, v8::Handle objRef = valRef->ToObject(); -#if (SWIG_V8_VERSION < 0x031511) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511) v8::Handle cdataRef = objRef->GetInternalField(0); sobj = static_cast(v8::External::Unwrap(cdataRef)); #else @@ -511,13 +511,13 @@ int SWIGV8_ConvertPacked(v8::Handle valRef, void *ptr, size_t sz, swi return SWIG_OK; } -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Persistent< v8::Value > object, void *parameter) { SwigV8PackedData *cdata = static_cast(parameter); -#elif (SWIG_V8_VERSION < 0x031900) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent object, void *parameter) { SwigV8PackedData *cdata = static_cast(parameter); -#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent *object, SwigV8PackedData *cdata) { #else SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackData &data) { @@ -527,15 +527,15 @@ SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackDataDispose(isolate); -#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) object->Dispose(); #else object.Clear(); @@ -552,35 +552,35 @@ v8::Handle SWIGV8_NewPackedObj(void *data, size_t size, swig_type_inf obj->SetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__"), SWIGV8_BOOLEAN_NEW(true)); -#if (SWIG_V8_VERSION < 0x031511) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511) obj->SetPointerInInternalField(0, cdata); #else obj->SetAlignedPointerInInternalField(0, cdata); #endif -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) cdata->handle = v8::Persistent::New(obj); -#elif (SWIG_V8_VERSION < 0x031900) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) cdata->handle = v8::Persistent::New(v8::Isolate::GetCurrent(), obj); #else cdata->handle.Reset(v8::Isolate::GetCurrent(), obj); #endif -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete); -#elif (SWIG_V8_VERSION < 0x031918) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031918) cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, _wrap_SwigV8PackedData_delete); -#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete); #else cdata->handle.SetWeak(cdata, _wrap_SwigV8PackedData_delete); // v8::V8::SetWeak(&cdata->handle, cdata, _wrap_SwigV8PackedData_delete); #endif -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) cdata->handle.MarkIndependent(); -#elif (SWIG_V8_VERSION < 0x032100) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100) cdata->handle.MarkIndependent(v8::Isolate::GetCurrent()); #else cdata->handle.MarkIndependent(); @@ -600,7 +600,7 @@ v8::Handle SWIGV8_NewPackedObj(void *data, size_t size, swig_type_inf SWIGRUNTIME -#if (SWIG_V8_VERSION < 0x031903) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) v8::Handle SWIGV8_AppendOutput(v8::Handle result, v8::Handle obj) { #else v8::Handle SWIGV8_AppendOutput(v8::Local result, v8::Handle obj) { @@ -610,11 +610,11 @@ v8::Handle SWIGV8_AppendOutput(v8::Local result, v8::Handl if (result->IsUndefined()) { result = SWIGV8_ARRAY_NEW(); } -#if (SWIG_V8_VERSION < 0x031903) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) v8::Handle arr = v8::Handle::Cast(result); #else v8::Local arr = v8::Local::Cast(result); -#endif +#endif arr->Set(arr->Length(), obj); SWIGV8_ESCAPE(arr); diff --git a/Lib/javascript/v8/javascriptruntime.swg b/Lib/javascript/v8/javascriptruntime.swg index ea11b0837..0e4059326 100644 --- a/Lib/javascript/v8/javascriptruntime.swg +++ b/Lib/javascript/v8/javascriptruntime.swg @@ -5,11 +5,22 @@ // V8 Version Macro // ---------------- -// v8 does not (until now) provide a version macro - which is still discussed and may come soon. -// Until then, we set a default version which can be overridden via command line using V8_VERSION: -// swig -javascript -v8 -DV8_VERSION=0x031110 +// +// v8 added version macros V8_MAJOR_VERSION, V8_MINOR_VERSION, V8_BUILD_NUMBER +// and V8_PATCH_LEVEL in version 4.3.0. SWIG generated code uses these if +// they are defined - to support earlier versions you can specify the V8 version +// in use via the command line when you run SWIG: +// +// swig -c++ -javascript -v8 -DV8_VERSION=0x032530 example.i +// // Or code in the interface file using SWIG_V8_VERSION: +// // %begin %{#define SWIG_V8_VERSION 0x031110%} +// +// This is specified as a hex constant, but the constant is read as pairs of +// decimal digits, so for V8 3.25.30 use constant 0x032530. This scheme can't +// represent components > 99, but this constant is only useful for V8 < 4.3.0, +// and no V8 versions from that era had a component > 99. %define %swig_v8_define_version(version) %insert("runtime") %{ diff --git a/Tools/javascript/v8_shell.cxx b/Tools/javascript/v8_shell.cxx index 7016e9c31..5001bc25a 100644 --- a/Tools/javascript/v8_shell.cxx +++ b/Tools/javascript/v8_shell.cxx @@ -13,7 +13,7 @@ typedef int (*V8ExtensionInitializer) (v8::Handle module); // Note: these typedefs and defines are used to deal with v8 API changes since version 3.19.00 -#if (SWIG_V8_VERSION < 0x031903) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) typedef v8::Handle SwigV8ReturnValue; typedef v8::Arguments SwigV8Arguments; typedef v8::AccessorInfo SwigV8PropertyCallbackInfo; @@ -28,11 +28,11 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #endif -#if (SWIG_V8_VERSION < 0x032117) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032117) #define SWIGV8_HANDLESCOPE() v8::HandleScope scope #define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope #define SWIGV8_ESCAPE(val) return scope.Close(val) -#elif (SWIG_V8_VERSION < 0x032318) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318) #define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent()); #define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope(v8::Isolate::GetCurrent()); #define SWIGV8_ESCAPE(val) return scope.Close(val) @@ -42,7 +42,7 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_ESCAPE(val) return scope.Escape(val) #endif -#if (SWIG_V8_VERSION < 0x032318) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318) #define SWIGV8_CURRENT_CONTEXT() v8::Context::GetCurrent() #define SWIGV8_STRING_NEW(str) v8::String::New(str) #define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(func) @@ -59,7 +59,7 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #endif -#if (SWIG_V8_VERSION < 0x031900) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) typedef v8::Persistent SwigV8Context; #else typedef v8::Local SwigV8Context; @@ -149,9 +149,9 @@ bool V8Shell::RunScript(const std::string &scriptPath) { context->Exit(); -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) context.Dispose(); -#elif (SWIG_V8_VERSION < 0x031900) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) context.Dispose(v8::Isolate::GetCurrent()); #else // context.Dispose(); @@ -193,9 +193,9 @@ bool V8Shell::RunShell() { context->Exit(); -#if (SWIG_V8_VERSION < 0x031710) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) context.Dispose(); -#elif (SWIG_V8_VERSION < 0x031900) +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) context.Dispose(v8::Isolate::GetCurrent()); #else // context.Dispose(); @@ -249,7 +249,7 @@ SwigV8Context V8Shell::CreateShellContext() { global->Set(SWIGV8_STRING_NEW("require"), SWIGV8_FUNCTEMPLATE_NEW(V8Shell::Require)); global->Set(SWIGV8_STRING_NEW("version"), SWIGV8_FUNCTEMPLATE_NEW(V8Shell::Version)); -#if (SWIG_V8_VERSION < 0x031900) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900) SwigV8Context context = v8::Context::New(NULL, global); return context; #else From 22b72d5da34e95ef7d423c902936c01156a23171 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 12 Jan 2016 09:33:39 +1300 Subject: [PATCH 241/732] [Javascript] Look for "nodejs" as well as "node", as it's packaged as the former on Debian. --- CHANGES.current | 4 ++++ configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index d925e5ffc..e114acd09 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.9 (in progress) =========================== +2016-01-12: olly + [Javascript] Look for "nodejs" as well as "node", as it's packaged + as the former on Debian. + 2016-01-12: olly [Javascript] For v8 >= 4.3.0, use V8_MAJOR_VERSION. Fixes https://github.com/swig/swig/issues/561. diff --git a/configure.ac b/configure.ac index 9dfdcbd9b..8b537461c 100644 --- a/configure.ac +++ b/configure.ac @@ -1422,7 +1422,7 @@ else # Look for Node.js which is the default Javascript engine #---------------------------------------------------------------- - AC_CHECK_PROGS(NODEJS, node) + AC_CHECK_PROGS(NODEJS, [nodejs node]) if test -n "$NODEJS"; then # node-gyp is needed to run the test-suite/examples From 2daf3fa237373d1e3b309a448f316d8904f4926d Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Tue, 12 Jan 2016 01:05:10 +0100 Subject: [PATCH 242/732] Ruby module docstring avoid memory leak --- Source/Modules/ruby.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 05852c232..9743771c5 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1150,8 +1150,10 @@ public: Printf(f_header, "#define SWIG_init Init_%s\n", feature); Printf(f_header, "#define SWIG_name \"%s\"\n\n", module); - if (mod_docstring && Len(mod_docstring)) { - Printf(f_header, "/*\n Document-module: %s\n\n%s\n*/\n", module, mod_docstring); + if (mod_docstring) { + if (Len(mod_docstring)) { + Printf(f_header, "/*\n Document-module: %s\n\n%s\n*/\n", module, mod_docstring); + } Delete(mod_docstring); mod_docstring = NULL; } From f910607e26392a97ddf67d85085492587b39e78e Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 12 Jan 2016 13:37:39 +1300 Subject: [PATCH 243/732] Fix typo: "neccessary" -> "necessary" --- CHANGES | 4 ++-- Doc/Manual/Java.html | 2 +- Source/Modules/python.cxx | 6 +++--- Source/Modules/ruby.cxx | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 9d110cad2..198230775 100644 --- a/CHANGES +++ b/CHANGES @@ -7853,7 +7853,7 @@ Version 1.3.28 (February 12, 2006) 12/10/2005: mmatus [UTF] - - Fix unneccessary calls to SWIG_TypeQuery for 'char *' + - Fix unnecessary calls to SWIG_TypeQuery for 'char *' and 'wchar_t *', problem found by Clay Culver while profiling the PyOgre project. @@ -23576,7 +23576,7 @@ Version 1.1b5 (March 12, 1997) 2/23/97 : Modified Python module to be better behaved under Windows - Module initialization function is now properly exported. - It should not be neccessary to explicitly export this function + It should not be necessary to explicitly export this function yourself. - Bizarre compilation problems when compiling the SWIG wrapper diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 83d14ed64..dae6edc01 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -3769,7 +3769,7 @@ may need to be attached to specific methods. of the "directorthrows" typemaps. In this example, a generic "directorthrows" typemap is appropriate for all three exceptions - all take single string constructors. If the exceptions had different constructors, -it would be neccessary to have separate typemaps for each exception type. +it would be necessary to have separate typemaps for each exception type.