ghazel-ffi-clang 0.2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +21 -0
  5. data/Gemfile +4 -0
  6. data/README.md +74 -0
  7. data/Rakefile +12 -0
  8. data/ext/rakefile.rb +12 -0
  9. data/ext/teapot.rb +16 -0
  10. data/ffi-clang.gemspec +26 -0
  11. data/lib/ffi/clang.rb +54 -0
  12. data/lib/ffi/clang/comment.rb +278 -0
  13. data/lib/ffi/clang/cursor.rb +378 -0
  14. data/lib/ffi/clang/diagnostic.rb +113 -0
  15. data/lib/ffi/clang/file.rb +69 -0
  16. data/lib/ffi/clang/index.rb +71 -0
  17. data/lib/ffi/clang/lib.rb +73 -0
  18. data/lib/ffi/clang/lib/comment.rb +117 -0
  19. data/lib/ffi/clang/lib/cursor.rb +353 -0
  20. data/lib/ffi/clang/lib/diagnostic.rb +87 -0
  21. data/lib/ffi/clang/lib/file.rb +57 -0
  22. data/lib/ffi/clang/lib/index.rb +34 -0
  23. data/lib/ffi/clang/lib/source_location.rb +53 -0
  24. data/lib/ffi/clang/lib/source_range.rb +46 -0
  25. data/lib/ffi/clang/lib/string.rb +45 -0
  26. data/lib/ffi/clang/lib/token.rb +58 -0
  27. data/lib/ffi/clang/lib/translation_unit.rb +106 -0
  28. data/lib/ffi/clang/lib/type.rb +154 -0
  29. data/lib/ffi/clang/lib/utils.rb +29 -0
  30. data/lib/ffi/clang/source_location.rb +149 -0
  31. data/lib/ffi/clang/source_range.rb +61 -0
  32. data/lib/ffi/clang/token.rb +95 -0
  33. data/lib/ffi/clang/translation_unit.rb +142 -0
  34. data/lib/ffi/clang/type.rb +135 -0
  35. data/lib/ffi/clang/unsaved_file.rb +49 -0
  36. data/lib/ffi/clang/utils.rb +58 -0
  37. data/lib/ffi/clang/version.rb +26 -0
  38. data/spec/clang/comment_spec.rb +470 -0
  39. data/spec/clang/cursor_spec.rb +709 -0
  40. data/spec/clang/diagnostic_spec.rb +89 -0
  41. data/spec/clang/file_spec.rb +84 -0
  42. data/spec/clang/index_spec.rb +70 -0
  43. data/spec/clang/source_location_spec.rb +140 -0
  44. data/spec/clang/source_range_spec.rb +76 -0
  45. data/spec/clang/token_spec.rb +83 -0
  46. data/spec/clang/translation_unit_spec.rb +214 -0
  47. data/spec/clang/type_spec.rb +289 -0
  48. data/spec/clang/utils_spec.rb +61 -0
  49. data/spec/fixtures/a.c +7 -0
  50. data/spec/fixtures/canonical.c +5 -0
  51. data/spec/fixtures/docs.c +1 -0
  52. data/spec/fixtures/docs.cc +1 -0
  53. data/spec/fixtures/docs.h +54 -0
  54. data/spec/fixtures/list.c +11 -0
  55. data/spec/fixtures/location1.c +7 -0
  56. data/spec/fixtures/simple.c +3 -0
  57. data/spec/fixtures/test.cxx +62 -0
  58. data/spec/spec_helper.rb +64 -0
  59. metadata +180 -0
