• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python declarations.get_global_namespace函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pygccxml.declarations.get_global_namespace函数的典型用法代码示例。如果您正苦于以下问题:Python get_global_namespace函数的具体用法?Python get_global_namespace怎么用?Python get_global_namespace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_global_namespace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test

    def test(self):
        """
        The purpose of this test was to check if changes to GCCXML
        would lead to changes in the outputted xml file (Meaning
        the bug was fixed).

        GCCXML wrongly outputted partial template specialization.
        CastXML does not have this bug. In this case we check if
        the template specialization can not be found; which is the
        expected/wanted behaviour.

        https://github.com/CastXML/CastXML/issues/20

        """

        src_reader = parser.source_reader_t(self.config)
        global_ns = declarations.get_global_namespace(
            src_reader.read_string(code))
        if 'GCCXML' in utils.xml_generator:
            a = global_ns.class_('A<const char [N]>')
            a.mem_fun('size')
        elif 'CastXML' in utils.xml_generator:
            self.assertRaises(
                global_ns.declaration_not_found_t,
                lambda: global_ns.class_('A<const char [N]>'))
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:25,代码来源:gccxml10185_tester.py


示例2: parse_files

def parse_files(path, files):
    # Find the location of the xml generator (castxml or gccxml)
    #generator_path, generator_name = utils.find_xml_generator()
    #print("GENER " + generator_path)
    # Configure the xml generator

    args = {
        'include_paths':[path],
        'keep_xml': True
        }
    if(xml_generator != None):
        args['xml_generator'] =xml_generator
    if(xml_generator_path != None):
        args['xml_generator_path'] =xml_generator_path

    xml_generator_config = parser.xml_generator_configuration_t(**args)
    
    # not sure this actually does anything when compilation_mode is set to "ALL_AT_ONCE"
    def cache_file(filename):
        return parser.file_configuration_t(
            data=filename,
            content_type=parser.CONTENT_TYPE.CACHED_SOURCE_FILE,
            cached_source_file=filename.replace(path, "tmp/xml")+".xml")
    cached_files = [cache_file(f) for f in files]

    project_reader = parser.project_reader_t(xml_generator_config)
    decls = project_reader.read_files(
        cached_files,
        compilation_mode=parser.COMPILATION_MODE.ALL_AT_ONCE)

    return declarations.get_global_namespace(decls)
开发者ID:henrikrudstrom,项目名称:oce-wrap,代码行数:31,代码来源:parse_headers.py


示例3: test_map_gcc5

    def test_map_gcc5(self):
        """
        The code in test_map_gcc5.hpp was breaking pygccxml.

        Test that case (gcc5 + castxml + c++11).

        See issue #45 and #55

        """

        if self.config.xml_generator == "gccxml":
            return

        decls = parser.parse([self.header], self.config)
        global_ns = declarations.get_global_namespace(decls)

        # This calldef is defined with gcc > 4.9 (maybe earlier, not tested)
        # and -std=c++11. Calling create_decl_string is failing with gcc.
        # With clang the calldef does not exist so the matcher
        # will just return an empty list, letting the test pass.
        # See the test_argument_without_name.py for an equivalent test,
        # which is not depending on the presence of the _M_clone_node
        # method in the stl_tree.h file.
        criteria = declarations.calldef_matcher(name="_M_clone_node")
        free_funcs = declarations.matcher.find(criteria, global_ns)
        for free_funcs in free_funcs:
            free_funcs.create_decl_string(with_defaults=False)
开发者ID:gccxml,项目名称:pygccxml,代码行数:27,代码来源:test_map_gcc5.py


示例4: test_attributes

    def test_attributes(self):

        decls = parser.parse([self.header], self.config)
        Test.global_ns = declarations.get_global_namespace(decls)
        Test.global_ns.init_optimizer()

        numeric = self.global_ns.class_('numeric_t')
        do_nothing = numeric.member_function('do_nothing')
        arg = do_nothing.arguments[0]

        generator = self.config.xml_generator_from_xml_file
        if generator.is_castxml1 or \
            (generator.is_castxml and
                float(generator.xml_output_version) >= 1.137):
            # This works since:
            # https://github.com/CastXML/CastXML/issues/25
            # https://github.com/CastXML/CastXML/pull/26
            # https://github.com/CastXML/CastXML/pull/27
            # The version bump to 1.137 came way later but this is the
            # only way to make sure the test is running correctly
            self.assertTrue("annotate(sealed)" == numeric.attributes)
            self.assertTrue("annotate(no throw)" == do_nothing.attributes)
            self.assertTrue("annotate(out)" == arg.attributes)
            self.assertTrue(
                numeric.member_operators(name="=")[0].attributes is None)
        else:
            self.assertTrue("gccxml(no throw)" == do_nothing.attributes)
            self.assertTrue("gccxml(out)" == arg.attributes)
