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

Python declarations.find_declaration函数代码示例

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

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



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

示例1: __test_type_transformation

    def __test_type_transformation(self, ns_name, transformer):
        ns_control = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.namespace_t,
            name=ns_name)
        self.assertTrue(ns_control, "unable to find '%s' namespace" % ns_name)
        ns_before = declarations.find_declaration(
            ns_control,
            decl_type=declarations.namespace_t,
            name='before')
        self.assertTrue(ns_before, "unable to find 'before' namespace")
        ns_after = declarations.find_declaration(
            ns_control,
            decl_type=declarations.namespace_t,
            name='after')
        self.assertTrue(ns_after, "unable to find 'after' namespace")

        for tbefore in ns_before.declarations:
            tafter = declarations.find_declaration(
                ns_after,
                name=tbefore.name)
            self.assertTrue(
                tafter,
                "unable to find transformed type definition for type '%s'" %
                tbefore.decl_string)
            transformed = transformer(tbefore)
            self.assertTrue(
                declarations.is_same(
                    transformed,
                    tafter),
                ("there is a difference between expected type '{0}' " +
                 "and result '{1}'. typedef name: {2}").format(
                    declarations.remove_declarated(tafter).decl_string,
                    declarations.remove_declarated(transformed).decl_string,
                    tbefore.decl_string))
开发者ID:gccxml,项目名称:pygccxml,代码行数:35,代码来源:type_traits_tester.py


示例2: test_is_base_and_derived

    def test_is_base_and_derived(self):
        ns = declarations.find_declaration(
            self.declarations,
            type=declarations.namespace_t,
            name='is_base_and_derived')
        self.failUnless(ns, "unable to find 'is_base_and_derived' namespace")
        base = declarations.find_declaration(
            ns.declarations,
            type=declarations.class_t,
            name='base')
        derived = declarations.find_declaration(
            ns.declarations,
            type=declarations.class_t,
            name='derived')
        self.failUnless(
            base and derived and declarations.is_base_and_derived(
                base,
                derived))
        self.failUnless(
            base and derived and
            declarations.is_base_and_derived(base, (derived, derived)))

        unrelated1 = declarations.find_declaration(
            ns.declarations,
            type=declarations.class_t,
            name='unrelated1')

        unrelated2 = declarations.find_declaration(
            ns.declarations,
            type=declarations.class_t,
            name='unrelated2')
        self.failUnless(
            base and derived and not declarations.is_base_and_derived(
                unrelated1,
                unrelated2))
开发者ID:programmdesign,项目名称:pygccxml,代码行数:35,代码来源:type_traits_tester.py


示例3: __test_type_category

    def __test_type_category(self, ns_name, controller):
        ns_control = declarations.find_declaration(
            self.declarations,
            type=declarations.namespace_t,
            name=ns_name)
        self.failUnless(ns_control, "unable to find '%s' namespace" % ns_name)
        ns_yes = declarations.find_declaration(
            ns_control,
            type=declarations.namespace_t,
            name='yes')
        self.failUnless(ns_yes, "unable to find 'yes' namespace")
        ns_no = declarations.find_declaration(
            ns_control,
            type=declarations.namespace_t,
            name='no')
        self.failUnless(ns_no, "unable to find 'no' namespace")
        er = 'for type "%s" the answer to the question "%s" should be True'
        for decl in ns_yes.declarations:
            if isinstance(decl, declarations.variable_t):
                self.failUnless(
                    controller(decl.type),
                    er % (decl.type.decl_string, ns_name))
            elif isinstance(decl, declarations.calldef_t) and \
                    decl.name.startswith('test_'):
                continue
            else:
                self.failUnless(
                    controller(decl), er % (decl.decl_string, ns_name))
        er = 'for type "%s" the answer to the question "%s" should be False'
        for decl in ns_no.declarations:
            if isinstance(decl, declarations.calldef_t) and \
                    decl.name.startswith('test_'):
                continue

            self.failIf(controller(decl), er % (decl.decl_string, ns_name))
开发者ID:programmdesign,项目名称:pygccxml,代码行数:35,代码来源:type_traits_tester.py


