class TurboRex::CStruct::StructMgr

Attributes

structs_table[R]

Public Class Methods

new(opts) click to toggle source
# File lib/turborex/cstruct.rb, line 251
def initialize(opts)
  @structs_table = {}
  @opts = opts
end

Public Instance Methods

[](name) click to toggle source
# File lib/turborex/cstruct.rb, line 256
def [](name)
  @structs_table[name.to_sym]
end
build() click to toggle source
# File lib/turborex/cstruct.rb, line 260
def build
  self
end
method_missing(m, *args, &block) click to toggle source
# File lib/turborex/cstruct.rb, line 273
def method_missing(m, *args, &block)
  if block
    arch = @opts[:arch] || 'x86'
    return Docile.dsl_eval(CStructBuilder.new(arch), &block).build(m.to_s)
  end

  FieldsProxy.new m.to_s
end
struct(obj) click to toggle source
# File lib/turborex/cstruct.rb, line 264
def struct(obj)
  @structs_table[obj.struct_name.to_sym] = obj
  TurboRex::CStruct::CStructBuilder.create_method(obj.struct_name.to_sym) do |name|
    self.s.template << ['template', name.to_s, obj.s]
  end

  self
end