当前位置: 首页>>代码示例>>C#>>正文


C# KopiLua.LuaState类代码示例

本文整理汇总了C#中KopiLua.LuaState的典型用法代码示例。如果您正苦于以下问题:C# KopiLua.LuaState类的具体用法?C# KopiLua.LuaState怎么用?C# KopiLua.LuaState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


KopiLua.LuaState类属于命名空间,在下文中一共展示了KopiLua.LuaState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Remove

        public void Remove(LuaState luaState)
        {
            if (!translators.ContainsKey (luaState))
                return;

            translators.Remove (luaState);
        }
开发者ID:jzgenius,项目名称:NLua,代码行数:7,代码来源:ObjectTranslatorPool.cs

示例2: Find

        public ObjectTranslator Find(LuaState luaState)
        {
            if (!translators.ContainsKey(luaState))
                return null;

            return translators [luaState];
        }
开发者ID:jzgenius,项目名称:NLua,代码行数:7,代码来源:ObjectTranslatorPool.cs

示例3: Find

        public ObjectTranslator Find(LuaState luaState)
        {
            if (translators.ContainsKey (luaState))
                return translators [luaState];

            LuaState main = LuaCore.LuaNetGetMainState (luaState);

            if (translators.ContainsKey (main))
                return translators [main];

            return null;
        }
开发者ID:unhappy224,项目名称:NLua,代码行数:12,代码来源:ObjectTranslatorPool.cs

