I got an inspiration from JRuby mailing list about Java 5. Since Java
5 is our language, we can use it more aggressively. We can use
annotation to mark which code is for builtin. My assumption is like
this.
@RubyBuiltin(name="Array")
public class RubyArray {
....
@RubyMethod(name="clear", type=NO_ARG)
public RubyArray clear() { ... }
}
Of course, Runtime will be changed to get the class. Maybe like this:
ArrayClass = ClassFactory.getClass(RubyArray.class);
Of course, we have to do some work to make it happen. I think the code
will look cleaner with this approach.
Do you like it? Any feedback is welcome!
Ye Zheng
--
Everything is simple!
_________________________________________________________________
http://liveearth.msn.com
--
Best Regards
XRuby http://xruby.com
femto http://hi.baidu.com/femto
On the other hand, I think most Java 5 features can be ported back on
Java 1.4 in bytecode level. The code generation is just used in
development which has no impact on deployment.
2007/7/25, femto gary <femt...@gmail.com>:
--
Everything is simple!
Here is a demo for test.
@RubyLevelClass(name="ClassFactory", modules="ClassFactoryModule")
public static class ClassFactoryValue extends RubyValue {
...
@RubyLevelMethod(name="test", type=MethodType.NO_ARG)
public RubyValue test() {
return RubyConstant.QNIL;
}
}
You can get the klass like this:
RubyClass klass = RubyTypeFactory.getClass(ClassFactoryValue.class);
I've applied this annotation on UnboundMethodClass. You will see the
code in RubyRuntime and RubyMethodValue.
UnboundMethodClass = RubyTypeFactory.getClass(RubyMethodValue.class);
I'll apply this idea more aggressively. :)
Ye Zheng
--
Everything is simple!