clangc 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/clangc/_clangc_functions.c +303 -0
- data/ext/clangc/_clangc_functions.h +51 -0
- data/ext/clangc/clangc.c +376 -0
- data/ext/clangc/class_CodeCompleteResults.c +186 -0
- data/ext/clangc/class_CodeCompleteResults.h +51 -0
- data/ext/clangc/class_CompletionResult.c +98 -0
- data/ext/clangc/class_CompletionResult.h +36 -0
- data/ext/clangc/class_CompletionString.c +231 -0
- data/ext/clangc/class_CompletionString.h +57 -0
- data/ext/clangc/class_Cursor.c +1677 -0
- data/ext/clangc/class_Cursor.h +259 -0
- data/ext/clangc/class_CursorSet.c +109 -0
- data/ext/clangc/class_CursorSet.h +39 -0
- data/ext/clangc/class_Diagnostic.c +322 -0
- data/ext/clangc/class_Diagnostic.h +66 -0
- data/ext/clangc/class_File.c +145 -0
- data/ext/clangc/class_File.h +45 -0
- data/ext/clangc/class_Index.c +461 -0
- data/ext/clangc/class_Index.h +58 -0
- data/ext/clangc/class_Module.c +181 -0
- data/ext/clangc/class_Module.h +51 -0
- data/ext/clangc/class_OverriddenCursor.c +51 -0
- data/ext/clangc/class_OverriddenCursor.h +31 -0
- data/ext/clangc/class_SourceLocation.c +197 -0
- data/ext/clangc/class_SourceLocation.h +45 -0
- data/ext/clangc/class_SourceRange.c +123 -0
- data/ext/clangc/class_SourceRange.h +42 -0
- data/ext/clangc/class_TranslationUnit.c +457 -0
- data/ext/clangc/class_TranslationUnit.h +63 -0
- data/ext/clangc/class_Type.c +564 -0
- data/ext/clangc/class_Type.h +108 -0
- data/ext/clangc/constants.c +660 -0
- data/ext/clangc/constants.h +21 -0
- data/ext/clangc/extconf.rb +34 -0
- data/ext/clangc/macros.h +230 -0
- data/lib/clangc.rb +397 -0
- metadata +95 -0
@@ -0,0 +1,259 @@
|
|
1
|
+
/*
|
2
|
+
* ruby-clangc ruby bindings for the C interface of Clang
|
3
|
+
* Copyright (C) 2015-2016 Cedric Le Moigne cedlemo <cedlemo@gmx.com>
|
4
|
+
*
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
8
|
+
* (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
* GNU General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU General Public License
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
*/
|
18
|
+
#ifndef CURSOR_H
|
19
|
+
#define CURSOR_H
|
20
|
+
#include <ruby/ruby.h>
|
21
|
+
#include "clang-c/Index.h"
|
22
|
+
typedef struct Cursor_t
|
23
|
+
{
|
24
|
+
CXCursor data;
|
25
|
+
VALUE parent;
|
26
|
+
} Cursor_t;
|
27
|
+
|
28
|
+
VALUE
|
29
|
+
c_Cursor_struct_alloc(VALUE);
|
30
|
+
|
31
|
+
VALUE
|
32
|
+
c_Cursor_is_null(VALUE);
|
33
|
+
|
34
|
+
VALUE
|
35
|
+
c_Cursor_is_equal(VALUE, VALUE);
|
36
|
+
|
37
|
+
VALUE
|
38
|
+
c_Cursor_get_hash(VALUE);
|
39
|
+
|
40
|
+
VALUE
|
41
|
+
c_Cursor_get_kind(VALUE);
|
42
|
+
|
43
|
+
VALUE
|
44
|
+
c_Cursor_get_linkage(VALUE);
|
45
|
+
|
46
|
+
VALUE
|
47
|
+
c_Cursor_get_availability(VALUE);
|
48
|
+
|
49
|
+
VALUE
|
50
|
+
c_Cursor_get_language(VALUE);
|
51
|
+
|
52
|
+
VALUE
|
53
|
+
c_Cursor_get_type(VALUE);
|
54
|
+
|
55
|
+
VALUE
|
56
|
+
c_Cursor_get_semantic_parent(VALUE);
|
57
|
+
|
58
|
+
VALUE
|
59
|
+
c_Cursor_get_lexical_parent(VALUE);
|
60
|
+
|
61
|
+
VALUE
|
62
|
+
c_Cursor_get_source_location(VALUE);
|
63
|
+
|
64
|
+
VALUE
|
65
|
+
c_Cursor_get_extent(VALUE);
|
66
|
+
|
67
|
+
VALUE
|
68
|
+
c_Cursor_get_spelling(VALUE);
|
69
|
+
|
70
|
+
VALUE
|
71
|
+
c_Cursor_get_typedef_decl_underlying_type(VALUE);
|
72
|
+
|
73
|
+
VALUE
|
74
|
+
c_Cursor_get_included_file(VALUE);
|
75
|
+
|
76
|
+
VALUE
|
77
|
+
c_Cursor_is_declaration(VALUE);
|
78
|
+
|
79
|
+
VALUE
|
80
|
+
c_Cursor_is_reference(VALUE);
|
81
|
+
|
82
|
+
VALUE
|
83
|
+
c_Cursor_is_expression(VALUE);
|
84
|
+
|
85
|
+
VALUE
|
86
|
+
c_Cursor_is_statement(VALUE);
|
87
|
+
|
88
|
+
VALUE
|
89
|
+
c_Cursor_is_attribute(VALUE);
|
90
|
+
|
91
|
+
VALUE
|
92
|
+
c_Cursor_is_invalid(VALUE);
|
93
|
+
|
94
|
+
VALUE
|
95
|
+
c_Cursor_is_translation_unit(VALUE);
|
96
|
+
|
97
|
+
VALUE
|
98
|
+
c_Cursor_is_preprocessing(VALUE);
|
99
|
+
|
100
|
+
VALUE
|
101
|
+
c_Cursor_get_enum_decl_integer_type(VALUE);
|
102
|
+
|
103
|
+
VALUE
|
104
|
+
c_Cursor_get_enum_const_decl_value(VALUE);
|
105
|
+
|
106
|
+
VALUE
|
107
|
+
c_Cursor_get_enum_const_decl_unsigned_value(VALUE);
|
108
|
+
|
109
|
+
VALUE
|
110
|
+
c_Cursor_get_field_decl_bit_width(VALUE);
|
111
|
+
|
112
|
+
VALUE
|
113
|
+
c_Cursor_get_num_arguments(VALUE);
|
114
|
+
|
115
|
+
VALUE
|
116
|
+
c_Cursor_get_argument(VALUE, VALUE);
|
117
|
+
|
118
|
+
#if (CINDEX_VERSION_MINOR >= 29)
|
119
|
+
VALUE
|
120
|
+
c_Cursor_get_num_template_arguments(VALUE);
|
121
|
+
#endif
|
122
|
+
|
123
|
+
VALUE
|
124
|
+
c_Cursor_get_decl_obj_c_type_encoding(VALUE);
|
125
|
+
|
126
|
+
VALUE
|
127
|
+
c_Cursor_get_result_type(VALUE);
|
128
|
+
|
129
|
+
#if (CINDEX_VERSION_MINOR >= 30)
|
130
|
+
VALUE
|
131
|
+
c_Cursor_get_offset_of_field(VALUE);
|
132
|
+
|
133
|
+
VALUE
|
134
|
+
c_Cursor_is_anonymous(VALUE);
|
135
|
+
#endif
|
136
|
+
|
137
|
+
VALUE
|
138
|
+
c_Cursor_is_bit_field(VALUE);
|
139
|
+
|
140
|
+
VALUE
|
141
|
+
c_Cursor_is_virtual_base(VALUE);
|
142
|
+
|
143
|
+
VALUE
|
144
|
+
c_Cursor_get_cxx_access_specifier(VALUE);
|
145
|
+
|
146
|
+
#if (CINDEX_VERSION_MINOR >= 29)
|
147
|
+
VALUE
|
148
|
+
c_Cursor_get_storage_class(VALUE);
|
149
|
+
#endif
|
150
|
+
|
151
|
+
VALUE
|
152
|
+
c_Cursor_get_num_overloaded_decls(VALUE);
|
153
|
+
|
154
|
+
VALUE
|
155
|
+
c_Cursor_get_overloaded_decl(VALUE, VALUE);
|
156
|
+
|
157
|
+
VALUE
|
158
|
+
c_Cursor_get_ib_outlet_collection_type(VALUE);
|
159
|
+
|
160
|
+
VALUE
|
161
|
+
c_Cursor_get_usr(VALUE);
|
162
|
+
|
163
|
+
VALUE
|
164
|
+
c_Cursor_get_display_name(VALUE);
|
165
|
+
|
166
|
+
VALUE
|
167
|
+
c_Cursor_get_referenced(VALUE);
|
168
|
+
|
169
|
+
VALUE
|
170
|
+
c_Cursor_get_definition(VALUE);
|
171
|
+
|
172
|
+
VALUE
|
173
|
+
c_Cursor_is_definition(VALUE);
|
174
|
+
|
175
|
+
VALUE
|
176
|
+
c_Cursor_get_canonical_cursor(VALUE);
|
177
|
+
|
178
|
+
VALUE
|
179
|
+
c_Cursor_get_obj_c_selector_index(VALUE);
|
180
|
+
|
181
|
+
VALUE
|
182
|
+
c_Cursor_is_dynamic_call(VALUE);
|
183
|
+
|
184
|
+
VALUE
|
185
|
+
c_Cursor_get_receiver_type(VALUE);
|
186
|
+
|
187
|
+
VALUE
|
188
|
+
c_Cursor_get_obj_c_decl_qualifiers(VALUE);
|
189
|
+
|
190
|
+
VALUE
|
191
|
+
c_Cursor_is_obj_c_optional(VALUE);
|
192
|
+
|
193
|
+
VALUE
|
194
|
+
c_Cursor_is_variadic(VALUE);
|
195
|
+
|
196
|
+
VALUE
|
197
|
+
c_Cursor_get_comment_range(VALUE);
|
198
|
+
|
199
|
+
VALUE
|
200
|
+
c_Cursor_get_raw_comment_text(VALUE);
|
201
|
+
|
202
|
+
VALUE
|
203
|
+
c_Cursor_get_brief_comment_text(VALUE);
|
204
|
+
|
205
|
+
#if (CINDEX_VERSION_MINOR >= 29)
|
206
|
+
VALUE
|
207
|
+
c_Cursor_get_mangling(VALUE);
|
208
|
+
#endif
|
209
|
+
|
210
|
+
VALUE
|
211
|
+
c_Cursor_cxx_method_is_pure_virtual(VALUE);
|
212
|
+
|
213
|
+
VALUE
|
214
|
+
c_Cursor_cxx_method_is_static(VALUE);
|
215
|
+
|
216
|
+
VALUE
|
217
|
+
c_Cursor_cxx_method_is_virtual(VALUE);
|
218
|
+
|
219
|
+
VALUE
|
220
|
+
c_Cursor_cxx_method_is_const(VALUE);
|
221
|
+
|
222
|
+
VALUE
|
223
|
+
c_Cursor_get_template_cursor_kind(VALUE);
|
224
|
+
|
225
|
+
VALUE
|
226
|
+
c_Cursor_get_specialized_cursor_template(VALUE);
|
227
|
+
|
228
|
+
VALUE
|
229
|
+
c_Cursor_get_completion_string(VALUE);
|
230
|
+
|
231
|
+
#if (CINDEX_VERSION_MINOR >= 29)
|
232
|
+
VALUE
|
233
|
+
c_Cursor_get_template_argument_kind(VALUE, VALUE);
|
234
|
+
|
235
|
+
VALUE
|
236
|
+
c_Cursor_get_template_argument_type(VALUE, VALUE);
|
237
|
+
|
238
|
+
VALUE
|
239
|
+
c_Cursor_get_template_argument_value(VALUE, VALUE);
|
240
|
+
|
241
|
+
VALUE
|
242
|
+
c_Cursor_get_template_argument_unsigned_value(VALUE, VALUE);
|
243
|
+
#endif
|
244
|
+
|
245
|
+
VALUE
|
246
|
+
c_Cursor_get_obj_c_property_attributes(VALUE, VALUE);
|
247
|
+
|
248
|
+
VALUE
|
249
|
+
c_Cursor_get_overridden_cursors(VALUE);
|
250
|
+
|
251
|
+
VALUE
|
252
|
+
c_Cursor_get_module(VALUE);
|
253
|
+
|
254
|
+
VALUE
|
255
|
+
c_Cursor_get_spelling_name_range(VALUE, VALUE, VALUE);
|
256
|
+
|
257
|
+
VALUE
|
258
|
+
c_Cursor_get_reference_name_range(VALUE, VALUE, VALUE);
|
259
|
+
#endif // CURSOR_H
|
@@ -0,0 +1,109 @@
|
|
1
|
+
/*
|
2
|
+
* ruby-clangc ruby bindings for the C interface of Clang
|
3
|
+
* Copyright (C) 2015-2016 Cedric Le Moigne cedlemo <cedlemo@gmx.com>
|
4
|
+
*
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
8
|
+
* (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
* GNU General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU General Public License
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
*/
|
18
|
+
/*CursorSet ruby class*/
|
19
|
+
#include "class_CursorSet.h"
|
20
|
+
#include "macros.h"
|
21
|
+
#include "class_Cursor.h"
|
22
|
+
|
23
|
+
static void c_CursorSet_struct_free(CursorSet_t *s)
|
24
|
+
{
|
25
|
+
if (s)
|
26
|
+
{
|
27
|
+
if (s->data) clang_disposeCXCursorSet(s->data);
|
28
|
+
|
29
|
+
ruby_xfree(s);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
static void c_CursorSet_mark(void *s)
|
34
|
+
{
|
35
|
+
if (s)
|
36
|
+
{
|
37
|
+
CursorSet_t *t = (CursorSet_t *) s;
|
38
|
+
rb_gc_mark(t->parent);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
VALUE
|
42
|
+
c_CursorSet_struct_alloc(VALUE klass)
|
43
|
+
{
|
44
|
+
|
45
|
+
CursorSet_t *ptr;
|
46
|
+
ptr = (CursorSet_t *) ruby_xmalloc(sizeof(CursorSet_t));
|
47
|
+
ptr->data = NULL;
|
48
|
+
ptr->parent = Qnil;
|
49
|
+
|
50
|
+
return Data_Wrap_Struct(klass, NULL, c_CursorSet_struct_free, (void *) ptr);
|
51
|
+
}
|
52
|
+
|
53
|
+
/**
|
54
|
+
* call-seq:
|
55
|
+
* Clangc::CursorSet#new => Clangc::CursorSet
|
56
|
+
*
|
57
|
+
* Creates an empty Clangc::CursorSet instance which is
|
58
|
+
* a fast container representing a set of Clangc::Cursor.
|
59
|
+
*/
|
60
|
+
VALUE
|
61
|
+
c_CursorSet_initialize(VALUE self)
|
62
|
+
{
|
63
|
+
CursorSet_t *c;
|
64
|
+
Data_Get_Struct(self, CursorSet_t, c);
|
65
|
+
c->data = clang_createCXCursorSet();
|
66
|
+
return self;
|
67
|
+
}
|
68
|
+
|
69
|
+
/**
|
70
|
+
* call-seq:
|
71
|
+
* Clangc::CursorSet#contains(Clangc::Cursor) => true / false
|
72
|
+
*
|
73
|
+
* Queries a CXCursorSet to see if it contains a specific CXCursor.
|
74
|
+
*
|
75
|
+
* Returns true if the set contains the specified cursor.
|
76
|
+
*/
|
77
|
+
VALUE
|
78
|
+
c_CursorSet_contains(VALUE self, VALUE cursor)
|
79
|
+
{
|
80
|
+
CursorSet_t *cs;
|
81
|
+
Cursor_t *c;
|
82
|
+
|
83
|
+
Data_Get_Struct(self, CursorSet_t, cs);
|
84
|
+
CHECK_ARG_TYPE(cursor, Cursor);
|
85
|
+
Data_Get_Struct(cursor, Cursor_t, c);
|
86
|
+
|
87
|
+
return NOT_0_2_RVAL(clang_CXCursorSet_contains(cs->data, c->data));
|
88
|
+
}
|
89
|
+
|
90
|
+
/**
|
91
|
+
* call-seq:
|
92
|
+
* Clangc::CursorSet(Clangc::Cursor) => true/false
|
93
|
+
*
|
94
|
+
* Inserts a CXCursor into a CXCursorSet.
|
95
|
+
*
|
96
|
+
* Returns false if the CXCursor was already in the set, and true otherwise.
|
97
|
+
*/
|
98
|
+
VALUE
|
99
|
+
c_CursorSet_insert(VALUE self, VALUE cursor)
|
100
|
+
{
|
101
|
+
CursorSet_t *cs;
|
102
|
+
Cursor_t *c;
|
103
|
+
|
104
|
+
Data_Get_Struct(self, CursorSet_t, cs);
|
105
|
+
CHECK_ARG_TYPE(cursor, Cursor);
|
106
|
+
Data_Get_Struct(cursor, Cursor_t, c);
|
107
|
+
|
108
|
+
return NOT_0_2_RVAL(clang_CXCursorSet_insert(cs->data, c->data));
|
109
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/*
|
2
|
+
* ruby-clangc ruby bindings for the C interface of Clang
|
3
|
+
* Copyright (C) 2015-2016 Cedric Le Moigne cedlemo <cedlemo@gmx.com>
|
4
|
+
*
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
8
|
+
* (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
* GNU General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU General Public License
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
*/
|
18
|
+
#ifndef CURSORSET_H
|
19
|
+
#define CURSORSET_H
|
20
|
+
#include <ruby/ruby.h>
|
21
|
+
#include "clang-c/Index.h"
|
22
|
+
typedef struct CursorSet_t
|
23
|
+
{
|
24
|
+
CXCursorSet data;
|
25
|
+
VALUE parent;
|
26
|
+
} CursorSet_t;
|
27
|
+
|
28
|
+
VALUE
|
29
|
+
c_CursorSet_struct_alloc(VALUE);
|
30
|
+
|
31
|
+
VALUE
|
32
|
+
c_CursorSet_initialize(VALUE);
|
33
|
+
|
34
|
+
VALUE
|
35
|
+
c_CursorSet_contains(VALUE, VALUE);
|
36
|
+
|
37
|
+
VALUE
|
38
|
+
c_CursorSet_insert(VALUE, VALUE);
|
39
|
+
#endif // CURSORSET_H
|
@@ -0,0 +1,322 @@
|
|
1
|
+
/*
|
2
|
+
* ruby-clangc ruby bindings for the C interface of Clang
|
3
|
+
* Copyright (C) 2015-2016 Cedric Le Moigne cedlemo <cedlemo@gmx.com>
|
4
|
+
*
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
8
|
+
* (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
* GNU General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU General Public License
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
*/
|
18
|
+
/*Diagnostic ruby class*/
|
19
|
+
#include "class_Diagnostic.h"
|
20
|
+
#include "macros.h"
|
21
|
+
#include "class_SourceRange.h"
|
22
|
+
#include "class_SourceLocation.h"
|
23
|
+
|
24
|
+
static void c_Diagnostic_struct_free(Diagnostic_t *s)
|
25
|
+
{
|
26
|
+
if (s)
|
27
|
+
{
|
28
|
+
|
29
|
+
if (s->data) clang_disposeDiagnostic(s->data);
|
30
|
+
|
31
|
+
ruby_xfree(s);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
static void c_Diagnostic_mark(void *s)
|
35
|
+
{
|
36
|
+
if (s)
|
37
|
+
{
|
38
|
+
Diagnostic_t *d = (Diagnostic_t *) s;
|
39
|
+
rb_gc_mark(d->parent);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
VALUE
|
43
|
+
c_Diagnostic_struct_alloc(VALUE klass)
|
44
|
+
{
|
45
|
+
|
46
|
+
Diagnostic_t *ptr;
|
47
|
+
ptr = (Diagnostic_t *) ruby_xmalloc(sizeof(Diagnostic_t));
|
48
|
+
ptr->data = NULL;
|
49
|
+
ptr->parent = Qnil;
|
50
|
+
return Data_Wrap_Struct(
|
51
|
+
klass, c_Diagnostic_mark, c_Diagnostic_struct_free, (void *) ptr);
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* call-seq:
|
56
|
+
* Clangc::Diagnostic#severity => Fixnum
|
57
|
+
*
|
58
|
+
* Determine the severity of the given diagnostic. It returns one of the
|
59
|
+
* constants defined
|
60
|
+
* in Clangc::DiagnosticSeverity.constants
|
61
|
+
*/
|
62
|
+
VALUE
|
63
|
+
c_Diagnostic_get_severity(VALUE self)
|
64
|
+
{
|
65
|
+
Diagnostic_t *d;
|
66
|
+
Data_Get_Struct(self, Diagnostic_t, d);
|
67
|
+
unsigned int severity = clang_getDiagnosticSeverity(d->data);
|
68
|
+
return CUINT_2_NUM(severity);
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* call-seq:
|
73
|
+
* Clangc::Diagnostic#spelling => String
|
74
|
+
*
|
75
|
+
* Retrieve the text of the given diagnostic.
|
76
|
+
*/
|
77
|
+
VALUE
|
78
|
+
c_Diagnostic_get_spelling(VALUE self)
|
79
|
+
{
|
80
|
+
Diagnostic_t *d;
|
81
|
+
Data_Get_Struct(self, Diagnostic_t, d);
|
82
|
+
return CXSTR_2_RVAL(clang_getDiagnosticSpelling(d->data));
|
83
|
+
}
|
84
|
+
|
85
|
+
/**
|
86
|
+
* call-seq:
|
87
|
+
* Clangc::Diagnostic#category => Fixnum
|
88
|
+
*
|
89
|
+
* Retrieve the category number for this diagnostic.
|
90
|
+
*
|
91
|
+
* Diagnostics can be categorized into groups along with other, related
|
92
|
+
* diagnostics (e.g., diagnostics under the same warning flag). This routine
|
93
|
+
* retrieves the category number for the given diagnostic.
|
94
|
+
*
|
95
|
+
* The number of the category that contains this diagnostic, or zero
|
96
|
+
* if this diagnostic is uncategorized.
|
97
|
+
*/
|
98
|
+
VALUE
|
99
|
+
c_Diagnostic_get_category(VALUE self)
|
100
|
+
{
|
101
|
+
Diagnostic_t *d;
|
102
|
+
Data_Get_Struct(self, Diagnostic_t, d);
|
103
|
+
unsigned int category = clang_getDiagnosticCategory(d->data);
|
104
|
+
return CUINT_2_NUM(category);
|
105
|
+
}
|
106
|
+
|
107
|
+
/**
|
108
|
+
* call-seq:
|
109
|
+
* Clangc::Diagnostic#category_name => String
|
110
|
+
*
|
111
|
+
* Retrieve the name of a particular diagnostic category. This
|
112
|
+
* is now deprecated. Use Clangc::Diagnostic#category_text
|
113
|
+
* instead.
|
114
|
+
*/
|
115
|
+
VALUE
|
116
|
+
c_Diagnostic_get_category_name(VALUE self)
|
117
|
+
{
|
118
|
+
// TODO deprecated write if macro based on clang vervion
|
119
|
+
Diagnostic_t *d;
|
120
|
+
Data_Get_Struct(self, Diagnostic_t, d);
|
121
|
+
return CXSTR_2_RVAL(
|
122
|
+
clang_getDiagnosticCategoryName(clang_getDiagnosticCategory(d->data)));
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
* call-seq:
|
127
|
+
* Clangc::Diagnostic#category_text => String
|
128
|
+
*
|
129
|
+
* Retrieve the diagnostic category text for a given diagnostic.
|
130
|
+
* Returns The text of the given diagnostic category.
|
131
|
+
*/
|
132
|
+
VALUE
|
133
|
+
c_Diagnostic_get_category_text(VALUE self)
|
134
|
+
{
|
135
|
+
Diagnostic_t *d;
|
136
|
+
Data_Get_Struct(self, Diagnostic_t, d);
|
137
|
+
return CXSTR_2_RVAL(clang_getDiagnosticCategoryText(d->data));
|
138
|
+
}
|
139
|
+
|
140
|
+
/**
|
141
|
+
* call-seq:
|
142
|
+
* Clangc::Diagnostic#num_ranges => Fixnum
|
143
|
+
*
|
144
|
+
* Determine the number of source ranges associated with the given
|
145
|
+
* diagnostic.
|
146
|
+
*/
|
147
|
+
VALUE
|
148
|
+
c_Diagnostic_get_num_ranges(VALUE self)
|
149
|
+
{
|
150
|
+
Diagnostic_t *d;
|
151
|
+
Data_Get_Struct(self, Diagnostic_t, d);
|
152
|
+
unsigned int num = clang_getDiagnosticNumRanges(d->data);
|
153
|
+
return CUINT_2_NUM(num);
|
154
|
+
}
|
155
|
+
|
156
|
+
/**
|
157
|
+
* call-seq:
|
158
|
+
* Clangc::Diagnostic#num_fixits => Fixnum
|
159
|
+
*
|
160
|
+
* Determine the number of fix-it hints associated with the given
|
161
|
+
* diagnostic.
|
162
|
+
*/
|
163
|
+
VALUE
|
164
|
+
c_Diagnostic_get_num_fixits(VALUE self)
|
165
|
+
{
|
166
|
+
Diagnostic_t *d;
|
167
|
+
Data_Get_Struct(self, Diagnostic_t, d);
|
168
|
+
unsigned int num = clang_getDiagnosticNumFixIts(d->data);
|
169
|
+
return CUINT_2_NUM(num);
|
170
|
+
}
|
171
|
+
|
172
|
+
/**
|
173
|
+
* call-seq:
|
174
|
+
* Clangc::Diagnostic#format(options) => String
|
175
|
+
*
|
176
|
+
* Format the given diagnostic in a manner that is suitable for display.
|
177
|
+
*
|
178
|
+
* This routine will format the given diagnostic to a string, rendering
|
179
|
+
* the diagnostic according to the various options given. The
|
180
|
+
* Clangc.default_diagnostic_display_options function returns the set of
|
181
|
+
* options that most closely mimics the behavior of the clang compiler.
|
182
|
+
*
|
183
|
+
* options A set of options that control the diagnostic display,
|
184
|
+
* created by combining Clangc::DiagnosticDisplayOptions constants.
|
185
|
+
*
|
186
|
+
* It returns a new string containing for formatted diagnostic.
|
187
|
+
*/
|
188
|
+
VALUE
|
189
|
+
c_Diagnostic_format(VALUE self, VALUE options)
|
190
|
+
{
|
191
|
+
Diagnostic_t *d;
|
192
|
+
Data_Get_Struct(self, Diagnostic_t, d);
|
193
|
+
unsigned int c_options = CLANGC_CONSTANT_TO_UINT("DiagnosticDisplayOptions",
|
194
|
+
options);
|
195
|
+
return CXSTR_2_RVAL(clang_formatDiagnostic(d->data, c_options));
|
196
|
+
}
|
197
|
+
|
198
|
+
/**
|
199
|
+
* call-seq:
|
200
|
+
* Clangc::Diagnostic#option => Array
|
201
|
+
*
|
202
|
+
* Retrieve the name of the command-line option that enabled this
|
203
|
+
* diagnostic such as ("-Wconversion" or "-pedantic") and the option
|
204
|
+
* that disables it if any.
|
205
|
+
* returned_array[0] == String command-line option that enabled the diagnostic
|
206
|
+
* returned_array[1] == String or nil command-line option that disable the
|
207
|
+
* diagnostic
|
208
|
+
*/
|
209
|
+
|
210
|
+
VALUE
|
211
|
+
c_Diagnostic_get_option(VALUE self)
|
212
|
+
{
|
213
|
+
Diagnostic_t *d;
|
214
|
+
Data_Get_Struct(self, Diagnostic_t, d);
|
215
|
+
|
216
|
+
CXString str1;
|
217
|
+
CXString str2;
|
218
|
+
str1 = clang_getDiagnosticOption(d->data, &str2);
|
219
|
+
VALUE ret = rb_ary_new();
|
220
|
+
rb_ary_push(ret, CXSTR_2_RVAL(str1));
|
221
|
+
rb_ary_push(ret, CXSTR_2_RVAL(str2));
|
222
|
+
|
223
|
+
return ret;
|
224
|
+
}
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Retrieve a source range associated with the diagnostic.
|
228
|
+
* call-seq:
|
229
|
+
* Clangc::Diagnostic#source_range(index) => Clangc::SourceRange
|
230
|
+
*
|
231
|
+
* A diagnostic's source ranges highlight important elements in the source
|
232
|
+
* code. On the command line, Clang displays source ranges by
|
233
|
+
* underlining them with '~' characters.
|
234
|
+
*
|
235
|
+
* \param Diagnostic the diagnostic whose range is being extracted.
|
236
|
+
*
|
237
|
+
* \param Range the zero-based index specifying which range to
|
238
|
+
*
|
239
|
+
* \returns the requested source range.
|
240
|
+
*/
|
241
|
+
VALUE
|
242
|
+
c_Diagnostic_get_source_range(VALUE self, VALUE index)
|
243
|
+
{
|
244
|
+
Diagnostic_t *d;
|
245
|
+
Data_Get_Struct(self, Diagnostic_t, d);
|
246
|
+
unsigned int c_index = NUM2UINT(index);
|
247
|
+
VALUE a_source_range;
|
248
|
+
SourceRange_t *s;
|
249
|
+
R_GET_CLASS_DATA("Clangc", SourceRange, a_source_range, s);
|
250
|
+
s->data = clang_getDiagnosticRange(d->data, c_index);
|
251
|
+
s->parent = self;
|
252
|
+
return a_source_range;
|
253
|
+
}
|
254
|
+
|
255
|
+
/**
|
256
|
+
* call-seq:
|
257
|
+
* Clangc::Diagnostic#source_location => Clangc::SourceLocation
|
258
|
+
*
|
259
|
+
* Retrieve the source location of the given diagnostic.
|
260
|
+
*
|
261
|
+
* This location is where Clang would print the caret ('^') when
|
262
|
+
* displaying the diagnostic on the command line.
|
263
|
+
*/
|
264
|
+
|
265
|
+
VALUE
|
266
|
+
c_Diagnostic_get_source_location(VALUE self)
|
267
|
+
{
|
268
|
+
Diagnostic_t *d;
|
269
|
+
Data_Get_Struct(self, Diagnostic_t, d);
|
270
|
+
VALUE a_source_location;
|
271
|
+
SourceLocation_t *sl;
|
272
|
+
R_GET_CLASS_DATA("Clangc", SourceLocation, a_source_location, sl);
|
273
|
+
sl->data = clang_getDiagnosticLocation(d->data);
|
274
|
+
sl->parent = self;
|
275
|
+
return a_source_location;
|
276
|
+
}
|
277
|
+
|
278
|
+
/**
|
279
|
+
* call-seq:
|
280
|
+
* Clangc::Diagnostic#fix_it(fix_number) => Array [Str, Clangc::SourceRange]
|
281
|
+
*
|
282
|
+
* Retrieve the replacement information for a given fix-it.
|
283
|
+
*
|
284
|
+
* Fix-its are described in terms of a source range whose contents
|
285
|
+
* should be replaced by a string. This approach generalizes over
|
286
|
+
* three kinds of operations: removal of source code (the range covers
|
287
|
+
* the code to be removed and the replacement string is empty),
|
288
|
+
* replacement of source code (the range covers the code to be
|
289
|
+
* replaced and the replacement string provides the new code), and
|
290
|
+
* insertion (both the start and end of the range point at the
|
291
|
+
* insertion location, and the replacement string provides the text to
|
292
|
+
* insert).
|
293
|
+
*
|
294
|
+
* fix_number The zero-based index of the fix-it.
|
295
|
+
*
|
296
|
+
* Returns an Array with in the following order:
|
297
|
+
*
|
298
|
+
* A string containing text that should be replace the source
|
299
|
+
* code indicated by the \c ReplacementRange.
|
300
|
+
*
|
301
|
+
* The source range whose contents will be
|
302
|
+
* replaced with the returned replacement string. Note that source
|
303
|
+
* ranges are half-open ranges [a, b), so the source code should be
|
304
|
+
* replaced from a and up to (but not including) b.
|
305
|
+
*/
|
306
|
+
VALUE
|
307
|
+
c_Diagnostic_get_fixit(VALUE self, VALUE index)
|
308
|
+
{
|
309
|
+
Diagnostic_t *d;
|
310
|
+
Data_Get_Struct(self, Diagnostic_t, d);
|
311
|
+
unsigned int c_index = NUM2UINT(index);
|
312
|
+
VALUE source_range;
|
313
|
+
SourceRange_t *s;
|
314
|
+
CXString fixit_str;
|
315
|
+
VALUE ret = rb_ary_new();
|
316
|
+
R_GET_CLASS_DATA("Clangc", SourceRange, source_range, s);
|
317
|
+
s->parent = self;
|
318
|
+
fixit_str = clang_getDiagnosticFixIt(d->data, c_index, &(s->data));
|
319
|
+
rb_ary_push(ret, CXSTR_2_RVAL(fixit_str));
|
320
|
+
rb_ary_push(ret, source_range);
|
321
|
+
return ret;
|
322
|
+
}
|