Octave: whitespace/indentation cleanup of octave.cxx

This commit is contained in:
Karl Wette 2014-05-21 22:31:36 +02:00
commit ebe1338015

View file

@ -75,50 +75,50 @@ public:
constructor_name(0), constructor_name(0),
docs(0) docs(0)
{ {
/* Add code to manage protected constructors and directors */ /* Add code to manage protected constructors and directors */
director_prot_ctor_code = NewString(""); director_prot_ctor_code = NewString("");
Printv(director_prot_ctor_code, Printv(director_prot_ctor_code,
"if ( $comparison ) { /* subclassed */\n", "if ( $comparison ) { /* subclassed */\n",
" $director_new \n", " $director_new \n",
"} else {\n", " error(\"accessing abstract class or protected constructor\"); \n", " SWIG_fail;\n", "}\n", NIL); "} else {\n", " error(\"accessing abstract class or protected constructor\"); \n", " SWIG_fail;\n", "}\n", NIL);
enable_cplus_runtime_mode(); enable_cplus_runtime_mode();
allow_overloading(); allow_overloading();
director_multiple_inheritance = 1; director_multiple_inheritance = 1;
director_language = 1; director_language = 1;
docs = NewHash(); docs = NewHash();
} }
virtual void main(int argc, char *argv[]) { virtual void main(int argc, char *argv[]) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
if (argv[i]) { if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) { if (strcmp(argv[i], "-help") == 0) {
fputs(usage, stdout); fputs(usage, stdout);
} else if (strcmp(argv[i], "-global") == 0 || } else if (strcmp(argv[i], "-global") == 0 ||
strcmp(argv[i], "-noglobal") == 0) { strcmp(argv[i], "-noglobal") == 0) {
Printv(stderr, Printv(stderr,
"*** -global/-noglobal are no longer supported\n" "*** -global/-noglobal are no longer supported\n"
"*** global load behaviour is now determined at module load\n" "*** global load behaviour is now determined at module load\n"
"*** see the Perl section in the manual for details.\n", NIL); "*** see the Perl section in the manual for details.\n", NIL);
SWIG_exit(EXIT_FAILURE); SWIG_exit(EXIT_FAILURE);
} else if (strcmp(argv[i], "-globals") == 0) { } else if (strcmp(argv[i], "-globals") == 0) {
if (argv[i + 1]) { if (argv[i + 1]) {
global_name = NewString(argv[i + 1]); global_name = NewString(argv[i + 1]);
Swig_mark_arg(i); Swig_mark_arg(i);
Swig_mark_arg(i + 1); Swig_mark_arg(i + 1);
i++; i++;
} else { } else {
Swig_arg_error(); Swig_arg_error();
} }
} else if (strcmp(argv[i], "-opprefix") == 0) { } else if (strcmp(argv[i], "-opprefix") == 0) {
if (argv[i + 1]) { if (argv[i + 1]) {
op_prefix = NewString(argv[i + 1]); op_prefix = NewString(argv[i + 1]);
Swig_mark_arg(i); Swig_mark_arg(i);
Swig_mark_arg(i + 1); Swig_mark_arg(i + 1);
i++; i++;
} else { } else {
Swig_arg_error(); Swig_arg_error();
} }
} }
} }
} }
@ -143,21 +143,21 @@ public:
{ {
Node *mod = Getattr(n, "module"); Node *mod = Getattr(n, "module");
if (mod) { if (mod) {
Node *options = Getattr(mod, "options"); Node *options = Getattr(mod, "options");
if (options) { if (options) {
int dirprot = 0; int dirprot = 0;
if (Getattr(options, "dirprot")) { if (Getattr(options, "dirprot")) {
dirprot = 1; dirprot = 1;
} }
if (Getattr(options, "nodirprot")) { if (Getattr(options, "nodirprot")) {
dirprot = 0; dirprot = 0;
} }
if (Getattr(options, "directors")) { if (Getattr(options, "directors")) {
allow_directors(); allow_directors();
if (dirprot) if (dirprot)
allow_dirprot(); allow_dirprot();
} }
} }
} }
} }
@ -202,8 +202,8 @@ public:
Printf(f_runtime, "#define SWIG_DIRECTORS\n"); Printf(f_runtime, "#define SWIG_DIRECTORS\n");
Swig_banner(f_directors_h); Swig_banner(f_directors_h);
if (dirprot_mode()) { if (dirprot_mode()) {
// Printf(f_directors_h, "#include <map>\n"); // Printf(f_directors_h, "#include <map>\n");
// Printf(f_directors_h, "#include <string>\n\n"); // Printf(f_directors_h, "#include <string>\n\n");
} }
} }
@ -263,19 +263,19 @@ public:
String *r = NewString(""); String *r = NewString("");
for (int j=0;s[j];++j) { for (int j=0;s[j];++j) {
if (s[j] == '\n') { if (s[j] == '\n') {
Append(r, "\\n\\\n"); Append(r, "\\n\\\n");
} else if (s[j] == '\r') { } else if (s[j] == '\r') {
Append(r, "\\r"); Append(r, "\\r");
} else if (s[j] == '\t') { } else if (s[j] == '\t') {
Append(r, "\\t"); Append(r, "\\t");
} else if (s[j] == '\\') { } else if (s[j] == '\\') {
Append(r, "\\\\"); Append(r, "\\\\");
} else if (s[j] == '\'') { } else if (s[j] == '\'') {
Append(r, "\\\'"); Append(r, "\\\'");
} else if (s[j] == '\"') { } else if (s[j] == '\"') {
Append(r, "\\\""); Append(r, "\\\"");
} else } else
Putc(s[j], r); Putc(s[j], r);
} }
return r; return r;
} }
@ -293,11 +293,11 @@ public:
String *escaped_doc_str = texinfo_escape(doc_str); String *escaped_doc_str = texinfo_escape(doc_str);
if (Len(doc_str)>0) { if (Len(doc_str)>0) {
Printf(f_doc,"static const char* %s_texinfo = ",wrap_name); Printf(f_doc,"static const char* %s_texinfo = ",wrap_name);
Printf(f_doc,"\"-*- texinfo -*-\\n\\\n%s", escaped_doc_str); Printf(f_doc,"\"-*- texinfo -*-\\n\\\n%s", escaped_doc_str);
if (Len(decl_info)) if (Len(decl_info))
Printf(f_doc,"\\n\\\n@end deftypefn"); Printf(f_doc,"\\n\\\n@end deftypefn");
Printf(f_doc,"\";\n"); Printf(f_doc,"\";\n");
} }
Delete(escaped_doc_str); Delete(escaped_doc_str);
@ -360,11 +360,11 @@ public:
SwigType *type = Getattr(n, "type"); SwigType *type = Getattr(n, "type");
if (type && Strcmp(type, "void")) { if (type && Strcmp(type, "void")) {
Node *nn = classLookup(Getattr(n, "type")); Node *nn = classLookup(Getattr(n, "type"));
String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
Append(decl_info, "@var{retval} = "); Append(decl_info, "@var{retval} = ");
Printf(args_str, "%s@var{retval} is of type %s. ", args_str, type_str); Printf(args_str, "%s@var{retval} is of type %s. ", args_str, type_str);
Delete(type_str); Delete(type_str);
} }
Append(decl_info, name); Append(decl_info, name);
@ -380,8 +380,8 @@ public:
// strip off {} if necessary // strip off {} if necessary
char *t = Char(str); char *t = Char(str);
if (*t == '{') { if (*t == '{') {
Delitem(str, 0); Delitem(str, 0);
Delitem(str, DOH_END); Delitem(str, DOH_END);
} }
// emit into synopsis section // emit into synopsis section
@ -420,8 +420,8 @@ public:
int i = arg_offset; int i = arg_offset;
while (p) { while (p) {
if (!Getattr(p, "lname")) { if (!Getattr(p, "lname")) {
String *pname = Swig_cparm_name(p, i); String *pname = Swig_cparm_name(p, i);
Delete(pname); Delete(pname);
} }
i++; i++;
p = nextSibling(p); p = nextSibling(p);
@ -444,12 +444,12 @@ public:
String *tm = Getattr(p, "tmap:in"); String *tm = Getattr(p, "tmap:in");
if (tm) { if (tm) {
pnext = Getattr(p, "tmap:in:next"); pnext = Getattr(p, "tmap:in:next");
if (checkAttribute(p, "tmap:in:numinputs", "0")) { if (checkAttribute(p, "tmap:in:numinputs", "0")) {
continue; continue;
} }
} else { } else {
pnext = nextSibling(p); pnext = nextSibling(p);
} }
String *name = 0; String *name = 0;
@ -457,9 +457,9 @@ public:
String *value = 0; String *value = 0;
String *pdoc = Getattr(p, "tmap:doc"); String *pdoc = Getattr(p, "tmap:doc");
if (pdoc) { if (pdoc) {
name = Getattr(p, "tmap:doc:name"); name = Getattr(p, "tmap:doc:name");
type = Getattr(p, "tmap:doc:type"); type = Getattr(p, "tmap:doc:type");
value = Getattr(p, "tmap:doc:value"); value = Getattr(p, "tmap:doc:value");
} }
// Note: the generated name should be consistent with that in kwnames[] // Note: the generated name should be consistent with that in kwnames[]
@ -471,28 +471,28 @@ public:
value = value ? value : Getattr(p, "value"); value = value ? value : Getattr(p, "value");
if (SwigType_isvarargs(type)) if (SwigType_isvarargs(type))
break; break;
String *tex_name = NewString(""); String *tex_name = NewString("");
if (name) if (name)
Printf(tex_name, "@var{%s}", name); Printf(tex_name, "@var{%s}", name);
else else
Printf(tex_name, "@var{?}"); Printf(tex_name, "@var{?}");
if (Len(decl_str)) if (Len(decl_str))
Append(decl_str, ", "); Append(decl_str, ", ");
Append(decl_str, tex_name); Append(decl_str, tex_name);
if (value) { if (value) {
String *new_value = convertValue(value, Getattr(p, "type")); String *new_value = convertValue(value, Getattr(p, "type"));
if (new_value) { if (new_value) {
value = new_value; value = new_value;
} else { } else {
Node *lookup = Swig_symbol_clookup(value, 0); Node *lookup = Swig_symbol_clookup(value, 0);
if (lookup) if (lookup)
value = Getattr(lookup, "sym:name"); value = Getattr(lookup, "sym:name");
} }
Printf(decl_str, " = %s", value); Printf(decl_str, " = %s", value);
} }
Node *nn = classLookup(Getattr(p, "type")); Node *nn = classLookup(Getattr(p, "type"));
@ -517,18 +517,18 @@ public:
if (v && Len(v) > 0) { if (v && Len(v) > 0) {
char fc = (Char(v))[0]; char fc = (Char(v))[0];
if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) { if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) {
/* number or string (or maybe NULL pointer) */ /* number or string (or maybe NULL pointer) */
if (SwigType_ispointer(t) && Strcmp(v, "0") == 0) if (SwigType_ispointer(t) && Strcmp(v, "0") == 0)
return NewString("None"); return NewString("None");
else else
return v; return v;
} }
if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0) 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) if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
return NewString("true"); return NewString("true");
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
return NewString("false"); return NewString("false");
} }
return 0; return 0;
} }
@ -573,88 +573,88 @@ public:
char source[64]; char source[64];
Printf(f->code, "if (!SWIG_check_num_args(\"%s\",args.length(),%i,%i,%i)) " 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); "{\n SWIG_fail;\n }\n", iname, num_arguments, num_required, varargs);
if (constructor && num_arguments == 1 && num_required == 1) { if (constructor && num_arguments == 1 && num_required == 1) {
if (Cmp(storage, "explicit") == 0) { if (Cmp(storage, "explicit") == 0) {
Node *parent = Swig_methodclass(n); Node *parent = Swig_methodclass(n);
if (GetFlag(parent, "feature:implicitconv")) { if (GetFlag(parent, "feature:implicitconv")) {
String *desc = NewStringf("SWIGTYPE%s", SwigType_manglestr(Getattr(n, "type"))); String *desc = NewStringf("SWIGTYPE%s", SwigType_manglestr(Getattr(n, "type")));
Printf(f->code, "if (SWIG_CheckImplicit(%s)) SWIG_fail;\n", desc); Printf(f->code, "if (SWIG_CheckImplicit(%s)) SWIG_fail;\n", desc);
Delete(desc); Delete(desc);
} }
} }
} }
for (j = 0, p = l; j < num_arguments; ++j) { for (j = 0, p = l; j < num_arguments; ++j) {
while (checkAttribute(p, "tmap:in:numinputs", "0")) { while (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next"); p = Getattr(p, "tmap:in:next");
} }
SwigType *pt = Getattr(p, "type"); SwigType *pt = Getattr(p, "type");
String *tm = Getattr(p, "tmap:in"); String *tm = Getattr(p, "tmap:in");
if (tm) { if (tm) {
if (!tm || checkAttribute(p, "tmap:in:numinputs", "0")) { if (!tm || checkAttribute(p, "tmap:in:numinputs", "0")) {
p = nextSibling(p); p = nextSibling(p);
continue; continue;
} }
sprintf(source, "args(%d)", j); sprintf(source, "args(%d)", j);
Setattr(p, "emit:input", source); Setattr(p, "emit:input", source);
Replaceall(tm, "$source", Getattr(p, "emit:input")); Replaceall(tm, "$source", Getattr(p, "emit:input"));
Replaceall(tm, "$input", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input"));
Replaceall(tm, "$target", Getattr(p, "lname")); Replaceall(tm, "$target", Getattr(p, "lname"));
if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) { if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) {
Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN");
} else { } else {
Replaceall(tm, "$disown", "0"); Replaceall(tm, "$disown", "0");
} }
if (Getattr(p, "tmap:in:implicitconv")) { if (Getattr(p, "tmap:in:implicitconv")) {
const char *convflag = "0"; const char *convflag = "0";
if (!Getattr(p, "hidden")) { if (!Getattr(p, "hidden")) {
SwigType *ptype = Getattr(p, "type"); SwigType *ptype = Getattr(p, "type");
convflag = get_implicitconv_flag(classLookup(ptype)); convflag = get_implicitconv_flag(classLookup(ptype));
} }
Replaceall(tm, "$implicitconv", convflag); Replaceall(tm, "$implicitconv", convflag);
Setattr(p, "implicitconv", convflag); Setattr(p, "implicitconv", convflag);
} }
String *getargs = NewString(""); String *getargs = NewString("");
if (j >= num_required) if (j >= num_required)
Printf(getargs, "if (%d<args.length()) {\n%s\n}", j, tm); Printf(getargs, "if (%d<args.length()) {\n%s\n}", j, tm);
else else
Printv(getargs, tm, NIL); Printv(getargs, tm, NIL);
Printv(f->code, getargs, "\n", NIL); Printv(f->code, getargs, "\n", NIL);
Delete(getargs); Delete(getargs);
p = Getattr(p, "tmap:in:next"); p = Getattr(p, "tmap:in:next");
continue; continue;
} else { } 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)); 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; break;
} }
} }
// Check for trailing varargs // Check for trailing varargs
if (varargs) { if (varargs) {
if (p && (tm = Getattr(p, "tmap:in"))) { if (p && (tm = Getattr(p, "tmap:in"))) {
Replaceall(tm, "$input", "varargs"); Replaceall(tm, "$input", "varargs");
Printv(f->code, tm, "\n", NIL); Printv(f->code, tm, "\n", NIL);
} }
} }
// Insert constraint checking code // Insert constraint checking code
for (p = l; p;) { for (p = l; p;) {
if ((tm = Getattr(p, "tmap:check"))) { if ((tm = Getattr(p, "tmap:check"))) {
Replaceall(tm, "$target", Getattr(p, "lname")); Replaceall(tm, "$target", Getattr(p, "lname"));
Printv(f->code, tm, "\n", NIL); Printv(f->code, tm, "\n", NIL);
p = Getattr(p, "tmap:check:next"); p = Getattr(p, "tmap:check:next");
} else { } else {
p = nextSibling(p); p = nextSibling(p);
} }
} }
@ -662,23 +662,23 @@ public:
String *cleanup = NewString(""); String *cleanup = NewString("");
for (p = l; p;) { for (p = l; p;) {
if ((tm = Getattr(p, "tmap:freearg"))) { if ((tm = Getattr(p, "tmap:freearg"))) {
if (Getattr(p, "tmap:freearg:implicitconv")) { if (Getattr(p, "tmap:freearg:implicitconv")) {
const char *convflag = "0"; const char *convflag = "0";
if (!Getattr(p, "hidden")) { if (!Getattr(p, "hidden")) {
SwigType *ptype = Getattr(p, "type"); SwigType *ptype = Getattr(p, "type");
convflag = get_implicitconv_flag(classLookup(ptype)); convflag = get_implicitconv_flag(classLookup(ptype));
} }
if (strcmp(convflag, "0") == 0) { if (strcmp(convflag, "0") == 0) {
tm = 0; tm = 0;
} }
} }
if (tm && (Len(tm) != 0)) { if (tm && (Len(tm) != 0)) {
Replaceall(tm, "$source", Getattr(p, "lname")); Replaceall(tm, "$source", Getattr(p, "lname"));
Printv(cleanup, tm, "\n", NIL); Printv(cleanup, tm, "\n", NIL);
} }
p = Getattr(p, "tmap:freearg:next"); p = Getattr(p, "tmap:freearg:next");
} else { } else {
p = nextSibling(p); p = nextSibling(p);
} }
} }
@ -686,15 +686,15 @@ public:
String *outarg = NewString(""); String *outarg = NewString("");
for (p = l; p;) { for (p = l; p;) {
if ((tm = Getattr(p, "tmap:argout"))) { if ((tm = Getattr(p, "tmap:argout"))) {
Replaceall(tm, "$source", Getattr(p, "lname")); Replaceall(tm, "$source", Getattr(p, "lname"));
Replaceall(tm, "$target", "_outp"); Replaceall(tm, "$target", "_outp");
Replaceall(tm, "$result", "_outp"); Replaceall(tm, "$result", "_outp");
Replaceall(tm, "$arg", Getattr(p, "emit:input")); Replaceall(tm, "$arg", Getattr(p, "emit:input"));
Replaceall(tm, "$input", Getattr(p, "emit:input")); Replaceall(tm, "$input", Getattr(p, "emit:input"));
Printv(outarg, tm, "\n", NIL); Printv(outarg, tm, "\n", NIL);
p = Getattr(p, "tmap:argout:next"); p = Getattr(p, "tmap:argout:next");
} else { } else {
p = nextSibling(p); p = nextSibling(p);
} }
} }
@ -720,9 +720,9 @@ public:
Replaceall(tm, "$result", "_outv"); Replaceall(tm, "$result", "_outv");
if (GetFlag(n, "feature:new")) if (GetFlag(n, "feature:new"))
Replaceall(tm, "$owner", "1"); Replaceall(tm, "$owner", "1");
else else
Replaceall(tm, "$owner", "0"); Replaceall(tm, "$owner", "0");
Printf(f->code, "%s\n", tm); Printf(f->code, "%s\n", tm);
Printf(f->code, "if (_outv.is_defined()) _outp = " "SWIG_Octave_AppendOutput(_outp, _outv);\n"); Printf(f->code, "if (_outv.is_defined()) _outp = " "SWIG_Octave_AppendOutput(_outp, _outv);\n");
@ -737,8 +737,8 @@ public:
if (GetFlag(n, "feature:new")) { if (GetFlag(n, "feature:new")) {
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
Replaceall(tm, "$source", Swig_cresult_name()); Replaceall(tm, "$source", Swig_cresult_name());
Printf(f->code, "%s\n", tm); Printf(f->code, "%s\n", tm);
} }
} }
@ -830,16 +830,16 @@ public:
if (is_assignable(n)) { if (is_assignable(n)) {
Setattr(n, "wrap:name", setname); Setattr(n, "wrap:name", setname);
if ((tm = Swig_typemap_lookup("varin", n, name, 0))) { if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
Replaceall(tm, "$source", "args(0)"); Replaceall(tm, "$source", "args(0)");
Replaceall(tm, "$target", name); Replaceall(tm, "$target", name);
Replaceall(tm, "$input", "args(0)"); Replaceall(tm, "$input", "args(0)");
if (Getattr(n, "tmap:varin:implicitconv")) { if (Getattr(n, "tmap:varin:implicitconv")) {
Replaceall(tm, "$implicitconv", get_implicitconv_flag(n)); Replaceall(tm, "$implicitconv", get_implicitconv_flag(n));
} }
emit_action_code(n, setf->code, tm); emit_action_code(n, setf->code, tm);
Delete(tm); Delete(tm);
} else { } 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"); Append(setf->code, "fail:\n");
Printf(setf->code, "return octave_value_list();\n"); Printf(setf->code, "return octave_value_list();\n");
@ -995,18 +995,18 @@ public:
int index = 0; int index = 0;
b = First(baselist); b = First(baselist);
while (b.item) { while (b.item) {
String *bname = Getattr(b.item, "name"); String *bname = Getattr(b.item, "name");
if ((!bname) || GetFlag(b.item, "feature:ignore") || (!Getattr(b.item, "module"))) { if ((!bname) || GetFlag(b.item, "feature:ignore") || (!Getattr(b.item, "module"))) {
b = Next(b); b = Next(b);
continue; continue;
} }
String *bname_mangled = SwigType_manglestr(SwigType_add_pointer(Copy(bname))); String *bname_mangled = SwigType_manglestr(SwigType_add_pointer(Copy(bname)));
Printf(base_class_names, "\"%s\",", bname_mangled); Printf(base_class_names, "\"%s\",", bname_mangled);
Printf(base_class, "0,"); Printf(base_class, "0,");
b = Next(b); b = Next(b);
index++; index++;
Delete(bname_mangled); Delete(bname_mangled);
} }
} }
@ -1064,7 +1064,7 @@ public:
if (overloaded) if (overloaded)
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END); Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
Printf(s_members_tab, "{\"%s\",%s,0,0,0,%s},\n", Printf(s_members_tab, "{\"%s\",%s,0,0,0,%s},\n",
realname, rname, tname); realname, rname, tname);
Delete(rname); Delete(rname);
Delete(tname); Delete(tname);
} }
@ -1112,7 +1112,7 @@ public:
Delete(name); Delete(name);
Setattr(self, "lname", "self_obj"); Setattr(self, "lname", "self_obj");
if (parms) if (parms)
set_nextSibling(self, parms); set_nextSibling(self, parms);
Setattr(n, "parms", self); Setattr(n, "parms", self);
Setattr(n, "wrap:self", "1"); Setattr(n, "wrap:self", "1");
Setattr(n, "hidden", "1"); Setattr(n, "hidden", "1");
@ -1145,7 +1145,7 @@ public:
if (overloaded) if (overloaded)
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END); Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
Printf(s_members_tab, "{\"%s\",%s,0,0,1,%s},\n", Printf(s_members_tab, "{\"%s\",%s,0,0,1,%s},\n",
realname, rname, tname); realname, rname, tname);
Delete(rname); Delete(rname);
Delete(tname); Delete(tname);
} }
@ -1217,24 +1217,24 @@ public:
if (!Getattr(n, "defaultargs")) { if (!Getattr(n, "defaultargs")) {
// constructor // constructor
{ {
Wrapper *w = NewWrapper(); Wrapper *w = NewWrapper();
String *call; String *call;
String *basetype = Getattr(parent, "classtype"); String *basetype = Getattr(parent, "classtype");
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
call = Swig_csuperclass_call(0, basetype, superparms); call = Swig_csuperclass_call(0, basetype, superparms);
Printf(w->def, "%s::%s: %s," "\nSwig::Director(static_cast<%s*>(this)) { \n", classname, target, call, basetype); Printf(w->def, "%s::%s: %s," "\nSwig::Director(static_cast<%s*>(this)) { \n", classname, target, call, basetype);
Append(w->def, "}\n"); Append(w->def, "}\n");
Delete(target); Delete(target);
Wrapper_print(w, f_directors); Wrapper_print(w, f_directors);
Delete(call); Delete(call);
DelWrapper(w); DelWrapper(w);
} }
// constructor header // constructor header
{ {
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
Printf(f_directors_h, " %s;\n", target); Printf(f_directors_h, " %s;\n", target);
Delete(target); Delete(target);
} }
} }
@ -1250,7 +1250,7 @@ public:
{ {
Wrapper *w = NewWrapper(); Wrapper *w = NewWrapper();
Printf(w->def, "SwigDirector_%s::SwigDirector_%s(void* self) :" 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"); Append(w->def, "}\n");
Wrapper_print(w, f_directors); Wrapper_print(w, f_directors);
DelWrapper(w); DelWrapper(w);
@ -1283,7 +1283,7 @@ public:
if (Cmp(storage, "virtual") == 0) { if (Cmp(storage, "virtual") == 0) {
if (Cmp(value, "0") == 0) { if (Cmp(value, "0") == 0) {
pure_virtual = true; pure_virtual = true;
} }
} }
@ -1317,18 +1317,18 @@ public:
Append(declaration, " throw("); Append(declaration, " throw(");
if (throw_parm_list) 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)) { for (p = throw_parm_list; p; p = nextSibling(p)) {
if (Getattr(p, "tmap:throws")) { if (Getattr(p, "tmap:throws")) {
if (gencomma++) { if (gencomma++) {
Append(w->def, ", "); Append(w->def, ", ");
Append(declaration, ", "); Append(declaration, ", ");
} }
String *str = SwigType_str(Getattr(p, "type"), 0); String *str = SwigType_str(Getattr(p, "type"), 0);
Append(w->def, str); Append(w->def, str);
Append(declaration, str); Append(declaration, str);
Delete(str); Delete(str);
} }
} }
Append(w->def, ")"); Append(w->def, ")");
@ -1343,22 +1343,22 @@ public:
// handle it, including declaration of c_result ($result). // handle it, including declaration of c_result ($result).
if (!is_void) { if (!is_void) {
if (!(ignored_method && !pure_virtual)) { if (!(ignored_method && !pure_virtual)) {
String *cres = SwigType_lstr(returntype, "c_result"); String *cres = SwigType_lstr(returntype, "c_result");
Printf(w->code, "%s;\n", cres); Printf(w->code, "%s;\n", cres);
Delete(cres); Delete(cres);
} }
} }
if (ignored_method) { if (ignored_method) {
if (!pure_virtual) { if (!pure_virtual) {
if (!is_void) if (!is_void)
Printf(w->code, "return "); Printf(w->code, "return ");
String *super_call = Swig_method_call(super, l); String *super_call = Swig_method_call(super, l);
Printf(w->code, "%s;\n", super_call); Printf(w->code, "%s;\n", super_call);
Delete(super_call); Delete(super_call);
} else { } else {
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname), Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname),
SwigType_namestr(name)); SwigType_namestr(name));
} }
} else { } else {
// attach typemaps to arguments (C/C++ -> Python) // attach typemaps to arguments (C/C++ -> Python)
@ -1374,50 +1374,50 @@ public:
int outputs = 0; int outputs = 0;
if (!is_void) if (!is_void)
outputs++; outputs++;
// build argument list and type conversion string // build argument list and type conversion string
p = l; p = l;
while (p) { while (p) {
if (checkAttribute(p, "tmap:in:numinputs", "0")) { if (checkAttribute(p, "tmap:in:numinputs", "0")) {
p = Getattr(p, "tmap:in:next"); p = Getattr(p, "tmap:in:next");
continue; continue;
} }
if (Getattr(p, "tmap:directorargout") != 0) if (Getattr(p, "tmap:directorargout") != 0)
outputs++; outputs++;
String *pname = Getattr(p, "name"); String *pname = Getattr(p, "name");
String *ptype = Getattr(p, "type"); String *ptype = Getattr(p, "type");
Wrapper_add_local(w, "tmpv", "octave_value tmpv"); Wrapper_add_local(w, "tmpv", "octave_value tmpv");
if ((tm = Getattr(p, "tmap:directorin")) != 0) { if ((tm = Getattr(p, "tmap:directorin")) != 0) {
String *parse = Getattr(p, "tmap:directorin:parse"); String *parse = Getattr(p, "tmap:directorin:parse");
if (!parse) { if (!parse) {
Setattr(p, "emit:directorinput", "tmpv"); Setattr(p, "emit:directorinput", "tmpv");
Replaceall(tm, "$input", "tmpv"); Replaceall(tm, "$input", "tmpv");
Replaceall(tm, "$owner", "0"); Replaceall(tm, "$owner", "0");
Printv(wrap_args, tm, "\n", NIL); Printv(wrap_args, tm, "\n", NIL);
Printf(wrap_args, "args.append(tmpv);\n"); Printf(wrap_args, "args.append(tmpv);\n");
Putc('O', parse_args); Putc('O', parse_args);
} else { } else {
Append(parse_args, parse); Append(parse_args, parse);
Setattr(p, "emit:directorinput", pname); Setattr(p, "emit:directorinput", pname);
Replaceall(tm, "$input", pname); Replaceall(tm, "$input", pname);
Replaceall(tm, "$owner", "0"); Replaceall(tm, "$owner", "0");
if (Len(tm) == 0) if (Len(tm) == 0)
Append(tm, pname); Append(tm, pname);
} }
p = Getattr(p, "tmap:directorin:next"); p = Getattr(p, "tmap:directorin:next");
continue; continue;
} else if (Cmp(ptype, "void")) { } else if (Cmp(ptype, "void")) {
Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, 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), "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)); SwigType_namestr(c_classname), SwigType_namestr(name));
status = SWIG_NOWRAP; status = SWIG_NOWRAP;
break; break;
} }
p = nextSibling(p); p = nextSibling(p);
} }
String *method_name = Getattr(n, "sym:name"); String *method_name = Getattr(n, "sym:name");
@ -1438,45 +1438,45 @@ public:
// marshal return value // marshal return value
if (!is_void) { if (!is_void) {
Printf(w->code, "if (out.length()<%d) {\n", outputs); Printf(w->code, "if (out.length()<%d) {\n", outputs);
Printf(w->code, "Swig::DirectorTypeMismatchException::raise(\"Octave " Printf(w->code, "Swig::DirectorTypeMismatchException::raise(\"Octave "
"method %s.%s failed to return the required number " "of arguments.\");\n", classname, method_name); "method %s.%s failed to return the required number " "of arguments.\");\n", classname, method_name);
Printf(w->code, "}\n"); Printf(w->code, "}\n");
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
if (tm != 0) { if (tm != 0) {
char temp[24]; char temp[24];
sprintf(temp, "out(%d)", idx); sprintf(temp, "out(%d)", idx);
Replaceall(tm, "$input", temp); Replaceall(tm, "$input", temp);
// Replaceall(tm, "$argnum", temp); // Replaceall(tm, "$argnum", temp);
Replaceall(tm, "$disown", Getattr(n, "wrap:disown") ? "SWIG_POINTER_DISOWN" : "0"); Replaceall(tm, "$disown", Getattr(n, "wrap:disown") ? "SWIG_POINTER_DISOWN" : "0");
if (Getattr(n, "tmap:directorout:implicitconv")) { if (Getattr(n, "tmap:directorout:implicitconv")) {
Replaceall(tm, "$implicitconv", get_implicitconv_flag(n)); Replaceall(tm, "$implicitconv", get_implicitconv_flag(n));
} }
Replaceall(tm, "$result", "c_result"); Replaceall(tm, "$result", "c_result");
Printv(w->code, tm, "\n", NIL); Printv(w->code, tm, "\n", NIL);
Delete(tm); Delete(tm);
} else { } else {
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
"Unable to use return type %s in director method %s::%s (skipping method).\n", "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)); SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
status = SWIG_ERROR; status = SWIG_ERROR;
} }
} }
idx++; idx++;
// marshal outputs // marshal outputs
for (p = l; p;) { for (p = l; p;) {
if ((tm = Getattr(p, "tmap:directorargout")) != 0) { if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
char temp[24]; char temp[24];
sprintf(temp, "out(%d)", idx); sprintf(temp, "out(%d)", idx);
Replaceall(tm, "$result", temp); Replaceall(tm, "$result", temp);
Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
Printv(w->code, tm, "\n", NIL); Printv(w->code, tm, "\n", NIL);
p = Getattr(p, "tmap:directorargout:next"); p = Getattr(p, "tmap:directorargout:next");
} else { } else {
p = nextSibling(p); p = nextSibling(p);
} }
} }
Delete(parse_args); Delete(parse_args);
@ -1486,13 +1486,13 @@ public:
if (!is_void) { if (!is_void) {
if (!(ignored_method && !pure_virtual)) { if (!(ignored_method && !pure_virtual)) {
String *rettype = SwigType_str(returntype, 0); String *rettype = SwigType_str(returntype, 0);
if (!SwigType_isreference(returntype)) { if (!SwigType_isreference(returntype)) {
Printf(w->code, "return (%s) c_result;\n", rettype); Printf(w->code, "return (%s) c_result;\n", rettype);
} else { } else {
Printf(w->code, "return (%s) *c_result;\n", rettype); Printf(w->code, "return (%s) *c_result;\n", rettype);
} }
Delete(rettype); Delete(rettype);
} }
} }
@ -1506,7 +1506,7 @@ public:
Replaceall(inline_extra_method, name, extra_method_name); Replaceall(inline_extra_method, name, extra_method_name);
Replaceall(inline_extra_method, ";\n", " {\n "); Replaceall(inline_extra_method, ";\n", " {\n ");
if (!is_void) if (!is_void)
Printf(inline_extra_method, "return "); Printf(inline_extra_method, "return ");
String *methodcall = Swig_method_call(super, l); String *methodcall = Swig_method_call(super, l);
Printv(inline_extra_method, methodcall, ";\n }\n", NIL); Printv(inline_extra_method, methodcall, ";\n }\n", NIL);
Delete(methodcall); Delete(methodcall);
@ -1515,10 +1515,10 @@ public:
// emit the director method // emit the director method
if (status == SWIG_OK) { if (status == SWIG_OK) {
if (!Getattr(n, "defaultargs")) { if (!Getattr(n, "defaultargs")) {
Replaceall(w->code, "$symname", symname); Replaceall(w->code, "$symname", symname);
Wrapper_print(w, f_directors); Wrapper_print(w, f_directors);
Printv(f_directors_h, declaration, NIL); Printv(f_directors_h, declaration, NIL);
Printv(f_directors_h, inline_extra_method, NIL); Printv(f_directors_h, inline_extra_method, NIL);
} }
} }
// clean up // clean up