File: namespace.rb

package info (click to toggle)
ruby-cstruct 1.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 412 kB
  • sloc: ruby: 1,008; makefile: 7
file content (29 lines) | stat: -rw-r--r-- 432 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# CStruct Examples
require 'cstruct'

# example:
module NS1    #namespace
  class A < CStruct
    uint32:handle
  end

  module NS2
    class B < CStruct
        A:a # directly use A
    end 
  end

  class C < CStruct
    A     :a
    NS2_B :b  # Meaning of the 'NS2_B' is NS2::B
  end 
end

class D < CStruct
  NS1_NS2_B:b # Meaning of the 'NS1_NS2_B' is NS1::NS2::B
end 

v = D.new
v.b.a.handle = 120
p D.__size__
p v.b.a.handle