Merge remote-tracking branch 'origin/master' into gsoc2012-scilab
Conflicts: .gitignore .travis.yml configure.ac
This commit is contained in:
commit
adc4b788df
352 changed files with 8897 additions and 2812 deletions
|
|
@ -627,9 +627,11 @@ public:
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void emitBanner(File *f) {
|
||||
Printf(f, "/* ----------------------------------------------------------------------------\n");
|
||||
Swig_banner_target_lang(f, " *");
|
||||
Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
|
||||
Printf(f, "//------------------------------------------------------------------------------\n");
|
||||
Printf(f, "// <auto-generated />\n");
|
||||
Printf(f, "//\n");
|
||||
Swig_banner_target_lang(f, "//");
|
||||
Printf(f, "//------------------------------------------------------------------------------\n\n");
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
|
|
@ -717,7 +719,7 @@ public:
|
|||
String *overloaded_name = getOverloadedName(n);
|
||||
|
||||
if (!Getattr(n, "sym:overloaded")) {
|
||||
if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name))
|
||||
if (!addSymbol(symname, n, imclass_name))
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
|
|
@ -912,21 +914,10 @@ public:
|
|||
String *null_attribute = 0;
|
||||
// Now write code to make the function call
|
||||
if (!native_function_flag) {
|
||||
if (Cmp(nodeType(n), "constant") == 0) {
|
||||
// Wrapping a constant hack
|
||||
Swig_save("functionWrapper", n, "wrap:action", NIL);
|
||||
|
||||
// below based on Swig_VargetToFunction()
|
||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
||||
Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
}
|
||||
|
||||
Swig_director_emit_dynamic_cast(n, f);
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if (Cmp(nodeType(n), "constant") == 0)
|
||||
Swig_restore(n);
|
||||
|
||||
/* Return value if necessary */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
canThrow(n, "out", n);
|
||||
|
|
@ -1088,15 +1079,13 @@ public:
|
|||
return ret;
|
||||
}
|
||||
|
||||
String *getCurrentScopeName(String *nspace)
|
||||
{
|
||||
String *getCurrentScopeName(String *nspace) {
|
||||
String *scope = 0;
|
||||
if (nspace || getCurrentClass()) {
|
||||
scope = NewString("");
|
||||
if (nspace)
|
||||
Printf(scope, "%s", nspace);
|
||||
if (Node* cls = getCurrentClass())
|
||||
{
|
||||
if (Node* cls = getCurrentClass()) {
|
||||
if (Node *outer = Getattr(cls, "nested:outer")) {
|
||||
String *outerClassesPrefix = Copy(Getattr(outer, "sym:name"));
|
||||
for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) {
|
||||
|
|
@ -1266,6 +1255,7 @@ public:
|
|||
int unnamedinstance = GetFlag(parent, "unnamedinstance");
|
||||
String *parent_name = Getattr(parent, "name");
|
||||
String *nspace = getNSpace();
|
||||
String *newsymname = 0;
|
||||
String *tmpValue;
|
||||
|
||||
// Strange hack from parent method
|
||||
|
|
@ -1290,14 +1280,20 @@ public:
|
|||
{
|
||||
EnumFeature enum_feature = decodeEnumFeature(parent);
|
||||
|
||||
if ((enum_feature == SimpleEnum) && GetFlag(parent, "scopedenum")) {
|
||||
newsymname = Swig_name_member(0, Getattr(parent, "sym:name"), symname);
|
||||
symname = newsymname;
|
||||
}
|
||||
|
||||
// Add to language symbol table
|
||||
String *scope = 0;
|
||||
if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) {
|
||||
if (proxy_class_name) {
|
||||
String *enumClassPrefix = getEnumClassPrefix();
|
||||
if (enumClassPrefix) {
|
||||
scope = NewString("");
|
||||
if (nspace)
|
||||
Printf(scope, "%s.", nspace);
|
||||
Printf(scope, "%s", proxy_class_name);
|
||||
Printf(scope, "%s", enumClassPrefix);
|
||||
} else {
|
||||
scope = Copy(module_class_name);
|
||||
}
|
||||
|
|
@ -1308,7 +1304,7 @@ public:
|
|||
else
|
||||
Printf(scope, ".%s", Getattr(parent, "sym:name"));
|
||||
}
|
||||
if (!addSymbol(name, n, scope))
|
||||
if (!addSymbol(symname, n, scope))
|
||||
return SWIG_ERROR;
|
||||
|
||||
const String *csattributes = Getattr(n, "feature:cs:attributes");
|
||||
|
|
@ -1380,6 +1376,7 @@ public:
|
|||
Delete(scope);
|
||||
}
|
||||
|
||||
Delete(newsymname);
|
||||
Delete(tmpValue);
|
||||
Swig_restore(n);
|
||||
return SWIG_OK;
|
||||
|
|
@ -3053,6 +3050,16 @@ public:
|
|||
// Use the C syntax to make a true C# constant and hope that it compiles as C# code
|
||||
value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex"));
|
||||
} else {
|
||||
String *newsymname = 0;
|
||||
if (!getCurrentClass() || !proxy_flag) {
|
||||
String *enumClassPrefix = getEnumClassPrefix();
|
||||
if (enumClassPrefix) {
|
||||
// A global scoped enum
|
||||
newsymname = Swig_name_member(0, enumClassPrefix, symname);
|
||||
symname = newsymname;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the enumvalue from a PINVOKE call
|
||||
if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) {
|
||||
// Strange hack to change the name
|
||||
|
|
@ -3061,7 +3068,7 @@ public:
|
|||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
||||
} else {
|
||||
memberconstantHandler(n);
|
||||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname)));
|
||||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, getEnumClassPrefix(), symname)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3198,43 +3205,6 @@ public:
|
|||
Delete(replacementname);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* makeParameterName()
|
||||
*
|
||||
* Inputs:
|
||||
* n - Node
|
||||
* p - parameter node
|
||||
* arg_num - parameter argument number
|
||||
* setter - set this flag when wrapping variables
|
||||
* Return:
|
||||
* arg - a unique parameter name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter) {
|
||||
|
||||
String *arg = 0;
|
||||
String *pn = Getattr(p, "name");
|
||||
|
||||
// Use C parameter name unless it is a duplicate or an empty parameter name
|
||||
int count = 0;
|
||||
ParmList *plist = Getattr(n, "parms");
|
||||
while (plist) {
|
||||
if ((Cmp(pn, Getattr(plist, "name")) == 0))
|
||||
count++;
|
||||
plist = nextSibling(plist);
|
||||
}
|
||||
String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0;
|
||||
arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn);
|
||||
|
||||
if (setter && Cmp(arg, "self") != 0) {
|
||||
// Note that in C# properties, the input variable name is always called 'value'
|
||||
Delete(arg);
|
||||
arg = NewString("value");
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* emitTypeWrapperClass()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -4283,6 +4253,10 @@ public:
|
|||
Delete(dirclassname);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* nestedClassesSupport()
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
NestedClassSupport nestedClassesSupport() const {
|
||||
return NCS_Full;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -803,24 +803,24 @@ public:
|
|||
// Emit each enum item.
|
||||
Language::enumDeclaration(n);
|
||||
|
||||
if (!GetFlag(n, "nonempty")) {
|
||||
// Do not wrap empty enums; the resulting D code would be illegal.
|
||||
Delete(proxy_enum_code);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
|
||||
// Finish the enum.
|
||||
if (typemap_lookup_type) {
|
||||
Printv(proxy_enum_code,
|
||||
lookupCodeTypemap(n, "dcode", typemap_lookup_type, WARN_NONE), // Extra D code
|
||||
"\n}\n", NIL);
|
||||
if (GetFlag(n, "nonempty")) {
|
||||
// Finish the enum.
|
||||
if (typemap_lookup_type) {
|
||||
Printv(proxy_enum_code,
|
||||
lookupCodeTypemap(n, "dcode", typemap_lookup_type, WARN_NONE), // Extra D code
|
||||
"\n}\n", NIL);
|
||||
} else {
|
||||
// Handle anonymous enums.
|
||||
Printv(proxy_enum_code, "\n}\n", NIL);
|
||||
}
|
||||
Replaceall(proxy_enum_code, "$dclassname", symname);
|
||||
} else {
|
||||
// Handle anonymous enums.
|
||||
Printv(proxy_enum_code, "\n}\n", NIL);
|
||||
// D enum declarations must have at least one member to be legal, so emit
|
||||
// an alias to int instead (their ctype/imtype is always int).
|
||||
Delete(proxy_enum_code);
|
||||
proxy_enum_code = NewStringf("\nalias int %s;\n", symname);
|
||||
}
|
||||
|
||||
Replaceall(proxy_enum_code, "$dclassname", symname);
|
||||
|
||||
const String* imports =
|
||||
lookupCodeTypemap(n, "dimports", typemap_lookup_type, WARN_NONE);
|
||||
String* imports_trimmed;
|
||||
|
|
@ -1701,21 +1701,10 @@ public:
|
|||
String *null_attribute = 0;
|
||||
// Now write code to make the function call
|
||||
if (!native_function_flag) {
|
||||
if (Cmp(nodeType(n), "constant") == 0) {
|
||||
// Wrapping a constant hack
|
||||
Swig_save("functionWrapper", n, "wrap:action", NIL);
|
||||
|
||||
// below based on Swig_VargetToFunction()
|
||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
||||
Setattr(n, "wrap:action", NewStringf("%s = (%s) %s;", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
}
|
||||
|
||||
Swig_director_emit_dynamic_cast(n, f);
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if (Cmp(nodeType(n), "constant") == 0)
|
||||
Swig_restore(n);
|
||||
|
||||
/* Return value if necessary */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
canThrow(n, "out", n);
|
||||
|
|
@ -2594,7 +2583,7 @@ private:
|
|||
const_String_or_char_ptr wrapper_function_name) {
|
||||
|
||||
// TODO: Add support for static linking here.
|
||||
Printf(im_dmodule_code, "extern(C) %s function%s %s;\n", return_type,
|
||||
Printf(im_dmodule_code, "SwigExternC!(%s function%s) %s;\n", return_type,
|
||||
parameters, d_name);
|
||||
Printv(wrapper_loader_bind_code, wrapper_loader_bind_command, NIL);
|
||||
Replaceall(wrapper_loader_bind_code, "$function", d_name);
|
||||
|
|
@ -2850,7 +2839,7 @@ private:
|
|||
// polymorphic call or an explicit method call. Needed to prevent infinite
|
||||
// recursion when calling director methods.
|
||||
Node *explicit_n = Getattr(n, "explicitcallnode");
|
||||
if (explicit_n) {
|
||||
if (explicit_n && Swig_directorclass(getCurrentClass())) {
|
||||
String *ex_overloaded_name = getOverloadedName(explicit_n);
|
||||
String *ex_intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, ex_overloaded_name);
|
||||
|
||||
|
|
@ -4299,40 +4288,8 @@ private:
|
|||
return proxyname;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* D::makeParameterName()
|
||||
*
|
||||
* Inputs:
|
||||
* n - Node
|
||||
* p - parameter node
|
||||
* arg_num - parameter argument number
|
||||
* setter - set this flag when wrapping variables
|
||||
* Return:
|
||||
* arg - a unique parameter name
|
||||
* --------------------------------------------------------------------------- */
|
||||
String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter) const {
|
||||
String *arg = 0;
|
||||
String *pn = Getattr(p, "name");
|
||||
|
||||
// Use C parameter name unless it is a duplicate or an empty parameter name
|
||||
int count = 0;
|
||||
ParmList *plist = Getattr(n, "parms");
|
||||
while (plist) {
|
||||
if ((Cmp(pn, Getattr(plist, "name")) == 0))
|
||||
count++;
|
||||
plist = nextSibling(plist);
|
||||
}
|
||||
String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0;
|
||||
arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn);
|
||||
|
||||
if (setter && Cmp(arg, "self") != 0) {
|
||||
// In theory, we could use the normal parameter name for setter functions.
|
||||
// Unfortunately, it is set to "Class::VariableName" for static public
|
||||
// members by the parser, which is not legal D syntax. Thus, we just force
|
||||
// it to "value".
|
||||
Delete(arg);
|
||||
arg = NewString("value");
|
||||
}
|
||||
String *arg = Language::makeParameterName(n, p, arg_num, setter);
|
||||
|
||||
if (split_proxy_dmodule && Strncmp(arg, package, Len(arg)) == 0) {
|
||||
// If we are in split proxy mode and the argument is named like the target
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1350,7 +1350,7 @@ public:
|
|||
Printv(f_header, tm, "\n", NIL);
|
||||
} else {
|
||||
// Create variable and assign it a value
|
||||
Printf(f_header, "static %s = %s;\n", SwigType_str(type, var_name), rvalue);
|
||||
Printf(f_header, "static %s = (%s)(%s);\n", SwigType_str(type, var_name), SwigType_str(type, 0), rvalue);
|
||||
}
|
||||
{
|
||||
/* Hack alert: will cleanup later -- Dave */
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ public:
|
|||
String *symname = Copy(Getattr(n, "sym:name"));
|
||||
if (symname && !GetFlag(n, "feature:flatnested")) {
|
||||
for (Node *outer_class = Getattr(n, "nested:outer"); outer_class; outer_class = Getattr(outer_class, "nested:outer")) {
|
||||
Push(symname, ".");
|
||||
Push(symname, jnidescriptor ? "$" : ".");
|
||||
Push(symname, Getattr(outer_class, "sym:name"));
|
||||
}
|
||||
}
|
||||
|
|
@ -838,7 +838,7 @@ public:
|
|||
bool is_destructor = (Cmp(Getattr(n, "nodeType"), "destructor") == 0);
|
||||
|
||||
if (!Getattr(n, "sym:overloaded")) {
|
||||
if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name))
|
||||
if (!addSymbol(symname, n, imclass_name))
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
|
|
@ -1039,26 +1039,15 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// Now write code to make the function call
|
||||
if (!native_function_flag) {
|
||||
if (Cmp(nodeType(n), "constant") == 0) {
|
||||
// Wrapping a constant hack
|
||||
Swig_save("functionWrapper", n, "wrap:action", NIL);
|
||||
|
||||
// below based on Swig_VargetToFunction()
|
||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
||||
Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
}
|
||||
|
||||
// Now write code to make the function call
|
||||
Swig_director_emit_dynamic_cast(n, f);
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
// Handle exception classes specified in the "except" feature's "throws" attribute
|
||||
addThrows(n, "feature:except", n);
|
||||
|
||||
if (Cmp(nodeType(n), "constant") == 0)
|
||||
Swig_restore(n);
|
||||
|
||||
/* Return value if necessary */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
addThrows(n, "tmap:out", n);
|
||||
|
|
@ -1194,15 +1183,13 @@ public:
|
|||
return ret;
|
||||
}
|
||||
|
||||
String *getCurrentScopeName(String *nspace)
|
||||
{
|
||||
String *getCurrentScopeName(String *nspace) {
|
||||
String *scope = 0;
|
||||
if (nspace || getCurrentClass()) {
|
||||
scope = NewString("");
|
||||
if (nspace)
|
||||
Printf(scope, "%s", nspace);
|
||||
if (Node* cls = getCurrentClass())
|
||||
{
|
||||
if (Node* cls = getCurrentClass()) {
|
||||
if (Node *outer = Getattr(cls, "nested:outer")) {
|
||||
String *outerClassesPrefix = Copy(Getattr(outer, "sym:name"));
|
||||
for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) {
|
||||
|
|
@ -1370,6 +1357,7 @@ public:
|
|||
int unnamedinstance = GetFlag(parent, "unnamedinstance");
|
||||
String *parent_name = Getattr(parent, "name");
|
||||
String *nspace = getNSpace();
|
||||
String *newsymname = 0;
|
||||
String *tmpValue;
|
||||
|
||||
// Strange hack from parent method
|
||||
|
|
@ -1394,14 +1382,20 @@ public:
|
|||
{
|
||||
EnumFeature enum_feature = decodeEnumFeature(parent);
|
||||
|
||||
if ((enum_feature == SimpleEnum) && GetFlag(parent, "scopedenum")) {
|
||||
newsymname = Swig_name_member(0, Getattr(parent, "sym:name"), symname);
|
||||
symname = newsymname;
|
||||
}
|
||||
|
||||
// Add to language symbol table
|
||||
String *scope = 0;
|
||||
if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) {
|
||||
if (proxy_class_name) {
|
||||
String *enumClassPrefix = getEnumClassPrefix();
|
||||
if (enumClassPrefix) {
|
||||
scope = NewString("");
|
||||
if (nspace)
|
||||
Printf(scope, "%s.", nspace);
|
||||
Printf(scope, "%s", proxy_class_name);
|
||||
Printf(scope, "%s", enumClassPrefix);
|
||||
} else {
|
||||
scope = Copy(constants_interface_name);
|
||||
}
|
||||
|
|
@ -1412,7 +1406,7 @@ public:
|
|||
else
|
||||
Printf(scope, ".%s", Getattr(parent, "sym:name"));
|
||||
}
|
||||
if (!addSymbol(name, n, scope))
|
||||
if (!addSymbol(symname, n, scope))
|
||||
return SWIG_ERROR;
|
||||
|
||||
if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
|
||||
|
|
@ -1466,6 +1460,7 @@ public:
|
|||
Delete(scope);
|
||||
}
|
||||
|
||||
Delete(newsymname);
|
||||
Delete(tmpValue);
|
||||
Swig_restore(n);
|
||||
return SWIG_OK;
|
||||
|
|
@ -2268,7 +2263,7 @@ public:
|
|||
Printf(imcall, "swigCPtr");
|
||||
|
||||
String *this_type = Copy(getClassType());
|
||||
String *name = NewString("self");
|
||||
String *name = NewString("jself");
|
||||
String *qualifier = Getattr(n, "qualifier");
|
||||
if (qualifier)
|
||||
SwigType_push(this_type, qualifier);
|
||||
|
|
@ -2959,6 +2954,16 @@ public:
|
|||
// Use the C syntax to make a true Java constant and hope that it compiles as Java code
|
||||
value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex"));
|
||||
} else {
|
||||
String *newsymname = 0;
|
||||
if (!getCurrentClass() || !proxy_flag) {
|
||||
String *enumClassPrefix = getEnumClassPrefix();
|
||||
if (enumClassPrefix) {
|
||||
// A global scoped enum
|
||||
newsymname = Swig_name_member(0, enumClassPrefix, symname);
|
||||
symname = newsymname;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the enumvalue from a JNI call
|
||||
if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) {
|
||||
// Strange hack to change the name
|
||||
|
|
@ -2967,8 +2972,9 @@ public:
|
|||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
||||
} else {
|
||||
memberconstantHandler(n);
|
||||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname)));
|
||||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, getEnumClassPrefix(), symname)));
|
||||
}
|
||||
Delete(newsymname);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
|
|
@ -3115,44 +3121,6 @@ public:
|
|||
Delete(replacementname);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* makeParameterName()
|
||||
*
|
||||
* Inputs:
|
||||
* n - Node
|
||||
* p - parameter node
|
||||
* arg_num - parameter argument number
|
||||
* setter - set this flag when wrapping variables
|
||||
* Return:
|
||||
* arg - a unique parameter name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter) {
|
||||
|
||||
String *arg = 0;
|
||||
String *pn = Getattr(p, "name");
|
||||
|
||||
// Use C parameter name unless it is a duplicate or an empty parameter name
|
||||
int count = 0;
|
||||
ParmList *plist = Getattr(n, "parms");
|
||||
while (plist) {
|
||||
if ((Cmp(pn, Getattr(plist, "name")) == 0))
|
||||
count++;
|
||||
plist = nextSibling(plist);
|
||||
}
|
||||
String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0;
|
||||
arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn);
|
||||
|
||||
if (setter && Cmp(arg, "self") != 0) {
|
||||
// Note that for setters the parameter name is always set but sometimes includes C++
|
||||
// scope resolution, so we need to strip off the scope resolution to make a valid name.
|
||||
Delete(arg);
|
||||
arg = NewString("value"); //Swig_scopename_last(pn);
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* emitTypeWrapperClass()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -3670,7 +3638,6 @@ public:
|
|||
* --------------------------------------------------------------- */
|
||||
|
||||
int classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||
String *classname = Getattr(parent, "sym:name");
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *name = Getattr(n, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
|
|
@ -3704,14 +3671,7 @@ public:
|
|||
String *imcall_args = NewString("");
|
||||
int classmeth_off = curr_class_dmethod - first_class_dmethod;
|
||||
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
|
||||
String *qualified_classname = Copy(classname);
|
||||
String *nspace = getNSpace();
|
||||
|
||||
if (nspace && package)
|
||||
Insert(qualified_classname, 0, NewStringf("%s.%s.", package, nspace));
|
||||
else if(nspace)
|
||||
Insert(qualified_classname, 0, NewStringf("%s.", nspace));
|
||||
|
||||
String *qualified_classname = getProxyName(getClassName());
|
||||
|
||||
// Kludge Alert: functionWrapper sets sym:overload properly, but it
|
||||
// isn't at this point, so we have to manufacture it ourselves. At least
|
||||
|
|
@ -3772,7 +3732,7 @@ public:
|
|||
/* Create the intermediate class wrapper */
|
||||
tm = Swig_typemap_lookup("jtype", n, "", 0);
|
||||
if (tm) {
|
||||
Printf(callback_def, " public static %s %s(%s self", tm, imclass_dmethod, qualified_classname);
|
||||
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));
|
||||
}
|
||||
|
|
@ -3834,7 +3794,6 @@ public:
|
|||
}
|
||||
|
||||
Delete(adjustedreturntypeparm);
|
||||
Delete(qualified_classname);
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
|
|
@ -3889,7 +3848,7 @@ public:
|
|||
Printf(w->code, "if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {\n");
|
||||
}
|
||||
|
||||
/* Start the Java field descriptor for the intermediate class's upcall (insert self object) */
|
||||
/* Start the Java field descriptor for the intermediate class's upcall (insert jself object) */
|
||||
Parm *tp = NewParmNode(c_classname, n);
|
||||
String *jdesc;
|
||||
|
||||
|
|
@ -4100,7 +4059,7 @@ public:
|
|||
|
||||
/* Emit the intermediate class's upcall to the actual class */
|
||||
|
||||
String *upcall = NewStringf("self.%s(%s)", symname, imcall_args);
|
||||
String *upcall = NewStringf("jself.%s(%s)", symname, imcall_args);
|
||||
|
||||
// Handle exception classes specified in the "except" feature's "throws" attribute
|
||||
addThrows(n, "feature:except", n);
|
||||
|
|
@ -4475,18 +4434,15 @@ public:
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
int classDirectorEnd(Node *n) {
|
||||
String *classname = Getattr(n, "sym:name");
|
||||
String *full_classname = Getattr(n, "name");
|
||||
String *classname = getProxyName(full_classname, true);
|
||||
String *director_classname = directorClassName(n);
|
||||
String *internal_classname;
|
||||
|
||||
Wrapper *w = NewWrapper();
|
||||
|
||||
if (Len(package_path) > 0 && Len(getNSpace()) > 0)
|
||||
internal_classname = NewStringf("%s/%s/%s", package_path, getNSpace(), classname);
|
||||
else if (Len(package_path) > 0)
|
||||
if (Len(package_path) > 0)
|
||||
internal_classname = NewStringf("%s/%s", package_path, classname);
|
||||
else if (Len(getNSpace()) > 0)
|
||||
internal_classname = NewStringf("%s/%s", getNSpace(), classname);
|
||||
else
|
||||
internal_classname = NewStringf("%s", classname);
|
||||
|
||||
|
|
@ -4598,6 +4554,7 @@ public:
|
|||
/*----------------------------------------------------------------------
|
||||
* extraDirectorProtectedCPPMethodsRequired()
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
bool extraDirectorProtectedCPPMethodsRequired() const {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -4623,6 +4580,10 @@ public:
|
|||
Setattr(n, "director:ctor", class_ctor);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* nestedClassesSupport()
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
NestedClassSupport nestedClassesSupport() const {
|
||||
return NCS_Full;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1231,18 +1231,27 @@ int JSEmitter::emitFunctionDispatcher(Node *n, bool /*is_member */ ) {
|
|||
// substract the extension "sym:overname",
|
||||
String *wrap_name = NewString(Getattr(n, "wrap:name"));
|
||||
String *overname = Getattr(n, "sym:overname");
|
||||
|
||||
Node *methodclass = Swig_methodclass(n);
|
||||
String *class_name = Getattr(methodclass, "sym:name");
|
||||
|
||||
int l1 = Len(wrap_name);
|
||||
int l2 = Len(overname);
|
||||
Delslice(wrap_name, l1 - l2, l1);
|
||||
|
||||
Setattr(n, "wrap:name", wrap_name);
|
||||
state.function(WRAPPER_NAME, wrap_name);
|
||||
String *new_string = NewStringf("%s_%s", class_name, wrap_name);
|
||||
String *final_wrap_name = Swig_name_wrapper(new_string);
|
||||
|
||||
Setattr(n, "wrap:name", final_wrap_name);
|
||||
state.function(WRAPPER_NAME, final_wrap_name);
|
||||
|
||||
|
||||
|
||||
t_function.replace("$jslocals", wrapper->locals)
|
||||
.replace("$jscode", wrapper->code);
|
||||
|
||||
// call this here, to replace all variables
|
||||
t_function.replace("$jswrapper", wrap_name)
|
||||
t_function.replace("$jswrapper", final_wrap_name)
|
||||
.replace("$jsname", state.function(NAME))
|
||||
.pretty_print(f_wrappers);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,9 @@ extern "C" {
|
|||
/* Some status variables used during parsing */
|
||||
static int InClass = 0; /* Parsing C++ or not */
|
||||
static String *ClassName = 0; /* This is the real name of the current class */
|
||||
static String *EnumClassName = 0; /* Enum class name */
|
||||
static String *ClassPrefix = 0; /* Class prefix */
|
||||
static String *EnumClassPrefix = 0; /* Prefix for strongly typed enums (including ClassPrefix) */
|
||||
static String *NSpace = 0; /* Namespace for the nspace feature */
|
||||
static String *ClassType = 0; /* Fully qualified type name to use */
|
||||
static String *DirectorClassName = 0; /* Director name of the current class */
|
||||
|
|
@ -1650,10 +1652,24 @@ int Language::enumDeclaration(Node *n) {
|
|||
String *oldNSpace = NSpace;
|
||||
NSpace = Getattr(n, "sym:nspace");
|
||||
|
||||
String *oldEnumClassPrefix = EnumClassPrefix;
|
||||
if (GetFlag(n, "scopedenum")) {
|
||||
assert(Getattr(n, "sym:name"));
|
||||
assert(Getattr(n, "name"));
|
||||
EnumClassPrefix = ClassPrefix ? NewStringf("%s_", ClassPrefix) : NewString("");
|
||||
Printv(EnumClassPrefix, Getattr(n, "sym:name"), NIL);
|
||||
EnumClassName = Copy(Getattr(n, "name"));
|
||||
}
|
||||
if (!ImportMode) {
|
||||
emit_children(n);
|
||||
}
|
||||
|
||||
if (GetFlag(n, "scopedenum")) {
|
||||
Delete(EnumClassName);
|
||||
EnumClassName = 0;
|
||||
Delete(EnumClassPrefix);
|
||||
EnumClassPrefix = oldEnumClassPrefix;
|
||||
}
|
||||
NSpace = oldNSpace;
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -1667,7 +1683,7 @@ int Language::enumvalueDeclaration(Node *n) {
|
|||
if (CurrentClass && (cplus_mode != PUBLIC))
|
||||
return SWIG_NOWRAP;
|
||||
|
||||
Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL);
|
||||
Swig_require("enumvalueDeclaration", n, "*name", "*sym:name", "?value", NIL);
|
||||
String *value = Getattr(n, "value");
|
||||
String *name = Getattr(n, "name");
|
||||
String *tmpValue;
|
||||
|
|
@ -1678,6 +1694,13 @@ int Language::enumvalueDeclaration(Node *n) {
|
|||
tmpValue = NewString(name);
|
||||
Setattr(n, "value", tmpValue);
|
||||
|
||||
Node *parent = parentNode(n);
|
||||
if (GetFlag(parent, "scopedenum")) {
|
||||
String *symname = Swig_name_member(0, Getattr(parent, "sym:name"), Getattr(n, "sym:name"));
|
||||
Setattr(n, "sym:name", symname);
|
||||
Delete(symname);
|
||||
}
|
||||
|
||||
if (!CurrentClass || !cparse_cplusplus) {
|
||||
Setattr(n, "name", tmpValue); /* for wrapping of enums in a namespace when emit_action is used */
|
||||
constantWrapper(n);
|
||||
|
|
@ -1716,16 +1739,19 @@ int Language::memberconstantHandler(Node *n) {
|
|||
Setattr(n, "feature:except", Getattr(n, "feature:exceptvar"));
|
||||
}
|
||||
|
||||
String *enumvalue_symname = Getattr(n, "enumvalueDeclaration:sym:name"); // Only set if a strongly typed enum
|
||||
String *name = Getattr(n, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *value = Getattr(n, "value");
|
||||
|
||||
String *mrename = Swig_name_member(0, ClassPrefix, symname);
|
||||
String *mrename = Swig_name_member(0, EnumClassPrefix, enumvalue_symname ? enumvalue_symname : symname);
|
||||
Setattr(n, "sym:name", mrename);
|
||||
|
||||
String *new_name = 0;
|
||||
if (Extend)
|
||||
new_name = Copy(value);
|
||||
else if (EnumClassName)
|
||||
new_name = NewStringf("%s::%s", isNonVirtualProtectedAccess(n) ? DirectorClassName : EnumClassName, name);
|
||||
else
|
||||
new_name = NewStringf("%s::%s", isNonVirtualProtectedAccess(n) ? DirectorClassName : ClassName, name);
|
||||
Setattr(n, "name", new_name);
|
||||
|
|
@ -2043,7 +2069,7 @@ int Language::classDirectorConstructors(Node *n) {
|
|||
needed, since there is a public constructor already defined.
|
||||
|
||||
(scottm) This code is needed here to make the director_abstract +
|
||||
test generate compileable code (Example2 in director_abastract.i).
|
||||
test generate compilable code (Example2 in director_abastract.i).
|
||||
|
||||
(mmatus) This is very strange, since swig compiled with gcc3.2.3
|
||||
doesn't need it here....
|
||||
|
|
@ -2369,6 +2395,7 @@ int Language::classDeclaration(Node *n) {
|
|||
int oldInClass = InClass;
|
||||
String *oldClassType = ClassType;
|
||||
String *oldClassPrefix = ClassPrefix;
|
||||
String *oldEnumClassPrefix = EnumClassPrefix;
|
||||
String *oldClassName = ClassName;
|
||||
String *oldDirectorClassName = DirectorClassName;
|
||||
String *oldNSpace = NSpace;
|
||||
|
|
@ -2410,6 +2437,7 @@ int Language::classDeclaration(Node *n) {
|
|||
Push(ClassPrefix, "_");
|
||||
Push(ClassPrefix, Getattr(outerClass, "sym:name"));
|
||||
}
|
||||
EnumClassPrefix = Copy(ClassPrefix);
|
||||
if (strip) {
|
||||
ClassType = Copy(name);
|
||||
} else {
|
||||
|
|
@ -2477,6 +2505,8 @@ int Language::classDeclaration(Node *n) {
|
|||
CurrentClass = oldCurrentClass;
|
||||
Delete(ClassType);
|
||||
ClassType = oldClassType;
|
||||
Delete(EnumClassPrefix);
|
||||
EnumClassPrefix = oldEnumClassPrefix;
|
||||
Delete(ClassPrefix);
|
||||
ClassPrefix = oldClassPrefix;
|
||||
Delete(ClassName);
|
||||
|
|
@ -2664,7 +2694,8 @@ int Language::constructorDeclaration(Node *n) {
|
|||
String *scope = Swig_scopename_check(ClassName) ? Swig_scopename_prefix(ClassName) : 0;
|
||||
String *actual_name = scope ? NewStringf("%s::%s", scope, name) : NewString(name);
|
||||
Delete(scope);
|
||||
if (!Equal(actual_name, expected_name) && !SwigType_istemplate(expected_name)) {
|
||||
if (!Equal(actual_name, expected_name) && !SwigType_istemplate(expected_name) && !SwigType_istemplate(actual_name)) {
|
||||
// Checking templates is skipped but they ought to be checked... they are just somewhat more tricky to check correctly
|
||||
bool illegal_name = true;
|
||||
if (Extend) {
|
||||
// Check for typedef names used as a constructor name in %extend. This is deprecated except for anonymous
|
||||
|
|
@ -2962,6 +2993,12 @@ int Language::variableWrapper(Node *n) {
|
|||
Delattr(n,"varset");
|
||||
Delattr(n,"varget");
|
||||
|
||||
String *newsymname = 0;
|
||||
if (!CurrentClass && EnumClassPrefix) {
|
||||
newsymname = Swig_name_member(0, EnumClassPrefix, symname);
|
||||
symname = newsymname;
|
||||
}
|
||||
|
||||
/* If no way to set variables. We simply create functions */
|
||||
int assignable = is_assignable(n);
|
||||
int flags = use_naturalvar_mode(n);
|
||||
|
|
@ -3019,6 +3056,7 @@ int Language::variableWrapper(Node *n) {
|
|||
functionWrapper(n);
|
||||
Delattr(n, "varget");
|
||||
Swig_restore(n);
|
||||
Delete(newsymname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -3499,6 +3537,45 @@ int Language::is_smart_pointer() const {
|
|||
return SmartPointer;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::makeParameterName()
|
||||
*
|
||||
* Inputs:
|
||||
* n - Node
|
||||
* p - parameter node
|
||||
* arg_num - parameter argument number
|
||||
* setter - set this flag when wrapping variables
|
||||
* Return:
|
||||
* arg - a unique parameter name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
String *Language::makeParameterName(Node *n, Parm *p, int arg_num, bool setter) const {
|
||||
|
||||
String *arg = 0;
|
||||
String *pn = Getattr(p, "name");
|
||||
|
||||
// Use C parameter name unless it is a duplicate or an empty parameter name
|
||||
int count = 0;
|
||||
ParmList *plist = Getattr(n, "parms");
|
||||
while (plist) {
|
||||
if ((Cmp(pn, Getattr(plist, "name")) == 0))
|
||||
count++;
|
||||
plist = nextSibling(plist);
|
||||
}
|
||||
String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0;
|
||||
arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn);
|
||||
|
||||
if (setter && Cmp(arg, "self") != 0) {
|
||||
// Some languages (C#) insist on calling the input variable "value" while
|
||||
// others (D, Java) could, in principle, use something different but this
|
||||
// would require more work, and so we just use "value" for them too.
|
||||
// For setters the parameter name sometimes includes C++ scope resolution which needs removing.
|
||||
Delete(arg);
|
||||
arg = NewString("value");
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -3517,9 +3594,22 @@ bool Language::extraDirectorProtectedCPPMethodsRequired() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::nestedClassesSupport()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Language::NestedClassSupport Language::nestedClassesSupport() const {
|
||||
return NCS_Unknown;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::kwargsSupport()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
bool Language::kwargsSupport() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::is_wrapping_class()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -3560,6 +3650,14 @@ String *Language::getClassPrefix() const {
|
|||
return ClassPrefix;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::getEnumClassPrefix()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Language::getEnumClassPrefix() const {
|
||||
return EnumClassPrefix;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::getClassType()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -1184,10 +1184,12 @@ public:
|
|||
if (getCurrentClass() && (cplus_mode != PUBLIC))
|
||||
return SWIG_NOWRAP;
|
||||
|
||||
Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL);
|
||||
Swig_require("enumvalueDeclaration", n, "*name", "?value", "*sym:name", NIL);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *value = Getattr(n, "value");
|
||||
String *name = Getattr(n, "name");
|
||||
String *tmpValue;
|
||||
Node *parent = parentNode(n);
|
||||
|
||||
if (value)
|
||||
tmpValue = NewString(value);
|
||||
|
|
@ -1196,6 +1198,13 @@ public:
|
|||
Setattr(n, "value", tmpValue);
|
||||
|
||||
Setattr(n, "name", tmpValue); /* for wrapping of enums in a namespace when emit_action is used */
|
||||
|
||||
if (GetFlag(parent, "scopedenum")) {
|
||||
symname = Swig_name_member(0, Getattr(parent, "sym:name"), symname);
|
||||
Setattr(n, "sym:name", symname);
|
||||
Delete(symname);
|
||||
}
|
||||
|
||||
int result = constantWrapper(n);
|
||||
|
||||
Delete(tmpValue);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ int SwigRuntime = 0; // 0 = no option, 1 = -runtime, 2 = -noruntime
|
|||
extern "C" {
|
||||
extern String *ModuleName;
|
||||
extern int ignore_nested_classes;
|
||||
extern int kwargs_supported;
|
||||
}
|
||||
|
||||
/* usage string split into multiple parts otherwise string is too big for some compilers */
|
||||
|
|
@ -62,6 +63,8 @@ static const char *usage1 = (const char *) "\
|
|||
-co <file> - Check <file> out of the SWIG library\n\
|
||||
-copyctor - Automatically generate copy constructors wherever possible\n\
|
||||
-cpperraswarn - Treat the preprocessor #error statement as #warning (default)\n\
|
||||
-cppext <ext> - Change file extension of generated C++ files to <ext>\n\
|
||||
(default is cxx, except for PHP which uses cpp)\n\
|
||||
-copyright - Display copyright notices\n\
|
||||
-debug-classes - Display information about the classes found in the interface\n\
|
||||
-debug-module <n>- Display module parse tree at stages 1-4, <n> is a csv list of stages\n\
|
||||
|
|
@ -79,6 +82,9 @@ static const char *usage1 = (const char *) "\
|
|||
-directors - Turn on director mode for all the classes, mainly for testing\n\
|
||||
-dirprot - Turn on wrapping of protected members for director classes (default)\n\
|
||||
-D<symbol> - Define a symbol <symbol> (for conditional compilation)\n\
|
||||
";
|
||||
|
||||
static const char *usage2 = (const char *) "\
|
||||
-E - Preprocess only, does not generate wrapper code\n\
|
||||
-external-runtime [file] - Export the SWIG runtime stack\n\
|
||||
-fakeversion <v>- Make SWIG fake the program version number to <v>\n\
|
||||
|
|
@ -86,9 +92,6 @@ static const char *usage1 = (const char *) "\
|
|||
-features <list>- Set global features, where <list> is a comma separated list of\n\
|
||||
features, eg -features directors,autodoc=1\n\
|
||||
If no explicit value is given to the feature, a default of 1 is used\n\
|
||||
";
|
||||
|
||||
static const char *usage2 = (const char *) "\
|
||||
-fastdispatch - Enable fast dispatch mode to produce faster overload dispatcher code\n\
|
||||
-Fmicrosoft - Display error/warning messages in Microsoft format\n\
|
||||
-Fstandard - Display error/warning messages in commonly used format\n\
|
||||
|
|
@ -100,6 +103,9 @@ static const char *usage2 = (const char *) "\
|
|||
-importall - Follow all #include statements as imports\n\
|
||||
-includeall - Follow all #include statements\n\
|
||||
-l<ifile> - Include SWIG library file <ifile>\n\
|
||||
";
|
||||
|
||||
static const char *usage3 = (const char *) "\
|
||||
-macroerrors - Report errors inside macros\n\
|
||||
-makedefault - Create default constructors/destructors (the default)\n\
|
||||
-M - List all dependencies\n\
|
||||
|
|
@ -119,10 +125,10 @@ static const char *usage2 = (const char *) "\
|
|||
-noexcept - Do not wrap exception specifiers\n\
|
||||
-nofastdispatch - Disable fast dispatch mode (default)\n\
|
||||
-nopreprocess - Skip the preprocessor step\n\
|
||||
-notemplatereduce - Disable reduction of the typedefs in templates\n\
|
||||
";
|
||||
|
||||
static const char *usage3 = (const char *) "\
|
||||
-notemplatereduce - Disable reduction of the typedefs in templates\n\
|
||||
static const char *usage4 = (const char *) "\
|
||||
-O - Enable the optimization options: \n\
|
||||
-fastdispatch -fvirtual \n\
|
||||
-o <outfile> - Set name of the output file to <outfile>\n\
|
||||
|
|
@ -677,6 +683,15 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-nocpperraswarn") == 0) {
|
||||
Preprocessor_error_as_warning(0);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-cppext") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
SWIG_config_cppext(argv[i + 1]);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if ((strcmp(argv[i], "-debug-typemap") == 0) || (strcmp(argv[i], "-debug_typemap") == 0) || (strcmp(argv[i], "-tm_debug") == 0)) {
|
||||
tm_debug = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -850,6 +865,7 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
fputs(usage1, stdout);
|
||||
fputs(usage2, stdout);
|
||||
fputs(usage3, stdout);
|
||||
fputs(usage4, stdout);
|
||||
Swig_mark_arg(i);
|
||||
help = 1;
|
||||
}
|
||||
|
|
@ -904,6 +920,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
// Inform the parser if the nested classes should be ignored unless explicitly told otherwise via feature:flatnested
|
||||
ignore_nested_classes = l->nestedClassesSupport() == Language::NCS_Unknown ? 1 : 0;
|
||||
|
||||
kwargs_supported = l->kwargsSupport() ? 1 : 0;
|
||||
|
||||
// Create Library search directories
|
||||
|
||||
// Check for SWIG_LIB environment variable
|
||||
|
|
|
|||
|
|
@ -1407,25 +1407,12 @@ MODULA3():
|
|||
}
|
||||
}
|
||||
|
||||
if (Cmp(nodeType(n), "constant") == 0) {
|
||||
// Wrapping a constant hack
|
||||
Swig_save("functionWrapper", n, "wrap:action", NIL);
|
||||
|
||||
// below based on Swig_VargetToFunction()
|
||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
||||
Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
}
|
||||
|
||||
Setattr(n, "wrap:name", wname);
|
||||
|
||||
// Now write code to make the function call
|
||||
if (!native_function_flag) {
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if (Cmp(nodeType(n), "constant") == 0) {
|
||||
Swig_restore(n);
|
||||
}
|
||||
|
||||
/* Return value if necessary */
|
||||
String *tm;
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
|
|
@ -3621,35 +3608,6 @@ MODULA3():
|
|||
return substitution_performed;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* makeParameterName()
|
||||
*
|
||||
* Inputs:
|
||||
* n - Node
|
||||
* p - parameter node
|
||||
* arg_num - parameter argument number
|
||||
* Return:
|
||||
* arg - a unique parameter name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *makeParameterName(Node *n, Parm *p, int arg_num) {
|
||||
|
||||
// Use C parameter name unless it is a duplicate or an empty parameter name
|
||||
String *pn = Getattr(p, "name");
|
||||
int count = 0;
|
||||
ParmList *plist = Getattr(n, "parms");
|
||||
while (plist) {
|
||||
if ((Cmp(pn, Getattr(plist, "name")) == 0))
|
||||
count++;
|
||||
plist = nextSibling(plist);
|
||||
}
|
||||
String *arg = (!pn || (count > 1)) ? NewStringf("arg%d",
|
||||
arg_num) : Copy(Getattr(p,
|
||||
"name"));
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* attachParameterNames()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ static const char *usage = "\
|
|||
Ocaml Options (available with -ocaml)\n\
|
||||
-oldvarnames - Old intermediary method names for variable wrappers\n\
|
||||
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
|
||||
-suffix <name> - Change .cxx to something else\n\
|
||||
-suffix <name> - Deprecated alias for general option -cppext\n\
|
||||
-where - Emit library location\n\
|
||||
\n";
|
||||
|
||||
|
|
@ -114,6 +114,7 @@ public:
|
|||
}
|
||||
} else if (strcmp(argv[i], "-suffix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
Printf(stderr, "swig: warning: -suffix option deprecated. SWIG 3.0.4 and later provide a -cppext option which should be used instead.\n");
|
||||
SWIG_config_cppext(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
|
|
@ -1350,9 +1351,6 @@ public:
|
|||
|
||||
/*
|
||||
* Modified polymorphism code for Ocaml language module.
|
||||
* Original:
|
||||
* C++/Python polymorphism demo code, copyright (C) 2002 Mark Rose
|
||||
* <mrose@stm.lbl.gov>
|
||||
*
|
||||
* TODO
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,8 +19,10 @@ static String *op_prefix = 0;
|
|||
|
||||
static const char *usage = "\
|
||||
Octave Options (available with -octave)\n\
|
||||
-cppcast - Enable C++ casting operators (default)\n\
|
||||
-globals <name> - Set <name> used to access C global variables [default: 'cvar']\n\
|
||||
Use '.' to load C global variables into module namespace\n\
|
||||
-nocppcast - Disable C++ casting operators\n\
|
||||
-opprefix <str> - Prefix <str> for global operator functions [default: 'op_']\n\
|
||||
\n";
|
||||
|
||||
|
|
@ -90,6 +92,8 @@ public:
|
|||
}
|
||||
|
||||
virtual void main(int argc, char *argv[]) {
|
||||
int cppcast = 1;
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
|
|
@ -112,6 +116,12 @@ public:
|
|||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if (strcmp(argv[i], "-cppcast") == 0) {
|
||||
cppcast = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-nocppcast") == 0) {
|
||||
cppcast = 0;
|
||||
Swig_mark_arg(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -120,6 +130,8 @@ public:
|
|||
global_name = NewString("cvar");
|
||||
if (!op_prefix)
|
||||
op_prefix = NewString("op_");
|
||||
if(cppcast)
|
||||
Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
|
||||
|
||||
SWIG_library_directory("octave");
|
||||
Preprocessor_define("SWIGOCTAVE 1", 0);
|
||||
|
|
@ -952,7 +964,26 @@ 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);
|
||||
}
|
||||
}
|
||||
String *wrap_class = NewStringf("&_wrap_class_%s", class_name);
|
||||
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);
|
||||
|
||||
int use_director = Swig_directorclass(n);
|
||||
|
|
|
|||
|
|
@ -342,11 +342,18 @@ public:
|
|||
Node *options = Getattr(mod, "options");
|
||||
module = Copy(Getattr(n,"name"));
|
||||
|
||||
String *underscore_module = Copy(module);
|
||||
Replaceall(underscore_module,":","_");
|
||||
|
||||
if (verbose > 0) {
|
||||
fprintf(stdout, "top: using namespace_module: %s\n", Char(namespace_module));
|
||||
}
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Swig_banner(f_directors_h);
|
||||
Printf(f_directors_h, "\n");
|
||||
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module);
|
||||
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module);
|
||||
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", underscore_module);
|
||||
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", underscore_module);
|
||||
if (dirprot_mode()) {
|
||||
Printf(f_directors_h, "#include <map>\n");
|
||||
Printf(f_directors_h, "#include <string>\n\n");
|
||||
|
|
@ -379,13 +386,6 @@ public:
|
|||
fprintf(stdout, "top: No package found\n");
|
||||
}
|
||||
}
|
||||
String *underscore_module = Copy(module);
|
||||
Replaceall(underscore_module,":","_");
|
||||
|
||||
if (verbose > 0) {
|
||||
fprintf(stdout, "top: using namespace_module: %s\n", Char(namespace_module));
|
||||
}
|
||||
|
||||
/* If we're in blessed mode, change the package name to "packagec" */
|
||||
|
||||
if (blessed) {
|
||||
|
|
@ -2178,12 +2178,12 @@ public:
|
|||
SwigType_add_pointer(ptype);
|
||||
String *mangle = SwigType_manglestr(ptype);
|
||||
|
||||
Wrapper_add_local(w, "self", "SV *self");
|
||||
Printf(w->code, "self = SWIG_NewPointerObj(SWIG_as_voidptr(this), SWIGTYPE%s, SWIG_SHADOW);\n", mangle);
|
||||
Printf(w->code, "sv_bless(self, gv_stashpv(swig_get_class(), 0));\n");
|
||||
Wrapper_add_local(w, "swigself", "SV *swigself");
|
||||
Printf(w->code, "swigself = SWIG_NewPointerObj(SWIG_as_voidptr(this), SWIGTYPE%s, SWIG_SHADOW);\n", mangle);
|
||||
Printf(w->code, "sv_bless(swigself, gv_stashpv(swig_get_class(), 0));\n");
|
||||
Delete(mangle);
|
||||
Delete(ptype);
|
||||
Append(pstack, "XPUSHs(self);\n");
|
||||
Append(pstack, "XPUSHs(swigself);\n");
|
||||
}
|
||||
|
||||
Parm *p;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@
|
|||
|
||||
static const char *usage = "\
|
||||
PHP Options (available with -php)\n\
|
||||
-cppext <ext> - Change C++ file extension to <ext> (default is cpp)\n\
|
||||
-noproxy - Don't generate proxy classes.\n\
|
||||
-prefix <prefix> - Prepend <prefix> to all class names in PHP wrappers\n\
|
||||
\n";
|
||||
|
|
@ -221,15 +220,6 @@ public:
|
|||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if (strcmp(argv[i], "-cppext") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
SWIG_config_cppext(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if ((strcmp(argv[i], "-noshadow") == 0) || (strcmp(argv[i], "-noproxy") == 0)) {
|
||||
shadow = 0;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -836,13 +826,6 @@ public:
|
|||
Delete(args);
|
||||
args = NULL;
|
||||
}
|
||||
if (is_member_director(n)) {
|
||||
Wrapper_add_local(f, "director", "Swig::Director *director = 0");
|
||||
Printf(f->code, "director = dynamic_cast<Swig::Director*>(arg1);\n");
|
||||
Wrapper_add_local(f, "upcall", "bool upcall = false");
|
||||
Printf(f->code, "upcall = !director->swig_is_overridden_method((char *)\"%s%s\", (char *)\"%s\");\n",
|
||||
prefix, Swig_class_name(Swig_methodclass(n)), name);
|
||||
}
|
||||
|
||||
// This generated code may be called:
|
||||
// 1) as an object method, or
|
||||
|
|
@ -931,6 +914,12 @@ public:
|
|||
Delete(source);
|
||||
}
|
||||
|
||||
if (is_member_director(n)) {
|
||||
Wrapper_add_local(f, "upcall", "bool upcall = false");
|
||||
Printf(f->code, "upcall = !Swig::Director::swig_is_overridden_method((char *)\"%s%s\", (char *)\"%s\" TSRMLS_CC);\n",
|
||||
prefix, Swig_class_name(Swig_methodclass(n)), name);
|
||||
}
|
||||
|
||||
Swig_director_emit_dynamic_cast(n, f);
|
||||
|
||||
/* Insert constraint checking code */
|
||||
|
|
@ -1278,7 +1267,7 @@ public:
|
|||
break;
|
||||
char *p;
|
||||
errno = 0;
|
||||
int n = strtol(Char(value), &p, 0);
|
||||
long n = strtol(Char(value), &p, 0);
|
||||
Clear(value);
|
||||
if (errno || *p) {
|
||||
Append(value, "?");
|
||||
|
|
@ -1293,10 +1282,11 @@ public:
|
|||
case T_SCHAR:
|
||||
case T_SHORT:
|
||||
case T_INT:
|
||||
case T_LONG: {
|
||||
case T_LONG:
|
||||
case T_LONGLONG: {
|
||||
char *p;
|
||||
errno = 0;
|
||||
unsigned int n = strtol(Char(value), &p, 0);
|
||||
long n = strtol(Char(value), &p, 0);
|
||||
(void) n;
|
||||
if (errno || *p) {
|
||||
Clear(value);
|
||||
|
|
@ -1307,7 +1297,8 @@ public:
|
|||
case T_UCHAR:
|
||||
case T_USHORT:
|
||||
case T_UINT:
|
||||
case T_ULONG: {
|
||||
case T_ULONG:
|
||||
case T_ULONGLONG: {
|
||||
char *p;
|
||||
errno = 0;
|
||||
unsigned int n = strtoul(Char(value), &p, 0);
|
||||
|
|
@ -1319,7 +1310,8 @@ public:
|
|||
break;
|
||||
}
|
||||
case T_FLOAT:
|
||||
case T_DOUBLE:{
|
||||
case T_DOUBLE:
|
||||
case T_LONGDOUBLE: {
|
||||
char *p;
|
||||
errno = 0;
|
||||
/* FIXME: strtod is locale dependent... */
|
||||
|
|
@ -1338,13 +1330,6 @@ public:
|
|||
}
|
||||
break;
|
||||
}
|
||||
case T_REFERENCE:
|
||||
case T_RVALUE_REFERENCE:
|
||||
case T_USER:
|
||||
case T_ARRAY:
|
||||
Clear(value);
|
||||
Append(value, "?");
|
||||
break;
|
||||
case T_STRING:
|
||||
if (Len(value) < 2) {
|
||||
// How can a string (including "" be less than 2 characters?)
|
||||
|
|
@ -1393,6 +1378,11 @@ public:
|
|||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* Safe default */
|
||||
Clear(value);
|
||||
Append(value, "?");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!arg_values[argno]) {
|
||||
|
|
@ -1741,7 +1731,8 @@ public:
|
|||
}
|
||||
} else {
|
||||
Printf(output, "\t\tif (!is_resource($r)) return $r;\n");
|
||||
Printf(output, "\t\tswitch (get_resource_type($r)) {\n");
|
||||
String *wrapobj = NULL;
|
||||
String *common = NULL;
|
||||
Iterator i = First(ret_types);
|
||||
while (i.item) {
|
||||
SwigType *ret_type = i.item;
|
||||
|
|
@ -1761,22 +1752,43 @@ public:
|
|||
continue;
|
||||
}
|
||||
}
|
||||
Printf(output, "\t\t");
|
||||
if (i.item) {
|
||||
Printf(output, "case '%s': ", mangled);
|
||||
} else {
|
||||
Printf(output, "default: ");
|
||||
}
|
||||
const char *classname = GetChar(class_node, "sym:name");
|
||||
if (!classname)
|
||||
classname = GetChar(class_node, "name");
|
||||
String * action = NewStringEmpty();
|
||||
if (classname)
|
||||
Printf(output, "return new %s%s($r);\n", prefix, classname);
|
||||
Printf(action, "return new %s%s($r);\n", prefix, classname);
|
||||
else
|
||||
Printf(output, "return $r;\n");
|
||||
Printf(action, "return $r;\n");
|
||||
if (!wrapobj) {
|
||||
wrapobj = NewString("\t\tswitch (get_resource_type($r)) {\n");
|
||||
common = action;
|
||||
} else {
|
||||
if (common && Cmp(common, action) != 0) {
|
||||
Delete(common);
|
||||
common = NULL;
|
||||
}
|
||||
}
|
||||
Printf(wrapobj, "\t\t");
|
||||
if (i.item) {
|
||||
Printf(wrapobj, "case '%s': ", mangled);
|
||||
} else {
|
||||
Printf(wrapobj, "default: ");
|
||||
}
|
||||
Printv(wrapobj, action, NIL);
|
||||
if (action != common) Delete(action);
|
||||
Delete(mangled);
|
||||
}
|
||||
Printf(output, "\t\t}\n");
|
||||
Printf(wrapobj, "\t\t}\n");
|
||||
if (common) {
|
||||
// All cases have the same action, so eliminate the switch
|
||||
// wrapper.
|
||||
Printf(output, "\t\t%s", common);
|
||||
Delete(common);
|
||||
} else {
|
||||
Printv(output, wrapobj, NIL);
|
||||
}
|
||||
Delete(wrapobj);
|
||||
}
|
||||
} else {
|
||||
if (non_void_return) {
|
||||
|
|
@ -2045,6 +2057,17 @@ done:
|
|||
} else if (GetFlag(n, "feature:exceptionclass")) {
|
||||
Append(s_phpclasses, "extends Exception ");
|
||||
}
|
||||
{
|
||||
Node *node = NewHash();
|
||||
Setattr(node, "type", Getattr(n, "name"));
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
String * interfaces = Swig_typemap_lookup("phpinterfaces", node, "", 0);
|
||||
if (interfaces) {
|
||||
Printf(s_phpclasses, "implements %s ", interfaces);
|
||||
}
|
||||
Delete(node);
|
||||
}
|
||||
Printf(s_phpclasses, "{\n\tpublic $%s=null;\n", SWIG_PTR);
|
||||
if (!baseclass) {
|
||||
// Only store this in the base class (NB !baseclass means we *are*
|
||||
|
|
@ -2622,12 +2645,12 @@ done:
|
|||
Printf(w->code, "zval *args[%d];\n", idx);
|
||||
}
|
||||
Printf(w->code, "zval *%s, funcname;\n", Swig_cresult_name());
|
||||
Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name());
|
||||
const char * funcname = GetChar(n, "sym:name");
|
||||
Printf(w->code, "ZVAL_STRINGL(&funcname, (char *)\"%s\", %d, 0);\n", funcname, strlen(funcname));
|
||||
Append(w->code, "if (!swig_self) {\n");
|
||||
Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");");
|
||||
Append(w->code, "}\n\n");
|
||||
Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name());
|
||||
const char * funcname = GetChar(n, "sym:name");
|
||||
Printf(w->code, "ZVAL_STRINGL(&funcname, (char *)\"%s\", %d, 0);\n", funcname, strlen(funcname));
|
||||
|
||||
/* wrap complex arguments to zvals */
|
||||
Printv(w->code, wrap_args, NIL);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
static int treduce = SWIG_cparse_template_reduce(0);
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define PYSHADOW_MEMBER 0x2
|
||||
#define WARN_PYTHON_MULTIPLE_INH 405
|
||||
|
|
@ -807,7 +809,7 @@ public:
|
|||
Printv(f_shadow, "\nfrom sys import version_info\n", NULL);
|
||||
|
||||
if (!builtin && fastproxy) {
|
||||
Printv(f_shadow, "if version_info >= (3,0,0):\n", NULL);
|
||||
Printv(f_shadow, "if version_info >= (3, 0, 0):\n", NULL);
|
||||
Printf(f_shadow, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module);
|
||||
Printv(f_shadow, "else:\n", NULL);
|
||||
Printv(f_shadow, tab4, "from new import instancemethod as new_instancemethod\n", NULL);
|
||||
|
|
@ -822,7 +824,7 @@ public:
|
|||
* isn't available in python 2.4 or earlier, so we have to write some
|
||||
* code conditional on the python version.
|
||||
*/
|
||||
Printv(f_shadow, "if version_info >= (2,6,0):\n", NULL);
|
||||
Printv(f_shadow, "if version_info >= (2, 6, 0):\n", NULL);
|
||||
Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL);
|
||||
Printv(f_shadow, tab8, "from os.path import dirname\n", NULL);
|
||||
Printv(f_shadow, tab8, "import imp\n", NULL);
|
||||
|
|
@ -852,40 +854,45 @@ public:
|
|||
Printf(f_shadow, "from %s import *\n", module);
|
||||
}
|
||||
if (modern || !classic) {
|
||||
Printv(f_shadow, "try:\n", tab4, "_swig_property = property\n", "except NameError:\n", tab4, "pass # Python < 2.2 doesn't have 'property'.\n", NULL);
|
||||
Printv(f_shadow, "try:\n", tab4, "_swig_property = property\n", "except NameError:\n", tab4, "pass # Python < 2.2 doesn't have 'property'.\n\n", NULL);
|
||||
}
|
||||
/* if (!modern) */
|
||||
/* always needed, a class can be forced to be no-modern, such as an exception */
|
||||
{
|
||||
// Python-2.2 object hack
|
||||
Printv(f_shadow,
|
||||
"def _swig_setattr_nondynamic(self,class_type,name,value,static=1):\n",
|
||||
tab4, "if (name == \"thisown\"): return self.this.own(value)\n",
|
||||
tab4, "if (name == \"this\"):\n", tab4, tab4, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n",
|
||||
"\n", "def _swig_setattr_nondynamic(self, class_type, name, value, static=1):\n",
|
||||
tab4, "if (name == \"thisown\"):\n", tab8, "return self.this.own(value)\n",
|
||||
tab4, "if (name == \"this\"):\n", tab8, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n",
|
||||
#ifdef USE_THISOWN
|
||||
tab4, tab8, "if hasattr(value,\"thisown\"): self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n",
|
||||
tab4, tab8, "if hasattr(value,\"thisown\"):\n", tab8, tab8, "self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n",
|
||||
#endif
|
||||
tab4, tab8, "return\n", tab4, "method = class_type.__swig_setmethods__.get(name,None)\n", tab4, "if method: return method(self,value)\n",
|
||||
tab4, tab8, "return\n", tab4, "method = class_type.__swig_setmethods__.get(name, None)\n", tab4, "if method:\n", tab4, tab4, "return method(self, value)\n",
|
||||
#ifdef USE_THISOWN
|
||||
tab4, "if (not static) or (name == \"thisown\"):\n",
|
||||
#else
|
||||
tab4, "if (not static):\n",
|
||||
#endif
|
||||
tab4, tab4, "self.__dict__[name] = value\n",
|
||||
tab4, tab4, "object.__setattr__(self, name, value)\n",
|
||||
tab4, "else:\n",
|
||||
tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n\n",
|
||||
"def _swig_setattr(self,class_type,name,value):\n", tab4, "return _swig_setattr_nondynamic(self,class_type,name,value,0)\n\n", NIL);
|
||||
"\n", "def _swig_setattr(self, class_type, name, value):\n", tab4, "return _swig_setattr_nondynamic(self, class_type, name, value, 0)\n\n", NIL);
|
||||
|
||||
Printv(f_shadow,
|
||||
"def _swig_getattr(self,class_type,name):\n",
|
||||
tab4, "if (name == \"thisown\"): return self.this.own()\n",
|
||||
tab4, "method = class_type.__swig_getmethods__.get(name,None)\n",
|
||||
tab4, "if method: return method(self)\n", tab4, "raise AttributeError(name)\n\n", NIL);
|
||||
"\n", "def _swig_getattr_nondynamic(self, class_type, name, static=1):\n",
|
||||
tab4, "if (name == \"thisown\"):\n", tab8, "return self.this.own()\n",
|
||||
tab4, "method = class_type.__swig_getmethods__.get(name, None)\n",
|
||||
tab4, "if method:\n", tab8, "return method(self)\n",
|
||||
tab4, "if (not static):\n",
|
||||
tab4, tab4, "return object.__getattr__(self, name)\n",
|
||||
tab4, "else:\n",
|
||||
tab4, tab4, "raise AttributeError(name)\n\n",
|
||||
"def _swig_getattr(self, class_type, name):\n", tab4, "return _swig_getattr_nondynamic(self, class_type, name, 0)\n\n", NIL);
|
||||
|
||||
Printv(f_shadow,
|
||||
"def _swig_repr(self):\n",
|
||||
tab4, "try: strthis = \"proxy of \" + self.this.__repr__()\n",
|
||||
tab4, "except: strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
|
||||
"\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);
|
||||
|
||||
if (!classic) {
|
||||
/* Usage of types.ObjectType is deprecated.
|
||||
|
|
@ -895,19 +902,19 @@ public:
|
|||
// "import types\n",
|
||||
"try:\n",
|
||||
// " _object = types.ObjectType\n",
|
||||
" _object = object\n", " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n",
|
||||
tab4, "_object = object\n", tab4, "_newclass = 1\n", "except AttributeError:\n", tab4, "class _object:\n", tab8, "pass\n", tab4, "_newclass = 0\n",
|
||||
// "del types\n",
|
||||
"\n\n", NIL);
|
||||
}
|
||||
}
|
||||
if (modern) {
|
||||
Printv(f_shadow, "def _swig_setattr_nondynamic_method(set):\n", tab4, "def set_attr(self,name,value):\n",
|
||||
Printv(f_shadow, "\n", "def _swig_setattr_nondynamic_method(set):\n", tab4, "def set_attr(self, name, value):\n",
|
||||
#ifdef USE_THISOWN
|
||||
tab4, tab4, "if hasattr(self,name) or (name in (\"this\", \"thisown\")):\n",
|
||||
tab4, tab4, "if hasattr(self, name) or (name in (\"this\", \"thisown\")):\n",
|
||||
#else
|
||||
tab4, tab4, "if (name == \"thisown\"): return self.this.own(value)\n", tab4, tab4, "if hasattr(self,name) or (name == \"this\"):\n",
|
||||
tab4, tab4, "if (name == \"thisown\"):\n", tab8, tab4, "return self.this.own(value)\n", tab4, tab4, "if hasattr(self, name) or (name == \"this\"):\n",
|
||||
#endif
|
||||
tab4, tab4, tab4, "set(self,name,value)\n",
|
||||
tab4, tab4, tab4, "set(self, name, value)\n",
|
||||
tab4, tab4, "else:\n",
|
||||
tab4, tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n", tab4, "return set_attr\n\n\n", NIL);
|
||||
}
|
||||
|
|
@ -1523,6 +1530,21 @@ public:
|
|||
return ds;
|
||||
}
|
||||
|
||||
virtual String *makeParameterName(Node *n, Parm *p, int arg_num, bool = false) const {
|
||||
// For the keyword arguments, we want to preserve the names as much as possible,
|
||||
// so we only minimally rename them in Swig_name_make(), e.g. replacing "keyword"
|
||||
// with "_keyword" if they have any name at all.
|
||||
if (check_kwargs(n)) {
|
||||
String *name = Getattr(p, "name");
|
||||
if (name)
|
||||
return Swig_name_make(p, 0, name, 0, 0);
|
||||
}
|
||||
|
||||
// For the other cases use the general function which replaces arguments whose
|
||||
// names clash with keywords with (less useful) "argN".
|
||||
return Language::makeParameterName(n, p, arg_num);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* addMissingParameterNames()
|
||||
* For functions that have not had nameless parameters set in the Language class.
|
||||
|
|
@ -1534,13 +1556,14 @@ public:
|
|||
* The "lname" attribute in each parameter in plist will be contain a parameter name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void addMissingParameterNames(ParmList *plist, int arg_offset) {
|
||||
void addMissingParameterNames(Node *n, ParmList *plist, int arg_offset) {
|
||||
Parm *p = plist;
|
||||
int i = arg_offset;
|
||||
while (p) {
|
||||
if (!Getattr(p, "lname")) {
|
||||
String *pname = Swig_cparm_name(p, i);
|
||||
Delete(pname);
|
||||
String *name = makeParameterName(n, p, i);
|
||||
Setattr(p, "lname", name);
|
||||
Delete(name);
|
||||
}
|
||||
i++;
|
||||
p = nextSibling(p);
|
||||
|
|
@ -1563,14 +1586,18 @@ public:
|
|||
Parm *pnext;
|
||||
|
||||
|
||||
int lines = 0;
|
||||
int start_arg_num = is_wrapping_class() ? 1 : 0;
|
||||
const int maxwidth = 80;
|
||||
// Normally we start counting auto-generated argument names from 1, but we should do it from 2
|
||||
// if the first argument is "self", i.e. if we're handling a non-static member function.
|
||||
int arg_num = 1;
|
||||
if (is_wrapping_class()) {
|
||||
if (Cmp(Getattr(n, "storage"), "static") != 0)
|
||||
arg_num++;
|
||||
}
|
||||
|
||||
if (calling)
|
||||
func_annotation = false;
|
||||
|
||||
addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms
|
||||
addMissingParameterNames(n, plist, arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms
|
||||
Swig_typemap_attach_parms("in", plist, 0);
|
||||
Swig_typemap_attach_parms("doc", plist, 0);
|
||||
|
||||
|
|
@ -1579,7 +1606,7 @@ public:
|
|||
return doc;
|
||||
}
|
||||
|
||||
for (p = plist; p; p = pnext) {
|
||||
for (p = plist; p; p = pnext, arg_num++) {
|
||||
|
||||
String *tm = Getattr(p, "tmap:in");
|
||||
if (tm) {
|
||||
|
|
@ -1602,25 +1629,22 @@ public:
|
|||
}
|
||||
|
||||
// Note: the generated name should be consistent with that in kwnames[]
|
||||
name = name ? name : Getattr(p, "name");
|
||||
name = name ? name : Getattr(p, "lname");
|
||||
name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword
|
||||
String *made_name = 0;
|
||||
if (!name) {
|
||||
name = made_name = makeParameterName(n, p, arg_num);
|
||||
}
|
||||
|
||||
type = type ? type : Getattr(p, "type");
|
||||
value = value ? value : Getattr(p, "value");
|
||||
|
||||
if (SwigType_isvarargs(type))
|
||||
if (SwigType_isvarargs(type)) {
|
||||
Delete(made_name);
|
||||
break;
|
||||
}
|
||||
|
||||
if (Len(doc)) {
|
||||
// add a comma to the previous one if any
|
||||
Append(doc, ", ");
|
||||
|
||||
// Do we need to wrap a long line?
|
||||
if ((Len(doc) - lines * maxwidth) > maxwidth) {
|
||||
Printf(doc, "\n%s", tab4);
|
||||
lines += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Do the param type too?
|
||||
|
|
@ -1637,22 +1661,16 @@ public:
|
|||
}
|
||||
// Write the function annotation
|
||||
if (func_annotation)
|
||||
Printf(doc, " : '%s'", type_str);
|
||||
Printf(doc, ": '%s'", type_str);
|
||||
|
||||
// Write default value
|
||||
if (value && !calling) {
|
||||
String *new_value = convertValue(value, Getattr(p, "type"));
|
||||
if (new_value) {
|
||||
value = new_value;
|
||||
} else {
|
||||
Node *lookup = Swig_symbol_clookup(value, 0);
|
||||
if (lookup)
|
||||
value = Getattr(lookup, "sym:name");
|
||||
}
|
||||
Printf(doc, "=%s", value);
|
||||
if (new_value)
|
||||
Printf(doc, "=%s", new_value);
|
||||
}
|
||||
Delete(type_str);
|
||||
Delete(name);
|
||||
Delete(made_name);
|
||||
}
|
||||
if (pdocs)
|
||||
Setattr(n, "feature:pdocs", pdocs);
|
||||
|
|
@ -1798,58 +1816,192 @@ public:
|
|||
return doc;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* 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);
|
||||
char *end;
|
||||
|
||||
double value = strtod(s, &end);
|
||||
(void) value;
|
||||
if (errno != ERANGE && end != s) {
|
||||
// An added complication: at least some versions of strtod() recognize
|
||||
// hexadecimal floating point numbers which don't exist in Python, so
|
||||
// detect them ourselves and refuse to convert them (this can't be done
|
||||
// without loss of precision in general).
|
||||
//
|
||||
// Also don't accept neither "NAN" nor "INFINITY" (both of which
|
||||
// conveniently contain "n").
|
||||
if (strpbrk(s, "xXnN"))
|
||||
return NIL;
|
||||
|
||||
// Disregard optional "f" suffix, it can be just dropped in Python as it
|
||||
// uses doubles for everything anyhow.
|
||||
for (char* p = end; *p != '\0'; ++p) {
|
||||
switch (*p) {
|
||||
case 'f':
|
||||
case 'F':
|
||||
break;
|
||||
|
||||
default:
|
||||
return NIL;
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid unnecessary string allocation in the common case when we don't
|
||||
// need to remove any suffix.
|
||||
return *end == '\0' ? v : NewStringWithSize(s, end - s);
|
||||
}
|
||||
|
||||
return NIL;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* convertValue()
|
||||
* Check if string v can be a Python value literal,
|
||||
* (eg. number or string), or translate it to a Python literal.
|
||||
* Check if string v can be a Python value literal or a
|
||||
* constant. Return NIL if it isn't.
|
||||
* ------------------------------------------------------------ */
|
||||
String *convertValue(String *v, SwigType *t) {
|
||||
if (v && Len(v) > 0) {
|
||||
char fc = (Char(v))[0];
|
||||
if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) {
|
||||
/* number or string (or maybe NULL pointer) */
|
||||
if (SwigType_ispointer(t) && Strcmp(v, "0") == 0)
|
||||
return NewString("None");
|
||||
else
|
||||
return v;
|
||||
const char *const s = Char(v);
|
||||
char *end;
|
||||
|
||||
// Check if this is a number in any base.
|
||||
long value = strtol(s, &end, 0);
|
||||
(void) value;
|
||||
if (end != s) {
|
||||
if (errno == ERANGE) {
|
||||
// There was an overflow, we could try representing the value as Python
|
||||
// long integer literal, but for now don't bother with it.
|
||||
return NIL;
|
||||
}
|
||||
if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
|
||||
return NewString("True");
|
||||
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("False");
|
||||
if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
|
||||
return SwigType_ispointer(t) ? NewString("None") : NewString("0");
|
||||
|
||||
if (*end != '\0') {
|
||||
// If there is a suffix after the number, we can safely ignore any
|
||||
// combination of "l" and "u", but not anything else (again, stuff like
|
||||
// "LL" could be handled, but we don't bother to do it currently).
|
||||
bool seen_long = false;
|
||||
for (char* p = end; *p != '\0'; ++p) {
|
||||
switch (*p) {
|
||||
case 'l':
|
||||
case 'L':
|
||||
// Bail out on "LL".
|
||||
if (seen_long)
|
||||
return NIL;
|
||||
seen_long = true;
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
case 'U':
|
||||
break;
|
||||
|
||||
default:
|
||||
// Except that our suffix could actually be the fractional part of
|
||||
// a floating point number, so we still have to check for this.
|
||||
return convertDoubleValue(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Deal with the values starting with 0 first as they can be octal or
|
||||
// hexadecimal numbers or even pointers.
|
||||
if (s[0] == '0') {
|
||||
if (Len(v) == 1) {
|
||||
// This is just a lone 0, but it needs to be represented differently
|
||||
// in Python depending on whether it's a zero or a null pointer.
|
||||
if (SwigType_ispointer(t))
|
||||
return NewString("None");
|
||||
else
|
||||
return v;
|
||||
} else if (s[1] == 'x' || s[1] == 'X') {
|
||||
// This must have been a hex number, we can use it directly in Python,
|
||||
// so nothing to do here.
|
||||
} else {
|
||||
// This must have been an octal number, we have to change its prefix
|
||||
// to be "0o" in Python 3 only (and as long as we still support Python
|
||||
// 2.5, this can't be done unconditionally).
|
||||
if (py3) {
|
||||
if (end - s > 1) {
|
||||
String *res = NewString("0o");
|
||||
Append(res, NewStringWithSize(s + 1, end - s - 1));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid unnecessary string allocation in the common case when we don't
|
||||
// need to remove any suffix.
|
||||
return *end == '\0' ? v : NewStringWithSize(s, end - s);
|
||||
}
|
||||
return 0;
|
||||
|
||||
// Check if this is a floating point number (notice that it wasn't
|
||||
// necessarily parsed as a long above, consider e.g. ".123").
|
||||
if (String *res = convertDoubleValue(v)) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
|
||||
return NewString("True");
|
||||
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("False");
|
||||
if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
|
||||
return SwigType_ispointer(t) ? NewString("None") : NewString("0");
|
||||
|
||||
// This could also be an enum type, default value of which could be
|
||||
// representable in Python if it doesn't include any scope (which could,
|
||||
// but currently is not, translated).
|
||||
if (!Strchr(s, ':')) {
|
||||
Node *lookup = Swig_symbol_clookup(v, 0);
|
||||
if (lookup) {
|
||||
if (Cmp(Getattr(lookup, "nodeType"), "enumitem") == 0)
|
||||
return Getattr(lookup, "sym:name");
|
||||
}
|
||||
}
|
||||
|
||||
return NIL;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* is_primitive_defaultargs()
|
||||
* Check if all the default args have primitive type.
|
||||
* (So we can generate proper parameter list with default
|
||||
* values..)
|
||||
* 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.
|
||||
* ------------------------------------------------------------ */
|
||||
bool is_primitive_defaultargs(Node *n) {
|
||||
bool is_representable_as_pyargs(Node *n) {
|
||||
bool is_representable = true;
|
||||
|
||||
ParmList *plist = CopyParmList(Getattr(n, "parms"));
|
||||
Parm *p;
|
||||
Parm *pnext;
|
||||
|
||||
Swig_typemap_attach_parms("in", plist, 0);
|
||||
for (p = plist; p; p = pnext) {
|
||||
pnext = NIL;
|
||||
String *tm = Getattr(p, "tmap:in");
|
||||
if (tm) {
|
||||
pnext = Getattr(p, "tmap:in:next");
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if (!pnext) {
|
||||
pnext = nextSibling(p);
|
||||
}
|
||||
String *type = Getattr(p, "type");
|
||||
String *value = Getattr(p, "value");
|
||||
if (!convertValue(value, type))
|
||||
return false;
|
||||
if (String *value = Getattr(p, "value")) {
|
||||
String *type = Getattr(p, "type");
|
||||
if (!convertValue(value, type)) {
|
||||
is_representable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
return is_representable;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1892,7 +2044,7 @@ public:
|
|||
n = nn;
|
||||
|
||||
/* For overloaded function, just use *args */
|
||||
if (is_real_overloaded(n) || GetFlag(n, "feature:compactdefaultargs") || !is_primitive_defaultargs(n)) {
|
||||
if (is_real_overloaded(n) || GetFlag(n, "feature:compactdefaultargs") || !is_representable_as_pyargs(n)) {
|
||||
String *parms = NewString("");
|
||||
if (in_class)
|
||||
Printf(parms, "self, ");
|
||||
|
|
@ -2012,7 +2164,7 @@ public:
|
|||
if (ret)
|
||||
ret = SwigType_str(ret, 0);
|
||||
}
|
||||
return (ret && py3) ? NewStringf(" -> \"%s\" ", ret)
|
||||
return (ret && py3) ? NewStringf(" -> \"%s\"", ret)
|
||||
: NewString("");
|
||||
}
|
||||
|
||||
|
|
@ -2029,15 +2181,15 @@ public:
|
|||
/* Make a wrapper function to insert the code into */
|
||||
Printv(f_dest, "\ndef ", name, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
|
||||
if (have_docstring(n))
|
||||
Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL);
|
||||
Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL);
|
||||
if (have_pythonprepend(n))
|
||||
Printv(f_dest, pythoncode(pythonprepend(n), " "), "\n", NIL);
|
||||
Printv(f_dest, pythoncode(pythonprepend(n), tab4), "\n", NIL);
|
||||
if (have_pythonappend(n)) {
|
||||
Printv(f_dest, " val = ", funcCall(name, callParms), "\n", NIL);
|
||||
Printv(f_dest, pythoncode(pythonappend(n), " "), "\n", NIL);
|
||||
Printv(f_dest, " return val\n", NIL);
|
||||
Printv(f_dest, tab4 "val = ", funcCall(name, callParms), "\n", NIL);
|
||||
Printv(f_dest, pythoncode(pythonappend(n), tab4), "\n", NIL);
|
||||
Printv(f_dest, tab4 "return val\n", NIL);
|
||||
} else {
|
||||
Printv(f_dest, " return ", funcCall(name, callParms), "\n", NIL);
|
||||
Printv(f_dest, tab4 "return ", funcCall(name, callParms), "\n", NIL);
|
||||
}
|
||||
|
||||
if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) {
|
||||
|
|
@ -2052,7 +2204,7 @@ public:
|
|||
* check if using kwargs is allowed for this Node
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
int check_kwargs(Node *n) {
|
||||
int check_kwargs(Node *n) const {
|
||||
return (use_kw || GetFlag(n, "feature:kwargs"))
|
||||
&& !GetFlag(n, "memberset") && !GetFlag(n, "memberget");
|
||||
}
|
||||
|
|
@ -2154,7 +2306,7 @@ public:
|
|||
Append(f->code, "--argc;\n");
|
||||
}
|
||||
|
||||
Replaceall(dispatch, "$args", "self,args");
|
||||
Replaceall(dispatch, "$args", "self, args");
|
||||
|
||||
Printv(f->code, dispatch, "\n", NIL);
|
||||
|
||||
|
|
@ -2431,7 +2583,6 @@ public:
|
|||
}
|
||||
|
||||
SwigType *pt = Getattr(p, "type");
|
||||
String *pn = Getattr(p, "name");
|
||||
String *ln = Getattr(p, "lname");
|
||||
bool parse_from_tuple = (i > 0 || !add_self);
|
||||
if (SwigType_type(pt) == T_VARARGS) {
|
||||
|
|
@ -2453,18 +2604,9 @@ public:
|
|||
|
||||
/* Keyword argument handling */
|
||||
if (allow_kwargs && parse_from_tuple) {
|
||||
if (Len(pn)) {
|
||||
String *tmp = 0;
|
||||
String *name = pn;
|
||||
if (!Getattr(p, "hidden")) {
|
||||
name = tmp = Swig_name_make(p, 0, pn, 0, 0); // rename parameter if a keyword
|
||||
}
|
||||
Printf(kwargs, "(char *) \"%s\",", name);
|
||||
if (tmp)
|
||||
Delete(tmp);
|
||||
} else {
|
||||
Printf(kwargs, "(char *)\"arg%d\",", i + 1);
|
||||
}
|
||||
String *name = makeParameterName(n, p, i + 1);
|
||||
Printf(kwargs, "(char *) \"%s\",", name);
|
||||
Delete(name);
|
||||
}
|
||||
|
||||
/* Look for an input typemap */
|
||||
|
|
@ -2595,7 +2737,6 @@ public:
|
|||
|
||||
/* Insert cleanup code */
|
||||
for (p = l; p;) {
|
||||
// if (!checkAttribute(p,"tmap:in:numinputs","0") && !Getattr(p,"tmap:in:parse")) {
|
||||
if (!Getattr(p, "tmap:in:parse") && (tm = Getattr(p, "tmap:freearg"))) {
|
||||
if (Getattr(p, "tmap:freearg:implicitconv")) {
|
||||
const char *convflag = "0";
|
||||
|
|
@ -3153,7 +3294,32 @@ public:
|
|||
Replaceall(tm, "$source", value);
|
||||
Replaceall(tm, "$target", name);
|
||||
Replaceall(tm, "$value", value);
|
||||
Printf(f_init, "%s\n", tm);
|
||||
if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER)) && (!in_class || !Getattr(n, "feature:python:callback"))) {
|
||||
// Generate method which registers the new constant
|
||||
Printf(f_wrappers, "SWIGINTERN PyObject *%s_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", iname);
|
||||
Printf(f_wrappers, tab2 "PyObject *module;\n", tm);
|
||||
if (modernargs) {
|
||||
if (fastunpack) {
|
||||
Printf(f_wrappers, tab2 "if (!SWIG_Python_UnpackTuple(args,(char*)\"swigconstant\", 1, 1,&module)) return NULL;\n");
|
||||
} else {
|
||||
Printf(f_wrappers, tab2 "if (!PyArg_UnpackTuple(args,(char*)\"swigconstant\", 1, 1,&module)) return NULL;\n");
|
||||
}
|
||||
} else {
|
||||
Printf(f_wrappers, tab2 "if (!PyArg_ParseTuple(args,(char*)\"O:swigconstant\", &module)) return NULL;\n");
|
||||
}
|
||||
Printf(f_wrappers, tab2 "PyObject *d = PyModule_GetDict(module);\n");
|
||||
Printf(f_wrappers, tab2 "if (!d) return NULL;\n");
|
||||
Printf(f_wrappers, tab2 "%s\n", tm);
|
||||
Printf(f_wrappers, tab2 "return SWIG_Py_Void();\n");
|
||||
Printf(f_wrappers, "}\n\n\n");
|
||||
|
||||
// Register the method in SwigMethods array
|
||||
String *cname = NewStringf("%s_swigconstant", iname);
|
||||
add_method(cname, cname, 0);
|
||||
Delete(cname);
|
||||
} else {
|
||||
Printf(f_init, "%s\n", tm);
|
||||
}
|
||||
Delete(tm);
|
||||
have_tm = 1;
|
||||
}
|
||||
|
|
@ -3168,9 +3334,13 @@ public:
|
|||
|
||||
if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
||||
if (!in_class) {
|
||||
Printv(f_shadow, "\n",NIL);
|
||||
Printv(f_shadow, module, ".", iname, "_swigconstant(",module,")\n", NIL);
|
||||
Printv(f_shadow, iname, " = ", module, ".", iname, "\n", NIL);
|
||||
} else {
|
||||
if (!(Getattr(n, "feature:python:callback"))) {
|
||||
Printv(f_shadow_stubs, "\n",NIL);
|
||||
Printv(f_shadow_stubs, module, ".", iname, "_swigconstant(", module, ")\n", NIL);
|
||||
Printv(f_shadow_stubs, iname, " = ", module, ".", iname, "\n", NIL);
|
||||
}
|
||||
}
|
||||
|
|
@ -3203,7 +3373,7 @@ public:
|
|||
* BEGIN C++ Director Class modifications
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/* C++/Python polymorphism demo code, copyright (C) 2002 Mark Rose <mrose@stm.lbl.gov>
|
||||
/* C++/Python polymorphism demo code
|
||||
*
|
||||
* TODO
|
||||
*
|
||||
|
|
@ -3901,7 +4071,7 @@ public:
|
|||
Printv(base_class, bname, NIL);
|
||||
b = Next(b);
|
||||
if (b.item) {
|
||||
Putc(',', base_class);
|
||||
Printv(base_class, ", ", NIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3922,7 +4092,7 @@ public:
|
|||
String *abcs = Getattr(n, "feature:python:abc");
|
||||
if (py3 && abcs) {
|
||||
if (Len(base_class)) {
|
||||
Putc(',', base_class);
|
||||
Printv(base_class, ", ", NIL);
|
||||
}
|
||||
Printv(base_class, abcs, NIL);
|
||||
}
|
||||
|
|
@ -3957,7 +4127,7 @@ public:
|
|||
if (!modern) {
|
||||
Printv(f_shadow, tab4, "__swig_setmethods__ = {}\n", NIL);
|
||||
if (Len(base_class)) {
|
||||
Printf(f_shadow, "%sfor _s in [%s]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))\n", tab4, base_class);
|
||||
Printv(f_shadow, tab4, "for _s in [", base_class, "]:\n", tab8, "__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))\n", NIL);
|
||||
}
|
||||
|
||||
if (!GetFlag(n, "feature:python:nondynamic")) {
|
||||
|
|
@ -3968,7 +4138,7 @@ public:
|
|||
|
||||
Printv(f_shadow, tab4, "__swig_getmethods__ = {}\n", NIL);
|
||||
if (Len(base_class)) {
|
||||
Printf(f_shadow, "%sfor _s in [%s]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))\n", tab4, base_class);
|
||||
Printv(f_shadow, tab4, "for _s in [", base_class, "]:\n", tab8, "__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))\n", NIL);
|
||||
}
|
||||
|
||||
Printv(f_shadow, tab4, "__getattr__ = lambda self, name: _swig_getattr(self, ", class_name, ", name)\n", NIL);
|
||||
|
|
@ -4056,7 +4226,7 @@ public:
|
|||
Delete(realct);
|
||||
if (!have_constructor) {
|
||||
if (!builtin)
|
||||
Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"", "No constructor defined",
|
||||
Printv(f_shadow_file, "\n", tab4, "def __init__(self, *args, **kwargs):\n", tab8, "raise AttributeError(\"", "No constructor defined",
|
||||
(Getattr(n, "abstracts") ? " - class is abstract" : ""), "\")\n", NIL);
|
||||
} else if (fastinit && !builtin) {
|
||||
|
||||
|
|
@ -4094,12 +4264,12 @@ public:
|
|||
Printv(f_shadow_file, "\nclass ", class_name, "Ptr(", class_name, "):\n", tab4, "def __init__(self, this):\n", NIL);
|
||||
if (!modern) {
|
||||
Printv(f_shadow_file,
|
||||
tab8, "try: self.this.append(this)\n",
|
||||
tab8, "except: self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL);
|
||||
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);
|
||||
} else {
|
||||
Printv(f_shadow_file,
|
||||
tab8, "try: self.this.append(this)\n",
|
||||
tab8, "except: self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4108,7 +4278,7 @@ public:
|
|||
List *shadow_list = Getattr(n, "shadow_methods");
|
||||
for (int i = 0; i < Len(shadow_list); ++i) {
|
||||
String *symname = Getitem(shadow_list, i);
|
||||
Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s,None,%s)\n", class_name, symname, module, Swig_name_member(NSPACE_TODO, class_name, symname),
|
||||
Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s, None, %s)\n", class_name, symname, module, Swig_name_member(NSPACE_TODO, class_name, symname),
|
||||
class_name);
|
||||
}
|
||||
}
|
||||
|
|
@ -4223,12 +4393,11 @@ public:
|
|||
String *callParms = make_pyParmList(n, true, true, allow_kwargs);
|
||||
if (!have_addtofunc(n)) {
|
||||
if (!fastproxy || olddefs) {
|
||||
Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL);
|
||||
Printv(f_shadow, " return ", funcCall(fullname, callParms), "\n", NIL);
|
||||
Printv(f_shadow, "\n", tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
|
||||
Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n", NIL);
|
||||
}
|
||||
} else {
|
||||
Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL);
|
||||
Printv(f_shadow, "\n", NIL);
|
||||
Printv(f_shadow, "\n", tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
|
||||
if (have_docstring(n))
|
||||
Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL);
|
||||
if (have_pythonprepend(n)) {
|
||||
|
|
@ -4314,7 +4483,7 @@ public:
|
|||
int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0;
|
||||
String *parms = make_pyParmList(n, false, false, kw);
|
||||
String *callParms = make_pyParmList(n, false, true, kw);
|
||||
Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
|
||||
Printv(f_shadow, "\n", tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
|
||||
if (have_docstring(n))
|
||||
Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL);
|
||||
if (have_pythonprepend(n))
|
||||
|
|
@ -4326,7 +4495,9 @@ public:
|
|||
} else {
|
||||
Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL);
|
||||
}
|
||||
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", symname, ")\n", NIL);
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, symname, " = staticmethod(", symname, ")\n", NIL);
|
||||
|
||||
if (!modern) {
|
||||
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", symname, "\n", NIL);
|
||||
|
|
@ -4338,7 +4509,9 @@ public:
|
|||
NIL);
|
||||
}
|
||||
if (!classic) {
|
||||
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname),
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname),
|
||||
")\n", NIL);
|
||||
}
|
||||
}
|
||||
|
|
@ -4427,7 +4600,7 @@ public:
|
|||
Printv(pass_self, tab8, tab4, "_self = None\n", tab8, "else:\n", tab8, tab4, "_self = self\n", NIL);
|
||||
}
|
||||
|
||||
Printv(f_shadow, tab4, "def __init__(", parms, ")", returnTypeAnnotation(n), ": \n", NIL);
|
||||
Printv(f_shadow, "\n", tab4, "def __init__(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
|
||||
if (have_docstring(n))
|
||||
Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL);
|
||||
if (have_pythonprepend(n))
|
||||
|
|
@ -4438,7 +4611,7 @@ public:
|
|||
} else {
|
||||
Printv(f_shadow,
|
||||
tab8, "this = ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), "\n",
|
||||
tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL);
|
||||
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), "\n\n", NIL);
|
||||
|
|
@ -4524,7 +4697,7 @@ public:
|
|||
Printv(f_shadow, tab4, "__swig_destroy__ = ", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "\n", NIL);
|
||||
if (!have_pythonprepend(n) && !have_pythonappend(n)) {
|
||||
if (proxydel) {
|
||||
Printv(f_shadow, tab4, "__del__ = lambda self : None;\n", NIL);
|
||||
Printv(f_shadow, tab4, "__del__ = lambda self: None\n", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -4535,7 +4708,7 @@ public:
|
|||
Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\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);
|
||||
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);
|
||||
#else
|
||||
#endif
|
||||
|
|
@ -4573,11 +4746,12 @@ public:
|
|||
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL);
|
||||
}
|
||||
if (!classic) {
|
||||
if (!assignable) {
|
||||
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ")\n", NIL);
|
||||
} else {
|
||||
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ", ", module, ".", setname, ")\n", NIL);
|
||||
}
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, symname, " = _swig_property(", module, ".", getname, NIL);
|
||||
if (assignable)
|
||||
Printv(f_shadow, ", ", module, ".", setname, NIL);
|
||||
Printv(f_shadow, ")\n", NIL);
|
||||
}
|
||||
Delete(mname);
|
||||
Delete(setname);
|
||||
|
|
@ -4646,11 +4820,12 @@ public:
|
|||
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL);
|
||||
}
|
||||
if (!classic && !builtin) {
|
||||
if (!assignable) {
|
||||
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ")\n", NIL);
|
||||
} else {
|
||||
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ", ", module, ".", setname, ")\n", NIL);
|
||||
}
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, symname, " = _swig_property(", module, ".", getname, NIL);
|
||||
if (assignable)
|
||||
Printv(f_shadow, ", ", module, ".", setname, NIL);
|
||||
Printv(f_shadow, ")\n", NIL);
|
||||
}
|
||||
String *getter = Getattr(n, "pybuiltin:getter");
|
||||
String *setter = Getattr(n, "pybuiltin:setter");
|
||||
|
|
@ -4776,6 +4951,13 @@ public:
|
|||
return NewString("swigpyrun.h");
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* kwargsSupport()
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
bool kwargsSupport() const {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
|
|
@ -4813,6 +4995,16 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
int idx;
|
||||
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
|
||||
|
||||
if (builtin) {
|
||||
// Rename any wrapped parameters called 'self' as the generated code contains a variable with same name
|
||||
Parm *p;
|
||||
for (p = l; p; p = nextSibling(p)) {
|
||||
String *arg = Getattr(p, "name");
|
||||
if (arg && Cmp(arg, "self") == 0)
|
||||
Delattr(p, "name");
|
||||
}
|
||||
}
|
||||
|
||||
if (Cmp(storage, "virtual") == 0) {
|
||||
if (Cmp(value, "0") == 0) {
|
||||
pure_virtual = true;
|
||||
|
|
|
|||
|
|
@ -3426,6 +3426,14 @@ public:
|
|||
String *defaultExternalRuntimeFilename() {
|
||||
return NewString("swigrubyrun.h");
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* kwargsSupport()
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
bool kwargsSupport() const {
|
||||
return true;
|
||||
}
|
||||
}; /* class RUBY */
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -182,11 +182,6 @@ int main(int margc, char **margv) {
|
|||
} else if (strcmp(argv[i], "-nolang") == 0) {
|
||||
dl = new Language;
|
||||
Swig_mark_arg(i);
|
||||
} else if ((strcmp(argv[i], "-dnone") == 0) ||
|
||||
(strcmp(argv[i], "-dhtml") == 0) ||
|
||||
(strcmp(argv[i], "-dlatex") == 0) || (strcmp(argv[i], "-dascii") == 0) || (strcmp(argv[i], "-stat") == 0)) {
|
||||
Printf(stderr, "swig: Warning. %s option deprecated.\n", argv[i]);
|
||||
Swig_mark_arg(i);
|
||||
} else if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0)) {
|
||||
if (strcmp(argv[i], "--help") == 0)
|
||||
strcpy(argv[i], "-help");
|
||||
|
|
|
|||
|
|
@ -291,12 +291,18 @@ protected:
|
|||
/* Return the current class prefix */
|
||||
String *getClassPrefix() const;
|
||||
|
||||
/* Return the current enum class prefix */
|
||||
String *getEnumClassPrefix() const;
|
||||
|
||||
/* Fully qualified type name to use */
|
||||
String *getClassType() const;
|
||||
|
||||
/* Return true if the current method is part of a smart-pointer */
|
||||
int is_smart_pointer() const;
|
||||
|
||||
/* Return the name to use for the given parameter. */
|
||||
virtual String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter = false) const;
|
||||
|
||||
/* Some language modules require additional wrappers for virtual methods not declared in sub-classes */
|
||||
virtual bool extraDirectorProtectedCPPMethodsRequired() const;
|
||||
|
||||
|
|
@ -315,6 +321,9 @@ public:
|
|||
*/
|
||||
virtual NestedClassSupport nestedClassesSupport() const;
|
||||
|
||||
/* Returns true if the target language supports key word arguments (kwargs) */
|
||||
virtual bool kwargsSupport() const;
|
||||
|
||||
protected:
|
||||
/* Identifies if a protected members that are generated when the allprotected option is used.
|
||||
This does not include protected virtual methods as they are turned on with the dirprot option. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue