cauterize 0.0.1.pre12 → 0.0.1.pre13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/example/Cauterize +0 -2
  4. data/lib/cauterize/builders/c/buildable.rb +7 -0
  5. data/lib/cauterize/builders/c/builtin.rb +4 -0
  6. data/lib/cauterize/builders/c/composite.rb +8 -0
  7. data/lib/cauterize/builders/c/enumeration.rb +8 -4
  8. data/lib/cauterize/builders/c/fixed_array.rb +11 -2
  9. data/lib/cauterize/builders/c/group.rb +26 -1
  10. data/lib/cauterize/builders/c/scalar.rb +4 -0
  11. data/lib/cauterize/builders/c/variable_array.rb +17 -3
  12. data/lib/cauterize/builders/cs/builtin.rb +1 -1
  13. data/lib/cauterize/builders/cs/fixed_array.rb +3 -1
  14. data/lib/cauterize/builders/ruby/builtin.rb +1 -1
  15. data/lib/cauterize/builders/ruby/composite.rb +10 -7
  16. data/lib/cauterize/builders/ruby/enumeration.rb +9 -9
  17. data/lib/cauterize/builders/ruby/fixed_array.rb +4 -4
  18. data/lib/cauterize/builders/ruby/group.rb +9 -9
  19. data/lib/cauterize/builders/ruby/scalar.rb +3 -3
  20. data/lib/cauterize/builders/ruby/variable_array.rb +5 -5
  21. data/lib/cauterize/c_builder.rb +6 -0
  22. data/lib/cauterize/enumeration.rb +4 -14
  23. data/lib/cauterize/representation.rb +32 -0
  24. data/lib/cauterize/ruby_builder.rb +7 -5
  25. data/lib/cauterize/variable_array.rb +3 -12
  26. data/lib/cauterize/version.rb +1 -1
  27. data/spec/base_type_spec.rb +2 -2
  28. data/spec/builders/c/group_spec.rb +21 -0
  29. data/spec/builders/c/variable_array_spec.rb +2 -4
  30. data/spec/builders/cs/fixed_array_spec.rb +2 -1
  31. data/spec/builders/cs/variable_array_spec.rb +0 -1
  32. data/spec/c_builder_spec.rb +22 -2
  33. data/spec/cs_builder_spec.rb +0 -2
  34. data/spec/doc_builder_spec.rb +0 -2
  35. data/spec/ruby_builder_spec.rb +5 -2
  36. data/spec/ruby_generated_spec.rb +735 -0
  37. data/spec/support/spec_sample_model.rb +1 -3
  38. data/spec/variable_array_spec.rb +5 -19
  39. data/support/cs/src/CauterizeFixedArrayFormatter.cs +27 -9
  40. data/support/cs/src/CauterizeVariableArrayFormatter.cs +28 -11
  41. data/support/ruby/src/cauterize_ruby_baseclasses.rb +297 -176
  42. data/support/ruby/src/cauterize_ruby_builtins.rb +121 -95
  43. metadata +25 -39
@@ -1,122 +1,148 @@
1
1
  require_relative './cauterize_ruby_baseclasses'
2
2
 
3
- class UInt8 < CauterizeBuiltinInteger
4
- def in_range(v) v >= 0 && v < 2**8 end
5
- def pack
6
- [to_i].pack("C")
7
- end
8
- def self.unpackio(str)
9
- UInt8.new str.read(1).unpack("C")[0]
3
+ module CauterizeRuby
4
+ class UInt8 < BuiltinInteger
5
+ def in_range(v) v >= 0 && v < 2**8 end
6
+ def self.max_size() 1 end
7
+ def cmp(other) to_ruby <=> other.to_ruby end
8
+ def packio(x)
9
+ x << [to_i].pack("C")
10
+ end
11
+ def self.unpackio(str)
12
+ UInt8.new str.read(max_size).unpack("C")[0]
13
+ end
10
14
  end
11
- end
12
15
 
13
- class UInt16 < CauterizeBuiltinInteger
14
- def in_range(v) v >= 0 && v < 2**16 end
15
- def pack
16
- [to_i].pack("S")
17
- end
18
- def self.unpackio(str)
19
- UInt16.new str.read(2).unpack("S")[0]
16
+ class UInt16 < BuiltinInteger
17
+ def in_range(v) v >= 0 && v < 2**16 end
18
+ def self.max_size() 2 end
19
+ def cmp(other) to_ruby <=> other.to_ruby end
20
+ def packio(x)
21
+ x << [to_i].pack("S")
22
+ end
23
+ def self.unpackio(str)
24
+ UInt16.new str.read(max_size).unpack("S")[0]
25
+ end
20
26
  end
21
- end
22
27
 
23
- class UInt32 < CauterizeBuiltinInteger
24
- def in_range(v) v >= 0 && v < 2**32 end
25
- def pack
26
- [to_i].pack("L")
27
- end
28
- def self.unpackio(str)
29
- UInt32.new str.read(4).unpack("L")[0]
28
+ class UInt32 < BuiltinInteger
29
+ def in_range(v) v >= 0 && v < 2**32 end
30
+ def self.max_size() 4 end
31
+ def cmp(other) to_ruby <=> other.to_ruby end
32
+ def packio(x)
33
+ x << [to_i].pack("L")
34
+ end
35
+ def self.unpackio(str)
36
+ UInt32.new str.read(max_size).unpack("L")[0]
37
+ end
30
38
  end
31
- end
32
39
 
33
- class UInt64 < CauterizeBuiltinInteger
34
- def in_range(v) v >= 0 && v < 2**64 end
35
- def pack
36
- [to_i].pack("Q")
37
- end
38
- def self.unpackio(str)
39
- UInt64.new str.read(8).unpack("Q")[0]
40
+ class UInt64 < BuiltinInteger
41
+ def in_range(v) v >= 0 && v < 2**64 end
42
+ def self.max_size() 8 end
43
+ def cmp(other) to_ruby <=> other.to_ruby end
44
+ def packio(x)
45
+ x << [to_i].pack("Q")
46
+ end
47
+ def self.unpackio(str)
48
+ UInt64.new str.read(max_size).unpack("Q")[0]
49
+ end
40
50
  end
41
- end
42
51
 
43
- class Int8 < CauterizeBuiltinInteger
44
- def in_range(v) (v >= -2**7) && (v < 2**7) end
45
- def pack
46
- [to_i].pack("c")
47
- end
48
- def self.unpackio(str)
49
- Int8.new str.read(1).unpack("c")[0]
52
+ class Int8 < BuiltinInteger
53
+ def in_range(v) (v >= -2**7) && (v < 2**7) end
54
+ def self.max_size() 1 end
55
+ def cmp(other) to_ruby <=> other.to_ruby end
56
+ def packio(x)
57
+ x << [to_i].pack("c")
58
+ end
59
+ def self.unpackio(str)
60
+ Int8.new str.read(max_size).unpack("c")[0]
61
+ end
50
62
  end
51
- end
52
63
 
53
- class Int16 < CauterizeBuiltinInteger
54
- def in_range(v) (v >= -2**15) && (v < 2**15) end
55
- def pack
56
- [to_i].pack("s")
57
- end
58
- def self.unpackio(str)
59
- Int16.new str.read(2).unpack("s")[0]
64
+ class Int16 < BuiltinInteger
65
+ def in_range(v) (v >= -2**15) && (v < 2**15) end
66
+ def self.max_size() 2 end
67
+ def cmp(other) to_ruby <=> other.to_ruby end
68
+ def packio(x)
69
+ x << [to_i].pack("s")
70
+ end
71
+ def self.unpackio(str)
72
+ Int16.new str.read(max_size).unpack("s")[0]
73
+ end
60
74
  end
61
- end
62
75
 
63
- class Int32 < CauterizeBuiltinInteger
64
- def in_range(v) (v >= -2**31) && (v < 2**31) end
65
- def pack
66
- [to_i].pack("l")
67
- end
68
- def self.unpackio(str)
69
- Int32.new str.read(4).unpack("l")[0]
76
+ class Int32 < BuiltinInteger
77
+ def in_range(v) (v >= -2**31) && (v < 2**31) end
78
+ def self.max_size() 4 end
79
+ def cmp(other) to_ruby <=> other.to_ruby end
80
+ def packio(x)
81
+ x << [to_i].pack("l")
82
+ end
83
+ def self.unpackio(str)
84
+ Int32.new str.read(max_size).unpack("l")[0]
85
+ end
70
86
  end
71
- end
72
87
 
73
- class Int64 < CauterizeBuiltinInteger
74
- def in_range(v) (v >= -2**63) && (v < 2**63) end
75
- def pack
76
- [to_i].pack("q")
77
- end
78
- def self.unpackio(str)
79
- Int64.new str.read(8).unpack("q")[0]
88
+ class Int64 < BuiltinInteger
89
+ def in_range(v) (v >= -2**63) && (v < 2**63) end
90
+ def self.max_size() 8 end
91
+ def cmp(other) to_ruby <=> other.to_ruby end
92
+ def packio(x)
93
+ x << [to_i].pack("q")
94
+ end
95
+ def self.unpackio(str)
96
+ Int64.new str.read(max_size).unpack("q")[0]
97
+ end
80
98
  end
81
- end
82
99
 
83
- class Bool < CauterizeBuiltinBool
84
- def in_range(v) true end
85
- def pack
86
- if @val
87
- [1].pack("C")
88
- else
89
- [0].pack("C")
100
+ class Bool < BuiltinBool
101
+ def in_range(v) true end
102
+ def self.max_size() 1 end
103
+ def cmp(other)
104
+ return 0 if to_ruby == other.to_ruby
105
+ return 1 if to_ruby
106
+ return -1
90
107
  end
91
- end
92
- def self.unpackio(str)
93
- if str.read(1).unpack("C")[0] == 0
94
- Bool.new false
95
- else
96
- Bool.new true
108
+ def packio(x)
109
+ x << if @val
110
+ [1].pack("C")
111
+ else
112
+ [0].pack("C")
113
+ end
114
+ end
115
+ def self.unpackio(str)
116
+ if str.read(max_size).unpack("C")[0] == 0
117
+ Bool.new false
118
+ else
119
+ Bool.new true
120
+ end
97
121
  end
98
122
  end
99
- end
100
123
 
101
- class Float32 < CauterizeBuiltinFloat
102
- def in_range(v) v > (-3.402823466e38) && v < (3.402823466e38) end
103
- def pack
104
- [to_f].pack("f")
105
- end
106
- def self.unpackio(str)
107
- Float32.new str.read(4).unpack("f")[0]
124
+ class Float32 < BuiltinFloat
125
+ def in_range(v) [v].pack("f").unpack("f").first.finite? end
126
+ def self.max_size() 4 end
127
+ def cmp(other) to_ruby <=> other.to_ruby end
128
+ def packio(x)
129
+ x << [to_f].pack("f")
130
+ end
131
+ def self.unpackio(str)
132
+ Float32.new str.read(max_size).unpack("f")[0]
133
+ end
108
134
  end
109
- end
110
135
 
111
- class Float64 < CauterizeBuiltinFloat
112
- def in_range(v) true end
113
- def pack
114
- [to_f].pack("d")
115
- end
116
- def self.unpackio(str)
117
- Float64.new str.read(8).unpack("d")[0]
136
+ class Float64 < BuiltinFloat
137
+ def in_range(v) true end
138
+ def self.max_size() 8 end
139
+ def cmp(other) to_ruby <=> other.to_ruby end
140
+ def packio(x)
141
+ x << [to_f].pack("d")
142
+ end
143
+ def self.unpackio(str)
144
+ Float64.new str.read(max_size).unpack("d")[0]
145
+ end
118
146
  end
