Class: FFI::Clang::Types::Pointer
- Defined in:
- lib/ffi/clang/types/pointer.rb
Overview
Represents a pointer type. This includes regular pointers, block pointers, Objective-C object pointers, and member pointers.
Instance Attribute Summary
Attributes inherited from Type
Instance Method Summary collapse
-
#class_type ⇒ Object
Get the class type for member pointers.
-
#forward_declaration? ⇒ Boolean
Check if this pointer references a forward declaration.
-
#function? ⇒ Boolean
Check if this is a function pointer.
-
#pointee ⇒ Object
Get the type that this pointer points to.
Methods inherited from Type
#==, #alignof, #canonical, #const_qualified?, create, #declaration, #initialize, #kind, #kind_spelling, #non_reference_type, #pod?, #ref_qualifier, #restrict_qualified?, #sizeof, #spelling, #to_s, #volatile_qualified?
Constructor Details
This class inherits a constructor from FFI::Clang::Types::Type
Instance Method Details
#class_type ⇒ Object
Get the class type for member pointers.
27 28 29 30 31 32 33 |
# File 'lib/ffi/clang/types/pointer.rb', line 27 def class_type if self.kind == :type_member_pointer Type.create Lib.type_get_class_type(@type), @translation_unit else nil end end |
#forward_declaration? ⇒ Boolean
Check if this pointer references a forward declaration.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ffi/clang/types/pointer.rb', line 37 def forward_declaration? # Is this a pointer to a record (struct or union) that referenced # a forward declaration at the point of its inclusion in the translation unit? if !self.function? && self.pointee.is_a?(Types::Elaborated) && self.pointee.canonical.is_a?(Types::Record) # Get the universal symbol reference usr = self.pointee.canonical.declaration.usr # Now does that same usr occur earlier in the file? first_declaration, _ = self.translation_unit.cursor.find do |child, parent| child.usr == usr end # NOTE - Maybe should also check that the line number of # is less than the line number of the declaration this type references first_declaration.forward_declaration? end end |