def c_output_class_handles(header, impl, intro, cfg): """writes callables declarations/definitions""" header.write('\n/* ==== handles ==== */\n') handles = [gencommon.c_handle_from_cls(cls,cfg) \ for cls in intro.exported_classes()] handles.sort() for handle in handles: header.write(cfg['c_cls_handle_gen'] % handle)
def c_callable_body_returning_interface(callable_, cfg): arglist, body = c_prepare_args(callable_) arglist = ', '.join(arglist) result_ptr_type = callable_.return_type()['base_name'] if callable_.return_type()['ref_counted']: fmtstr = "boost::intrusive_ptr<%s> const& result__ = %s%s(%s);" fmt_ret = "return ptr2handle<%s>(result__.get());" else: fmtstr = "%s* result__ = %s%s(%s);" fmt_ret = "return ptr2handle<%s>(result__);" body.append(fmtstr % (result_ptr_type, callable_.is_memfun() and 'this__->' or '', callable_.callable_object().name(), arglist)) opts = callable_.callable_object().opts result_ptr_handle = gencommon.c_handle_from_cls( callable_.return_type()['base'], opts) body.append(fmt_ret % result_ptr_handle) return {'try_body': "\n ".join(body)}
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)
def c_callable_body_returning_interface(callable_, cfg): arglist, body = c_prepare_args(callable_) arglist = ', '.join(arglist) result_ptr_type = callable_.return_type()['base_name']; if callable_.return_type()['ref_counted']: fmtstr = "boost::intrusive_ptr<%s> const& result__ = %s%s(%s);" fmt_ret = "return ptr2handle<%s>(result__.get());" else: fmtstr = "%s* result__ = %s%s(%s);" fmt_ret = "return ptr2handle<%s>(result__);" body.append(fmtstr % (result_ptr_type, callable_.is_memfun() and 'this__->' or '', callable_.callable_object().name(), arglist)) opts = callable_.callable_object().opts result_ptr_handle = gencommon.c_handle_from_cls(callable_.return_type()['base'], opts) body.append(fmt_ret % result_ptr_handle) return { 'try_body' : "\n ".join(body) }
def callable_body_returning_interface(callable_, cfg): cls = callable_.return_type()['base'] return dict(invocation=form_invocation(callable_,cfg), c_result_cls=gencommon.c_handle_from_cls(cls,cfg), cpp_result_cls=gencommon.cls_from_cls(cls,cfg))
def callable_body_returning_interface(callable_, cfg): cls = callable_.return_type()['base'] return dict(invocation=form_invocation(callable_, cfg), c_result_cls=gencommon.c_handle_from_cls(cls, cfg), cpp_result_cls=gencommon.cls_from_cls(cls, cfg))