Remove numerous hard coded 'result' variable name in generated c/c++ wrappers. The variable name is now defined in just one place, making it possible to change the name easily if a target language so wishes - see cwrap.c.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12830 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
d1dc016b68
commit
24133bacd7
29 changed files with 252 additions and 227 deletions
|
|
@ -961,9 +961,9 @@ public:
|
|||
/* emit function call */
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$input", Swig_cresult_name());
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "return_value");
|
||||
Replaceall(tm, "$result", "return_value");
|
||||
Replaceall(tm, "$owner", newobject ? "1" : "0");
|
||||
|
|
@ -983,14 +983,14 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
}
|
||||
|
|
@ -2253,13 +2253,13 @@ done:
|
|||
director_prot_ctor_code = NewStringEmpty();
|
||||
Printf(director_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n");
|
||||
Printf(director_prot_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n");
|
||||
Printf(director_ctor_code, " result = (%s *)new %s(%s);\n", ctype, ctype, args);
|
||||
Printf(director_ctor_code, " %s = (%s *)new %s(%s);\n", Swig_cresult_name(), ctype, ctype, args);
|
||||
Printf(director_prot_ctor_code, " SWIG_PHP_Error(E_ERROR, \"accessing abstract class or protected constructor\");\n", name, name, args);
|
||||
if (i) {
|
||||
Insert(args, 0, ", ");
|
||||
}
|
||||
Printf(director_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", ctype, sname, args);
|
||||
Printf(director_prot_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", ctype, sname, args);
|
||||
Printf(director_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Delete(args);
|
||||
|
||||
wrapperType = directorconstructor;
|
||||
|
|
@ -2595,7 +2595,7 @@ done:
|
|||
}
|
||||
|
||||
/* exception handling */
|
||||
tm = Swig_typemap_lookup("director:except", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
|
||||
if (!tm) {
|
||||
tm = Getattr(n, "feature:director:except");
|
||||
if (tm)
|
||||
|
|
@ -2616,8 +2616,8 @@ done:
|
|||
} else {
|
||||
Printf(w->code, "zval *args[%d];\n", idx);
|
||||
}
|
||||
Append(w->code, "zval *result, funcname;\n");
|
||||
Append(w->code, "MAKE_STD_ZVAL(result);\n");
|
||||
Printf(w->code, "zval *%s, funcname;\n", Swig_cresult_name());
|
||||
Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name());
|
||||
Printf(w->code, "ZVAL_STRING(&funcname, (char *)\"%s\", 0);\n", GetChar(n, "sym:name"));
|
||||
Append(w->code, "if (!swig_self) {\n");
|
||||
Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");");
|
||||
|
|
@ -2627,7 +2627,7 @@ done:
|
|||
Printv(w->code, wrap_args, NIL);
|
||||
|
||||
Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,\n");
|
||||
Printf(w->code, " result, %d, args TSRMLS_CC);\n", idx);
|
||||
Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx);
|
||||
|
||||
if (tm) {
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
|
|
@ -2651,10 +2651,11 @@ done:
|
|||
* occurs in Language::cDeclaration().
|
||||
*/
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "result", w);
|
||||
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm != 0) {
|
||||
Replaceall(tm, "$input", "&result");
|
||||
static const String *amp_result = NewStringf("&%s", Swig_cresult_name());
|
||||
Replaceall(tm, "$input", amp_result);
|
||||
char temp[24];
|
||||
sprintf(temp, "%d", idx);
|
||||
Replaceall(tm, "$argnum", temp);
|
||||
|
|
@ -2679,7 +2680,7 @@ done:
|
|||
/* marshal outputs */
|
||||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$input", Swig_cresult_name());
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
|
|
@ -2688,7 +2689,7 @@ done:
|
|||
}
|
||||
}
|
||||
|
||||
Append(w->code, "FREE_ZVAL(result);\n");
|
||||
Printf(w->code, "FREE_ZVAL(%s);\n", Swig_cresult_name());
|
||||
|
||||
Delete(parse_args);
|
||||
Delete(cleanup);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue