cauterize 0.0.1.pre13 → 0.0.1.pre14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +33 -33
- data/.rspec +1 -1
- data/.travisci.yml +4 -4
- data/Gemfile +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +177 -177
- data/Rakefile +54 -54
- data/bin/cauterize +61 -61
- data/cauterize.gemspec +27 -27
- data/example/Cauterize +68 -68
- data/example/build.sh +25 -25
- data/example/c_example_support/empty_main.c +1 -1
- data/example/c_example_support/example_project_config.c +11 -11
- data/example/c_example_support/example_project_config.h +15 -15
- data/example/ruby_ex.rb +14 -14
- data/lib/cauterize.rb +117 -117
- data/lib/cauterize/base_type.rb +78 -78
- data/lib/cauterize/builders.rb +41 -41
- data/lib/cauterize/builders/c/buildable.rb +91 -91
- data/lib/cauterize/builders/c/builtin.rb +43 -43
- data/lib/cauterize/builders/c/composite.rb +57 -57
- data/lib/cauterize/builders/c/enumeration.rb +60 -60
- data/lib/cauterize/builders/c/fixed_array.rb +74 -74
- data/lib/cauterize/builders/c/group.rb +143 -143
- data/lib/cauterize/builders/c/scalar.rb +34 -34
- data/lib/cauterize/builders/c/variable_array.rb +98 -98
- data/lib/cauterize/builders/cs/buildable.rb +59 -59
- data/lib/cauterize/builders/cs/builtin.rb +22 -22
- data/lib/cauterize/builders/cs/composite.rb +21 -21
- data/lib/cauterize/builders/cs/csarray.rb +32 -32
- data/lib/cauterize/builders/cs/enumeration.rb +21 -21
- data/lib/cauterize/builders/cs/fixed_array.rb +27 -27
- data/lib/cauterize/builders/cs/group.rb +32 -32
- data/lib/cauterize/builders/cs/scalar.rb +10 -10
- data/lib/cauterize/builders/cs/variable_array.rb +40 -34
- data/lib/cauterize/builders/doc/buildable.rb +30 -30
- data/lib/cauterize/builders/doc/builtin.rb +21 -21
- data/lib/cauterize/builders/doc/composite.rb +23 -23
- data/lib/cauterize/builders/doc/enumeration.rb +24 -24
- data/lib/cauterize/builders/doc/fixed_array.rb +26 -26
- data/lib/cauterize/builders/doc/group.rb +29 -29
- data/lib/cauterize/builders/doc/scalar.rb +21 -21
- data/lib/cauterize/builders/doc/variable_array.rb +26 -26
- data/lib/cauterize/builders/ruby/buildable.rb +11 -11
- data/lib/cauterize/builders/ruby/builtin.rb +25 -25
- data/lib/cauterize/builders/ruby/composite.rb +26 -26
- data/lib/cauterize/builders/ruby/enumeration.rb +27 -27
- data/lib/cauterize/builders/ruby/fixed_array.rb +20 -20
- data/lib/cauterize/builders/ruby/group.rb +35 -35
- data/lib/cauterize/builders/ruby/scalar.rb +19 -19
- data/lib/cauterize/builders/ruby/variable_array.rb +22 -22
- data/lib/cauterize/builtin.rb +62 -62
- data/lib/cauterize/c_builder.rb +103 -103
- data/lib/cauterize/cauterize.rb +76 -76
- data/lib/cauterize/composite.rb +64 -64
- data/lib/cauterize/cs_builder.rb +58 -58
- data/lib/cauterize/doc_builder.rb +34 -34
- data/lib/cauterize/enumeration.rb +98 -98
- data/lib/cauterize/fixed_array.rb +50 -50
- data/lib/cauterize/formatter.rb +67 -67
- data/lib/cauterize/group.rb +81 -81
- data/lib/cauterize/representation.rb +32 -32
- data/lib/cauterize/ruby_builder.rb +44 -44
- data/lib/cauterize/scalar.rb +53 -53
- data/lib/cauterize/snake_case.rb +21 -21
- data/lib/cauterize/variable_array.rb +55 -55
- data/lib/cauterize/version.rb +3 -3
- data/spec/base_type_spec.rb +251 -251
- data/spec/builders/c/buildable_spec.rb +25 -25
- data/spec/builders/c/builtin_spec.rb +22 -22
- data/spec/builders/c/composite_spec.rb +50 -50
- data/spec/builders/c/enumeration_spec.rb +95 -95
- data/spec/builders/c/fixed_array_spec.rb +36 -36
- data/spec/builders/c/group_spec.rb +140 -140
- data/spec/builders/c/scalar_spec.rb +26 -26
- data/spec/builders/c/variable_array_spec.rb +48 -48
- data/spec/builders/cs/buildable_spec.rb +8 -8
- data/spec/builders/cs/composite_spec.rb +32 -32
- data/spec/builders/cs/enumeration_spec.rb +33 -33
- data/spec/builders/cs/fixed_array_spec.rb +41 -41
- data/spec/builders/cs/group_spec.rb +56 -56
- data/spec/builders/cs/scalar_spec.rb +7 -7
- data/spec/builders/cs/variable_array_spec.rb +49 -45
- data/spec/builders/doc/buildable_spec.rb +25 -25
- data/spec/builders_spec.rb +57 -57
- data/spec/builtin_spec.rb +43 -43
- data/spec/c_builder_spec.rb +176 -176
- data/spec/cauterize_spec.rb +15 -15
- data/spec/composite_spec.rb +77 -77
- data/spec/cs_builder_spec.rb +115 -115
- data/spec/doc_builder_spec.rb +260 -260
- data/spec/enumeration_spec.rb +145 -145
- data/spec/fixed_array_spec.rb +61 -61
- data/spec/group_spec.rb +111 -111
- data/spec/ruby_builder_spec.rb +83 -83
- data/spec/ruby_generated_spec.rb +735 -735
- data/spec/scalar_spec.rb +44 -44
- data/spec/spec_helper.rb +122 -122
- data/spec/support/shared_examples_for_array_buildables.rb +22 -22
- data/spec/support/shared_examples_for_c_buildables.rb +103 -103
- data/spec/support/shared_examples_for_sane_c_buildables.rb +22 -22
- data/spec/support/shared_examples_for_stubbed_functions.rb +18 -18
- data/spec/support/spec_sample_model.rb +74 -74
- data/spec/test_main.c +13 -13
- data/spec/variable_array_spec.rb +73 -73
- data/support/c/src/cauterize.c +75 -75
- data/support/c/src/cauterize.h +60 -60
- data/support/c/src/cauterize_debug.h +29 -29
- data/support/c/src/cauterize_util.h +8 -8
- data/support/c/test/greatest.h +536 -536
- data/support/c/test/test.c +166 -166
- data/support/cs/src/CauterizeCompositeFormatter.cs +0 -0
- data/support/cs/src/CauterizeContainerFormatter.cs +0 -0
- data/support/cs/src/CauterizeEnumFormatter.cs +0 -0
- data/support/cs/src/CauterizeException.cs +15 -15
- data/support/cs/src/CauterizeFixedArrayFormatter.cs +2 -2
- data/support/cs/src/CauterizeFormatter.cs +0 -0
- data/support/cs/src/CauterizeGroupFormatter.cs +0 -0
- data/support/cs/src/CauterizeTypeFormatterFactory.cs +0 -0
- data/support/cs/src/CauterizeTypes.cs +46 -12
- data/support/cs/src/CauterizeVariableArrayFormatter.cs +1 -1
- data/support/cs/src/ICauterizeTypeFormatter.cs +0 -0
- data/support/cs/src/OrderAttribute.cs +0 -0
- data/support/cs/src/PrimitiveSupport.cs +12 -0
- data/support/cs/test/CauterizeCompositeFormatterTest.cs +0 -0
- data/support/cs/test/CauterizeEnumFormatterTest.cs +0 -0
- data/support/cs/test/CauterizeFixedArrayFormatterTest.cs +0 -0
- data/support/cs/test/CauterizeFormatterTest.cs +0 -0
- data/support/cs/test/CauterizeGroupFormatterTest.cs +0 -0
- data/support/cs/test/CauterizeIntegrationTest.cs +0 -0
- data/support/cs/test/CauterizePrimitiveFormatterTest.cs +0 -0
- data/support/cs/test/CauterizeTypeFormatterFactoryTest.cs +0 -0
- data/support/cs/test/CauterizeVariableArrayFormatterTest.cs +0 -0
- data/support/cs/test/OrderAttributeTest.cs +0 -0
- data/support/ruby/src/cauterize_ruby_baseclasses.rb +367 -367
- data/support/ruby/src/cauterize_ruby_builtins.rb +148 -148
- metadata +20 -20
@@ -1,140 +1,140 @@
|
|
1
|
-
module Cauterize
|
2
|
-
describe Cauterize::Builders::C::Group do
|
3
|
-
let(:type_constructor) { lambda {|name| Cauterize.group(name)}}
|
4
|
-
|
5
|
-
it_behaves_like "a buildable"
|
6
|
-
it_behaves_like "a sane buildable"
|
7
|
-
include_examples "no enum"
|
8
|
-
|
9
|
-
context "enumeration for type tag" do
|
10
|
-
before do
|
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.dataless(:c)
|
16
|
-
end
|
17
|
-
@b = Cauterize::Builders::C::Group.new(@g)
|
18
|
-
end
|
19
|
-
|
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
|
24
|
-
end
|
25
|
-
|
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
|
33
|
-
end
|
34
|
-
|
35
|
-
describe ".preprocessor_defines" do
|
36
|
-
before do
|
37
|
-
f = default_formatter
|
38
|
-
@b.preprocessor_defines(f)
|
39
|
-
@fs = f.to_s
|
40
|
-
end
|
41
|
-
|
42
|
-
it "contains the maximum encoded length definition" do
|
43
|
-
@fs.should match /MAX_ENCODED_LENGTH_some_name/
|
44
|
-
end
|
45
|
-
|
46
|
-
it "includes the group length in the max encoded length" do
|
47
|
-
@fs.should match /MAX_ENCODED_LENGTH_some_name.+MAX_ENCODED_LENGTH_group_some_name_type/
|
48
|
-
end
|
49
|
-
|
50
|
-
it "includes the length of type synonyms 'a', 'b' in the max encoded length" do
|
51
|
-
@fs.should match /MAX_ENCODED_LENGTH_some_name.+MAX_ENCODED_LENGTH_uint8/
|
52
|
-
@fs.should match /MAX_ENCODED_LENGTH_some_name.+MAX_ENCODED_LENGTH_uint8/
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe ".packer_defn" do
|
57
|
-
before do
|
58
|
-
f = default_formatter
|
59
|
-
@b.packer_defn(f)
|
60
|
-
@fs = f.to_s
|
61
|
-
end
|
62
|
-
|
63
|
-
it "contains the enum packer" do
|
64
|
-
@fs.should match /Pack_group_some_name_type/
|
65
|
-
end
|
66
|
-
|
67
|
-
it "contains each tag" do
|
68
|
-
@fs.should match /GROUP_SOME_NAME_TYPE_A/
|
69
|
-
@fs.should match /GROUP_SOME_NAME_TYPE_B/
|
70
|
-
@fs.should match /GROUP_SOME_NAME_TYPE_C/
|
71
|
-
end
|
72
|
-
|
73
|
-
it "contains each data field" do
|
74
|
-
@fs.should match /src->data\.a/
|
75
|
-
@fs.should match /src->data\.b/
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe ".unpacker_defn" do
|
80
|
-
before do
|
81
|
-
f = default_formatter
|
82
|
-
@b.unpacker_defn(f)
|
83
|
-
@fs = f.to_s
|
84
|
-
end
|
85
|
-
|
86
|
-
it "contains the enum unpacker" do
|
87
|
-
@fs.should match /Unpack_group_some_name_type/
|
88
|
-
end
|
89
|
-
|
90
|
-
it "contains each tag" do
|
91
|
-
@fs.should match /GROUP_SOME_NAME_TYPE_A/
|
92
|
-
@fs.should match /GROUP_SOME_NAME_TYPE_B/
|
93
|
-
@fs.should match /GROUP_SOME_NAME_TYPE_C/
|
94
|
-
end
|
95
|
-
|
96
|
-
it "contains each data field" do
|
97
|
-
@fs.should match /dst->data\.a/
|
98
|
-
@fs.should match /dst->data\.b/
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
context "structure definition" do
|
104
|
-
let(:grp) do
|
105
|
-
_g = Cauterize.group(:oof) do |g|
|
106
|
-
g.field(:aaa, :int32)
|
107
|
-
g.field(:bbb, :int32)
|
108
|
-
g.dataless(:empty)
|
109
|
-
end
|
110
|
-
|
111
|
-
Builders.get(:c, _g)
|
112
|
-
end
|
113
|
-
|
114
|
-
describe ".struct_proto" do
|
115
|
-
it "defines a structure prototype" do
|
116
|
-
f = default_formatter
|
117
|
-
grp.struct_proto(f)
|
118
|
-
f.to_s.should == "struct oof;"
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe ".struct_defn" do
|
123
|
-
it "defines a structure definition" do
|
124
|
-
f = default_formatter
|
125
|
-
grp.struct_defn(f)
|
126
|
-
fs = f.to_s
|
127
|
-
|
128
|
-
fs.should match /struct oof/
|
129
|
-
fs.should match /enum group_oof_type tag;/
|
130
|
-
fs.should match /union/
|
131
|
-
fs.should match /int32_t aaa;/ # built-in types are represented as their C type
|
132
|
-
fs.should match /int32_t bbb;/ # built-in types are represented as their C type
|
133
|
-
fs.should match /No data associated with 'empty'./
|
134
|
-
fs.should match /} data;/
|
135
|
-
fs.should match /};/
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
1
|
+
module Cauterize
|
2
|
+
describe Cauterize::Builders::C::Group do
|
3
|
+
let(:type_constructor) { lambda {|name| Cauterize.group(name)}}
|
4
|
+
|
5
|
+
it_behaves_like "a buildable"
|
6
|
+
it_behaves_like "a sane buildable"
|
7
|
+
include_examples "no enum"
|
8
|
+
|
9
|
+
context "enumeration for type tag" do
|
10
|
+
before do
|
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.dataless(:c)
|
16
|
+
end
|
17
|
+
@b = Cauterize::Builders::C::Group.new(@g)
|
18
|
+
end
|
19
|
+
|
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
|
24
|
+
end
|
25
|
+
|
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
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".preprocessor_defines" do
|
36
|
+
before do
|
37
|
+
f = default_formatter
|
38
|
+
@b.preprocessor_defines(f)
|
39
|
+
@fs = f.to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
it "contains the maximum encoded length definition" do
|
43
|
+
@fs.should match /MAX_ENCODED_LENGTH_some_name/
|
44
|
+
end
|
45
|
+
|
46
|
+
it "includes the group length in the max encoded length" do
|
47
|
+
@fs.should match /MAX_ENCODED_LENGTH_some_name.+MAX_ENCODED_LENGTH_group_some_name_type/
|
48
|
+
end
|
49
|
+
|
50
|
+
it "includes the length of type synonyms 'a', 'b' in the max encoded length" do
|
51
|
+
@fs.should match /MAX_ENCODED_LENGTH_some_name.+MAX_ENCODED_LENGTH_uint8/
|
52
|
+
@fs.should match /MAX_ENCODED_LENGTH_some_name.+MAX_ENCODED_LENGTH_uint8/
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe ".packer_defn" do
|
57
|
+
before do
|
58
|
+
f = default_formatter
|
59
|
+
@b.packer_defn(f)
|
60
|
+
@fs = f.to_s
|
61
|
+
end
|
62
|
+
|
63
|
+
it "contains the enum packer" do
|
64
|
+
@fs.should match /Pack_group_some_name_type/
|
65
|
+
end
|
66
|
+
|
67
|
+
it "contains each tag" do
|
68
|
+
@fs.should match /GROUP_SOME_NAME_TYPE_A/
|
69
|
+
@fs.should match /GROUP_SOME_NAME_TYPE_B/
|
70
|
+
@fs.should match /GROUP_SOME_NAME_TYPE_C/
|
71
|
+
end
|
72
|
+
|
73
|
+
it "contains each data field" do
|
74
|
+
@fs.should match /src->data\.a/
|
75
|
+
@fs.should match /src->data\.b/
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe ".unpacker_defn" do
|
80
|
+
before do
|
81
|
+
f = default_formatter
|
82
|
+
@b.unpacker_defn(f)
|
83
|
+
@fs = f.to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
it "contains the enum unpacker" do
|
87
|
+
@fs.should match /Unpack_group_some_name_type/
|
88
|
+
end
|
89
|
+
|
90
|
+
it "contains each tag" do
|
91
|
+
@fs.should match /GROUP_SOME_NAME_TYPE_A/
|
92
|
+
@fs.should match /GROUP_SOME_NAME_TYPE_B/
|
93
|
+
@fs.should match /GROUP_SOME_NAME_TYPE_C/
|
94
|
+
end
|
95
|
+
|
96
|
+
it "contains each data field" do
|
97
|
+
@fs.should match /dst->data\.a/
|
98
|
+
@fs.should match /dst->data\.b/
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "structure definition" do
|
104
|
+
let(:grp) do
|
105
|
+
_g = Cauterize.group(:oof) do |g|
|
106
|
+
g.field(:aaa, :int32)
|
107
|
+
g.field(:bbb, :int32)
|
108
|
+
g.dataless(:empty)
|
109
|
+
end
|
110
|
+
|
111
|
+
Builders.get(:c, _g)
|
112
|
+
end
|
113
|
+
|
114
|
+
describe ".struct_proto" do
|
115
|
+
it "defines a structure prototype" do
|
116
|
+
f = default_formatter
|
117
|
+
grp.struct_proto(f)
|
118
|
+
f.to_s.should == "struct oof;"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe ".struct_defn" do
|
123
|
+
it "defines a structure definition" do
|
124
|
+
f = default_formatter
|
125
|
+
grp.struct_defn(f)
|
126
|
+
fs = f.to_s
|
127
|
+
|
128
|
+
fs.should match /struct oof/
|
129
|
+
fs.should match /enum group_oof_type tag;/
|
130
|
+
fs.should match /union/
|
131
|
+
fs.should match /int32_t aaa;/ # built-in types are represented as their C type
|
132
|
+
fs.should match /int32_t bbb;/ # built-in types are represented as their C type
|
133
|
+
fs.should match /No data associated with 'empty'./
|
134
|
+
fs.should match /} data;/
|
135
|
+
fs.should match /};/
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
module Cauterize
|
2
|
-
describe Cauterize::Builders::C::Scalar do
|
3
|
-
let(:type_constructor) {
|
4
|
-
lambda {
|
5
|
-
|name| Cauterize.scalar(name) {
|
6
|
-
|t| t.type_name(:int32)
|
7
|
-
}
|
8
|
-
}
|
9
|
-
}
|
10
|
-
|
11
|
-
describe ".typedef_decl" do
|
12
|
-
it "declares the type synonym" do
|
13
|
-
s = Cauterize.scalar(:zeep) {|t| t.type_name(:int32)}
|
14
|
-
|
15
|
-
f = default_formatter
|
16
|
-
Builders.get(:c, s).typedef_decl(f)
|
17
|
-
f.to_s.should == "typedef int32_t zeep;"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it_behaves_like "a buildable"
|
22
|
-
it_behaves_like "a sane buildable"
|
23
|
-
include_examples "no enum"
|
24
|
-
include_examples "no struct"
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module Cauterize
|
2
|
+
describe Cauterize::Builders::C::Scalar do
|
3
|
+
let(:type_constructor) {
|
4
|
+
lambda {
|
5
|
+
|name| Cauterize.scalar(name) {
|
6
|
+
|t| t.type_name(:int32)
|
7
|
+
}
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
describe ".typedef_decl" do
|
12
|
+
it "declares the type synonym" do
|
13
|
+
s = Cauterize.scalar(:zeep) {|t| t.type_name(:int32)}
|
14
|
+
|
15
|
+
f = default_formatter
|
16
|
+
Builders.get(:c, s).typedef_decl(f)
|
17
|
+
f.to_s.should == "typedef int32_t zeep;"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it_behaves_like "a buildable"
|
22
|
+
it_behaves_like "a sane buildable"
|
23
|
+
include_examples "no enum"
|
24
|
+
include_examples "no struct"
|
25
|
+
end
|
26
|
+
end
|
@@ -1,48 +1,48 @@
|
|
1
|
-
module Cauterize
|
2
|
-
describe Cauterize::Builders::C::VariableArray do
|
3
|
-
let(:type_constructor) do
|
4
|
-
lambda do |name|
|
5
|
-
Cauterize.variable_array(name) do |a|
|
6
|
-
a.array_type(:uint8)
|
7
|
-
a.array_size(8)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
it_behaves_like "a buildable"
|
13
|
-
it_behaves_like "a sane buildable"
|
14
|
-
include_examples "no enum"
|
15
|
-
|
16
|
-
context "structure definition" do
|
17
|
-
let(:vara) do
|
18
|
-
_a = Cauterize.variable_array(:va) do |a|
|
19
|
-
a.array_size(700000)
|
20
|
-
a.array_type(:int32)
|
21
|
-
end
|
22
|
-
|
23
|
-
Builders.get(:c, _a)
|
24
|
-
end
|
25
|
-
|
26
|
-
describe ".struct_proto" do
|
27
|
-
it "defines a structure prototype" do
|
28
|
-
f = default_formatter
|
29
|
-
vara.struct_proto(f)
|
30
|
-
f.to_s.should == "struct va;"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe ".struct_defn" do
|
35
|
-
it "defines a structure definition" do
|
36
|
-
f = default_formatter
|
37
|
-
vara.struct_defn(f)
|
38
|
-
fs = f.to_s
|
39
|
-
|
40
|
-
fs.should match /struct va/
|
41
|
-
fs.should match /int32_t length;/
|
42
|
-
fs.should match /int32_t data\[700000\];/
|
43
|
-
fs.should match /};/
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
1
|
+
module Cauterize
|
2
|
+
describe Cauterize::Builders::C::VariableArray do
|
3
|
+
let(:type_constructor) do
|
4
|
+
lambda do |name|
|
5
|
+
Cauterize.variable_array(name) do |a|
|
6
|
+
a.array_type(:uint8)
|
7
|
+
a.array_size(8)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it_behaves_like "a buildable"
|
13
|
+
it_behaves_like "a sane buildable"
|
14
|
+
include_examples "no enum"
|
15
|
+
|
16
|
+
context "structure definition" do
|
17
|
+
let(:vara) do
|
18
|
+
_a = Cauterize.variable_array(:va) do |a|
|
19
|
+
a.array_size(700000)
|
20
|
+
a.array_type(:int32)
|
21
|
+
end
|
22
|
+
|
23
|
+
Builders.get(:c, _a)
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".struct_proto" do
|
27
|
+
it "defines a structure prototype" do
|
28
|
+
f = default_formatter
|
29
|
+
vara.struct_proto(f)
|
30
|
+
f.to_s.should == "struct va;"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe ".struct_defn" do
|
35
|
+
it "defines a structure definition" do
|
36
|
+
f = default_formatter
|
37
|
+
vara.struct_defn(f)
|
38
|
+
fs = f.to_s
|
39
|
+
|
40
|
+
fs.should match /struct va/
|
41
|
+
fs.should match /int32_t length;/
|
42
|
+
fs.should match /int32_t data\[700000\];/
|
43
|
+
fs.should match /};/
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
include Cauterize::Builders::CS
|
2
|
-
|
3
|
-
describe Cauterize::Builders::CS do
|
4
|
-
describe Buildable do
|
5
|
-
subject { Buildable.new(:some_blueprint) }
|
6
|
-
pending "nothing to test until packing"
|
7
|
-
end
|
8
|
-
end
|
1
|
+
include Cauterize::Builders::CS
|
2
|
+
|
3
|
+
describe Cauterize::Builders::CS do
|
4
|
+
describe Buildable do
|
5
|
+
subject { Buildable.new(:some_blueprint) }
|
6
|
+
pending "nothing to test until packing"
|
7
|
+
end
|
8
|
+
end
|
@@ -1,32 +1,32 @@
|
|
1
|
-
module Cauterize
|
2
|
-
describe Cauterize::Builders::CS::Composite do
|
3
|
-
context "class definition" do
|
4
|
-
let(:comp) do
|
5
|
-
Cauterize.scalar(:int32_t) {|t| t.type_name(:int32) }
|
6
|
-
Cauterize.scalar(:int16_t) {|t| t.type_name(:int16) }
|
7
|
-
_c = Cauterize.composite(:foo) do |c|
|
8
|
-
c.field(:an_int, :int32_t)
|
9
|
-
c.field(:a_short, :int16_t)
|
10
|
-
end
|
11
|
-
|
12
|
-
Builders.get(:cs, _c)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe ".class_defn" do
|
16
|
-
it "defines a class for the composite" do
|
17
|
-
f = four_space_formatter
|
18
|
-
comp.class_defn(f)
|
19
|
-
f.to_s.should == <<EOS
|
20
|
-
public class Foo : CauterizeComposite
|
21
|
-
{
|
22
|
-
[Order(0)]
|
23
|
-
public Int32 AnInt { get; set; }
|
24
|
-
[Order(1)]
|
25
|
-
public Int16 AShort { get; set; }
|
26
|
-
}
|
27
|
-
EOS
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
1
|
+
module Cauterize
|
2
|
+
describe Cauterize::Builders::CS::Composite do
|
3
|
+
context "class definition" do
|
4
|
+
let(:comp) do
|
5
|
+
Cauterize.scalar(:int32_t) {|t| t.type_name(:int32) }
|
6
|
+
Cauterize.scalar(:int16_t) {|t| t.type_name(:int16) }
|
7
|
+
_c = Cauterize.composite(:foo) do |c|
|
8
|
+
c.field(:an_int, :int32_t)
|
9
|
+
c.field(:a_short, :int16_t)
|
10
|
+
end
|
11
|
+
|
12
|
+
Builders.get(:cs, _c)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".class_defn" do
|
16
|
+
it "defines a class for the composite" do
|
17
|
+
f = four_space_formatter
|
18
|
+
comp.class_defn(f)
|
19
|
+
f.to_s.should == <<EOS
|
20
|
+
public class Foo : CauterizeComposite
|
21
|
+
{
|
22
|
+
[Order(0)]
|
23
|
+
public Int32 AnInt { get; set; }
|
24
|
+
[Order(1)]
|
25
|
+
public Int16 AShort { get; set; }
|
26
|
+
}
|
27
|
+
EOS
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|