How to use the pygccxml.declarations.find_declaration function in pygccxml

To help you get started, we’ve selected a few pygccxml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gccxml / pygccxml / unittests / text_reader_tester.py View on Github external
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, decl_type=declarations.variable_t, name='i')
        self.assertTrue(var_i, "Variable i has not been found.")
github gccxml / pygccxml / unittests / type_traits_tester.py View on Github external
not declarations.is_binary_operator(operator_pp),
            'operator++ should be idenitified as unary operator')

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

        operator_pe = declarations.find_declaration(
            self.declarations,
            decl_type=declarations.operator_t,
            fullname='::is_unary_operator::operator+=')
        self.assertTrue(operator_pe, 'operator+= was not found')
        self.assertTrue(
            not declarations.is_unary_operator(operator_pe),
            'operator+= should be idenitified as binary operator')
        self.assertTrue(
            declarations.is_binary_operator(operator_pe),
            'operator+= should be idenitified as binray operator')
github gccxml / pygccxml / unittests / start_with_declarations_tester.py View on Github external
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")
github gccxml / pygccxml / unittests / start_with_declarations_tester.py View on Github external
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")
github gccxml / pygccxml / unittests / type_traits_tester.py View on Github external
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))
github gccxml / pygccxml / unittests / type_traits_tester.py View on Github external
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 \
github InsightSoftwareConsortium / ITK / parser / project_reader.py View on Github external
def _join_top_namespaces(main_ns_list, other_ns_list):
        answer = main_ns_list[:]
        for other_ns in other_ns_list:
            main_ns = pygccxml.declarations.find_declaration(
                answer,
                decl_type=pygccxml.declarations.namespace_t,
                name=other_ns._name,
                recursive=False)
            if main_ns:
                main_ns.take_parenting(other_ns)
            else:
                answer.append(other_ns)
        return answer
github cpc / tce / tce / Python-bindings / tools / pygccxml / pygccxml / parser / project_reader.py View on Github external
def _join_top_namespaces(self, main_ns_list, other_ns_list):
        answer = main_ns_list[:]
        for other_ns in other_ns_list:
            main_ns = pygccxml.declarations.find_declaration( answer
                                                              , type=pygccxml.declarations.namespace_t
                                                              , name=other_ns._name
                                                              , recursive=False )
            if main_ns:
                main_ns.take_parenting( other_ns )
            else:
                answer.append( other_ns )
        return answer
github gccxml / pygccxml / pygccxml / parser / project_reader.py View on Github external
def _join_top_namespaces(main_ns_list, other_ns_list):
        answer = main_ns_list[:]
        for other_ns in other_ns_list:
            main_ns = pygccxml.declarations.find_declaration(
                answer,
                decl_type=pygccxml.declarations.namespace_t,
                name=other_ns._name,
                recursive=False)
            if main_ns:
                main_ns.take_parenting(other_ns)
            else:
                answer.append(other_ns)
        return answer