开发者ID:gccxml,项目名称:pygccxml,代码行数:28,代码来源:attributes_tester.py


示例5: test

    def test(self):
        code = """
            namespace A{
            struct B{
                int c;
            };

            template <class T>
            struct C: public T{
                int d;
            };

            template <class T>
            struct D{
                int dD;
            };

            typedef C<B> easy;
            typedef D<easy> Deasy;

            inline void instantiate(){
                sizeof(easy);
            }

            }
        """

        global_ns = parser.parse_string( code, autoconfig.cxx_parsers_cfg.gccxml)
        global_ns = declarations.get_global_namespace( global_ns )
        easy = global_ns.typedef( 'easy' )
        c_a = declarations.class_traits.get_declaration( easy )  #this works very well
        deasy = global_ns.typedef( 'Deasy' )
        d_a = declarations.class_traits.get_declaration( deasy )  
        self.failUnless( isinstance( d_a, declarations.class_types ) )
开发者ID:atemysemicolon,项目名称:pyplusplusclone,代码行数:34,代码来源:type_traits_tester.py


示例6: test

 def test(self):
     src_reader = parser.source_reader_t(self.config)
     global_ns = declarations.get_global_namespace(
         src_reader.read_string(code))
     global_ns.decl('A<int>')
     f = global_ns.free_fun('f')
     self.failUnless(f.demangled == 'void f<int>(A<int> const&)')
开发者ID:programmdesign,项目名称:pygccxml,代码行数:7,代码来源:gccxml10183_tester.py


示例7: test

    def test(self):
        db = pypp_utils.exposed_decls_db_t()
        config = parser.config_t( gccxml_path=autoconfig.gccxml.executable )

        reader = parser.project_reader_t( config, None, decl_wrappers.dwfactory_t() )
        decls = reader.read_files( [parser.create_text_fc(self.CODE)] )
    
        global_ns = declarations.get_global_namespace( decls )
        ns = global_ns.namespace( 'ns' )
        ns_skip = global_ns.namespace( 'ns_skip' )

        global_ns.exclude()        
        ns.include()
        
        db.register_decls( global_ns, [] )
                    
        for x in ns.decls(recursive=True):
            self.failUnless( db.is_exposed( x ) == True )
            
        for x in ns_skip.decls(recursive=True):
            self.failUnless( db.is_exposed( x ) == False )

        db.save( os.path.join( autoconfig.build_dir, 'exposed.db.pypp' ) )

        db2 = pypp_utils.exposed_decls_db_t()
        db2.load( os.path.join( autoconfig.build_dir, 'exposed.db.pypp' ) )
        for x in ns.decls(recursive=True):
            self.failUnless( db.is_exposed( x ) == True )

        ns_skip = global_ns.namespace( 'ns_skip' )
        for x in ns_skip.decls(recursive=True):
            self.failUnless( db.is_exposed( x ) == False )
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:32,代码来源:exposed_decls_db_tester.py


示例8: test_attributes_thiscall

    def test_attributes_thiscall(self):
        """
        Test attributes with the "f2" flag

        """
        if self.config.compiler != "msvc":
            return

        self.config.flags = ["f2"]

        decls = parser.parse([self.header], self.config)
        Test.global_ns = declarations.get_global_namespace(decls)
        Test.global_ns.init_optimizer()

        numeric = self.global_ns.class_('numeric_t')
        do_nothing = numeric.member_function('do_nothing')
        arg = do_nothing.arguments[0]

        generator = self.config.xml_generator_from_xml_file
        if generator.is_castxml1 or (
                generator.is_castxml and
                float(generator.xml_output_version) >= 1.137):
            self.assertTrue("annotate(sealed)" == numeric.attributes)
            self.assertTrue("annotate(out)" == arg.attributes)

            self.assertTrue(
                "__thiscall__ annotate(no throw)" == do_nothing.attributes)
            self.assertTrue(
                numeric.member_operators(name="=")[0].attributes ==
                "__thiscall__")
