Exemple #1
0
        static void GenerateStatic(Larva larva)
        {
            // generate struct
            string staticDefinition = GetElement(ElementType.StaticDefinition);

            TextHelper.ReplaceExpressions(ref staticDefinition, larva);

            string body = larva.GetStaticBody();

            TextHelper.ReplaceField(ref staticDefinition, "%body%", body);

            larva.Declaration.Add(staticDefinition);

            // generate field definition
            foreach (Part p in larva.Parts)
            {
                larva.Definitions.Add(p.GetStaticFieldDefinition());
            }

            // generate method definition
            foreach (string name in larva.Methods)
            {
                Method m = MethodFactory.GetMethod(name);
                larva.Definitions.Add(m.GetDefinition(larva));
            }
        }
Exemple #2
0
        static void GenerateStruct(Larva larva)
        {
            // generate struct
            string structDefinition = larva.BaseName == null?GetElement(ElementType.StructDefinition) : GetElement(ElementType.StructDefinitionWithBase);

            TextHelper.ReplaceExpressions(ref structDefinition, larva);

            string body = larva.GetStructBody();

            TextHelper.ReplaceField(ref structDefinition, "%body%", body);

            larva.Declaration.Add(structDefinition);
            larva.Definitions.Add(larva.GetConstructorDefinition());

            // generate method definition
            foreach (string name in larva.Methods)
            {
                Method m = MethodFactory.GetMethod(name);
                larva.Definitions.Add(m.GetDefinition(larva));
            }
        }