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.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +33 -33
  3. data/.rspec +1 -1
  4. data/.travisci.yml +4 -4
  5. data/Gemfile +4 -4
  6. data/LICENSE.txt +21 -21
  7. data/README.md +177 -177
  8. data/Rakefile +54 -54
  9. data/bin/cauterize +61 -61
  10. data/cauterize.gemspec +27 -27
  11. data/example/Cauterize +68 -68
  12. data/example/build.sh +25 -25
  13. data/example/c_example_support/empty_main.c +1 -1
  14. data/example/c_example_support/example_project_config.c +11 -11
  15. data/example/c_example_support/example_project_config.h +15 -15
  16. data/example/ruby_ex.rb +14 -14
  17. data/lib/cauterize.rb +117 -117
  18. data/lib/cauterize/base_type.rb +78 -78
  19. data/lib/cauterize/builders.rb +41 -41
  20. data/lib/cauterize/builders/c/buildable.rb +91 -91
  21. data/lib/cauterize/builders/c/builtin.rb +43 -43
  22. data/lib/cauterize/builders/c/composite.rb +57 -57
  23. data/lib/cauterize/builders/c/enumeration.rb +60 -60
  24. data/lib/cauterize/builders/c/fixed_array.rb +74 -74
  25. data/lib/cauterize/builders/c/group.rb +143 -143
  26. data/lib/cauterize/builders/c/scalar.rb +34 -34
  27. data/lib/cauterize/builders/c/variable_array.rb +98 -98
  28. data/lib/cauterize/builders/cs/buildable.rb +59 -59
  29. data/lib/cauterize/builders/cs/builtin.rb +22 -22
  30. data/lib/cauterize/builders/cs/composite.rb +21 -21
  31. data/lib/cauterize/builders/cs/csarray.rb +32 -32
  32. data/lib/cauterize/builders/cs/enumeration.rb +21 -21
  33. data/lib/cauterize/builders/cs/fixed_array.rb +27 -27
  34. data/lib/cauterize/builders/cs/group.rb +32 -32
  35. data/lib/cauterize/builders/cs/scalar.rb +10 -10
  36. data/lib/cauterize/builders/cs/variable_array.rb +40 -34
  37. data/lib/cauterize/builders/doc/buildable.rb +30 -30
  38. data/lib/cauterize/builders/doc/builtin.rb +21 -21
  39. data/lib/cauterize/builders/doc/composite.rb +23 -23
  40. data/lib/cauterize/builders/doc/enumeration.rb +24 -24
  41. data/lib/cauterize/builders/doc/fixed_array.rb +26 -26
  42. data/lib/cauterize/builders/doc/group.rb +29 -29
  43. data/lib/cauterize/builders/doc/scalar.rb +21 -21
  44. data/lib/cauterize/builders/doc/variable_array.rb +26 -26
  45. data/lib/cauterize/builders/ruby/buildable.rb +11 -11
  46. data/lib/cauterize/builders/ruby/builtin.rb +25 -25
  47. data/lib/cauterize/builders/ruby/composite.rb +26 -26
  48. data/lib/cauterize/builders/ruby/enumeration.rb +27 -27
  49. data/lib/cauterize/builders/ruby/fixed_array.rb +20 -20
  50. data/lib/cauterize/builders/ruby/group.rb +35 -35
  51. data/lib/cauterize/builders/ruby/scalar.rb +19 -19
  52. data/lib/cauterize/builders/ruby/variable_array.rb +22 -22
  53. data/lib/cauterize/builtin.rb +62 -62
  54. data/lib/cauterize/c_builder.rb +103 -103
  55. data/lib/cauterize/cauterize.rb +76 -76
  56. data/lib/cauterize/composite.rb +64 -64
  57. data/lib/cauterize/cs_builder.rb +58 -58
  58. data/lib/cauterize/doc_builder.rb +34 -34
  59. data/lib/cauterize/enumeration.rb +98 -98
  60. data/lib/cauterize/fixed_array.rb +50 -50
  61. data/lib/cauterize/formatter.rb +67 -67
  62. data/lib/cauterize/group.rb +81 -81
  63. data/lib/cauterize/representation.rb +32 -32
  64. data/lib/cauterize/ruby_builder.rb +44 -44
  65. data/lib/cauterize/scalar.rb +53 -53
  66. data/lib/cauterize/snake_case.rb +21 -21
  67. data/lib/cauterize/variable_array.rb +55 -55
  68. data/lib/cauterize/version.rb +3 -3
  69. data/spec/base_type_spec.rb +251 -251
  70. data/spec/builders/c/buildable_spec.rb +25 -25
  71. data/spec/builders/c/builtin_spec.rb +22 -22
  72. data/spec/builders/c/composite_spec.rb +50 -50
  73. data/spec/builders/c/enumeration_spec.rb +95 -95
  74. data/spec/builders/c/fixed_array_spec.rb +36 -36
  75. data/spec/builders/c/group_spec.rb +140 -140
  76. data/spec/builders/c/scalar_spec.rb +26 -26
  77. data/spec/builders/c/variable_array_spec.rb +48 -48
  78. data/spec/builders/cs/buildable_spec.rb +8 -8
  79. data/spec/builders/cs/composite_spec.rb +32 -32
  80. data/spec/builders/cs/enumeration_spec.rb +33 -33
  81. data/spec/builders/cs/fixed_array_spec.rb +41 -41
  82. data/spec/builders/cs/group_spec.rb +56 -56
  83. data/spec/builders/cs/scalar_spec.rb +7 -7
  84. data/spec/builders/cs/variable_array_spec.rb +49 -45
  85. data/spec/builders/doc/buildable_spec.rb +25 -25
  86. data/spec/builders_spec.rb +57 -57
  87. data/spec/builtin_spec.rb +43 -43
  88. data/spec/c_builder_spec.rb +176 -176
  89. data/spec/cauterize_spec.rb +15 -15
  90. data/spec/composite_spec.rb +77 -77
  91. data/spec/cs_builder_spec.rb +115 -115
  92. data/spec/doc_builder_spec.rb +260 -260
  93. data/spec/enumeration_spec.rb +145 -145
  94. data/spec/fixed_array_spec.rb +61 -61
  95. data/spec/group_spec.rb +111 -111
  96. data/spec/ruby_builder_spec.rb +83 -83
  97. data/spec/ruby_generated_spec.rb +735 -735
  98. data/spec/scalar_spec.rb +44 -44
  99. data/spec/spec_helper.rb +122 -122
  100. data/spec/support/shared_examples_for_array_buildables.rb +22 -22
  101. data/spec/support/shared_examples_for_c_buildables.rb +103 -103
  102. data/spec/support/shared_examples_for_sane_c_buildables.rb +22 -22
  103. data/spec/support/shared_examples_for_stubbed_functions.rb +18 -18
  104. data/spec/support/spec_sample_model.rb +74 -74
  105. data/spec/test_main.c +13 -13
  106. data/spec/variable_array_spec.rb +73 -73
  107. data/support/c/src/cauterize.c +75 -75
  108. data/support/c/src/cauterize.h +60 -60
  109. data/support/c/src/cauterize_debug.h +29 -29
  110. data/support/c/src/cauterize_util.h +8 -8
  111. data/support/c/test/greatest.h +536 -536
  112. data/support/c/test/test.c +166 -166
  113. data/support/cs/src/CauterizeCompositeFormatter.cs +0 -0
  114. data/support/cs/src/CauterizeContainerFormatter.cs +0 -0
  115. data/support/cs/src/CauterizeEnumFormatter.cs +0 -0
  116. data/support/cs/src/CauterizeException.cs +15 -15
  117. data/support/cs/src/CauterizeFixedArrayFormatter.cs +2 -2
  118. data/support/cs/src/CauterizeFormatter.cs +0 -0
  119. data/support/cs/src/CauterizeGroupFormatter.cs +0 -0
  120. data/support/cs/src/CauterizeTypeFormatterFactory.cs +0 -0
  121. data/support/cs/src/CauterizeTypes.cs +46 -12
  122. data/support/cs/src/CauterizeVariableArrayFormatter.cs +1 -1
  123. data/support/cs/src/ICauterizeTypeFormatter.cs +0 -0
  124. data/support/cs/src/OrderAttribute.cs +0 -0
  125. data/support/cs/src/PrimitiveSupport.cs +12 -0
  126. data/support/cs/test/CauterizeCompositeFormatterTest.cs +0 -0
  127. data/support/cs/test/CauterizeEnumFormatterTest.cs +0 -0
  128. data/support/cs/test/CauterizeFixedArrayFormatterTest.cs +0 -0
  129. data/support/cs/test/CauterizeFormatterTest.cs +0 -0
  130. data/support/cs/test/CauterizeGroupFormatterTest.cs +0 -0
  131. data/support/cs/test/CauterizeIntegrationTest.cs +0 -0
  132. data/support/cs/test/CauterizePrimitiveFormatterTest.cs +0 -0
  133. data/support/cs/test/CauterizeTypeFormatterFactoryTest.cs +0 -0
  134. data/support/cs/test/CauterizeVariableArrayFormatterTest.cs +0 -0
  135. data/support/cs/test/OrderAttributeTest.cs +0 -0
  136. data/support/ruby/src/cauterize_ruby_baseclasses.rb +367 -367
  137. data/support/ruby/src/cauterize_ruby_builtins.rb +148 -148
  138. metadata +20 -20
