merge from trunk

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11821 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Baozeng Ding 2010-01-11 00:59:12 +00:00
commit d8a371808a
190 changed files with 5425 additions and 2040 deletions

View file

@ -1900,14 +1900,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n",
Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s(%s) ignored. Method %s(%s) const at %s:%d used.\n",
Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms),
Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
@ -1916,14 +1917,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n",
Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s(%s) const ignored. Method %s(%s) at %s:%d used.\n",
Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms),
Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
@ -1937,15 +1939,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s is shadowed by %s at %s:%d.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
nodes[j].error = 1;
}

View file

@ -518,7 +518,7 @@ class Allocate:public Dispatcher {
*/
String *scatchlist = Getattr(n, "feature:catches");
if (scatchlist) {
catchlist = Swig_cparse_parms(scatchlist);
catchlist = Swig_cparse_parms(scatchlist, n);
if (catchlist) {
Setattr(n, "catchlist", catchlist);
mark_exception_classes(catchlist);

View file

@ -618,12 +618,12 @@ int CFFI::enumDeclaration(Node *n) {
slot_name_keywords = true;
//Registering the enum name to the cin and cout typemaps
Parm *pattern = NewParm(name, NULL);
Parm *pattern = NewParm(name, NULL, n);
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
Delete(pattern);
//Registering with the kind, i.e., enum
pattern = NewParm(NewStringf("enum %s", name), NULL);
pattern = NewParm(NewStringf("enum %s", name), NULL, n);
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
Delete(pattern);
@ -688,7 +688,7 @@ void CFFI::emit_class(Node *n) {
Printf(f_clos, "\n(cl:defclass %s%s", lisp_name, supers);
Printf(f_clos, "\n ((ff-pointer :reader ff-pointer)))\n\n");
Parm *pattern = NewParm(Getattr(n, "name"), NULL);
Parm *pattern = NewParm(Getattr(n, "name"), NULL, n);
Swig_typemap_register("lispclass", pattern, lisp_name, NULL, NULL);
SwigType_add_pointer(Getattr(pattern, "type"));
@ -758,7 +758,7 @@ void CFFI::emit_class(Node *n) {
Delete(supers);
// Delete(ns_list);
// Parm *pattern = NewParm(name,NULL);
// Parm *pattern = NewParm(name, NULL, n);
// Swig_typemap_register("cin",pattern,lisp_name,NULL,NULL);
//Swig_typemap_register("cout",pattern,lisp_name,NULL,NULL);
//Delete(pattern);
@ -787,12 +787,12 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
//Register the struct/union name to the cin and cout typemaps
Parm *pattern = NewParm(name, NULL);
Parm *pattern = NewParm(name, NULL, n);
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
Delete(pattern);
//Registering with the kind, i.e., struct or union
pattern = NewParm(NewStringf("%s %s", kind, name), NULL);
pattern = NewParm(NewStringf("%s %s", kind, name), NULL, n);
Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL);
Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL);
Delete(pattern);

View file

@ -452,7 +452,7 @@ String *CLISP::get_ffi_type(Node *n, SwigType *ty) {
SwigType *cp = Copy(ty);
SwigType *fn = SwigType_pop_function(cp);
String *args = NewString("");
ParmList *pl = SwigType_function_parms(fn);
ParmList *pl = SwigType_function_parms(fn, n);
if (ParmList_len(pl) != 0) {
Printf(args, "(:arguments ");
}

View file

@ -86,13 +86,6 @@ class CSHARP:public Language {
enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum };
static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) {
Parm *p = NewParm(type, name);
Setfile(p, Getfile(n));
Setline(p, Getline(n));
return p;
}
public:
/* -----------------------------------------------------------------------------
@ -1211,6 +1204,9 @@ public:
String *symname = Getattr(n, "sym:name");
String *value = Getattr(n, "value");
String *name = Getattr(n, "name");
Node *parent = parentNode(n);
int unnamedinstance = GetFlag(parent, "unnamedinstance");
String *parent_name = Getattr(parent, "name");
String *tmpValue;
// Strange hack from parent method
@ -1222,13 +1218,18 @@ public:
Setattr(n, "value", tmpValue);
{
EnumFeature enum_feature = decodeEnumFeature(parentNode(n));
EnumFeature enum_feature = decodeEnumFeature(parent);
const String *csattributes = Getattr(n, "feature:cs:attributes");
if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
// Wrap (non-anonymous) C/C++ enum with a proper C# enum
// Emit the enum item.
if (!GetFlag(n, "firstenumitem"))
Printf(enum_code, ",\n");
if (csattributes)
Printf(enum_code, " %s\n", csattributes);
Printf(enum_code, " %s", symname);
// Check for the %csconstvalue feature
@ -1241,21 +1242,19 @@ public:
}
} else {
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
const String *parent_name = Getattr(parentNode(n), "name");
String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int");
String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */
SwigType *typemap_lookup_type = parent_name ? parent_name : type;
const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF);
String *return_type = Copy(tm);
Delete(typemap_lookup_type);
typemap_lookup_type = NULL;
// The %csconst feature determines how the constant value is obtained
int const_feature_flag = GetFlag(n, "feature:cs:const");
const String *methodmods = Getattr(n, "feature:cs:methodmodifiers");
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
if ((enum_feature == TypesafeEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
// Wrap (non-anonymouse) enum using the typesafe enum pattern
if (csattributes)
Printf(enum_code, " %s\n", csattributes);
if ((enum_feature == TypesafeEnum) && parent_name && !unnamedinstance) {
// Wrap (non-anonymous) enum using the typesafe enum pattern
if (Getattr(n, "enumvalue")) {
String *value = enumValue(n);
Printf(enum_code, " %s static readonly %s %s = new %s(\"%s\", %s);\n", methodmods, return_type, symname, return_type, symname, value);
@ -1267,6 +1266,10 @@ public:
// Simple integer constants
// Note these are always generated for anonymous enums, no matter what enum_feature is specified
// Code generated is the same for SimpleEnum and TypeunsafeEnum -> the class it is generated into is determined later
// The %csconst feature determines how the constant value is obtained
int const_feature_flag = GetFlag(n, "feature:cs:const");
const char *const_readonly = const_feature_flag ? "const" : "static readonly";
String *value = enumValue(n);
Printf(enum_code, " %s %s %s %s = %s;\n", methodmods, const_readonly, return_type, symname, value);
@ -1275,9 +1278,9 @@ public:
}
// Add the enum value to the comma separated list being constructed in the enum declaration.
String *enumvalues = Getattr(parentNode(n), "enumvalues");
String *enumvalues = Getattr(parent, "enumvalues");
if (!enumvalues)
Setattr(parentNode(n), "enumvalues", Copy(symname));
Setattr(parent, "enumvalues", Copy(symname));
else
Printv(enumvalues, ", ", symname, NIL);
}
@ -1384,7 +1387,14 @@ public:
enum_constant_flag = false;
} else {
// Alternative constant handling will use the C syntax to make a true C# constant and hope that it compiles as C# code
Printf(constants_code, "%s;\n", Getattr(n, "value"));
if (Getattr(n, "wrappedasconstant")) {
if (SwigType_type(t) == T_CHAR)
Printf(constants_code, "\'%s\';\n", Getattr(n, "staticmembervariableHandler:value"));
else
Printf(constants_code, "%s;\n", Getattr(n, "staticmembervariableHandler:value"));
} else {
Printf(constants_code, "%s;\n", Getattr(n, "value"));
}
}
// Emit the generated code to appropriate place
@ -3314,7 +3324,7 @@ public:
}
/* Create the intermediate class wrapper */
Parm *tp = NewParmFromNode(returntype, empty_str, n);
Parm *tp = NewParm(returntype, empty_str, n);
tm = Swig_typemap_lookup("imtype", tp, "", 0);
if (tm) {
@ -3334,7 +3344,7 @@ public:
Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(returntype, 0));
}
Parm *retpm = NewParmFromNode(returntype, empty_str, n);
Parm *retpm = NewParm(returntype, empty_str, n);
if ((c_ret_type = Swig_typemap_lookup("ctype", retpm, "", 0))) {
@ -3421,7 +3431,7 @@ public:
if (ctypeout)
c_param_type = ctypeout;
Parm *tp = NewParmFromNode(c_param_type, empty_str, n);
Parm *tp = NewParm(c_param_type, empty_str, n);
String *desc_tm = NULL;
/* Add to local variables */
@ -3576,7 +3586,7 @@ public:
String *upcall = NewStringf("%s(%s)", symname, imcall_args);
if (!is_void) {
Parm *tp = NewParmFromNode(returntype, empty_str, n);
Parm *tp = NewParm(returntype, empty_str, n);
if ((tm = Swig_typemap_lookup("csdirectorout", tp, "", 0))) {
substituteClassname(returntype, tm);
@ -3602,7 +3612,7 @@ public:
if (!is_void) {
String *jresult_str = NewString("jresult");
String *result_str = NewString("c_result");
Parm *tp = NewParmFromNode(returntype, result_str, n);
Parm *tp = NewParm(returntype, result_str, n);
/* Copy jresult into c_result... */
if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) {

View file

@ -1407,16 +1407,18 @@ public:
}
{
/* Hack alert: will cleanup later -- Dave */
Node *n = NewHash();
Setattr(n, "name", var_name);
Setattr(n, "sym:name", iname);
Setattr(n, "type", nctype);
SetFlag(n, "feature:immutable");
Node *nn = NewHash();
Setfile(nn, Getfile(n));
Setline(nn, Getline(n));
Setattr(nn, "name", var_name);
Setattr(nn, "sym:name", iname);
Setattr(nn, "type", nctype);
SetFlag(nn, "feature:immutable");
if (constasvar) {
SetFlag(n, "feature:constasvar");
SetFlag(nn, "feature:constasvar");
}
variableWrapper(n);
Delete(n);
variableWrapper(nn);
Delete(nn);
}
Delete(var_name);
Delete(nctype);

View file

@ -83,13 +83,6 @@ class JAVA:public Language {
enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum };
static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) {
Parm *p = NewParm(type, name);
Setfile(p, Getfile(n));
Setline(p, Getline(n));
return p;
}
public:
/* -----------------------------------------------------------------------------
@ -1267,6 +1260,9 @@ public:
String *symname = Getattr(n, "sym:name");
String *value = Getattr(n, "value");
String *name = Getattr(n, "name");
Node *parent = parentNode(n);
int unnamedinstance = GetFlag(parent, "unnamedinstance");
String *parent_name = Getattr(parent, "name");
String *tmpValue;
// Strange hack from parent method
@ -1278,9 +1274,9 @@ public:
Setattr(n, "value", tmpValue);
{
EnumFeature enum_feature = decodeEnumFeature(parentNode(n));
EnumFeature enum_feature = decodeEnumFeature(parent);
if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
// Wrap (non-anonymous) C/C++ enum with a proper Java enum
// Emit the enum item.
if (!GetFlag(n, "firstenumitem"))
@ -1293,18 +1289,16 @@ public:
}
} else {
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
const String *parent_name = Getattr(parentNode(n), "name");
String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int");
String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */
SwigType *typemap_lookup_type = parent_name ? parent_name : type;
const String *tm = typemapLookup(n, "jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF);
String *return_type = Copy(tm);
Delete(typemap_lookup_type);
typemap_lookup_type = NULL;
String *return_type = Copy(tm);
const String *methodmods = Getattr(n, "feature:java:methodmodifiers");
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
if ((enum_feature == TypesafeEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
// Wrap (non-anonymouse) enum using the typesafe enum pattern
if ((enum_feature == TypesafeEnum) && parent_name && !unnamedinstance) {
// Wrap (non-anonymous) enum using the typesafe enum pattern
if (Getattr(n, "enumvalue")) {
String *value = enumValue(n);
Printf(enum_code, " %s final static %s %s = new %s(\"%s\", %s);\n", methodmods, return_type, symname, return_type, symname, value);
@ -1323,9 +1317,9 @@ public:
}
// Add the enum value to the comma separated list being constructed in the enum declaration.
String *enumvalues = Getattr(parentNode(n), "enumvalues");
String *enumvalues = Getattr(parent, "enumvalues");
if (!enumvalues)
Setattr(parentNode(n), "enumvalues", Copy(symname));
Setattr(parent, "enumvalues", Copy(symname));
else
Printv(enumvalues, ", ", symname, NIL);
}
@ -1425,7 +1419,14 @@ public:
enum_constant_flag = false;
} else {
// Alternative constant handling will use the C syntax to make a true Java constant and hope that it compiles as Java code
Printf(constants_code, "%s;\n", Getattr(n, "value"));
if (Getattr(n, "wrappedasconstant")) {
if (SwigType_type(t) == T_CHAR)
Printf(constants_code, "\'%s\';\n", Getattr(n, "staticmembervariableHandler:value"));
else
Printf(constants_code, "%s;\n", Getattr(n, "staticmembervariableHandler:value"));
} else {
Printf(constants_code, "%s;\n", Getattr(n, "value"));
}
}
// Emit the generated code to appropriate place
@ -1973,7 +1974,7 @@ public:
if (qualifier)
SwigType_push(this_type, qualifier);
SwigType_add_pointer(this_type);
Parm *this_parm = NewParm(this_type, name);
Parm *this_parm = NewParm(this_type, name, n);
Swig_typemap_attach_parms("jtype", this_parm, NULL);
Swig_typemap_attach_parms("jstype", this_parm, NULL);
@ -3381,7 +3382,7 @@ public:
}
/* Create the intermediate class wrapper */
Parm *tp = NewParmFromNode(returntype, empty_str, n);
Parm *tp = NewParm(returntype, empty_str, n);
tm = Swig_typemap_lookup("jtype", tp, "", 0);
if (tm) {
@ -3393,7 +3394,7 @@ public:
String *cdesc = NULL;
SwigType *covariant = Getattr(n, "covariant");
SwigType *adjustedreturntype = covariant ? covariant : returntype;
Parm *adjustedreturntypeparm = NewParmFromNode(adjustedreturntype, empty_str, n);
Parm *adjustedreturntypeparm = NewParm(adjustedreturntype, empty_str, n);
if ((tm = Swig_typemap_lookup("directorin", adjustedreturntypeparm, "", 0))
&& (cdesc = Getattr(adjustedreturntypeparm, "tmap:directorin:descriptor"))) {
@ -3413,10 +3414,10 @@ public:
/* Get the JNI field descriptor for this return type, add the JNI field descriptor
to jniret_desc */
Parm *retpm = NewParmFromNode(returntype, empty_str, n);
Parm *retpm = NewParm(returntype, empty_str, n);
if ((c_ret_type = Swig_typemap_lookup("jni", retpm, "", 0))) {
Parm *tp = NewParmFromNode(c_ret_type, empty_str, n);
Parm *tp = NewParm(c_ret_type, empty_str, n);
if (!is_void && !ignored_method) {
String *jretval_decl = NewStringf("%s jresult", c_ret_type);
@ -3518,7 +3519,7 @@ public:
}
/* Start the Java field descriptor for the intermediate class's upcall (insert self object) */
Parm *tp = NewParmFromNode(c_classname, empty_str, n);
Parm *tp = NewParm(c_classname, empty_str, n);
String *jdesc;
if ((tm = Swig_typemap_lookup("directorin", tp, "", 0))
@ -3560,7 +3561,7 @@ public:
/* Get parameter's intermediary C type */
if ((c_param_type = Getattr(p, "tmap:jni"))) {
Parm *tp = NewParmFromNode(c_param_type, empty_str, n);
Parm *tp = NewParm(c_param_type, empty_str, n);
String *desc_tm = NULL, *jdesc = NULL, *cdesc = NULL;
/* Add to local variables */
@ -3716,8 +3717,11 @@ public:
String *upcall = NewStringf("self.%s(%s)", symname, imcall_args);
// Handle exception classes specified in the "except" feature's "throws" attribute
addThrows(n, "feature:except", n);
if (!is_void) {
Parm *tp = NewParmFromNode(returntype, empty_str, n);
Parm *tp = NewParm(returntype, empty_str, n);
if ((tm = Swig_typemap_lookup("javadirectorout", tp, "", 0))) {
addThrows(n, "tmap:javadirectorout", tp);
@ -3761,7 +3765,7 @@ public:
if (!is_void) {
String *jresult_str = NewString("jresult");
String *result_str = NewString("c_result");
Parm *tp = NewParmFromNode(returntype, result_str, n);
Parm *tp = NewParm(returntype, result_str, n);
/* Copy jresult into c_result... */
if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) {
@ -3854,7 +3858,7 @@ public:
SwigType_add_pointer(jenv_type);
p = NewParmFromNode(jenv_type, NewString("jenv"), n);
p = NewParm(jenv_type, NewString("jenv"), n);
Setattr(p, "arg:byname", "1");
set_nextSibling(p, NULL);
@ -3891,7 +3895,7 @@ public:
String *jenv_type = NewString("JNIEnv");
SwigType_add_pointer(jenv_type);
p = NewParmFromNode(jenv_type, NewString("jenv"), n);
p = NewParm(jenv_type, NewString("jenv"), n);
set_nextSibling(p, parms);
parms = p;

View file

@ -175,7 +175,7 @@ int Dispatcher::emit_one(Node *n) {
} else if (strcmp(tag, "types") == 0) {
ret = typesDirective(n);
} else {
Printf(stderr, "%s:%d. Unrecognized parse tree node type '%s'\n", input_file, line_number, tag);
Swig_error(input_file, line_number, "Unrecognized parse tree node type '%s'\n", tag);
ret = SWIG_ERROR;
}
if (wrn) {
@ -900,7 +900,7 @@ int Language::cDeclaration(Node *n) {
Delete(ty);
ty = fullty;
fullty = 0;
ParmList *parms = SwigType_function_parms(ty);
ParmList *parms = SwigType_function_parms(ty, n);
Setattr(n, "parms", parms);
}
/* Transform the node into a 'function' node and emit */
@ -1188,6 +1188,8 @@ int Language::memberfunctionHandler(Node *n) {
Setattr(cbn, "type", cbty);
Setattr(cbn, "value", cbvalue);
Setattr(cbn, "name", name);
Setfile(cbn, Getfile(n));
Setline(cbn, Getline(n));
memberconstantHandler(cbn);
Setattr(n, "feature:callback:name", Swig_name_member(ClassPrefix, cbname));
@ -1407,39 +1409,36 @@ int Language::membervariableHandler(Node *n) {
target = NewStringf("%s->%s", pname, name);
Delete(pname);
}
} else {
target = NewStringf("$extendgetcall"); // member variable access expanded later
tm = Swig_typemap_lookup("memberin", n, target, 0);
}
tm = Swig_typemap_lookup("memberin", n, target, 0);
int flags = Extend | SmartPointer | use_naturalvar_mode(n);
if (is_non_virtual_protected_access(n))
flags = flags | CWRAP_ALL_PROTECTED_ACCESS;
String *call = 0;
Swig_MembersetToFunction(n, ClassType, flags, &call);
Swig_MembersetToFunction(n, ClassType, flags);
Setattr(n, "memberset", "1");
if (!Extend) {
/* Check for a member in typemap here */
if (!tm) {
if (SwigType_isarray(type)) {
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0));
make_set_wrapper = 0;
if (!tm) {
if (SwigType_isarray(type)) {
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0));
make_set_wrapper = 0;
}
} else {
String *pname0 = Swig_cparm_name(0, 0);
String *pname1 = Swig_cparm_name(0, 1);
Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
Replace(tm, "$target", target, DOH_REPLACE_ANY);
Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
Setattr(n, "wrap:action", tm);
Delete(tm);
Delete(pname0);
Delete(pname1);
}
} else {
String *pname0 = Swig_cparm_name(0, 0);
String *pname1 = Swig_cparm_name(0, 1);
Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
Replace(tm, "$target", target, DOH_REPLACE_ANY);
Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
Replace(tm, "$extendgetcall", call, DOH_REPLACE_ANY);
Setattr(n, "wrap:action", tm);
Delete(tm);
Delete(pname0);
Delete(pname1);
Delete(target);
}
Delete(call);
Delete(target);
if (make_set_wrapper) {
Setattr(n, "sym:name", mrename_set);
functionWrapper(n);
@ -1481,7 +1480,7 @@ int Language::membervariableHandler(Node *n) {
Parm *p;
String *gname;
SwigType *vty;
p = NewParm(type, 0);
p = NewParm(type, 0, n);
gname = NewStringf(AttributeFunctionGet, symname);
if (!Extend) {
ActionFunc = Copy(Swig_cmemberget_call(name, type));
@ -1907,12 +1906,14 @@ int Language::classDirectorDisown(Node *n) {
String *type = NewString(ClassType);
String *name = NewString("self");
SwigType_add_pointer(type);
Parm *p = NewParm(type, name);
Parm *p = NewParm(type, name, n);
Delete(name);
Delete(type);
type = NewString("void");
String *action = NewString("");
Printv(action, "{\n", "Swig::Director *director = dynamic_cast<Swig::Director *>(arg1);\n", "if (director) director->swig_disown();\n", "}\n", NULL);
Setfile(disown, Getfile(n));
Setline(disown, Getline(n));
Setattr(disown, "wrap:action", action);
Setattr(disown, "name", mrename);
Setattr(disown, "sym:name", mrename);
@ -2165,7 +2166,7 @@ static void addCopyConstructor(Node *n) {
if (!symname) {
symname = Copy(csymname);
}
Parm *p = NewParm(cc, "other");
Parm *p = NewParm(cc, "other", n);
Setattr(cn, "name", name);
Setattr(cn, "sym:name", symname);

View file

@ -62,11 +62,16 @@ static const char *usage1 = (const char *) "\
-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\
-debug-symtabs - Display symbol tables information\n\
-debug-symbols - Display target language symbols in the symbol tables\n\
-debug-csymbols - Display C symbols in the symbol tables\n\
-debug-tags - Display information about the tags found in the interface\n\
-debug-template - Display information for debugging templates\n\
-debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages\n\
-debug-typedef - Display information about the types and typedefs in the interface\n\
-debug-typemap - Display information for debugging typemaps\n\
-debug-typemap - Display typemap debugging information\n\
-debug-tmsearch - Display typemap search debugging information\n\
-debug-tmused - Display typemaps used debugging information\n\
-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\
@ -162,6 +167,9 @@ static int no_cpp = 0;
static char *outfile_name = 0;
static char *outfile_name_h = 0;
static int tm_debug = 0;
static int dump_symtabs = 0;
static int dump_symbols = 0;
static int dump_csymbols = 0;
static int dump_tags = 0;
static int dump_module = 0;
static int dump_top = 0;
@ -649,6 +657,12 @@ void SWIG_getoptions(int argc, char *argv[]) {
} 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);
} else if (strcmp(argv[i], "-debug-tmsearch") == 0) {
Swig_typemap_search_debug_set();
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-debug-tmused") == 0) {
Swig_typemap_used_debug_set();
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-module") == 0) {
Swig_mark_arg(i);
if (argv[i + 1]) {
@ -716,6 +730,15 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if (strncmp(argv[i], "-w", 2) == 0) {
Swig_mark_arg(i);
Swig_warnfilter(argv[i] + 2, 1);
} else if (strcmp(argv[i], "-debug-symtabs") == 0) {
dump_symtabs = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-debug-symbols") == 0) {
dump_symbols = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-debug-csymbols") == 0) {
dump_csymbols = 1;
Swig_mark_arg(i);
} else if ((strcmp(argv[i], "-debug-tags") == 0) || (strcmp(argv[i], "-dump_tags") == 0)) {
dump_tags = 1;
Swig_mark_arg(i);
@ -829,12 +852,6 @@ int SWIG_main(int argc, char *argv[], Language *l) {
Preprocessor_define((DOH *) "SWIG 1", 0);
Preprocessor_define((DOH *) "__STDC__", 0);
#ifdef MACSWIG
Preprocessor_define((DOH *) "SWIGMAC 1", 0);
#endif
#ifdef SWIGWIN32
Preprocessor_define((DOH *) "SWIGWIN32 1", 0);
#endif
// Set the SWIG version value in format 0xAABBCC from package version expected to be in format A.B.C
String *package_version = NewString(PACKAGE_VERSION); /* Note that the fakeversion has not been set at this point */
@ -1145,6 +1162,19 @@ int SWIG_main(int argc, char *argv[], Language *l) {
SwigType_print_scope(0);
}
if (dump_symtabs) {
Swig_symbol_print_tables(Swig_symbol_global_scope());
Swig_symbol_print_tables_summary();
}
if (dump_symbols) {
Swig_symbol_print_symbols();
}
if (dump_csymbols) {
Swig_symbol_print_csymbols();
}
if (dump_tags) {
Swig_print_tags(top, 0);
}

View file

@ -81,7 +81,7 @@ char cvsroot_modula3_cxx[] = "$Id$";
that assign special purposes to the array types.
- Can one interpret $n_basetype as the identifier matched with SWIGTYPE ?
Swig's odds:
SWIG's odds:
- arguments of type (Node *) for SWIG functions
should be most often better (const Node *):
Swig_symbol_qualified, Getattr, nodeType, parentNode

View file

@ -647,13 +647,15 @@ public:
{
/* Hack alert: will cleanup later -- Dave */
Node *n = NewHash();
Setattr(n, "name", var_name);
Setattr(n, "sym:name", iname);
Setattr(n, "type", type);
SetFlag(n, "feature:immutable");
variableWrapper(n);
Delete(n);
Node *nn = NewHash();
Setfile(nn, Getfile(n));
Setline(nn, Getline(n));
Setattr(nn, "name", var_name);
Setattr(nn, "sym:name", iname);
Setattr(nn, "type", type);
SetFlag(nn, "feature:immutable");
variableWrapper(nn);
Delete(nn);
}
}
Delete(proc_name);
@ -762,7 +764,7 @@ public:
Printv(access_mem, "(ptr)->", name, NIL);
if ((SwigType_type(type) == T_USER) && (!is_a_pointer(type))) {
Printv(convert_tab, tab4, "fields[i++] = ", NIL);
Printv(convert_tab, "_swig_convert_struct_", swigtype, "((", SwigType_str(ctype_ptr, ""), ")&((ptr)->", name, "));\n", NIL);
Printv(convert_tab, "_swig_convert_struct_", swigtype, "((", SwigType_str(ctype_ptr, 0), ")&((ptr)->", name, "));\n", NIL);
} else if ((tm = Swig_typemap_lookup("varout", n, access_mem, 0))) {
Replaceall(tm, "$result", "fields[i++]");
Printv(convert_tab, tm, "\n", NIL);

View file

@ -1727,7 +1727,7 @@ public:
ParmList *superparms = Getattr(n, "parms");
ParmList *parms = CopyParmList(superparms);
String *type = NewString("CAML_VALUE");
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
q = Copy(p);
set_nextSibling(q, superparms);
set_nextSibling(p, parms);
@ -1780,7 +1780,7 @@ public:
ParmList *superparms = Getattr(n, "parms");
ParmList *parms = CopyParmList(superparms);
String *type = NewString("CAML_VALUE");
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
q = Copy(p);
set_nextSibling(p, parms);
parms = p;

View file

@ -13,7 +13,7 @@ char cvsroot_octave_cxx[] = "$Id$";
static const char *usage = (char *) "\
Octave Options (available with -octave)\n\
-api <N> - Generate code that assumes Octave API N [default: 37]\n\
[no additional options]\n\
\n";
@ -36,8 +36,6 @@ private:
int have_destructor;
String *constructor_name;
int api_version;
Hash *docs;
public:
@ -56,7 +54,6 @@ public:
director_multiple_inheritance = 1;
director_language = 1;
docs = NewHash();
api_version = 0;
}
virtual void main(int argc, char *argv[]) {
@ -64,15 +61,6 @@ public:
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) {
fputs(usage, stderr);
} else if (strcmp(argv[i], "-api") == 0) {
if (argv[i + 1]) {
api_version = atoi(argv[i + 1]);
Swig_mark_arg(i);
Swig_mark_arg(i + 1);
i++;
} else {
Swig_arg_error();
}
}
}
}
@ -138,7 +126,6 @@ public:
Printf(f_runtime, "#define SWIGOCTAVE\n");
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
Printf(f_runtime, "#define SWIG_name %s\n", module);
Printf(f_runtime, "#define OCTAVE_API_VERSION_OPTION %i\n", api_version);
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
@ -969,7 +956,7 @@ public:
String *name = NewString("self");
String *type = NewString("void");
SwigType_add_pointer(type);
self = NewParm(type, name);
self = NewParm(type, name, n);
Delete(type);
Delete(name);
Setattr(self, "lname", "self_obj");
@ -1064,7 +1051,7 @@ public:
ParmList *parms = CopyParmList(superparms);
String *type = NewString("void");
SwigType_add_pointer(type);
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
set_nextSibling(p, parms);
parms = p;

View file

@ -223,13 +223,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored. Non-const method %s at %s:%d used.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
@ -238,13 +240,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored. Non-const method %s at %s:%d used.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
@ -258,15 +262,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s is shadowed by %s at %s:%d.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
Getfile(nodes[i].n), Getline(nodes[i].n));
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
nodes[j].error = 1;
}

View file

@ -1636,7 +1636,7 @@ public:
} else {
Node *parent = Swig_methodclass(n);
String *classname = Swig_class_name(parent);
Printf(output, "\t\tif (get_class($this) === '%s') {\n", classname);
Printf(output, "\t\tif (get_class($this) === '%s%s') {\n", prefix, classname);
Printf(output, "\t\t\t$_this = null;\n");
Printf(output, "\t\t} else {\n");
Printf(output, "\t\t\t$_this = $this;\n");
@ -1684,7 +1684,7 @@ public:
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($r);\n", Getattr(classLookup(d), "sym:name"));
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");
} else {
@ -1929,9 +1929,7 @@ done:
virtual int classHandler(Node *n) {
constructors = 0;
//SwigType *t = Getattr(n, "classtype");
current_class = n;
// String *use_class_name=SwigType_manglestr(SwigType_ltype(t));
if (shadow) {
char *rename = GetChar(n, "sym:name");
@ -2325,7 +2323,7 @@ done:
ParmList *parms = CopyParmList(superparms);
String *type = NewString("zval");
SwigType_add_pointer(type);
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
set_nextSibling(p, parms);
parms = p;
@ -2538,7 +2536,24 @@ done:
}
p = nextSibling(p);
}
Append(w->code, "int error;\n");
/* exception handling */
tm = Swig_typemap_lookup("director:except", n, "result", 0);
if (!tm) {
tm = Getattr(n, "feature:director:except");
if (tm)
tm = Copy(tm);
}
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
if (Replaceall(tm, "$error", "error")) {
/* Only declare error if it is used by the typemap. */
Append(w->code, "int error;\n");
}
} else {
Delete(tm);
tm = NULL;
}
if (!idx) {
Printf(w->code, "zval **args = NULL;\n", idx);
} else {
@ -2557,18 +2572,10 @@ done:
Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,\n");
Printf(w->code, " result, %d, args TSRMLS_CC);\n", idx);
/* exception handling */
tm = Swig_typemap_lookup("director:except", n, "result", 0);
if (!tm) {
tm = Getattr(n, "feature:director:except");
if (tm)
tm = Copy(tm);
}
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
Replaceall(tm, "$error", "error");
if (tm) {
Printv(w->code, Str(tm), "\n", NIL);
Delete(tm);
}
Delete(tm);
/* marshal return value from PHP to C/C++ type */

View file

@ -2625,7 +2625,7 @@ public:
ParmList *parms = CopyParmList(superparms);
String *type = NewString("PyObject");
SwigType_add_pointer(type);
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
set_nextSibling(p, parms);
parms = p;
@ -3205,7 +3205,7 @@ public:
String *name = NewString("self");
String *type = NewString("PyObject");
SwigType_add_pointer(type);
self = NewParm(type, name);
self = NewParm(type, name, n);
Delete(type);
Delete(name);
Setattr(self, "lname", "O");

View file

@ -588,7 +588,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
// ParmList *parms = Getattr(n, "parms");
// memory leak
ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)));
ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)), n);
// if (debugMode) {
@ -712,10 +712,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
XXX Have to be a little more clever so that we can deal with struct A * - the * is getting lost.
Is this still true? If so, will a SwigType_push() solve things?
*/
Node *bbase = NewHash();
Setattr(bbase, "type", rettype);
Setattr(bbase, "name", NewString("result"));
Parm *bbase = NewParm(rettype, "result", n);
String *returnTM = Swig_typemap_lookup("in", bbase, "result", f);
if(returnTM) {
String *tm = returnTM;
@ -1101,7 +1098,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
Delete(pitem);
}
Delete(itemList);
Printf(f->code, ")\n");
Printf(f->code, ");\n");
if (!isSet && varaccessor > 0) {
Printf(f->code, "%svaccessors = c(", tab8);
@ -1117,7 +1114,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
Printf(f->code, "'%s'%s", item, vcount < varaccessor ? ", " : "");
}
}
Printf(f->code, ")\n");
Printf(f->code, ");\n");
}
@ -1129,24 +1126,24 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
"stop(\"No ", (isSet ? "modifiable" : "accessible"), " field named \", name, \" in ", className,
": fields are \", paste(names(accessorFuns), sep = \", \")",
")", "\n}\n", NIL); */
Printv(f->code, tab8,
"idx = pmatch(name, names(accessorFuns))\n",
Printv(f->code, ";", tab8,
"idx = pmatch(name, names(accessorFuns));\n",
tab8,
"if(is.na(idx)) \n",
tab8, tab4, NIL);
Printf(f->code, "return(callNextMethod(x, name%s))\n",
Printf(f->code, "return(callNextMethod(x, name%s));\n",
isSet ? ", value" : "");
Printv(f->code, tab8, "f = accessorFuns[[idx]]\n", NIL);
Printv(f->code, tab8, "f = accessorFuns[[idx]];\n", NIL);
if(isSet) {
Printv(f->code, tab8, "f(x, value)\n", NIL);
Printv(f->code, tab8, "x\n", NIL); // make certain to return the S value.
Printv(f->code, tab8, "f(x, value);\n", NIL);
Printv(f->code, tab8, "x;\n", NIL); // make certain to return the S value.
} else {
Printv(f->code, tab8, "formals(f)[[1]] = x\n", NIL);
Printv(f->code, tab8, "formals(f)[[1]] = x;\n", NIL);
if (varaccessor) {
Printv(f->code, tab8,
"if (is.na(match(name, vaccessors))) f else f(x)\n", NIL);
"if (is.na(match(name, vaccessors))) f else f(x);\n", NIL);
} else {
Printv(f->code, tab8, "f\n", NIL);
Printv(f->code, tab8, "f;\n", NIL);
}
}
Printf(f->code, "}\n");
@ -1157,15 +1154,15 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
isSet ? "<-" : "",
getRClassName(className));
Wrapper_print(f, out);
Printf(out, ")\n");
Printf(out, ");\n");
if(isSet) {
Printf(out, "setMethod('[[<-', c('_p%s', 'character'),",
getRClassName(className));
Insert(f->code, 2, "name = i\n");
Insert(f->code, 2, "name = i;\n");
Printf(attr->code, "%s", f->code);
Wrapper_print(attr, out);
Printf(out, ")\n");
Printf(out, ");\n");
}
DelWrapper(attr);
@ -1489,8 +1486,8 @@ static List * Swig_overload_rank(Node *n,
}
if (!differ) {
/* See if declarations differ by const only */
String *d1 = Getattr(nodes[i].n,"decl");
String *d2 = Getattr(nodes[j].n,"decl");
String *d1 = Getattr(nodes[i].n, "decl");
String *d2 = Getattr(nodes[j].n, "decl");
if (d1 && d2) {
String *dq1 = Copy(d1);
String *dq2 = Copy(d2);
@ -1500,49 +1497,47 @@ static List * Swig_overload_rank(Node *n,
if (SwigType_isconst(d2)) {
Delete(SwigType_pop(dq2));
}
if (Strcmp(dq1,dq2) == 0) {
if (Strcmp(dq1, dq2) == 0) {
if (SwigType_isconst(d1) && !SwigType_isconst(d2)) {
if (script_lang_wrapping) {
// Swap nodes so that the const method gets ignored (shadowed by the non-const method)
Overloaded t = nodes[i];
nodes[i] = nodes[j];
nodes[j] = t;
}
if (script_lang_wrapping) {
// Swap nodes so that the const method gets ignored (shadowed by the non-const method)
Overloaded t = nodes[i];
nodes[i] = nodes[j];
nodes[j] = t;
}
differ = 1;
if (!nodes[j].error) {
if (script_lang_wrapping) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n",
Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms),
Getfile(nodes[i].n), Getline(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s(%s) ignored. Method %s(%s) const at %s:%d used.\n",
Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms),
Getattr(nodes[i].n,"name"), ParmList_errorstr(nodes[i].parms),
Getfile(nodes[i].n), Getline(nodes[i].n));
}
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
} else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) {
differ = 1;
if (!nodes[j].error) {
if (script_lang_wrapping) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n",
Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms),
Getfile(nodes[i].n), Getline(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s(%s) const ignored. Method %s(%s) at %s:%d used.\n",
Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms),
Getattr(nodes[i].n,"name"), ParmList_errorstr(nodes[i].parms),
Getfile(nodes[i].n), Getline(nodes[i].n));
}
}
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
}
nodes[j].error = 1;
}
}
@ -1552,18 +1547,18 @@ static List * Swig_overload_rank(Node *n,
}
if (!differ) {
if (!nodes[j].error) {
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s is shadowed by %s at %s:%d.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
Getfile(nodes[i].n), Getline(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
Getfile(nodes[i].n), Getline(nodes[i].n));
}
if (script_lang_wrapping) {
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
} else {
if (!Getattr(nodes[j].n, "overload:ignore"))
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
"using %s instead.\n", Swig_name_decl(nodes[i].n));
}
nodes[j].error = 1;
}
}
@ -1601,9 +1596,9 @@ void R::dispatchFunction(Node *n) {
List *dispatch = Swig_overload_rank(n, true);
int nfunc = Len(dispatch);
Printv(f->code,
"argtypes <- mapply(class, list(...))\n",
"argv <- list(...)\n",
"argc <- length(argtypes)\n", NIL );
"argtypes <- mapply(class, list(...));\n",
"argv <- list(...);\n",
"argc <- length(argtypes);\n", NIL );
Printf(f->code, "# dispatch functions %d\n", nfunc);
int cur_args = -1;
@ -1649,16 +1644,16 @@ void R::dispatchFunction(Node *n) {
}
p = Getattr(p, "tmap:in:next");
}
Printf(f->code, ") { f <- %s%s }\n", sfname, overname);
Printf(f->code, ") { f <- %s%s; }\n", sfname, overname);
} else {
Printf(f->code, "f <- %s%s", sfname, overname);
Printf(f->code, "f <- %s%s; ", sfname, overname);
}
}
if (cur_args != -1) {
Printv(f->code, "}", NIL);
}
Printv(f->code, "\nf(...)", NIL);
Printv(f->code, "\n}", NIL);
Printv(f->code, ";\nf(...)", NIL);
Printv(f->code, ";\n}", NIL);
Wrapper_print(f, sfile);
Printv(sfile, "# Dispatch function\n", NIL);
DelWrapper(f);
@ -1886,16 +1881,16 @@ int R::functionWrapper(Node *n) {
String *snargs = NewStringf("%d", nargs);
Printv(sfun->code, "if(is.function(", name, ")) {", "\n",
"assert('...' %in% names(formals(", name,
")) || length(formals(", name, ")) >= ", snargs, ")\n} ", NIL);
")) || length(formals(", name, ")) >= ", snargs, ");\n} ", NIL);
Delete(snargs);
Printv(sfun->code, "else {\n",
"if(is.character(", name, ")) {\n",
name, " = getNativeSymbolInfo(", name, ")",
"\n}\n",
name, " = getNativeSymbolInfo(", name, ");",
"\n};\n",
"if(is(", name, ", \"NativeSymbolInfo\")) {\n",
name, " = ", name, "$address", "\n}\n",
"}\n",
name, " = ", name, "$address", ";\n}\n",
"}; \n",
NIL);
} else {
Printf(sfun->code, "%s\n", tm);
@ -2090,10 +2085,10 @@ int R::functionWrapper(Node *n) {
}
Printv(sfun->code, (Len(tm) ? "ans = " : ""), ".Call('", wname,
"', ", sargs, "PACKAGE='", Rpackage, "')\n", NIL);
Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname,
"', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL);
if(Len(tm))
Printf(sfun->code, "%s\n\nans\n", tm);
Printf(sfun->code, "%s\n\nans;\n", tm);
if (destructor)
Printv(f->code, "R_ClearExternalPtr(self);\n", NIL);
@ -2452,11 +2447,11 @@ int R::generateCopyRoutines(Node *n) {
/* The S functions to get and set the member value. */
String *elNameT = replaceInitialDash(elName);
Printf(copyToR->code, "obj@%s = value$%s\n", elNameT, elNameT);
Printf(copyToC->code, "obj$%s = value@%s\n", elNameT, elNameT);
Printf(copyToR->code, "obj@%s = value$%s;\n", elNameT, elNameT);
Printf(copyToC->code, "obj$%s = value@%s;\n", elNameT, elNameT);
Delete(elNameT);
}
Printf(copyToR->code, "obj\n}\n\n");
Printf(copyToR->code, "obj;\n}\n\n");
String *rclassName = getRClassNameCopyStruct(type, 0); // without the Ref.
Printf(sfile, "# Start definition of copy functions & methods for %s\n", rclassName);
@ -2466,9 +2461,9 @@ int R::generateCopyRoutines(Node *n) {
Printf(sfile, "# Start definition of copy methods for %s\n", rclassName);
Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s)\n", rclassName,
Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s);\n", rclassName,
mangledName);
Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s)\n\n", rclassName,
Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s);\n\n", rclassName,
mangledName);
Printf(sfile, "# End definition of copy methods for %s\n", rclassName);

View file

@ -2590,7 +2590,7 @@ public:
Parm *self;
String *name = NewString("self");
String *type = NewString("VALUE");
self = NewParm(type, name);
self = NewParm(type, name, n);
Delete(type);
Delete(name);
Setattr(self, "lname", "Qnil");
@ -2812,7 +2812,7 @@ public:
ParmList *superparms = Getattr(n, "parms");
ParmList *parms = CopyParmList(superparms);
String *type = NewString("VALUE");
p = NewParm(type, NewString("self"));
p = NewParm(type, NewString("self"), n);
set_nextSibling(p, parms);
parms = p;