gogyou 0.1.240911.prototype → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/{LICENSE.txt → LICENSE.markdown} +35 -39
- data/README.markdown +429 -0
- data/Rakefile +106 -0
- data/gemstub.rb +40 -0
- data/lib/gogyou.rb +264 -593
- data/lib/gogyou/accessor.rb +397 -0
- data/lib/gogyou/mixin.rb +641 -0
- data/lib/gogyou/model.rb +504 -0
- data/lib/gogyou/primitives.rb +317 -0
- data/lib/gogyou/typespec.rb +15 -0
- data/mkprims.rb +172 -0
- data/spec/gogyou_spec.rb +160 -0
- metadata +65 -34
- data/README.txt +0 -3
data/spec/gogyou_spec.rb
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
#vim: set fileencoding:utf-8
|
2
|
+
|
3
|
+
require "gogyou"
|
4
|
+
|
5
|
+
describe Gogyou do
|
6
|
+
it "basic struct-1" do
|
7
|
+
x = Gogyou.struct {
|
8
|
+
uint32_t :a
|
9
|
+
}
|
10
|
+
|
11
|
+
expect(x.ancestors).to include Gogyou::Accessor::Struct
|
12
|
+
expect(x::BYTESIZE).to eq 4
|
13
|
+
expect(x::BYTEALIGN).to eq 4
|
14
|
+
end
|
15
|
+
|
16
|
+
it "basic struct-2" do
|
17
|
+
x = Gogyou.struct {
|
18
|
+
uint32_t :a, :b
|
19
|
+
}
|
20
|
+
|
21
|
+
expect(x.ancestors).to include Gogyou::Accessor::Struct
|
22
|
+
expect(x::BYTESIZE).to eq 8
|
23
|
+
expect(x::BYTEALIGN).to eq 4
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe Gogyou::Model do
|
28
|
+
it "struct in union" do
|
29
|
+
x = Gogyou.union {
|
30
|
+
struct {
|
31
|
+
int32_t :a
|
32
|
+
}
|
33
|
+
uint32_t :b
|
34
|
+
}
|
35
|
+
|
36
|
+
reference = Gogyou::Model::Union[
|
37
|
+
4, 4,
|
38
|
+
Gogyou::Model::Field[0, :a, nil, Gogyou::Primitives::INT32_T, 0x00],
|
39
|
+
Gogyou::Model::Field[0, :b, nil, Gogyou::Primitives::UINT32_T, 0x00]
|
40
|
+
]
|
41
|
+
|
42
|
+
expect(x::MODEL).to eq reference
|
43
|
+
end
|
44
|
+
|
45
|
+
it "nested struct with anonymous fields" do
|
46
|
+
x = Gogyou.struct {
|
47
|
+
char :a
|
48
|
+
union {
|
49
|
+
int :b
|
50
|
+
struct {
|
51
|
+
int64_t :c
|
52
|
+
int32_t :d
|
53
|
+
}
|
54
|
+
}
|
55
|
+
char :e
|
56
|
+
}
|
57
|
+
|
58
|
+
ref = Gogyou::Model::Struct[
|
59
|
+
32, 8,
|
60
|
+
Gogyou::Model::Field[0, :a, nil, Gogyou::Primitives::CHAR, 0],
|
61
|
+
Gogyou::Model::Field[8, :b, nil, Gogyou::Primitives::INT, 0],
|
62
|
+
Gogyou::Model::Field[8, :c, nil, Gogyou::Primitives::INT64_T, 0],
|
63
|
+
Gogyou::Model::Field[16, :d, nil, Gogyou::Primitives::INT32_T, 0],
|
64
|
+
Gogyou::Model::Field[24, :e, nil, Gogyou::Primitives::CHAR, 0]
|
65
|
+
]
|
66
|
+
|
67
|
+
expect(x::MODEL).to eq ref
|
68
|
+
end
|
69
|
+
|
70
|
+
it "nested struct with array" do
|
71
|
+
x = Gogyou.struct {
|
72
|
+
char :a
|
73
|
+
union {
|
74
|
+
int :b
|
75
|
+
struct -> {
|
76
|
+
int64_t :c
|
77
|
+
int32_t :d
|
78
|
+
}, :e, 4
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
ref = Gogyou::Model::Struct[
|
83
|
+
72, 8,
|
84
|
+
Gogyou::Model::Field[0, :a, nil, Gogyou::Primitives::CHAR, 0x00],
|
85
|
+
Gogyou::Model::Field[8, :b, nil, Gogyou::Primitives::INT, 0x00],
|
86
|
+
Gogyou::Model::Field[8, :e, [4], Gogyou::Model::Struct[
|
87
|
+
16, 8,
|
88
|
+
Gogyou::Model::Field[0, :c, nil, Gogyou::Primitives::INT64_T, 0x00],
|
89
|
+
Gogyou::Model::Field[8, :d, nil, Gogyou::Primitives::INT32_T, 0x00]], 0x00]]
|
90
|
+
expect(x::MODEL).to eq ref
|
91
|
+
end
|
92
|
+
|
93
|
+
it "nested struct in union" do
|
94
|
+
x = Gogyou.struct {
|
95
|
+
char :a
|
96
|
+
union {
|
97
|
+
int :b
|
98
|
+
struct {
|
99
|
+
int64_t :c
|
100
|
+
int32_t :d
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
y = Gogyou.union {
|
106
|
+
struct x, :a, :b
|
107
|
+
}
|
108
|
+
|
109
|
+
ref = Gogyou::Model::Union[
|
110
|
+
24, 8,
|
111
|
+
Gogyou::Model::Field[0, :a, nil, x, 0x00],
|
112
|
+
Gogyou::Model::Field[0, :b, nil, x, 0x00]]
|
113
|
+
expect(y::MODEL).to eq ref
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe Gogyou::Accessor do
|
118
|
+
it "fixed bytesize struct" do
|
119
|
+
type = Gogyou.struct {
|
120
|
+
int32_t :a, :b, 2, 2
|
121
|
+
}
|
122
|
+
|
123
|
+
expect(type.bytesize).to eq 20
|
124
|
+
expect(type.bytealign).to eq 4
|
125
|
+
expect(type.extensible?).to eq false
|
126
|
+
|
127
|
+
obj = type.new
|
128
|
+
expect(obj.bytesize).to eq 20
|
129
|
+
end
|
130
|
+
|
131
|
+
it "extensibity struct" do
|
132
|
+
type = Gogyou.struct {
|
133
|
+
int32_t :a, :b, 2, 2
|
134
|
+
int32_t :c, 4, 0
|
135
|
+
}
|
136
|
+
|
137
|
+
expect(type.bytesize).to eq 20
|
138
|
+
expect(type.bytealign).to eq 4
|
139
|
+
expect(type.extensible?).to eq true
|
140
|
+
|
141
|
+
obj = type.new
|
142
|
+
expect(obj.bytesize).to eq 20
|
143
|
+
end
|
144
|
+
|
145
|
+
it "extensibity struct in struct" do
|
146
|
+
type = Gogyou.struct {
|
147
|
+
struct -> {
|
148
|
+
int32_t :a, :b, 2, 2
|
149
|
+
int32_t :c, 4, 0
|
150
|
+
}, :x
|
151
|
+
}
|
152
|
+
|
153
|
+
expect(type.bytesize).to eq 20
|
154
|
+
expect(type.bytealign).to eq 4
|
155
|
+
expect(type.extensible?).to eq true
|
156
|
+
|
157
|
+
obj = type.new
|
158
|
+
expect(obj.bytesize).to eq 20
|
159
|
+
end
|
160
|
+
end
|
metadata
CHANGED
@@ -1,69 +1,100 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gogyou
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease: 11
|
4
|
+
version: '0.2'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- dearblue
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
|
15
|
-
|
11
|
+
date: 2014-09-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: |
|
42
|
+
The gogyou is a library that provides auxiliary features of binary data operation for ruby.
|
16
43
|
|
17
|
-
The C
|
44
|
+
The C-liked struct, union and multidimensional array definition are posible in ruby syntax.
|
18
45
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
- By using the typedef, you can define any class.
|
24
|
-
|
25
|
-
- Definition of a one-dimensional array is possible.
|
26
|
-
|
27
|
-
'
|
46
|
+
* Usable nested struct.
|
47
|
+
* Usable nested union.
|
48
|
+
* Usable multidimensional array.
|
49
|
+
* Usable user definition types.
|
28
50
|
email: dearblue@users.sourceforge.jp
|
29
51
|
executables: []
|
30
52
|
extensions: []
|
31
53
|
extra_rdoc_files:
|
32
|
-
-
|
33
|
-
-
|
54
|
+
- LICENSE.markdown
|
55
|
+
- README.markdown
|
34
56
|
- lib/gogyou.rb
|
57
|
+
- lib/gogyou/accessor.rb
|
58
|
+
- lib/gogyou/mixin.rb
|
59
|
+
- lib/gogyou/model.rb
|
60
|
+
- lib/gogyou/typespec.rb
|
61
|
+
- lib/gogyou/primitives.rb
|
35
62
|
files:
|
36
|
-
-
|
37
|
-
-
|
63
|
+
- LICENSE.markdown
|
64
|
+
- README.markdown
|
65
|
+
- Rakefile
|
66
|
+
- gemstub.rb
|
38
67
|
- lib/gogyou.rb
|
68
|
+
- lib/gogyou/accessor.rb
|
69
|
+
- lib/gogyou/mixin.rb
|
70
|
+
- lib/gogyou/model.rb
|
71
|
+
- lib/gogyou/primitives.rb
|
72
|
+
- lib/gogyou/typespec.rb
|
73
|
+
- mkprims.rb
|
74
|
+
- spec/gogyou_spec.rb
|
39
75
|
homepage: http://sourceforge.jp/projects/rutsubo/
|
40
76
|
licenses:
|
41
77
|
- 2-clause BSD License
|
78
|
+
metadata: {}
|
42
79
|
post_install_message:
|
43
|
-
rdoc_options:
|
44
|
-
- -e
|
45
|
-
- UTF-8
|
46
|
-
- -m
|
47
|
-
- README.txt
|
80
|
+
rdoc_options: []
|
48
81
|
require_paths:
|
49
82
|
- lib
|
50
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
84
|
requirements:
|
53
|
-
- -
|
85
|
+
- - ">="
|
54
86
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
87
|
+
version: '2.0'
|
56
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
89
|
requirements:
|
59
|
-
- -
|
90
|
+
- - ">="
|
60
91
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
92
|
+
version: '0'
|
62
93
|
requirements: []
|
63
94
|
rubyforge_project:
|
64
|
-
rubygems_version:
|
95
|
+
rubygems_version: 2.4.1
|
65
96
|
signing_key:
|
66
97
|
specification_version: 3
|
67
|
-
summary:
|
98
|
+
summary: binary data operation library with the C liked struct and union
|
68
99
|
test_files: []
|
69
|
-
has_rdoc:
|
100
|
+
has_rdoc:
|
data/README.txt
DELETED