Another merge with master.

Change Doxygen error codes to start at 740 instead of at 720 as the latter was
taken by Scilab in the meanwhile.

Resolve conflicts in autodoc_runme.py once again.
This commit is contained in:
Vadim Zeitlin 2015-02-16 23:46:39 +01:00
commit 300ccce46c
419 changed files with 18675 additions and 1315 deletions

View file

@ -914,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);

View file

@ -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);

File diff suppressed because it is too large Load diff

View file

@ -1300,13 +1300,13 @@ public:
char *name = GetChar(n, "name");
char *iname = GetChar(n, "sym:name");
SwigType *type = Getattr(n, "type");
String *value = Getattr(n, "value");
String *rawval = Getattr(n, "rawval");
String *value = rawval ? rawval : Getattr(n, "value");
int constasvar = GetFlag(n, "feature:constasvar");
String *proc_name;
String *var_name;
String *rvalue;
Wrapper *f;
SwigType *nctype;
String *tm;
@ -1334,23 +1334,14 @@ public:
}
// See if there's a typemap
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
if (SwigType_type(nctype) == T_STRING) {
rvalue = NewStringf("\"%s\"", value);
} else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) {
rvalue = NewStringf("\'%s\'", value);
} else {
rvalue = NewString(value);
}
if ((tm = Swig_typemap_lookup("constant", n, name, 0))) {
Replaceall(tm, "$source", rvalue);
Replaceall(tm, "$value", rvalue);
Replaceall(tm, "$source", value);
Replaceall(tm, "$value", value);
Replaceall(tm, "$target", name);
Printv(f_header, tm, "\n", NIL);
} else {
// Create variable and assign it a value
Printf(f_header, "static %s = (%s)(%s);\n", SwigType_str(type, var_name), SwigType_str(type, 0), rvalue);
Printf(f_header, "static %s = (%s)(%s);\n", SwigType_str(type, var_name), SwigType_str(type, 0), value);
}
{
/* Hack alert: will cleanup later -- Dave */
@ -1370,7 +1361,6 @@ public:
Delete(var_name);
Delete(nctype);
Delete(proc_name);
Delete(rvalue);
DelWrapper(f);
return SWIG_OK;
}

View file

@ -1078,26 +1078,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);

View file

@ -1792,6 +1792,7 @@ int JSCEmitter::emitNamespaces() {
namespace_definition.replace("$jsglobalvariables", variables)
.replace("$jsglobalfunctions", functions)
.replace("$jsnspace", name_mangled)
.replace("$jsmangledname", name_mangled)
.pretty_print(f_wrap_cpp);
Template t_createNamespace(getTemplate("jsc_nspace_definition"));

View file

@ -63,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\
@ -80,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\
@ -87,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\
@ -101,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\
@ -120,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\
@ -678,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);
@ -851,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;
}

View file

@ -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))) {

View file

@ -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);

View file

@ -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);

View file

@ -1996,8 +1996,8 @@ public:
Printf(f_directors_h, " return (iv != swig_inner.end() ? iv->second : false);\n");
Printf(f_directors_h, " }\n");
Printf(f_directors_h, " void swig_set_inner(const char *swig_protected_method_name, bool val) const {\n");
Printf(f_directors_h, " swig_inner[swig_protected_method_name] = val;\n");
Printf(f_directors_h, " void swig_set_inner(const char *swig_protected_method_name, bool swig_val) const {\n");
Printf(f_directors_h, " swig_inner[swig_protected_method_name] = swig_val;\n");
Printf(f_directors_h, " }\n");
Printf(f_directors_h, "private:\n");
Printf(f_directors_h, " mutable std::map<std::string, bool> swig_inner;\n");

View file

