How to use the pygccxml.declarations.type_traits.remove_declarated 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 gjcarneiro / pybindgen / pybindgen / castxmlparser.py View on Github external
if outer_class is None:
                    warnings.warn_explicit(("Class %s ignored: anonymous structure not inside a named structure/union."
                                            % cls.partial_decl_string),
                                           NotSupportedWarning, cls.location.file_name, cls.location.line)
                    continue

                self._anonymous_structs.append((cls, outer_class))
                continue

            timings.append(time.time())

            if '<' in cls.name:

                for typedef in module_namespace.typedefs(function=self.location_filter,
                                                         recursive=False, allow_empty=True):
                    typedef_type = type_traits.remove_declarated(typedef.decl_type)
                    if typedef_type == cls:
                        break
                else:
                    typedef = None

            timings.append(time.time())
            base_class_wrappers = []
            bases_ok = True
            for cls_bases_item in cls.bases:
                base_cls = cls_bases_item.related_class
                try:
                    base_class_wrapper = self._registered_classes[base_cls]
                except KeyError:
                    ## base class not yet registered => postpone this class registration
                    if base_cls not in unregistered_classes:
                        warnings.warn_explicit("Class %s ignored because it uses a base class (%s) "
github gjcarneiro / pybindgen / pybindgen / gccxmlparser.py View on Github external
have_copy_constructor = True

            ## ------------ attribute --------------------
            elif isinstance(member, variable_t):
                if not member.name:
                    continue # anonymous structure
                if member.access_type == 'protected':
                    warnings.warn_explicit("%s: protected member variables not yet implemented "
                                           "by PyBindGen."
                                           % member,
                                           NotSupportedWarning, member.location.file_name, member.location.line)
                    continue
                if member.access_type == 'private':
                    continue

                real_type = type_traits.remove_declarated(member.type)
                if hasattr(real_type, 'name') and not real_type.name:
                    warnings.warn_explicit("Member variable %s of class %s will not be wrapped, "
                                           "because wrapping member variables of anonymous types "
                                           "is not yet supported by pybindgen"
                                           % (member.name, cls.partial_decl_string),
                                           NotSupportedWarning, member.location.file_name, member.location.line)
                    continue

                return_type_spec = self.type_registry.lookup_return(member.type, global_annotations)

                ## pygen...
                if 'pygen_comment' in global_annotations:
                    pygen_sink.writeln('## ' + global_annotations['pygen_comment'])
                if member.type_qualifiers.has_static:
                    pygen_sink.writeln("cls.add_static_attribute(%r, %s, is_const=%r)" %
                                       (member.name, _pygen_retval(*return_type_spec),
github InsightSoftwareConsortium / ITK / pygccxml / declarations / container_traits.py View on Github external
def __find_xxx_type(
            self,
            type_,
            xxx_index,
            xxx_typedef,
            cache_property_name):
        cls = self.class_declaration(type_)
        result = getattr(cls.cache, cache_property_name)
        if not result:
            if isinstance(cls, class_declaration.class_t):
                xxx_type = cls.typedef(xxx_typedef, recursive=False).type
                result = type_traits.remove_declarated(xxx_type)
            else:
                xxx_type_str = templates.args(cls.name)[xxx_index]
                result = type_traits.impl_details.find_value_type(
                    cls.top_parent,
                    xxx_type_str)
                if None is result:
                    raise RuntimeError(
                        "Unable to find out %s '%s' key\\value type." %
                        (self.name(), cls.decl_string))
            setattr(cls.cache, cache_property_name, result)
        return result
github gjcarneiro / pybindgen / pybindgen / castxmlparser.py View on Github external
postpone_class(cls, "waiting for base class %s to be registered first" % base_cls)
                    bases_ok = False
                    break
                else:
                    base_class_wrappers.append(base_class_wrapper)
                    del base_class_wrapper
                del base_cls
            if not bases_ok:
                continue

            timings.append(time.time())

            ## If this class implicitly converts to another class, but
            ## that other class is not yet registered, postpone.
            for operator in cls.casting_operators(allow_empty=True):
                target_type = type_traits.remove_declarated(operator.return_type)
                if not isinstance(target_type, class_t):
                    continue
                target_class_name = normalize_class_name(operator.return_type.partial_decl_string, '::')
                try:
                    dummy = root_module[target_class_name]
                except KeyError:
                    if target_class_name not in [normalize_class_name(t.partial_decl_string, '::') for t in unregistered_classes]:
                        ok = True # (lp:455689)
                    else:
                        ok = False
                    break
            else:
                ok = True
            if not ok:
                postpone_class(cls, ("waiting for implicit conversion target class %s to be registered first"
                                     % (operator.return_type.partial_decl_string,)))
github gccxml / pygccxml / pygccxml / declarations / container_traits.py View on Github external
def __find_xxx_type(
            self,
            type_,
            xxx_index,
            xxx_typedef,
            cache_property_name):
        cls_declaration = self.class_declaration(type_)
        result = getattr(cls_declaration.cache, cache_property_name)
        if not result:
            if isinstance(cls_declaration, class_declaration.class_t):
                xxx_type = cls_declaration.typedef(
                    xxx_typedef, recursive=False).decl_type
                result = type_traits.remove_declarated(xxx_type)
            else:
                xxx_type_str = templates.args(cls_declaration.name)[xxx_index]
                result = traits_impl_details.impl_details.find_value_type(
                    cls_declaration.top_parent, xxx_type_str)
                if None is result:
                    raise RuntimeError(
                        "Unable to find out %s '%s' key\\value type." %
                        (self.name(), cls_declaration.decl_string))
            setattr(cls_declaration.cache, cache_property_name, result)
        return result
github gccxml / pygccxml / pygccxml / declarations / has_operator_matcher.py View on Github external
def has_public_binary_operator(type_, operator_symbol):
    """returns True, if `type_` has public binary operator, otherwise False"""
    type_ = type_traits.remove_alias(type_)
    type_ = type_traits.remove_cv(type_)
    type_ = type_traits.remove_declarated(type_)
    assert isinstance(type_, class_declaration.class_t)

    if type_traits.is_std_string(type_) or type_traits.is_std_wstring(type_):
        # In some case compare operators of std::basic_string are not
        # instantiated
        return True

    operators = type_.member_operators(
        function=matchers.custom_matcher_t(
            lambda decl: not decl.is_artificial) &
        matchers.access_type_matcher_t('public'),
        symbol=operator_symbol, allow_empty=True, recursive=False)
    if operators:
        return True

    t = cpptypes.declarated_t(type_)
github NetBSD / xsrc / external / mit / MesaLib / dist / src / gallium / drivers / svga / svgadump / svga_dump.py View on Github external
def visit_declarated(self):
        #print 'decl = %r' % self.type.decl_string
        decl = type_traits.remove_declarated(self.type)
        dump_decl(self.instance, decl)
github gccxml / pygccxml / pygccxml / declarations / pointer_traits.py View on Github external
def is_smart_pointer(type_):
        """returns True, if type represents instantiation of
        `boost::shared_ptr`, False otherwise"""
        type_ = type_traits.remove_alias(type_)
        type_ = type_traits.remove_cv(type_)
        type_ = type_traits.remove_declarated(type_)
        if not isinstance(type_,
                          (class_declaration.class_declaration_t,
                           class_declaration.class_t)):
            return False
        if not traits_impl_details.impl_details.is_defined_in_xxx(
                'std', type_):
            return False
        return type_.decl_string.startswith('::std::auto_ptr<')
github gccxml / pygccxml / pygccxml / declarations / pointer_traits.py View on Github external
def is_smart_pointer(type_):
        """returns True, if type represents instantiation of
        `boost::shared_ptr` or `std::shared_ptr`, False otherwise"""
        type_ = type_traits.remove_alias(type_)
        type_ = type_traits.remove_cv(type_)
        type_ = type_traits.remove_declarated(type_)
        if not isinstance(type_,
                          (class_declaration.class_declaration_t,
                           class_declaration.class_t)):
            return False
        if not (
                traits_impl_details.impl_details.is_defined_in_xxx(
                    'boost', type_) or
                traits_impl_details.impl_details.is_defined_in_xxx(
                    'std', type_)):
            return False
        return type_.decl_string.startswith('::boost::shared_ptr<') or \
            type_.decl_string.startswith('::std::shared_ptr<')