def cpp_callable_body(callable, cfg): """writes body of a free fun""" body_disp = { 'interface' : g_callable_muster_ptr, 'void' : g_callable_muster_err_code, 'other' : g_callable_muster_other } args = [] mi = callable.metainfo() ret_cat = mi.return_type_category() body_dict = globals()['callable_body_returning_'+ret_cat](mi, cfg) gencommon.update_dict(body_dict, cfg, 'no_exceptions_tag', 'exception_instance', 'global_error_check') return body_dict, body_disp[ret_cat]
def c_callable_body(stream, freefun, cfg): """writes body of a free fun""" body_disp = { 'interface' : g_callable_muster_ptr, 'void' : g_callable_muster_err_code, 'other' : g_callable_muster_other } args = [] mi = freefun.metainfo() ret_cat = mi.return_type_category() subst_dict = globals()['c_callable_body_returning_'+ret_cat](mi, cfg) gencommon.update_dict(subst_dict, cfg, 'internal_exception_cls', 'c_catch_set_global_error') stream.write(Template(body_disp[ret_cat]).substitute(subst_dict))
def c_callable_body(stream, freefun, cfg): """writes body of a free fun""" body_disp = { 'interface': g_callable_muster_ptr, 'void': g_callable_muster_err_code, 'other': g_callable_muster_other } args = [] mi = freefun.metainfo() ret_cat = mi.return_type_category() subst_dict = globals()['c_callable_body_returning_' + ret_cat](mi, cfg) gencommon.update_dict(subst_dict, cfg, 'internal_exception_cls', 'c_catch_set_global_error') stream.write(Template(body_disp[ret_cat]).substitute(subst_dict))
def cpp_callable_body(callable, cfg): """writes body of a free fun""" body_disp = { 'interface': g_callable_muster_ptr, 'void': g_callable_muster_err_code, 'other': g_callable_muster_other } args = [] mi = callable.metainfo() ret_cat = mi.return_type_category() body_dict = globals()['callable_body_returning_' + ret_cat](mi, cfg) gencommon.update_dict(body_dict, cfg, 'no_exceptions_tag', 'exception_instance', 'global_error_check') return body_dict, body_disp[ret_cat]
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)
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)