开发者ID:gccxml,项目名称:pygccxml,代码行数:30,代码来源:attributes_tester.py


示例9: setUp

    def setUp(self):
        if not tester_t.global_ns:
            decls = parser.parse([self.header], self.config)
            tester_t.global_ns = declarations.get_global_namespace(decls)
            tester_t.global_ns.init_optimizer()

            process = subprocess.Popen(
                args='scons msvc_compiler=%s' %
                autoconfig.cxx_parsers_cfg.gccxml.compiler,
                shell=True,
                stdin=subprocess.PIPE,
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT,
                cwd=self.binary_parsers_dir)
            process.stdin.close()

            while process.poll() is None:
                line = process.stdout.readline()
                print(line.rstrip())
            for line in process.stdout.readlines():
                print(line.rstrip())
            if process.returncode:
                raise RuntimeError(
                    ("unable to compile binary parser module. " +
                        "See output for the errors."))
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:25,代码来源:undname_creator_tester.py


示例10: global_namespace

def global_namespace():
    #configure GCC-XML parser
    config = parser.config_t( gccxml_path= "c:/Progra~1/GCC_XML/bin/gccxml.exe",\
                              include_paths= ["e:/starteam/docplatform/nextrelease/code/common"] )
    #parsing source file
    decls = parser.parse( ['interf.h'], config )
    return declarations.get_global_namespace( decls )
开发者ID:Rogaven,项目名称:jagpdf,代码行数:7,代码来源:sig.py


示例11: test_function_pointer

    def test_function_pointer(self):
        """
        Test working with pointers and function pointers.

        """

        decls = parser.parse([self.header], self.config)
        global_ns = declarations.get_global_namespace(decls)

        # Test on a function pointer
        criteria = declarations.variable_matcher(name="func1")
        variables = declarations.matcher.find(criteria, global_ns)

        self.assertTrue(variables[0].name == "func1")
        self.assertTrue(
            isinstance(variables[0].decl_type, declarations.pointer_t))
        self.assertTrue(
            str(variables[0].decl_type) == "void (*)( int,double )")
        self.assertTrue(
            declarations.is_calldef_pointer(variables[0].decl_type))
        self.assertTrue(
            isinstance(declarations.remove_pointer(variables[0].decl_type),
                       declarations.free_function_type_t))

        # Get the function (free_function_type_t) and test the return and
        # argument types
        function = variables[0].decl_type.base
        self.assertTrue(isinstance(function.return_type, declarations.void_t))
        self.assertTrue(
            isinstance(function.arguments_types[0], declarations.int_t))
        self.assertTrue(
            isinstance(function.arguments_types[1], declarations.double_t))

        # Test on a normal pointer
        criteria = declarations.variable_matcher(name="myPointer")
        variables = declarations.matcher.find(criteria, global_ns)

        self.assertTrue(variables[0].name == "myPointer")
        self.assertTrue(
            isinstance(variables[0].decl_type, declarations.pointer_t))
        self.assertFalse(
            declarations.is_calldef_pointer(variables[0].decl_type))
        self.assertTrue(
            isinstance(declarations.remove_pointer(variables[0].decl_type),
                       declarations.volatile_t))

        # Test on function pointer in struct (x8)
        for d in global_ns.declarations:
            if d.name == "x8":
                self.assertTrue(
                    isinstance(d.decl_type, declarations.pointer_t))
                self.assertTrue(declarations.is_calldef_pointer(d.decl_type))
                self.assertTrue(
                    isinstance(
                        declarations.remove_pointer(d.decl_type),
                        declarations.member_function_type_t))
                self.assertTrue(
                    str(declarations.remove_pointer(d.decl_type)) ==
                    "void ( ::some_struct_t::* )(  )")
开发者ID:gccxml,项目名称:pygccxml,代码行数:59,代码来源:test_function_pointer.py


示例12: setUp

 def setUp(self):
     if not self.global_ns:
         decls = parser.parse([self.header], self.config)
         self.global_ns = declarations.get_global_namespace(decls)
         self.global_ns.init_optimizer()
         Test.xml_generator_from_xml_file = \
             self.config.xml_generator_from_xml_file
     self.xml_generator_from_xml_file = Test.xml_generator_from_xml_file
开发者ID:gccxml,项目名称:pygccxml,代码行数:8,代码来源:non_copyable_classes_tester.py


