ffi-clang 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +12 -8
  3. data/README.md +3 -1
  4. data/ffi-clang.gemspec +1 -1
  5. data/lib/ffi/clang.rb +3 -1
  6. data/lib/ffi/clang/code_completion.rb +193 -0
  7. data/lib/ffi/clang/comment.rb +154 -11
  8. data/lib/ffi/clang/compilation_database.rb +125 -0
  9. data/lib/ffi/clang/cursor.rb +145 -9
  10. data/lib/ffi/clang/diagnostic.rb +36 -10
  11. data/lib/ffi/clang/file.rb +69 -0
  12. data/lib/ffi/clang/index.rb +9 -17
  13. data/lib/ffi/clang/lib.rb +25 -2
  14. data/lib/ffi/clang/lib/code_completion.rb +130 -0
  15. data/lib/ffi/clang/lib/comment.rb +73 -12
  16. data/lib/ffi/clang/lib/compilation_database.rb +58 -0
  17. data/lib/ffi/clang/lib/cursor.rb +78 -14
  18. data/lib/ffi/clang/lib/diagnostic.rb +32 -12
  19. data/lib/ffi/clang/lib/file.rb +15 -3
  20. data/lib/ffi/clang/lib/inclusions.rb +32 -0
  21. data/lib/ffi/clang/lib/source_location.rb +18 -0
  22. data/lib/ffi/clang/lib/source_range.rb +5 -0
  23. data/lib/ffi/clang/lib/token.rb +58 -0
  24. data/lib/ffi/clang/lib/translation_unit.rb +71 -1
  25. data/lib/ffi/clang/lib/type.rb +61 -3
  26. data/lib/ffi/clang/source_location.rb +102 -0
  27. data/lib/ffi/clang/source_range.rb +25 -4
  28. data/lib/ffi/clang/token.rb +95 -0
  29. data/lib/ffi/clang/translation_unit.rb +118 -2
  30. data/lib/ffi/clang/type.rb +61 -0
  31. data/lib/ffi/clang/unsaved_file.rb +16 -0
  32. data/lib/ffi/clang/utils.rb +38 -12
  33. data/lib/ffi/clang/version.rb +1 -1
  34. data/spec/clang/code_completion_spec.rb +181 -0
  35. data/spec/clang/comment_spec.rb +385 -12
  36. data/spec/clang/compilation_database_spec.rb +178 -0
  37. data/spec/clang/cursor_spec.rb +335 -12
  38. data/spec/clang/diagnostic_spec.rb +63 -4
  39. data/spec/clang/file_spec.rb +84 -0
  40. data/spec/clang/index_spec.rb +62 -5
  41. data/spec/clang/source_location_spec.rb +104 -4
  42. data/spec/clang/source_range_spec.rb +76 -0
  43. data/spec/clang/token_spec.rb +84 -0
  44. data/spec/clang/translation_unit_spec.rb +202 -5
  45. data/spec/clang/type_spec.rb +191 -0
  46. data/spec/clang/utils_spec.rb +2 -3
  47. data/spec/fixtures/a.c +3 -0
  48. data/spec/fixtures/compile_commands.json +17 -0
  49. data/spec/fixtures/completion.cxx +8 -0
  50. data/spec/fixtures/docs.c +1 -0
  51. data/spec/fixtures/docs.cc +1 -0
  52. data/spec/fixtures/docs.h +46 -3
  53. data/spec/fixtures/list.c +1 -0
  54. data/spec/fixtures/location1.c +7 -0
  55. data/spec/fixtures/simple.c +3 -0
  56. data/spec/fixtures/test.cxx +36 -0
  57. data/spec/spec_helper.rb +11 -0
  58. metadata +50 -21
@@ -31,9 +31,8 @@ describe FFI::Clang::Utils do
31
31
 
32
32
  describe '#self.self.clang_version' do
33
33
  let (:version) { Utils::clang_version }
34
- it "returns only a version of clang as string" do
35
- expect(version).to be_kind_of(String)
36
- expect(version).to match(/^\d+\.\d+$/)
34
+ it "returns only a version of clang as array [major, minor]" do
35
+ expect(version).to be_kind_of(Array)
37
36
  end
38
37
  end
39
38
 
@@ -2,3 +2,6 @@ int main(int argc, char const *argv)
2
2
  {
3
3
  return 0;
4
4
  }
