Class: FFI::Clang::Types::Pointer

Inherits:
Type
  • Object
show all
Defined in:
lib/ffi/clang/types/pointer.rb

Instance Attribute Summary

Attributes inherited from Type

#translation_unit, #type

Instance Method Summary collapse

Methods inherited from Type

#==, #alignof, #const_qualified?, create, #declaration, #initialize, #kind, #kind_spelling, #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_typeObject



13
14
15
16
17
18
19
# File 'lib/ffi/clang/types/pointer.rb', line 13

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

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ffi/clang/types/pointer.rb', line 21

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

#function?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/ffi/clang/types/pointer.rb', line 9

def function?
	self.pointee.is_a?(Types::Function)
end

#pointeeObject



5
6
7
# File 'lib/ffi/clang/types/pointer.rb', line 5

def pointee
	Type.create Lib.get_pointee_type(@type), @translation_unit
end