示例4: __test_type_transformation

    def __test_type_transformation(self, ns_name, transformer):
        ns_control = declarations.find_declaration(
            self.declarations,
            type=declarations.namespace_t,
            name=ns_name)
        self.failUnless(ns_control, "unable to find '%s' namespace" % ns_name)
        ns_before = declarations.find_declaration(
            ns_control,
            type=declarations.namespace_t,
            name='before')
        self.failUnless(ns_before, "unable to find 'before' namespace")
        ns_after = declarations.find_declaration(
            ns_control,
            type=declarations.namespace_t,
            name='after')
        self.failUnless(ns_after, "unable to find 'after' namespace")

        for tbefore in ns_before.declarations:
            tafter = declarations.find_declaration(
                ns_after,
                name=tbefore.name)
            self.failUnless(
                tafter,
                "unable to find transformed type definition for type '%s'" %
                tbefore.decl_string)
            transformed = transformer(tbefore)
            self.failUnless(
                declarations.is_same(
                    transformed,
                    tafter),
                ("there is a difference between expected type and result. " +
                 "typedef name: %s") % tbefore.decl_string)
开发者ID:programmdesign,项目名称:pygccxml,代码行数:32,代码来源:type_traits_tester.py


示例5: __is_convertible_impl

 def __is_convertible_impl( self, decl ):
     defs = decl.bases[0].related_class.declarations
     source_type = declarations.find_declaration( defs, name='source_type' )
     target_type = declarations.find_declaration( defs, name='target_type' )
     expected_type = declarations.find_declaration( defs
                                                    , name='expected'
                                                    , type=declarations.enumeration_t )
     expected_value = bool( expected_type.get_name2value_dict()['value'] )
     self.failUnless( expected_value == declarations.is_convertible( source_type, target_type )
                      , 'Check conversion failed for ' + decl.name )
开发者ID:atemysemicolon,项目名称:pyplusplusclone,代码行数:10,代码来源:type_traits_tester.py


示例6: __check_result

 def __check_result(self, decls):
     E11 = declarations.find_declaration(decls, fullname='::E11')
     self.assertTrue(E11, "unable to find 'E11' enum")
     ns12 = declarations.find_declaration(decls, fullname='::ns::ns12')
     self.assertTrue(ns12, "unable to find 'ns12' namespace")
     E13 = declarations.find_declaration(ns12.declarations, name='E13')
     self.assertTrue(E13, "unable to find 'E13' enum")
     E14 = declarations.find_declaration(decls, name='E14')
     self.assertTrue(
         not E14,
         "enum 'E14' should not be found in declarations")
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:11,代码来源:start_with_declarations_tester.py


示例7: __is_convertible_impl

 def __is_convertible_impl( self, decl ):
     if decl.name == 'x81':
         i = 0
     defs = decl.bases[0].related_class.declarations
     source_type = declarations.find_declaration( defs, name='source_type' )
     target_type = declarations.find_declaration( defs, name='target_type' )
     expected_type = declarations.find_declaration( defs
                                                    , name='expected'
                                                    , type=declarations.enumeration_t )
     expected_value = bool( expected_type.get_name2value_dict()['value'] )
     if expected_value != declarations.is_convertible( source_type, target_type ):
         print decl.name
开发者ID:glehmann,项目名称:WrapITK-unstable,代码行数:12,代码来源:type_traits_tester.py


示例8: test_numeric_patcher

 def test_numeric_patcher(self):
     fix_numeric = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='fix_numeric' )
     self.failUnless( fix_numeric, "Free function fix_numeric has not been found." )
     if 32 == self.architecture:
         self.failUnless( fix_numeric.arguments[0].default_value == u"0xffffffffffffffff" )
     else: 
         self.failUnless( fix_numeric.arguments[0].default_value == u"0ffffffff" )
开发者ID:glehmann,项目名称:WrapITK-unstable,代码行数:7,代码来源:patcher_tester.py


示例9: setUp

 def setUp(self):
     if not self.declarations:
         self.declarations = parser.parse( [self.header], self.config )
         self.global_ns = declarations.find_declaration( self.declarations
                                                         , type=declarations.namespace_t
                                                         , name='::' )
         self.global_ns.init_optimizer()
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:7,代码来源:typedefs_tester.py


示例10: test_is_convertible

    def test_is_convertible( self ):
        ns_is_convertible = declarations.find_declaration( self.declarations
                                                           , type=declarations.namespace_t
                                                           , name="is_convertible" )

        self.failUnless( ns_is_convertible, "namespace is_convertible was not found" )
        for tester in filter( lambda decl: decl.name.startswith( 'x' ), ns_is_convertible.declarations ):
            self.__is_convertible_impl( tester )
开发者ID:atemysemicolon,项目名称:pyplusplusclone,代码行数:8,代码来源:type_traits_tester.py


