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


C# SharpLua类代码示例

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


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

示例1: push

 /*
  * Pushes the function into the Lua stack
  */
 internal void push(SharpLua.Lua.LuaState luaState)
 {
     if (_Reference != 0)
         LuaDLL.lua_getref(luaState, _Reference);
     else
         _Interpreter.pushCSFunction(function);
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:10,代码来源:LuaFunction.cs

示例2: LuaInterface

        /// <summary>
        /// CAUTION: LuaInterface's can't share the same lua state!
        /// </summary>
        /// <param name="lState"></param>
        public LuaInterface(SharpLua.Lua.LuaState lState)
        {
            lState.initializing = true;
            LuaDLL.lua_pushstring(lState, "LUAINTERFACE LOADED");
            LuaDLL.lua_gettable(lState, (int)LuaIndexes.LUA_REGISTRYINDEX);

            if (LuaDLL.lua_toboolean(lState, -1))
            {
                LuaDLL.lua_settop(lState, -2);
                throw new LuaException("There is already a LuaInterface associated with this LuaState");
            }
            else
            {
                LuaDLL.lua_settop(lState, -2);
                LuaDLL.lua_pushstring(lState, "LUAINTERFACE LOADED");
                LuaDLL.lua_pushboolean(lState, true);
                LuaDLL.lua_settable(lState, (int)LuaIndexes.LUA_REGISTRYINDEX);
                this.luaState = lState;
                LuaDLL.lua_pushvalue(lState, (int)LuaIndexes.LUA_GLOBALSINDEX);
                LuaDLL.lua_getglobal(lState, "luanet");
                LuaDLL.lua_pushstring(lState, "getmetatable");
                LuaDLL.lua_getglobal(lState, "getmetatable");
                LuaDLL.lua_settable(lState, -3);
                LuaDLL.lua_replace(lState, (int)LuaIndexes.LUA_GLOBALSINDEX);
                translator = new ObjectTranslator(this, this.luaState);
                LuaDLL.lua_replace(lState, (int)LuaIndexes.LUA_GLOBALSINDEX);
                DoString(ScriptStrings.InitLuaNet, "LuaNet");
                DoString(ScriptStrings.InitClrLib, "ClrLib");
                DoString(ScriptStrings.InitExtLib, "ExtLib");
            }
            _StatePassed = true;
            lState.initializing = false;
        }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:37,代码来源:Lua.cs

示例3: createIndexingMetaFunction

 /*
  * Registers the indexing function of CLR objects
  * passed to Lua
  */
 private void createIndexingMetaFunction(SharpLua.Lua.LuaState luaState)
 {
     LuaDLL.lua_pushstring(luaState, "luaNet_indexfunction");
     LuaDLL.luaL_dostring(luaState, MetaFunctions.luaIndexFunction);	// steffenj: lua_dostring renamed to luaL_dostring
     //LuaDLL.lua_pushstdcallcfunction(luaState,indexFunction);
     LuaDLL.lua_rawset(luaState, (int)LuaIndexes.LUA_REGISTRYINDEX);
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:11,代码来源:ObjectTranslator.cs

示例4: RegisterModule

 public void RegisterModule(SharpLua.LuaTypes.LuaTable environment)
 {
     LuaTable mod = new LuaTable();
     RegisterFunctions(mod);
     
     LuaTable mt = new LuaTable();
     mt.Register("__newindex", (LuaValue[] args) =>
                 {
                     string key = args[1].ToString();
                     if (key.ToLower() == "key")
                     {
                         CryptoLib.key = IExtendFramework.Encryption.SampleObjects.CreateRijndaelKeyWithSHA512(args[2].ToString());
                         Console.WriteLine("Encryption Key is now " + ByteToString(CryptoLib.key));
                     }
                     else if (key.ToLower() == "iv")
                     {
                         iv = IExtendFramework.Encryption.SampleObjects.CreateRijndaelIVWithSHA512(args[2].ToString());
                         Console.WriteLine("Encryption IV is now " + ByteToString(CryptoLib.iv));
                     }
                     
                     return LuaNil.Nil;
                 });
     mod.MetaTable = mt;
     environment.SetNameValue(ModuleName, mod);
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:25,代码来源:MyClass.cs

示例5: createLuaObjectList

 /*
  * Sets up the list of objects in the Lua side
  */
 private void createLuaObjectList(SharpLua.Lua.LuaState luaState)
 {
     LuaDLL.lua_pushstring(luaState, "luaNet_objects");
     LuaDLL.lua_newtable(luaState);
     LuaDLL.lua_newtable(luaState);
     LuaDLL.lua_pushstring(luaState, "__mode");
     LuaDLL.lua_pushstring(luaState, "v");
     LuaDLL.lua_settable(luaState, -3);
     LuaDLL.lua_setmetatable(luaState, -2);
     LuaDLL.lua_settable(luaState, (int)LuaIndexes.LUA_REGISTRYINDEX);
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:14,代码来源:ObjectTranslator.cs

示例6: collectObject

 /*
  * __gc metafunction of CLR objects.
  */
 private int collectObject(SharpLua.Lua.LuaState luaState)
 {
     int udata = LuaDLL.luanet_rawnetobj(luaState, 1);
     if (udata != -1)
     {
         translator.collectObject(udata);
     }
     else
     {
         // Debug.WriteLine("not found: " + udata);
     }
     return 0;
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:16,代码来源:Metatables.cs

示例7: createBaseClassMetatable

 /*
  * Creates the metatable for superclasses (the base
  * field of registered tables)
  */
 private void createBaseClassMetatable(SharpLua.Lua.LuaState luaState)
 {
     LuaDLL.luaL_newmetatable(luaState, "luaNet_searchbase");
     LuaDLL.lua_pushstring(luaState, "__gc");
     LuaDLL.lua_pushstdcallcfunction(luaState, metaFunctions.gcFunction);
     LuaDLL.lua_settable(luaState, -3);
     LuaDLL.lua_pushstring(luaState, "__tostring");
     LuaDLL.lua_pushstdcallcfunction(luaState, metaFunctions.toStringFunction);
     LuaDLL.lua_settable(luaState, -3);
     LuaDLL.lua_pushstring(luaState, "__index");
     LuaDLL.lua_pushstdcallcfunction(luaState, metaFunctions.baseIndexFunction);
     LuaDLL.lua_settable(luaState, -3);
     LuaDLL.lua_pushstring(luaState, "__newindex");
     LuaDLL.lua_pushstdcallcfunction(luaState, metaFunctions.newindexFunction);
     LuaDLL.lua_settable(luaState, -3);
     LuaDLL.lua_settop(luaState, -2);
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:21,代码来源:ObjectTranslator.cs

示例8: ObjectTranslator

        public ObjectTranslator(LuaInterface interpreter, SharpLua.Lua.LuaState luaState)
        {
            this.interpreter = interpreter;
            typeChecker = new CheckType(this);
            metaFunctions = new MetaFunctions(this);

            importTypeFunction = new SharpLua.Lua.lua_CFunction(this.importType);
            loadAssemblyFunction = new SharpLua.Lua.lua_CFunction(this.loadAssembly);
            registerTableFunction = new SharpLua.Lua.lua_CFunction(this.registerTable);
            unregisterTableFunction = new SharpLua.Lua.lua_CFunction(this.unregisterTable);
            getMethodSigFunction = new SharpLua.Lua.lua_CFunction(this.getMethodSignature);
            getConstructorSigFunction = new SharpLua.Lua.lua_CFunction(this.getConstructorSignature);

            ctypeFunction = new SharpLua.Lua.lua_CFunction(this.ctype);
            enumFromIntFunction = new SharpLua.Lua.lua_CFunction(this.enumFromInt);

            createLuaObjectList(luaState);
            createIndexingMetaFunction(luaState);
            createBaseClassMetatable(luaState);
            createClassMetatable(luaState);
            createFunctionMetatable(luaState);
            setGlobalFunctions(luaState);
        }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:23,代码来源:ObjectTranslator.cs

示例9: getAsBoolean

 private object getAsBoolean(SharpLua.Lua.LuaState luaState, int stackPos)
 {
     return LuaDLL.lua_toboolean(luaState, stackPos);
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:4,代码来源:CheckType.cs

示例10: getAsDecimal

 private object getAsDecimal(SharpLua.Lua.LuaState luaState, int stackPos)
 {
     decimal retVal = (decimal)LuaDLL.lua_tonumber(luaState, stackPos);
     if (retVal == 0 && !LuaDLL.lua_isnumber(luaState, stackPos)) return null;
     return retVal;
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:6,代码来源:CheckType.cs

示例11: LuaFunction

 public LuaFunction(SharpLua.Lua.lua_CFunction function, LuaInterface interpreter)
 {
     _Reference = 0;
     this.function = function;
     _Interpreter = interpreter;
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:6,代码来源:LuaFunction.cs

示例12: getAsNetObject

 public object getAsNetObject(SharpLua.Lua.LuaState luaState, int stackPos)
 {
     object obj = translator.getNetObject(luaState, stackPos);
     if (obj == null && LuaDLL.lua_type(luaState, stackPos) == LuaTypes.LUA_TTABLE)
     {
         if (LuaDLL.luaL_getmetafield(luaState, stackPos, "__index"))
         {
             if (LuaDLL.luaL_checkmetatable(luaState, -1))
             {
                 LuaDLL.lua_insert(luaState, stackPos);
                 LuaDLL.lua_remove(luaState, stackPos + 1);
                 obj = translator.getNetObject(luaState, stackPos);
             }
             else
             {
                 LuaDLL.lua_settop(luaState, -2);
             }
         }
     }
     return obj;
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:21,代码来源:CheckType.cs

示例13: getAsFunction

 private object getAsFunction(SharpLua.Lua.LuaState luaState, int stackPos)
 {
     return translator.getFunction(luaState, stackPos);
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:4,代码来源:CheckType.cs

示例14: checkudata_raw

        private static object checkudata_raw(SharpLua.Lua.LuaState L, int ud, string tname)
        {
            object p = SharpLua.Lua.lua_touserdata(L, ud);

            if (p != null)
            {  /* value is a userdata? */
                if (SharpLua.Lua.lua_getmetatable(L, ud) != 0)
                {
                    bool isEqual;

                    /* does it have a metatable? */
                    SharpLua.Lua.lua_getfield(L, (int)LuaIndexes.LUA_REGISTRYINDEX, tname);  /* get correct metatable */

                    isEqual = SharpLua.Lua.lua_rawequal(L, -1, -2) != 0;

                    // NASTY - we need our own version of the lua_pop macro
                    // lua_pop(L, 2);  /* remove both metatables */
                    SharpLua.Lua.lua_settop(L, -(2) - 1);

                    if (isEqual)   /* does it have the correct mt? */
                        return p;
                }
            }

            return null;
        }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:26,代码来源:LuaDLL.cs

示例15: luaL_where

 //[DllImport(LUADLL,CallingConvention=CallingConvention.Cdecl)]
 public static void luaL_where(SharpLua.Lua.LuaState luaState, int level)
 {
     SharpLua.Lua.luaL_where(luaState, level);
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:5,代码来源:LuaDLL.cs


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