cstruct 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +81 -0
- data/cstruct.gemspec +10 -0
- data/doc/examples/anonymous_struct.rb.html +94 -94
- data/doc/examples/anonymous_union.rb.html +93 -93
- data/doc/examples/array_member.rb.html +79 -79
- data/doc/examples/file_io.rb.html +87 -87
- data/doc/examples/first_example.rb.html +104 -104
- data/doc/examples/get_system_info.rb.html +114 -114
- data/doc/examples/get_versionex.rb.html +97 -97
- data/doc/examples/global_memory.rb.html +102 -102
- data/doc/examples/inner_struct.rb.html +79 -79
- data/doc/examples/inner_union.rb.html +77 -77
- data/doc/examples/namespace.rb.html +80 -80
- data/doc/examples/show_processes.rb.html +95 -95
- data/doc/examples/struct_member.rb.html +128 -128
- data/doc/stylesheets/ie.css +8 -8
- data/examples/anonymous_struct.rb +6 -6
- data/examples/anonymous_union.rb +5 -5
- data/examples/array_member.rb +1 -1
- data/examples/file_io.rb +22 -23
- data/examples/first_example.rb +4 -4
- data/examples/inner_struct.rb +5 -5
- data/examples/inner_union.rb +4 -4
- data/examples/namespace.rb +15 -15
- data/examples/win32/get_system_info.rb +31 -31
- data/examples/win32/get_versionex.rb +12 -12
- data/examples/win32/global_memory.rb +9 -9
- data/examples/win32/show_processes.rb +28 -28
- data/lib/cstruct.rb +1 -523
- data/lib/cstruct/cstruct.rb +457 -0
- data/lib/cstruct/field.rb +45 -0
- data/lib/cstruct/utils.rb +53 -0
- data/lib/cstruct/win32struct.rb +84 -0
- data/lib/cstruct/win64struct.rb +5 -0
- data/lib/win32struct.rb +3 -90
- data/lib/win64struct.rb +3 -13
- data/spec/cstruct_spec.rb +240 -0
- metadata +62 -73
@@ -1,79 +1,79 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
-
<head profile="http://gmpg.org/xfn/11" >
|
4
|
-
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
-
<title>CStruct:Examples:Inner struct</title>
|
6
|
-
<style type="text/css">
|
7
|
-
|
8
|
-
.CodeRay {
|
9
|
-
background-color: #232323;
|
10
|
-
border: 1px solid black;
|
11
|
-
font-family: 'Courier New', 'Terminal', monospace;
|
12
|
-
color: #E6E0DB;
|
13
|
-
padding: 3px 5px;
|
14
|
-
overflow: auto;
|
15
|
-
font-size: 12px;
|
16
|
-
margin: 12px 0;
|
17
|
-
}
|
18
|
-
.CodeRay pre {
|
19
|
-
margin: 0px;
|
20
|
-
padding: 0px;
|
21
|
-
}
|
22
|
-
|
23
|
-
.CodeRay .an { color:#E7BE69 }
|
24
|
-
.CodeRay .c { color:#BC9358; font-style: italic; }
|
25
|
-
.CodeRay .ch { color:#509E4F }
|
26
|
-
.CodeRay .cl { color:#FFF }
|
27
|
-
.CodeRay .co { color:#FFF }
|
28
|
-
.CodeRay .fl { color:#A4C260 }
|
29
|
-
.CodeRay .fu { color:#FFC56D }
|
30
|
-
.CodeRay .gv { color:#D0CFFE }
|
31
|
-
.CodeRay .i { color:#A4C260 }
|
32
|
-
.CodeRay .il { background:#151515 }
|
33
|
-
.CodeRay .iv { color:#D0CFFE }
|
34
|
-
.CodeRay .pp { color:#E7BE69 }
|
35
|
-
.CodeRay .r { color:#CB7832 }
|
36
|
-
.CodeRay .rx { color:#A4C260 }
|
37
|
-
.CodeRay .s { color:#A4C260 }
|
38
|
-
.CodeRay .sy { color:#6C9CBD }
|
39
|
-
.CodeRay .ta { color:#E7BE69 }
|
40
|
-
.CodeRay .pc { color:#6C9CBD }
|
41
|
-
|
42
|
-
</style>
|
43
|
-
</head>
|
44
|
-
<body>
|
45
|
-
<div style="margin-left:auto;margin-right:auto;width:800px;">
|
46
|
-
<div class="CodeRay">
|
47
|
-
<div class="code"><pre><span class="c"># CStruct Examples</span>
|
48
|
-
require <span class="s"><span class="dl">'</span><span class="k">cstruct</span><span class="dl">'</span></span>
|
49
|
-
<span class="c"># example:</span>
|
50
|
-
<span class="c"># struct A in C\C++ (32-bit platform): </span>
|
51
|
-
<span class="c"># struct A{</span>
|
52
|
-
<span class="c"># struct Inner</span>
|
53
|
-
<span class="c"># {</span>
|
54
|
-
<span class="c"># int v1; </span>
|
55
|
-
<span class="c"># int v2;</span>
|
56
|
-
<span class="c"># };</span>
|
57
|
-
<span class="c"># Inner inner;</span>
|
58
|
-
<span class="c"># };</span>
|
59
|
-
|
60
|
-
<span class="c"># struct A in Ruby:</span>
|
61
|
-
<span class="r">class</span> <span class="cl">A</span> < <span class="co">CStruct</span>
|
62
|
-
<span class="r">class</span> <span class="cl">Inner</span> < <span class="co">CStruct</span>
|
63
|
-
int32 <span class="sy">:v1</span>
|
64
|
-
int32 <span class="sy">:v2</span>
|
65
|
-
<span class="r">end</span>
|
66
|
-
<span class="co">Inner</span> <span class="sy">:inner</span>
|
67
|
-
<span class="r">end</span>
|
68
|
-
|
69
|
-
a = <span class="co">A</span>.new
|
70
|
-
a.inner.v1 = <span class="i">1</span>
|
71
|
-
a.inner.v2 = <span class="i">2</span>
|
72
|
-
|
73
|
-
puts a.inner.v1
|
74
|
-
puts a.inner.v2
|
75
|
-
</pre></div>
|
76
|
-
</div>
|
77
|
-
|
78
|
-
</div>
|
79
|
-
</body>
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
+
<head profile="http://gmpg.org/xfn/11" >
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
+
<title>CStruct:Examples:Inner struct</title>
|
6
|
+
<style type="text/css">
|
7
|
+
|
8
|
+
.CodeRay {
|
9
|
+
background-color: #232323;
|
10
|
+
border: 1px solid black;
|
11
|
+
font-family: 'Courier New', 'Terminal', monospace;
|
12
|
+
color: #E6E0DB;
|
13
|
+
padding: 3px 5px;
|
14
|
+
overflow: auto;
|
15
|
+
font-size: 12px;
|
16
|
+
margin: 12px 0;
|
17
|
+
}
|
18
|
+
.CodeRay pre {
|
19
|
+
margin: 0px;
|
20
|
+
padding: 0px;
|
21
|
+
}
|
22
|
+
|
23
|
+
.CodeRay .an { color:#E7BE69 }
|
24
|
+
.CodeRay .c { color:#BC9358; font-style: italic; }
|
25
|
+
.CodeRay .ch { color:#509E4F }
|
26
|
+
.CodeRay .cl { color:#FFF }
|
27
|
+
.CodeRay .co { color:#FFF }
|
28
|
+
.CodeRay .fl { color:#A4C260 }
|
29
|
+
.CodeRay .fu { color:#FFC56D }
|
30
|
+
.CodeRay .gv { color:#D0CFFE }
|
31
|
+
.CodeRay .i { color:#A4C260 }
|
32
|
+
.CodeRay .il { background:#151515 }
|
33
|
+
.CodeRay .iv { color:#D0CFFE }
|
34
|
+
.CodeRay .pp { color:#E7BE69 }
|
35
|
+
.CodeRay .r { color:#CB7832 }
|
36
|
+
.CodeRay .rx { color:#A4C260 }
|
37
|
+
.CodeRay .s { color:#A4C260 }
|
38
|
+
.CodeRay .sy { color:#6C9CBD }
|
39
|
+
.CodeRay .ta { color:#E7BE69 }
|
40
|
+
.CodeRay .pc { color:#6C9CBD }
|
41
|
+
|
42
|
+
</style>
|
43
|
+
</head>
|
44
|
+
<body>
|
45
|
+
<div style="margin-left:auto;margin-right:auto;width:800px;">
|
46
|
+
<div class="CodeRay">
|
47
|
+
<div class="code"><pre><span class="c"># CStruct Examples</span>
|
48
|
+
require <span class="s"><span class="dl">'</span><span class="k">cstruct</span><span class="dl">'</span></span>
|
49
|
+
<span class="c"># example:</span>
|
50
|
+
<span class="c"># struct A in C\C++ (32-bit platform): </span>
|
51
|
+
<span class="c"># struct A{</span>
|
52
|
+
<span class="c"># struct Inner</span>
|
53
|
+
<span class="c"># {</span>
|
54
|
+
<span class="c"># int v1; </span>
|
55
|
+
<span class="c"># int v2;</span>
|
56
|
+
<span class="c"># };</span>
|
57
|
+
<span class="c"># Inner inner;</span>
|
58
|
+
<span class="c"># };</span>
|
59
|
+
|
60
|
+
<span class="c"># struct A in Ruby:</span>
|
61
|
+
<span class="r">class</span> <span class="cl">A</span> < <span class="co">CStruct</span>
|
62
|
+
<span class="r">class</span> <span class="cl">Inner</span> < <span class="co">CStruct</span>
|
63
|
+
int32 <span class="sy">:v1</span>
|
64
|
+
int32 <span class="sy">:v2</span>
|
65
|
+
<span class="r">end</span>
|
66
|
+
<span class="co">Inner</span> <span class="sy">:inner</span>
|
67
|
+
<span class="r">end</span>
|
68
|
+
|
69
|
+
a = <span class="co">A</span>.new
|
70
|
+
a.inner.v1 = <span class="i">1</span>
|
71
|
+
a.inner.v2 = <span class="i">2</span>
|
72
|
+
|
73
|
+
puts a.inner.v1
|
74
|
+
puts a.inner.v2
|
75
|
+
</pre></div>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
</div>
|
79
|
+
</body>
|
@@ -1,77 +1,77 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
-
<head profile="http://gmpg.org/xfn/11" >
|
4
|
-
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
-
<title>CStruct:Examples:Inner union</title>
|
6
|
-
<style type="text/css">
|
7
|
-
|
8
|
-
.CodeRay {
|
9
|
-
background-color: #232323;
|
10
|
-
border: 1px solid black;
|
11
|
-
font-family: 'Courier New', 'Terminal', monospace;
|
12
|
-
color: #E6E0DB;
|
13
|
-
padding: 3px 5px;
|
14
|
-
overflow: auto;
|
15
|
-
font-size: 12px;
|
16
|
-
margin: 12px 0;
|
17
|
-
}
|
18
|
-
.CodeRay pre {
|
19
|
-
margin: 0px;
|
20
|
-
padding: 0px;
|
21
|
-
}
|
22
|
-
|
23
|
-
.CodeRay .an { color:#E7BE69 }
|
24
|
-
.CodeRay .c { color:#BC9358; font-style: italic; }
|
25
|
-
.CodeRay .ch { color:#509E4F }
|
26
|
-
.CodeRay .cl { color:#FFF }
|
27
|
-
.CodeRay .co { color:#FFF }
|
28
|
-
.CodeRay .fl { color:#A4C260 }
|
29
|
-
.CodeRay .fu { color:#FFC56D }
|
30
|
-
.CodeRay .gv { color:#D0CFFE }
|
31
|
-
.CodeRay .i { color:#A4C260 }
|
32
|
-
.CodeRay .il { background:#151515 }
|
33
|
-
.CodeRay .iv { color:#D0CFFE }
|
34
|
-
.CodeRay .pp { color:#E7BE69 }
|
35
|
-
.CodeRay .r { color:#CB7832 }
|
36
|
-
.CodeRay .rx { color:#A4C260 }
|
37
|
-
.CodeRay .s { color:#A4C260 }
|
38
|
-
.CodeRay .sy { color:#6C9CBD }
|
39
|
-
.CodeRay .ta { color:#E7BE69 }
|
40
|
-
.CodeRay .pc { color:#6C9CBD }
|
41
|
-
|
42
|
-
</style>
|
43
|
-
</head>
|
44
|
-
<body>
|
45
|
-
<div style="margin-left:auto;margin-right:auto;width:800px;">
|
46
|
-
<div class="CodeRay">
|
47
|
-
<div class="code"><pre><span class="c"># CStruct Examples</span>
|
48
|
-
require <span class="s"><span class="dl">'</span><span class="k">cstruct</span><span class="dl">'</span></span>
|
49
|
-
|
50
|
-
<span class="c"># example:</span>
|
51
|
-
<span class="c"># struct U in C\C++ (32-bit platform): </span>
|
52
|
-
<span class="c"># </span>
|
53
|
-
<span class="c">#struct U</span>
|
54
|
-
<span class="c">#{</span>
|
55
|
-
<span class="c"># union NumericType</span>
|
56
|
-
<span class="c"># {</span>
|
57
|
-
<span class="c"># int32 v1;</span>
|
58
|
-
<span class="c"># int16 v2; </span>
|
59
|
-
<span class="c"># int16 v3; </span>
|
60
|
-
<span class="c"># };</span>
|
61
|
-
<span class="c"># NumericType value;</span>
|
62
|
-
<span class="c">#};</span>
|
63
|
-
|
64
|
-
<span class="c"># Named union is nonsupport in CStruct. Fortunately, anonymous union can take the place of it.</span>
|
65
|
-
<span class="c"># struct U in Ruby: </span>
|
66
|
-
<span class="r">class</span> <span class="cl">U</span> < <span class="co">CStruct</span>
|
67
|
-
union<span class="sy">:value</span> <span class="r">do</span>
|
68
|
-
int32<span class="sy">:x</span>
|
69
|
-
int32<span class="sy">:y</span>
|
70
|
-
<span class="r">end</span>
|
71
|
-
<span class="r">end</span>
|
72
|
-
|
73
|
-
<span class="c"># See also: 'anonymous_union.rb' </span></pre></div>
|
74
|
-
</div>
|
75
|
-
|
76
|
-
</div>
|
77
|
-
</body>
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
+
<head profile="http://gmpg.org/xfn/11" >
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
+
<title>CStruct:Examples:Inner union</title>
|
6
|
+
<style type="text/css">
|
7
|
+
|
8
|
+
.CodeRay {
|
9
|
+
background-color: #232323;
|
10
|
+
border: 1px solid black;
|
11
|
+
font-family: 'Courier New', 'Terminal', monospace;
|
12
|
+
color: #E6E0DB;
|
13
|
+
padding: 3px 5px;
|
14
|
+
overflow: auto;
|
15
|
+
font-size: 12px;
|
16
|
+
margin: 12px 0;
|
17
|
+
}
|
18
|
+
.CodeRay pre {
|
19
|
+
margin: 0px;
|
20
|
+
padding: 0px;
|
21
|
+
}
|
22
|
+
|
23
|
+
.CodeRay .an { color:#E7BE69 }
|
24
|
+
.CodeRay .c { color:#BC9358; font-style: italic; }
|
25
|
+
.CodeRay .ch { color:#509E4F }
|
26
|
+
.CodeRay .cl { color:#FFF }
|
27
|
+
.CodeRay .co { color:#FFF }
|
28
|
+
.CodeRay .fl { color:#A4C260 }
|
29
|
+
.CodeRay .fu { color:#FFC56D }
|
30
|
+
.CodeRay .gv { color:#D0CFFE }
|
31
|
+
.CodeRay .i { color:#A4C260 }
|
32
|
+
.CodeRay .il { background:#151515 }
|
33
|
+
.CodeRay .iv { color:#D0CFFE }
|
34
|
+
.CodeRay .pp { color:#E7BE69 }
|
35
|
+
.CodeRay .r { color:#CB7832 }
|
36
|
+
.CodeRay .rx { color:#A4C260 }
|
37
|
+
.CodeRay .s { color:#A4C260 }
|
38
|
+
.CodeRay .sy { color:#6C9CBD }
|
39
|
+
.CodeRay .ta { color:#E7BE69 }
|
40
|
+
.CodeRay .pc { color:#6C9CBD }
|
41
|
+
|
42
|
+
</style>
|
43
|
+
</head>
|
44
|
+
<body>
|
45
|
+
<div style="margin-left:auto;margin-right:auto;width:800px;">
|
46
|
+
<div class="CodeRay">
|
47
|
+
<div class="code"><pre><span class="c"># CStruct Examples</span>
|
48
|
+
require <span class="s"><span class="dl">'</span><span class="k">cstruct</span><span class="dl">'</span></span>
|
49
|
+
|
50
|
+
<span class="c"># example:</span>
|
51
|
+
<span class="c"># struct U in C\C++ (32-bit platform): </span>
|
52
|
+
<span class="c"># </span>
|
53
|
+
<span class="c">#struct U</span>
|
54
|
+
<span class="c">#{</span>
|
55
|
+
<span class="c"># union NumericType</span>
|
56
|
+
<span class="c"># {</span>
|
57
|
+
<span class="c"># int32 v1;</span>
|
58
|
+
<span class="c"># int16 v2; </span>
|
59
|
+
<span class="c"># int16 v3; </span>
|
60
|
+
<span class="c"># };</span>
|
61
|
+
<span class="c"># NumericType value;</span>
|
62
|
+
<span class="c">#};</span>
|
63
|
+
|
64
|
+
<span class="c"># Named union is nonsupport in CStruct. Fortunately, anonymous union can take the place of it.</span>
|
65
|
+
<span class="c"># struct U in Ruby: </span>
|
66
|
+
<span class="r">class</span> <span class="cl">U</span> < <span class="co">CStruct</span>
|
67
|
+
union<span class="sy">:value</span> <span class="r">do</span>
|
68
|
+
int32<span class="sy">:x</span>
|
69
|
+
int32<span class="sy">:y</span>
|
70
|
+
<span class="r">end</span>
|
71
|
+
<span class="r">end</span>
|
72
|
+
|
73
|
+
<span class="c"># See also: 'anonymous_union.rb' </span></pre></div>
|
74
|
+
</div>
|
75
|
+
|
76
|
+
</div>
|
77
|
+
</body>
|
@@ -1,80 +1,80 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
-
<head profile="http://gmpg.org/xfn/11" >
|
4
|
-
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
-
<title>CStruct:Examples:Namespace</title>
|
6
|
-
<style type="text/css">
|
7
|
-
|
8
|
-
.CodeRay {
|
9
|
-
background-color: #232323;
|
10
|
-
border: 1px solid black;
|
11
|
-
font-family: 'Courier New', 'Terminal', monospace;
|
12
|
-
color: #E6E0DB;
|
13
|
-
padding: 3px 5px;
|
14
|
-
overflow: auto;
|
15
|
-
font-size: 12px;
|
16
|
-
margin: 12px 0;
|
17
|
-
}
|
18
|
-
.CodeRay pre {
|
19
|
-
margin: 0px;
|
20
|
-
padding: 0px;
|
21
|
-
}
|
22
|
-
|
23
|
-
.CodeRay .an { color:#E7BE69 }
|
24
|
-
.CodeRay .c { color:#BC9358; font-style: italic; }
|
25
|
-
.CodeRay .ch { color:#509E4F }
|
26
|
-
.CodeRay .cl { color:#FFF }
|
27
|
-
.CodeRay .co { color:#FFF }
|
28
|
-
.CodeRay .fl { color:#A4C260 }
|
29
|
-
.CodeRay .fu { color:#FFC56D }
|
30
|
-
.CodeRay .gv { color:#D0CFFE }
|
31
|
-
.CodeRay .i { color:#A4C260 }
|
32
|
-
.CodeRay .il { background:#151515 }
|
33
|
-
.CodeRay .iv { color:#D0CFFE }
|
34
|
-
.CodeRay .pp { color:#E7BE69 }
|
35
|
-
.CodeRay .r { color:#CB7832 }
|
36
|
-
.CodeRay .rx { color:#A4C260 }
|
37
|
-
.CodeRay .s { color:#A4C260 }
|
38
|
-
.CodeRay .sy { color:#6C9CBD }
|
39
|
-
.CodeRay .ta { color:#E7BE69 }
|
40
|
-
.CodeRay .pc { color:#6C9CBD }
|
41
|
-
|
42
|
-
</style>
|
43
|
-
</head>
|
44
|
-
<body>
|
45
|
-
<div style="margin-left:auto;margin-right:auto;width:800px;">
|
46
|
-
<div class="CodeRay">
|
47
|
-
<div class="code"><pre><span class="c"># CStruct Examples</span>
|
48
|
-
require <span class="s"><span class="dl">'</span><span class="k">cstruct</span><span class="dl">'</span></span>
|
49
|
-
|
50
|
-
<span class="c"># example:</span>
|
51
|
-
<span class="r">module</span> <span class="cl">NS1</span> <span class="c">#namespace</span>
|
52
|
-
<span class="r">class</span> <span class="cl">A</span> < <span class="co">CStruct</span>
|
53
|
-
uint32<span class="sy">:handle</span>
|
54
|
-
<span class="r">end</span>
|
55
|
-
|
56
|
-
<span class="r">module</span> <span class="cl">NS2</span>
|
57
|
-
<span class="r">class</span> <span class="cl">B</span> < <span class="co">CStruct</span>
|
58
|
-
<span class="co">A</span><span class="sy">:a</span> <span class="c"># directly use A</span>
|
59
|
-
<span class="r">end</span>
|
60
|
-
<span class="r">end</span>
|
61
|
-
|
62
|
-
<span class="r">class</span> <span class="cl">C</span> < <span class="co">CStruct</span>
|
63
|
-
<span class="co">A</span> <span class="sy">:a</span>
|
64
|
-
<span class="co">NS2_B</span> <span class="sy">:b</span> <span class="c"># Meaning of the 'NS2_B' is NS2::B</span>
|
65
|
-
<span class="r">end</span>
|
66
|
-
<span class="r">end</span>
|
67
|
-
|
68
|
-
<span class="r">class</span> <span class="cl">D</span> < <span class="co">CStruct</span>
|
69
|
-
<span class="co">NS1_NS2_B</span><span class="sy">:b</span> <span class="c"># Meaning of the 'NS1_NS2_B' is NS1::NS2::B</span>
|
70
|
-
<span class="r">end</span>
|
71
|
-
|
72
|
-
v = <span class="co">D</span>.new
|
73
|
-
v.b.a.handle = <span class="i">120</span>
|
74
|
-
p <span class="co">D</span>.__size__
|
75
|
-
p v.b.a.handle
|
76
|
-
</pre></div>
|
77
|
-
</div>
|
78
|
-
|
79
|
-
</div>
|
80
|
-
</body>
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
+
<head profile="http://gmpg.org/xfn/11" >
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
+
<title>CStruct:Examples:Namespace</title>
|
6
|
+
<style type="text/css">
|
7
|
+
|
8
|
+
.CodeRay {
|
9
|
+
background-color: #232323;
|
10
|
+
border: 1px solid black;
|
11
|
+
font-family: 'Courier New', 'Terminal', monospace;
|
12
|
+
color: #E6E0DB;
|
13
|
+
padding: 3px 5px;
|
14
|
+
overflow: auto;
|
15
|
+
font-size: 12px;
|
16
|
+
margin: 12px 0;
|
17
|
+
}
|
18
|
+
.CodeRay pre {
|
19
|
+
margin: 0px;
|
20
|
+
padding: 0px;
|
21
|
+
}
|
22
|
+
|
23
|
+
.CodeRay .an { color:#E7BE69 }
|
24
|
+
.CodeRay .c { color:#BC9358; font-style: italic; }
|
25
|
+
.CodeRay .ch { color:#509E4F }
|
26
|
+
.CodeRay .cl { color:#FFF }
|
27
|
+
.CodeRay .co { color:#FFF }
|
28
|
+
.CodeRay .fl { color:#A4C260 }
|
29
|
+
.CodeRay .fu { color:#FFC56D }
|
30
|
+
.CodeRay .gv { color:#D0CFFE }
|
31
|
+
.CodeRay .i { color:#A4C260 }
|
32
|
+
.CodeRay .il { background:#151515 }
|
33
|
+
.CodeRay .iv { color:#D0CFFE }
|
34
|
+
.CodeRay .pp { color:#E7BE69 }
|
35
|
+
.CodeRay .r { color:#CB7832 }
|
36
|
+
.CodeRay .rx { color:#A4C260 }
|
37
|
+
.CodeRay .s { color:#A4C260 }
|
38
|
+
.CodeRay .sy { color:#6C9CBD }
|
39
|
+
.CodeRay .ta { color:#E7BE69 }
|
40
|
+
.CodeRay .pc { color:#6C9CBD }
|
41
|
+
|
42
|
+
</style>
|
43
|
+
</head>
|
44
|
+
<body>
|
45
|
+
<div style="margin-left:auto;margin-right:auto;width:800px;">
|
46
|
+
<div class="CodeRay">
|
47
|
+
<div class="code"><pre><span class="c"># CStruct Examples</span>
|
48
|
+
require <span class="s"><span class="dl">'</span><span class="k">cstruct</span><span class="dl">'</span></span>
|
49
|
+
|
50
|
+
<span class="c"># example:</span>
|
51
|
+
<span class="r">module</span> <span class="cl">NS1</span> <span class="c">#namespace</span>
|
52
|
+
<span class="r">class</span> <span class="cl">A</span> < <span class="co">CStruct</span>
|
53
|
+
uint32<span class="sy">:handle</span>
|
54
|
+
<span class="r">end</span>
|
55
|
+
|
56
|
+
<span class="r">module</span> <span class="cl">NS2</span>
|
57
|
+
<span class="r">class</span> <span class="cl">B</span> < <span class="co">CStruct</span>
|
58
|
+
<span class="co">A</span><span class="sy">:a</span> <span class="c"># directly use A</span>
|
59
|
+
<span class="r">end</span>
|
60
|
+
<span class="r">end</span>
|
61
|
+
|
62
|
+
<span class="r">class</span> <span class="cl">C</span> < <span class="co">CStruct</span>
|
63
|
+
<span class="co">A</span> <span class="sy">:a</span>
|
64
|
+
<span class="co">NS2_B</span> <span class="sy">:b</span> <span class="c"># Meaning of the 'NS2_B' is NS2::B</span>
|
65
|
+
<span class="r">end</span>
|
66
|
+
<span class="r">end</span>
|
67
|
+
|
68
|
+
<span class="r">class</span> <span class="cl">D</span> < <span class="co">CStruct</span>
|
69
|
+
<span class="co">NS1_NS2_B</span><span class="sy">:b</span> <span class="c"># Meaning of the 'NS1_NS2_B' is NS1::NS2::B</span>
|
70
|
+
<span class="r">end</span>
|
71
|
+
|
72
|
+
v = <span class="co">D</span>.new
|
73
|
+
v.b.a.handle = <span class="i">120</span>
|
74
|
+
p <span class="co">D</span>.__size__
|
75
|
+
p v.b.a.handle
|
76
|
+
</pre></div>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
</div>
|
80
|
+
</body>
|