コード例 #1
0
        // test ok
        void processMethod(MethodDeclaration md, TClass tc)
        {
            TMethod m = new TMethod();

            processEntiry(md, m);



            var plist = md.Descendants.OfType <ParameterDeclaration>().ToList();

            foreach (var item in plist)
            {
                TParameter p = new TParameter();
                p.name = item.Name;
                p.type = item.Type.GetText();
                var text  = item.GetText();
                var split = text.Split('=');
                if (split.Count() > 1)
                {
                    p.optionValue = split[split.Count() - 1];
                }
                m.parameters.Add(p);
            }
            processBody(md.Body, m.body);
            tc.methods.Add(m);
        }
コード例 #2
0
            public void Run(TNamespace ns)
            {
                foreach (var item in ns.classes)
                {
                    TClass c = item as TClass;
                    if (c != null)
                    {
                        foreach (var p in c.properties)
                        {
                            if (p.getter != null)
                            {
                                TMethod m = new TMethod();
                                m.name = "get" + p.name;
                                if (p.getter.isInternal || p.getter.isPrivate)
                                {
                                    m.isPrivate = true;
                                }
                                else
                                {
                                    m.isPublic = true;
                                }
                                m.type = p.type;
                                m.body = p.getter.body;
                                c.methods.Add(m);
                            }

                            if (p.setter != null)
                            {
                                TMethod m = new TMethod();
                                m.name = "set" + p.name;
                                if (p.setter.isInternal || p.setter.isPrivate)
                                {
                                    m.isPrivate = true;
                                }
                                else
                                {
                                    m.isPublic = true;
                                }
                                m.type = "void";
                                TParameter param = new TParameter();
                                param.type = p.type;
                                param.name = "value";
                                m.parameters.Add(param);
                                m.body = p.setter.body;
                                c.methods.Add(m);
                            }
                        }
                    }
                    c.properties.Clear();
                }
            }
コード例 #3
0
        /*void processDestructor(DestructorDeclaration dd, TClass tc)
         * {
         *  TDestructor dtor = new TDestructor();
         *  processEntiry(dd, dtor);
         *
         *  var plist = dd.Descendants.OfType<ParameterDeclaration>().ToList();
         *  foreach (var item in plist)
         *  {
         *      TParameter p = new TParameter();
         *      p.name = item.Name;
         *      p.type = item.Type.GetText();
         *      var text = item.GetText();
         *      var split = text.Split('=');
         *      if (split.Count() > 1)
         *          p.optionValue = split[split.Count() - 1];
         *      dtor.parameters.Add(p);
         *
         *  }
         *  dtor.body = dd.Body.GetText();
         *  tc.destructors.Add(dtor);
         * }*/

        void processIndexer(IndexerDeclaration indexer, TClass tc)
        {
            TIndexer i = new TIndexer();

            processEntiry(indexer, i);

            var plist = indexer.Descendants.OfType <ParameterDeclaration>().ToList();

            foreach (var item in plist)
            {
                TParameter p = new TParameter();
                p.name = item.Name;
                p.type = item.Type.GetText();
                var text  = item.GetText();
                var split = text.Split('=');
                if (split.Count() > 1)
                {
                    p.optionValue = split[split.Count() - 1];
                }
                i.parameters.Add(p);
            }

            Accessor getter = indexer.Getter;

            if (!getter.IsNull)
            {
                i.getter = new TAccessor();
                processAccessor(getter, i.getter);
            }
            ;

            Accessor setter = indexer.Setter;

            if (!setter.IsNull)
            {
                i.setter = new TAccessor();
                processAccessor(setter, i.setter);
            }
            ;

            tc.indexers.Add(i);
        }
コード例 #4
0
        void processConstructor(ConstructorDeclaration cd, TClass tc)
        {
            TConstructor ctor = new TConstructor();

            processEntiry(cd, ctor);

            var plist = cd.Descendants.OfType <ParameterDeclaration>().ToList();

            foreach (var item in plist)
            {
                TParameter p = new TParameter();
                p.name = item.Name;
                p.type = item.Type.GetText();
                var text  = item.GetText();
                var split = text.Split('=');
                if (split.Count() > 1)
                {
                    p.optionValue = split[split.Count() - 1];
                }
                ctor.parameters.Add(p);
            }
            processBody(cd.Body, ctor.body);
            tc.constructors.Add(ctor);
        }