[C#, D, Java] Check for collision of parameter names with target language keywords when generating the director glue code.

The situation in which the generated could would previously be invalid is illustrated in the new 'director_keywords' test case.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12358 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
David Nadlinger 2010-12-30 15:40:17 +00:00
commit 91523f7510
6 changed files with 35 additions and 16 deletions

View file

@ -3473,7 +3473,6 @@ public:
String *callback_def = NewString("");
String *callback_code = NewString("");
String *imcall_args = NewString("");
int gencomma = 0;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
// Kludge Alert: functionWrapper sets sym:overload properly, but it
@ -3617,14 +3616,14 @@ public:
Printf(w->code, "} else {\n");
/* Go through argument list, convert from native to Java */
for (p = l; p; /* empty */ ) {
for (i = 0, p = l; p; ++i) {
/* Is this superfluous? */
while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
p = Getattr(p, "tmap:directorin:next");
}
SwigType *pt = Getattr(p, "type");
String *ln = Copy(Getattr(p, "name"));
String *ln = makeParameterName(n, p, i, false);
String *c_param_type = NULL;
String *c_decl = NewString("");
String *arg = NewString("");
@ -3632,7 +3631,7 @@ public:
Printf(arg, "j%s", ln);
/* And add to the upcall args */
if (gencomma > 0)
if (i > 0)
Printf(jupcall_args, ", ");
Printf(jupcall_args, "%s", arg);
@ -3660,7 +3659,7 @@ public:
Delete(tm);
/* Add C type to callback typedef */
if (gencomma > 0)
if (i > 0)
Printf(callback_typedef_parms, ", ");
Printf(callback_typedef_parms, "%s", c_param_type);
@ -3681,7 +3680,7 @@ public:
substituteClassname(pt, din);
Replaceall(din, "$iminput", ln);
if (gencomma > 0) {
if (i > 0) {
Printf(delegate_parms, ", ");
Printf(proxy_method_types, ", ");
Printf(imcall_args, ", ");
@ -3727,7 +3726,7 @@ public:
p = nextSibling(p);
}
gencomma++;
Delete(ln);
Delete(arg);
Delete(c_decl);
Delete(c_param_type);

View file

@ -1867,7 +1867,6 @@ public:
String *callback_def = NewString("");
String *callback_code = NewString("");
String *imcall_args = NewString("");
int gencomma = 0;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
// Kludge Alert: functionWrapper sets sym:overload properly, but it
@ -2007,14 +2006,14 @@ public:
Printf(w->code, "} else {\n");
// Go through argument list.
for (p = l; p; /* empty */) {
for (i = 0, p = l; p; ++i) {
/* Is this superfluous? */
while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
p = Getattr(p, "tmap:directorin:next");
}
SwigType *pt = Getattr(p, "type");
String *ln = Copy(Getattr(p, "name"));
String *ln = makeParameterName(n, p, i, false);
String *c_param_type = NULL;
String *c_decl = NewString("");
String *arg = NewString("");
@ -2071,7 +2070,7 @@ public:
Replaceall(din, "$winput", ln);
Printf(delegate_parms, ", ");
if (gencomma > 0) {
if (i > 0) {
Printf(proxy_method_param_list, ", ");
Printf(imcall_args, ", ");
}
@ -2123,10 +2122,10 @@ public:
p = nextSibling(p);
}
gencomma++;
Delete(arg);
Delete(c_decl);
Delete(c_param_type);
Delete(ln);
}
/* header declaration, start wrapper definition */

View file

@ -3548,7 +3548,6 @@ public:
String *callback_def = NewString("");
String *callback_code = NewString("");
String *imcall_args = NewString("");
int gencomma = 0;
int classmeth_off = curr_class_dmethod - first_class_dmethod;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
@ -3767,14 +3766,14 @@ public:
Delete(tp);
/* Go through argument list, convert from native to Java */
for (p = l; p; /* empty */ ) {
for (i = 0, p = l; p; ++i) {
/* Is this superfluous? */
while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
p = Getattr(p, "tmap:directorin:next");
}
SwigType *pt = Getattr(p, "type");
String *ln = Copy(Getattr(p, "name"));
String *ln = makeParameterName(n, p, i, false);
String *c_param_type = NULL;
String *c_decl = NewString("");
String *arg = NewString("");
@ -3833,7 +3832,7 @@ public:
substituteClassname(pt, din);
Replaceall(din, "$jniinput", ln);
if (++gencomma > 1)
if (i > 0)
Printf(imcall_args, ", ");
Printf(callback_def, ", %s %s", tm, ln);
@ -3896,6 +3895,7 @@ public:
Delete(arg);
Delete(c_decl);
Delete(c_param_type);
Delete(ln);
}
/* header declaration, start wrapper definition */