Ejemplo n.º 1
0
]:
    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
std_filter = matchers.and_matcher_t([
    matchers.declaration_matcher_t(decl_type=decl_wrappers.class_t),
    matchers.namespace_contains_matcher_t("std")
])

for ns in included_ns:
    for decl in namespaces.get_deps(
            ns_hmf, matchers.namespace_contains_matcher_t("std")):
        if decl.indexing_suite or decl.name.startswith("bitset"):
            decl.include()

# std::hash specialisations are only used from within the member hash functions
mb.classes(matchers.match_std_container_t("hash"), allow_empty=True).exclude()
                'Dls_program_builder',
                'Ppu_program_on_dls',
                'Connection',
                'Ppu_on_dls',
                'Mailbox_on_dls',
        ] or cls.name.endswith('_handle'):
            continue
        classes.add_pickle_suite(cls, serialization_framework='cereal')
        classes.add_to_and_from_json(cls)

# Spike in uni namespace...
cls = n_uni.class_('Spike')
classes.add_pickle_suite(cls, serialization_framework='cereal')
classes.add_to_and_from_json(cls)

# 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$)')

# add context semantics to python-wrapping of Connection
classes.add_context_manager(
    n.class_("Connection"),
    n.class_("Connection").member_function("disconnect"))

wrap.finish()