cauterize 0.0.1.pre1 → 0.0.1.pre5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +1 -1
- data/Gemfile +1 -1
- data/README.md +0 -2
- data/Rakefile +19 -3
- data/bin/cauterize +14 -6
- data/example/Cauterize +22 -10
- data/example/build.sh +15 -2
- data/lib/cauterize/base_type.rb +2 -5
- data/lib/cauterize/builders.rb +1 -3
- data/lib/cauterize/builders/c/buildable.rb +3 -2
- data/lib/cauterize/builders/c/builtin.rb +46 -0
- data/lib/cauterize/builders/c/enumeration.rb +23 -2
- data/lib/cauterize/builders/c/fixed_array.rb +16 -7
- data/lib/cauterize/builders/c/group.rb +32 -3
- data/lib/cauterize/builders/c/scalar.rb +5 -0
- data/lib/cauterize/builders/c/variable_array.rb +1 -1
- data/lib/cauterize/builders/cs/buildable.rb +59 -0
- data/lib/cauterize/builders/cs/builtin.rb +23 -0
- data/lib/cauterize/builders/cs/composite.rb +21 -0
- data/lib/cauterize/builders/cs/csarray.rb +32 -0
- data/lib/cauterize/builders/cs/enumeration.rb +21 -0
- data/lib/cauterize/builders/cs/fixed_array.rb +25 -0
- data/lib/cauterize/builders/cs/group.rb +33 -0
- data/lib/cauterize/builders/cs/scalar.rb +10 -0
- data/lib/cauterize/builders/cs/variable_array.rb +34 -0
- data/lib/cauterize/builtin.rb +52 -0
- data/lib/cauterize/c_builder.rb +15 -1
- data/lib/cauterize/cauterize.rb +44 -13
- data/lib/cauterize/composite.rb +3 -3
- data/lib/cauterize/cs_builder.rb +53 -0
- data/lib/cauterize/enumeration.rb +20 -3
- data/lib/cauterize/fixed_array.rb +3 -3
- data/lib/cauterize/formatter.rb +7 -3
- data/lib/cauterize/group.rb +5 -8
- data/lib/cauterize/scalar.rb +16 -7
- data/lib/cauterize/variable_array.rb +6 -6
- data/lib/cauterize/version.rb +1 -1
- data/spec/base_type_spec.rb +133 -125
- data/spec/builders/c/buildable_spec.rb +18 -18
- data/spec/builders/c/builtin_spec.rb +22 -0
- data/spec/builders/c/composite_spec.rb +37 -33
- data/spec/builders/c/enumeration_spec.rb +84 -21
- data/spec/builders/c/fixed_array_spec.rb +6 -6
- data/spec/builders/c/group_spec.rb +97 -90
- data/spec/builders/c/scalar_spec.rb +24 -6
- data/spec/builders/c/variable_array_spec.rb +37 -37
- data/spec/builders/cs/buildable_spec.rb +8 -0
- data/spec/builders/cs/composite_spec.rb +32 -0
- data/spec/builders/cs/enumeration_spec.rb +33 -0
- data/spec/builders/cs/fixed_array_spec.rb +40 -0
- data/spec/builders/cs/group_spec.rb +56 -0
- data/spec/builders/cs/scalar_spec.rb +7 -0
- data/spec/builders/cs/variable_array_spec.rb +46 -0
- data/spec/builders_spec.rb +38 -38
- data/spec/builtin_spec.rb +46 -0
- data/spec/c_builder_spec.rb +116 -102
- data/spec/cauterize_spec.rb +8 -1
- data/spec/composite_spec.rb +52 -48
- data/spec/cs_builder_spec.rb +113 -0
- data/spec/enumeration_spec.rb +55 -16
- data/spec/fixed_array_spec.rb +7 -9
- data/spec/group_spec.rb +81 -76
- data/spec/scalar_spec.rb +20 -10
- data/spec/spec_helper.rb +103 -94
- data/spec/support/shared_examples_for_c_buildables.rb +68 -64
- data/spec/variable_array_spec.rb +12 -17
- data/{c → support/c}/src/cauterize.c +8 -7
- data/support/c/src/cauterize.h +59 -0
- data/{c → support/c}/src/cauterize_debug.h +0 -0
- data/support/c/src/cauterize_util.h +49 -0
- data/{c → support/c}/test/greatest.h +0 -0
- data/{c → support/c}/test/test.c +0 -0
- data/support/cs/src/CauterizeCompositeFormatter.cs +34 -0
- data/support/cs/src/CauterizeContainerFormatter.cs +18 -0
- data/support/cs/src/CauterizeEnumFormatter.cs +67 -0
- data/support/cs/src/CauterizeException.cs +15 -0
- data/support/cs/src/CauterizeFixedArrayFormatter.cs +39 -0
- data/support/cs/src/CauterizeFormatter.cs +40 -0
- data/support/cs/src/CauterizeGroupFormatter.cs +46 -0
- data/support/cs/src/CauterizePrimitiveFormatter.cs +33 -0
- data/support/cs/src/CauterizeTypeFormatterFactory.cs +39 -0
- data/support/cs/src/CauterizeTypes.cs +107 -0
- data/support/cs/src/CauterizeVariableArrayFormatter.cs +49 -0
- data/support/cs/src/ICauterizeTypeFormatter.cs +12 -0
- data/support/cs/src/OrderAttribute.cs +50 -0
- data/support/cs/src/PrimitiveSupport.cs +134 -0
- data/support/cs/src/SerializedRepresentationAttribute.cs +24 -0
- data/support/cs/test/CauterizeCompositeFormatterTest.cs +59 -0
- data/support/cs/test/CauterizeEnumFormatterTest.cs +110 -0
- data/support/cs/test/CauterizeFixedArrayFormatterTest.cs +91 -0
- data/support/cs/test/CauterizeFormatterTest.cs +40 -0
- data/support/cs/test/CauterizeGroupFormatterTest.cs +147 -0
- data/support/cs/test/CauterizeIntegrationTest.cs +129 -0
- data/support/cs/test/CauterizePrimitiveFormatterTest.cs +98 -0
- data/support/cs/test/CauterizeTypeFormatterFactoryTest.cs +73 -0
- data/support/cs/test/CauterizeVariableArrayFormatterTest.cs +130 -0
- data/support/cs/test/OrderAttributeTest.cs +39 -0
- data/support/cs/test/SerializedRepresentationAttributeTest.cs +39 -0
- metadata +68 -10
- data/c/src/cauterize.h +0 -46
- data/c/src/cauterize_util.h +0 -7
@@ -1,24 +1,24 @@
|
|
1
|
-
|
1
|
+
module Cauterize::Builders::C
|
2
|
+
describe Cauterize::Builders::C do
|
3
|
+
describe Buildable do
|
4
|
+
subject { Buildable.new(:some_blueprint) }
|
2
5
|
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
subject.send(m)
|
12
|
-
end
|
13
|
-
}.should raise_error /must implement/
|
6
|
+
describe "required methods" do
|
7
|
+
it "raises errors on required interfaces" do
|
8
|
+
lambda {
|
9
|
+
REQUIRED_METHODS.each do |m|
|
10
|
+
subject.send(m)
|
11
|
+
end
|
12
|
+
}.should raise_error /must implement/
|
13
|
+
end
|
14
14
|
end
|
15
|
-
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
describe :method_missing do
|
17
|
+
it "calls the original if method not required" do
|
18
|
+
lambda {
|
19
|
+
subject.is_not_defined
|
20
|
+
}.should raise_error NoMethodError
|
21
|
+
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Cauterize
|
2
|
+
describe Builders::C::BuiltIn do
|
3
|
+
let(:bi) do
|
4
|
+
b = BuiltIn.new(:foo)
|
5
|
+
b.is_signed(false)
|
6
|
+
b.byte_length(4)
|
7
|
+
b
|
8
|
+
end
|
9
|
+
|
10
|
+
let (:bi_bldr) do
|
11
|
+
Builders.get(:c, bi)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".declare" do
|
15
|
+
it "declares a variable with the BuiltIn's type" do
|
16
|
+
f = default_formatter
|
17
|
+
bi_bldr.declare(f, :meep)
|
18
|
+
f.to_s.should == "uint32_t meep;"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,45 +1,49 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
scalar(:int32)
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
module Cauterize
|
2
|
+
describe Cauterize::Builders::C::Composite do
|
3
|
+
before do
|
4
|
+
Cauterize.scalar(:my_int) {|t| t.type_name(:int32)}
|
5
|
+
end
|
6
|
+
|
7
|
+
let(:type_constructor) do
|
8
|
+
lambda do |name|
|
9
|
+
Cauterize.composite(name) do |c|
|
10
|
+
c.field :an_int, :my_int
|
11
|
+
c.field :another_int, :my_int
|
12
|
+
end
|
8
13
|
end
|
9
14
|
end
|
10
|
-
end
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
it_behaves_like "a buildable"
|
17
|
+
it_behaves_like "a sane buildable"
|
18
|
+
include_examples "no enum"
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
20
|
+
context "structure definition" do
|
21
|
+
let(:comp) do
|
22
|
+
_c = Cauterize.composite(:foo) do |c|
|
23
|
+
c.field(:an_int, :my_int)
|
24
|
+
end
|
22
25
|
|
23
|
-
|
24
|
-
|
26
|
+
Builders.get(:c, _c)
|
27
|
+
end
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
describe ".struct_proto" do
|
30
|
+
it "defines a structure prototype" do
|
31
|
+
f = default_formatter
|
32
|
+
comp.struct_proto(f)
|
33
|
+
f.to_s.should == "struct foo;"
|
34
|
+
end
|
31
35
|
end
|
32
|
-
end
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
describe ".struct_defn" do
|
38
|
+
it "defines a structure definition" do
|
39
|
+
f = default_formatter
|
40
|
+
comp.struct_defn(f)
|
41
|
+
fs = f.to_s
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
+
fs.should match /struct foo/
|
44
|
+
fs.should match /my_int an_int;/
|
45
|
+
fs.should match /};/
|
46
|
+
end
|
43
47
|
end
|
44
48
|
end
|
45
49
|
end
|
@@ -1,32 +1,95 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Cauterize
|
2
|
+
describe Cauterize::Builders::C::Enumeration do
|
3
|
+
let(:type_constructor) { lambda {|name|
|
4
|
+
Cauterize.enumeration(name) do |t|
|
5
|
+
t.value :a, 100
|
6
|
+
end
|
7
|
+
}}
|
8
|
+
|
9
|
+
it_behaves_like "a buildable"
|
10
|
+
it_behaves_like "a sane buildable"
|
11
|
+
include_examples "no struct"
|
3
12
|
|
4
|
-
|
5
|
-
|
6
|
-
|
13
|
+
describe ".enum_defn" do
|
14
|
+
let(:en) do
|
15
|
+
_e = Cauterize.enumeration(:foo) do |e|
|
16
|
+
e.value :aaa
|
17
|
+
e.value :bbb
|
18
|
+
e.value "QuickBrownFox".to_sym
|
19
|
+
end
|
7
20
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
e.value :aaa
|
12
|
-
e.value :bbb
|
13
|
-
e.value "QuickBrownFox".to_sym
|
21
|
+
f = default_formatter
|
22
|
+
Builders.get(:c, _e).enum_defn(f)
|
23
|
+
f.to_s
|
14
24
|
end
|
15
25
|
|
16
|
-
|
17
|
-
|
18
|
-
|
26
|
+
it "contains the enum name" do
|
27
|
+
en.should match /enum foo/
|
28
|
+
end
|
29
|
+
|
30
|
+
it "contains an entry for each value" do
|
31
|
+
en.should match /AAA = 0,/
|
32
|
+
en.should match /BBB = 1,/
|
33
|
+
en.should match /QUICK_BROWN_FOX = 2,/
|
34
|
+
en.should match /};/
|
35
|
+
end
|
19
36
|
end
|
20
37
|
|
21
|
-
|
22
|
-
|
38
|
+
describe ".packer_defn" do
|
39
|
+
let(:en0) do
|
40
|
+
_e = Cauterize.enumeration(:foo) do |e|
|
41
|
+
e.value :aaa
|
42
|
+
e.value :bbb
|
43
|
+
e.value "QuickBrownFox".to_sym
|
44
|
+
end
|
45
|
+
|
46
|
+
f = default_formatter
|
47
|
+
Builders.get(:c, _e).packer_defn(f)
|
48
|
+
f.to_s
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:en1) do
|
52
|
+
_e = Cauterize.enumeration(:bar) do |e|
|
53
|
+
e.value :aaa, 500
|
54
|
+
e.value :bbb, -30
|
55
|
+
end
|
56
|
+
|
57
|
+
f = default_formatter
|
58
|
+
Builders.get(:c, _e).packer_defn(f)
|
59
|
+
f.to_s
|
60
|
+
end
|
61
|
+
|
62
|
+
it "defines a representation variable" do
|
63
|
+
en0.should match /int8_t enum_representation;/
|
64
|
+
en1.should match /int16_t enum_representation;/
|
65
|
+
end
|
66
|
+
|
67
|
+
it "references a packer for the representation" do
|
68
|
+
en0.should match /Pack_int8/
|
69
|
+
en1.should match /Pack_int16/
|
70
|
+
end
|
23
71
|
end
|
24
72
|
|
25
|
-
|
26
|
-
en
|
27
|
-
|
28
|
-
|
29
|
-
|
73
|
+
describe ".unpacker_defn" do
|
74
|
+
let(:en) do
|
75
|
+
_e = Cauterize.enumeration(:foo) do |e|
|
76
|
+
e.value :aaa
|
77
|
+
e.value :bbb
|
78
|
+
e.value "QuickBrownFox".to_sym
|
79
|
+
end
|
80
|
+
|
81
|
+
f = default_formatter
|
82
|
+
Builders.get(:c, _e).unpacker_defn(f)
|
83
|
+
f.to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
it "defines a representation variable" do
|
87
|
+
en.should match /int8_t enum_representation;/
|
88
|
+
end
|
89
|
+
|
90
|
+
it "references a unpacker for the representation" do
|
91
|
+
en.should match /Unpack_int8/
|
92
|
+
end
|
30
93
|
end
|
31
94
|
end
|
32
95
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
describe Cauterize::Builders::C::FixedArray do
|
2
2
|
let(:type_constructor) do
|
3
|
-
scalar(:uint32_t)
|
3
|
+
Cauterize.scalar(:uint32_t)
|
4
4
|
lambda do |name|
|
5
|
-
fixed_array(name) do |a|
|
5
|
+
Cauterize.fixed_array(name) do |a|
|
6
6
|
a.array_type :uint32_t
|
7
7
|
a.array_size 16
|
8
8
|
end
|
@@ -10,8 +10,8 @@ describe Cauterize::Builders::C::FixedArray do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it_behaves_like "a buildable"
|
13
|
+
it_behaves_like "a sane buildable"
|
13
14
|
include_examples "no enum"
|
14
|
-
include_examples "no struct"
|
15
15
|
|
16
16
|
context "an array buildable" do
|
17
17
|
let(:desc_instance) { type_constructor.call(:some_type_name) }
|
@@ -20,8 +20,8 @@ describe Cauterize::Builders::C::FixedArray do
|
|
20
20
|
|
21
21
|
describe :render do
|
22
22
|
it "contains the name" do
|
23
|
-
|
24
|
-
subject.render.should match /#{
|
23
|
+
name = subject.instance_variable_get(:@blueprint).name
|
24
|
+
subject.render.should match /#{name}/
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -29,7 +29,7 @@ describe Cauterize::Builders::C::FixedArray do
|
|
29
29
|
before { subject.declare(formatter, :some_sym) }
|
30
30
|
|
31
31
|
it "contains the name and a ;" do
|
32
|
-
formatter.to_s.should match /
|
32
|
+
formatter.to_s.should match /struct some_type_name some_sym;/
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -1,111 +1,118 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
it_behaves_like "a buildable"
|
5
|
-
it_behaves_like "a sane buildable"
|
6
|
-
include_examples "no enum"
|
7
|
-
|
8
|
-
context "enumeration for type tag" do
|
9
|
-
before do
|
10
|
-
scalar(:uint8_t)
|
11
|
-
@g = group!(:some_name) do |_g|
|
12
|
-
_g.field(:a, :uint8_t)
|
13
|
-
_g.field(:b, :uint8_t)
|
14
|
-
end
|
15
|
-
@b = Cauterize::Builders::C::Group.new(@g)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe ".initialize" do
|
19
|
-
it "creates the enumeration tag" do
|
20
|
-
@b.instance_variable_get(:@tag_enum).class.name.should == "Cauterize::Enumeration"
|
21
|
-
end
|
22
|
-
end
|
1
|
+
module Cauterize
|
2
|
+
describe Cauterize::Builders::C::Group do
|
3
|
+
let(:type_constructor) { lambda {|name| Cauterize.group(name)}}
|
23
4
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
e.values.keys.should =~ [ :GROUP_SOME_NAME_TYPE_A,
|
28
|
-
:GROUP_SOME_NAME_TYPE_B ]
|
29
|
-
end
|
30
|
-
end
|
5
|
+
it_behaves_like "a buildable"
|
6
|
+
it_behaves_like "a sane buildable"
|
7
|
+
include_examples "no enum"
|
31
8
|
|
32
|
-
|
9
|
+
context "enumeration for type tag" do
|
33
10
|
before do
|
34
|
-
|
35
|
-
@
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
@
|
41
|
-
end
|
42
|
-
|
43
|
-
it "contains each tag" do
|
44
|
-
@fs.should match /GROUP_SOME_NAME_TYPE_A/
|
45
|
-
@fs.should match /GROUP_SOME_NAME_TYPE_B/
|
11
|
+
Cauterize.scalar(:uint8_t)
|
12
|
+
@g = Cauterize.group!(:some_name) do |_g|
|
13
|
+
_g.field(:a, :uint8_t)
|
14
|
+
_g.field(:b, :uint8_t)
|
15
|
+
_g.field(:c)
|
16
|
+
end
|
17
|
+
@b = Cauterize::Builders::C::Group.new(@g)
|
46
18
|
end
|
47
19
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
describe ".unpacker_defn" do
|
55
|
-
before do
|
56
|
-
f = default_formatter
|
57
|
-
@b.unpacker_defn(f)
|
58
|
-
@fs = f.to_s
|
20
|
+
describe ".initialize" do
|
21
|
+
it "creates the enumeration tag" do
|
22
|
+
@b.instance_variable_get(:@tag_enum).class.name.should == "Cauterize::Enumeration"
|
23
|
+
end
|
59
24
|
end
|
60
25
|
|
61
|
-
|
62
|
-
|
26
|
+
describe "@tag_enum" do
|
27
|
+
it "contains a entry for each field in the group" do
|
28
|
+
e = @b.instance_variable_get(:@tag_enum)
|
29
|
+
e.values.keys.should =~ [ :GROUP_SOME_NAME_TYPE_A,
|
30
|
+
:GROUP_SOME_NAME_TYPE_B,
|
31
|
+
:GROUP_SOME_NAME_TYPE_C ]
|
32
|
+
end
|
63
33
|
end
|
64
34
|
|
65
|
-
|
66
|
-
|
67
|
-
|
35
|
+
describe ".packer_defn" do
|
36
|
+
before do
|
37
|
+
f = default_formatter
|
38
|
+
@b.packer_defn(f)
|
39
|
+
@fs = f.to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
it "contains the enum packer" do
|
43
|
+
@fs.should match /Pack_group_some_name_type/
|
44
|
+
end
|
45
|
+
|
46
|
+
it "contains each tag" do
|
47
|
+
@fs.should match /GROUP_SOME_NAME_TYPE_A/
|
48
|
+
@fs.should match /GROUP_SOME_NAME_TYPE_B/
|
49
|
+
@fs.should match /GROUP_SOME_NAME_TYPE_C/
|
50
|
+
end
|
51
|
+
|
52
|
+
it "contains each data field" do
|
53
|
+
@fs.should match /src->data\.a/
|
54
|
+
@fs.should match /src->data\.b/
|
55
|
+
end
|
68
56
|
end
|
69
57
|
|
70
|
-
|
71
|
-
|
72
|
-
|
58
|
+
describe ".unpacker_defn" do
|
59
|
+
before do
|
60
|
+
f = default_formatter
|
61
|
+
@b.unpacker_defn(f)
|
62
|
+
@fs = f.to_s
|
63
|
+
end
|
64
|
+
|
65
|
+
it "contains the enum unpacker" do
|
66
|
+
@fs.should match /Unpack_group_some_name_type/
|
67
|
+
end
|
68
|
+
|
69
|
+
it "contains each tag" do
|
70
|
+
@fs.should match /GROUP_SOME_NAME_TYPE_A/
|
71
|
+
@fs.should match /GROUP_SOME_NAME_TYPE_B/
|
72
|
+
@fs.should match /GROUP_SOME_NAME_TYPE_C/
|
73
|
+
end
|
74
|
+
|
75
|
+
it "contains each data field" do
|
76
|
+
@fs.should match /dst->data\.a/
|
77
|
+
@fs.should match /dst->data\.b/
|
78
|
+
end
|
73
79
|
end
|
74
80
|
end
|
75
|
-
end
|
76
81
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
context "structure definition" do
|
83
|
+
let(:grp) do
|
84
|
+
_g = Cauterize.group(:oof) do |g|
|
85
|
+
g.field(:aaa, :int32)
|
86
|
+
g.field(:bbb, :int32)
|
87
|
+
g.field(:empty)
|
88
|
+
end
|
84
89
|
|
85
|
-
|
86
|
-
|
90
|
+
Builders.get(:c, _g)
|
91
|
+
end
|
87
92
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
+
describe ".struct_proto" do
|
94
|
+
it "defines a structure prototype" do
|
95
|
+
f = default_formatter
|
96
|
+
grp.struct_proto(f)
|
97
|
+
f.to_s.should == "struct oof;"
|
98
|
+
end
|
93
99
|
end
|
94
|
-
end
|
95
100
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
101
|
+
describe ".struct_defn" do
|
102
|
+
it "defines a structure definition" do
|
103
|
+
f = default_formatter
|
104
|
+
grp.struct_defn(f)
|
105
|
+
fs = f.to_s
|
106
|
+
|
107
|
+
fs.should match /struct oof/
|
108
|
+
fs.should match /enum group_oof_type tag;/
|
109
|
+
fs.should match /union/
|
110
|
+
fs.should match /int32_t aaa;/ # built-in types are represented as their C type
|
111
|
+
fs.should match /int32_t bbb;/ # built-in types are represented as their C type
|
112
|
+
fs.should match /No data associated with 'empty'./
|
113
|
+
fs.should match /} data;/
|
114
|
+
fs.should match /};/
|
115
|
+
end
|
109
116
|
end
|
110
117
|
end
|
111
118
|
end
|