Class: Cheri::Builder::Generator::AutoFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/cheri/builder/generator.rb

Overview

Factory for self-building types (e.g., Cheri markup types)

Instance Method Summary collapse

Constructor Details

#initialize(mod, types) ⇒ AutoFactory

Returns a new instance of AutoFactory.



128
129
130
131
132
133
# File 'lib/cheri/builder/generator.rb', line 128

def initialize(mod,types)
  raise Cheri.type_error(types,BuildTypes) unless BuildTypes === types
  @mod = mod
  @types = types
  @inv = types.invert
end

Instance Method Details

#builder(ctx, sym, *r, &k) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/cheri/builder/generator.rb', line 134

def builder(ctx,sym,*r,&k)
  if (type = @types[sym])
    bld = type.clazz.new(ctx,sym,*r,&k)
  elsif @inv[r.first.class]
    if sym == :cherify
      CherifyBuilder.new(@mod,ctx,sym,*r,&k)
    elsif sym == :cheri_yield
      CheriYieldBuilder.new(@mod,ctx,sym,*r,&k)
    else
      nil
    end
  else
    nil
  end
end