Merge branch 'master' of https://github.com/swig/swig into Cmerge

This commit is contained in:
Joey Yakimowich-Payne 2023-02-18 00:05:36 -07:00
commit 5a06ca1ed7
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
33 changed files with 10904 additions and 7309 deletions

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* allocate.cxx
*

View file

@ -212,7 +212,7 @@ String* get_c_proxy_name(Node* n) {
String *nspace = Getattr(n, "sym:nspace");
if (nspace) {
scoped_dohptr nspace_mangled(Swig_string_mangle(nspace));
scoped_dohptr nspace_mangled(Swig_name_mangle_string(nspace));
proxyname = NewStringf("%s_%s", (DOH*)nspace_mangled, symname);
} else {
proxyname = Swig_name_type(symname);
@ -1559,7 +1559,7 @@ public:
if (GetFlag(parentNode(n), "feature:nspace")) {
scopename_prefix = Swig_scopename_prefix(Getattr(n, "name"));
if (scopename_prefix) {
scoped_dohptr mangled_prefix(Swig_string_mangle(scopename_prefix));
scoped_dohptr mangled_prefix(Swig_name_mangle_string(scopename_prefix));
scopename_prefix = mangled_prefix;
}
}
@ -1766,7 +1766,7 @@ public:
} else if (strcmp(argv[i], "-namespace") == 0) {
if (argv[i + 1]) {
ns_cxx = NewString(argv[i + 1]);
ns_prefix = Swig_string_mangle(ns_cxx);
ns_prefix = Swig_name_mangle_string(ns_cxx);
Swig_mark_arg(i);
Swig_mark_arg(i + 1);
i++;
@ -2136,7 +2136,7 @@ public:
s += len_enum_prefix;
Printf(result, "e%s", s);
} else {
Printf(result, "%s", Char(Swig_name_mangle(SwigType_base(type))));
Printf(result, "%s", Char(Swig_name_mangle_string(SwigType_base(type))));
}
Delete(prefix);

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* contract.cxx
*

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* csharp.cxx
*
@ -399,7 +399,7 @@ public:
Swig_banner(f_begin);
Printf(f_runtime, "\n\n#ifndef SWIGCSHARP\n#define SWIGCSHARP\n#endif\n\n");
Swig_obligatory_macros(f_runtime, "CSHARP");
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
@ -1744,35 +1744,32 @@ public:
Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name);
String *classname = SwigType_namestr(c_classname);
String *baseclassname = SwigType_namestr(c_baseclassname);
if (smart) {
SwigType *bsmart = Swig_smartptr_upcast(smart, c_classname, c_baseclassname);
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(smart);
// TODO: SwigType_typedef_resolve_all on a String instead of SwigType is incorrect for templates
SwigType *rclassname = SwigType_typedef_resolve_all(classname);
SwigType *rbaseclassname = SwigType_typedef_resolve_all(baseclassname);
Replaceall(bsmartnamestr, rclassname, rbaseclassname);
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(rbaseclassname);
Delete(rclassname);
Delete(bsmartnamestr);
Delete(smartnamestr);
Delete(bsmart);
} else {
String *classname = SwigType_namestr(c_classname);
String *baseclassname = SwigType_namestr(c_baseclassname);
Printv(upcasts_code,
"SWIGEXPORT ", baseclassname, " * SWIGSTDCALL ", wname, "(", classname, " *jarg1) {\n",
" return (", baseclassname, " *)jarg1;\n"
"}\n", "\n", NIL);
Delete(baseclassname);
Delete(classname);
}
Delete(baseclassname);
Delete(classname);
Delete(wname);
}
@ -2976,7 +2973,7 @@ public:
/* A C# HandleRef is used for all classes in the SWIG intermediary class.
* The intermediary class methods are thus mangled when overloaded to give
* a unique name. */
String *overloaded_name = NewStringf("%s", Getattr(n, "sym:name"));
String *overloaded_name = Copy(Getattr(n, "sym:name"));
if (Getattr(n, "sym:overloaded")) {
Printv(overloaded_name, Getattr(n, "sym:overname"), NIL);
@ -3820,7 +3817,7 @@ public:
String *name = Getattr(n, "name");
String *symname = Getattr(n, "sym:name");
SwigType *returntype = Getattr(n, "type");
String *overloaded_name = getOverloadedName(n);
String *overloaded_name = 0;
String *storage = Getattr(n, "storage");
String *value = Getattr(n, "value");
String *decl = Getattr(n, "decl");
@ -3842,7 +3839,6 @@ public:
String *qualified_name = NewStringf("%s::%s", dirclassname, name);
SwigType *c_ret_type = NULL;
String *jupcall_args = NewString("");
String *imclass_dmethod;
String *callback_typedef_parms = NewString("");
String *delegate_parms = NewString("");
String *proxy_method_types = NewString("");
@ -3856,7 +3852,8 @@ public:
// we're consistent with the sym:overload name in functionWrapper. (?? when
// does the overloaded method name get set?)
imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(getNSpace(), getClassPrefix(), overloaded_name));
if (!ignored_method)
overloaded_name = getOverloadedName(n);
qualified_return = SwigType_rcaststr(returntype, "c_result");
@ -3909,28 +3906,28 @@ public:
}
}
/* Create the intermediate class wrapper */
tm = Swig_typemap_lookup("imtype", n, "", 0);
if (tm) {
String *imtypeout = Getattr(n, "tmap:imtype:out"); // the type in the imtype typemap's out attribute overrides the type in the typemap
if (imtypeout)
tm = imtypeout;
const String *im_directoroutattributes = Getattr(n, "tmap:imtype:directoroutattributes");
if (im_directoroutattributes) {
Printf(callback_def, " %s\n", im_directoroutattributes);
if (!ignored_method)
Printf(director_delegate_definitions, " %s\n", im_directoroutattributes);
}
if (!ignored_method) {
/* Create the intermediate class wrapper */
tm = Swig_typemap_lookup("imtype", n, "", 0);
if (tm) {
String *imtypeout = Getattr(n, "tmap:imtype:out"); // the type in the imtype typemap's out attribute overrides the type in the typemap
if (imtypeout)
tm = imtypeout;
const String *im_directoroutattributes = Getattr(n, "tmap:imtype:directoroutattributes");
if (im_directoroutattributes) {
Printf(callback_def, " %s\n", im_directoroutattributes);
if (!ignored_method)
Printf(director_delegate_definitions, " %s\n", im_directoroutattributes);
}
Printf(callback_def, " private %s SwigDirectorMethod%s(", tm, overloaded_name);
if (!ignored_method) {
Printf(callback_def, " private %s SwigDirectorMethod%s(", tm, overloaded_name);
const String *csdirectordelegatemodifiers = Getattr(n, "feature:csdirectordelegatemodifiers");
String *modifiers = (csdirectordelegatemodifiers ? NewStringf("%s%s", csdirectordelegatemodifiers, Len(csdirectordelegatemodifiers) > 0 ? " " : "") : NewStringf("public "));
Printf(director_delegate_definitions, " %sdelegate %s", modifiers, tm);
Delete(modifiers);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(returntype, 0));
}
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(returntype, 0));
}
if ((c_ret_type = Swig_typemap_lookup("ctype", n, "", 0))) {
@ -4288,6 +4285,8 @@ public:
if (!ignored_method) {
/* Emit the actual upcall through */
String *member_name = Swig_name_member(getNSpace(), getClassPrefix(), overloaded_name);
String *imclass_dmethod = NewStringf("SwigDirector_%s", member_name);
UpcallData *udata = addUpcallMethod(imclass_dmethod, symname, decl, overloaded_name);
String *methid = Getattr(udata, "class_methodidx");
Setattr(n, "upcalldata", udata);
@ -4303,6 +4302,9 @@ public:
Printf(director_delegate_instances, " private SwigDelegate%s_%s swigDelegate%s;\n", classname, methid, methid);
Printf(director_method_types, " private static global::System.Type[] swigMethodTypes%s = new global::System.Type[] { %s };\n", methid, proxy_method_types);
Printf(director_connect_parms, "SwigDirector%s%s delegate%s", classname, methid, methid);
Delete(imclass_dmethod);
Delete(member_name);
}
Delete(pre_code);

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* d.cxx
*
@ -472,7 +472,7 @@ public:
Swig_banner(f_begin);
Printf(f_runtime, "\n\n#ifndef SWIGD\n#define SWIGD\n#endif\n\n");
Swig_obligatory_macros(f_runtime, "D");
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
@ -1943,7 +1943,7 @@ public:
String *name = Getattr(n, "name");
String *symname = Getattr(n, "sym:name");
SwigType *returntype = Getattr(n, "type");
String *overloaded_name = getOverloadedName(n);
String *overloaded_name = 0;
String *storage = Getattr(n, "storage");
String *value = Getattr(n, "value");
String *decl = Getattr(n, "decl");
@ -1962,7 +1962,6 @@ public:
String *qualified_name = NewStringf("%s::%s", dirclassname, name);
SwigType *c_ret_type = NULL;
String *dcallback_call_args = NewString("");
String *imclass_dmethod;
String *callback_typedef_parms = NewString("");
String *delegate_parms = NewString("");
String *proxy_method_param_list = NewString("");
@ -1977,7 +1976,8 @@ public:
// we're consistent with the sym:overload name in functionWrapper. (?? when
// does the overloaded method name get set?)
imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(getNSpace(), classname, overloaded_name));
if (!ignored_method)
overloaded_name = getOverloadedName(n);
qualified_return = SwigType_rcaststr(returntype, "c_result");
@ -2381,8 +2381,9 @@ public:
dp_return_type = NewString("");
}
String *member_name = Swig_name_member(getNSpace(), classname, overloaded_name);
String *imclass_dmethod = NewStringf("SwigDirector_%s", member_name);
UpcallData *udata = addUpcallMethod(imclass_dmethod, symname, decl, overloaded_name, dp_return_type, proxy_method_param_list);
Delete(dp_return_type);
// Write the global callback function pointer on the C code.
String *methid = Getattr(udata, "class_methodidx");
@ -2396,6 +2397,10 @@ public:
String *dirClassName = directorClassName(parent);
Printf(proxy_callback_type, "%s_Callback%s", dirClassName, methid);
Printf(im_dmodule_code, "alias extern(C) %s function(void*%s) %s;\n", proxy_callback_return_type, delegate_parms, proxy_callback_type);
Delete(imclass_dmethod);
Delete(member_name);
Delete(dp_return_type);
Delete(proxy_callback_type);
Delete(dirClassName);
}
@ -3374,19 +3379,15 @@ private:
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);
writeImDModuleFunction(upcast_name, "void*", "(void* objectRef)", upcast_wrapper_name);
String *classname = SwigType_namestr(c_classname);
String *baseclassname = SwigType_namestr(c_baseclassname);
if (smart) {
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(smart);
// TODO: SwigType_typedef_resolve_all on a String instead of SwigType is incorrect for templates
SwigType *rclassname = SwigType_typedef_resolve_all(classname);
SwigType *rbaseclassname = SwigType_typedef_resolve_all(baseclassname);
Replaceall(bsmartnamestr, rclassname, rbaseclassname);
if (smart) {
SwigType *bsmart = Swig_smartptr_upcast(smart, c_classname, c_baseclassname);
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(bsmart);
Printv(upcasts_code,
"SWIGEXPORT ", bsmartnamestr, " * ", upcast_wrapper_name,
@ -3395,10 +3396,9 @@ private:
"}\n",
"\n", NIL);
Delete(rbaseclassname);
Delete(rclassname);
Delete(bsmartnamestr);
Delete(smartnamestr);
Delete(bsmart);
} else {
Printv(upcasts_code,
"SWIGEXPORT ", baseclassname, " * ", upcast_wrapper_name,
@ -3413,8 +3413,8 @@ private:
Delete(baseclassname);
Delete(classname);
Delete(upcast_name);
Delete(upcast_wrapper_name);
Delete(upcast_name);
Delete(smart);
}
@ -4286,6 +4286,7 @@ private:
* D::getOverloadedName()
* --------------------------------------------------------------------------- */
String *getOverloadedName(Node *n) const {
// A void* parameter is used for all wrapped classes in the wrapper code.
// Thus, the wrapper function names for overloaded functions are postfixed
// with a counter string to make them unique.

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* directors.cxx
*
@ -233,3 +233,38 @@ void Swig_director_parms_fixup(ParmList *parms) {
}
}
/* -----------------------------------------------------------------------------
* Swig_director_can_unwrap()
*
* Determine whether a function's return type can be returned as an existing
* target language object instead of creating a new target language object.
* Must be a director class and only for return by pointer or reference only
* (not by value or by pointer to pointer etc).
* ----------------------------------------------------------------------------- */
bool Swig_director_can_unwrap(Node *n) {
// FIXME: this will not try to unwrap directors returned as non-director
// base class pointers!
bool unwrap = false;
String *type = Getattr(n, "type");
SwigType *t = SwigType_typedef_resolve_all(type);
SwigType *t1 = SwigType_strip_qualifiers(t);
SwigType *prefix = SwigType_prefix(t1);
if (Strcmp(prefix, "p.") == 0 || Strcmp(prefix, "r.") == 0) {
Node *parent = Swig_methodclass(n);
Node *module = Getattr(parent, "module");
Node *target = Swig_directormap(module, t1);
if (target)
unwrap = true;
}
Delete(prefix);
Delete(t1);
Delete(t);
return unwrap;
}

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* emit.cxx
*

View file

@ -1,6 +1,10 @@
/* -----------------------------------------------------------------------------
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at https://www.swig.org/legal.html.
*
* go.cxx
*
@ -508,6 +512,9 @@ private:
Swig_register_filebyname("cgo_comment_typedefs", f_cgo_comment_typedefs);
Swig_banner(f_c_begin);
Swig_obligatory_macros(f_c_runtime, "GO");
if (CPlusPlus) {
Printf(f_c_begin, "\n// source: %s\n\n", swig_filename);
} else {
@ -515,6 +522,7 @@ private:
}
Printf(f_c_runtime, "#define SWIGMODULE %s\n", module);
if (gccgo_flag) {
Printf(f_c_runtime, "#define SWIGGO_PREFIX %s\n", go_prefix);
}
@ -4648,8 +4656,8 @@ private:
* 'X'.
* ---------------------------------------------------------------------- */
String *exportedName(String *name) {
String *copy = Copy(name);
String *exportedName(SwigType *name) {
SwigType *copy = Copy(name);
char c = *Char(copy);
if (islower(c)) {
char l[2];
@ -4669,7 +4677,7 @@ private:
u[2] = '\0';
Replace(copy, l, u, DOH_REPLACE_FIRST);
}
String *ret = Swig_name_mangle(copy);
String *ret = Swig_name_mangle_type(copy);
Delete(copy);
return ret;
}
@ -4717,7 +4725,7 @@ private:
Append(nw, c3);
Delete(c2);
Delete(c3);
String *ret = Swig_name_mangle(nw);
String *ret = Swig_name_mangle_string(nw);
Delete(nw);
return ret;
}
@ -4734,7 +4742,7 @@ private:
String *buildGoWrapperName(String *name, String *overname) {
String *s1 = NewString("_swig_wrap_");
Append(s1, name);
String *s2 = Swig_name_mangle(s1);
String *s2 = Swig_name_mangle_string(s1);
Delete(s1);
if (overname) {
Append(s2, overname);
@ -5548,11 +5556,11 @@ private:
return NewString("int");
}
String *type = Getattr(n, "enumtype");
SwigType *type = Getattr(n, "enumtype");
assert(type);
char *p = Char(type);
int len = Len(type);
String *s = NewString("");
SwigType *s = NewString("");
bool capitalize = true;
for (int i = 0; i < len; ++i, ++p) {
if (*p == ':') {
@ -5568,7 +5576,7 @@ private:
}
}
ret = Swig_name_mangle(s);
ret = Swig_name_mangle_type(s);
Delete(s);
return ret;
}

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* guile.cxx
*
@ -321,7 +321,7 @@ public:
Swig_banner(f_begin);
Printf(f_runtime, "\n\n#ifndef SWIGGUILE\n#define SWIGGUILE\n#endif\n\n");
Swig_obligatory_macros(f_runtime, "GUILE");
/* Write out directives and declarations */
@ -1396,7 +1396,7 @@ public:
SwigType *ct = NewStringf("p.%s", Getattr(n, "name"));
swigtype_ptr = SwigType_manglestr(ct);
String *mangled_classname = Swig_name_mangle(Getattr(n, "sym:name"));
String *mangled_classname = Swig_name_mangle_string(Getattr(n, "sym:name"));
/* Export clientdata structure */
Printf(f_runtime, "static swig_guile_clientdata _swig_guile_clientdata%s = { NULL, SCM_EOL };\n", mangled_classname);

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* interface.cxx
*
@ -183,6 +183,7 @@ void Swig_interface_propagate_methods(Node *n) {
if (Strcmp(symname, "$ignore") != 0) {
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
Node *on = Swig_symbol_add(symname, cn);
(void)on;
assert(on == cn);
// Features from the copied base class method are already present, now add in features specific to the added method in the derived class

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* java.cxx
*
@ -456,7 +456,7 @@ public:
Swig_banner(f_begin);
Printf(f_runtime, "\n\n#ifndef SWIGJAVA\n#define SWIGJAVA\n#endif\n\n");
Swig_obligatory_macros(f_runtime, "JAVA");
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
@ -1883,16 +1883,10 @@ public:
Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method_name);
String *classname = SwigType_namestr(c_classname);
String *baseclassname = SwigType_namestr(c_baseclassname);
if (smart) {
SwigType *bsmart = Swig_smartptr_upcast(smart, c_classname, c_baseclassname);
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(smart);
// TODO: SwigType_typedef_resolve_all on a String instead of SwigType is incorrect for templates
SwigType *rclassname = SwigType_typedef_resolve_all(classname);
SwigType *rbaseclassname = SwigType_typedef_resolve_all(baseclassname);
Replaceall(bsmartnamestr, rclassname, rbaseclassname);
String *bsmartnamestr = SwigType_namestr(bsmart);
Printv(upcasts_code,
"SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
@ -1905,11 +1899,13 @@ public:
" return baseptr;\n"
"}\n", "\n", NIL);
Delete(rbaseclassname);
Delete(rclassname);
Delete(bsmartnamestr);
Delete(smartnamestr);
Delete(bsmart);
} else {
String *classname = SwigType_namestr(c_classname);
String *baseclassname = SwigType_namestr(c_baseclassname);
Printv(upcasts_code,
"SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
" jlong baseptr = 0;\n"
@ -1918,10 +1914,11 @@ public:
" *(", baseclassname, " **)&baseptr = *(", classname, " **)&jarg1;\n"
" return baseptr;\n"
"}\n", "\n", NIL);
Delete(baseclassname);
Delete(classname);
}
Delete(baseclassname);
Delete(classname);
Delete(wname);
Delete(jniname);
}
@ -2991,7 +2988,7 @@ public:
* a Java long is used for all classes in the SWIG intermediary class.
* The intermediary class methods are thus mangled when overloaded to give
* a unique name. */
String *overloaded_name = NewStringf("%s", Getattr(n, "sym:name"));
String *overloaded_name = Copy(Getattr(n, "sym:name"));
if (Getattr(n, "sym:overloaded")) {
Printv(overloaded_name, Getattr(n, "sym:overname"), NIL);
@ -4006,7 +4003,7 @@ public:
String *name = Getattr(n, "name");
String *symname = Getattr(n, "sym:name");
SwigType *returntype = Getattr(n, "type");
String *overloaded_name = getOverloadedName(n);
String *overloaded_name = 0;
String *storage = Getattr(n, "storage");
String *value = Getattr(n, "value");
String *decl = Getattr(n, "decl");
@ -4029,7 +4026,7 @@ public:
String *classret_desc = NewString("");
SwigType *c_ret_type = NULL;
String *jupcall_args = NewString("swigjobj");
String *imclass_dmethod;
String *imclass_dmethod = 0;
String *callback_def = NewString("");
String *callback_code = NewString("");
String *imcall_args = NewString("");
@ -4042,7 +4039,11 @@ public:
// we're consistent with the sym:overload name in functionWrapper. (?? when
// does the overloaded method name get set?)
imclass_dmethod = NewStringf("%s", Swig_name_member(getNSpace(), dirclassname, overloaded_name));
if (!ignored_method) {
overloaded_name = getOverloadedName(n);
imclass_dmethod = Swig_name_member(getNSpace(), dirclassname, overloaded_name);
}
qualified_return = SwigType_rcaststr(returntype, "c_result");
@ -4095,12 +4096,14 @@ public:
}
}
/* Create the intermediate class wrapper */
tm = Swig_typemap_lookup("jtype", n, "", 0);
if (tm) {
Printf(callback_def, " public static %s %s(%s jself", tm, imclass_dmethod, qualified_classname);
} else {
Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s\n", SwigType_str(returntype, 0));
if (!ignored_method) {
/* Create the intermediate class wrapper */
tm = Swig_typemap_lookup("jtype", n, "", 0);
if (tm) {
Printf(callback_def, " public static %s %s(%s jself", tm, imclass_dmethod, qualified_classname);
} else {
Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s\n", SwigType_str(returntype, 0));
}
}
String *cdesc = NULL;

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* javascript.cxx
*
@ -1461,7 +1461,7 @@ Hash *JSEmitter::createNamespaceEntry(const char *_name, const char *parent, con
Hash *entry = NewHash();
String *name = NewString(_name);
Setattr(entry, NAME, Swig_scopename_last(name));
Setattr(entry, NAME_MANGLED, Swig_name_mangle(name));
Setattr(entry, NAME_MANGLED, Swig_name_mangle_string(name));
Setattr(entry, PARENT, NewString(parent));
Setattr(entry, PARENT_MANGLED, NewString(parent_mangled));
@ -1615,6 +1615,8 @@ int JSCEmitter::initialize(Node *n) {
Swig_banner(f_wrap_cpp);
Swig_obligatory_macros(f_runtime, "JAVASCRIPT");
return SWIG_OK;
}
@ -1945,6 +1947,8 @@ int V8Emitter::initialize(Node *n) {
Swig_banner(f_wrap_cpp);
Swig_obligatory_macros(f_runtime, "JAVASCRIPT");
return SWIG_OK;
}

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* lang.cxx
*
@ -77,7 +77,9 @@ static Hash *classhash;
extern int GenerateDefault;
extern int ForceExtern;
extern int AddExtern;
extern int UseWrapperSuffix;
extern "C" {
extern int UseWrapperSuffix;
}
/* import modes */
@ -1308,16 +1310,18 @@ int Language::staticmemberfunctionHandler(Node *n) {
else
cname = NewStringf("%s::%s", sname, name);
} else {
String *mname = Swig_name_mangle(ClassName);
String *classname_str = SwigType_namestr(ClassName);
String *mname = Swig_name_mangle_string(classname_str);
cname = Swig_name_member(NSpace, mname, name);
Delete(mname);
Delete(classname_str);
}
mrename = Swig_name_member(NSpace, ClassPrefix, symname);
if (Extend) {
String *code = Getattr(n, "code");
String *defaultargs = Getattr(n, "defaultargs");
String *mangled = Swig_name_mangle(mrename);
String *mangled = Swig_name_mangle_string(mrename);
Delete(mrename);
mrename = mangled;
@ -1331,7 +1335,7 @@ int Language::staticmemberfunctionHandler(Node *n) {
if (!defaultargs) {
/* Hmmm. An added static member. We have to create a little wrapper for this */
String *mangled_cname = Swig_name_mangle(cname);
String *mangled_cname = Swig_name_mangle_string(cname);
Swig_add_extension_code(n, mangled_cname, parms, type, code, CPlusPlus, 0);
Setattr(n, "extendname", mangled_cname);
Delete(mangled_cname);

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* lua.cxx
*
@ -329,7 +329,7 @@ public:
/* Standard stuff for the SWIG runtime section */
Swig_banner(f_begin);
Printf(f_runtime, "\n\n#ifndef SWIGLUA\n#define SWIGLUA\n#endif\n\n");
Swig_obligatory_macros(f_runtime, "LUA");
emitLuaFlavor(f_runtime);
@ -556,6 +556,12 @@ public:
this line adds this into the wrapper code
NEW LANGUAGE NOTE:END *********************************************** */
Printv(f->def, "static int ", wname, "(lua_State* L) {", NIL);
// SWIG_fail in lua leads to a call to lua_error() which calls longjmp()
// which means the destructors of any live function-local C++ objects won't
// get run. To avoid this happening, we wrap almost everything in the
// function in a block, and end that right before lua_error() at which
// point those destructors will get called.
if (CPlusPlus) Append(f->def, "\n{");
/* NEW LANGUAGE NOTE:***********************************************
this prints the list of args, eg for a C fn
@ -766,10 +772,12 @@ public:
/* Close the function */
Printv(f->code, "return SWIG_arg;\n", NIL);
// add the failure cleanup code:
Printv(f->code, "\nif(0) SWIG_fail;\n", NIL);
Printv(f->code, "\nfail:\n", NIL);
Printv(f->code, "$cleanup", "lua_error(L);\n", NIL);
Printv(f->code, "return SWIG_arg;\n", NIL);
Printv(f->code, "\nfail: SWIGUNUSED;\n", "$cleanup", NIL);
if (CPlusPlus) Append(f->code, "}\n");
Printv(f->code, "lua_error(L);\n", NIL);
// lua_error() calls longjmp() but we need a dummy return to avoid compiler
// warnings.
Printv(f->code, "return 0;\n", NIL);
Printf(f->code, "}\n");
/* Substitute the cleanup code */
@ -1261,7 +1269,7 @@ public:
full_proxy_class_name = NewStringf("%s.%s", nspace, proxy_class_name);
assert(full_proxy_class_name);
mangled_full_proxy_class_name = Swig_name_mangle(full_proxy_class_name);
mangled_full_proxy_class_name = Swig_name_mangle_string(full_proxy_class_name);
SwigType *t = Copy(Getattr(n, "name"));
SwigType *fr_t = SwigType_typedef_resolve_all(t); /* Create fully resolved type */
@ -1795,7 +1803,7 @@ public:
if (nspace == 0 || Len(nspace) == 0)
mangled_name = NewString("SwigModule");
else
mangled_name = Swig_name_mangle(nspace);
mangled_name = Swig_name_mangle_string(nspace);
String *cname = NewStringf("swig_%s", mangled_name);
Setattr(carrays_hash, "cname", cname);

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* main.cxx
*
@ -37,10 +37,13 @@ int Verbose = 0;
int AddExtern = 0;
int NoExcept = 0;
int SwigRuntime = 0; // 0 = no option, 1 = -runtime, 2 = -noruntime
int UseWrapperSuffix = 0; // If 1, append suffix to non-overloaded functions too.
extern "C" {
int UseWrapperSuffix = 0; // If 1, append suffix to non-overloaded functions too.
}
/* Suppress warning messages for private inheritance, etc by default.
These are enabled by command line option -Wextra.
/* Suppress warning messages for private inheritance, preprocessor evaluation etc...
WARN_PP_EVALUATION 202
WARN_PARSE_PRIVATE_INHERIT 309
WARN_PARSE_BUILTIN_NAME 321
WARN_PARSE_REDUNDANT 322
@ -48,7 +51,7 @@ int UseWrapperSuffix = 0; // If 1, append suffix to non-overloaded functions too
WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED 405
WARN_LANG_OVERLOAD_CONST 512
*/
#define EXTRA_WARNINGS "202,309,403,405,512,321,322"
#define EXTRA_WARNINGS "309,403,405,512,321,322"
extern "C" {
extern String *ModuleName;
@ -908,25 +911,11 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
Preprocessor_define((DOH *) "SWIG 1", 0);
Preprocessor_define((DOH *) "__STDC__", 0);
// Set the SWIG version value in format 0xAABBCC from package version expected to be in format A.B.C
String *package_version = NewString(PACKAGE_VERSION); /* Note that the fakeversion has not been set at this point */
char *token = strtok(Char(package_version), ".");
String *vers = NewString("SWIG_VERSION 0x");
int count = 0;
while (token) {
int len = (int)strlen(token);
assert(len == 1 || len == 2);
Printf(vers, "%s%s", (len == 1) ? "0" : "", token);
token = strtok(NULL, ".");
count++;
}
Delete(package_version);
assert(count == 3); // Check version format is correct
/* Turn on contracts */
String *vers = Swig_package_version_hex();
Preprocessor_define(vers, 0);
Delete(vers);
Swig_contract_mode_set(1);
Preprocessor_define(vers, 0);
/* Turn off directors mode */
Wrapper_director_mode_set(0);
@ -1326,7 +1315,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
if (tlm->status == Experimental) {
Swig_warning(WARN_LANG_EXPERIMENTAL, "SWIG", 1, "Experimental target language. "
"Target language %s specified by %s is an experimental language. "
"Please read about SWIG experimental languages, http://swig.org/Doc4.0/Introduction.html#Introduction_experimental_status.\n",
"Please read about SWIG experimental languages, https://swig.org/Doc4.0/Introduction.html#Introduction_experimental_status.\n",
tlm->help ? tlm->help : "", tlm->name);
}

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* mzscheme.cxx
*
@ -147,7 +147,7 @@ public:
Swig_banner(f_begin);
Printf(f_runtime, "\n\n#ifndef SWIGMZSCHEME\n#define SWIGMZSCHEME\n#endif\n\n");
Swig_obligatory_macros(f_runtime, "MZSCHEME");
module = Getattr(n, "name");
@ -569,7 +569,7 @@ public:
// Make a static variable;
Printf(var_name, "_wrap_const_%s", Swig_name_mangle(Getattr(n, "sym:name")));
Printf(var_name, "_wrap_const_%s", Swig_name_mangle_string(Getattr(n, "sym:name")));
// Build the name for scheme.
Printv(proc_name, iname, NIL);
@ -641,8 +641,6 @@ public:
* classHandler()
* ------------------------------------------------------------ */
virtual int classHandler(Node *n) {
String *mangled_classname = 0;
String *real_classname = 0;
String *scm_structname = NewString("");
SwigType *ctype_ptr = NewStringf("p.%s", getClassType());
@ -658,14 +656,11 @@ public:
convert_proto_tab = NewString("");
struct_name = Getattr(n, "sym:name");
mangled_struct_name = Swig_name_mangle(Getattr(n, "sym:name"));
mangled_struct_name = Swig_name_mangle_string(Getattr(n, "sym:name"));
Printv(scm_structname, struct_name, NIL);
Replaceall(scm_structname, "_", "-");
real_classname = Getattr(n, "name");
mangled_classname = Swig_name_mangle(real_classname);
Printv(fieldnames_tab, "static const char *_swig_struct_", cls_swigtype, "_field_names[] = { \n", NIL);
Printv(convert_proto_tab, "static Scheme_Object *_swig_convert_struct_", cls_swigtype, "(", SwigType_str(ctype_ptr, "ptr"), ");\n", NIL);
@ -695,7 +690,6 @@ public:
" = SWIG_MzScheme_new_scheme_struct(menv, \"", scm_structname, "\", ",
"_swig_struct_", cls_swigtype, "_field_names_cnt,", "(char**) _swig_struct_", cls_swigtype, "_field_names);\n", NIL);
Delete(mangled_classname);
Delete(swigtype_ptr);
swigtype_ptr = 0;
Delete(fieldnames_tab);

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* nested.cxx
*

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* ocaml.cxx
*
@ -276,7 +276,7 @@ public:
Swig_banner(f_begin);
Printf(f_runtime, "\n\n#ifndef SWIGOCAML\n#define SWIGOCAML\n#endif\n\n");
Swig_obligatory_macros(f_runtime, "OCAML");
Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module);
/* Module name */
@ -1181,6 +1181,7 @@ public:
/*
* Produce the symbol name that ocaml will use when referring to the
* target item. I wonder if there's a better way to do this:
* (WF - use Swig_name_mangle_string/Swig_name_mangle_type)
*
* I shudder to think about doing it with a hash lookup, but that would
* make a couple of things easier:
@ -1209,6 +1210,8 @@ public:
Replaceall(out, "=", "_xx_equals");
Replaceall(out, "/", "_xx_slash");
Replaceall(out, ".", "_xx_dot");
Replaceall(out, "?", "_xx_question");
Replaceall(out, ":", "_xx_colon");
return out;
}
@ -1238,6 +1241,7 @@ public:
int enumvalueDeclaration(Node *n) {
String *name = Getattr(n, "name");
String *symname = Getattr(n, "sym:name");
SwigType *qtype = 0;
if (name_qualifier_type) {
@ -1245,8 +1249,8 @@ public:
Printv(qtype, name, NIL);
}
if (const_enum && qtype && name && !Getattr(seen_enumvalues, name)) {
Setattr(seen_enumvalues, name, "true");
if (const_enum && qtype && symname && !Getattr(seen_enumvalues, symname)) {
Setattr(seen_enumvalues, symname, "true");
SetFlag(n, "feature:immutable");
Setattr(n, "feature:enumvalue", "1"); // this does not appear to be used
@ -1255,10 +1259,10 @@ public:
String *evname = SwigType_manglestr(qtype);
Insert(evname, 0, "SWIG_ENUM_");
Setattr(n, "feature:enumvname", name);
Setattr(n, "feature:enumvname", symname);
Setattr(n, "feature:symname", evname);
Delete(evname);
Printf(f_enumtypes_value, "| `%s\n", name);
Printf(f_enumtypes_value, "| `%s\n", symname);
return Language::enumvalueDeclaration(n);
} else
@ -1646,20 +1650,13 @@ public:
/* any existing helper functions to handle this? */
if (!is_void) {
if (!(ignored_method && !pure_virtual)) {
/* A little explanation:
* The director_enum test case makes a method whose return type
* is an enum type. returntype here is "int". gcc complains
* about an implicit enum conversion, and although i don't strictly
* agree with it, I'm working on fixing the error:
*
* Below is what I came up with. It's not great but it should
* always essentially work.
*/
String *rettype = SwigType_str(returntype, 0);
if (!SwigType_isreference(returntype)) {
Printf(w->code, "CAMLreturn_type((%s)c_result);\n", SwigType_lstr(returntype, ""));
Printf(w->code, "CAMLreturn_type((%s)c_result);\n", rettype);
} else {
Printf(w->code, "CAMLreturn_type(*c_result);\n");
Printf(w->code, "CAMLreturn_type((%s)*c_result);\n", rettype);
}
Delete(rettype);
}
} else {
Printf(w->code, "CAMLreturn0;\n");

View file

@ -4,7 +4,7 @@
* 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
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
* and at https://www.swig.org/legal.html.
*
* octave.cxx
*
@ -190,7 +190,7 @@ public:
Swig_banner(f_begin);
Printf(f_runtime, "\n\n#ifndef SWIGOCTAVE\n#define SWIGOCTAVE\n#endif\n\n");
Swig_obligatory_macros(f_runtime, "OCTAVE");
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
Printf(f_runtime, "#define SWIG_name %s\n", module);
@ -835,7 +835,7 @@ public:
String *setwname = Swig_name_wrapper(setname);
Octave_begin_function(n, setf->def, setname, setwname, true);
Printf(setf->code, "if (!SWIG_check_num_args(\"%s_set\",args.length(),1,1,0)) return octave_value_list();", iname);
Printf(setf->code, "if (!SWIG_check_num_args(\"%s_set\",args.length(),1,1,0)) return octave_value_list();\n", iname);
if (is_assignable(n)) {
Setattr(n, "wrap:name", setname);
if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
@ -946,7 +946,7 @@ public:
// This is a bug, due to the fact that swig_type -> octave_class mapping
// is 1-to-n.
static Hash *emitted = NewHash();
String *mangled_classname = Swig_name_mangle(Getattr(n, "name"));
String *mangled_classname = Swig_name_mangle_type(Getattr(n, "name"));
if (Getattr(emitted, mangled_classname)) {
Delete(mangled_classname);
return SWIG_NOWRAP;

Some files were not shown because too many files have changed in this diff Show more