def __declarated_types(self, namespaces): def get_from_type(cpptype): if not cpptype: return [] elif isinstance(cpptype, pygccxml.declarations.fundamental_t): return [] 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 else: 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.type)) return types
def __declarated_types(self, namespaces): def get_from_type(cpptype): if not cpptype: return [] elif isinstance( cpptype, pygccxml.declarations.fundamental_t ): return [] 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 else: 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.type ) ) return types
def subtypes(cls): """Return subclasses of 'cls'.""" types = [cls] if not cls: return types for subclass in cls.__subclasses__(): types.extend(subtypes(subclass)) return types
def _unpack_lists(state, arg): """Extract inner types of Lists and Tuples. Pops arg count items from the stack, concatenates their inner types into 1 list, and returns that list. Example: if stack[-arg:] == [[i1, i2], [i3]], the output is [i1, i2, i3] """ types = [] for i in range(arg, 0, -1): type_constraint = state.stack[-i] if isinstance(type_constraint, typehints.IndexableTypeConstraint): types.extend(type_constraint._inner_types()) else: logging.debug('Unhandled type_constraint: %r', type_constraint) types.append(typehints.Any) state.stack[-arg:] = [] return types
def get_from_type(cpptype): if not cpptype: return [] elif isinstance(cpptype, pygccxml.declarations.fundamental_t): return [] 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 else: assert isinstance(cpptype, pygccxml.declarations.unknown_t) return []
def get_from_type(cpptype): if not cpptype: return [] elif isinstance(cpptype, pygccxml.declarations.fundamental_t): return [] 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 else: assert isinstance(cpptype, (pygccxml.declarations.unknown_t, pygccxml.declarations.ellipsis_t)) return []