Re: Implementing Interfaces:

48 views
Skip to first unread message

Nick Howard

unread,
Oct 15, 2012, 2:19:38 PM10/15/12
to mi...@googlegroups.com
Hi,
Looks like you might have found a bug. Could you try compiling with --verbose and dumping the output in a gist/pastebin? It'd be helpful to have the full test.mirah file too.

On Mon, Oct 15, 2012 at 12:40 AM, Peter Ehrlich <peter.i...@gmail.com> wrote:
Hey -- new here to Java and to Mirah.  I'm experimenting with using it in combination with the LeJos project to control lego robotics.

Trying to implement this java code is giving me trouble.  Here's the spec from their tutorial:

Button.ENTER.addButtonListener(new ButtonListener() {
      public void buttonPressed(Button b) {
        LCD.drawString("ENTER pressed", 0, 0);
      }

      public void buttonReleased(Button b) {
        LCD.clear();
      }
    });


And here's my (failing) Mirah implementation.  Hopefully, there some dumb mistake that I just wouldn't think of:


class MyButtonListener
  implements ButtonListener

  def buttonPressed(b: Button):void
    LCD.drawString("ESC pressed", 0, 6)
  end

  def buttonReleased(b: Button):void
    LCD.drawString("ESC released", 0, 6)
  end
end

// and later:
listener = MyButtonListener.new
Button.ESCAPE.addButtonListener(listener)


It gives me the following error:


$ mirahc --java --classpath /Users/peter/Downloads/leJOS_NXJ_0.9.1beta-3/lib/nxt/classes.jar  test.mirah 
Parsing...
  test.mirah
Inferring types...
test.mirah:32: can't convert Mirah::JVM::Types::TypeDefinition into String
    Button.ESCAPE.addButtonListener(listener)
Mirah::InternalCompilerError: can't convert Mirah::JVM::Types::TypeDefinition into String
         infer at /Users/peter/.rvm/gems/jruby-1.6.7.2/gems/mirah-0.0.12-java/lib/mirah/typer/simple.rb:280
         infer at /Users/peter/.rvm/gems/jruby-1.6.7.2/gems/mirah-0.0.12-java/lib/mirah/typer/simple.rb:275
       resolve at /Users/peter/.rvm/gems/jruby-1.6.7.2/gems/mirah-0.0.12-java/lib/mirah/typer/simple.rb:324
          each at org/jruby/RubyHash.java:1186



See the full docs:

Cheers & Thanks for any help!
--Peter



--
-Nick Howard
http://blog.baroquebobcat.com/


Peter Ehrlich

unread,
Oct 15, 2012, 10:00:48 PM10/15/12
to mi...@googlegroups.com
You guys sure know how to do verbose! Here's the output and the source:


Thanks for the help
Reply all
Reply to author
Forward
0 new messages