Esempio n. 1
0
 static int SetValue(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         LuaPerfect.ObjectItem obj = (LuaPerfect.ObjectItem)ToLua.CheckObject <LuaPerfect.ObjectItem>(L, 1);
         string arg0 = ToLua.CheckString(L, 2);
         obj.SetValue(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 2
0
 static int StaticGetValue(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         LuaPerfect.ObjectItem arg0 = (LuaPerfect.ObjectItem)ToLua.CheckObject <LuaPerfect.ObjectItem>(L, 1);
         string o = LuaPerfect.ObjectItem.StaticGetValue(arg0);
         LuaDLL.lua_pushstring(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 3
0
 static int GetChildCount(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         LuaPerfect.ObjectItem obj = (LuaPerfect.ObjectItem)ToLua.CheckObject <LuaPerfect.ObjectItem>(L, 1);
         int o = obj.GetChildCount();
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 4
0
 static int StaticGetChildObjectByName(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         LuaPerfect.ObjectItem arg0 = (LuaPerfect.ObjectItem)ToLua.CheckObject <LuaPerfect.ObjectItem>(L, 1);
         string arg1            = ToLua.CheckString(L, 2);
         LuaPerfect.ObjectRef o = LuaPerfect.ObjectItem.StaticGetChildObjectByName(arg0, arg1);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 5
0
 static int StaticGetChildObject(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         LuaPerfect.ObjectItem arg0 = (LuaPerfect.ObjectItem)ToLua.CheckObject <LuaPerfect.ObjectItem>(L, 1);
         int arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
         LuaPerfect.ObjectRef o = LuaPerfect.ObjectItem.StaticGetChildObject(arg0, arg1);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 6
0
 static int GetChildName(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         LuaPerfect.ObjectItem obj = (LuaPerfect.ObjectItem)ToLua.CheckObject <LuaPerfect.ObjectItem>(L, 1);
         int    arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         string o    = obj.GetChildName(arg0);
         LuaDLL.lua_pushstring(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 7
0
 static int InnerFormatObject(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         object arg0             = ToLua.ToVarObject(L, 1);
         bool   arg1             = LuaDLL.luaL_checkboolean(L, 2);
         LuaPerfect.ObjectItem o = LuaPerfect.ObjectFormater.InnerFormatObject(arg0, arg1);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 8
0
 static int AddChild(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         LuaPerfect.ObjectItem obj = (LuaPerfect.ObjectItem)ToLua.CheckObject <LuaPerfect.ObjectItem>(L, 1);
         string arg0 = ToLua.CheckString(L, 2);
         object arg1 = ToLua.ToVarObject(L, 3);
         obj.AddChild(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 9
0
    static int get_childObjectRefList(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            LuaPerfect.ObjectItem obj = (LuaPerfect.ObjectItem)o;
            System.Collections.Generic.List <LuaPerfect.ObjectRef> ret = obj.childObjectRefList;
            ToLua.PushSealed(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index childObjectRefList on a nil value"));
        }
    }
Esempio n. 10
0
    static int set_childObjectRefList(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            LuaPerfect.ObjectItem obj = (LuaPerfect.ObjectItem)o;
            System.Collections.Generic.List <LuaPerfect.ObjectRef> arg0 = (System.Collections.Generic.List <LuaPerfect.ObjectRef>)ToLua.CheckObject(L, 2, typeof(System.Collections.Generic.List <LuaPerfect.ObjectRef>));
            obj.childObjectRefList = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index childObjectRefList on a nil value"));
        }
    }
Esempio n. 11
0
        public static ObjectItem FormatObject(System.Object obj, bool collectChildren)
        {
            System.Object obj1 = obj;
            if (obj.GetType() == typeof(ObjectRef))
            {
                ObjectRef objectRef = (ObjectRef)obj;
                obj1 = ObjectCache.GetObject(objectRef.objectID);
            }
            ObjectItem objectItem = null;

            try
            {
                objectItem = InnerFormatObject(obj1, collectChildren);
            }
            catch
            {
                objectItem = new ObjectItem();
            }
            return(objectItem);
        }
Esempio n. 12
0
    static int _CreateLuaPerfect_ObjectItem(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                LuaPerfect.ObjectItem obj = new LuaPerfect.ObjectItem();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: LuaPerfect.ObjectItem.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Esempio n. 13
0
        public static ObjectItem InnerFormatObject(System.Object obj, bool collectChildren)
        {
            ObjectItem objectItem = new ObjectItem();

            if (obj == null)
            {
                objectItem.SetValue("null");
                return(objectItem);
            }
            Type type = obj.GetType();

            if (IsBasicType(type))
            {
                if (type == typeof(System.Boolean))
                {
                    objectItem.SetValue((bool)obj ? "true" : "false");
                }
                else if (type == typeof(System.String))
                {
                    objectItem.SetValue("\"" + (string)obj + "\"");
                }
                else
                {
                    objectItem.SetValue(obj.ToString());
                }
            }
            else if (type.IsEnum)
            {
                objectItem.SetValue(obj.ToString());
            }
            else if (type == typeof(ArrayList))
            {
                ArrayList arrayList = (ArrayList)obj;
                objectItem.SetValue(String.Format("<C# ArrayList> Count = {0}", arrayList.Count));
                if (collectChildren)
                {
                    int i = 0;
                    foreach (object obj1 in arrayList)
                    {
                        string name = i.ToString();
                        objectItem.AddChild(name, obj1);
                        i++;
                    }
                }
            }
            else if (type == typeof(Hashtable))
            {
                Hashtable hashtable = (Hashtable)obj;
                objectItem.SetValue(String.Format("<C# Hashtable> Count = {0}", hashtable.Count));
                if (collectChildren)
                {
                    foreach (object key in hashtable.Keys)
                    {
                        string name = key.ToString();
                        objectItem.AddChild(name, hashtable[key]);
                    }
                }
            }
            else if (type.IsArray)
            {
                Array array = (Array)obj;
                objectItem.SetValue(String.Format("<C# Array> Length = {0}", array.Length));
                if (collectChildren)
                {
                    int i = 0;
                    foreach (object obj1 in array)
                    {
                        string name = i.ToString();
                        objectItem.AddChild(name, obj1);
                        i++;
                    }
                }
            }
            else
            {
                ClassInfoItem classInfoItem = GetClassInfo(type);
                if (classInfoItem != null)
                {
                    objectItem.SetValue(classInfoItem.fullName2);
                    if (collectChildren)
                    {
                        if (type == typeof(GameObject))
                        {
                            GameObject  gameObject = (GameObject)obj;
                            Component[] components = gameObject.GetComponents(typeof(Component));
                            int         i          = 0;
                            foreach (Component component in components)
                            {
                                Type   componentType = component.GetType();
                                bool   isScript      = componentType.IsSubclassOf(typeof(MonoBehaviour));
                                string name          = String.Format("Component_{0}_{1}{2}", i, componentType.Name, isScript ? "_Script" : "");
                                objectItem.AddChild(name, component);
                                i++;
                            }
                            List <GameObject> children = GetChildrenGameObjects(gameObject);
                            i = 0;
                            foreach (GameObject childGameObject in children)
                            {
                                string name = String.Format("Child_{0}_{1}", i, childGameObject.name);
                                objectItem.AddChild(name, childGameObject);
                                i++;
                            }
                        }
                        foreach (FieldInfo field in classInfoItem.fields)
                        {
                            object value = field.GetValue(obj);
                            string name  = field.Name;
                            objectItem.AddChild(name, value);
                        }
                        foreach (PropertyInfo property in classInfoItem.properties)
                        {
                            object value = null;
                            try
                            {
                                value = property.GetValue(obj, null);
                            }
                            catch (Exception)
                            {
                            }
                            string name = property.Name;
                            objectItem.AddChild(name, value);
                        }
                    }
                }
            }
            return(objectItem);
        }
Esempio n. 14
0
 public static ObjectRef StaticGetChildObjectByName(ObjectItem objectItem, string name)
 {
     return(objectItem.GetChildObjectByName(name));
 }
Esempio n. 15
0
 public static ObjectRef StaticGetChildObject(ObjectItem objectItem, int i)
 {
     return(objectItem.GetChildObject(i));
 }
Esempio n. 16
0
 public static string StaticGetChildName(ObjectItem objectItem, int i)
 {
     return(objectItem.GetChildName(i));
 }
Esempio n. 17
0
 public static string StaticGetValue(ObjectItem objectItem)
 {
     return(objectItem.GetValue());
 }
Esempio n. 18
0
 public static int StaticGetChildCount(ObjectItem objectItem)
 {
     return(objectItem.GetChildCount());
 }