class DataManager

Public Class Methods

new(template) click to toggle source
# File template.rb, line 1149
def initialize(template)
  @template = template
  @manager = template.template.getDataManager
  @directive = Directive.new(template)

  @builder = nil
  @ref_count = 0
end

Public Instance Methods

align(value, fill_with=-1) click to toggle source
Assembler Directives (Data)
# File template.rb, line 1187
def align(value, fill_with=-1)
  @builder.addDirective @directive.align(value, fill_with)
end
balign(value, fill_with=-1) click to toggle source
# File template.rb, line 1191
def balign(value, fill_with=-1)
  @builder.addDirective @directive.balign(value, fill_with)
end
beginConfig(target, addressableSize) click to toggle source
# File template.rb, line 1158
def beginConfig(target, addressableSize)
  @configurator = @manager.beginConfig target, addressableSize
end
beginData(global, separate_file) click to toggle source
# File template.rb, line 1167
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 1211
def comment(value)
  @builder.addDirective @directive.comment(value)
end
data(attrs = {}, &contents) click to toggle source
# File template.rb, line 1292
def data(attrs = {}, &contents)
  self.instance_eval &contents
end
define_space(attrs) click to toggle source
# File template.rb, line 1242
def define_space(attrs)
  id   = get_attribute attrs, :id
  text = get_attribute attrs, :text
  data = get_attribute attrs, :fill_with

  # Defining data in data sections
  p = lambda { |length| @builder.addDirective @directive.space(text, data, length) }
  define_method_for DataManager, id, 'space', p

  # Defining data in code sections
  p = lambda { |length| @template.addDirective @directive.space(text, data, length),
                                               get_caller_location }
  define_method_for Template, id, 'space', p
end
define_string(attrs) click to toggle source
# File template.rb, line 1257
def define_string(attrs)
  id   = get_attribute attrs, :id
  text = get_attribute attrs, :text
  term = get_attribute attrs, :zero_term

  # Define data in data sections
  p = lambda { |*strings| @builder.addDirective @directive.ascii(text, term, strings) }
  define_method_for DataManager, id, 'string', p

  # Define data in data sections
  p = lambda { |*strings| @template.addDirective @directive.ascii(text, term, strings),
                                                 get_caller_location }
  define_method_for Template, id, 'string', p
end
define_type(attrs) click to toggle source
# File template.rb, line 1223
def define_type(attrs)
  id     = get_attribute attrs, :id
  text   = get_attribute attrs, :text
  type   = get_attribute attrs, :type
  format = attrs.has_key?(:format) ? attrs[:format] : ''
  align  = attrs.has_key?(:align)  ? attrs[:align]  : true

  @configurator.defineType id, text, type.name, type.args, format, align

  # Defining data in data sections
  p = lambda { |*values| @builder.addDirective @directive.data(id, values, align) }
  define_method_for DataManager, id, 'type', p

  # Defining data in code sections
  p = lambda { |*values| @template.addDirective @directive.data(id, values, align),
                                                get_caller_location }
  define_method_for Template, id, 'type', p
end
dist(*ranges) click to toggle source
# File template.rb, line 1280
def dist(*ranges)
  @template.dist *ranges
end
endConfig() click to toggle source
# File template.rb, line 1162
def endConfig
  @manager.endConfig
  @configurator = nil
end
endData() click to toggle source
# File template.rb, line 1175
def endData
  @ref_count = @ref_count - 1
  if @ref_count == 0
    @template.template.endData
    @builder = nil
  end
end
global_label(id) click to toggle source
# File template.rb, line 1219
def global_label(id)
  @builder.addLabel id, true
end
label(id) click to toggle source
# File template.rb, line 1215
def label(id)
  @builder.addLabel id, false
end
method_missing(meth, *args, &block) click to toggle source
# File template.rb, line 1296
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 "Method '#{meth}' is not available in data sections"
  end
end
option(value) click to toggle source
# File template.rb, line 1203
def option(value)
  @builder.addDirective @directive.option(value)
end
org(value, is_absolute=false) click to toggle source
# File template.rb, line 1199
def org(value, is_absolute=false)
  @builder.addDirective @directive.org(value, is_absolute)
end
p2align(value, fill_with=-1) click to toggle source
# File template.rb, line 1195
def p2align(value, fill_with=-1)
  @builder.addDirective @directive.p2align(value, fill_with)
end
rand(from, to) click to toggle source
# File template.rb, line 1276
def rand(from, to)
  @template.rand from, to
end
range(attrs = {}) click to toggle source
# File template.rb, line 1284
def range(attrs = {})
  @template.range attrs
end
text(value) click to toggle source
# File template.rb, line 1207
def text(value)
  @builder.addDirective @directive.text(value)
end
type(*args) click to toggle source
# File template.rb, line 1272
def type(*args)
  Type.new *args
end
value(*args) click to toggle source
# File template.rb, line 1288
def value(*args)
  @template.value *args
end