Refactor: move makeParameterName() to common Language base class.

This method was duplicated more or less identically for 4 languages and will
be needed for another one soon, so put it in the base class from which it can
be simply reused instead.

No changes in the program behaviour whatsoever.
This commit is contained in:
Vadim Zeitlin 2014-08-16 00:21:33 +02:00
commit 8c76270619
6 changed files with 42 additions and 137 deletions

View file

@ -3256,44 +3256,6 @@ public:
Delete(replacementname);
}
/* -----------------------------------------------------------------------------
* makeParameterName()
*
* Inputs:
* n - Node
* p - parameter node
* arg_num - parameter argument number
* setter - set this flag when wrapping variables
* Return:
* arg - a unique parameter name
* ----------------------------------------------------------------------------- */
String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter) {
String *arg = 0;
String *pn = Getattr(p, "name");
// Use C parameter name unless it is a duplicate or an empty parameter name
int count = 0;
ParmList *plist = Getattr(n, "parms");
while (plist) {
if ((Cmp(pn, Getattr(plist, "name")) == 0))
count++;
plist = nextSibling(plist);
}
String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0;
arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn);
if (setter && Cmp(arg, "self") != 0) {
// Note that for setters the parameter name is always set but sometimes includes C++
// scope resolution, so we need to strip off the scope resolution to make a valid name.
Delete(arg);
arg = NewString("value"); //Swig_scopename_last(pn);
}
return arg;
}
/* -----------------------------------------------------------------------------
* emitTypeWrapperClass()
* ----------------------------------------------------------------------------- */