예제 #1
0
def gen_properties(iface, ind_lvl=0, ind_tp='\t'):
    out = io.StringIO()
    gen = sciface.CodeGen(out, ind_lvl, ind_tp)
    for prop in iface.properties:
        gen_prop_getter(prop, gen)
        gen_prop_setter(prop, gen)
    return out.getvalue().rstrip()
예제 #2
0
def gen_constant_decls(iface, ind_lvl=0, ind_tp='\t'):
    out = io.StringIO()
    gen = sciface.CodeGen(out, ind_lvl, ind_tp)
    constants = sorted(
        (strip_const_prefix(c.name), c.value) for c in iface.constants)
    for name, value in constants:
        gen.iwriteln('static constexpr int %s = %d;' % (name, value))
    return out.getvalue()
예제 #3
0
def gen_sparse_lexer_names(iface, ind_lvl=0, ind_tp='\t'):
    max_lex = max(lex.value for lex in iface.lexers)
    lexer_names = ['nullptr' for x in range(0, max_lex + 1)]
    for lexer in iface.lexers:
        lexer_names[lexer.value] = '"%s"' % lexer.name
    out = io.StringIO()
    gen = sciface.CodeGen(out, ind_lvl, ind_tp)
    for name in lexer_names:
        gen.iwriteln('%s,' % name)
    return out.getvalue().rstrip()
예제 #4
0
def gen_signal_accessors(iface, ind_lvl=0, ind_tp='\t'):
    out = io.StringIO()
    gen = sciface.CodeGen(out, ind_lvl, ind_tp)
    for event in iface.events:
        gen.iwriteln('NotificationSignal &signal_%s()' % event.name)
        gen.iwriteln('{')
        gen.indent()
        gen.iwriteln('return signal_%s_;' % event.name)
        gen.unindent()
        gen.iwriteln('}\n')
    return out.getvalue().rstrip()
예제 #5
0
def gen_enums(iface, ind_lvl=0, ind_tp='\t'):
    out = io.StringIO()
    gen = sciface.CodeGen(out, ind_lvl, ind_tp)
    for enum in iface.enumerations:
        format_comment(gen, enum.comment)
        gen.iwriteln('enum class %s' % enum.name)
        gen.iwriteln('{')
        gen.indent()
        for etor in enum.enumerators:
            gen.iwriteln('%s = %d,' % (etor.name, etor.value))
        gen.unindent()
        gen.iwriteln('};\n')
    return out.getvalue().rstrip()
예제 #6
0
def gen_lexer_style_refs(iface, ind_lvl=0, ind_tp='\t'):
    max_lex = max(lex.value for lex in iface.lexers)
    lexer_counts = [0 for x in range(0, max_lex + 1)]
    lexer_names = ['nullptr' for x in range(0, max_lex + 1)]
    for lexer in iface.lexers:
        if len(lexer.styles) > 0:
            max_style = max(style.value for style in lexer.styles)
        else:
            max_style = 0
        lexer_counts[lexer.value] = max_style + 1
        lexer_names[lexer.value] = lexer.name.lower() + '_styles'
    out = io.StringIO()
    gen = sciface.CodeGen(out, ind_lvl, ind_tp)
    for i in range(0, max_lex + 1):
        gen.iwriteln('{ %d, %s },' % (lexer_counts[i], lexer_names[i]))
    return out.getvalue()
예제 #7
0
def gen_lexer_style_defs(iface, ind_lvl=0, ind_tp='\t'):
    out = io.StringIO()
    gen = sciface.CodeGen(out, ind_lvl, ind_tp)
    for lexer in iface.lexers:
        if len(lexer.styles) > 0:
            max_style = max(style.value for style in lexer.styles)
        else:
            max_style = 0
        style_names = ['nullptr' for x in range(0, max_style + 1)]
        for style in lexer.styles:
            style_names[style.value] = '"%s"' % style.name.lower()
        gen.iwriteln('static const char *%s_styles[%d]' %
                     (lexer.name.lower(), max_style + 2))
        gen.iwriteln('{')
        gen.indent()
        for name in style_names:
            gen.iwriteln('%s,' % name)
        gen.iwriteln('nullptr,')
        gen.unindent()
        gen.iwriteln('};')
        gen.iwriteln()
    return out.getvalue().rstrip() + '\n'
예제 #8
0
def gen_signals(iface, ind_lvl=0, ind_tp='\t'):
    out = io.StringIO()
    gen = sciface.CodeGen(out, ind_lvl, ind_tp)
    for event in iface.events:
        gen.iwriteln('NotificationSignal signal_%s_;' % event.name)
    return out.getvalue().rstrip()
예제 #9
0
def gen_constant_undefs(iface, ind_lvl=0, ind_tp='\t'):
    out = io.StringIO()
    gen = sciface.CodeGen(out, ind_lvl, ind_tp)
    for const in iface.constants:
        gen.iwriteln('#undef %s' % const.name)
    return out.getvalue()
예제 #10
0
def gen_functions(iface, ind_lvl=0, ind_tp='\t'):
    out = io.StringIO()
    gen = sciface.CodeGen(out, ind_lvl, ind_tp)
    for func in iface.functions:
        gen_function(func, gen)
    return out.getvalue().rstrip()