cauterize 0.0.1.pre5 → 0.0.1.pre7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/README.md +9 -0
  2. data/Rakefile +1 -1
  3. data/bin/cauterize +1 -1
  4. data/cauterize.gemspec +1 -0
  5. data/example/Cauterize +15 -9
  6. data/example/build.sh +3 -0
  7. data/example/doc_cauterize_output/example_project.txt +124 -0
  8. data/example/ruby_ex.rb +14 -0
  9. data/lib/cauterize.rb +117 -0
  10. data/lib/cauterize/base_type.rb +3 -2
  11. data/lib/cauterize/builders.rb +18 -2
  12. data/lib/cauterize/builders/c/group.rb +2 -3
  13. data/lib/cauterize/builders/cs/group.rb +2 -3
  14. data/lib/cauterize/builders/doc/buildable.rb +30 -0
  15. data/lib/cauterize/builders/doc/builtin.rb +21 -0
  16. data/lib/cauterize/builders/doc/composite.rb +23 -0
  17. data/lib/cauterize/builders/doc/enumeration.rb +24 -0
  18. data/lib/cauterize/builders/doc/fixed_array.rb +26 -0
  19. data/lib/cauterize/builders/doc/group.rb +29 -0
  20. data/lib/cauterize/builders/doc/scalar.rb +21 -0
  21. data/lib/cauterize/builders/doc/variable_array.rb +26 -0
  22. data/lib/cauterize/builtin.rb +2 -2
  23. data/lib/cauterize/c_builder.rb +5 -0
  24. data/lib/cauterize/cauterize.rb +7 -2
  25. data/lib/cauterize/composite.rb +8 -7
  26. data/lib/cauterize/cs_builder.rb +8 -5
  27. data/lib/cauterize/doc_builder.rb +34 -0
  28. data/lib/cauterize/enumeration.rb +5 -5
  29. data/lib/cauterize/fixed_array.rb +3 -3
  30. data/lib/cauterize/group.rb +18 -8
  31. data/lib/cauterize/scalar.rb +3 -3
  32. data/lib/cauterize/variable_array.rb +3 -3
  33. data/lib/cauterize/version.rb +1 -1
  34. data/spec/base_type_spec.rb +10 -0
  35. data/spec/builders/c/group_spec.rb +2 -2
  36. data/spec/builders/cs/group_spec.rb +1 -1
  37. data/spec/builders/doc/buildable_spec.rb +25 -0
  38. data/spec/builders_spec.rb +4 -2
  39. data/spec/builtin_spec.rb +2 -0
  40. data/spec/c_builder_spec.rb +12 -3
  41. data/spec/composite_spec.rb +11 -0
  42. data/spec/cs_builder_spec.rb +6 -2
  43. data/spec/doc_builder_spec.rb +247 -0
  44. data/spec/enumeration_spec.rb +2 -0
  45. data/spec/fixed_array_spec.rb +2 -0
  46. data/spec/group_spec.rb +4 -2
  47. data/spec/scalar_spec.rb +2 -0
  48. data/spec/spec_helper.rb +4 -0
  49. data/support/c/src/cauterize.h +1 -1
  50. data/support/cs/src/CauterizeFormatter.cs +7 -5
  51. data/support/cs/src/CauterizeTypes.cs +45 -5
  52. metadata +50 -18
@@ -16,6 +16,8 @@ module Cauterize
16
16
  end
17
17
  end
18
18
 
19
+ it { can_be_documented(Cauterize::Enumeration) }
20
+
19
21
  describe :value do
20
22
  it "adds a new value to the enumeration" do
21
23
  enum = Cauterize.enumeration(:foo) do |e|
@@ -23,6 +23,8 @@ module Cauterize
23
23
  end
24
24
  end
25
25
 
26
+ it { can_be_documented(Cauterize::FixedArray) }
27
+
26
28
  describe :array_type do
27
29
  it "Defines the type of the FixedArray." do
28
30
  Cauterize.scalar(:uint32_t)
data/spec/group_spec.rb CHANGED
@@ -42,6 +42,8 @@ module Cauterize
42
42
  end
