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
#==, #address_space, #alignof, #canonical, #const_qualified?, #copy_assignable?, #copyable?, create, #declaration, #fqn_elaborated, #fqn_impl, #fqn_pointer, #fqn_record, #fqn_template_args, #fully_qualified_name, #initialize, #intrinsic_type, #kind, #kind_spelling, #modified_type, #non_reference_type, #nullability, #num_template_arguments, #parse_template_args_from_spelling, #pod?, #pretty_printed, #ref_qualifier, #reference?, #restrict_qualified?, #sizeof, #spelling, #template_argument_type, #to_s, #transparent_tag_typedef?, #typedef_name, #unqualified_type, #value_type, #visit_base_classes, #visit_fields, #visit_methods, #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 55 56 57 58 59 60 61 62 |
# File 'lib/ffi/clang/types/pointer.rb', line 37 def forward_declaration? pointee = self.pointee return nil if self.function? # Resolve to a Record type, handling both elaborated and direct record types. # Newer clang versions (22+) may return :type_record directly instead of # wrapping in :type_elaborated. record_type = if pointee.is_a?(Types::Elaborated) && pointee.canonical.is_a?(Types::Record) pointee.canonical elsif pointee.is_a?(Types::Record) pointee end return nil unless record_type # Get the universal symbol reference usr = record_type.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 |