5
+
6
+ int * volatile volatile_int_ptr;
7
+ int * restrict restrict_int_ptr;
@@ -0,0 +1,17 @@
1
+ [
2
+ {
3
+ "directory": "/home/xxxxx/src/build-trunk/lib/Support",
4
+ "command": "/opt/llvm/3.4/bin/clang++ -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -fno-rtti -ffunction-sections -fdata-sections -O3 -I/home/xxxxx/src/build-trunk/lib/Support -I/home/xxxxx/src/llvm-trunk/lib/Support -I/home/xxxxx/src/build-trunk/include -I/home/xxxxx/src/llvm-trunk/include -UNDEBUG -fno-exceptions -o CMakeFiles/LLVMSupport.dir/APFloat.cpp.o -c /home/xxxxx/src/llvm-trunk/lib/Support/APFloat.cpp",
5
+ "file": "/home/xxxxx/src/llvm-trunk/lib/Support/APFloat.cpp"
6
+ },
7
+ {
8
+ "directory": "/home/xxxxx/src/build-trunk/lib/Support",
9
+ "command": "/opt/llvm/3.4/bin/clang++ -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -fno-rtti -ffunction-sections -fdata-sections -O3 -I/home/xxxxx/src/build-trunk/lib/Support -I/home/xxxxx/src/llvm-trunk/lib/Support -I/home/xxxxx/src/build-trunk/include -I/home/xxxxx/src/llvm-trunk/include -UNDEBUG -fno-exceptions -o CMakeFiles/LLVMSupport.dir/APInt.cpp.o -c /home/xxxxx/src/llvm-trunk/lib/Support/APInt.cpp",
10
+ "file": "/home/xxxxx/src/llvm-trunk/lib/Support/APInt.cpp"
11
+ },
12
+ {
13
+ "directory": "/home/xxxxx/src/build-trunk/lib/Support",
14
+ "command": "/opt/llvm/3.4/bin/clang++ -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -fno-rtti -ffunction-sections -fdata-sections -O3 -I/home/xxxxx/src/build-trunk/lib/Support -I/home/xxxxx/src/llvm-trunk/lib/Support -I/home/xxxxx/src/build-trunk/include -I/home/xxxxx/src/llvm-trunk/include -UNDEBUG -fno-exceptions -o CMakeFiles/LLVMSupport.dir/APSInt.cpp.o -c /home/xxxxx/src/llvm-trunk/lib/Support/APSInt.cpp",
15
+ "file": "/home/xxxxx/src/llvm-trunk/lib/Support/APSInt.cpp"
16
+ }
17
+ ]
@@ -0,0 +1,8 @@
1
+ #include <vector>
2
+
3
+ std::vector<int> v1;
4
+ std::vector<> v2;
5
+
6
+ int main(void) {
7
+ v1.
8
+ }
@@ -0,0 +1 @@
1
+ #include "docs.h"
@@ -0,0 +1 @@
1
+ #include "docs.h"
@@ -1,11 +1,54 @@
1
+ #ifndef DOCS_H
2
+ #define DOCS_H
3
+
1
4
  /**
2
5
  * Short explanation
3
6
  *
4
7
  * This is a longer explanation
5
8
  * that spans multiple lines
6
9
  *
7
- * @param input some input
8
- * @param flags some flags
10
+ * @param[in] input some input
11
+ * @param[out] flags some flags
12
+ * @param[in,out] buf some input and output buffer
13
+ * @param option some option
9
14
  * @return a random value
10
15
  */
11
- int a_function(char *input, int flags);
16
+ int a_function(char *input, int *flags, char *buf, int option);
17
+
18
+ int no_comment_function(void);
19
+
20
+ /**
21
+ * <br />
22
+ * <a href="http://example.org/">
23
+ * </a>
24
+ */
25
+ void b_function(void);
26
+
27
+ /**
28
+ * @tparam T1 some type of foo
29
+ * @tparam T2 some type of bar
30
+ * @tparam T3 some type of baz
31
+ */
32
+ template<typename T1, template<typename T2> class T3>
33
+ void c_function(T3<int> xxx);
34
+
35
+ /**
36
+ * abc \em foo \b bar
37
+ */
38
+ void d_function(void);
39
+
40
+ /**
41
+ * \verbatim
42
+ * foo bar
43
+ * baz
44
+ * \endverbatim
45
+ */
46
+ void e_function(void);
47
+
48
+ /**
49
+ * \brief this is a function.
50
+ */
51
+ int f_function(void);
52
+
53
+
54
+ #endif
@@ -6,5 +6,6 @@ int sum(union List *L) { return 1; };
6
6
 
7
7
  main(int argc, char const *argv)
8
8
  {
9
+ if (0 == 1);
9
10
  return 0;
10
11
  }
@@ -0,0 +1,7 @@
1
+ #123 "dummy.c" 1
2
+
3
+ static int func(void)
4
+ {
5
+ return 0;
6
+ }
7
+
@@ -0,0 +1,3 @@
1
+ int main(void) {
2
+ return 0;
3
+ }
@@ -1,5 +1,6 @@
1
1
  struct A {
2
2
  virtual int func_a() = 0;
3
+ int int_member_a;
3
4
  };
4
5
 
5
6
  struct B : public virtual A {
@@ -16,11 +17,46 @@ struct C : public virtual A {
16
17
 
17
18
  struct D : public B, public C {
18
19
  private:
20
+ int func_a() { return B::func_a(); }
19
21
  void func_d();
22
+
23
+ int private_member_int;
24
+ public:
25
+ int public_member_int;
26
+ protected:
27
+ int protected_member_int;
20
28
  };
21
29
 
22
30
  void D::func_d() {};
31
+ f_dynamic_call(A *a) { a->func_a(); };
23
32
 
24
33
  void f_variadic(int a, ...);
34
+ void f_non_variadic(int a, char b, long c);
25
35
 
26
36
  typedef int const* const_int_ptr;
37
+ int int_array[8];
38
+
39
+ struct RefQualifier {
40
+ void func_lvalue_ref() &;
41
+ void func_rvalue_ref() &&;
42
+ void func_none();
43
+ };
44
+
45
+ int A::*member_pointer = &A::int_member_a;
46
+
47
+ struct BitField {
48
+ int bit_field_a : 2;
49
+ int bit_field_b : 6;
50
+ int non_bit_field_c;
51
+ };
52
+
53
+ enum normal_enum {
54
+ normal_enum_a
55
+ };
56
+
57
+ template <typename T> T func_overloaded(T a) { return a;};
58
+ template <typename T> T func_overloaded() { return 100;};
59
+ template <typename T> T use_func_overloaded() { return func_overloaded<T>(); };
60
+ int use_overloaded_int_a = func_overloaded<int>();
61
+
62
+ void availability_func(void) __attribute__((availability(macosx,introduced=10.4.1,deprecated=10.6,obsoleted=10.7)));
@@ -3,6 +3,17 @@ require 'ffi/clang'
3
3
 
4
4
  include FFI::Clang
5
5
 
6
+ TMP_DIR = File.expand_path("../tmp/", __FILE__)
7
+
8
+ if ENV['LLVM_CONFIG']
9
+ llvm_bindir = `#{ENV['LLVM_CONFIG']} --bindir`.chomp
10
+ CLANG_COMPILER = File.expand_path('clang', llvm_bindir)
11
+ CLANGPP_COMPILER = File.expand_path('clang++', llvm_bindir)
12
+ else
13
+ CLANG_COMPILER = 'clang'
14
+ CLANGPP_COMPILER = 'clang++'
15
+ end
16
+
6
17
  module ClangSpecHelper
7
18
  def fixture_path(path)
8
19
  File.join File.expand_path("../fixtures", __FILE__), path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-clang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
@@ -9,62 +9,62 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-02 00:00:00.000000000 Z
12
+ date: 2014-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '1.3'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '1.3'
42
42
  - !ruby/object:Gem::Dependency
43
- name: rake
43
+ name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: 3.0.0
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '0'
55
+ version: 3.0.0
56
56
  - !ruby/object:Gem::Dependency
57
- name: rspec
57
+ name: rake
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  description: Ruby FFI bindings for libclang C interface.
@@ -75,9 +75,9 @@ executables: []
75
75
  extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
- - .gitignore
79
- - .rspec
80
- - .travis.yml
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
81
  - Gemfile
82
82
  - README.md
83
83
  - Rakefile
@@ -85,41 +85,60 @@ files:
85
85
  - ext/teapot.rb
86
86
  - ffi-clang.gemspec
87
87
  - lib/ffi/clang.rb
88
+ - lib/ffi/clang/code_completion.rb
88
89
  - lib/ffi/clang/comment.rb
90
+ - lib/ffi/clang/compilation_database.rb
89
91
  - lib/ffi/clang/cursor.rb
90
92
  - lib/ffi/clang/diagnostic.rb
93
+ - lib/ffi/clang/file.rb
91
94
  - lib/ffi/clang/index.rb
92
95
  - lib/ffi/clang/lib.rb
96
+ - lib/ffi/clang/lib/code_completion.rb
93
97
  - lib/ffi/clang/lib/comment.rb
98
+ - lib/ffi/clang/lib/compilation_database.rb
94
99
  - lib/ffi/clang/lib/cursor.rb
95
100
  - lib/ffi/clang/lib/diagnostic.rb
96
101
  - lib/ffi/clang/lib/file.rb
102
+ - lib/ffi/clang/lib/inclusions.rb
97
103
  - lib/ffi/clang/lib/index.rb
98
104
  - lib/ffi/clang/lib/source_location.rb
99
105
  - lib/ffi/clang/lib/source_range.rb
100
106
  - lib/ffi/clang/lib/string.rb
107
+ - lib/ffi/clang/lib/token.rb
101
108
  - lib/ffi/clang/lib/translation_unit.rb
102
109
  - lib/ffi/clang/lib/type.rb
103
110
  - lib/ffi/clang/lib/utils.rb
104
111
  - lib/ffi/clang/source_location.rb
105
112
  - lib/ffi/clang/source_range.rb
113
+ - lib/ffi/clang/token.rb
106
114
  - lib/ffi/clang/translation_unit.rb
107
115
  - lib/ffi/clang/type.rb
108
116
  - lib/ffi/clang/unsaved_file.rb
109
117
  - lib/ffi/clang/utils.rb
110
118
  - lib/ffi/clang/version.rb
119
+ - spec/clang/code_completion_spec.rb
111
120
  - spec/clang/comment_spec.rb
121
+ - spec/clang/compilation_database_spec.rb
112
122
  - spec/clang/cursor_spec.rb
113
123
  - spec/clang/diagnostic_spec.rb
124
+ - spec/clang/file_spec.rb
114
125
  - spec/clang/index_spec.rb
115
126
  - spec/clang/source_location_spec.rb
127
+ - spec/clang/source_range_spec.rb
128
+ - spec/clang/token_spec.rb
116
129
  - spec/clang/translation_unit_spec.rb
117
130
  - spec/clang/type_spec.rb
118
131
  - spec/clang/utils_spec.rb
119
132
  - spec/fixtures/a.c
120
133
  - spec/fixtures/canonical.c
134
+ - spec/fixtures/compile_commands.json
135
+ - spec/fixtures/completion.cxx
136
+ - spec/fixtures/docs.c
137
+ - spec/fixtures/docs.cc
121
138
  - spec/fixtures/docs.h
122
139
  - spec/fixtures/list.c
140
+ - spec/fixtures/location1.c
141
+ - spec/fixtures/simple.c
123
142
  - spec/fixtures/test.cxx
124
143
  - spec/spec_helper.rb
125
144
  homepage: ''
@@ -132,33 +151,43 @@ require_paths:
132
151
  - lib
133
152
  required_ruby_version: !ruby/object:Gem::Requirement
134
153
  requirements:
135
- - - '>='
154
+ - - ">="
136
155
  - !ruby/object:Gem::Version
137
156
  version: '0'
138
157
  required_rubygems_version: !ruby/object:Gem::Requirement
139
158
  requirements:
140
- - - '>='
159
+ - - ">="
141
160
  - !ruby/object:Gem::Version
142
161
  version: '0'
143
162
  requirements: []
144
163
  rubyforge_project:
145
- rubygems_version: 2.0.3
164
+ rubygems_version: 2.2.2
146
165
  signing_key:
147
166
  specification_version: 4
148
167
  summary: Ruby FFI bindings for libclang C interface.
149
168
  test_files:
169
+ - spec/clang/code_completion_spec.rb
150
170
  - spec/clang/comment_spec.rb
171
+ - spec/clang/compilation_database_spec.rb
151
172
  - spec/clang/cursor_spec.rb
152
173
  - spec/clang/diagnostic_spec.rb
174
+ - spec/clang/file_spec.rb
153
175
  - spec/clang/index_spec.rb
154
176
  - spec/clang/source_location_spec.rb
177
+ - spec/clang/source_range_spec.rb
178
+ - spec/clang/token_spec.rb
155
179
  - spec/clang/translation_unit_spec.rb
156
180
  - spec/clang/type_spec.rb
157
181
  - spec/clang/utils_spec.rb
158
182
  - spec/fixtures/a.c
159
183
  - spec/fixtures/canonical.c
184
+ - spec/fixtures/compile_commands.json
185
+ - spec/fixtures/completion.cxx
186
+ - spec/fixtures/docs.c
187
+ - spec/fixtures/docs.cc
160
188
  - spec/fixtures/docs.h
161
189
  - spec/fixtures/list.c
190
+ - spec/fixtures/location1.c
191
+ - spec/fixtures/simple.c
162
192
  - spec/fixtures/test.cxx
163
193
  - spec/spec_helper.rb
164
- has_rdoc: