Merge latest master into doxygen branch again.

Update Doxygen-specific Python unit tests to work with the new indentation.

Update one of Doxygen-specific Java tests to still build with the new handling
of srcdir.
This commit is contained in:
Vadim Zeitlin 2014-06-11 02:21:43 +02:00
commit 6cce652762
557 changed files with 4998 additions and 4138 deletions

View file

@ -318,6 +318,10 @@ public:
**/
virtual int fragmentDirective(Node *n);
public:
virtual String *getNSpace() const;
private:
JSEmitter *emitter;
@ -467,6 +471,10 @@ int JAVASCRIPT::fragmentDirective(Node *n) {
return SWIG_OK;
}
String *JAVASCRIPT::getNSpace() const {
return Language::getNSpace();
}
/* ---------------------------------------------------------------------
* top()
*
@ -716,19 +724,19 @@ int JSEmitter::emitWrapperFunction(Node *n) {
// detected via the 'view' attribute.
|| (Equal(kind, "variable") && Equal(Getattr(n, "view"), "globalfunctionHandler"))
) {
bool is_member = GetFlag(n, "ismember") | GetFlag(n, "feature:extend");
bool is_static = GetFlag(state.function(), IS_STATIC);
bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0;
bool is_static = GetFlag(state.function(), IS_STATIC) != 0;
ret = emitFunction(n, is_member, is_static);
} else if (Cmp(kind, "variable") == 0) {
bool is_static = GetFlag(state.variable(), IS_STATIC);
bool is_static = GetFlag(state.variable(), IS_STATIC) != 0;
// HACK: smartpointeraccessed static variables are not treated as statics
if (GetFlag(n, "allocate:smartpointeraccess")) {
is_static = false;
}
bool is_member = GetFlag(n, "ismember");
bool is_setter = GetFlag(n, "memberset") || GetFlag(n, "varset");
bool is_getter = GetFlag(n, "memberget") || GetFlag(n, "varget");
bool is_member = GetFlag(n, "ismember") != 0;
bool is_setter = GetFlag(n, "memberset") != 0 || GetFlag(n, "varset") != 0;
bool is_getter = GetFlag(n, "memberget") != 0 || GetFlag(n, "varget") != 0;
if (is_setter) {
ret = emitSetter(n, is_member, is_static);
} else if (is_getter) {
@ -832,7 +840,7 @@ int JSEmitter::emitCtor(Node *n) {
Wrapper *wrapper = NewWrapper();
bool is_overloaded = GetFlag(n, "sym:overloaded");
bool is_overloaded = GetFlag(n, "sym:overloaded") != 0;
Template t_ctor(getTemplate("js_ctor"));
@ -1152,7 +1160,7 @@ int JSEmitter::emitFunction(Node *n, bool is_member, bool is_static) {
Wrapper *wrapper = NewWrapper();
Template t_function(getTemplate("js_function"));
bool is_overloaded = GetFlag(n, "sym:overloaded");
bool is_overloaded = GetFlag(n, "sym:overloaded") != 0;
// prepare the function wrapper name
String *iname = Getattr(n, "sym:name");
@ -1223,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);
@ -1280,7 +1297,7 @@ void JSEmitter::marshalOutput(Node *n, ParmList *params, Wrapper *wrapper, Strin
cresult = defaultResultName;
tm = Swig_typemap_lookup_out("out", n, cresult, wrapper, actioncode);
bool should_own = GetFlag(n, "feature:new");
bool should_own = GetFlag(n, "feature:new") != 0;
if (tm) {
Replaceall(tm, "$objecttype", Swig_scopename_last(SwigType_str(SwigType_strip_qualifiers(type), 0)));
@ -1346,14 +1363,26 @@ int JSEmitter::switchNamespace(Node *n) {
return SWIG_OK;
}
String *nspace = Getattr(n, "sym:nspace");
// if nspace is deactivated, everything goes into the global scope
if (!GetFlag(n, "feature:nspace")) {
current_namespace = Getattr(namespaces, "::");
return SWIG_OK;
}
// EXPERIMENTAL: we want to use Language::getNSpace() here
// However, it is not working yet.
// For namespace functions Language::getNSpace() does not give a valid result
#if 0
JAVASCRIPT *lang = static_cast<JAVASCRIPT*>(Language::instance());
String *_nspace = lang->getNSpace();
if (!Equal(nspace, _nspace)) {
Printf(stdout, "##### Custom vs Language::getNSpace(): %s | %s\n", nspace, _nspace);
Swig_print_node(n);
}
#endif
String *nspace = Getattr(n, "sym:nspace");
if (nspace == NULL) {
// It seems that only classes have 'sym:nspace' set.
// We try to get the namespace from the qualified name (i.e., everything before the last '::')
@ -1608,8 +1637,8 @@ int JSCEmitter::enterFunction(Node *n) {
int JSCEmitter::exitFunction(Node *n) {
Template t_function = getTemplate("jsc_function_declaration");
bool is_member = GetFlag(n, "ismember") | GetFlag(n, "feature:extend");
bool is_overloaded = GetFlag(n, "sym:overloaded");
bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0;
bool is_overloaded = GetFlag(n, "sym:overloaded") != 0;
// handle overloaded functions
if (is_overloaded) {
@ -2057,10 +2086,10 @@ int V8Emitter::exitVariable(Node *n) {
}
int V8Emitter::exitFunction(Node *n) {
bool is_member = GetFlag(n, "ismember") | GetFlag(n, "feature:extend");
bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0;
// create a dispatcher for overloaded functions
bool is_overloaded = GetFlag(n, "sym:overloaded");
bool is_overloaded = GetFlag(n, "sym:overloaded") != 0;
if (is_overloaded) {
if (!Getattr(n, "sym:nextSibling")) {
//state.function(WRAPPER_NAME, Swig_name_wrapper(Getattr(n, "name")));

View file

@ -1172,6 +1172,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
Printf(stdout, "Processing unnamed structs...\n");
Swig_nested_name_unnamed_c_structs(top);
}
Swig_extend_unused_check();
if (Verbose) {
Printf(stdout, "Processing types...\n");

View file

@ -362,7 +362,15 @@ void Swig_nested_name_unnamed_c_structs(Node *n) {
Delete(bases);
}
Setattr(classhash, name, c);
// Merge the extension into the symbol table
if (Node *am = Getattr(Swig_extend_hash(), name)) {
Swig_extend_merge(c, am);
Swig_extend_append_previous(c, am);
Delattr(Swig_extend_hash(), name);
}
Swig_symbol_popscope();
// process declarations following this type (assign correct new type)
SwigType *ty = Copy(name);
Node *decl = nextSibling(c);
@ -376,16 +384,6 @@ void Swig_nested_name_unnamed_c_structs(Node *n) {
decl = nextSibling(decl);
}
Delete(ty);
// Check for extensions
/* // TODO: we can save extensions hash like class hash and move check_extensions() after nesting processing
if (extendhash) {
if (Node *am = Getattr(extendhash, name)) {
// Merge the extension into the symbol table
merge_extensions(c, am);
append_previous_extension(c, am);
Delattr(extendhash, clsname);
}
}*/
Swig_symbol_setscope(Swig_symbol_global_scope());
add_symbols_c(c);
@ -396,7 +394,12 @@ void Swig_nested_name_unnamed_c_structs(Node *n) {
Delete(ins);
Delattr(c, "nested:outer");
} else {
// global unnamed struct - ignore it
// global unnamed struct - ignore it and it's instances
SetFlag(c, "feature:ignore");
while (next && Getattr(next, "nested:unnamedtype") == c) {
SetFlag(next, "feature:ignore");
next = nextSibling(next);
}
c = next;
continue;
}

View file

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
* This file is part of SWIG, which is licensed as a whole under version 3
* This file is part of SWIG, which is licensed as a whole under version 3
* (or any later version) of the GNU General Public License. Some additional
* terms also apply to certain portions of SWIG. The full details of the SWIG
* license and copyrights can be found in the LICENSE and COPYRIGHT files
@ -75,51 +75,44 @@ public:
constructor_name(0),
docs(0)
{
/* Add code to manage protected constructors and directors */
director_prot_ctor_code = NewString("");
Printv(director_prot_ctor_code,
"if ( $comparison ) { /* subclassed */\n",
" $director_new \n",
"} else {\n", " error(\"accessing abstract class or protected constructor\"); \n", " SWIG_fail;\n", "}\n", NIL);
/* Add code to manage protected constructors and directors */
director_prot_ctor_code = NewString("");
Printv(director_prot_ctor_code,
"if ( $comparison ) { /* subclassed */\n",
" $director_new \n",
"} else {\n", " error(\"accessing abstract class or protected constructor\"); \n", " SWIG_fail;\n", "}\n", NIL);
enable_cplus_runtime_mode();
allow_overloading();
director_multiple_inheritance = 1;
director_language = 1;
docs = NewHash();
}
enable_cplus_runtime_mode();
allow_overloading();
director_multiple_inheritance = 1;
director_language = 1;
docs = NewHash();
}
virtual void main(int argc, char *argv[]) {
for (int i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) {
fputs(usage, stdout);
} else if (strcmp(argv[i], "-global") == 0 ||
strcmp(argv[i], "-noglobal") == 0) {
Printv(stderr,
"*** -global/-noglobal are no longer supported\n"
"*** global load behaviour is now determined at module load\n"
"*** see the Perl section in the manual for details.\n", NIL);
SWIG_exit(EXIT_FAILURE);
} else if (strcmp(argv[i], "-globals") == 0) {
if (argv[i + 1]) {
global_name = NewString(argv[i + 1]);
Swig_mark_arg(i);
Swig_mark_arg(i + 1);
i++;
} else {
Swig_arg_error();
}
} else if (strcmp(argv[i], "-opprefix") == 0) {
if (argv[i + 1]) {
op_prefix = NewString(argv[i + 1]);
Swig_mark_arg(i);
Swig_mark_arg(i + 1);
i++;
} else {
Swig_arg_error();
}
}
if (strcmp(argv[i], "-help") == 0) {
fputs(usage, stdout);
} else if (strcmp(argv[i], "-globals") == 0) {
if (argv[i + 1]) {
global_name = NewString(argv[i + 1]);
Swig_mark_arg(i);
Swig_mark_arg(i + 1);
i++;
} else {
Swig_arg_error();
}
} else if (strcmp(argv[i], "-opprefix") == 0) {
if (argv[i + 1]) {
op_prefix = NewString(argv[i + 1]);
Swig_mark_arg(i);
Swig_mark_arg(i + 1);
i++;
} else {
Swig_arg_error();
}
}
}
}
@ -143,21 +136,21 @@ public:
{
Node *mod = Getattr(n, "module");
if (mod) {
Node *options = Getattr(mod, "options");
if (options) {
int dirprot = 0;
if (Getattr(options, "dirprot")) {
dirprot = 1;
}
if (Getattr(options, "nodirprot")) {
dirprot = 0;
}
if (Getattr(options, "directors")) {
allow_directors();
if (dirprot)
allow_dirprot();
}
}
Node *options = Getattr(mod, "options");
if (options) {
int dirprot = 0;
if (Getattr(options, "dirprot")) {
dirprot = 1;
}
if (Getattr(options, "nodirprot")) {
dirprot = 0;
}
if (Getattr(options, "directors")) {
allow_directors();
if (dirprot)
allow_dirprot();
}
}
}
}
@ -202,8 +195,8 @@ public:
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
Swig_banner(f_directors_h);
if (dirprot_mode()) {
// Printf(f_directors_h, "#include <map>\n");
// Printf(f_directors_h, "#include <string>\n\n");
// Printf(f_directors_h, "#include <map>\n");
// Printf(f_directors_h, "#include <string>\n\n");
}
}
@ -263,19 +256,19 @@ public:
String *r = NewString("");
for (int j=0;s[j];++j) {
if (s[j] == '\n') {
Append(r, "\\n\\\n");
Append(r, "\\n\\\n");
} else if (s[j] == '\r') {
Append(r, "\\r");
Append(r, "\\r");
} else if (s[j] == '\t') {
Append(r, "\\t");
Append(r, "\\t");
} else if (s[j] == '\\') {
Append(r, "\\\\");
Append(r, "\\\\");
} else if (s[j] == '\'') {
Append(r, "\\\'");
Append(r, "\\\'");
} else if (s[j] == '\"') {
Append(r, "\\\"");
Append(r, "\\\"");
} else
Putc(s[j], r);
Putc(s[j], r);
}
return r;
}
@ -293,11 +286,11 @@ public:
String *escaped_doc_str = texinfo_escape(doc_str);
if (Len(doc_str)>0) {
Printf(f_doc,"static const char* %s_texinfo = ",wrap_name);
Printf(f_doc,"\"-*- texinfo -*-\\n\\\n%s", escaped_doc_str);
if (Len(decl_info))
Printf(f_doc,"\\n\\\n@end deftypefn");
Printf(f_doc,"\";\n");
Printf(f_doc,"static const char* %s_texinfo = ",wrap_name);
Printf(f_doc,"\"-*- texinfo -*-\\n\\\n%s", escaped_doc_str);
if (Len(decl_info))
Printf(f_doc,"\\n\\\n@end deftypefn");
Printf(f_doc,"\";\n");
}
Delete(escaped_doc_str);
@ -313,7 +306,7 @@ public:
String *decl_info = Getattr(n, "decl_info");
String *cdecl_info = Getattr(n, "cdecl_info");
String *args_info = Getattr(n, "args_info");
return !Len(synopsis) && !Len(decl_info) &&
return !Len(synopsis) && !Len(decl_info) &&
!Len(cdecl_info) && !Len(args_info);
}
String *texinfo_name(Node* n, const char* defval = "0") {
@ -360,11 +353,11 @@ public:
SwigType *type = Getattr(n, "type");
if (type && Strcmp(type, "void")) {
Node *nn = classLookup(Getattr(n, "type"));
String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
Append(decl_info, "@var{retval} = ");
Printf(args_str, "%s@var{retval} is of type %s. ", args_str, type_str);
Delete(type_str);
Node *nn = classLookup(Getattr(n, "type"));
String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
Append(decl_info, "@var{retval} = ");
Printf(args_str, "%s@var{retval} is of type %s. ", args_str, type_str);
Delete(type_str);
}
Append(decl_info, name);
@ -380,8 +373,8 @@ public:
// strip off {} if necessary
char *t = Char(str);
if (*t == '{') {
Delitem(str, 0);
Delitem(str, DOH_END);
Delitem(str, 0);
Delitem(str, DOH_END);
}
// emit into synopsis section
@ -408,7 +401,7 @@ public:
* addMissingParameterNames()
* For functions that have not had nameless parameters set in the Language class.
*
* Inputs:
* Inputs:
* plist - entire parameter list
* arg_offset - argument number for first parameter
* Side effects:
@ -420,8 +413,8 @@ public:
int i = arg_offset;
while (p) {
if (!Getattr(p, "lname")) {
String *pname = Swig_cparm_name(p, i);
Delete(pname);
String *pname = Swig_cparm_name(p, i);
Delete(pname);
}
i++;
p = nextSibling(p);
@ -444,12 +437,12 @@ public:
String *tm = Getattr(p, "tmap:in");
if (tm) {
pnext = Getattr(p, "tmap:in:next");
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
continue;
}
pnext = Getattr(p, "tmap:in:next");
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
continue;
}
} else {
pnext = nextSibling(p);
pnext = nextSibling(p);
}
String *name = 0;
@ -457,9 +450,9 @@ public:
String *value = 0;
String *pdoc = Getattr(p, "tmap:doc");
if (pdoc) {
name = Getattr(p, "tmap:doc:name");
type = Getattr(p, "tmap:doc:type");
value = Getattr(p, "tmap:doc:value");
name = Getattr(p, "tmap:doc:name");
type = Getattr(p, "tmap:doc:type");
value = Getattr(p, "tmap:doc:value");
}
// Note: the generated name should be consistent with that in kwnames[]
@ -471,28 +464,28 @@ public:
value = value ? value : Getattr(p, "value");
if (SwigType_isvarargs(type))
break;
break;
String *tex_name = NewString("");
if (name)
Printf(tex_name, "@var{%s}", name);
Printf(tex_name, "@var{%s}", name);
else
Printf(tex_name, "@var{?}");
Printf(tex_name, "@var{?}");
if (Len(decl_str))
Append(decl_str, ", ");
Append(decl_str, ", ");
Append(decl_str, tex_name);
if (value) {
String *new_value = convertValue(value, Getattr(p, "type"));
if (new_value) {
value = new_value;
} else {
Node *lookup = Swig_symbol_clookup(value, 0);
if (lookup)
value = Getattr(lookup, "sym:name");
}
Printf(decl_str, " = %s", value);
String *new_value = convertValue(value, Getattr(p, "type"));
if (new_value) {
value = new_value;
} else {
Node *lookup = Swig_symbol_clookup(value, 0);
if (lookup)
value = Getattr(lookup, "sym:name");
}
Printf(decl_str, " = %s", value);
}
Node *nn = classLookup(Getattr(p, "type"));
@ -517,18 +510,18 @@ public:
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;
/* number or string (or maybe NULL pointer) */
if (SwigType_ispointer(t) && Strcmp(v, "0") == 0)
return NewString("None");
else
return v;
}
if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
return SwigType_ispointer(t) ? NewString("nil") : NewString("0");
return SwigType_ispointer(t) ? NewString("nil") : NewString("0");
if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
return NewString("true");
return NewString("true");
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
return NewString("false");
return NewString("false");
}
return 0;
}
@ -572,89 +565,89 @@ public:
int varargs = emit_isvarargs(l);
char source[64];
Printf(f->code, "if (!SWIG_check_num_args(\"%s\",args.length(),%i,%i,%i)) "
"{\n SWIG_fail;\n }\n", iname, num_arguments, num_required, varargs);
Printf(f->code, "if (!SWIG_check_num_args(\"%s\",args.length(),%i,%i,%i)) "
"{\n SWIG_fail;\n }\n", iname, num_arguments, num_required, varargs);
if (constructor && num_arguments == 1 && num_required == 1) {
if (Cmp(storage, "explicit") == 0) {
Node *parent = Swig_methodclass(n);
if (GetFlag(parent, "feature:implicitconv")) {
String *desc = NewStringf("SWIGTYPE%s", SwigType_manglestr(Getattr(n, "type")));
Printf(f->code, "if (SWIG_CheckImplicit(%s)) SWIG_fail;\n", desc);
Delete(desc);
}
Node *parent = Swig_methodclass(n);
if (GetFlag(parent, "feature:implicitconv")) {
String *desc = NewStringf("SWIGTYPE%s", SwigType_manglestr(Getattr(n, "type")));
Printf(f->code, "if (SWIG_CheckImplicit(%s)) SWIG_fail;\n", desc);
Delete(desc);
}
}
}
for (j = 0, p = l; j < num_arguments; ++j) {
while (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next");
p = Getattr(p, "tmap:in:next");
}
SwigType *pt = Getattr(p, "type");
String *tm = Getattr(p, "tmap:in");
if (tm) {
if (!tm || checkAttribute(p, "tmap:in:numinputs", "0")) {
p = nextSibling(p);
continue;
}
if (!tm || checkAttribute(p, "tmap:in:numinputs", "0")) {
p = nextSibling(p);
continue;
}
sprintf(source, "args(%d)", j);
Setattr(p, "emit:input", source);
sprintf(source, "args(%d)", j);
Setattr(p, "emit:input", source);
Replaceall(tm, "$source", Getattr(p, "emit:input"));
Replaceall(tm, "$input", Getattr(p, "emit:input"));
Replaceall(tm, "$target", Getattr(p, "lname"));
Replaceall(tm, "$source", Getattr(p, "emit:input"));
Replaceall(tm, "$input", Getattr(p, "emit:input"));
Replaceall(tm, "$target", Getattr(p, "lname"));
if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) {
Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN");
} else {
Replaceall(tm, "$disown", "0");
}
if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) {
Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN");
} else {
Replaceall(tm, "$disown", "0");
}
if (Getattr(p, "tmap:in:implicitconv")) {
const char *convflag = "0";
if (!Getattr(p, "hidden")) {
SwigType *ptype = Getattr(p, "type");
convflag = get_implicitconv_flag(classLookup(ptype));
}
Replaceall(tm, "$implicitconv", convflag);
Setattr(p, "implicitconv", convflag);
}
if (Getattr(p, "tmap:in:implicitconv")) {
const char *convflag = "0";
if (!Getattr(p, "hidden")) {
SwigType *ptype = Getattr(p, "type");
convflag = get_implicitconv_flag(classLookup(ptype));
}
Replaceall(tm, "$implicitconv", convflag);
Setattr(p, "implicitconv", convflag);
}
String *getargs = NewString("");
if (j >= num_required)
Printf(getargs, "if (%d<args.length()) {\n%s\n}", j, tm);
else
Printv(getargs, tm, NIL);
Printv(f->code, getargs, "\n", NIL);
Delete(getargs);
String *getargs = NewString("");
if (j >= num_required)
Printf(getargs, "if (%d<args.length()) {\n%s\n}", j, tm);
else
Printv(getargs, tm, NIL);
Printv(f->code, getargs, "\n", NIL);
Delete(getargs);
p = Getattr(p, "tmap:in:next");
continue;
p = Getattr(p, "tmap:in:next");
continue;
} else {
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
break;
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
break;
}
}
// Check for trailing varargs
if (varargs) {
if (p && (tm = Getattr(p, "tmap:in"))) {
Replaceall(tm, "$input", "varargs");
Printv(f->code, tm, "\n", NIL);
Replaceall(tm, "$input", "varargs");
Printv(f->code, tm, "\n", NIL);
}
}
// Insert constraint checking code
for (p = l; p;) {
if ((tm = Getattr(p, "tmap:check"))) {
Replaceall(tm, "$target", Getattr(p, "lname"));
Printv(f->code, tm, "\n", NIL);
p = Getattr(p, "tmap:check:next");
Replaceall(tm, "$target", Getattr(p, "lname"));
Printv(f->code, tm, "\n", NIL);
p = Getattr(p, "tmap:check:next");
} else {
p = nextSibling(p);
p = nextSibling(p);
}
}
@ -662,23 +655,23 @@ public:
String *cleanup = NewString("");
for (p = l; p;) {
if ((tm = Getattr(p, "tmap:freearg"))) {
if (Getattr(p, "tmap:freearg:implicitconv")) {
const char *convflag = "0";
if (!Getattr(p, "hidden")) {
SwigType *ptype = Getattr(p, "type");
convflag = get_implicitconv_flag(classLookup(ptype));
}
if (strcmp(convflag, "0") == 0) {
tm = 0;
}
}
if (tm && (Len(tm) != 0)) {
Replaceall(tm, "$source", Getattr(p, "lname"));
Printv(cleanup, tm, "\n", NIL);
}
p = Getattr(p, "tmap:freearg:next");
if (Getattr(p, "tmap:freearg:implicitconv")) {
const char *convflag = "0";
if (!Getattr(p, "hidden")) {
SwigType *ptype = Getattr(p, "type");
convflag = get_implicitconv_flag(classLookup(ptype));
}
if (strcmp(convflag, "0") == 0) {
tm = 0;
}
}
if (tm && (Len(tm) != 0)) {
Replaceall(tm, "$source", Getattr(p, "lname"));
Printv(cleanup, tm, "\n", NIL);
}
p = Getattr(p, "tmap:freearg:next");
} else {
p = nextSibling(p);
p = nextSibling(p);
}
}
@ -686,15 +679,15 @@ public:
String *outarg = NewString("");
for (p = l; p;) {
if ((tm = Getattr(p, "tmap:argout"))) {
Replaceall(tm, "$source", Getattr(p, "lname"));
Replaceall(tm, "$target", "_outp");
Replaceall(tm, "$result", "_outp");
Replaceall(tm, "$arg", Getattr(p, "emit:input"));
Replaceall(tm, "$input", Getattr(p, "emit:input"));
Printv(outarg, tm, "\n", NIL);
p = Getattr(p, "tmap:argout:next");
Replaceall(tm, "$source", Getattr(p, "lname"));
Replaceall(tm, "$target", "_outp");
Replaceall(tm, "$result", "_outp");
Replaceall(tm, "$arg", Getattr(p, "emit:input"));
Replaceall(tm, "$input", Getattr(p, "emit:input"));
Printv(outarg, tm, "\n", NIL);
p = Getattr(p, "tmap:argout:next");
} else {
p = nextSibling(p);
p = nextSibling(p);
}
}
@ -720,9 +713,9 @@ public:
Replaceall(tm, "$result", "_outv");
if (GetFlag(n, "feature:new"))
Replaceall(tm, "$owner", "1");
Replaceall(tm, "$owner", "1");
else
Replaceall(tm, "$owner", "0");
Replaceall(tm, "$owner", "0");
Printf(f->code, "%s\n", tm);
Printf(f->code, "if (_outv.is_defined()) _outp = " "SWIG_Octave_AppendOutput(_outp, _outv);\n");
@ -737,8 +730,8 @@ public:
if (GetFlag(n, "feature:new")) {
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
Replaceall(tm, "$source", Swig_cresult_name());
Printf(f->code, "%s\n", tm);
Replaceall(tm, "$source", Swig_cresult_name());
Printf(f->code, "%s\n", tm);
}
}
@ -830,16 +823,16 @@ public:
if (is_assignable(n)) {
Setattr(n, "wrap:name", setname);
if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
Replaceall(tm, "$source", "args(0)");
Replaceall(tm, "$target", name);
Replaceall(tm, "$input", "args(0)");
if (Getattr(n, "tmap:varin:implicitconv")) {
Replaceall(tm, "$implicitconv", get_implicitconv_flag(n));
}
emit_action_code(n, setf->code, tm);
Delete(tm);
Replaceall(tm, "$source", "args(0)");
Replaceall(tm, "$target", name);
Replaceall(tm, "$input", "args(0)");
if (Getattr(n, "tmap:varin:implicitconv")) {
Replaceall(tm, "$implicitconv", get_implicitconv_flag(n));
}
emit_action_code(n, setf->code, tm);
Delete(tm);
} else {
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0));
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0));
}
Append(setf->code, "fail:\n");
Printf(setf->code, "return octave_value_list();\n");
@ -995,18 +988,18 @@ public:
int index = 0;
b = First(baselist);
while (b.item) {
String *bname = Getattr(b.item, "name");
if ((!bname) || GetFlag(b.item, "feature:ignore") || (!Getattr(b.item, "module"))) {
b = Next(b);
continue;
}
String *bname = Getattr(b.item, "name");
if ((!bname) || GetFlag(b.item, "feature:ignore") || (!Getattr(b.item, "module"))) {
b = Next(b);
continue;
}
String *bname_mangled = SwigType_manglestr(SwigType_add_pointer(Copy(bname)));
Printf(base_class_names, "\"%s\",", bname_mangled);
Printf(base_class, "0,");
b = Next(b);
index++;
Delete(bname_mangled);
String *bname_mangled = SwigType_manglestr(SwigType_add_pointer(Copy(bname)));
Printf(base_class_names, "\"%s\",", bname_mangled);
Printf(base_class, "0,");
b = Next(b);
index++;
Delete(bname_mangled);
}
}
@ -1063,8 +1056,8 @@ public:
bool overloaded = !!Getattr(n, "sym:overloaded");
if (overloaded)
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
Printf(s_members_tab, "{\"%s\",%s,0,0,0,%s},\n",
realname, rname, tname);
Printf(s_members_tab, "{\"%s\",%s,0,0,0,%s},\n",
realname, rname, tname);
Delete(rname);
Delete(tname);
}
@ -1112,7 +1105,7 @@ public:
Delete(name);
Setattr(self, "lname", "self_obj");
if (parms)
set_nextSibling(self, parms);
set_nextSibling(self, parms);
Setattr(n, "parms", self);
Setattr(n, "wrap:self", "1");
Setattr(n, "hidden", "1");
@ -1144,12 +1137,12 @@ public:
bool overloaded = !!Getattr(n, "sym:overloaded");
if (overloaded)
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
Printf(s_members_tab, "{\"%s\",%s,0,0,1,%s},\n",
realname, rname, tname);
Printf(s_members_tab, "{\"%s\",%s,0,0,1,%s},\n",
realname, rname, tname);
Delete(rname);
Delete(tname);
}
return SWIG_OK;
}
@ -1217,24 +1210,24 @@ public:
if (!Getattr(n, "defaultargs")) {
// constructor
{
Wrapper *w = NewWrapper();
String *call;
String *basetype = Getattr(parent, "classtype");
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
call = Swig_csuperclass_call(0, basetype, superparms);
Printf(w->def, "%s::%s: %s," "\nSwig::Director(static_cast<%s*>(this)) { \n", classname, target, call, basetype);
Append(w->def, "}\n");
Delete(target);
Wrapper_print(w, f_directors);
Delete(call);
DelWrapper(w);
Wrapper *w = NewWrapper();
String *call;
String *basetype = Getattr(parent, "classtype");
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
call = Swig_csuperclass_call(0, basetype, superparms);
Printf(w->def, "%s::%s: %s," "\nSwig::Director(static_cast<%s*>(this)) { \n", classname, target, call, basetype);
Append(w->def, "}\n");
Delete(target);
Wrapper_print(w, f_directors);
Delete(call);
DelWrapper(w);
}
// constructor header
{
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
Printf(f_directors_h, " %s;\n", target);
Delete(target);
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
Printf(f_directors_h, " %s;\n", target);
Delete(target);
}
}
@ -1250,7 +1243,7 @@ public:
{
Wrapper *w = NewWrapper();
Printf(w->def, "SwigDirector_%s::SwigDirector_%s(void* self) :"
"\nSwig::Director((octave_swig_type*)self,static_cast<%s*>(this)) { \n", classname, classname, classname);
"\nSwig::Director((octave_swig_type*)self,static_cast<%s*>(this)) { \n", classname, classname, classname);
Append(w->def, "}\n");
Wrapper_print(w, f_directors);
DelWrapper(w);
@ -1283,7 +1276,7 @@ public:
if (Cmp(storage, "virtual") == 0) {
if (Cmp(value, "0") == 0) {
pure_virtual = true;
pure_virtual = true;
}
}
@ -1317,18 +1310,18 @@ public:
Append(declaration, " throw(");
if (throw_parm_list)
Swig_typemap_attach_parms("throws", throw_parm_list, 0);
Swig_typemap_attach_parms("throws", throw_parm_list, 0);
for (p = throw_parm_list; p; p = nextSibling(p)) {
if (Getattr(p, "tmap:throws")) {
if (gencomma++) {
Append(w->def, ", ");
Append(declaration, ", ");
}
String *str = SwigType_str(Getattr(p, "type"), 0);
Append(w->def, str);
Append(declaration, str);
Delete(str);
}
if (Getattr(p, "tmap:throws")) {
if (gencomma++) {
Append(w->def, ", ");
Append(declaration, ", ");
}
String *str = SwigType_str(Getattr(p, "type"), 0);
Append(w->def, str);
Append(declaration, str);
Delete(str);
}
}
Append(w->def, ")");
@ -1338,27 +1331,27 @@ public:
Append(w->def, " {");
Append(declaration, ";\n");
// declare method return value
// declare method return value
// if the return value is a reference or const reference, a specialized typemap must
// handle it, including declaration of c_result ($result).
if (!is_void) {
if (!(ignored_method && !pure_virtual)) {
String *cres = SwigType_lstr(returntype, "c_result");
Printf(w->code, "%s;\n", cres);
Delete(cres);
String *cres = SwigType_lstr(returntype, "c_result");
Printf(w->code, "%s;\n", cres);
Delete(cres);
}
}
if (ignored_method) {
if (!pure_virtual) {
if (!is_void)
Printf(w->code, "return ");
String *super_call = Swig_method_call(super, l);
Printf(w->code, "%s;\n", super_call);
Delete(super_call);
if (!is_void)
Printf(w->code, "return ");
String *super_call = Swig_method_call(super, l);
Printf(w->code, "%s;\n", super_call);
Delete(super_call);
} else {
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname),
SwigType_namestr(name));
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname),
SwigType_namestr(name));
}
} else {
// attach typemaps to arguments (C/C++ -> Python)
@ -1374,50 +1367,50 @@ public:
int outputs = 0;
if (!is_void)
outputs++;
outputs++;
// build argument list and type conversion string
p = l;
while (p) {
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next");
continue;
}
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next");
continue;
}
if (Getattr(p, "tmap:directorargout") != 0)
outputs++;
if (Getattr(p, "tmap:directorargout") != 0)
outputs++;
String *pname = Getattr(p, "name");
String *ptype = Getattr(p, "type");
Wrapper_add_local(w, "tmpv", "octave_value tmpv");
String *pname = Getattr(p, "name");
String *ptype = Getattr(p, "type");
Wrapper_add_local(w, "tmpv", "octave_value tmpv");
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
String *parse = Getattr(p, "tmap:directorin:parse");
if (!parse) {
Setattr(p, "emit:directorinput", "tmpv");
Replaceall(tm, "$input", "tmpv");
Replaceall(tm, "$owner", "0");
Printv(wrap_args, tm, "\n", NIL);
Printf(wrap_args, "args.append(tmpv);\n");
Putc('O', parse_args);
} else {
Append(parse_args, parse);
Setattr(p, "emit:directorinput", pname);
Replaceall(tm, "$input", pname);
Replaceall(tm, "$owner", "0");
if (Len(tm) == 0)
Append(tm, pname);
}
p = Getattr(p, "tmap:directorin:next");
continue;
} else if (Cmp(ptype, "void")) {
Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number,
"Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(ptype, 0),
SwigType_namestr(c_classname), SwigType_namestr(name));
status = SWIG_NOWRAP;
break;
}
p = nextSibling(p);
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
String *parse = Getattr(p, "tmap:directorin:parse");
if (!parse) {
Setattr(p, "emit:directorinput", "tmpv");
Replaceall(tm, "$input", "tmpv");
Replaceall(tm, "$owner", "0");
Printv(wrap_args, tm, "\n", NIL);
Printf(wrap_args, "args.append(tmpv);\n");
Putc('O', parse_args);
} else {
Append(parse_args, parse);
Setattr(p, "emit:directorinput", pname);
Replaceall(tm, "$input", pname);
Replaceall(tm, "$owner", "0");
if (Len(tm) == 0)
Append(tm, pname);
}
p = Getattr(p, "tmap:directorin:next");
continue;
} else if (Cmp(ptype, "void")) {
Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number,
"Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(ptype, 0),
SwigType_namestr(c_classname), SwigType_namestr(name));
status = SWIG_NOWRAP;
break;
}
p = nextSibling(p);
}
String *method_name = Getattr(n, "sym:name");
@ -1438,45 +1431,45 @@ public:
// marshal return value
if (!is_void) {
Printf(w->code, "if (out.length()<%d) {\n", outputs);
Printf(w->code, "Swig::DirectorTypeMismatchException::raise(\"Octave "
"method %s.%s failed to return the required number " "of arguments.\");\n", classname, method_name);
Printf(w->code, "}\n");
Printf(w->code, "if (out.length()<%d) {\n", outputs);
Printf(w->code, "Swig::DirectorTypeMismatchException::raise(\"Octave "
"method %s.%s failed to return the required number " "of arguments.\");\n", classname, method_name);
Printf(w->code, "}\n");
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
if (tm != 0) {
char temp[24];
sprintf(temp, "out(%d)", idx);
Replaceall(tm, "$input", temp);
// Replaceall(tm, "$argnum", temp);
Replaceall(tm, "$disown", Getattr(n, "wrap:disown") ? "SWIG_POINTER_DISOWN" : "0");
if (Getattr(n, "tmap:directorout:implicitconv")) {
Replaceall(tm, "$implicitconv", get_implicitconv_flag(n));
}
Replaceall(tm, "$result", "c_result");
Printv(w->code, tm, "\n", NIL);
Delete(tm);
} else {
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
"Unable to use return type %s in director method %s::%s (skipping method).\n",
SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
status = SWIG_ERROR;
}
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
if (tm != 0) {
char temp[24];
sprintf(temp, "out(%d)", idx);
Replaceall(tm, "$input", temp);
// Replaceall(tm, "$argnum", temp);
Replaceall(tm, "$disown", Getattr(n, "wrap:disown") ? "SWIG_POINTER_DISOWN" : "0");
if (Getattr(n, "tmap:directorout:implicitconv")) {
Replaceall(tm, "$implicitconv", get_implicitconv_flag(n));
}
Replaceall(tm, "$result", "c_result");
Printv(w->code, tm, "\n", NIL);
Delete(tm);
} else {
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
"Unable to use return type %s in director method %s::%s (skipping method).\n",
SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
status = SWIG_ERROR;
}
}
idx++;
// marshal outputs
for (p = l; p;) {
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
char temp[24];
sprintf(temp, "out(%d)", idx);
Replaceall(tm, "$result", temp);
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
Printv(w->code, tm, "\n", NIL);
p = Getattr(p, "tmap:directorargout:next");
} else {
p = nextSibling(p);
}
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
char temp[24];
sprintf(temp, "out(%d)", idx);
Replaceall(tm, "$result", temp);
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
Printv(w->code, tm, "\n", NIL);
p = Getattr(p, "tmap:directorargout:next");
} else {
p = nextSibling(p);
}
}
Delete(parse_args);
@ -1486,13 +1479,13 @@ public:
if (!is_void) {
if (!(ignored_method && !pure_virtual)) {
String *rettype = SwigType_str(returntype, 0);
if (!SwigType_isreference(returntype)) {
Printf(w->code, "return (%s) c_result;\n", rettype);
} else {
Printf(w->code, "return (%s) *c_result;\n", rettype);
}
Delete(rettype);
String *rettype = SwigType_str(returntype, 0);
if (!SwigType_isreference(returntype)) {
Printf(w->code, "return (%s) c_result;\n", rettype);
} else {
Printf(w->code, "return (%s) *c_result;\n", rettype);
}
Delete(rettype);
}
}
@ -1506,7 +1499,7 @@ public:
Replaceall(inline_extra_method, name, extra_method_name);
Replaceall(inline_extra_method, ";\n", " {\n ");
if (!is_void)
Printf(inline_extra_method, "return ");
Printf(inline_extra_method, "return ");
String *methodcall = Swig_method_call(super, l);
Printv(inline_extra_method, methodcall, ";\n }\n", NIL);
Delete(methodcall);
@ -1515,10 +1508,10 @@ public:
// emit the director method
if (status == SWIG_OK) {
if (!Getattr(n, "defaultargs")) {
Replaceall(w->code, "$symname", symname);
Wrapper_print(w, f_directors);
Printv(f_directors_h, declaration, NIL);
Printv(f_directors_h, inline_extra_method, NIL);
Replaceall(w->code, "$symname", symname);
Wrapper_print(w, f_directors);
Printv(f_directors_h, declaration, NIL);
Printv(f_directors_h, inline_extra_method, NIL);
}
}
// clean up

