Class: Cheri::Builder::Generator::EvalBuilder

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

Instance Method Summary collapse

Constructor Details

#initialize(*r, &k) ⇒ EvalBuilder

Returns a new instance of EvalBuilder.



346
347
348
349
350
# File 'lib/cheri/builder/generator.rb', line 346

def initialize(*r,&k)
  @__mapped = BuildTypes.new
  @__unmapped = []
  instance_eval(&k)  
end

Instance Method Details

#__extObject



360
361
362
# File 'lib/cheri/builder/generator.rb', line 360

def __ext
  @__ext  
end

#__mappedObject



352
353
354
# File 'lib/cheri/builder/generator.rb', line 352

def __mapped
  @__mapped  
end

#__pkgObject



364
365
366
# File 'lib/cheri/builder/generator.rb', line 364

def __pkg
  @__pkg
end

#__tcObject



368
369
370
# File 'lib/cheri/builder/generator.rb', line 368

def __tc
  @__tc  
end

#__unmappedObject



356
357
358
# File 'lib/cheri/builder/generator.rb', line 356

def __unmapped
  @__unmapped
end

#build(type, sym = nil, &k) ⇒ Object



382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/cheri/builder/generator.rb', line 382

def build(type,sym=nil,&k)
  raise Cheri.type_error(type,Class) unless Class === type
  if sym
    if Symbol === sym
      add_mapped(type,sym,&k)
    elsif Array === sym
      sym.each do |s|
        raise Cheri.type_error(s,Symbol) unless Symbol === s
        add_mapped(type,s,&k)        
      end
    else
      raise Cheri.type_error(sym,Symbol,Array)
    end
  else
    @__unmapped << BuildType.new(type,nil,&k) unless @__unmapped.include?(type) 
  end
end

#build_package(str) ⇒ Object

Raises:

  • (BuilderException)


406
407
408
409
410
411
412
413
414
415
# File 'lib/cheri/builder/generator.rb', line 406

def build_package(str)
  raise Cheri.type_error(str,String) unless String === str
  raise BuilderException,"packages supported only for Java (JRuby)" unless defined?JRUBY_VERSION
  require 'cheri/java/builder'
  if @__pkg
    @__pkg << str unless @__pkg.include?(str)
  else
    @__pkg = [str]    
  end
end

#extend_builder(bld) ⇒ Object

Raises:

  • (BuilderException)


372
373
374
375
376
377
378
379
380
# File 'lib/cheri/builder/generator.rb', line 372

def extend_builder(bld)
  return unless bld
  raise BuilderException,"only one extend_builder may be specified" if @__ext
  unless bld.respond_to?(:factory) || bld.respond_to?(:connecter) ||
      bld.respond_to?(:consumer) || bld.respond_to?(:resolver)
    raise ArgumentError,"not a valid builder: #{bld}"
  end
  @__ext = bld
end

#type(mod, &k) ⇒ Object Also known as: types, symbol, symbols



417
418
419
420
# File 'lib/cheri/builder/generator.rb', line 417

def type(mod,&k)
  @__tc ||= TypeConnecter.new
  @__tc.type(mod,&k)  
end