@@ -1 +1 @@
1
- int main(int argc, char * argv[]) { (void)argc; (void)argv; return 0; }
1
+ int main(int argc, char * argv[]) { (void)argc; (void)argv; return 0; }
@@ -1,11 +1,11 @@
1
- #include "example_project_config.h"
2
-
3
- CAUTERIZE_STATUS_T spec_Pack_uint8_buffer(struct Cauterize * dst, struct uint8_buffer * src)
4
- {
5
- CAUTERIZE_STATUS_T err;
6
-
7
- if (src->length > ARRAY_SIZE(src->data)) { return CA_ERR_INVALID_LENGTH; }
8
- if (CA_OK != (err = Pack_uint8(dst, &src->length))) { return err; }
9
-
10
- return CauterizeAppend(dst, src->data, src->length * sizeof(src->data[0]));
11
- }
1
+ #include "example_project_config.h"
2
+
3
+ CAUTERIZE_STATUS_T spec_Pack_uint8_buffer(struct Cauterize * dst, struct uint8_buffer * src)
4
+ {
5
+ CAUTERIZE_STATUS_T err;
6
+
7
+ if (src->length > ARRAY_SIZE(src->data)) { return CA_ERR_INVALID_LENGTH; }
8
+ if (CA_OK != (err = Pack_uint8(dst, &src->length))) { return err; }
9
+
10
+ return CauterizeAppend(dst, src->data, src->length * sizeof(src->data[0]));
11
+ }
@@ -1,15 +1,15 @@
1
- #ifndef EXAMPLE_PROJECT_CONFIG_H
2
- #define EXAMPLE_PROJECT_CONFIG_H
3
-
4
- #include "example_project.h"
5
-
6
- /* We're going to define a specialized version of Pack_uint8_buffer which packs
7
- * the entire buffer at once. We know this is okay since we're guaranteed not
8
- * to have any padding between the bytes in the array. */
9
- #define SPECIALIZED_Pack_uint8_buffer spec_Pack_uint8_buffer
10
-
11
- CAUTERIZE_STATUS_T spec_Pack_uint8_buffer(
12
- struct Cauterize * dst,
13
- struct uint8_buffer * src);
14
-
15
- #endif /* EXAMPLE_PROJECT_CONFIG_H */
1
+ #ifndef EXAMPLE_PROJECT_CONFIG_H
2
+ #define EXAMPLE_PROJECT_CONFIG_H
3
+
4
+ #include "example_project.h"
5
+
6
+ /* We're going to define a specialized version of Pack_uint8_buffer which packs
7
+ * the entire buffer at once. We know this is okay since we're guaranteed not
8
+ * to have any padding between the bytes in the array. */
9
+ #define SPECIALIZED_Pack_uint8_buffer spec_Pack_uint8_buffer
10
+
11
+ CAUTERIZE_STATUS_T spec_Pack_uint8_buffer(
12
+ struct Cauterize * dst,
13
+ struct uint8_buffer * src);
14
+
15
+ #endif /* EXAMPLE_PROJECT_CONFIG_H */
@@ -1,14 +1,14 @@
1
- $LOAD_PATH << File.join(File.dirname(__FILE__), "../lib")
2
- require 'cauterize'
3
- require 'bindata'
4
-
5
-
6
- Cauterize.populate(ARGV[0])
7
-
8
- i = Cauterize::ExampleProject::Wat.new
9
- i.tag.representation = 0
10
- p i.num_bytes
11
- i.tag.representation = 1
12
- p i.num_bytes
13
- i.tag.representation = 2
14
- p i.num_bytes
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), "../lib")
2
+ require 'cauterize'
3
+ require 'bindata'
4
+
5
+
6
+ Cauterize.populate(ARGV[0])
7
+
8
+ i = Cauterize::ExampleProject::Wat.new
9
+ i.tag.representation = 0
10
+ p i.num_bytes
11
+ i.tag.representation = 1
12
+ p i.num_bytes
13
+ i.tag.representation = 2
14
+ p i.num_bytes
@@ -1,117 +1,117 @@
1
- require 'bindata'
2
- require 'cauterize/snake_case'
3
- require 'cauterize/base_type'
4
- require 'cauterize/cauterize'
5
-
6
- def fix(s)
7
- s.gsub(/([[:alpha:]])_([[:digit:]])/) do |m|
8
- $1 + $2
9
- end
10
- end
11
-
12
-
13
- def populate_scalar(klass, inst)
14
- klass.class_eval do
15
- endian :little
16
- send(fix(inst.type_name.name.to_s), :data)
17
- end
18
- end
19
-
20
- def populate_enum(klass, inst)
21
- klass.class_eval do
22
- endian :little
23
-
24
- send(fix(inst.representation.name.to_s), :representation)
25
-
26
- enum_vals = inst.values.values.map {|v| [v.value, v.name.to_sym]}
27
- enum_hash = Hash[enum_vals]
28
- const_set(:ENUM_MAP, enum_hash)
29
- inst.values.values.each do |v|
30
- klass.const_set(v.name.upcase.to_sym, v.value)
31
- end
32
-
33
- def enum
34
- self.class.const_get(:ENUM_MAP)[representation]
35
- end
36
- end
37
- end
38
-
39
- def populate_fixed_array(klass, inst)
40
- klass.class_eval do
41
- endian :little
42
- array :data, { :type => fix(inst.array_type.name.to_s),
43
- :initial_length => inst.array_size }
44
- end
45
- end
46
-
47
- def populate_variable_array(klass, inst)
48
- # TODO: Figure out what we should do with inst.array_size
49
- klass.class_eval do
50
- endian :little
51
- send(fix(inst.size_type.name.to_s), :va_len, :value => lambda { data.length })
52
- array :data, { :type => fix(inst.array_type.name.to_s),
53
- :read_until => lambda { index == va_len - 1}}
54
- end
55
- end
56
-
57
- def populate_composite(klass, inst)
58
- klass.class_eval do
59
- endian :little
60
- inst.fields.values.each do |v|
61
- send(fix(v.type.name.to_s), v.name.to_s)
62
- end
63
- end
64
- end
65
-
66
- def populate_group(klass, inst)
67
- choices = inst.fields.values.each_with_index.map do |v, i|
68
- [i, v.type.nil? ? :empty_data : fix(v.type.name.to_s).to_sym]
69
- end
70
-
71
- klass.class_eval do
72
- endian :little
73
- send(fix(inst.tag_enum.name.to_s), :tag)
74
-
75
- choice :data, :selection => lambda { tag.representation },
76
- :choices => Hash[choices]
77
- end
78
- end
79
-
80
- module Cauterize
81
- class EmptyData < BinData::Record; end
82
-
83
- def self.populate(desc_file)
84
- parse_dsl(desc_file)
85
-
86
- dsl_mod = Module.new do |mod|
87
-
88
- BaseType.all_instances.each do |inst|
89
- next if Cauterize::BuiltIn == inst.class
90
-
91
- n = inst.name.to_s.camel
92
- module_eval("class #{n} < BinData::Record; end")
93
- klass = const_get(n)
94
-
95
- case inst
96
- when Cauterize::Scalar
97
- populate_scalar(klass, inst)
98
- when Cauterize::Enumeration
99
- populate_enum(klass, inst)
100
- when Cauterize::FixedArray
101
- populate_fixed_array(klass, inst)
102
- when Cauterize::VariableArray
103
- populate_variable_array(klass, inst)
104
- when Cauterize::Composite
105
- populate_composite(klass, inst)
106
- when Cauterize::Group
107
- populate_group(klass, inst)
108
- else
109
- puts "Unhandled instance: #{inst.class.name}"
110
- end
111
- end
112
- end
113
-
114
- const_set(Cauterize.get_name.camel, dsl_mod)
115
- end
116
- end
117
-
1
+ require 'bindata'
2
+ require 'cauterize/snake_case'
3
+ require 'cauterize/base_type'
4
+ require 'cauterize/cauterize'
5
+
6
+ def fix(s)
7
+ s.gsub(/([[:alpha:]])_([[:digit:]])/) do |m|
8
+ $1 + $2
9
+ end
10
+ end
11
+
12
+
13
+ def populate_scalar(klass, inst)
14
+ klass.class_eval do
15
+ endian :little
16
+ send(fix(inst.type_name.name.to_s), :data)
17
+ end
18
+ end
19
+
20
+ def populate_enum(klass, inst)
21
+ klass.class_eval do
22
+ endian :little
23
+
24
+ send(fix(inst.representation.name.to_s), :representation)
25
+
26
+ enum_vals = inst.values.values.map {|v| [v.value, v.name.to_sym]}
27
+ enum_hash = Hash[enum_vals]
28
+ const_set(:ENUM_MAP, enum_hash)
29
+ inst.values.values.each do |v|
30
+ klass.const_set(v.name.upcase.to_sym, v.value)
31
+ end
32
+
33
+ def enum
34
+ self.class.const_get(:ENUM_MAP)[representation]
35
+ end
36
+ end
37
+ end
38
+
39
+ def populate_fixed_array(klass, inst)
40
+ klass.class_eval do
41
+ endian :little
42
+ array :data, { :type => fix(inst.array_type.name.to_s),
43
+ :initial_length => inst.array_size }
44
+ end
45
+ end
46
+
47
+ def populate_variable_array(klass, inst)
48
+ # TODO: Figure out what we should do with inst.array_size
49
+ klass.class_eval do
50
+ endian :little
51
+ send(fix(inst.size_type.name.to_s), :va_len, :value => lambda { data.length })
52
+ array :data, { :type => fix(inst.array_type.name.to_s),
53
+ :read_until => lambda { index == va_len - 1}}
54
+ end
55
+ end
56
+
57
+ def populate_composite(klass, inst)
58
+ klass.class_eval do
59
+ endian :little
60
+ inst.fields.values.each do |v|
61
+ send(fix(v.type.name.to_s), v.name.to_s)
62
+ end
63
+ end
64
+ end
65
+
66
+ def populate_group(klass, inst)
67
+ choices = inst.fields.values.each_with_index.map do |v, i|
68
+ [i, v.type.nil? ? :empty_data : fix(v.type.name.to_s).to_sym]
69
+ end
70
+
71
+ klass.class_eval do
72
+ endian :little
73
+ send(fix(inst.tag_enum.name.to_s), :tag)
74
+
75
+ choice :data, :selection => lambda { tag.representation },
76
+ :choices => Hash[choices]
77
+ end
78
+ end
79
+
80
+ module Cauterize
81
+ class EmptyData < BinData::Record; end
82
+
83
+ def self.populate(desc_file)
84
+ parse_dsl(desc_file)
85
+
86
+ dsl_mod = Module.new do |mod|
87
+
88
+ BaseType.all_instances.each do |inst|
89
+ next if Cauterize::BuiltIn == inst.class
90
+
91
+ n = inst.name.to_s.camel
92
+ module_eval("class #{n} < BinData::Record; end")
93
+ klass = const_get(n)
94
+
95
+ case inst
96
+ when Cauterize::Scalar
97
+ populate_scalar(klass, inst)
98
+ when Cauterize::Enumeration
99
+ populate_enum(klass, inst)
100
+ when Cauterize::FixedArray
101
+ populate_fixed_array(klass, inst)
102
+ when Cauterize::VariableArray
103
+ populate_variable_array(klass, inst)
104
+ when Cauterize::Composite
105
+ populate_composite(klass, inst)
106
+ when Cauterize::Group
107
+ populate_group(klass, inst)
108
+ else
109
+ puts "Unhandled instance: #{inst.class.name}"
110
+ end
111
+ end
112
+ end
113
+
114
+ const_set(Cauterize.get_name.camel, dsl_mod)
115
+ end
116
+ end
117
+
@@ -1,78 +1,78 @@
1
- require 'set'
2
- require 'digest'
3
-
4
- module Cauterize
5
- class BaseType
6
- attr_reader :name, :description
7
- @@instances = {}
8
-
9
- def initialize(name, description=nil)
10
- if @@instances.keys.include?(name)
11
- raise Exception.new("A type with the name #{name} already exists. [#{@@instances[name].inspect}]")
12
- end
13
-
14
- @name = name
15
- @description = description
16
- register_instance(self)
17
- end
18
-
19
- def type_hash(digest = nil)
20
- digest ||= BaseType.digest_class.new
21
- digest.update(@name.to_s)
22
- local_hash(digest)
23
- end
24
-
25
- def self.all_instances; @@instances.values end
26
-
27
- def self.model_hash
28
- @@instances.keys.sort.map do |k|
29
- @@instances[k]
30
- end.inject(BaseType.digest_class.new) do |d, i|
31
- i.type_hash(d)
32
- end.digest
33
- end
34
-
35
- def self.find_type(name)
36
- @@instances[name]
37
- end
38
-
39
- def self.find_type!(name)
40
- unless t = find_type(name)
41
- raise Exception.new("The name #{name} does not correspond to a type.")
42
- else
43
- return t
44
- end
45
- end
46
-
47
- def self.digest_class
48
- Digest::SHA1
49
- end
50
-
51
- alias :orig_method_missing :method_missing
52
-
53
- def method_missing(sym, *args)
54
- m = sym.to_s.match /is_([^\?]+)\?/
55
- if m
56
- return ("Cauterize::#{m[1].camel}" == self.class.name)
57
- else
58
- orig_method_missing(sym, *args)
59
- end
60
- end
61
-
62
- protected
63
-
64
- # local_hash is responsible for hashing the things in the type that
65
- # are not known about in the BaseType parent class.
66
- def local_hash(digest)
67
- raise Exception.new("All instances of BaseType (including #{self.class}) must implement local_hash.")
68
- end
69
-
70
- def register_instance(inst)
71
- if @@instances[inst.name]
72
- raise Exception.new("Type with name #{inst.name} already defined.")
73
- end
74
-
75
- @@instances[inst.name] = inst
76
- end
77
- end
78
- end
1
+ require 'set'
2
+ require 'digest'
3
+
4
+ module Cauterize
5
+ class BaseType
6
+ attr_reader :name, :description
7
+ @@instances = {}
8
+
9
+ def initialize(name, description=nil)
10
+ if @@instances.keys.include?(name)
11
+ raise Exception.new("A type with the name #{name} already exists. [#{@@instances[name].inspect}]")
12
+ end
13
+
14
+ @name = name
15
+ @description = description
16
+ register_instance(self)
17
+ end
18
+
19
+ def type_hash(digest = nil)
20
+ digest ||= BaseType.digest_class.new
21
+ digest.update(@name.to_s)
22
+ local_hash(digest)
23
+ end
24
+
25
+ def self.all_instances; @@instances.values end
26
+
27
+ def self.model_hash
28
+ @@instances.keys.sort.map do |k|
29
+ @@instances[k]
30
+ end.inject(BaseType.digest_class.new) do |d, i|
31
+ i.type_hash(d)
32
+ end.digest
33
+ end
34
+
35
+ def self.find_type(name)
36
+ @@instances[name]
37
+ end
38
+
39
+ def self.find_type!(name)
40
+ unless t = find_type(name)
41
+ raise Exception.new("The name #{name} does not correspond to a type.")
42
+ else
43
+ return t
44
+ end
45
+ end
46
+
47
+ def self.digest_class
48
+ Digest::SHA1
49
+ end
50
+
51
+ alias :orig_method_missing :method_missing
52
+
53
+ def method_missing(sym, *args)
54
+ m = sym.to_s.match /is_([^\?]+)\?/
55
+ if m
56
+ return ("Cauterize::#{m[1].camel}" == self.class.name)
57
+ else
58
+ orig_method_missing(sym, *args)
59
+ end
60
+ end
61
+
62
+ protected
63
+
64
+ # local_hash is responsible for hashing the things in the type that
65
+ # are not known about in the BaseType parent class.
66
+ def local_hash(digest)
67
+ raise Exception.new("All instances of BaseType (including #{self.class}) must implement local_hash.")
68
+ end
69
+
70
+ def register_instance(inst)
71
+ if @@instances[inst.name]
72
+ raise Exception.new("Type with name #{inst.name} already defined.")
73
+ end
74
+
75
+ @@instances[inst.name] = inst
76
+ end
77
+ end
78
+ end