@ -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) {

View file

@ -17,6 +17,8 @@
static int treduce = SWIG_cparse_template_reduce(0);
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <sstream>
#include "../DoxygenTranslator/src/PyDocConverter.h"
@ -898,7 +900,17 @@ public:
#else
tab4, "if (not static):\n",
#endif
tab4, tab4, "object.__setattr__(self, name, value)\n",
NIL);
if (!classic) {
if (!modern)
Printv(f_shadow, tab4, tab4, "if _newclass:\n", tab4, NIL);
Printv(f_shadow, tab4, tab4, "object.__setattr__(self, name, value)\n", NIL);
if (!modern)
Printv(f_shadow, tab4, tab4, "else:\n", tab4, NIL);
}
if (classic || !modern)
Printv(f_shadow, tab4, tab4, "self.__dict__[name] = value\n", NIL);
Printv(f_shadow,
tab4, "else:\n",
tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n\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);
@ -1878,20 +1890,133 @@ 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 or a
* constant. Return NIL if it isn't.
* ------------------------------------------------------------ */
String *convertValue(String *v, SwigType *t) {
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 (*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);
}
// 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)
@ -1899,12 +2024,15 @@ public:
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 is perfectly
// representable in Python.
Node *lookup = Swig_symbol_clookup(v, 0);
if (lookup) {
if (Cmp(Getattr(lookup, "nodeType"), "enumitem") == 0)
return Getattr(lookup, "sym:name");
// 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;
@ -1920,27 +2048,34 @@ public:
* at C++ code level where they can always be handled.
* ------------------------------------------------------------ */
bool is_representable_as_pyargs(Node *n) {
bool is_representable = true;
ParmList *plist = CopyParmList(Getattr(n, "parms"));
Parm *p;
Parm *pnext;
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);
}
if (String *value = Getattr(p, "value")) {
String *type = Getattr(p, "type");
if (!convertValue(value, type))
return false;
if (!convertValue(value, type)) {
is_representable = false;
break;
}
}
}
return true;
return is_representable;
}
@ -3233,7 +3368,33 @@ 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);
Printf(f_wrappers, tab2 "PyObject *d;\n");
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 "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;
}
@ -3255,6 +3416,8 @@ public:
}
if (f_s) {
Printv(f_s, "\n",NIL);
Printv(f_s, module, ".", iname, "_swigconstant(",module,")\n", NIL);
Printv(f_s, iname, " = ", module, ".", iname, "\n", NIL);
if (have_docstring(n))
Printv(f_s, docstring(n, AUTODOC_CONST), "\n", NIL);
@ -3421,8 +3584,8 @@ public:
Printf(f_directors_h, " return (iv != swig_inner.end() ? iv->second : false);\n");
Printf(f_directors_h, " }\n");
Printf(f_directors_h, " void swig_set_inner(const char *swig_protected_method_name, bool val) const {\n");
Printf(f_directors_h, " swig_inner[swig_protected_method_name] = val;\n");
Printf(f_directors_h, " void swig_set_inner(const char *swig_protected_method_name, bool swig_val) const {\n");
Printf(f_directors_h, " swig_inner[swig_protected_method_name] = swig_val;\n");
Printf(f_directors_h, " }\n");
Printf(f_directors_h, "private:\n");
Printf(f_directors_h, " mutable std::map<std::string, bool> swig_inner;\n");

1122
Source/Modules/scilab.cxx Normal file

File diff suppressed because it is too large Load diff

View file

@ -49,6 +49,7 @@ extern "C" {
Language *swig_cffi(void);
Language *swig_uffi(void);
Language *swig_r(void);
Language *swig_scilab(void);
Language *swig_go(void);
Language *swig_d(void);
Language *swig_javascript(void);
@ -89,6 +90,7 @@ static swig_module modules[] = {
{"-python", swig_python, "Python"},
{"-r", swig_r, "R (aka GNU S)"},
{"-ruby", swig_ruby, "Ruby"},
{"-scilab", swig_scilab, "Scilab"},
{"-sexp", swig_sexp, "Lisp S-Expressions"},
{"-tcl", swig_tcl, "Tcl"},
{"-tcl8", swig_tcl, 0},
@ -180,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");