Exemple #1
0
        public override string Render(DefConst c)
        {
            var ctx = new TemplateContext();
            var env = new TTypeTemplateCommonExtends
            {
                ["x"] = c
            };

            ctx.PushGlobal(env);


            var template = t_tsConstRender ??= Template.Parse(@"

class {{x.py_full_name}}:
    {{~ for item in x.items ~}}
    {{item.name}} = {{py_const_value item.ctype item.value}}
    {{~end~}}
    {{~if (x.items == empty)~}}
    pass
    {{~end~}}

");
            var result   = template.Render(ctx);

            return(result);
        }
        public override string Render(DefConst c)
        {
            var ctx = new TemplateContext();
            var env = new TTypeTemplateCommonExtends
            {
                ["x"] = c
            };

            ctx.PushGlobal(env);


            var template = t_tsConstRender ??= Template.Parse(@"
namespace {{x.namespace}} {
export class {{x.name}} {
    {{~ for item in x.items ~}}
    static {{item.name}} : {{ts_define_type item.ctype}}  = {{ts_const_value item.ctype item.value}};
    {{~end~}}
}
}

");
            var result   = template.Render(ctx);

            return(result);
        }
Exemple #3
0
        public static string RenderJavaConstClass(DefConst c)
        {
            var ctx = new TemplateContext();
            var env = new TTypeTemplateCommonExtends
            {
                ["x"] = c
            };

            ctx.PushGlobal(env);


            var template = t_javaConstRender ??= Template.Parse(@"
package {{x.namespace_with_top_module}};

public final class {{x.name}}
{
    {{~ for item in x.items ~}}
    public static final {{java_define_type item.ctype}} {{item.name}} = {{java_const_value item.ctype item.value}};
    {{~end~}}
}


");
            var result   = template.Render(ctx);

            return(result);
        }
Exemple #4
0
        public static string RenderCppConstClass(DefConst c)
        {
            var ctx = new TemplateContext();
            var env = new TTypeTemplateCommonExtends
            {
                ["x"] = c
            };

            ctx.PushGlobal(env);


            var template = t_cppConstRender ??= Template.Parse(@"
{{x.cpp_namespace_begin}}

struct {{x.name}}
{
    {{~ for item in x.items ~}}
    static constexpr {{cpp_define_type item.ctype}} {{item.name}} = {{cpp_const_value item.ctype item.value}};
    {{~end~}}
};
{{x.cpp_namespace_end}}

");
            var result   = template.Render(ctx);

            return(result);
        }
Exemple #5
0
        public string Render(DefConst c)
        {
            string package = "cfg";

            var template = t_constRender ??= Template.Parse(@"
package {{package}}

const (
    {{- for item in x.items }}
    {{x.go_full_name}}_{{item.name}} = {{go_const_value item.ctype item.value}}
    {{-end}}
)
");
            var result   = template.RenderCode(c, new Dictionary <string, object>()
            {
                ["package"] = package
            });

            return(result);
        }
Exemple #6
0
 public string Render(DefConst c)
 {
     return(RenderUtil.RenderCsConstClass(c));
 }
Exemple #7
0
 public abstract string Render(DefConst c);
Exemple #8
0
 public override string Render(DefConst c)
 {
     return(RenderUtil.RenderJavaConstClass(c));
 }
Exemple #9
0
 public string Render(DefConst c)
 {
     return("// const");
 }