class DataManager
Public Class Methods
new(template, manager)
click to toggle source
# File template.rb, line 977 def initialize(template, manager) @template = template @manager = manager @builder = nil @ref_count = 0 end
Public Instance Methods
align(value)
click to toggle source
# File template.rb, line 1010 def align(value) value_in_bytes = @template.alignment_in_bytes(value) @builder.align value, value_in_bytes end
beginConfig(text, target, addressableSize, baseVirtAddr)
click to toggle source
# File template.rb, line 985 def beginConfig(text, target, addressableSize, baseVirtAddr) @configurer = @manager.beginConfig text, target, addressableSize, baseVirtAddr end
beginData(global, separate_file)
click to toggle source
# File template.rb, line 994 def beginData(global, separate_file) if @ref_count == 0 @builder = @template.template.beginData global, separate_file end @ref_count = @ref_count + 1 @builder end
comment(value)
click to toggle source
# File template.rb, line 1099 def comment(value) @manager.addComment value end
data(attrs = {}, &contents)
click to toggle source
# File template.rb, line 1107 def data(attrs = {}, &contents) self.instance_eval &contents end
define_ascii_string(attrs)
click to toggle source
# File template.rb, line 1081 def define_ascii_string(attrs) id = get_attribute attrs, :id text = get_attribute attrs, :text zeroTerm = get_attribute attrs, :zero_term @configurer.defineAsciiString id, text, zeroTerm p = lambda do |*strings| @builder.addAsciiStrings zeroTerm, strings end define_method_for DataManager, id, 'string', p end
define_space(attrs)
click to toggle source
# File template.rb, line 1067 def define_space(attrs) id = get_attribute attrs, :id text = get_attribute attrs, :text fillWith = get_attribute attrs, :fill_with @configurer.defineSpace id, text, fillWith p = lambda do |length| @builder.addSpace length end define_method_for DataManager, id, 'space', p end
define_type(attrs)
click to toggle source
# File template.rb, line 1049 def define_type(attrs) id = get_attribute attrs, :id text = get_attribute attrs, :text type = get_attribute attrs, :type @configurer.defineType id, text, type.name, type.args p = lambda do |*arguments| dataBuilder = @builder.addDataValues id arguments.each do |value| dataBuilder.add value end dataBuilder.build end define_method_for DataManager, id, 'type', p end
dist(*ranges)
click to toggle source
# File template.rb, line 1041 def dist(*ranges) @template.dist *ranges end
endConfig()
click to toggle source
# File template.rb, line 989 def endConfig @manager.endConfig @configurer = nil end
endData()
click to toggle source
# File template.rb, line 1002 def endData @ref_count = @ref_count - 1 if @ref_count == 0 @template.template.endData @builder = nil end end
label(id)
click to toggle source
# File template.rb, line 1033 def label(id) @builder.addLabel id end
method_missing(meth, *args, &block)
click to toggle source
# File template.rb, line 1111 def method_missing(meth, *args, &block) # Redirecting call to the template. Note: methods of Template are not accepted. if @template.respond_to?(meth) and not Template.instance_methods.include?(meth) @template.send meth, *args, &block else raise MTRubyError, "Method '#{meth}' is not available in data sections." end end
org(origin)
click to toggle source
# File template.rb, line 1015 def org(origin) if origin.is_a?(Integer) @builder.setOrigin origin elsif origin.is_a?(Hash) delta = get_attribute origin, :delta if !delta.is_a?(Integer) raise MTRubyError, "delta (#{delta}) must be an Integer." end @builder.setRelativeOrigin delta else raise MTRubyError, "origin (#{origin}) must be an Integer or a Hash." end end
rand(from, to)
click to toggle source
# File template.rb, line 1037 def rand(from, to) @template.rand from, to end
range(attrs = {})
click to toggle source
# File template.rb, line 1045 def range(attrs = {}) @template.range attrs end
text(value)
click to toggle source
# File template.rb, line 1095 def text(value) @manager.addText value end
type(*args)
click to toggle source
# File template.rb, line 1029 def type(*args) Type.new *args end
value(*args)
click to toggle source
# File template.rb, line 1103 def value(*args) @template.value *args end