示例4: Call

        /*
         * Calls the method. Receives the arguments from the Lua stack
         * and returns values in it.
         */
        int Call(LuaState luaState)
        {
            var methodToCall = _Method;
            object targetObject = _Target;
            bool failedCall = true;
            int nReturnValues = 0;

            if (!LuaLib.LuaCheckStack (luaState, 5))
                throw new LuaException ("Lua stack overflow");

            bool isStatic = (_BindingType & BindingFlags.Static) == BindingFlags.Static;
            SetPendingException (null);

            if (methodToCall == null) { // Method from name
                if (isStatic)
                    targetObject = null;
                else
                    targetObject = _ExtractTarget (luaState, 1);

                if (_LastCalledMethod.cachedMethod != null) { // Cached?
                    int numStackToSkip = isStatic ? 0 : 1; // If this is an instance invoe we will have an extra arg on the stack for the targetObject
                    int numArgsPassed = LuaLib.LuaGetTop (luaState) - numStackToSkip;
                    MethodBase method = _LastCalledMethod.cachedMethod;

                    if (numArgsPassed == _LastCalledMethod.argTypes.Length) { // No. of args match?
                        if (!LuaLib.LuaCheckStack (luaState, _LastCalledMethod.outList.Length + 6))
                            throw new LuaException ("Lua stack overflow");

                        object [] args = _LastCalledMethod.args;

                        try {
                            for (int i = 0; i < _LastCalledMethod.argTypes.Length; i++) {

                                MethodArgs type = _LastCalledMethod.argTypes [i];

                                int index = i + 1 + numStackToSkip;

                                Func<int, object> valueExtractor = (currentParam) => {
                                    return type.extractValue (luaState, currentParam);
                                };

                                if (_LastCalledMethod.argTypes [i].isParamsArray) {
                                    int count = index - _LastCalledMethod.argTypes.Length;
                                    Array paramArray = _Translator.TableToArray (valueExtractor, type.paramsArrayType, index, count);
                                    args [_LastCalledMethod.argTypes [i].index] = paramArray;
                                } else {
                                    args [type.index] = valueExtractor (index);
                                }

                                if (_LastCalledMethod.args [_LastCalledMethod.argTypes [i].index] == null &&
                                    !LuaLib.LuaIsNil (luaState, i + 1 + numStackToSkip))
                                    throw new LuaException (string.Format("argument number {0} is invalid",(i + 1)));
                            }

                            if ((_BindingType & BindingFlags.Static) == BindingFlags.Static)
                                _Translator.Push (luaState, method.Invoke (null, _LastCalledMethod.args));
                            else {
                                if (method.IsConstructor)
                                    _Translator.Push (luaState, ((ConstructorInfo)method).Invoke (_LastCalledMethod.args));
                                else
                                    _Translator.Push (luaState, method.Invoke (targetObject, _LastCalledMethod.args));
                            }

                            failedCall = false;
                        } catch (TargetInvocationException e) {
                            // Failure of method invocation
                            return SetPendingException (e.GetBaseException ());
                        } catch (Exception e) {
                            if (_Members.Length == 1) // Is the method overloaded?
                                // No, throw error
                                return SetPendingException (e);
                        }
                    }
                }

                // Cache miss
                if (failedCall) {
                    // System.Diagnostics.Debug.WriteLine("cache miss on " + methodName);
                    // If we are running an instance variable, we can now pop the targetObject from the stack
                    if (!isStatic) {
                        if (targetObject == null) {
                            _Translator.ThrowError (luaState, String.Format ("instance method '{0}' requires a non null target object", _MethodName));
                            LuaLib.LuaPushNil (luaState);
                            return 1;
                        }

                        LuaLib.LuaRemove (luaState, 1); // Pops the receiver
                    }

                    bool hasMatch = false;
                    string candidateName = null;

                    foreach (var member in _Members) {
                        candidateName = member.ReflectedType.Name + "." + member.Name;
                        var m = (MethodInfo)member;
                        bool isMethod = _Translator.MatchParameters (luaState, m, ref _LastCalledMethod);
//.........这里部分代码省略.........
开发者ID:nobitagamer,项目名称:NLua,代码行数:101,代码来源:LuaMethodWrapper.cs

示例5: Push

 /*
  * Pushes this table into the Lua stack
  */
 internal void Push(LuaState luaState)
 {
     LuaLib.LuaGetRef (luaState, _Reference);
 }
开发者ID:ProfessorXZ,项目名称:Addons,代码行数:7,代码来源:LuaTable.cs

示例6: LuaGetField

 public static void LuaGetField(LuaState luaState, int stackPos, string meta)
 {
     LuaCore.LuaGetField (luaState, stackPos, meta);
 }
开发者ID:nobitagamer,项目名称:NLua,代码行数:4,代码来源:LuaLib.cs

示例7: LuaError

 public static void LuaError(LuaState luaState)
 {
     LuaCore.LuaError (luaState);
 }
开发者ID:nobitagamer,项目名称:NLua,代码行数:4,代码来源:LuaLib.cs

示例8: LuaCreateTable

 public static void LuaCreateTable(LuaState luaState, int narr, int nrec)
 {
     LuaCore.LuaCreateTable (luaState, narr, nrec);
 }
开发者ID:nobitagamer,项目名称:NLua,代码行数:4,代码来源:LuaLib.cs

示例9: LuaCall

 public static void LuaCall(LuaState luaState, int nArgs, int nResults)
 {
     LuaCore.LuaCall (luaState, nArgs, nResults);
 }
开发者ID:nobitagamer,项目名称:NLua,代码行数:4,代码来源:LuaLib.cs

示例10: LuaSetTop

 public static void LuaSetTop(LuaState luaState, int newTop)
 {
     LuaCore.LuaSetTop (luaState, newTop);
 }
开发者ID:nobitagamer,项目名称:NLua,代码行数:4,代码来源:LuaLib.cs

示例11: LuaSetTable

 public static void LuaSetTable(LuaState luaState, int index)
 {
     LuaCore.LuaSetTable (luaState, index);
 }
开发者ID:nobitagamer,项目名称:NLua,代码行数:4,代码来源:LuaLib.cs

示例12: LuaSetMetatable

 public static void LuaSetMetatable(LuaState luaState, int objIndex)
 {
     LuaCore.LuaSetMetatable (luaState, objIndex);
 }
开发者ID:nobitagamer,项目名称:NLua,代码行数:4,代码来源:LuaLib.cs

示例13: LuaReplace

 public static void LuaReplace(LuaState luaState, int index)
 {
     LuaCore.LuaReplace (luaState, index);
 }
开发者ID:nobitagamer,项目名称:NLua,代码行数:4,代码来源:LuaLib.cs

示例14: LuaRef

 public static int LuaRef(LuaState luaState, int lockRef)
 {
     return lockRef != 0 ? LuaLRef (luaState, (int)LuaIndexes.Registry) : 0;
 }
开发者ID:nobitagamer,项目名称:NLua,代码行数:4,代码来源:LuaLib.cs

示例15: LuaRawSetI

 public static void LuaRawSetI(LuaState luaState, int tableIndex, int index)
 {
     LuaCore.LuaRawSetI (luaState, tableIndex, index);
 }
开发者ID:nobitagamer,项目名称:NLua,代码行数:4,代码来源:LuaLib.cs


注:本文中的KopiLua.LuaState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。