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


C# LuaState.Type方法代码示例

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


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

示例1: TestSetGetGlobal

        public void TestSetGetGlobal()
        {
            LuaState L = null;
            using (L = new LuaState())
            {
                L.PushString("Value A");
                L.SetGlobal("a");
                Assert.Equal(0, L.GetTop());

                L.GetGlobal("a");
                Assert.Equal(1, L.GetTop());
                Assert.Equal(LuaType.String, L.Type(-1));

                L.GetGlobal("b");
                Assert.Equal(2, L.GetTop());
                Assert.Equal(LuaType.Nil, L.Type(-1));

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

示例2: 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

示例3: TestPushThread

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

示例4: TestRegister

        public void TestRegister()
        {
            LuaState L = null;
            using (L = new LuaState())
            {
                L.GetGlobal("a");
                Assert.Equal(1, L.GetTop());
                Assert.Equal(LuaType.Nil, L.Type(-1));

                L.Register("a", (l) => {
                    l.PushNumber(12.34);
                    return 0;
                });

                L.GetGlobal("a");
                Assert.Equal(2, L.GetTop());
                Assert.Equal(LuaType.Function, L.Type(-1));
            }
        }
开发者ID:ygrenier,项目名称:LuaN,代码行数:19,代码来源:LuaStateTest.cs

示例5: TestPushNumber

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

示例6: TestPushString

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

示例7: TestPushGlobalTable

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

示例8: TestNewUserData

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

示例9: TestPushFString

 public void TestPushFString()
 {
     LuaState L = null;
     using (L = new LuaState())
     {
         L.PushFString("-s-d-", 1234);
         L.PushFString("-%s-", "Text");
         L.PushFString("-%f-", 123.45);
         L.PushFString("-%d-", 987);
         L.PushFString("-%s-%s-", "Str", "Text");
         L.PushFString("-%s-%f-", "Str", 123.45);
         L.PushFString("-%s-%d-", "Str", 987);
         L.PushFString("-%f-%s-", 11.22, "Text");
         L.PushFString("-%f-%f-", 11.22, 123.45);
         L.PushFString("-%f-%d-", 11.22, 987);
         L.PushFString("-%d-%s-", 9988, "Text");
         L.PushFString("-%d-%f-", 9988, 123.45);
         L.PushFString("-%d-%d-", 9988, 987);
         Assert.Equal(13, L.GetTop());
         Assert.Equal(LuaType.String, L.Type(-1));
         Assert.Equal("-s-d-", L.ToString(1));
         Assert.Equal("-Text-", L.ToString(2));
         Assert.Equal("-123.45-", L.ToString(3));
         Assert.Equal("-987-", L.ToString(4));
         Assert.Equal("-Str-Text-", L.ToString(5));
         Assert.Equal("-Str-123.45-", L.ToString(6));
         Assert.Equal("-Str-987-", L.ToString(7));
         Assert.Equal("-11.22-Text-", L.ToString(8));
         Assert.Equal("-11.22-123.45-", L.ToString(9));
         Assert.Equal("-11.22-987-", L.ToString(10));
         Assert.Equal("-9988-Text-", L.ToString(11));
         Assert.Equal("-9988-123.45-", L.ToString(12));
         Assert.Equal("-9988-987-", L.ToString(13));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:35,代码来源:LuaStateTest.cs

示例10: TestPushFunction

        public void TestPushFunction()
        {
            LuaState L = null;
            using (L = new LuaState())
            {
                L.PushFunction((l) => {
                    l.PushNumber(12.34);
                    return 0;
                });
                Assert.Equal(1, L.GetTop());
                Assert.Equal(LuaType.Function, L.Type(-1));

                Assert.Throws<ArgumentNullException>(() => L.PushFunction(null));
            }
        }
开发者ID:ygrenier,项目名称:LuaN,代码行数:15,代码来源:LuaStateTest.cs

示例11: TestPushCClosure

 public void TestPushCClosure()
 {
     LuaState L = null;
     using (L = new LuaState())
     {
         LuaFunction f = l => 0;
         L.PushCClosure(f, 0);
         Assert.Equal(1, L.GetTop());
         Assert.Equal(LuaType.Function, L.Type(-1));
         Assert.Same(f, L.ToCFunction(-1));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:12,代码来源:LuaStateTest.cs

示例12: TestPushBoolean

 public void TestPushBoolean()
 {
     LuaState L = null;
     using (L = new LuaState())
     {
         L.PushBoolean(true);
         L.PushBoolean(false);
         Assert.Equal(2, L.GetTop());
         Assert.Equal(LuaType.Boolean, L.Type(-1));
         Assert.Equal(LuaType.Boolean, L.Type(-2));
         Assert.Equal(false, L.ToBoolean(-1));
         Assert.Equal(true, L.ToBoolean(-2));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:14,代码来源:LuaStateTest.cs

示例13: 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

示例14: 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

示例15: TestPushLightUserData

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


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