示例13: test2

 def test2(self):
     code = 'int* aaaa[2][3][4][5];'
     src_reader = parser.source_reader_t(self.config)
     global_ns = declarations.get_global_namespace(
         src_reader.read_string(code))
     aaaa_type = global_ns.var('aaaa').type
     self.failUnless(
         'int *[2][3][4][5]' == aaaa_type.decl_string,
         aaaa_type.decl_string)
开发者ID:programmdesign,项目名称:pygccxml,代码行数:9,代码来源:array_bug_tester.py


示例14: test_on_big_file

def test_on_big_file(file_name, count):
    file_name = os.path.join(autoconfig.data_directory, file_name)
    for i in range(count):
        reader = parser.project_reader_t(
            parser.xml_generator_configuration_t(
                xml_generator_path=autoconfig.generator_path))
        decls = reader.read_files([parser.create_gccxml_fc(file_name)])
        global_ns = declarations.get_global_namespace(decls)
        global_ns.init_optimizer()
开发者ID:gccxml,项目名称:pygccxml,代码行数:9,代码来源:test_performance.py


示例15: test4

 def test4(self):
     code = 'struct xyz{}; xyz aaaa[2][3];'
     src_reader = parser.source_reader_t(self.config)
     global_ns = declarations.get_global_namespace(
         src_reader.read_string(code))
     aaaa_type = global_ns.variable('aaaa').type
     self.assertTrue(
         '::xyz[2][3]' == aaaa_type.decl_string,
         aaaa_type.decl_string)
开发者ID:MarkOates,项目名称:pygccxml,代码行数:9,代码来源:array_bug_tester.py


示例16: test3

 def test3(self):
     code = 'int aaaa[2];'
     src_reader = parser.source_reader_t(self.config)
     global_ns = declarations.get_global_namespace(
         src_reader.read_string(code))
     aaaa_type = global_ns.variable('aaaa').type
     self.assertTrue(
         'int[2]' == aaaa_type.decl_string,
         aaaa_type.decl_string)
开发者ID:MarkOates,项目名称:pygccxml,代码行数:9,代码来源:array_bug_tester.py


示例17: setUp

 def setUp(self):
     if not gccxml_declarations_t.global_ns:
         decls = parser.parse(
             self.test_files,
             self.config,
             self.COMPILATION_MODE)
         gccxml_declarations_t.global_ns = \
             declarations.get_global_namespace(decls)
     if not self.global_ns:
         self.global_ns = gccxml_declarations_t.global_ns
开发者ID:iMichka,项目名称:pygccxml,代码行数:10,代码来源:declarations_tester.py


示例18: global_namespace

def global_namespace(options):
    config = setup_pygccxml(options)
    gcccache = options["gccxml-cache"]
    if not gcccache:
        gcccache = "gcccache"
    cache = parser.directory_cache.directory_cache_t(dir=gcccache, md5_sigs=False)
    # normalize input files so that cache can match them
    # mixed slashes does not play well with the cache
    in_files = [os.path.abspath(p) for p in options["infiles"]]
    decls = parser.parse(in_files, config, cache=cache)
    return declarations.get_global_namespace(decls)
开发者ID:mkawserm,项目名称:jagpdf,代码行数:11,代码来源:introspect.py


示例19: test

    def test(self):
        decls = parser.parse_string(code, self.config)
        global_ns = declarations.get_global_namespace(decls)

        # TODO: demangled attribute does not existe for castxml
        # and will not be added. Remove this test once gccxml
        # support is dropped.
        if self.config.xml_generator_from_xml_file.is_gccxml:
            global_ns.decl('A<int>')
            f = global_ns.free_function('f')
            self.assertTrue(f.demangled == 'void f<int>(A<int> const&)')
开发者ID:gccxml,项目名称:pygccxml,代码行数:11,代码来源:gccxml10183_tester.py


示例20: test

    def test(self):
        src_reader = parser.source_reader_t(self.config)
        global_ns = declarations.get_global_namespace(
            src_reader.read_string(code))

        # TODO: demangled attribute does not existe for castxml
        # and will not be added. Remove this test once gccxml
        # support is dropped.
        if 'GCCXML' in utils.xml_generator:
            global_ns.decl('A<int>')
            f = global_ns.free_fun('f')
            self.assertTrue(f.demangled == 'void f<int>(A<int> const&)')
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:12,代码来源:gccxml10183_tester.py



注:本文中的pygccxml.declarations.get_global_namespace函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python declarations.is_const函数代码示例发布时间:2022-05-25
下一篇:
Python declarations.full_name函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap