Esempio n. 1
0
 def POINTER(self, _cursor_type):
     """
     Handles POINTER types.
     """
     #
     # FIXME catch InvalidDefinitionError and return a void *
     #
     #
     # we shortcut to canonical typedefs and to pointee canonical defs
     comment = None
     _type = _cursor_type.get_pointee().get_canonical()
     _p_type_name = self.get_unique_name(_type)
     # get pointer size
     size = _cursor_type.get_size()  # not size of pointee
     align = _cursor_type.get_align()
     log.debug("POINTER: size:%d align:%d typ:%s" %
               (size, align, _type.kind))
     if self.is_fundamental_type(_type):
         p_type = self.parse_cursor_type(_type)
     elif self.is_pointer_type(_type) or self.is_array_type(_type):
         p_type = self.parse_cursor_type(_type)
     elif _type.kind == TypeKind.FUNCTIONPROTO:
         p_type = self.parse_cursor_type(_type)
     elif _type.kind == TypeKind.FUNCTIONNOPROTO:
         p_type = self.parse_cursor_type(_type)
     else:  #elif _type.kind == TypeKind.RECORD:
         # check registration
         decl = _type.get_declaration()
         decl_name = self.get_unique_name(decl)
         # Type is already defined OR will be defined later.
         if self.is_registered(decl_name):
             p_type = self.get_registered(decl_name)
         else:  # forward declaration, without looping
             log.debug('POINTER: %s type was not previously declared' %
                       (decl_name))
             try:
                 p_type = self.parse_cursor(decl)
             except InvalidDefinitionError as e:
                 # no declaration in source file. Fake a void *
                 p_type = typedesc.FundamentalType('None', 1, 1)
                 comment = "InvalidDefinitionError"
     log.debug("POINTER: pointee type_name:'%s'" % (_p_type_name))
     # return the pointer
     obj = typedesc.PointerType(p_type, size, align)
     obj.location = p_type.location
     if comment is not None:
         obj.comment = comment
     return obj
Esempio n. 2
0
 def PointerType(self, attrs):
     typ = attrs["type"]
     size = attrs["size"]
     align = attrs["align"]
     return typedesc.PointerType(typ, size, align)