예제 #1
0
        void FillMethodArguments(LuaState luaState, int numStackToSkip)
        {
            object[] args = _lastCalledMethod.args;


            for (int i = 0; i < _lastCalledMethod.argTypes.Length; i++)
            {
                MethodArgs type = _lastCalledMethod.argTypes[i];

                int index = i + 1 + numStackToSkip;


                if (_lastCalledMethod.argTypes[i].IsParamsArray)
                {
                    int   count      = _lastCalledMethod.argTypes.Length - i;
                    Array paramArray = _translator.TableToArray(luaState, type.ExtractValue, type.ParameterType, index, count);
                    args[_lastCalledMethod.argTypes[i].Index] = paramArray;
                }
                else
                {
                    args[type.Index] = type.ExtractValue(luaState, index);
                }

                if (_lastCalledMethod.args[_lastCalledMethod.argTypes[i].Index] == null &&
                    !luaState.IsNil(i + 1 + numStackToSkip))
                {
                    throw new LuaException(string.Format("Argument number {0} is invalid", (i + 1)));
                }
            }
        }
예제 #2
0
        private void FillMethodArguments(LuaState luaState, int numStackToSkip)
        {
            var args = _lastCalledMethod.args;


            for (var i = 0; i < _lastCalledMethod.argTypes.Length; i++)
            {
                var type = _lastCalledMethod.argTypes[i];

                var index = i + 1 + numStackToSkip;


                if (_lastCalledMethod.argTypes[i].IsParamsArray)
                {
                    var count      = _lastCalledMethod.argTypes.Length - i;
                    var paramArray = ObjectTranslator.TableToArray(luaState, type.ExtractValue, type.ParameterType, index, count);
                    args[_lastCalledMethod.argTypes[i].Index] = paramArray;
                }
                else
                {
                    args[type.Index] = type.ExtractValue(luaState, index);
                }

                if (_lastCalledMethod.args[_lastCalledMethod.argTypes[i].Index] == null &&
                    !luaState.IsNil(i + 1 + numStackToSkip))
                {
                    throw new LuaException($"Argument number {(i + 1)} is invalid");
                }
            }
        }