Beispiel #1
0
    def __init__( self
                  , global_ns
                  , library_path
                  , exported_symbols ):
        declarations.decl_visitor_t.__init__(self)
        self.logger = _logging_.loggers.module_builder
        self.decl_logger = _logging_.loggers.declarations

        self.global_ns = global_ns

        self.__library_path = library_path
        self.__exported_symbols = exported_symbols
        self.__exported_decls = set( exported_symbols.itervalues() )
        self.module = code_creators.ctypes_module_t( global_ns )
        self.__dependencies_manager = dependencies_manager.manager_t(self.decl_logger)

        #bookmark for class introductions
        self.__class_ccs = code_creators.bookmark_t()
        #bookmark for class deinitions
        self.__class_defs_ccs = code_creators.bookmark_t()
        #bookmark for typedef definitions
        self.__typedefs_ccs =  code_creators.bookmark_t()
        self.curr_decl = global_ns
        self.curr_code_creator = self.module
        #mapping between class declaration and class introduction code creator
        self.__class2introduction = {}
        #mapping between namespace and its code creator
        self.__namespace2pyclass = {}
Beispiel #2
0
    def __init__(self, global_ns, library_path, exported_symbols):
        declarations.decl_visitor_t.__init__(self)
        self.logger = _logging_.loggers.module_builder
        self.decl_logger = _logging_.loggers.declarations

        self.global_ns = global_ns

        self.__library_path = library_path
        self.__exported_symbols = exported_symbols
        self.__exported_decls = set(exported_symbols.itervalues())
        self.module = code_creators.ctypes_module_t(global_ns)
        self.__dependencies_manager = dependencies_manager.manager_t(
            self.decl_logger)

        #bookmark for class introductions
        self.__class_ccs = code_creators.bookmark_t()
        #bookmark for class deinitions
        self.__class_defs_ccs = code_creators.bookmark_t()
        #bookmark for typedef definitions
        self.__typedefs_ccs = code_creators.bookmark_t()
        self.curr_decl = global_ns
        self.curr_code_creator = self.module
        #mapping between class declaration and class introduction code creator
        self.__class2introduction = {}
        #mapping between namespace and its code creator
        self.__namespace2pyclass = {}
Beispiel #3
0
    def __init__( self
                  , decls
                  , module_name
                  , boost_python_ns_name='bp'
                  , call_policies_resolver_=None
                  , types_db=None
                  , target_configuration=None
                  , enable_indexing_suite=True
                  , doc_extractor=None ):
        """Constructor.

        @param decls: Declarations that should be exposed in the final module.
        @param module_name: The name of the final module.
        @param boost_python_ns_name: The alias for the boost::python namespace.
        @param call_policies_resolver_: Callable that takes one declaration (calldef_t) as input and returns a call policy object which should be used for this declaration.
        @param types_db: ...todo...
        @param target_configuration: A target configuration object can be used to customize the generated source code to a particular compiler or a particular version of Boost.Python.
        @param doc_extractor: callable, that takes as argument declaration reference and returns documentation string
        @param already_exposed_dbs: list of files/directories other modules, this module depends on, generated their code too
        @type decls: list of declaration_t
        @type module_name: str
        @type boost_python_ns_name: str
        @type call_policies_resolver_: callable
        @type types_db: L{types_database_t<types_database.types_database_t>}
        @type target_configuration: L{target_configuration_t<code_creators.target_configuration_t>}
        @type doc_extractor: callable
        @type already_exposed_dbs: list of strings
        """
        declarations.decl_visitor_t.__init__(self)
        self.logger = _logging_.loggers.module_builder
        self.decl_logger = _logging_.loggers.declarations

        self.__enable_indexing_suite = enable_indexing_suite
        self.__target_configuration = target_configuration
        if not self.__target_configuration:
            self.__target_configuration = code_creators.target_configuration_t()

        self.__call_policies_resolver = call_policies_resolver_
        if not self.__call_policies_resolver:
            self.__call_policies_resolver \
                = call_policies_resolver.built_in_resolver_t(self.__target_configuration)

        self.__types_db = types_db
        if not self.__types_db:
            self.__types_db = types_database.types_database_t()

        self.__extmodule = code_creators.module_t( declarations.get_global_namespace(decls) )
        if boost_python_ns_name:
            bp_ns_alias = code_creators.namespace_alias_t( alias=boost_python_ns_name
                                                           , full_namespace_name='::boost::python' )
            self.__extmodule.adopt_creator( bp_ns_alias )

        self.__module_body = code_creators.module_body_t( name=module_name )

        self.__extmodule.adopt_creator( self.__module_body )

        self.__opaque_types_manager = opaque_types_manager.manager_t( self.__extmodule )
        self.__dependencies_manager = dependencies_manager.manager_t(self.decl_logger)

        prepared_decls = self._prepare_decls( decls, doc_extractor )
        self.__decls = sort_algorithms.sort( prepared_decls )

        self.curr_code_creator = self.__module_body
        self.curr_decl = None
        self.__array_1_registered = set() #(type.decl_string,size)
        self.__free_operators = []
        self.__exposed_free_fun_overloads = set()