119
147
  end
120
148
 
121
-
122
-
metadata CHANGED
@@ -1,110 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cauterize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre12
5
- prerelease: 6
4
+ version: 0.0.1.pre13
6
5
  platform: ruby
7
6
  authors:
8
7
  - John Van Enk
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-02 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ">="
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.9.2.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ">="
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.9.2.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: thor
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ">="
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.16.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ">="
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.16.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: require_all
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ">="
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.2.1
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ">="
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.2.1
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: bindata
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ">="
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '1.5'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ">="
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '1.5'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ">="
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: 2.12.0
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ">="
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: 2.12.0
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: mocha
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ">="
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: 0.13.0
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ">="
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: 0.13.0
110
97
  description: Tools to generate C structures and marshalers with a Ruby DSL.
@@ -115,9 +102,9 @@ executables:
115
102
  extensions: []
116
103
  extra_rdoc_files: []
117
104
  files:
118
- - ".gitignore"
119
- - ".rspec"
120
- - ".travisci.yml"
105
+ - .gitignore
106
+ - .rspec
107
+ - .travisci.yml
121
108
  - Gemfile
122
109
  - LICENSE.txt
123
110
  - README.md
@@ -176,6 +163,7 @@ files:
176
163
  - lib/cauterize/fixed_array.rb
177
164
  - lib/cauterize/formatter.rb
178
165
  - lib/cauterize/group.rb
166
+ - lib/cauterize/representation.rb
179
167
  - lib/cauterize/ruby_builder.rb
180
168
  - lib/cauterize/scalar.rb
181
169
  - lib/cauterize/snake_case.rb
@@ -209,6 +197,7 @@ files:
209
197
  - spec/fixed_array_spec.rb
210
198
  - spec/group_spec.rb
211
199
  - spec/ruby_builder_spec.rb
200
+ - spec/ruby_generated_spec.rb
212
201
  - spec/scalar_spec.rb
213
202
  - spec/spec_helper.rb
214
203
  - spec/support/shared_examples_for_array_buildables.rb
@@ -254,30 +243,26 @@ files:
254
243
  - support/ruby/src/cauterize_ruby_builtins.rb
255
244
  homepage: https://github.com/sw17ch/cauterize
256
245
  licenses: []
246
+ metadata: {}
257
247
  post_install_message:
258
248
  rdoc_options: []
259
249
  require_paths:
260
250
  - lib
261
251
  required_ruby_version: !ruby/object:Gem::Requirement
262
- none: false
263
252
  requirements:
264
- - - ">="
253
+ - - '>='
265
254
  - !ruby/object:Gem::Version
266
255
  version: '0'
267
- segments:
268
- - 0
269
- hash: 2978929199543110981
270
256
  required_rubygems_version: !ruby/object:Gem::Requirement
271
- none: false
272
257
  requirements:
273
- - - ">"
258
+ - - '>'
274
259
  - !ruby/object:Gem::Version
275
260
  version: 1.3.1
276
261
  requirements: []
277
262
  rubyforge_project:
278
- rubygems_version: 1.8.25
263
+ rubygems_version: 2.0.3
279
264
  signing_key:
280
- specification_version: 3
265
+ specification_version: 4
281
266
  summary: Tools to generate structures and mashalers suitable for static-memory environments.
282
267
  test_files:
283
268
  - spec/base_type_spec.rb
@@ -308,6 +293,7 @@ test_files:
308
293
  - spec/fixed_array_spec.rb
309
294
  - spec/group_spec.rb
310
295
  - spec/ruby_builder_spec.rb
296
+ - spec/ruby_generated_spec.rb
311
297
  - spec/scalar_spec.rb
312
298
  - spec/spec_helper.rb
313
299
  - spec/support/shared_examples_for_array_buildables.rb