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


C# LuaState.PushNil方法代码示例

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


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

示例1: TestIsUserData

 public void TestIsUserData()
 {
     LuaState L = null;
     using (L = new LuaState())
     {
         L.PushNil()
             .PushNumber(123.45)
             .PushInteger(987)
             .PushString("Test")
             .PushString("5.6")
             .PushString("5D")
             .PushString("5")
             .PushBoolean(true)
             .PushCClosure(l => 0, 0)
             //.PushLightUserData(DateTime.Now)
             .PushGlobalTable()
             ;
         Assert.False(L.IsUserData(1));
         Assert.False(L.IsUserData(2));
         Assert.False(L.IsUserData(3));
         Assert.False(L.IsUserData(4));
         Assert.False(L.IsUserData(5));
         Assert.False(L.IsUserData(6));
         Assert.False(L.IsUserData(7));
         Assert.False(L.IsUserData(8));
         Assert.False(L.IsUserData(9));
         Assert.False(L.IsUserData(10));
         Assert.False(L.IsUserData(11));
         Assert.False(L.IsUserData(12));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:31,代码来源:LuaStateTest.cs

示例2: TestTypeName

 public void TestTypeName()
 {
     LuaState L = null;
     using (L = new LuaState())
     {
         L.PushNil()
             .PushNumber(123.45)
             .PushInteger(987)
             .PushString("Test")
             .PushString("5.6")
             .PushString("5D")
             .PushString("5")
             .PushBoolean(true)
             .PushCClosure(l => 0, 0)
             //.PushLightUserData(DateTime.Now)
             .PushGlobalTable()
             ;
         Assert.Equal("nil", L.TypeName(L.Type(1)));
         Assert.Equal("number", L.TypeName(L.Type(2)));
         Assert.Equal("number", L.TypeName(L.Type(3)));
         Assert.Equal("string", L.TypeName(L.Type(4)));
         Assert.Equal("string", L.TypeName(L.Type(5)));
         Assert.Equal("string", L.TypeName(L.Type(6)));
         Assert.Equal("string", L.TypeName(L.Type(7)));
         Assert.Equal("boolean", L.TypeName(L.Type(8)));
         Assert.Equal("function", L.TypeName(L.Type(9)));
         Assert.Equal("table", L.TypeName(L.Type(10)));
         Assert.Equal("no value", L.TypeName(L.Type(11)));
         Assert.Equal("no value", L.TypeName(L.Type(12)));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:31,代码来源:LuaStateTest.cs

示例3: TestIsFunction

 public void TestIsFunction()
 {
     LuaState L = null;
     using (L = new LuaState())
     {
         L.PushNil()
             .PushNumber(123.45)
             .PushInteger(987)
             .PushString("Test")
             .PushString("5.6")
             .PushString("5D")
             .PushString("5z")
             .PushBoolean(true)
             .PushCClosure(l => 0, 0)
             //.PushLightUserData(DateTime.Now)
             .PushGlobalTable()
             ;
         // TODO Add test with Lua script function
         Assert.False(L.IsFunction(1));
         Assert.False(L.IsFunction(2));
         Assert.False(L.IsFunction(3));
         Assert.False(L.IsFunction(4));
         Assert.False(L.IsFunction(5));
         Assert.False(L.IsFunction(6));
         Assert.False(L.IsFunction(7));
         Assert.False(L.IsFunction(8));
         Assert.True(L.IsFunction(9));
         Assert.False(L.IsFunction(10));
         Assert.False(L.IsFunction(11));
         Assert.False(L.IsFunction(12));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:32,代码来源:LuaStateTest.cs

示例4: TestToUserData

 public void TestToUserData()
 {
     LuaState L = null;
     using (L = new LuaState())
     {
         DateTime dt = DateTime.Now;
         LuaFunction f = l => 0;
         L.PushNil()
             .PushNumber(123.45)
             .PushInteger(987)
             .PushString("Test")
             .PushString("5.6")
             .PushString("5D")
             .PushString("5z")
             .PushBoolean(true)
             .PushCClosure(f, 0)
             .PushLightUserData(dt)
             .PushGlobalTable()
             ;
         Assert.Equal(null, L.ToUserData(1));
         Assert.Equal(null, L.ToUserData(2));
         Assert.Equal(null, L.ToUserData(3));
         Assert.Equal(null, L.ToUserData(4));
         Assert.Equal(null, L.ToUserData(5));
         Assert.Equal(null, L.ToUserData(6));
         Assert.Equal(null, L.ToUserData(7));
         Assert.Equal(null, L.ToUserData(8));
         Assert.Equal(null, L.ToUserData(9));
         Assert.Equal(dt, L.ToUserData(10));
         Assert.Equal(null, L.ToUserData(11));
         Assert.Equal(null, L.ToUserData(12));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:33,代码来源:LuaStateTest.cs

示例5: TestType

 public void TestType()
 {
     LuaState L = null;
     using (L = new LuaState())
     {
         L.PushNil()
             .PushNumber(123.45)
             .PushInteger(987)
             .PushString("Test")
             .PushString("5.6")
             .PushString("5D")
             .PushString("5")
             .PushBoolean(true)
             .PushCClosure(l => 0, 0)
             //.PushLightUserData(DateTime.Now)
             .PushGlobalTable()
             ;
         Assert.Equal(LuaType.Nil, L.Type(1));
         Assert.Equal(LuaType.Number, L.Type(2));
         Assert.Equal(LuaType.Number, L.Type(3));
         Assert.Equal(LuaType.String, L.Type(4));
         Assert.Equal(LuaType.String, L.Type(5));
         Assert.Equal(LuaType.String, L.Type(6));
         Assert.Equal(LuaType.String, L.Type(7));
         Assert.Equal(LuaType.Boolean, L.Type(8));
         Assert.Equal(LuaType.Function, L.Type(9));
         Assert.Equal(LuaType.Table, L.Type(10));
         Assert.Equal(LuaType.None, L.Type(11));
         Assert.Equal(LuaType.None, L.Type(12));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:31,代码来源:LuaStateTest.cs

示例6: TestToThread

 public void TestToThread()
 {
     LuaState L = null;
     using (L = new LuaState())
     {
         LuaFunction f = l => 0;
         L.PushNil()
             .PushNumber(123.45)
             .PushInteger(987)
             .PushString("Test")
             .PushString("5.6")
             .PushString("5D")
             .PushString("5z")
             .PushBoolean(true)
             .PushCClosure(f, 0)
             //.PushLightUserData(DateTime.Now)
             .PushGlobalTable()
             ;
         L.PushThread();
         Assert.Equal(null, L.ToThread(1));
         Assert.Equal(null, L.ToThread(2));
         Assert.Equal(null, L.ToThread(3));
         Assert.Equal(null, L.ToThread(4));
         Assert.Equal(null, L.ToThread(5));
         Assert.Equal(null, L.ToThread(6));
         Assert.Equal(null, L.ToThread(7));
         Assert.Equal(null, L.ToThread(8));
         Assert.Equal(null, L.ToThread(9));
         Assert.Equal(null, L.ToThread(10));
         Assert.Same(L, L.ToThread(11));
         Assert.Equal(null, L.ToThread(12));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:33,代码来源:LuaStateTest.cs

示例7: TestToNumber

        public void TestToNumber()
        {
            LuaState L = null;
            using (L = new LuaState())
            {
                L.PushNil()
                    .PushNumber(123.45)
                    .PushInteger(987)
                    .PushString("Test")
                    .PushString("5.6")
                    .PushString("5D")
                    .PushString("5z")
                    .PushBoolean(true)
                    .PushCClosure(l => 0, 0)
                    //.PushLightUserData(DateTime.Now)
                    .PushGlobalTable()
                    ;

                bool isnum;
                Assert.Equal(0.0, L.ToNumber(1));
                Assert.Equal(0.0, L.ToNumber(1, out isnum));
                Assert.Equal(false, isnum);

                Assert.Equal(123.45, L.ToNumber(2));
                Assert.Equal(123.45, L.ToNumber(2, out isnum));
                Assert.Equal(true, isnum);

                Assert.Equal(987.0, L.ToNumber(3));
                Assert.Equal(987.0, L.ToNumber(3, out isnum));
                Assert.Equal(true, isnum);

                Assert.Equal(0.0, L.ToNumber(4));
                Assert.Equal(0.0, L.ToNumber(4, out isnum));
                Assert.Equal(false, isnum);

                Assert.Equal(5.6, L.ToNumber(5));
                Assert.Equal(5.6, L.ToNumber(5, out isnum));
                Assert.Equal(true, isnum);

                Assert.Equal(0.0, L.ToNumber(6));
                Assert.Equal(0.0, L.ToNumber(7));
                Assert.Equal(0.0, L.ToNumber(8));
                Assert.Equal(0.0, L.ToNumber(9));
                Assert.Equal(0.0, L.ToNumber(10));
                Assert.Equal(0.0, L.ToNumber(11));
                Assert.Equal(0.0, L.ToNumber(12));
            }
        }
开发者ID:ygrenier,项目名称:LuaN,代码行数:48,代码来源:LuaStateTest.cs

示例8: TestToBoolean

 public void TestToBoolean()
 {
     LuaState L = null;
     using (L = new LuaState())
     {
         L.PushNil()
             .PushNumber(123.45)
             .PushInteger(987)
             .PushString("Test")
             .PushString("5.6")
             .PushString("5D")
             .PushString("5z")
             .PushBoolean(true)
             .PushCClosure(l => 0, 0)
             //.PushLightUserData(DateTime.Now)
             .PushGlobalTable()
             ;
         Assert.Equal(false, L.ToBoolean(1));
         Assert.Equal(true, L.ToBoolean(2));
         Assert.Equal(true, L.ToBoolean(3));
         Assert.Equal(true, L.ToBoolean(4));
         Assert.Equal(true, L.ToBoolean(5));
         Assert.Equal(true, L.ToBoolean(6));
         Assert.Equal(true, L.ToBoolean(7));
         Assert.Equal(true, L.ToBoolean(8));
         Assert.Equal(true, L.ToBoolean(9));
         Assert.Equal(true, L.ToBoolean(10));
         Assert.Equal(false, L.ToBoolean(11));
         Assert.Equal(false, L.ToBoolean(12));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:31,代码来源:LuaStateTest.cs

示例9: TestPushNil

 public void TestPushNil()
 {
     LuaState L = null;
     using (L = new LuaState())
     {
         L.PushNil();
         Assert.Equal(1, L.GetTop());
         Assert.Equal(LuaType.Nil, L.Type(-1));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:10,代码来源:LuaStateTest.cs

示例10: TestNext

        public void TestNext()
        {
            LuaState L = null;
            using (L = new LuaState())
            {
                L.NewTable();
                var t = L.GetTop();
                L.PushString("Value A");
                L.SetField(t, "a");
                L.PushString("Value 2");
                L.SetI(t, 2);
                Assert.Equal(1, L.GetTop());

                int count = 0;
                bool foundA = false;
                // First Key
                L.PushNil();
                while (L.Next(t))
                {
                    count++;
                    // => 'key' at index -2 , 'value' as index -1
                    if (LuaType.String == L.Type(-2))
                    {
                        Assert.False(foundA);
                        Assert.Equal(LuaType.String, L.Type(-2));
                        Assert.Equal("a", L.ToString(-2));
                        Assert.Equal(LuaType.String, L.Type(-1));
                        Assert.Equal("Value A", L.ToString(-1));
                        foundA = true;
                    }
                    else
                    {
                        // Second key
                        Assert.Equal(LuaType.Number, L.Type(-2));
                        Assert.Equal(2, L.ToInteger(-2));
                        Assert.Equal(LuaType.String, L.Type(-1));
                        Assert.Equal("Value 2", L.ToString(-1));
                    }
                    // Remove 'value' and keep the 'key' on the stack for the next key
                    L.Pop(1);
                }
                Assert.Equal(2, count);
                Assert.True(foundA);
                // No more key
                // The stack is cleaned
                Assert.Equal(1, L.GetTop());

            }
        }
开发者ID:ygrenier,项目名称:LuaN,代码行数:49,代码来源:LuaStateTest.cs


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