if declarations.is_reference(v.decl_type): v.use_make_functions = True mb.decl("get_string_vector").include() mb.namespace("test").include() cl = mb.class_("RefWrap") cl.include() functions.convert_vector_of_references_return_type(cl.mem_fun("ints")) for cl_name in ["ReturnOptional", "ReturnOptionalB", "ReturnOptionalC"]: cl = mb.class_(cl_name) cl.include() for fun in cl.member_functions(): functions.return_optional_by_value(fun) # expose only public interfaces namespaces.exclude_by_access_type(mb, ['variables', 'calldefs', 'classes'], 'private') namespaces.exclude_by_access_type(mb, ['variables', 'calldefs', 'classes'], 'protected') # exclude names begining with a single underscore or ending with Cpp namespaces.exclude_by_regex(mb, ['calldefs'], r'(^_[^_])|(.*Cpp$)|(^impl$)') cls = mb.class_("WithPickle") classes.add_pickle_suite(cls) cls = mb.class_("WithPickleCereal") classes.add_pickle_suite(cls, serialization_framework='cereal') wrap.finish()
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() for variable in cl.variables(allow_empty=True): classes.add_optional_vector_wrapper_for(mb, variable) classes.add_pickle_suite(cl)
for c in [ 'Analog', 'BackgroundGenerator', 'BackgroundGeneratorArray', 'Crossbar', 'CrossbarRow', 'DNCMerger', 'DNCMergerLine', 'DecoderDoubleRow', 'DecoderRow', 'DriverDecoder', 'FGBlock', 'FGConfig', 'FGControl', 'FGInstruction', 'FGStimulus', 'GbitLink', 'HorizontalRepeater', 'L1Address', 'Merger', 'MergerTree', 'Neuron', 'NeuronConfig', 'NeuronQuad', 'Repeater', 'RepeaterBlock', 'RowConfig', 'STDPAnalog', 'STDPControl', 'STDPEval', 'STDPLUT', 'STDPTiming', 'Status', 'SynapseDecoder', 'SynapseDriver', 'SynapseSwitch', 'SynapseSwitchRow', 'SynapseWeight', 'TestEvent_3', 'VerticalRepeater', 'WeightRow', 'FGErrorResult', 'FGErrorResultRow', 'FGErrorResultQuadRow', 'FGRow' ]: cls = ns_hmf.class_('::HMF::HICANN::' + c) classes.add_pickle_suite(cls) c = mb.class_('::HMF::ADC::USBSerial') c.include() classes.add_comparison_operators(c) classes.expose_std_hash(c) c.add_registration_code('def(bp::self == bp::self)') c.include_files.append('pywrap/print_helper.hpp') c.add_registration_code('def(pywrap::PrintNice())') classes.add_pickle_suite(c) # HMF::Handle stuff & special handling (ECM) for c in ns_hmf.namespace('Handle').classes(allow_empty=True): classes.add_context_manager(c) # Try to capture the std::container dependcies