Commit b4943c8d authored by capresti's avatar capresti
Browse files

- Improved Metatables getMethod when working with float[], double[], int[]...

- Improved Metatables getMethod when working with float[], double[], int[] arrays and attempting to index them

git-svn-id: http://luainterface.googlecode.com/svn/trunk@12 63eb109e-e254-0410-a61e-ed0b8f8614f5
parent 7e4740d0
...@@ -161,9 +161,28 @@ namespace LuaInterface ...@@ -161,9 +161,28 @@ namespace LuaInterface
// Try to access by array if the type is right and index is an int (lua numbers always come across as double) // Try to access by array if the type is right and index is an int (lua numbers always come across as double)
if (objType.IsArray && index is double) if (objType.IsArray && index is double)
{ {
object[] arr = (object[])obj; int intIndex = (int)((double)index);
translator.push(luaState, arr[(int)((double)index)]); if (objType.UnderlyingSystemType == typeof(float[]))
{
float[] arr = ((float[])obj);
translator.push(luaState, arr[intIndex]);
}
else if (objType.UnderlyingSystemType == typeof(double[]))
{
double[] arr = ((double[])obj);
translator.push(luaState, arr[intIndex]);
}
else if (objType.UnderlyingSystemType == typeof(int[]))
{
int[] arr = ((int[])obj);
translator.push(luaState, arr[intIndex]);
}
else
{
object[] arr = (object[])obj;
translator.push(luaState, arr[intIndex]);
}
} }
else else
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment