class DataManager
Public Class Methods
new(template, manager)
click to toggle source
# File template.rb, line 1023 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 1056 def align(value) value_in_bytes = @template.alignment_in_bytes(value) @builder.align value, value_in_bytes end
beginConfig(target, addressableSize, baseVirtAddr)
click to toggle source
# File template.rb, line 1031 def beginConfig(target, addressableSize, baseVirtAddr) @configurer = @manager.beginConfig target, addressableSize, baseVirtAddr end
beginData(global, separate_file)
click to toggle source
# File template.rb, line 1040 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 1145 def comment(value) @builder.addComment value end
data(attrs = {}, &contents)
click to toggle source
# File template.rb, line 1153 def data(attrs = {}, &contents) self.instance_eval &contents end
define_ascii_string(attrs)
click to toggle source
# File template.rb, line 1127 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 1113 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 1095 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 1087 def dist(*ranges) @template.dist *ranges end
endConfig()
click to toggle source
# File template.rb, line 1035 def endConfig @manager.endConfig @configurer = nil end
endData()
click to toggle source
# File template.rb, line 1048 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 1079 def label(id) @builder.addLabel id end
method_missing(meth, *args, &block)
click to toggle source
# File template.rb, line 1157 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 1061 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 1083 def rand(from, to) @template.rand from, to end
range(attrs = {})
click to toggle source
# File template.rb, line 1091 def range(attrs = {}) @template.range attrs end
text(value)
click to toggle source
# File template.rb, line 1141 def text(value) @builder.addText value end
type(*args)
click to toggle source
# File template.rb, line 1075 def type(*args) Type.new *args end
value(*args)
click to toggle source
# File template.rb, line 1149 def value(*args) @template.value *args end