Esempio n. 1
0
    def create(self, decl_headers=None):
        """
        create and return the module for the extension - code creators tree root.

        :param decl_headers: If None the headers for the wrapped decls are automatically found.
                             But you can pass a list of headers here to override that search.
        :rtype: :class:`code_creators.module_t`
        """
        # Invoke the appropriate visit_*() method on all decls
        for decl in self.__decls:
            self.curr_decl = decl
            declarations.apply_visitor(self, decl)
        for operator in self.__free_operators:
            self._adopt_free_operator(operator)
        self._treat_smart_pointers()
        if self.__enable_indexing_suite:
            self._treat_indexing_suite()
        for creator in code_creators.make_flatten_generator(self.__extmodule):
            creator.target_configuration = self.__target_configuration
        # last action.
        self._append_user_code()

        add_include = self.__extmodule.add_include
        # add system headers
        system_headers = self.__extmodule.get_system_files(recursive=True, unique=True, language="c++")
        map(lambda header: add_include(header, user_defined=False, system=True), system_headers)
        # add user defined header files
        if decl_headers is None:
            decl_headers = declarations.declaration_files(self.__decls)
        map(lambda header: add_include(header, user_defined=False, system=False), decl_headers)

        self.__dependencies_manager.inform_user()

        return self.__extmodule
Esempio n. 2
0
 def test(self):
     prj_reader = parser.project_reader_t(self.config)
     decls = prj_reader.read_files(
         self.__files, compilation_mode=parser.COMPILATION_MODE.ALL_AT_ONCE)
     files = declarations.declaration_files(decls)
     result = set()
     for fn in files:
         result.add(os.path.split(fn)[1])
     self.assertTrue(set(self.__files).issubset(result))
 def test(self):
     prj_reader = parser.project_reader_t(self.config)
     decls = prj_reader.read_files(
         self.__files,
         compilation_mode=parser.COMPILATION_MODE.ALL_AT_ONCE)
     files = declarations.declaration_files(decls)
     result = set()
     for fn in files:
         result.add(os.path.split(fn)[1])
     self.failUnless(set(self.__files).issubset(result))
Esempio n. 4
0
 def dumpCachedTree(self, sourceFiles, configSig, declTree):
     self.logger.info("Writing module cache... ")
     cache_file = file(self.cacheFileName,'wb')
     
     src_and_cfg_digest = self.computeSrcAndCfgDigest(sourceFiles, configSig)
     decl_files = [ f for f in decls_package.declaration_files(declTree) if os.path.isfile(f)]        
     inc_sig = md5.new()
     for f in decl_files:
         inc_sig.update(file_signature(f))
         
     cPickle.dump( (src_and_cfg_digest, inc_sig.hexdigest(), decl_files), 
                   cache_file, cPickle.HIGHEST_PROTOCOL)
     cPickle.dump(declTree, cache_file, cPickle.HIGHEST_PROTOCOL)
     cache_file.close()
     self.logger.info("Complete.")
Esempio n. 5
0
    def create(self, decl_headers=None):
        """
        create and return the module for the extension - code creators tree root.

        :param decl_headers: If None the headers for the wrapped decls are automatically found.
                             But you can pass a list of headers here to override that search.
        :rtype: :class:`code_creators.module_t`
        """
        # Invoke the appropriate visit_*() method on all decls
        for decl in self.__decls:
            self.curr_decl = decl
            declarations.apply_visitor(self, decl)
        for operator in self.__free_operators:
            self._adopt_free_operator(operator)
        self._treat_smart_pointers()
        if self.__enable_indexing_suite:
            self._treat_indexing_suite()
        for creator in code_creators.make_flatten_generator(self.__extmodule):
            creator.target_configuration = self.__target_configuration
        #last action.
        self._append_user_code()

        add_include = self.__extmodule.add_include
        #add system headers
        system_headers = self.__extmodule.get_system_files(recursive=True,
                                                           unique=True,
                                                           language='c++')
        map(
            lambda header: add_include(header, user_defined=False, system=True
                                       ), system_headers)
        #add user defined header files
        if decl_headers is None:
            decl_headers = declarations.declaration_files(self.__decls)
        map(
            lambda header: add_include(
                header, user_defined=False, system=False), decl_headers)

        self.__dependencies_manager.inform_user()

        return self.__extmodule