class DataManager
Public Class Methods
new(template, manager)
click to toggle source
# File template.rb, line 1088 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 1121 def align(value) value_in_bytes = @template.alignment_in_bytes(value) @builder.align value, value_in_bytes end
beginConfig(target, addressableSize)
click to toggle source
# File template.rb, line 1096 def beginConfig(target, addressableSize) @configurer = @manager.beginConfig target, addressableSize end
beginData(global, separate_file)
click to toggle source
# File template.rb, line 1105 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 1210 def comment(value) @builder.addComment value end
data(attrs = {}, &contents)
click to toggle source
# File template.rb, line 1218 def data(attrs = {}, &contents) self.instance_eval &contents end
define_ascii_string(attrs)
click to toggle source
# File template.rb, line 1192 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 1178 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 1160 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 1152 def dist(*ranges) @template.dist *ranges end
endConfig()
click to toggle source
# File template.rb, line 1100 def endConfig @manager.endConfig @configurer = nil end
endData()
click to toggle source
# File template.rb, line 1113 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 1144 def label(id) @builder.addLabel id end
method_missing(meth, *args, &block)
click to toggle source
# File template.rb, line 1222 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 1126 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 1148 def rand(from, to) @template.rand from, to end
range(attrs = {})
click to toggle source
# File template.rb, line 1156 def range(attrs = {}) @template.range attrs end
text(value)
click to toggle source
# File template.rb, line 1206 def text(value) @builder.addText value end
type(*args)
click to toggle source
# File template.rb, line 1140 def type(*args) Type.new *args end
value(*args)
click to toggle source
# File template.rb, line 1214 def value(*args) @template.value *args end