@@ -0,0 +1,61 @@
1
+ # Copyright, 2014 by Masahiro Sano.
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require 'spec_helper'
22
+
23
+ describe FFI::Clang::Utils do
24
+ describe '#self.clang_version_string' do
25
+ let (:version) { Utils::clang_version_string }
26
+ it "returns a version string for showing to user" do
27
+ expect(version).to be_kind_of(String)
28
+ expect(version).to match(/clang version \d+\.\d+/)
29
+ end
30
+ end
31
+
32
+ describe '#self.self.clang_version' do
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+$/)
37
+ end
38
+ end
39
+
40
+ describe '#self.clang_version_symbol' do
41
+ let (:symbol) { Utils::clang_version_symbol }
42
+ it "returns a symbol that represents clang version" do
43
+ expect(symbol).to be_kind_of(Symbol)
44
+ expect(symbol.to_s).to match(/^clang_\d+\_\d+$/)
45
+ end
46
+ end
47
+
48
+ describe '#self.self.clang_major_version' do
49
+ let (:version) { Utils::clang_major_version }
50
+ it "returns major versions as integer" do
51
+ expect(version).to be_kind_of(Integer)
52
+ end
53
+ end
54
+
55
+ describe '#self.self.clang_minor_version' do
56
+ let (:version) { Utils::clang_minor_version }
57
+ it "returns minor versions as integer" do
58
+ expect(version).to be_kind_of(Integer)
59
+ end
60
+ end
61
+ end
data/spec/fixtures/a.c ADDED
@@ -0,0 +1,7 @@
1
+ int main(int argc, char const *argv)
2
+ {
3
+ return 0;
4
+ }
5
+
6
+ int * volatile volatile_int_ptr;
7
+ int * restrict restrict_int_ptr;
@@ -0,0 +1,5 @@
1
+ struct X;
2
+ struct X;
3
+ struct X {
4
+ int a;
5
+ };
@@ -0,0 +1 @@
1
+ #include "docs.h"
@@ -0,0 +1 @@
1
+ #include "docs.h"
@@ -0,0 +1,54 @@
1
+ #ifndef DOCS_H
2
+ #define DOCS_H
3
+
4
+ /**
5
+ * Short explanation
6
+ *
7
+ * This is a longer explanation
8
+ * that spans multiple lines
9
+ *
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
14
+ * @return a random value
15
+ */
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
@@ -0,0 +1,11 @@
1
+ struct List {
2
+ int Data;
3
+ struct List *Next;
4
+ };
5
+ int sum(union List *L) { return 1; };
6
+
7
+ main(int argc, char const *argv)
8
+ {
9
+ if (0 == 1);
10
+ return 0;
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
+ }
@@ -0,0 +1,62 @@
1
+ struct A {
2
+ virtual int func_a() = 0;
3
+ int int_member_a;
4
+ };
5
+
6
+ struct B : public virtual A {
7
+ int func_a() { return 0; }
8
+
9
+ static int func_b() { return 11; }
10
+ };
11
+
12
+ struct C : public virtual A {
13
+ int func_a() { return 1; }
14
+
15
+ enum { EnumC = 100 };
16
+ };
17
+
18
+ struct D : public B, public C {
19
+ private:
20
+ int func_a() { return B::func_a(); }
21
+ void func_d();
22
+
23
+ int private_member_int;
24
+ public:
25
+ int public_member_int;
26
+ protected:
27
+ int protected_member_int;
28
+ };
29
+
30
+ void D::func_d() {};
31
+ f_dynamic_call(A *a) { a->func_a(); };
32
+
33
+ void f_variadic(int a, ...);
34
+ void f_non_variadic(int a, char b, long c);
35
+
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)));
@@ -0,0 +1,64 @@
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
+ require 'ffi/clang'
3
+
4
+ include FFI::Clang
5
+
6
+ TMP_DIR = File.expand_path("../tmp/", __FILE__)
7
+
8
+ module ClangSpecHelper
9
+ def fixture_path(path)
10
+ File.join File.expand_path("../fixtures", __FILE__), path
11
+ end
12
+
13
+ def find_all(cursor, kind)
14
+ ret = []
15
+
16
+ cursor.visit_children do |cursor, parent|
17
+ if (cursor.kind == kind)
18
+ ret << cursor
19
+ end
20
+ :recurse
21
+ end
22
+
23
+ ret
24
+ end
25
+
26
+ def find_first(cursor, kind)
27
+ find_all(cursor, kind).first
28
+ end
29
+
30
+ def find_all_matching(cursor, &term)
31
+ ret = []
32
+
33
+ cursor.visit_children do |child, parent|
34
+ if term.call child, parent
35
+ ret << child
36
+ end
37
+
38
+ :recurse
39
+ end
40
+
41
+ ret
42
+ end
43
+
44
+ def find_matching(cursor, &term)
45
+ find_all_matching(cursor, &term).first
46
+ end
47
+ end
48
+
49
+ RSpec.configure do |c|
50
+ c.include ClangSpecHelper
51
+ supported_versions = ['3.2', '3.3', '3.4', '3.5']
52
+ current_version = ENV['LLVM_VERSION'] || supported_versions.last
53
+ supported_versions.reverse_each { |version|
54
+ break if version == current_version
55
+ sym = ('from_' + version.tr('.', '_')).to_sym
56
+ c.filter_run_excluding sym => true
57
+ }
58
+
59
+ supported_versions.each { |version|
60
+ break if version == current_version
61
+ sym = ('upto_' + version.tr('.', '_')).to_sym
62
+ c.filter_run_excluding sym => true
63
+ }
64
+ end
metadata ADDED
@@ -0,0 +1,180 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ghazel-ffi-clang
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jari Bakken
8
+ - Samuel Williams
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-02-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ffi
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: '1.3'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: '1.3'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ description: Ruby FFI bindings for libclang C interface.
71
+ email:
72
+ - Jari Bakken
73
+ - samuel.williams@oriontransfer.co.nz
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - .gitignore
79
+ - .rspec
80
+ - .travis.yml
81
+ - Gemfile
82
+ - README.md
83
+ - Rakefile
84
+ - ext/rakefile.rb
85
+ - ext/teapot.rb
86
+ - ffi-clang.gemspec
87
+ - lib/ffi/clang.rb
88
+ - lib/ffi/clang/comment.rb
89
+ - lib/ffi/clang/cursor.rb
90
+ - lib/ffi/clang/diagnostic.rb
91
+ - lib/ffi/clang/file.rb
92
+ - lib/ffi/clang/index.rb
93
+ - lib/ffi/clang/lib.rb
94
+ - lib/ffi/clang/lib/comment.rb
95
+ - lib/ffi/clang/lib/cursor.rb
96
+ - lib/ffi/clang/lib/diagnostic.rb
97
+ - lib/ffi/clang/lib/file.rb
98
+ - lib/ffi/clang/lib/index.rb
99
+ - lib/ffi/clang/lib/source_location.rb
100
+ - lib/ffi/clang/lib/source_range.rb
101
+ - lib/ffi/clang/lib/string.rb
102
+ - lib/ffi/clang/lib/token.rb
103
+ - lib/ffi/clang/lib/translation_unit.rb
104
+ - lib/ffi/clang/lib/type.rb
105
+ - lib/ffi/clang/lib/utils.rb
106
+ - lib/ffi/clang/source_location.rb
107
+ - lib/ffi/clang/source_range.rb
108
+ - lib/ffi/clang/token.rb
109
+ - lib/ffi/clang/translation_unit.rb
110
+ - lib/ffi/clang/type.rb
111
+ - lib/ffi/clang/unsaved_file.rb
112
+ - lib/ffi/clang/utils.rb
113
+ - lib/ffi/clang/version.rb
114
+ - spec/clang/comment_spec.rb
115
+ - spec/clang/cursor_spec.rb
116
+ - spec/clang/diagnostic_spec.rb
117
+ - spec/clang/file_spec.rb
118
+ - spec/clang/index_spec.rb
119
+ - spec/clang/source_location_spec.rb
120
+ - spec/clang/source_range_spec.rb
121
+ - spec/clang/token_spec.rb
122
+ - spec/clang/translation_unit_spec.rb
123
+ - spec/clang/type_spec.rb
124
+ - spec/clang/utils_spec.rb
125
+ - spec/fixtures/a.c
126
+ - spec/fixtures/canonical.c
127
+ - spec/fixtures/docs.c
128
+ - spec/fixtures/docs.cc
129
+ - spec/fixtures/docs.h
130
+ - spec/fixtures/list.c
131
+ - spec/fixtures/location1.c
132
+ - spec/fixtures/simple.c
133
+ - spec/fixtures/test.cxx
134
+ - spec/spec_helper.rb
135
+ homepage: ''
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.0.3
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Ruby FFI bindings for libclang C interface.
159
+ test_files:
160
+ - spec/clang/comment_spec.rb
161
+ - spec/clang/cursor_spec.rb
162
+ - spec/clang/diagnostic_spec.rb
163
+ - spec/clang/file_spec.rb
164
+ - spec/clang/index_spec.rb
165
+ - spec/clang/source_location_spec.rb
166
+ - spec/clang/source_range_spec.rb
167
+ - spec/clang/token_spec.rb
168
+ - spec/clang/translation_unit_spec.rb
169
+ - spec/clang/type_spec.rb
170
+ - spec/clang/utils_spec.rb
171
+ - spec/fixtures/a.c
172
+ - spec/fixtures/canonical.c
173
+ - spec/fixtures/docs.c
174
+ - spec/fixtures/docs.cc
175
+ - spec/fixtures/docs.h
176
+ - spec/fixtures/list.c
177
+ - spec/fixtures/location1.c
178
+ - spec/fixtures/simple.c
179
+ - spec/fixtures/test.cxx
180
+ - spec/spec_helper.rb