43
43
  end
44
44
 
45
+ it { can_be_documented(Cauterize::Group) }
46
+
45
47
  describe :field do
46
48
  it "adds a field to the Group" do
47
49
  a = Cauterize.scalar(:aaa)
@@ -85,8 +87,8 @@ module Cauterize
85
87
 
86
88
  it "allows nil types" do
87
89
  grp = Cauterize.group(:empty) do |g|
88
- g.field(:a)
89
- g.field(:b)
90
+ g.dataless(:a)
91
+ g.dataless(:b)
90
92
  end
91
93
 
92
94
  grp.tag_enum.values.keys.should =~ [:GROUP_EMPTY_TYPE_A, :GROUP_EMPTY_TYPE_B]
data/spec/scalar_spec.rb CHANGED
@@ -6,6 +6,8 @@ module Cauterize
6
6
  end
7
7
  end
8
8
 
9
+ it { can_be_documented(Cauterize::Scalar) }
10
+
9
11
  describe :id do
10
12
  it { has_a_unique_id_for_each_instance(Scalar) }
11
13
  end
data/spec/spec_helper.rb CHANGED
@@ -35,6 +35,10 @@ module Cauterize
35
35
  Cauterize.create_builtins
36
36
  end
37
37
 
38
+ def can_be_documented(klass)
39
+ klass.new(:dokumented_klass, "precious documentation").description.should == "precious documentation"
40
+ end
41
+
38
42
  def is_tagged_as(cls, tag)
39
43
  cls.new(:foo).tag.should == tag
40
44
  end
@@ -18,7 +18,7 @@ typedef enum cauterize_status {
18
18
  CA_ERR_INVALID_LENGTH = 4,
19
19
  CA_ERR_INVALUD_TYPE_TAG = 5,
20
20
  CA_ERR_INVALID_ENUM_VAL = 6,
21
- CA_ERR_GENERAL = UINT32_MAX,
21
+ CA_ERR_GENERAL = INT32_MAX,
22
22
  } CAUTERIZE_STATUS_T;
23
23
 
