mirror of https://github.com/adamdruppe/arsd.git
possible param name fix in large ApiProviders.. see comment on line 1493
This commit is contained in:
parent
a9a94d4829
commit
0c4665b90a
31
web.d
31
web.d
|
|
@ -1482,20 +1482,28 @@ sizediff_t indexOfNew(string s, char a) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
sizediff_t lastIndexOfNew(string s, char a) {
|
||||||
* Returns the parameter names of the given function
|
for(sizediff_t i = s.length; i > 0; i--)
|
||||||
*
|
if(s[i - 1] == a)
|
||||||
* Params:
|
return i - 1;
|
||||||
* func = the function alias to get the parameter names of
|
return -1;
|
||||||
*
|
}
|
||||||
* Returns: an array of strings containing the parameter names
|
|
||||||
*/
|
|
||||||
|
// FIXME: a problem here is the compiler only keeps one stringof
|
||||||
|
// for a particular type
|
||||||
|
//
|
||||||
|
// so if you have void a(string a, string b); and void b(string b, string c),
|
||||||
|
// both a() and b() will show up as params == ["a", "b"]!
|
||||||
|
//
|
||||||
|
//
|
||||||
private string[][2] parameterInfoImpl (alias func) ()
|
private string[][2] parameterInfoImpl (alias func) ()
|
||||||
{
|
{
|
||||||
string funcStr = typeof(&func).stringof;
|
string funcStr = typeof(func).stringof; // this might fix the fixme above...
|
||||||
|
// it used to be typeof(&func).stringof
|
||||||
|
|
||||||
auto start = funcStr.indexOfNew('(');
|
auto start = funcStr.indexOfNew('(');
|
||||||
auto end = funcStr.indexOfNew(')');
|
auto end = funcStr.lastIndexOfNew(')');
|
||||||
|
|
||||||
assert(start != -1);
|
assert(start != -1);
|
||||||
assert(end != -1);
|
assert(end != -1);
|
||||||
|
|
@ -1925,7 +1933,7 @@ WrapperFunction generateWrapper(alias ObjectType, string funName, alias f, R)(Re
|
||||||
} else {
|
} else {
|
||||||
throw new InsufficientParametersException(funName, "arg " ~ name ~ " is not present");
|
throw new InsufficientParametersException(funName, "arg " ~ name ~ " is not present");
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
// We now check the type reported by the client, if there is one
|
// We now check the type reported by the client, if there is one
|
||||||
// Right now, only one type is supported: ServerResult, which means
|
// Right now, only one type is supported: ServerResult, which means
|
||||||
|
|
@ -1962,6 +1970,7 @@ WrapperFunction generateWrapper(alias ObjectType, string funName, alias f, R)(Re
|
||||||
args[i] = fromUrlParam!type(ofInterest);
|
args[i] = fromUrlParam!type(ofInterest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static if(!is(ReturnType!f == void))
|
static if(!is(ReturnType!f == void))
|
||||||
ReturnType!(f) ret;
|
ReturnType!(f) ret;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue