示例#1
0
 def test_ast_to_structs(self):
     ast = header_to_ast('../../../../../clib/tests/check_isti_sqlite.h')
     structs = ast_to_structs(ast)
     assert len(structs) == 1, structs
     assert 'foo' in [struct['sname'] for struct in structs], structs
     fields = structs[0]['fields']
     assert len(fields) == 3, fields
     for field in fields:
         assert field['fname'] in ('id', 'bar', 'baz'), field
         assert field['fname'] != 'id' or field['type'] == 'int'
         assert field['fname'] != 'bar' or field['type'] == 'int'
         assert field['fname'] != 'baz' or (field['type'] == 'char' and field['pointer'])
示例#2
0
文件: run.py 项目: EverydayQA/prima
def run(files, prefix='corm'):
    for infile in files:
        root = splitext(infile)[0]
        outfile = root + '.%s.' % prefix
        ast = header_to_ast(infile)
        structs = ast_to_structs(ast)
        with open(outfile + 'h', 'w') as out:
            generate_h_preamble(out, original=infile, root=root.replace(sep, '_'))
            for struct in structs:
                generate_h(struct, out, prefix=prefix)
            generate_h_postamble(out)
        with open(outfile + 'c', 'w') as out:
            generate_c_preamble(out, header=outfile+'h')
            for struct in structs:
                generate_c(struct, out, prefix=prefix)
        with open(outfile + 'sql', 'w') as out:
            for struct in structs:
                generate_sql(struct, out)
示例#3
0
 def test_generate(self):
     ast = header_to_ast('../../../../../clib/tests/check_isti_sqlite.h')
     structs = ast_to_structs(ast)
     for struct in structs:
         generate(struct)
     assert False