示例11: __test_type_category

    def __test_type_category(self, ns_name, controller):
        ns_control = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.namespace_t,
            name=ns_name)
        self.assertTrue(ns_control, "unable to find '%s' namespace" % ns_name)
        ns_yes = declarations.find_declaration(
            ns_control,
            decl_type=declarations.namespace_t,
            name='yes')
        self.assertTrue(ns_yes, "unable to find 'yes' namespace")
        ns_no = declarations.find_declaration(
            ns_control,
            decl_type=declarations.namespace_t,
            name='no')
        self.assertTrue(ns_no, "unable to find 'no' namespace")
        er = 'for type "%s" the answer to the question "%s" should be True'
        for decl in ns_yes.declarations:
            if isinstance(decl, declarations.variable_t):
                self.assertTrue(
                    controller(decl.decl_type),
                    er % (decl.decl_type.decl_string, ns_name))
            elif isinstance(decl, declarations.calldef_t) and \
                    decl.name.startswith('test_'):
                continue
            else:
                self.assertTrue(
                    controller(decl), er % (decl.decl_string, ns_name))
        er = 'for type "%s" the answer to the question "%s" should be False'
        generator = self.xml_generator_from_xml_file
        for decl in ns_no.declarations:
            if isinstance(decl, declarations.calldef_t) and \
                    decl.name.startswith('test_'):
                continue

            if generator.is_castxml1 or (
                    generator.is_castxml and
                    float(generator.xml_output_version) < 1.138):
                if decl.name in ['const_item', 'const_container']:
                    # Skip this test to workaround CastXML bug.
                    # See https://github.com/CastXML/CastXML/issues/55
                    continue

            self.assertFalse(
                controller(decl),
                er % (decl.decl_string, ns_name))
开发者ID:gccxml,项目名称:pygccxml,代码行数:46,代码来源:type_traits_tester.py


示例12: test

 def test( self ):                
     item_cls = declarations.find_declaration( self.declarations
                                           , type=declarations.class_t
                                           , name='item_t' )
     self.failUnless( item_cls, "unable to find class 'item_t'" )
     self.failUnless( len( item_cls.aliases ) == 3 )
     expected_aliases = set( ['Item', 'Item1', 'Item2' ] )
     real_aliases = set( map( lambda typedef: typedef.name, item_cls.aliases ) )
     self.failUnless( real_aliases == expected_aliases )
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:9,代码来源:typedefs_tester.py


示例13: test

 def test(self):
     item_cls = declarations.find_declaration(
         self.declarations,
         type=declarations.class_t,
         name='item_t')
     self.assertTrue(item_cls, "unable to find class 'item_t'")
     self.assertTrue(len(item_cls.aliases) == 3)
     expected_aliases = set(['Item', 'Item1', 'Item2'])
     real_aliases = set([typedef.name for typedef in item_cls.aliases])
     self.assertTrue(real_aliases == expected_aliases)
开发者ID:Artoria2e5,项目名称:pygccxml,代码行数:10,代码来源:typedefs_tester.py


示例14: test

    def test(self):
        fconfig = parser.file_configuration_t(
            data="int i;", start_with_declarations=None, content_type=parser.file_configuration_t.CONTENT_TYPE.TEXT
        )

        prj_reader = parser.project_reader_t(self.config)
        decls = prj_reader.read_files([fconfig], compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)

        var_i = declarations.find_declaration(decls, type=declarations.variable_t, name="i")
        self.failUnless(var_i, "Variable i has not been found.")
开发者ID:iMichka,项目名称:pygccxml,代码行数:10,代码来源:text_reader_tester.py


示例15: test_is_convertible

    def test_is_convertible(self):
        ns_is_convertible = declarations.find_declaration(
            self.declarations,
            type=declarations.namespace_t,
            name="is_convertible")

        self.failUnless(
            ns_is_convertible,
            "namespace is_convertible was not found")
        for tester in [
            decl for decl in ns_is_convertible.declarations if
                decl.name.startswith('x')]:

            self.__is_convertible_impl(tester)
开发者ID:programmdesign,项目名称:pygccxml,代码行数:14,代码来源:type_traits_tester.py


示例16: test_by_location

 def test_by_location(self):
     reader = parser.source_reader_t( self.config )
     decls = reader.read_file( self.__fname )
     decls_count = len( declarations.make_flatten( decls ) )
     filtered = declarations.filtering.by_location( decls, [autoconfig.data_directory] )
     flatten_filtered = declarations.make_flatten( filtered )
     self.failUnless( len( flatten_filtered  ) != decls_count )
     for decl in flatten_filtered:
         if decl.location:
             self.failUnless( declarations.filtering.normalize_path( decl.location.file_name )
                              , self.__fpath )
     self.failUnless( declarations.find_declaration( filtered
                                                     , name='color'
                                                     , type=declarations.enumeration_t
                                                     , recursive=False) )
