예제 #1
0
#!/usr/bin/env python

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):
예제 #2
0
#!/usr/bin/env python

from pywrap.wrapper import Wrapper
import pywrap.namespaces as ns

wrap = Wrapper()
mb = wrap.mb

# include everything from test namespace
mb.namespace("test").include()

# expose only public interfaces
ns.exclude_by_access_type(mb, ['variables', 'calldefs', 'classes'], 'private')
ns.exclude_by_access_type(mb, ['variables', 'calldefs', 'classes'],
                          'protected')

# exclude names begining with a single underscore or ending with Cpp
ns.exclude_by_regex(mb, ['calldefs'], r'(^_[^_])|(.*Cpp$)|(^impl$)')

wrap.finish()
예제 #3
0
#!/usr/bin/env python
from pywrap.wrapper import Wrapper
from pywrap import containers, namespaces, matchers, classes, functions
from pygccxml import declarations

wrap = Wrapper()
wrap.set_number_of_files(0)
module_name = wrap.module_name()
mb = wrap.mb

containers.extend_std_containers(mb)
namespaces.include_default_copy_constructors(mb)

for c in ("KProxy", ):
    cls = mb.class_(c)
    for v in cls.variables():
        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)
예제 #4
0
파일: generate.py 프로젝트: cpehle/halbe

def add_numpy_construtor_to_strong_typedefs(ns):
    matcher = matchers.match_std_container_t("array")

    def _filter(c):
        return any([matcher(base.related_class) for base in c.bases])

    for c in ns.classes(_filter, allow_empty=True):
        classes.add_numpy_construtor(c)
        for b in c.bases:
            b.related_class.exclude()


# FIXME: fix py++ to include our headers before boost python headers
wrap = Wrapper(license='#include "pyhalbe.h"')
module_name = wrap.module_name()
mb = wrap.mb
ns_util = NamespaceUtil()

# Less noise
ns_util.log.setLevel(logging.WARN)
classes.log.setLevel(logging.WARN)
messages.disable(messages.W1043)  # Ugly names, who cares? ...
messages.disable(messages.W1066)  # Not exposed typedefs

# Collect namespaces
ns_hmf = mb.namespace("::HMF")
ns_hmf_hicann = mb.namespace("::HMF::HICANN")
ns_coordinate = mb.namespace("::HMF::Coordinate")
ns_realtime = mb.namespace("::Realtime")