Class: Mirah::JavaSource::InterfaceBuilder

Inherits:
ClassBuilder show all
Defined in:
lib/mirah/jvm/source_generator/builder.rb

Instance Attribute Summary

Attributes inherited from ClassBuilder

#abstract, #class_name, #filename, #interfaces, #name, #out, #package, #superclass

Instance Method Summary collapse

Methods inherited from ClassBuilder

#build_constructor, #build_jsni_method, #classes, #compiler, #declare_field, #generate, #main, #start, #stop

Methods included from Mirah::JVM::Compiler::JVMBytecode::JVMLogger

#log

Methods included from Helper

#annotate, #annotation_value, #block, #dedent, #indent, #init_value, #print, #puts

Constructor Details

#initialize(builder, name, interfaces) ⇒ InterfaceBuilder

Returns a new instance of InterfaceBuilder.



309
310
311
# File 'lib/mirah/jvm/source_generator/builder.rb', line 309

def initialize(builder, name, interfaces)
  super(builder, name, nil, interfaces, true)
end

Instance Method Details

#build_method(name, visibility, static, exceptions, type, *args) ⇒ Object



328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/mirah/jvm/source_generator/builder.rb', line 328

def build_method(name, visibility, static, exceptions, type, *args)
  raise "Interfaces can't have static methods" if static
  finish_declaration
  type ||= Mirah::AST::type(nil, :void)
  @methods << MethodBuilder.new(self,
                                :name => name,
                                :visibility => visibility,
                                :return => type,
                                :args => args,
                                :abstract => true,
                                :exceptions => exceptions)
  @methods[-1]
end

#finish_declarationObject



313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/mirah/jvm/source_generator/builder.rb', line 313

def finish_declaration
  return if @declaration_finished
  @declaration_finished = true
  print "public interface #{class_name}"
  unless @interfaces.empty?
    print " extends "
    @interfaces.each_with_index do |interface, index|
      print ', ' unless index == 0
      print interface.to_source
    end
  end
  puts " {"
  indent
end