24
24
  struct Cauterize {
@@ -1,9 +1,6 @@
1
1
  using System;
2
- using System.Collections.Generic;
3
2
  using System.IO;
4
- using System.Reflection;
5
3
  using System.Runtime.Serialization;
6
- using System.Text;
7
4
 
8
5
  namespace Cauterize
9
6
  {
@@ -26,8 +23,13 @@ namespace Cauterize
26
23
 
27
24
  public virtual T Deserialize<T>(Stream serializationStream)
28
25
  {
29
- var formatter = _formatterFactory.GetFormatter(typeof(T));
30
- return (T)formatter.Deserialize(serializationStream, typeof(T));
26
+ return (T)Deserialize(serializationStream, typeof (T));
27
+ }
28
+
29
+ public virtual object Deserialize(Stream serializationStream, Type t)
30
+ {
31
+ var formatter = _formatterFactory.GetFormatter(t);
32
+ return formatter.Deserialize(serializationStream, t);
31
33
  }
32
34
 
33
35
  public virtual void Serialize(Stream serializationStream, object obj)
@@ -1,21 +1,45 @@
1
1
  using System;
2
- using System.Collections.Generic;
3
- using System.Text;
4
2
 
5
3
  namespace Cauterize
6
4
  {
7
5
  public class CauterizeInfo {
8
- public static string Name;
9
- public static string GeneratedVersion;
10
- public static string GeneratedDate;
6
+ public string Name;
7
+ public string GeneratedVersion;
8
+ public string GeneratedDate;
11
9
  }
12
10
 
13
11
  public class CauterizeComposite
14
12
  {
13
+ public override string ToString()
14
+ {
15
+ var result = "{";
16
+ foreach (var prop in OrderAttribute.GetSortedProperties(GetType()))
17
+ {
18
+ result += String.Format("{0}: {1}, ", prop.Name, prop.GetValue(this, null));
19
+ }
20
+ result = result.TrimEnd(',', ' ');
21
+ result += "}";
22
+ return result;
23
+ }
15
24
  }
16
25
 
17
26
  public class CauterizeGroup
18
27
  {
28
+ public override string ToString()
29
+ {
30
+ var enumProp = OrderAttribute.GetPropertyByOrder(GetType(), 0);
31
+ var value = enumProp.GetValue(this, null);
32
+ var index = (int) value + 1;
33
+ var prop = OrderAttribute.GetPropertyByOrder(GetType(), index);
34
+ if (prop != null)
35
+ {
36
+ return String.Format("({0}: {1})", prop.Name, prop.GetValue(this, null));
37
+ }
38
+ else
39
+ {
40
+ return String.Format("({0})", value);
41
+ }
42
+ }
19
43
  }
20
44
 
21
45
  public abstract class CauterizeFixedArray
@@ -48,6 +72,14 @@ namespace Cauterize
48
72
  return array._data;
49
73
  }
50
74
 
75
+ public override string ToString()
76
+ {
77
+ var result = "[";
78
+ result += String.Join(", ", _data);
79
+ result += "]";
80
+ return result;
81
+ }
82
+
51
83
  // implicit conversion won't cover slicing
52
84
  public T this[int i]
53
85
  {
@@ -91,6 +123,14 @@ namespace Cauterize
91
123
  return array._data;
92
124
  }
93
125
 
126
+ public override string ToString()
127
+ {
128
+ var result = "[";
129
+ result += String.Join(", ", _data);
130
+ result += "]";
131
+ return result;
132
+ }
133
+
94
134
  // implicit conversion won't cover slicing
95
135
  public T this[int i]
96
136
  {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cauterize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre5
4
+ version: 0.0.1.pre7
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-20 00:00:00.000000000 Z
12
+ date: 2013-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: 0.9.2.0
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.9.2.0
30
30
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - ">="
36
36
  - !ruby/object:Gem::Version
37
37
  version: 0.16.0
38
38
  type: :runtime
@@ -40,7 +40,7 @@ dependencies:
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - ">="
44
44
  - !ruby/object:Gem::Version
45
45
  version: 0.16.0
46
46
  - !ruby/object:Gem::Dependency
@@ -48,7 +48,7 @@ dependencies:
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: 1.2.1
54
54
  type: :runtime
@@ -56,15 +56,31 @@ dependencies:
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.2.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: bindata
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '1.5'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '1.5'
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: rspec
64
80
  requirement: !ruby/object:Gem::Requirement
65
81
  none: false
66
82
  requirements:
67
- - - ! '>='
83
+ - - ">="
68
84
  - !ruby/object:Gem::Version
69
85
  version: 2.12.0
70
86
  type: :development
@@ -72,7 +88,7 @@ dependencies:
72
88
  version_requirements: !ruby/object:Gem::Requirement
73
89
  none: false
74
90
  requirements:
75
- - - ! '>='
91
+ - - ">="
76
92
  - !ruby/object:Gem::Version
77
93
  version: 2.12.0
78
94
  - !ruby/object:Gem::Dependency
@@ -80,7 +96,7 @@ dependencies:
80
96
  requirement: !ruby/object:Gem::Requirement
81
97
  none: false
82
98
  requirements:
83
- - - ! '>='
99
+ - - ">="
84
100
  - !ruby/object:Gem::Version
85
101
  version: 0.13.0
86
102
  type: :development
@@ -88,7 +104,7 @@ dependencies:
88
104
  version_requirements: !ruby/object:Gem::Requirement
89
105
  none: false
90
106
  requirements:
91
- - - ! '>='
107
+ - - ">="
92
108
  - !ruby/object:Gem::Version
93
109
  version: 0.13.0
94
110
  description: Tools to generate C structures and marshalers with a Ruby DSL.
@@ -99,9 +115,9 @@ executables:
99
115
  extensions: []
100
116
  extra_rdoc_files: []
101
117
  files:
102
- - .gitignore
103
- - .rspec
104
- - .travisci.yml
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travisci.yml"
105
121
  - Gemfile
106
122
  - LICENSE.txt
107
123
  - README.md
@@ -110,6 +126,9 @@ files:
110
126
  - cauterize.gemspec
111
127
  - example/Cauterize
112
128
  - example/build.sh
129
+ - example/doc_cauterize_output/example_project.txt
130
+ - example/ruby_ex.rb
131
+ - lib/cauterize.rb
113
132
  - lib/cauterize/base_type.rb
114
133
  - lib/cauterize/builders.rb
115
134
  - lib/cauterize/builders/c/buildable.rb
@@ -129,11 +148,20 @@ files:
129
148
  - lib/cauterize/builders/cs/group.rb
130
149
  - lib/cauterize/builders/cs/scalar.rb
131
150
  - lib/cauterize/builders/cs/variable_array.rb
151
+ - lib/cauterize/builders/doc/buildable.rb
152
+ - lib/cauterize/builders/doc/builtin.rb
153
+ - lib/cauterize/builders/doc/composite.rb
154
+ - lib/cauterize/builders/doc/enumeration.rb
155
+ - lib/cauterize/builders/doc/fixed_array.rb
156
+ - lib/cauterize/builders/doc/group.rb
157
+ - lib/cauterize/builders/doc/scalar.rb
158
+ - lib/cauterize/builders/doc/variable_array.rb
132
159
  - lib/cauterize/builtin.rb
133
160
  - lib/cauterize/c_builder.rb
134
161
  - lib/cauterize/cauterize.rb
135
162
  - lib/cauterize/composite.rb
136
163
  - lib/cauterize/cs_builder.rb
164
+ - lib/cauterize/doc_builder.rb
137
165
  - lib/cauterize/enumeration.rb
138
166
  - lib/cauterize/fixed_array.rb
139
167
  - lib/cauterize/formatter.rb
@@ -158,12 +186,14 @@ files:
158
186
  - spec/builders/cs/group_spec.rb
159
187
  - spec/builders/cs/scalar_spec.rb
160
188
  - spec/builders/cs/variable_array_spec.rb
189
+ - spec/builders/doc/buildable_spec.rb
161
190
  - spec/builders_spec.rb
162
191
  - spec/builtin_spec.rb
163
192
  - spec/c_builder_spec.rb
164
193
  - spec/cauterize_spec.rb
165
194
  - spec/composite_spec.rb
166
195
  - spec/cs_builder_spec.rb
196
+ - spec/doc_builder_spec.rb
167
197
  - spec/enumeration_spec.rb
168
198
  - spec/fixed_array_spec.rb
169
199
  - spec/group_spec.rb
@@ -216,16 +246,16 @@ require_paths:
216
246
  required_ruby_version: !ruby/object:Gem::Requirement
217
247
  none: false
218
248
  requirements:
219
- - - ! '>='
249
+ - - ">="
220
250
  - !ruby/object:Gem::Version
221
251
  version: '0'
222
252
  segments:
223
253
  - 0
224
- hash: -69308014069678082
254
+ hash: -3520063422642430845
225
255
  required_rubygems_version: !ruby/object:Gem::Requirement
226
256
  none: false
227
257
  requirements:
228
- - - ! '>'
258
+ - - ">"
229
259
  - !ruby/object:Gem::Version
230
260
  version: 1.3.1
231
261
  requirements: []
@@ -251,12 +281,14 @@ test_files:
251
281
  - spec/builders/cs/group_spec.rb
252
282
  - spec/builders/cs/scalar_spec.rb
253
283
  - spec/builders/cs/variable_array_spec.rb
284
+ - spec/builders/doc/buildable_spec.rb
254
285
  - spec/builders_spec.rb
255
286
  - spec/builtin_spec.rb
256
287
  - spec/c_builder_spec.rb
257
288
  - spec/cauterize_spec.rb
258
289
  - spec/composite_spec.rb
259
290
  - spec/cs_builder_spec.rb
291
+ - spec/doc_builder_spec.rb
260
292
  - spec/enumeration_spec.rb
261
293
  - spec/fixed_array_spec.rb
262
294
  - spec/group_spec.rb