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.



33
34
35
36
37
# File 'lib/ffi/clang/diagnostic.rb', line 33

def initialize(translation_unit, pointer)
	super pointer

	@translation_unit = translation_unit
end

Class Method Details

.default_display_optsObject



29
30
31
# File 'lib/ffi/clang/diagnostic.rb', line 29

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

.release(pointer) ⇒ Object



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

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

Instance Method Details

#categoryObject



94
95
96
# File 'lib/ffi/clang/diagnostic.rb', line 94

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

#category_idObject



98
99
100
# File 'lib/ffi/clang/diagnostic.rb', line 98

def category_id
	Lib.get_diagnostic_category(self)
end

#childrenObject



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

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



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

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

#enable_optionObject



84
85
86
# File 'lib/ffi/clang/diagnostic.rb', line 84

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

#fixitsObject



61
62
63
64
65
66
67
68
# File 'lib/ffi/clang/diagnostic.rb', line 61

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



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

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

#inspectObject



102
103
104
# File 'lib/ffi/clang/diagnostic.rb', line 102

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

#locationObject



56
57
58
59
# File 'lib/ffi/clang/diagnostic.rb', line 56

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

#rangesObject



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

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

#severityObject



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

def severity
	Lib.get_diagnostic_severity self
end

#spellingObject



52
53
54
# File 'lib/ffi/clang/diagnostic.rb', line 52

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