• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# KopiLua.LuaState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: LuaUnref

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


示例17: LuaAtPanic

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


示例18: LuaToBoolean

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


示例19: LuaCheckStack

 public static bool LuaCheckStack(LuaState luaState, int extra)
 {
     return LuaCore.LuaCheckStack (luaState, extra) != 0;
 }
开发者ID:nobitagamer,项目名称:NLua,代码行数:4,代码来源:LuaLib.cs


示例20: LuaToCFunction

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Ats.IBNet类代码示例发布时间:2022-05-24
下一篇:
C# KopiLua.Lua类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap