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.
Files changed (102) hide show
  1. data/.gitignore +5 -0
  2. data/.rspec +1 -1
  3. data/Gemfile +1 -1
  4. data/README.md +0 -2
  5. data/Rakefile +19 -3
  6. data/bin/cauterize +14 -6
  7. data/example/Cauterize +22 -10
  8. data/example/build.sh +15 -2
  9. data/lib/cauterize/base_type.rb +2 -5
  10. data/lib/cauterize/builders.rb +1 -3
  11. data/lib/cauterize/builders/c/buildable.rb +3 -2
  12. data/lib/cauterize/builders/c/builtin.rb +46 -0
  13. data/lib/cauterize/builders/c/enumeration.rb +23 -2
  14. data/lib/cauterize/builders/c/fixed_array.rb +16 -7
  15. data/lib/cauterize/builders/c/group.rb +32 -3
  16. data/lib/cauterize/builders/c/scalar.rb +5 -0
  17. data/lib/cauterize/builders/c/variable_array.rb +1 -1
  18. data/lib/cauterize/builders/cs/buildable.rb +59 -0
  19. data/lib/cauterize/builders/cs/builtin.rb +23 -0
  20. data/lib/cauterize/builders/cs/composite.rb +21 -0
  21. data/lib/cauterize/builders/cs/csarray.rb +32 -0
  22. data/lib/cauterize/builders/cs/enumeration.rb +21 -0
  23. data/lib/cauterize/builders/cs/fixed_array.rb +25 -0
  24. data/lib/cauterize/builders/cs/group.rb +33 -0
  25. data/lib/cauterize/builders/cs/scalar.rb +10 -0
  26. data/lib/cauterize/builders/cs/variable_array.rb +34 -0
  27. data/lib/cauterize/builtin.rb +52 -0
  28. data/lib/cauterize/c_builder.rb +15 -1
  29. data/lib/cauterize/cauterize.rb +44 -13
  30. data/lib/cauterize/composite.rb +3 -3
  31. data/lib/cauterize/cs_builder.rb +53 -0
  32. data/lib/cauterize/enumeration.rb +20 -3
  33. data/lib/cauterize/fixed_array.rb +3 -3
  34. data/lib/cauterize/formatter.rb +7 -3
  35. data/lib/cauterize/group.rb +5 -8
  36. data/lib/cauterize/scalar.rb +16 -7
  37. data/lib/cauterize/variable_array.rb +6 -6
  38. data/lib/cauterize/version.rb +1 -1
  39. data/spec/base_type_spec.rb +133 -125
  40. data/spec/builders/c/buildable_spec.rb +18 -18
  41. data/spec/builders/c/builtin_spec.rb +22 -0
  42. data/spec/builders/c/composite_spec.rb +37 -33
  43. data/spec/builders/c/enumeration_spec.rb +84 -21
  44. data/spec/builders/c/fixed_array_spec.rb +6 -6
  45. data/spec/builders/c/group_spec.rb +97 -90
  46. data/spec/builders/c/scalar_spec.rb +24 -6
  47. data/spec/builders/c/variable_array_spec.rb +37 -37
  48. data/spec/builders/cs/buildable_spec.rb +8 -0
  49. data/spec/builders/cs/composite_spec.rb +32 -0
  50. data/spec/builders/cs/enumeration_spec.rb +33 -0
  51. data/spec/builders/cs/fixed_array_spec.rb +40 -0
  52. data/spec/builders/cs/group_spec.rb +56 -0
  53. data/spec/builders/cs/scalar_spec.rb +7 -0
  54. data/spec/builders/cs/variable_array_spec.rb +46 -0
  55. data/spec/builders_spec.rb +38 -38
  56. data/spec/builtin_spec.rb +46 -0
  57. data/spec/c_builder_spec.rb +116 -102
  58. data/spec/cauterize_spec.rb +8 -1
  59. data/spec/composite_spec.rb +52 -48
  60. data/spec/cs_builder_spec.rb +113 -0
  61. data/spec/enumeration_spec.rb +55 -16
  62. data/spec/fixed_array_spec.rb +7 -9
  63. data/spec/group_spec.rb +81 -76
  64. data/spec/scalar_spec.rb +20 -10
  65. data/spec/spec_helper.rb +103 -94
  66. data/spec/support/shared_examples_for_c_buildables.rb +68 -64
  67. data/spec/variable_array_spec.rb +12 -17
  68. data/{c → support/c}/src/cauterize.c +8 -7
  69. data/support/c/src/cauterize.h +59 -0
  70. data/{c → support/c}/src/cauterize_debug.h +0 -0
  71. data/support/c/src/cauterize_util.h +49 -0
  72. data/{c → support/c}/test/greatest.h +0 -0
  73. data/{c → support/c}/test/test.c +0 -0
  74. data/support/cs/src/CauterizeCompositeFormatter.cs +34 -0
  75. data/support/cs/src/CauterizeContainerFormatter.cs +18 -0
  76. data/support/cs/src/CauterizeEnumFormatter.cs +67 -0
  77. data/support/cs/src/CauterizeException.cs +15 -0
  78. data/support/cs/src/CauterizeFixedArrayFormatter.cs +39 -0
  79. data/support/cs/src/CauterizeFormatter.cs +40 -0
  80. data/support/cs/src/CauterizeGroupFormatter.cs +46 -0
  81. data/support/cs/src/CauterizePrimitiveFormatter.cs +33 -0
  82. data/support/cs/src/CauterizeTypeFormatterFactory.cs +39 -0
  83. data/support/cs/src/CauterizeTypes.cs +107 -0
  84. data/support/cs/src/CauterizeVariableArrayFormatter.cs +49 -0
  85. data/support/cs/src/ICauterizeTypeFormatter.cs +12 -0
  86. data/support/cs/src/OrderAttribute.cs +50 -0
  87. data/support/cs/src/PrimitiveSupport.cs +134 -0
  88. data/support/cs/src/SerializedRepresentationAttribute.cs +24 -0
  89. data/support/cs/test/CauterizeCompositeFormatterTest.cs +59 -0
  90. data/support/cs/test/CauterizeEnumFormatterTest.cs +110 -0
  91. data/support/cs/test/CauterizeFixedArrayFormatterTest.cs +91 -0
  92. data/support/cs/test/CauterizeFormatterTest.cs +40 -0
  93. data/support/cs/test/CauterizeGroupFormatterTest.cs +147 -0
  94. data/support/cs/test/CauterizeIntegrationTest.cs +129 -0
  95. data/support/cs/test/CauterizePrimitiveFormatterTest.cs +98 -0
  96. data/support/cs/test/CauterizeTypeFormatterFactoryTest.cs +73 -0
  97. data/support/cs/test/CauterizeVariableArrayFormatterTest.cs +130 -0
  98. data/support/cs/test/OrderAttributeTest.cs +39 -0
  99. data/support/cs/test/SerializedRepresentationAttributeTest.cs +39 -0
  100. metadata +68 -10
  101. data/c/src/cauterize.h +0 -46
  102. data/c/src/cauterize_util.h +0 -7
@@ -6,16 +6,16 @@ module Cauterize
6
6
  module_function
7
7
 
8
8
  def composite(name)
9
- c = composites[name] || composites[name] = Composite.new(name)
9
+ c = Cauterize.composites[name] || Cauterize.composites[name] = Composite.new(name)
10
10
  yield c if block_given?
11
11
  return c
12
12
  end
13
13
 
14
14
  def composite!(name, &blk)
15
- if composites[name]
15
+ if Cauterize.composites[name]
16
16
  raise Exception.new("Composite with name #{name} already exists.")
17
17
  else
18
- composite(name, &blk)
18
+ Cauterize.composite(name, &blk)
19
19
  end
20
20
  end
21
21
 
@@ -0,0 +1,53 @@
1
+ require 'time'
2
+
3
+ module Cauterize
4
+ class CSBuilder
5
+ attr_reader :cs
6
+
7
+ def initialize(cs_file, name="cauterize")
8
+ @cs = cs_file
9
+ @name = name.camel
10
+ end
11
+
12
+ def build
13
+ build_cs
14
+ end
15
+
16
+ private
17
+
18
+ def build_cs
19
+ f = four_space_formatter
20
+
21
+ f << "using System;"
22
+ f << "using Cauterize;"
23
+ f.blank_line
24
+ f << "namespace #{@name}"
25
+ f.braces do
26
+ f << "public class #{@name}CauterizeInfo : CauterizeInfo"
27
+ f.braces do
28
+ f << "static #{@name}CauterizeInfo()"
29
+ f.braces do
30
+ f << "Name = \"#{@name}\";"
31
+ f << "GeneratedVersion = \"#{Cauterize.get_version}\";"
32
+ f << "GeneratedDate = \"#{Cauterize.get_version}\";"
33
+ end
34
+ end
35
+ f.blank_line
36
+
37
+ instances = BaseType.all_instances
38
+ builders = instances.map {|i| Builders.get(:cs, i)}
39
+
40
+ builders.each { |b| b.enum_defn(f) }
41
+ builders.each { |b| b.class_defn(f) }
42
+ # # should we really do these, or is it annotations and a custom
43
+ # # formatter in support???
44
+ # builders.each { |b| b.packer_defn(f) }
45
+ # builders.each { |b| b.unpacker_defn(f) }
46
+ end
47
+
48
+ File.open(@cs, "wb") do |fh|
49
+ fh.write(f.to_s)
50
+ end
51
+ end
52
+ end
53
+ end
@@ -7,16 +7,16 @@ require 'set'
7
7
  module Cauterize
8
8
  module_function
9
9
  def enumeration(name)
10
- e = enumerations[name] || enumerations[name] = Enumeration.new(name)
10
+ e = Cauterize.enumerations[name] || Cauterize.enumerations[name] = Enumeration.new(name)
11
11
  yield e if block_given?
12
12
  return e
13
13
  end
14
14
 
15
15
  def enumeration!(name, &blk)
16
- if enumerations[name]
16
+ if Cauterize.enumerations[name]
17
17
  raise Exception.new("Enumeration with name #{name} already exists.")
18
18
  else
19
- enumeration(name, &blk)
19
+ Cauterize.enumeration(name, &blk)
20
20
  end
21
21
  end
22
22
 
@@ -53,6 +53,23 @@ module Cauterize
53
53
  @values[name] = EnumerationValue.new(name, next_id)
54
54
  end
55
55
 
56
+ def representation
57
+ max_val = @values.values.map(&:value).max
58
+ min_val = @values.values.map(&:value).min
59
+
60
+ if -128 <= min_val and max_val <= 127
61
+ BaseType.find_type!(:int8)
62
+ elsif (-32768 <= min_val and max_val <= 32767)
63
+ BaseType.find_type!(:int16)
64
+ elsif (-2147483648 <= min_val and max_val <= 2147483647)
65
+ BaseType.find_type!(:int32)
66
+ elsif (-9223372036854775808 <= min_val and max_val <= 9223372036854775807)
67
+ BaseType.find_type!(:int64)
68
+ else
69
+ raise Exception.new("Unable to represent enumeration (#{min_val} -> #{max_val})")
70
+ end
71
+ end
72
+
56
73
  private
57
74
 
58
75
  def value_id(next_id=nil)
@@ -2,16 +2,16 @@ module Cauterize
2
2
  module_function
3
3
 
4
4
  def fixed_array(name)
5
- a = fixed_arrays[name] || fixed_arrays[name] = FixedArray.new(name)
5
+ a = Cauterize.fixed_arrays[name] || Cauterize.fixed_arrays[name] = FixedArray.new(name)
6
6
  yield a if block_given?
7
7
  return a
8
8
  end
9
9
 
10
10
  def fixed_array!(name, &blk)
11
- if fixed_arrays[name]
11
+ if Cauterize.fixed_arrays[name]
12
12
  raise Exception.new("FixedArray with name #{name} already exists.")
13
13
  else
14
- fixed_array(name, &blk)
14
+ Cauterize.fixed_array(name, &blk)
15
15
  end
16
16
  end
17
17
 
@@ -1,11 +1,15 @@
1
1
  def default_formatter
2
- Formatter.new
2
+ Formatter.new(" ")
3
+ end
4
+
5
+ def four_space_formatter
6
+ Formatter.new(" ")
3
7
  end
4
8
 
5
9
  class Formatter
6
- def initialize
10
+ def initialize(indent_str)
7
11
  @indent_level = 0
8
- @indent_str = " "
12
+ @indent_str = indent_str
9
13
  @lines = []
10
14
  end
11
15
 
@@ -2,16 +2,16 @@ module Cauterize
2
2
  module_function
3
3
 
4
4
  def group(name)
5
- a = groups[name] || groups[name] = Group.new(name)
5
+ a = Cauterize.groups[name] || Cauterize.groups[name] = Group.new(name)
6
6
  yield a if block_given?
7
7
  return a
8
8
  end
9
9
 
10
10
  def group!(name, &blk)
11
- if groups[name]
11
+ if Cauterize.groups[name]
12
12
  raise Exception.new("Group with name #{name} already exists.")
13
13
  else
14
- group(name, &blk)
14
+ Cauterize.group(name, &blk)
15
15
  end
16
16
  end
17
17
 
@@ -24,10 +24,7 @@ module Cauterize
24
24
 
25
25
  def initialize(name, type)
26
26
  @name = name
27
- @type = BaseType.find_type!(type)
28
- end
29
-
30
- def enum_sym
27
+ @type = BaseType.find_type!(type) if type
31
28
  end
32
29
  end
33
30
 
@@ -40,7 +37,7 @@ module Cauterize
40
37
  @tag_enum = Cauterize.enumeration!("group_#{name}_type".to_sym)
41
38
  end
42
39
 
43
- def field(name, type)
40
+ def field(name, type=nil)
44
41
  if @fields[name]
45
42
  raise Exception.new("Field name #{name} already used.")
46
43
  else
@@ -9,16 +9,16 @@ module Cauterize
9
9
  module_function
10
10
 
11
11
  def scalar(name)
12
- a = scalars[name] || scalars[name] = Scalar.new(name)
12
+ a = Cauterize.scalars[name] || Cauterize.scalars[name] = Scalar.new(name)
13
13
  yield a if block_given?
14
14
  return a
15
15
  end
16
16
 
17
17
  def scalar!(name, &blk)
18
- if scalars[name]
18
+ if Cauterize.scalars[name]
19
19
  raise Exception.new("Scalar with name #{name} already exists.")
20
20
  else
21
- scalar(name, &blk)
21
+ Cauterize.scalar(name, &blk)
22
22
  end
23
23
  end
24
24
 
@@ -26,13 +26,22 @@ module Cauterize
26
26
  @scalars ||= {}
27
27
  end
28
28
 
29
- def flush_scalars
30
- @scalars = {}
31
- end
32
-
33
29
  class Scalar < BaseType
34
30
  def initialize(name)
35
31
  super
36
32
  end
33
+
34
+ def type_name(type_name = nil)
35
+ if type_name
36
+ t = BaseType.find_type!(type_name)
37
+ if t.class != BuiltIn
38
+ raise Exception.new("Must specify a BuiltIn type for scalars.")
39
+ end
40
+
41
+ @type_name = t
42
+ else
43
+ @type_name
44
+ end
45
+ end
37
46
  end
38
47
  end
@@ -2,21 +2,21 @@ module Cauterize
2
2
  module_function
3
3
 
4
4
  def variable_array(name)
5
- a = variable_arrays[name] || variable_arrays[name] = VariableArray.new(name)
5
+ a = Cauterize.variable_arrays[name] || Cauterize.variable_arrays[name] = VariableArray.new(name)
6
6
  yield a if block_given?
7
7
  return a
8
8
  end
9
9
 
10
10
  def variable_array!(name, &blk)
11
- if variable_arrays[name]
11
+ if Cauterize.variable_arrays[name]
12
12
  raise Exception.new("VariableArray with name #{name} already exists.")
13
13
  else
14
- variable_array(name, &blk)
14
+ Cauterize.variable_array(name, &blk)
15
15
  end
16
16
  end
17
17
 
18
18
  def variable_arrays
19
- @variable_ararys ||= {}
19
+ @variable_arrays ||= {}
20
20
  end
21
21
 
22
22
  class VariableArray < BaseType
@@ -43,10 +43,10 @@ module Cauterize
43
43
  def size_type(t = nil)
44
44
  if t
45
45
  _t = BaseType.find_type!(t)
46
- if _t.is_scalar?
46
+ if _t.is_built_in? or _t.is_scalar?
47
47
  @size_type = _t
48
48
  else
49
- raise Exception.new("The type #{t} is not an scalar")
49
+ raise Exception.new("The type #{t} is not a built-in or scalar type")
50
50
  end
51
51
  else
52
52
  @size_type
@@ -1,3 +1,3 @@
1
1
  module Cauterize
2
- VERSION = "0.0.1.pre1"
2
+ VERSION = "0.0.1.pre5"
3
3
  end
@@ -1,166 +1,174 @@
1
- include Cauterize
1
+ module Cauterize
2
2
 
3
- describe Cauterize do
4
- before {
5
- BaseType.class_variable_set(:@@next_id, {})
6
- BaseType.class_variable_set(:@@instances, {})
7
- }
3
+ describe Cauterize do
4
+ describe BaseType do
5
+ describe :id do
6
+ it { has_a_unique_id_for_each_instance(BaseType) }
7
+ end
8
8
 
9
- describe BaseType do
10
- describe :id do
11
- it { has_a_unique_id_for_each_instance(BaseType) }
12
- end
9
+ describe :type_str do
10
+ it "is the hexadecimal representation of type" do
11
+ f = Cauterize.enumeration(:foo) do |e|
12
+ e.value :a, 1
13
+ end
13
14
 
14
- describe :type_str do
15
- it "is the hexadecimal representation of type" do
16
- f = enumeration(:foo) do |e|
17
- e.value :a, 1
18
- end
19
- b = enumeration(:bar) do |e|
20
- e.value :a, 1
21
- end
15
+ b = Cauterize.enumeration(:bar) do |e|
16
+ e.value :a, 1
17
+ end
22
18
 
23
- b.type_str.should == "0x2001"
19
+ b.type_str.should == "0x2001"
20
+ end
24
21
  end
25
- end
26
-
27
- describe :tag do
28
- it { is_tagged_as(Scalar, 0) }
29
- it { is_tagged_as(Enumeration, 1) }
30
- it { is_tagged_as(Composite, 2) }
31
- it { is_tagged_as(FixedArray, 3) }
32
- it { is_tagged_as(VariableArray, 4) }
33
- it { is_tagged_as(Group, 5) }
34
- end
35
22
 
36
- describe :next_id do
37
- it "is an incrementing value starting at 0" do
38
- # the .new consumes the 0.
39
- BaseType.new(:foo).instance_exec do
40
- next_id.should == 1
41
- next_id.should == 2
42
- next_id.should == 3
43
- next_id.should == 4
23
+ describe :tag do
24
+ it { is_tagged_as(Scalar, 0) }
25
+ it { is_tagged_as(Enumeration, 1) }
26
+ it { is_tagged_as(Composite, 2) }
27
+ it { is_tagged_as(FixedArray, 3) }
28
+ it { is_tagged_as(VariableArray, 4) }
29
+ it { is_tagged_as(Group, 5) }
30
+ end
31
+
32
+ describe :next_id do
33
+ it "is an incrementing value starting at 0" do
34
+ # the .new consumes the 0.
35
+ BaseType.new(:foo).instance_exec do
36
+ next_id.should == 1
37
+ next_id.should == 2
38
+ next_id.should == 3
39
+ next_id.should == 4
40
+ end
44
41
  end
45
- end
46
42
 
47
- it "should not allow derived class ids to interact" do
48
- a1 = Scalar.new(:foo)
49
- a2 = Scalar.new(:bar)
50
- e1 = Enumeration.new(:zoop)
51
- e2 = Enumeration.new(:nih)
43
+ it "should not allow derived class ids to interact" do
44
+ a1 = Scalar.new(:uint8_t)
45
+ a2 = Scalar.new(:uint64_t)
46
+ e1 = Enumeration.new(:zoop)
47
+ e2 = Enumeration.new(:nih)
52
48
 
53
- a1.id.should == 0
54
- a2.id.should == 1
55
- e1.id.should == 0
56
- e2.id.should == 1
49
+ a1.id.should == 0
50
+ a2.id.should == 1
51
+ e1.id.should == 0
52
+ e2.id.should == 1
53
+ end
57
54
  end
58
- end
59
55
 
60
- describe "bit stuff" do
61
- it "is consistent" do
62
- BaseType.class_exec do
63
- (tag_bit_width + id_bit_width).should == type_bit_width
64
- (tag_bit_mask >> id_bit_width).should == 0x7
56
+ describe "bit stuff" do
57
+ it "is consistent" do
58
+ BaseType.class_exec do
59
+ (tag_bit_width + id_bit_width).should == type_bit_width
60
+ (tag_bit_mask >> id_bit_width).should == 0x7
61
+ end
65
62
  end
66
63
  end
67
- end
68
64
 
69
- describe :register_instance do
70
- it "adds an instance to the instance list" do
71
- class X < BaseType
72
- def initialize(name); end
73
- end
74
- x = X.new(:foo)
65
+ describe :register_instance do
66
+ it "adds an instance to the instance list" do
67
+ orig_len = BaseType.all_instances.length
75
68
 
76
- x.instance_exec do
77
- register_instance(x)
78
- end
69
+ class X < BaseType
70
+ def initialize(name); end
71
+ end
72
+ x = X.new(:foo)
73
+
74
+ x.instance_exec do
75
+ register_instance(x)
76
+ end
79
77
 
80
- BaseType.all_instances[0].should be x
81
- BaseType.all_instances.length.should == 1
78
+ BaseType.all_instances.last.should be x
79
+ BaseType.all_instances.length.should == orig_len + 1
80
+ end
82
81
  end
83
- end
84
82
 
85
- describe :instances do
86
- # Two things are being tested here.
87
- # 1. That instances works.
88
- # 2. That super() is called in each .new
89
- it "is every instance of a BaseType-derived class" do
90
- BaseType.all_instances.should == []
83
+ describe :instances do
84
+ # Two things are being tested here.
85
+ # 1. That instances works.
86
+ # 2. That super() is called in each .new
87
+ it "is every instance of a BaseType-derived class" do
88
+ BaseType.class_variable_set(:@@instances, {})
89
+
90
+ b = BuiltIn.new(:uint32)
91
+ s = Scalar.new(:eek)
92
+ e = Enumeration.new(:emoo)
93
+ c = Composite.new(:cooo)
94
+ f = FixedArray.new(:moo)
95
+ v = VariableArray.new(:quack)
96
+ g = Group.new(:goo)
91
97
 
92
- a = Scalar.new(:foo)
93
- e = Enumeration.new(:emoo)
94
- c = Composite.new(:cooo)
95
- f = FixedArray.new(:moo)
96
- v = VariableArray.new(:quack)
97
- g = Group.new(:goo)
98
+ lst = [b, s, e, c, f, v, g]
98
99
 
99
- lst = [a, e, c, f, v, g]
100
+ instances = BaseType.all_instances
100
101
 
101
- instances = BaseType.all_instances
102
- instances.length.should == lst.length + 1 # +1 because groups make an enum as well
102
+ # There will be some extras due to automatic creation of enums and
103
+ # scalars in Enumeration and Group.
104
+ instances.should include(*lst)
103
105
 
104
- # Check that each of our instances shows up in the list returned from
105
- # all_instances. Do it this way in case there are other types created
106
- # (like the enumeration for Group).
107
- lst.all? do |l|
108
- instances.any? {|i| i.equal? l}
106
+ # Check that each of our instances shows up in the list returned from
107
+ # all_instances. Do it this way in case there are other types created
108
+ # (like the enumeration for Group).
109
+ lst.all? do |l|
110
+ instances.any? {|i| i.equal? l}
111
+ end
109
112
  end
110
113
  end
111
- end
112
114
 
113
- describe :find_type do
114
- it "returns the instance with the provided name" do
115
- f = scalar(:foo)
116
- b = scalar(:bar)
115
+ describe :find_type do
116
+ it "returns the instance with the provided name" do
117
+ f = Cauterize.scalar(:foo)
118
+ b = Cauterize.scalar(:bar)
117
119
 
118
- BaseType.find_type(:bar).should be b
119
- BaseType.find_type(:foo).should be f
120
- end
120
+ BaseType.find_type(:bar).should be b
121
+ BaseType.find_type(:foo).should be f
122
+ end
121
123
 
122
- it "is nil on an unknown name" do
123
- BaseType.find_type(:xxxxxxxxxxxxxxxxxx).should be_nil
124
+ it "is nil on an unknown name" do
125
+ BaseType.find_type(:xxxxxxxxxxxxxxxxxx).should be_nil
126
+ end
124
127
  end
125
- end
126
128
 
127
- describe :find_type! do
128
- it "returns the instance with the provided name" do
129
- f = scalar(:foo)
130
- b = scalar(:bar)
129
+ describe :find_type! do
130
+ it "returns the instance with the provided name" do
131
+ f = Cauterize.scalar(:foo)
132
+ b = Cauterize.scalar(:bar)
131
133
 
132
- BaseType.find_type!(:bar).should be b
133
- BaseType.find_type!(:foo).should be f
134
- end
134
+ BaseType.find_type!(:bar).should be b
135
+ BaseType.find_type!(:foo).should be f
136
+ end
135
137
 
136
- it "errors on an unknown name" do
137
- lambda { BaseType.find_type!(:foo) }.should raise_error /name foo does not/
138
+ it "errors on an unknown name" do
139
+ lambda { BaseType.find_type!(:foo) }.should raise_error /name foo does not/
140
+ end
138
141
  end
139
- end
140
142
 
141
- describe "is_[type]?" do
142
- it "supports scalar" do
143
- scalar(:foo).is_scalar?.should be_true
144
- end
143
+ describe "is_[type]?" do
144
+ it "supports scalar" do
145
+ Cauterize.scalar(:foo).is_scalar?.should be_true
146
+ end
145
147
 
146
- it "supports enumeration" do
147
- enumeration(:foo).is_enumeration?.should be_true
148
- end
148
+ it "supports enumeration" do
149
+ Cauterize.enumeration(:foo).is_enumeration?.should be_true
150
+ end
149
151
 
150
- it "supports composite" do
151
- composite(:foo).is_composite?.should be_true
152
- end
152
+ it "supports composite" do
153
+ Cauterize.composite(:foo).is_composite?.should be_true
154
+ end
153
155
 
154
- it "supports fixed_array" do
155
- fixed_array(:foo).is_fixed_array?.should be_true
156
- end
156
+ it "supports fixed_array" do
157
+ Cauterize.fixed_array(:foo).is_fixed_array?.should be_true
158
+ end
157
159
 
158
- it "supports variable_array" do
159
- variable_array(:foo).is_variable_array?.should be_true
160
- end
160
+ it "supports variable_array" do
161
+ Cauterize.variable_array(:foo).is_variable_array?.should be_true
162
+ end
161
163
 
162
- it "supports group" do
163
- group(:foo).is_group?.should be_true
164
+ it "supports group" do
165
+ Cauterize.group(:foo).is_group?.should be_true
166
+ end
167
+
168
+ it "supports builtin" do
169
+ # This one is special because of how buitins are declared
170
+ Cauterize.builtins[:int32].is_built_in?.should be_true
171
+ end
164
172
  end
165
173
  end
166
174
  end