Class: CF::Base
- Inherits:
- 
      Object
      
        - Object
- CF::Base
 
- Defined in:
- lib/corefoundation/base.rb
Overview
The base class for all of the wrapper classes in CF module.
Constant Summary collapse
- @@type_map =
- {} 
Instance Attribute Summary collapse
- 
  
    
      #ptr  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute ptr. 
Class Method Summary collapse
- 
  
    
      .check_cftype(cftyperef)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Raises an exception if the argument does not inherit from CF::Base. 
- .finalize(pointer) ⇒ Object
- 
  
    
      .typecast(cftyperef)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Wraps an FFI::Pointer with the appropriate subclass of CF::Base If the pointer is not a CFTypeRef behaviour is undefined. 
Instance Method Summary collapse
- 
  
    
      #eql?(other)  ⇒ Boolean 
    
    
      (also: #==)
    
  
  
  
  
  
  
  
  
  
    eql? (and ==) are implemented using CFEqual. 
- 
  
    
      #equals?(other)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    equals? is defined as returning true if the wrapped pointer is the same. 
- 
  
    
      #hash  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    Uses CFHash to return a hash code. 
- 
  
    
      #initialize(pointer)  ⇒ Base 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Base. 
- 
  
    
      #null?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Whether the instance is the CFNull singleton. 
- 
  
    
      #to_cf  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    This is a no-op on CF::Base and its subclasses. 
- #to_ruby ⇒ Object
Methods included from Memory
#inspect, #release, #retain, #to_ptr
Methods included from Register
Constructor Details
Instance Attribute Details
#ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
| 13 14 15 | # File 'lib/corefoundation/base.rb', line 13 def ptr @ptr end | 
Class Method Details
.check_cftype(cftyperef) ⇒ Object
Raises an exception if the argument does not inherit from CF::Base
| 18 19 20 | # File 'lib/corefoundation/base.rb', line 18 def self.check_cftype(cftyperef) raise TypeError, "#{cftyperef.inspect} is not a cftype" unless cftyperef.is_a?(CF::Base) end | 
.finalize(pointer) ⇒ Object
| 40 41 42 | # File 'lib/corefoundation/base.rb', line 40 def self.finalize(pointer) proc { CF.release(pointer) unless pointer.address.zero? } end | 
.typecast(cftyperef) ⇒ Object
Wraps an FFI::Pointer with the appropriate subclass of CF::Base If the pointer is not a CFTypeRef behaviour is undefined
| 27 28 29 30 | # File 'lib/corefoundation/base.rb', line 27 def self.typecast(cftyperef) klass = klass_from_cf_type cftyperef klass.new(cftyperef) end | 
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
eql? (and ==) are implemented using CFEqual
| 59 60 61 62 63 64 65 | # File 'lib/corefoundation/base.rb', line 59 def eql?(other) if other.is_a?(CF::Base) CF.CFEqual(self, other) != 0 else false end end | 
#equals?(other) ⇒ Boolean
equals? is defined as returning true if the wrapped pointer is the same
| 70 71 72 73 74 75 76 | # File 'lib/corefoundation/base.rb', line 70 def equals?(other) if other.is_a?(CF::Base) @ptr.address == other.to_ptr.address else false end end | 
#hash ⇒ Integer
Uses CFHash to return a hash code
| 54 55 56 | # File 'lib/corefoundation/base.rb', line 54 def hash CF.CFHash(self) end | 
#null? ⇒ Boolean
Whether the instance is the CFNull singleton
| 47 48 49 | # File 'lib/corefoundation/base.rb', line 47 def null? equals?(CF::NULL) end | 
#to_cf ⇒ Object
This is a no-op on CF::Base and its subclasses. Always returns self.
| 85 86 87 | # File 'lib/corefoundation/base.rb', line 85 def to_cf self end | 
#to_ruby ⇒ Object
| 78 79 80 | # File 'lib/corefoundation/base.rb', line 78 def to_ruby raise CF::Exceptions::MethodNotImplemented, "#{self.class} should implement the to_ruby method." end |