def FUNCTIONPROTO(self, _cursor_type): """Handles function prototype.""" # id, returns, attributes returns = _cursor_type.get_result() # if self.is_fundamental_type(returns): returns = self.parse_cursor_type(returns) attributes = [] obj = typedesc.FunctionType(returns, attributes) for i, _attr_type in enumerate(_cursor_type.argument_types()): arg = typedesc.Argument("a%d" % (i), self.parse_cursor_type(_attr_type)) obj.add_argument(arg) self.set_location(obj, None) return obj
def PARM_DECL(self, cursor): """Handles parameter declarations.""" # try and get the type. If unexposed, The canonical type will work. _type = cursor.type _name = cursor.spelling if (self.is_array_type(_type) or self.is_fundamental_type(_type) or self.is_pointer_type(_type) or self.is_unexposed_type(_type)): _argtype = self.parse_cursor_type(_type) else: # FIXME: Which UT/case ? size_t in stdio.h for example. _argtype_decl = _type.get_declaration() _argtype_name = self.get_unique_name(_argtype_decl) if not self.is_registered(_argtype_name): log.info('This param type is not declared: %s', _argtype_name) _argtype = self.parse_cursor_type(_type) else: _argtype = self.get_registered(_argtype_name) obj = typedesc.Argument(_name, _argtype) self.set_location(obj, cursor) self.set_comment(obj, cursor) return obj
def PARM_DECL(self, cursor): """Handles parameter declarations.""" # try and get the type. If unexposed, The canonical type will work. _type = cursor.type _name = cursor.spelling if (self.is_array_type(_type) or self.is_fundamental_type(_type) or self.is_pointer_type(_type) or self.is_unexposed_type(_type)): _argtype = self.parse_cursor_type(_type) else: # FIXME which UT/case ? _argtype_decl = _type.get_declaration() _argtype_name = self.get_unique_name(_argtype_decl) if not self.is_registered(_argtype_name): log.error('this param type is not declared') #code.interact(local=locals()) _argtype = self.parse_cursor_type(_type) else: _argtype = self.get_registered(_argtype_name) obj = typedesc.Argument(_name, _argtype) self.set_location(obj, cursor) self.set_comment(obj, cursor) return obj
def Argument(self, attrs): parent = self.context[-1] if parent is not None: parent.add_argument( typedesc.Argument(attrs["type"], attrs.get("name")))