예제 #1
0
파일: cppgen.py 프로젝트: Rogaven/jagpdf
def output_free_funs(header, intro, cfg):
    header.write('\n\n\n/* ==== free functions ==== */\n\n')
    import sig
    s = sig.cpp_signature(cfg)
    funcs = [(s.get(f), f) for f in intro.exported_freefunctions()]
    funcs.sort()
    for sig, fun in funcs:
        header.write(output_callable(fun, cfg) + '\n\n')
예제 #2
0
파일: cppgen.py 프로젝트: Rogaven/jagpdf
def output_callable(callable, cfg):
    s = sig.cpp_signature(cfg)
    csig = s.get(callable)
    if isinstance(callable, introspect.freefun_i):
        csig = 'inline ' + csig
    subst_dict, templ = cpp_callable_body(callable, cfg)
    subst_dict['signature']=csig
    return Template(templ).substitute(subst_dict)
예제 #3
0
def output_free_funs(header, intro, cfg):
    header.write('\n\n\n/* ==== free functions ==== */\n\n')
    import sig
    s = sig.cpp_signature(cfg)
    funcs = [(s.get(f), f) for f in intro.exported_freefunctions()]
    funcs.sort()
    for sig, fun in funcs:
        header.write(output_callable(fun, cfg) + '\n\n')
예제 #4
0
def output_callable(callable, cfg):
    s = sig.cpp_signature(cfg)
    csig = s.get(callable)
    if isinstance(callable, introspect.freefun_i):
        csig = 'inline ' + csig
    subst_dict, templ = cpp_callable_body(callable, cfg)
    subst_dict['signature'] = csig
    return Template(templ).substitute(subst_dict)
예제 #5
0
파일: cppgen.py 프로젝트: Rogaven/jagpdf
def output_class(cls, header, intro, cfg):
    substd = { 'c_handle' : gencommon.c_handle_from_cls(cls,cfg),
               'cpp_name' : gencommon.cls_from_cls(cls,cfg) }
    gencommon.update_dict(substd, cfg, 'c_handle_inc', 'c_handle_dec')
    decl_string = gencommon.decl_string_generic(cls)
    cls_body = get_class_body(decl_string in cfg['ref_counted'])
    cls_muster = Template(cls_body).safe_substitute(substd)
    body = []
    import sig
    s = sig.cpp_signature(cfg)
    methods = [(s.get(m), m) for m in cls.methods()]
    methods.sort()
    for sig, m in methods:
        body.append(cpp_indent(output_callable(m, cfg), 4))
    substd = { 'body' : "\n".join(body) }
    cls_def = Template(cls_muster).substitute(substd)
    header.write(cls_def)
예제 #6
0
def output_class(cls, header, intro, cfg):
    substd = {
        'c_handle': gencommon.c_handle_from_cls(cls, cfg),
        'cpp_name': gencommon.cls_from_cls(cls, cfg)
    }
    gencommon.update_dict(substd, cfg, 'c_handle_inc', 'c_handle_dec')
    decl_string = gencommon.decl_string_generic(cls)
    cls_body = get_class_body(decl_string in cfg['ref_counted'])
    cls_muster = Template(cls_body).safe_substitute(substd)
    body = []
    import sig
    s = sig.cpp_signature(cfg)
    methods = [(s.get(m), m) for m in cls.methods()]
    methods.sort()
    for sig, m in methods:
        body.append(cpp_indent(output_callable(m, cfg), 4))
    substd = {'body': "\n".join(body)}
    cls_def = Template(cls_muster).substitute(substd)
    header.write(cls_def)