Closed GoogleCodeExporter closed 9 years ago
I've added support for this functionality as of revision 17.
I've tested it pretty thoroughly, but it would be awesome if people could grab
the r17 version and check it out as well.
Original comment by eonstorm@gmail.com
on 3 Jul 2010 at 3:29
In my testing i could never get it to call the new code in r17 for a params
argument
i was able to hack in my own support to make it work like i wanted in
Metatables.c line 820, basicly if last ParameterInfo for a method and it is a
params you know any remaining arguments should be added to the args array,
currently they are not and it throws out invalid arguents, i hacked in support
that loops remaining args and adds them to the args array, using this code it
allows you to use function({arg, arg2}) or function (arg, arg2), all i did was
add an else if check to see if any remaining arguments after current and if so
loop them and add to params array, now not sure how good this code is but fixes
the problem for me and allows me to call functions with out the {}
Code:
else if (currentLuaParam < nLuaParams)
{
int idx = 1;
paramArray = Array.CreateInstance(paramArrayType, nLuaParams - currentLuaParam + 1);
paramArray.SetValue(luaParamValue, 0);
currentLuaParam++;
while (currentLuaParam <= nLuaParams && _IsParamsArray(luaState, currentLuaParam, currentNetParam, out extractValue))
{
luaParamValue = extractValue(luaState, currentLuaParam);
paramArrayType = currentNetParam.ParameterType.GetElementType();
paramArray.SetValue(luaParamValue, idx);
currentLuaParam++;
idx++;
}
currentLuaParam--;
}
Original comment by icewolfz...@gmail.com
on 16 Jul 2010 at 3:27
another error i found but am still trying to fix is function() for params as in
.net if no params it is still a valid function call but in lua it reports as
invalid arguments
Original comment by icewolfz...@gmail.com
on 16 Jul 2010 at 3:41
another error i found but am still trying to fix is function() for params as in
.net if no params it is still a valid function call but in lua it reports as
invalid arguments
Original comment by icewolfz...@gmail.com
on 16 Jul 2010 at 3:41
i was able to fix params if none and it is of type param array
line 775 of metatables.c if you add a elseif to check if a params array and add
a empty array of type as value it fixes it.
also had to add a 2nd IsParamsArray, just returns true or false and nothing
nothing else
code :
else if (_IsParamsArray(luaState, currentLuaParam, currentNetParam))
{
paramList.Add(Array.CreateInstance(currentNetParam.ParameterType.GetElementType(
), 0));
}
private bool _IsParamsArray(IntPtr luaState, int currentLuaParam, ParameterInfo currentNetParam)
{
if (currentNetParam.GetCustomAttributes(typeof(ParamArrayAttribute), false).Length > 0)
return true;
Debug.WriteLine("Type wasn't Params object.");
return false;
}
Original comment by icewolfz...@gmail.com
on 16 Jul 2010 at 3:59
a patch of my changes to metatables.c
Original comment by icewolfz...@gmail.com
on 16 Jul 2010 at 4:03
Attachments:
Original issue reported on code.google.com by
eonstorm@gmail.com
on 3 Jul 2010 at 2:59