Merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12733 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
e48855bfbf
60 changed files with 1099 additions and 545 deletions
|
|
@ -3990,7 +3990,7 @@ public:
|
|||
|
||||
Printf(w->code, "jenv->%s(Swig::jclass_%s, Swig::director_methids[%s], %s);\n", methop, imclass_name, methid, jupcall_args);
|
||||
|
||||
Printf(w->code, "if (jenv->ExceptionOccurred()) return $null;\n");
|
||||
Printf(w->code, "if (jenv->ExceptionCheck() == JNI_TRUE) return $null;\n");
|
||||
|
||||
if (!is_void) {
|
||||
String *jresult_str = NewString("jresult");
|
||||
|
|
|
|||
|
|
@ -15,9 +15,16 @@ char cvsroot_octave_cxx[] = "$Id$";
|
|||
|
||||
#include "swigmod.h"
|
||||
|
||||
static bool global_load = true;
|
||||
static String *global_name = 0;
|
||||
static String *op_prefix = 0;
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
Octave Options (available with -octave)\n\
|
||||
[no additional options]\n\
|
||||
-global - Load all symbols into the global namespace [default]\n\
|
||||
-globals <name> - Set <name> used to access C global variables [default: 'cvar']\n\
|
||||
-noglobal - Do not load all symbols into the global namespace\n\
|
||||
-opprefix <str> - Prefix <str> for global operator functions [default: 'op_']\n\
|
||||
\n";
|
||||
|
||||
|
||||
|
|
@ -65,10 +72,39 @@ public:
|
|||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(usage, stdout);
|
||||
}
|
||||
} else if (strcmp(argv[i], "-global") == 0) {
|
||||
global_load = true;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-noglobal") == 0) {
|
||||
global_load = false;
|
||||
Swig_mark_arg(i);
|
||||
} 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 (!global_name)
|
||||
global_name = NewString("cvar");
|
||||
if (!op_prefix)
|
||||
op_prefix = NewString("op_");
|
||||
|
||||
SWIG_library_directory("octave");
|
||||
Preprocessor_define("SWIGOCTAVE 1", 0);
|
||||
SWIG_config_file("octave.swg");
|
||||
|
|
@ -131,6 +167,11 @@ public:
|
|||
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
|
||||
Printf(f_runtime, "#define SWIG_name %s\n", module);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIG_global_load %s\n", global_load ? "true" : "false");
|
||||
Printf(f_runtime, "#define SWIG_global_name \"%s\"\n", global_name);
|
||||
Printf(f_runtime, "#define SWIG_op_prefix \"%s\"\n", op_prefix);
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
Swig_banner(f_directors_h);
|
||||
|
|
|
|||
|
|
@ -328,6 +328,9 @@ public:
|
|||
if (!prefix)
|
||||
prefix = NewStringEmpty();
|
||||
|
||||
Printf(f_runtime, "#define SWIG_PREFIX \"%s\"\n", prefix);
|
||||
Printf(f_runtime, "#define SWIG_PREFIX_LEN %lu\n", (unsigned long)Len(prefix));
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Swig_banner(f_directors_h);
|
||||
Printf(f_directors_h, "\n");
|
||||
|
|
@ -803,8 +806,8 @@ public:
|
|||
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\", (char *)\"%s\");\n",
|
||||
Swig_class_name(Swig_methodclass(n)), name);
|
||||
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:
|
||||
|
|
@ -1655,7 +1658,7 @@ public:
|
|||
Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke);
|
||||
} else {
|
||||
String *classname = Swig_class_name(current_class);
|
||||
Printf(output, "\t\treturn new %s(%s);\n", classname, invoke);
|
||||
Printf(output, "\t\treturn new %s%s(%s);\n", prefix, classname, invoke);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1682,36 +1685,26 @@ public:
|
|||
if (Cmp(invoke, "$r") != 0)
|
||||
Printf(output, "\t\t$r=%s;\n", invoke);
|
||||
if (Len(ret_types) == 1) {
|
||||
/* If it has an abstract base, then we can't create a new
|
||||
* base object. */
|
||||
int hasabstractbase = 0;
|
||||
Node *bases = Getattr(Swig_methodclass(n), "bases");
|
||||
if (bases) {
|
||||
Iterator i = First(bases);
|
||||
while(i.item) {
|
||||
if (Getattr(i.item, "abstract")) {
|
||||
hasabstractbase = 1;
|
||||
break;
|
||||
}
|
||||
i = Next(i);
|
||||
}
|
||||
/* If d is abstract we can't create a new wrapper type d. */
|
||||
Node * d_class = classLookup(d);
|
||||
int is_abstract = 0;
|
||||
if (Getattr(d_class, "abstract")) {
|
||||
is_abstract = 1;
|
||||
}
|
||||
if (newobject || !hasabstractbase) {
|
||||
/*
|
||||
* _p_Foo -> Foo, _p_ns__Bar -> Bar
|
||||
* TODO: do this in a more elegant way
|
||||
*/
|
||||
if (newobject || !is_abstract) {
|
||||
Printf(output, "\t\tif (is_resource($r)) {\n");
|
||||
if (Getattr(classLookup(Getattr(n, "type")), "module")) {
|
||||
/*
|
||||
* _p_Foo -> Foo, _p_ns__Bar -> Bar
|
||||
* TODO: do this in a more elegant way
|
||||
*/
|
||||
if (Len(prefix) == 0) {
|
||||
Printf(output, "\t\t\t$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n");
|
||||
} else {
|
||||
Printf(output, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix);
|
||||
}
|
||||
Printf(output, "\t\t\tif (!class_exists($c)) {\n");
|
||||
Printf(output, "\t\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name"));
|
||||
Printf(output, "\t\t\t}\n");
|
||||
Printf(output, "\t\t\treturn new $c($r);\n");
|
||||
Printf(output, "\t\t\tif (class_exists($c)) return new $c($r);\n");
|
||||
Printf(output, "\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name"));
|
||||
} else {
|
||||
Printf(output, "\t\t\t$c = new stdClass();\n");
|
||||
Printf(output, "\t\t\t$c->"SWIG_PTR" = $r;\n");
|
||||
|
|
|
|||
|
|
@ -3233,6 +3233,13 @@ public:
|
|||
Printf(f_init, " builtin_basetype = SWIG_MangledTypeQuery(\"%s\");\n", base_mname);
|
||||
Printv(f_init, " if (builtin_basetype && builtin_basetype->clientdata && ((SwigPyClientData*) builtin_basetype->clientdata)->pytype) {\n", NIL);
|
||||
Printv(f_init, " builtin_bases[builtin_base_count++] = ((SwigPyClientData*) builtin_basetype->clientdata)->pytype;\n", NIL);
|
||||
Printv(f_init, " } else {\n", NIL);
|
||||
Printf(f_init, " PyErr_SetString(PyExc_TypeError, \"Could not create type '%s' as base '%s' has not been initialized.\\n\");\n", symname, bname);
|
||||
Printv(f_init, "#if PY_VERSION_HEX >= 0x03000000\n", NIL);
|
||||
Printv(f_init, " return NULL;\n", NIL);
|
||||
Printv(f_init, "#else\n", NIL);
|
||||
Printv(f_init, " return;\n", NIL);
|
||||
Printv(f_init, "#endif\n", NIL);
|
||||
Printv(f_init, " }\n", NIL);
|
||||
Delete(base_name);
|
||||
Delete(base_mname);
|
||||
|
|
@ -3538,7 +3545,7 @@ public:
|
|||
Printf(f, "SWIGINTERN SwigPyClientData %s_clientdata = {%s, 0, 0, 0, 0, 0, (PyTypeObject *)&%s_type};\n\n", templ, clientdata_klass, templ);
|
||||
|
||||
Printv(f_init, " if (PyType_Ready(builtin_pytype) < 0) {\n", NIL);
|
||||
Printf(f_init, " PyErr_SetString(PyExc_TypeError, \"Couldn't create type '%s'\");\n", symname);
|
||||
Printf(f_init, " PyErr_SetString(PyExc_TypeError, \"Could not create type '%s'.\");\n", symname);
|
||||
Printv(f_init, "#if PY_VERSION_HEX >= 0x03000000\n", NIL);
|
||||
Printv(f_init, " return NULL;\n", NIL);
|
||||
Printv(f_init, "#else\n", NIL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue