Class: FFI::Clang::Diagnostic

Inherits:
AutoPointer
  • Object
show all
Defined in:
lib/ffi/clang/diagnostic.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(translation_unit, pointer) ⇒ Diagnostic

Returns a new instance of Diagnostic.



21
22
23
24
25
# File 'lib/ffi/clang/diagnostic.rb', line 21

def initialize(translation_unit, pointer)
	super pointer

	@translation_unit = translation_unit
end

Class Method Details

.default_display_optsObject



17
18
19
# File 'lib/ffi/clang/diagnostic.rb', line 17

def self.default_display_opts
	Lib.opts_from(Lib::DiagnosticDisplayOptions, Lib.default_diagnostic_display_options)
end

.release(pointer) ⇒ Object



27
28
29
# File 'lib/ffi/clang/diagnostic.rb', line 27

def self.release(pointer)
	Lib.dispose_diagnostic(pointer)
end

Instance Method Details

#categoryObject



82
83
84
# File 'lib/ffi/clang/diagnostic.rb', line 82

def category
	Lib.extract_string Lib.get_diagnostic_category_text(self)
end

#category_idObject



86
87
88
# File 'lib/ffi/clang/diagnostic.rb', line 86

def category_id
	Lib.get_diagnostic_category(self)
end

#childrenObject



64
65
66
67
68
69
70
# File 'lib/ffi/clang/diagnostic.rb', line 64

def children
	diagnostic_set = Lib.get_child_diagnostics(self)
	num_diagnostics = Lib.get_num_diagnostics_in_set(diagnostic_set)
	num_diagnostics.times.map { |i|
		Diagnostic.new(@translation_unit, Lib.get_diagnostic_in_set(diagnostic_set, i))
	}
end

#disable_optionObject



76
77
78
79
80
# File 'lib/ffi/clang/diagnostic.rb', line 76

def disable_option
	ptr = MemoryPointer.new Lib::CXString
	Lib.get_diagnostic_option(self, ptr)
	Lib.extract_string ptr
end

#enable_optionObject



72
73
74
# File 'lib/ffi/clang/diagnostic.rb', line 72

def enable_option
	Lib.extract_string Lib.get_diagnostic_option(self, nil)
end

#fixitsObject



49
50
51
52
53
54
55
56
# File 'lib/ffi/clang/diagnostic.rb', line 49

def fixits
	n = Lib.get_diagnostic_num_fix_its(self)
	n.times.map { |i|
	ptr = MemoryPointer.new Lib::CXSourceRange
		replace_text = Lib.extract_string(Lib.get_diagnostic_fix_it(self, i, ptr))
		{text: replace_text, range: SourceRange.new(ptr)}
	}
end

#format(opts = {}) ⇒ Object



31
32
33
34
# File 'lib/ffi/clang/diagnostic.rb', line 31

def format(opts = {})
	cxstring = Lib.format_diagnostic(self, display_opts(opts))
	Lib.extract_string cxstring
end

#inspectObject



90
91
92
# File 'lib/ffi/clang/diagnostic.rb', line 90

def inspect
	"#{self.location}: #{self.format}"
end

#locationObject



44
45
46
47
# File 'lib/ffi/clang/diagnostic.rb', line 44

def location
	sl = Lib.get_diagnostic_location(self)
	ExpansionLocation.new sl
end

#rangesObject



58
59
60
61
62
# File 'lib/ffi/clang/diagnostic.rb', line 58

def ranges
	n = Lib.get_diagnostic_num_ranges(self)
	
	n.times.map {|i| SourceRange.new Lib.get_diagnostic_range(self, i)}
end

#severityObject



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

def severity
	Lib.get_diagnostic_severity self
end

#spellingObject



40
41
42
# File 'lib/ffi/clang/diagnostic.rb', line 40

def spelling
	Lib.get_string Lib.get_diagnostic_spelling(self)
end