View file

@ -834,7 +834,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);
@ -849,7 +849,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);
@ -879,20 +879,20 @@ 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
@ -901,18 +901,18 @@ public:
tab4, tab4, "self.__dict__[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(self, class_type, name):\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, "raise AttributeError(name)\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.
@ -922,19 +922,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);
}
@ -1686,7 +1686,7 @@ public:
}
// Write the function annotation
if (func_annotation)
Printf(doc, " : '%s'", type_str);
Printf(doc, ": '%s'", type_str);
// Write default value
if (value && !calling) {
@ -2061,7 +2061,7 @@ public:
if (ret)
ret = SwigType_str(ret, 0);
}
return (ret && py3) ? NewStringf(" -> \"%s\" ", ret)
return (ret && py3) ? NewStringf(" -> \"%s\"", ret)
: NewString("");
}
@ -2078,15 +2078,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, tab2), "\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)) {
@ -2203,7 +2203,7 @@ public:
Append(f->code, "--argc;\n");
}
Replaceall(dispatch, "$args", "self,args");
Replaceall(dispatch, "$args", "self, args");
Printv(f->code, dispatch, "\n", NIL);
@ -3950,7 +3950,7 @@ public:
Printv(base_class, bname, NIL);
b = Next(b);
if (b.item) {
Putc(',', base_class);
Printv(base_class, ", ", NIL);
}
}
}
@ -3971,7 +3971,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);
}
@ -4008,7 +4008,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")) {
@ -4019,7 +4019,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);
@ -4107,7 +4107,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) {
@ -4145,12 +4145,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);
}
}
@ -4159,7 +4159,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);
}
}
@ -4274,13 +4274,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, "\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)) {
@ -4366,7 +4364,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))
@ -4378,7 +4376,7 @@ 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);
Printv(f_shadow, tab4, modern ? "" : "if _newclass:\n", tab8, symname, " = staticmethod(", symname, ")\n", NIL);
if (!modern) {
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", symname, "\n", NIL);
@ -4390,7 +4388,7 @@ public:
NIL);
}
if (!classic) {
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname),
Printv(f_shadow, tab4, modern ? "" : "if _newclass:\n", tab8, symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname),
")\n", NIL);
}
}
@ -4479,7 +4477,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))
@ -4490,7 +4488,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);
@ -4576,7 +4574,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;
}
@ -4587,7 +4585,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
@ -4626,9 +4624,9 @@ public:
}
if (!classic) {
if (!assignable) {
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ")\n", NIL);
Printv(f_shadow, tab4, modern ? "" : "if _newclass:\n", tab8, symname, " = _swig_property(", module, ".", getname, ")\n", NIL);
} else {
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ", ", module, ".", setname, ")\n", NIL);
Printv(f_shadow, tab4, modern ? "" : "if _newclass:\n", tab8, symname, " = _swig_property(", module, ".", getname, ", ", module, ".", setname, ")\n", NIL);
}
}
Delete(mname);
@ -4699,9 +4697,9 @@ public:
}
if (!classic && !builtin) {
if (!assignable) {
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ")\n", NIL);
Printv(f_shadow, tab4, modern ? "" : "if _newclass:\n", tab8, symname, " = _swig_property(", module, ".", getname, ")\n", NIL);
} else {
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ", ", module, ".", setname, ")\n", NIL);
Printv(f_shadow, tab4, modern ? "" : "if _newclass:\n", tab8, symname, " = _swig_property(", module, ".", getname, ", ", module, ".", setname, ")\n", NIL);
}
}
String *getter = Getattr(n, "pybuiltin:getter");

View file

@ -667,6 +667,9 @@ class TypePass:private Dispatcher {
/* Normalize types. */
SwigType *ty = Getattr(n, "type");
if (!ty) {
return SWIG_OK;
}
normalize_type(ty);
SwigType *decl = Getattr(n, "decl");
if (decl) {