예제 #1
0
        private void CreateObjects(List <Tuple <EToken, string, string> > Tokens)
        {
            CPPObject current = null;

            foreach (Tuple <EToken, string, string> token in Tokens)
            {
                switch (token.Item1)
                {
                case EToken.ClassDeclaration:
                    if (current != null)
                    {
                        Globals.ReflectedObjects.Add(current.Name, current.GetCopy());
                        Objects.Add(current.Name, current);
                    }
                    current = new CPPObject(EReflectionTarget.CLASS, token.Item3);
                    break;

                case EToken.StructDeclaration:
                    if (current != null)
                    {
                        Globals.ReflectedObjects.Add(current.Name, current.GetCopy());
                        Objects.Add(current.Name, current);
                    }
                    current = new CPPObject(EReflectionTarget.STRUCT, token.Item3);
                    break;

                case EToken.ParentClassDeclaration:
                    current.AddParentClass(token.Item3);
                    break;

                case EToken.PropertyDeclaration:
                    string[] split = token.Item3.Split(' ', StringSplitOptions.RemoveEmptyEntries);;
                    if (split[0].Trim() == "const")
                    {
                        current.AddProperty(new FProperty(split[2], token.Item2));     // const int32 variableName = 10;
                    }
                    else
                    {
                        current.AddProperty(new FProperty(split[1], token.Item2));     // int32 variableName = 10;
                    }
                    break;

                case EToken.FunctionDeclaration:
                    current.AddFunction(new FFunction(token.Item3, token.Item2));
                    break;

                default: break;
                }
            }
            if (current != null)
            {
                Globals.ReflectedObjects.Add(current.Name, current.GetCopy());
                Objects.Add(current.Name, current);
            }
        }
예제 #2
0
        public CPPObject GetCopy()
        {
            CPPObject copy = new CPPObject(Type, Name);

            foreach (string parent in ParentClasses)
            {
                copy.AddParentClass(parent);
            }
            foreach (FProperty prop in Properties.Values)
            {
                copy.AddProperty(prop);
            }
            return(copy);
        }