def from_cindex(cls, cursor: Cursor, namespace: Text): """Create a Type object from cindex cursor.""" fq_name = '::'.join([namespace, cursor.spelling]) is_pure_virtual = cursor.is_pure_virtual_method() arguments = [Type.from_cindex(x) for x in cursor.type.argument_types()] if cursor.type == TypeKind.VOID: return_type = [Type.void()] else: return_type = [Type.from_cindex(cursor.type.get_result())] return cls(fq_name, is_pure_virtual, arguments, return_type)
def _traverse_function(self, cursor: Cursor, namespaces: List[Text]) -> ast_pb2.Decl: """Traverses a function in clang AST and registers its declaration. This method modifies self._func_decl_map. Args: cursor: The cursor which is pointing to the head of a function in clang AST. namespaces: The namespace in which the function is in. Returns: The function declaration. This is needed so that the class decl which defines this function can add it as a member. """ func_decl = ast_pb2.Decl() func_decl.decltype = ast_pb2.Decl.Type.FUNC func_decl.func.is_pure_virtual = cursor.is_pure_virtual_method() namespace = self._gen_namespace_str(namespaces) fully_qualified_name = '::'.join([namespace, cursor.spelling]) self._func_decl_map[fully_qualified_name] = func_decl return func_decl