Module: Cheri::Java::Builder::EventMethodConsumer
- Defined in:
- lib/cheri/java/builder/main.rb
Overview
DefaultConsumer
Constant Summary collapse
- On =
:stopdoc:
'on_'.freeze
- Eq =
'='.freeze
- Aliases =
TODO: any other useful aliases?
{:on_click => 'actionPerformed'.freeze}
Class Method Summary collapse
-
.consume(ctx, bld, sym, *args, &block) ⇒ Object
:startdoc:.
Class Method Details
.consume(ctx, bld, sym, *args, &block) ⇒ Object
:startdoc:
251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/cheri/java/builder/main.rb', line 251 def self.consume(ctx,bld,sym,*args,&block) return false,nil unless (obj = bld.object).respond_to?(:java_class) && ((method_name = Aliases[sym]) || (s = sym.to_s).rindex(On,0)) method_name ||= Util.lcc(s[3,s.length]) unless (info = Interfaces.get_listener_info(obj.java_class||obj.class.java_class,method_name)) raise NameError,"no Java interface found matching event handler name: #{sym}" end raise ArgumentError,"missing block for event handler: #{sym}" unless block listener = Interfaces.get_listener_impl(info).new listener.__send__(method_name + Eq , block) obj.__send__(info.add_method_name,listener) return true,listener end |