//~LuaFunction()
//{
// if (reference != 0)
// interpreter.dispose(reference);
//}
//bool disposed = false;
//~LuaFunction()
//{
// Dispose(false);
//}
//public void Dispose()
//{
// Dispose(true);
// GC.SuppressFinalize(this);
//}
//public virtual void Dispose(bool disposeManagedResources)
//{
// if (!this.disposed)
// {
// if (disposeManagedResources)
// {
// if (_Reference != 0)
// _Interpreter.dispose(_Reference);
// }
// disposed = true;
// }
//}
/*
* Calls the function casting return values to the types
* in returnTypes
*/
internal object[] call(object[] args, Type[] returnTypes)
{
//return _Interpreter.callFunction(this, args, returnTypes);
int nArgs = 0;
int oldTop = LuaDLL.lua_gettop(L);
if (!LuaDLL.lua_checkstack(L, args.Length + 6))
{
throw new LuaException("Lua stack overflow");
}
translator.push(L, this);
if (args != null)
{
nArgs = args.Length;
for (int i = 0; i < args.Length; i++)
{
translator.push(L, args[i]);
}
}
int error = LuaDLL.lua_pcall(L, nArgs, -1, 0);
if (error != 0)
{
ThrowExceptionFromError(oldTop);
}
if (returnTypes != null)
{
return(translator.popValues(L, oldTop, returnTypes));
}
else
{
return(translator.popValues(L, oldTop));
}
}