How to use the pygccxml.declarations.make_flatten 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 / decl_printer_tester.py View on Github external
def test__str__(self):
        decls = declarations.make_flatten(self.decls)
        for decl in decls:
            str(decl)
github gccxml / pygccxml / unittests / test_pattern_parser.py View on Github external
def test_template_split_std_vector(self):
        """
        Demonstrate error in pattern parser, see #60

        """

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

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

        for decl in declarations.make_flatten(decls):
            if "myClass" in decl.name:
                _ = decl.partial_name
github gccxml / pygccxml / unittests / filtering_tester.py View on Github external
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) )
github gccxml / pygccxml / unittests / declarations_comparison_tester.py View on Github external
def test_comparison_declaration_by_declaration(self):
        parsed = parser.parse([self.header], self.config)
        copied = copy.deepcopy(parsed)
        parsed = declarations.make_flatten(parsed)
        copied = declarations.make_flatten(copied)
        parsed.sort()
        copied.sort()
        failuers = []
        for parsed_decl, copied_decl, index in \
                zip(parsed, copied, list(range(len(copied)))):

            if parsed_decl != copied_decl:
                failuers.append(
                    ("__lt__ and/or __qe__ does not working " +
                        "properly in case of %s, %s, index %d") %
                    (parsed_decl.__class__.__name__,
                        copied_decl.__class__.__name__, index))
        self.assertTrue(not failuers, 'Failures: ' + '\n\t'.join(failuers))
github InsightSoftwareConsortium / ITK / parser / project_reader.py View on Github external
"Cache has been flushed in %.1f secs",
            (timeit.default_timer() - start_time))
        answer = []
        self.logger.debug("Joining namespaces ...")
        for file_nss in namespaces:
            answer = self._join_top_namespaces(answer, file_nss)
        self.logger.debug("Joining declarations ...")
        for ns in answer:
            if isinstance(ns, pygccxml.declarations.namespace_t):
                declarations_joiner.join_declarations(ns)
        leaved_classes = self._join_class_hierarchy(answer)
        types = self.__declarated_types(answer)
        self.logger.debug("Relinking declared types ...")
        self._relink_declarated_types(leaved_classes, types)
        declarations_joiner.bind_aliases(
            pygccxml.declarations.make_flatten(answer))
        return answer
github gccxml / pygccxml / pygccxml / parser / project_reader.py View on Github external
elif isinstance(cpptype, pygccxml.declarations.declarated_t):
                return [cpptype]
            elif isinstance(cpptype, pygccxml.declarations.compound_t):
                return get_from_type(cpptype.base)
            elif isinstance(cpptype, pygccxml.declarations.calldef_type_t):
                types = get_from_type(cpptype.return_type)
                for arg in cpptype.arguments_types:
                    types.extend(get_from_type(arg))
                return types
            assert isinstance(
                cpptype,
                (pygccxml.declarations.unknown_t,
                 pygccxml.declarations.ellipsis_t))
            return []
        types = []
        for decl in pygccxml.declarations.make_flatten(namespaces):
            if isinstance(decl, pygccxml.declarations.calldef_t):
                types.extend(get_from_type(decl.function_type()))
            elif isinstance(
                    decl, (pygccxml.declarations.typedef_t,
                           pygccxml.declarations.variable_t)):
                types.extend(get_from_type(decl.decl_type))
        return types
github cpc / tce / tce / Python-bindings / tools / pygccxml / pyplusplus / module_creator / creator.py View on Github external
def _prepare_decls( self, decls, doc_extractor ):
        to_be_exposed = []
        for decl in declarations.make_flatten( decls ):
            if decl.ignore:
                continue

            if isinstance( decl, declarations.namespace_t ):
                continue

            if not decl.exportable:
                #leave only decls that user wants to export and that could be exported
                self.__print_readme( decl )
                continue

            if decl.already_exposed:
                #check wether this is already exposed in other module
                continue

            if isinstance( decl.parent, declarations.namespace_t ):
github cpc / tce / tce / Python-bindings / tools / pygccxml / pygccxml / parser / project_reader.py View on Github external
def _join_class_hierarchy( self, namespaces ):
        create_key = lambda decl:( decl.location.as_tuple()
                                   , tuple( pygccxml.declarations.declaration_path( decl ) ) )
        classes = filter( lambda decl: isinstance(decl, pygccxml.declarations.class_t )
                          , pygccxml.declarations.make_flatten( namespaces ) )
        leaved_classes = {}
        #selecting classes to leave
        for class_ in classes:
            key = create_key( class_ )
            if key not in leaved_classes:
                leaved_classes[ key ] = class_
        #replacing base and derived classes with those that should be leave
        #also this loop will add missing derived classes to the base
        for class_ in classes:
            leaved_class = leaved_classes[create_key( class_ )]
            for base_info in class_.bases:
                leaved_base = leaved_classes[ create_key( base_info.related_class ) ]
                #treating base class hierarchy of leaved_class
                leaved_base_info = pygccxml.declarations.hierarchy_info_t(
                    related_class=leaved_base
                    , access=base_info.access )
github cpc / tce / tce / Python-bindings / tools / pygccxml / pyplusplus / module_builder / builder.py View on Github external
def __apply_decls_defaults(self, decls):
        flatten_decls = decls_package.make_flatten( decls )
        self.__filter_by_location( flatten_decls )
        call_policies_resolver = mcreator_package.built_in_resolver_t()
        calldefs = filter( lambda decl: isinstance( decl, decls_package.calldef_t )
                           , flatten_decls )
        map( lambda calldef: calldef.set_call_policies( call_policies_resolver( calldef ) )
             , calldefs )
        mem_vars = filter( lambda decl: isinstance( decl, decls_package.variable_t )
                                        and isinstance( decl.parent, decls_package.class_t )
                           , flatten_decls )
        map( lambda mem_var: mem_var.set_getter_call_policies( call_policies_resolver( mem_var, 'get' ) )
             , mem_vars )
        map( lambda mem_var: mem_var.set_setter_call_policies( call_policies_resolver( mem_var, 'set' ) )
             , mem_vars )