Class: FFI::Clang::File

Inherits:
Pointer
  • Object
show all
Defined in:
lib/ffi/clang/file.rb

Overview

Represents a file in a translation unit.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pointer, translation_unit) ⇒ File

Initialize a file with a pointer and translation unit.



19
20
21
22
23
24
25
26
# File 'lib/ffi/clang/file.rb', line 19

def initialize(pointer, translation_unit)
  super pointer
  @translation_unit = translation_unit
  
  pointer = MemoryPointer.new(Lib::CXFileUniqueID)
  Lib.get_file_unique_id(self, pointer)
  @unique_id = Lib::CXFileUniqueID.new(pointer)
end

Instance Attribute Details

#The translation unit this file belongs to.(translationunitthisfilebelongsto.) ⇒ Object (readonly)



14
# File 'lib/ffi/clang/file.rb', line 14

attr_reader :translation_unit

#translation_unitObject (readonly)

Returns the value of attribute translation_unit.



14
15
16
# File 'lib/ffi/clang/file.rb', line 14

def translation_unit
  @translation_unit
end

Instance Method Details

#deviceObject

Get the device ID of the file.



54
55
56
# File 'lib/ffi/clang/file.rb', line 54

def device
  @unique_id[:device]
end

#include_guarded?Boolean

Check if the file has include guards.

Returns:

  • (Boolean)


48
49
50
# File 'lib/ffi/clang/file.rb', line 48

def include_guarded?
  Lib.is_file_multiple_include_guarded(@translation_unit, self) != 0
end

#inodeObject

Get the inode number of the file.



60
61
62
# File 'lib/ffi/clang/file.rb', line 60

def inode
  @unique_id[:inode]
end

#modificationObject

Get the modification time from the unique ID.



66
67
68
# File 'lib/ffi/clang/file.rb', line 66

def modification
  Time.at(@unique_id[:modification])
end

#nameObject

Get the file name.



36
37
38
# File 'lib/ffi/clang/file.rb', line 36

def name
  Lib.extract_string Lib.get_file_name(self)
end

#timeObject

Get the file modification time.



42
43
44
# File 'lib/ffi/clang/file.rb', line 42

def time
  Time.at(Lib.get_file_time(self))
end

#to_sObject

Get the file name as a string.



30
31
32
# File 'lib/ffi/clang/file.rb', line 30

def to_s
  name
end