Class: TurboRex::CStruct::StructMgr
- Inherits:
-
Object
- Object
- TurboRex::CStruct::StructMgr
show all
- Defined in:
- lib/turborex/cstruct.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(opts) ⇒ StructMgr
Returns a new instance of StructMgr.
251
252
253
254
|
# File 'lib/turborex/cstruct.rb', line 251
def initialize(opts)
@structs_table = {}
@opts = opts
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
273
274
275
276
277
278
279
280
|
# 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
|
Instance Attribute Details
#structs_table ⇒ Object
Returns the value of attribute structs_table.
249
250
251
|
# File 'lib/turborex/cstruct.rb', line 249
def structs_table
@structs_table
end
|
Instance Method Details
#[](name) ⇒ Object
256
257
258
|
# File 'lib/turborex/cstruct.rb', line 256
def [](name)
@structs_table[name.to_sym]
end
|
#build ⇒ Object
260
261
262
|
# File 'lib/turborex/cstruct.rb', line 260
def build
self
end
|
#struct(obj) ⇒ Object
264
265
266
267
268
269
270
271
|
# 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
|