开发者ID:ChrisCarlsen,项目名称:tortuga,代码行数:15,代码来源:filtering_tester.py


示例17: test_is_unary_binary_operator

    def test_is_unary_binary_operator(self):
        operator_not = declarations.find_declaration( self.declarations
                                                      , type=declarations.operator_t
                                                      , fullname='::is_unary_operator::dummy::operator!' )
        self.failUnless( operator_not, 'operator! was not found' )
        self.failUnless( declarations.is_unary_operator( operator_not ), 'operator! should be idenitified as unary operator' )
        self.failUnless( not declarations.is_binary_operator( operator_not ), 'operator! should be idenitified as unary operator' )

        operator_class_p = declarations.find_declaration( self.declarations
                                                          , type=declarations.operator_t
                                                          , fullname='::is_unary_operator::dummy::operator+' )
        self.failUnless( operator_class_p, 'operator+ was not found' )
        self.failUnless( not declarations.is_unary_operator( operator_class_p ), 'operator+ should be idenitified as binary operator' )
        self.failUnless( declarations.is_binary_operator( operator_class_p ), 'operator! should be idenitified as binary operator' )

        operator_class_pp = declarations.find_declaration( self.declarations
                                                           , type=declarations.operator_t
                                                           , fullname='::is_unary_operator::dummy::operator++' )
        self.failUnless( operator_class_pp, 'operator++ was not found' )
        self.failUnless( declarations.is_unary_operator( operator_class_pp ), 'operator++ should be idenitified as unary operator' )
        self.failUnless( not declarations.is_binary_operator( operator_class_pp ), 'operator++ should be idenitified as unary operator' )

        operator_pp = declarations.find_declaration( self.declarations
                                                     , type=declarations.operator_t
                                                     , fullname='::is_unary_operator::operator++' )
        self.failUnless( operator_pp, 'operator++ was not found' )
        self.failUnless( declarations.is_unary_operator( operator_pp ), 'operator++ should be idenitified as unary operator' )
        self.failUnless( not declarations.is_binary_operator( operator_pp ), 'operator++ should be idenitified as unary operator' )

        operator_mm = declarations.find_declaration( self.declarations
                                                     , type=declarations.operator_t
                                                     , fullname='::is_unary_operator::operator*' )
        self.failUnless( operator_mm, 'operator-- was not found' )
        self.failUnless( not declarations.is_unary_operator( operator_mm ), 'operator-- should be idenitified as binary operator' )
        self.failUnless( declarations.is_binary_operator( operator_mm ), 'operator-- should be idenitified as binray operator' )

        operator_pe = declarations.find_declaration( self.declarations
                                                     , type=declarations.operator_t
                                                     , fullname='::is_unary_operator::operator+=' )
        self.failUnless( operator_pe, 'operator+= was not found' )
        self.failUnless( not declarations.is_unary_operator( operator_pe ), 'operator+= should be idenitified as binary operator' )
        self.failUnless( declarations.is_binary_operator( operator_pe ), 'operator+= should be idenitified as binray operator' )
开发者ID:atemysemicolon,项目名称:pyplusplusclone,代码行数:42,代码来源:type_traits_tester.py


示例18: test_enum_patcher

 def test_enum_patcher(self):
     fix_enum = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='fix_enum' )
     self.failUnless( fix_enum, "Free function fix_enum has not been found." )
     self.failUnless( fix_enum.arguments[0].default_value == '::ns1::ns2::apple' )
开发者ID:glehmann,项目名称:WrapITK-unstable,代码行数:4,代码来源:patcher_tester.py


示例19: test_unnamed_enum_patcher

 def test_unnamed_enum_patcher(self):
     fix_unnamed = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='fix_unnamed' )
     self.failUnless( fix_unnamed, "Free function fix_unnamed has not been found." )
     self.failUnless( fix_unnamed.arguments[0].default_value == u"int(::fx::unnamed)" )
开发者ID:glehmann,项目名称:WrapITK-unstable,代码行数:4,代码来源:patcher_tester.py


示例20: test_function_call_patcher

 def test_function_call_patcher(self):
     fix_function_call = declarations.find_declaration( self.__decls, type=declarations.free_function_t, name='fix_function_call' )
     self.failUnless( fix_function_call, "Free function fix_function_call has not been found." )
     self.failUnless( fix_function_call.arguments[0].default_value == u"function_call::calc( 1, 2, 3 )" )
开发者ID:glehmann,项目名称:WrapITK-unstable,代码行数:4,代码来源:patcher_tester.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python declarations.full_name函数代码示例发布时间:2022-05-25
下一篇:
Python declarations.dummy_type_t函数代码示例发布时间: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