from pywrap.wrapper import Wrapper from pywrap import namespaces, containers, classes wrap = Wrapper() mb = wrap.mb ns = mb.namespace('::pymarocco::runtime') for name in [ "sthal::Wafer", "marocco::results::Marocco", "marocco::placement::algorithms::PlacePopulationsBase" ]: mb.add_registration_code( "bp::register_ptr_to_python< boost::shared_ptr< " + name + " > >();") namespaces.extend_array_operators(ns) for cl in ns.classes(allow_empty=True): cl.include() classes.add_pickle_suite(cl) factory = list(cl.mem_funs("create", allow_empty=True)) if factory: cl.add_fake_constructors(factory) # propagate "explictness" to python :) cl.constructors(lambda c: c.explicit == True, allow_empty=True).allow_implicit_conversion = False # expose member variables of type `boost::optional<vector<...>>` uns = mb.namespace('::marocco::placement::algorithms') namespaces.extend_array_operators(uns) for cl in uns.classes(allow_empty=True): cl.include()
#!/usr/bin/env python from pywrap.wrapper import Wrapper from pywrap import containers, namespaces, matchers, classes from pyplusplus.module_builder import call_policies wrap = Wrapper() mb = wrap.mb # Special fix up containers.extend_std_containers(mb) namespaces.include_default_copy_constructors(mb) ns_hwdb4cpp = mb.namespace('hwdb4cpp') ns_hwdb4cpp.include() namespaces.extend_array_operators(ns_hwdb4cpp) for c in ns_hwdb4cpp.classes(allow_empty=True): c.include() if c.name.startswith('database'): for f in c.mem_funs('get_wafer_entry', allow_empty=True): f.call_policies = call_policies.return_internal_reference() for f in c.mem_funs('get_dls_entry', allow_empty=True): f.call_policies = call_policies.return_internal_reference() for f in c.mem_funs('get_hxcube_entry', allow_empty=True): f.call_policies = call_policies.return_internal_reference() # expose only public interfaces namespaces.exclude_by_access_type(mb, ['variables', 'calldefs', 'classes'], 'private') namespaces.exclude_by_access_type(mb, ['variables', 'calldefs', 'classes'],