Ejemplo n.º 1
0
 def __repr__ (self):
     
     virtual  = "virtual" if self.is_virtual() else ""
     constant = "const"   if self.is_constant() else ""
     params = ""
     
     for param in self.get_type().get_param_types():
         type = Type.from_pointer (param.as_pointer())
         
         if len(params) > 0:
             params = params + ", " + type.get_name()
         else: params = type.get_name()
         
     
     prototype = ("%s %s %s (%s) %s" %
                  (virtual,
                   self.get_type().get_return_type().get_name(),
                   self.get_name(),
                   params,
                   constant))
     
     prototype = prototype.strip()
     
     return ("<%s.%s object at %#x with a function object instance at %#x " \
             "implementing the prototype %s>" %
             (self.__module__,
              self.__class__.__name__,
              id(self),
              self._ptr,
              prototype))
Ejemplo n.º 2
0
 def __repr__ (self):
     
     params = ""
     
     for param in self.get_param_types():
         type = Type.from_pointer (param.as_pointer())
         
         if len(params) > 0:
             params = params + ", " + type.get_name()
         else: params = type.get_name()
     
     if (len(params) > 0):
         params = "requiring the parameters (%s)" % params
     else:
         params = "requiring no parameters"
     
     return ("<%s.%s object at %#x with a constructor object instance at " \
             "%#x %s>" %
             (self.__module__,
              self.__class__.__name__,
              id(self),
              self._ptr,
              params))
Ejemplo n.º 3
0
def check_param_types (types, params):
    # check param size
    if params.get_size() <> types.get_size():
        raise ValueError ("Parameter list must have '%d' matching values, " \
                          "'%d' was given" %
                          (types.get_size(), params.get_size()))
    
    # check param types
    for i in range(0, len(params)):
        
        # get types
        param_type = params[i].get_type()
        expected_type = Type.from_pointer (types[i].get_pointer().get_raw())
        
        # get real pointer type from generic pointer
        if param_type.get_atom() == Type.type_pointer():
            param_type = params[i].get_pointer().get_type()
        
        
        # make sure we have the same type atom
        if param_type.get_atom() != expected_type.get_atom():
            raise TypeError ("Parameter '%d' does not match the appropriate " \
                             "type. Expected '%s', got '%s'" %
                             (i + 1,
                              expected_type.get_name(),
                              param_type.get_name()))
        
        
        # reference parameter types must be a pointer
        if expected_type.is_reference() and not param_type.is_pointer():
            raise TypeError ("Parameter '%d' is a reference type '%s' but " \
                             "the expected type is not a pointer, " \
                             "instead '%s' was given" %
                             (i + 1,
                              expected_type.get_name(),
                              param_type.get_name()))
Ejemplo n.º 4
0
 def get_param_type (self, index):
     type = _lib.myelin_function_type_get_param_type (self, index)
     return Type.from_pointer (type)
Ejemplo n.º 5
0
 def get_return_type (self):
     type = _lib.myelin_function_type_get_return_type (self)
     return Type.from_pointer (type)
Ejemplo n.º 6
0
 def get_param_type (self, index):
     type = _lib.myelin_constructor_get_param_type (self, index)
     return Type.from_pointer (type)
Ejemplo n.º 7
0
 def get_output_type(self):
     type = _lib.myelin_converter_get_output_type(self)
     return Type.from_pointer(type)
Ejemplo n.º 8
0
 def get_type (self):
     type = _lib.myelin_value_get_type (self)
     return Type.from_pointer (type)
Ejemplo n.º 9
0
 def get_type (self):
     return Type.from_pointer (_lib.myelin_class_get_type (self))