Permalink
Browse files

Migrating trunk to Java 5; added in annotation support for method def…

…inition, updated Fixnum to use it, added Retroweaver support in the build, moved to ASM 3.0.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@4084 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
headius committed Aug 5, 2007
1 parent 104c9af commit 28f4ed91a9eb9fe0a644de65c9ccb5c7b1fd844a
View
@@ -36,6 +36,8 @@
<patternset id="other.src.pattern">
<include name="**/*.properties"/>
</patternset>
+
+ <taskdef name="retro" classname="net.sourceforge.retroweaver.ant.RetroWeaverTask" classpathref="build.classpath"/>
<target name="init" description="initialize the build">
<xmlproperty file="build-config.xml" keepRoot="false" collapseAttributes="true"/>
@@ -148,11 +150,16 @@
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Main-Class" value="org.jruby.Main"/>
- <attribute name="Class-Path" value="asm-2.2.3.jar asm-commons-2.2.3.jar asm-util-2.2.3.jar jline-0.9.91.jar bsf.jar backport-util-concurrent.jar"/>
+ <attribute name="Class-Path" value="asm-3.0.jar asm-commons-3.0.jar asm-util-3.0.jar jline-0.9.91.jar bsf.jar backport-util-concurrent.jar"/>
</manifest>
</jar>
</target>
+ <target name="jar-1.4" depends="jar-jruby">
+ <copy file="${lib.dir}/jruby.jar" tofile="${lib.dir}/jruby1.5.jar"/>
+ <retro inputjar="${lib.dir}/jruby1.5.jar" outputjar="${lib.dir}/jruby.jar"/>
+ <delete file="${lib.dir}/jruby1.5.jar"/>
+ </target>
<target name="jar-complete" depends="generate-method-classes" description="Create the 'complete' JRuby jar. Pass 'mainclass' and 'filename' to adjust.">
<property name="mainclass" value="org.jruby.Main"/>
@@ -165,9 +172,9 @@
<fileset dir="${basedir}/lib/ruby/1.8">
<include name="**/*.rb"/>
</fileset>
- <zipfileset src="${lib.dir}/asm-2.2.3.jar"/>
- <zipfileset src="${lib.dir}/asm-commons-2.2.3.jar"/>
- <zipfileset src="${lib.dir}/asm-util-2.2.3.jar"/>
+ <zipfileset src="${lib.dir}/asm-3.0.jar"/>
+ <zipfileset src="${lib.dir}/asm-commons-3.0.jar"/>
+ <zipfileset src="${lib.dir}/asm-util-3.0.jar"/>
<zipfileset src="${lib.dir}/jline-0.9.91.jar"/>
<zipfileset src="${lib.dir}/backport-util-concurrent.jar"/>
<rule pattern="org.objectweb.asm.**" result="jruby.objectweb.asm.@1"/>
@@ -216,9 +223,9 @@
<exclude name="**/xmlrpc/**"/>
<exclude name="**/xsd/**"/>
</fileset>
- <zipfileset src="${lib.dir}/asm-2.2.3.jar"/>
- <zipfileset src="${lib.dir}/asm-commons-2.2.3.jar"/>
- <zipfileset src="${lib.dir}/asm-util-2.2.3.jar"/>
+ <zipfileset src="${lib.dir}/asm-3.0.jar"/>
+ <zipfileset src="${lib.dir}/asm-commons-3.0.jar"/>
+ <zipfileset src="${lib.dir}/asm-util-3.0.jar"/>
<zipfileset src="${lib.dir}/jline-0.9.91.jar"/>
<zipfileset src="${lib.dir}/backport-util-concurrent.jar"/>
<manifest>
View
@@ -15,4 +15,4 @@ release.dir=release
test.results.dir=${build.dir}/test-results
html.test.results.dir=${test.results.dir}/html
html.test.coverage.results.dir=${test.results.dir}/html-coverage
-javac.version=1.4
+javac.version=1.5
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
@@ -63,14 +63,14 @@
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
<compilation-unit>
<package-root>src</package-root>
- <classpath mode="compile">lib/bsf.jar:lib/junit.jar:lib/asm-2.2.3.jar:lib/asm-commons-2.2.3.jar:lib/jline-0.9.91.jar:lib/backport-util-concurrent.jar:lib/ant.jar:lib/asm-util-2.2.3.jar</classpath>
- <source-level>1.4</source-level>
+ <classpath mode="compile">lib/bsf.jar:lib/junit.jar:lib/jline-0.9.91.jar:lib/backport-util-concurrent.jar:lib/ant.jar:lib/asm-3.0.jar:lib/asm-commons-3.0.jar:lib/asm-util-3.0.jar</classpath>
+ <source-level>1.5</source-level>
</compilation-unit>
<compilation-unit>
<package-root>test</package-root>
<unit-tests/>
<classpath mode="compile">lib/bsf.jar:lib/junit.jar:src</classpath>
- <source-level>1.4</source-level>
+ <source-level>1.5</source-level>
</compilation-unit>
</java-data>
</configuration>
@@ -36,6 +36,7 @@
package org.jruby;
import java.math.BigInteger;
+import org.jruby.anno.JRubyMethod;
import org.jruby.runtime.Arity;
import org.jruby.runtime.CallbackFactory;
import org.jruby.runtime.ClassIndex;
@@ -57,47 +58,8 @@ public static RubyClass createFixnumClass(Ruby runtime) {
CallbackFactory callbackFactory = runtime.callbackFactory(RubyFixnum.class);
fixnum.includeModule(runtime.getModule("Precision"));
- fixnum.getMetaClass().defineFastMethod("induced_from", callbackFactory.getFastSingletonMethod(
- "induced_from", RubyKernel.IRUBY_OBJECT));
-
- fixnum.defineFastMethod("to_s", callbackFactory.getFastOptMethod("to_s"));
-
- fixnum.defineFastMethod("id2name", callbackFactory.getFastMethod("id2name"));
- fixnum.defineFastMethod("to_sym", callbackFactory.getFastMethod("to_sym"));
-
- fixnum.defineFastMethod("-@", callbackFactory.getFastMethod("uminus"));
- fixnum.defineFastMethod("+", callbackFactory.getFastMethod("plus", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("-", callbackFactory.getFastMethod("minus", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("*", callbackFactory.getFastMethod("mul", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("/", callbackFactory.getFastMethod("div_slash", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("div", callbackFactory.getFastMethod("div_div", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("%", callbackFactory.getFastMethod("mod", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("modulo", callbackFactory.getFastMethod("mod", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("divmod", callbackFactory.getFastMethod("divmod", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("quo", callbackFactory.getFastMethod("quo", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("**", callbackFactory.getFastMethod("pow", RubyKernel.IRUBY_OBJECT));
-
- fixnum.defineFastMethod("abs", callbackFactory.getFastMethod("abs"));
-
- fixnum.defineFastMethod("==", callbackFactory.getFastMethod("equal", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("<=>", callbackFactory.getFastMethod("cmp", RubyKernel.IRUBY_OBJECT));
-
- fixnum.defineFastMethod(">", callbackFactory.getFastMethod("gt", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod(">=", callbackFactory.getFastMethod("ge", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("<", callbackFactory.getFastMethod("lt", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("<=", callbackFactory.getFastMethod("le", RubyKernel.IRUBY_OBJECT));
-
- fixnum.defineFastMethod("~", callbackFactory.getFastMethod("rev"));
- fixnum.defineFastMethod("&", callbackFactory.getFastMethod("and", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("|", callbackFactory.getFastMethod("or", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("^", callbackFactory.getFastMethod("xor", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("[]", callbackFactory.getFastMethod("aref", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod("<<", callbackFactory.getFastMethod("lshift", RubyKernel.IRUBY_OBJECT));
- fixnum.defineFastMethod(">>", callbackFactory.getFastMethod("rshift", RubyKernel.IRUBY_OBJECT));
-
- fixnum.defineFastMethod("to_f", callbackFactory.getFastMethod("to_f"));
- fixnum.defineFastMethod("size", callbackFactory.getFastMethod("size"));
- fixnum.defineFastMethod("zero?", callbackFactory.getFastMethod("zero_p"));
+
+ fixnum.defineAnnotatedMethods(RubyFixnum.class, callbackFactory);
fixnum.dispatcher = callbackFactory.createDispatcher(fixnum);
@@ -212,6 +174,7 @@ public boolean equals(Object other) {
/** fix_to_s
*
*/
+ @JRubyMethod(name = "to_s", optional = 1)
public RubyString to_s(IRubyObject[] args) {
Arity.checkArgumentCount(getRuntime(), args, 0, 1);
@@ -225,6 +188,7 @@ public RubyString to_s(IRubyObject[] args) {
/** fix_id2name
*
*/
+ @JRubyMethod(name = "id2name")
public IRubyObject id2name() {
String symbol = RubySymbol.getSymbol(getRuntime(), value);
if (symbol != null) {
@@ -236,6 +200,7 @@ public IRubyObject id2name() {
/** fix_to_sym
*
*/
+ @JRubyMethod(name = "to_sym")
public IRubyObject to_sym() {
String symbol = RubySymbol.getSymbol(getRuntime(), value);
if (symbol != null) {
@@ -247,6 +212,7 @@ public IRubyObject to_sym() {
/** fix_uminus
*
*/
+ @JRubyMethod(name = "-@")
public IRubyObject uminus() {
if (value == MIN) { // a gotcha
return RubyBignum.newBignum(getRuntime(), BigInteger.valueOf(value).negate());
@@ -257,6 +223,7 @@ public IRubyObject uminus() {
/** fix_plus
*
*/
+ @JRubyMethod(name = "+", required = 1)
public IRubyObject plus(IRubyObject other) {
if (other instanceof RubyFixnum) {
long otherValue = ((RubyFixnum) other).value;
@@ -278,6 +245,7 @@ public IRubyObject plus(IRubyObject other) {
/** fix_minus
*
*/
+ @JRubyMethod(name = "-", required = 1)
public IRubyObject minus(IRubyObject other) {
if (other instanceof RubyFixnum) {
long otherValue = ((RubyFixnum) other).value;
@@ -297,6 +265,7 @@ public IRubyObject minus(IRubyObject other) {
/** fix_mul
*
*/
+ @JRubyMethod(name = "*", required = 1)
public IRubyObject mul(IRubyObject other) {
if (other instanceof RubyFixnum) {
long otherValue = ((RubyFixnum) other).value;
@@ -327,10 +296,12 @@ public IRubyObject mul(IRubyObject other) {
*
* also note that RubyFloat doesn't override Numeric.div
*/
+ @JRubyMethod(name = "div", required = 1)
public IRubyObject div_div(IRubyObject other) {
return idiv(other, "div");
}
+ @JRubyMethod(name = "/", required = 1)
public IRubyObject div_slash(IRubyObject other) {
return idiv(other, "/");
}
@@ -359,6 +330,7 @@ public IRubyObject idiv(IRubyObject other, String method) {
/** fix_mod
*
*/
+ @JRubyMethod(name = "%", required = 1, alias = "modulo")
public IRubyObject mod(IRubyObject other) {
if (other instanceof RubyFixnum) {
// Java / and % are not the same as ruby
@@ -383,6 +355,7 @@ public IRubyObject mod(IRubyObject other) {
/** fix_divmod
*
*/
+ @JRubyMethod(name = "divmod", required = 1)
public IRubyObject divmod(IRubyObject other) {
if (other instanceof RubyFixnum) {
long x = value;
@@ -413,6 +386,7 @@ public IRubyObject divmod(IRubyObject other) {
/** fix_quo
*
*/
+ @JRubyMethod(name = "quo", required = 1)
public IRubyObject quo(IRubyObject other) {
if (other instanceof RubyFixnum) {
return RubyFloat.newFloat(getRuntime(), (double) value
@@ -424,6 +398,7 @@ public IRubyObject quo(IRubyObject other) {
/** fix_pow
*
*/
+ @JRubyMethod(name = "**", required = 1)
public IRubyObject pow(IRubyObject other) {
if(other instanceof RubyFixnum) {
long b = ((RubyFixnum) other).value;
@@ -447,16 +422,18 @@ public IRubyObject pow(IRubyObject other) {
/** fix_abs
*
*/
+ @JRubyMethod(name = "abs")
public IRubyObject abs() {
if (value < 0) {
return RubyFixnum.newFixnum(getRuntime(), -value);
- }
+ }
return this;
}
/** fix_equal
*
*/
+ @JRubyMethod(name = "==", required = 1)
public IRubyObject equal(IRubyObject other) {
if (other instanceof RubyFixnum) {
return RubyBoolean.newBoolean(getRuntime(), value == ((RubyFixnum) other).value);
@@ -467,6 +444,7 @@ public IRubyObject equal(IRubyObject other) {
/** fix_cmp
*
*/
+ @JRubyMethod(name = "<=>", required = 1)
public IRubyObject cmp(IRubyObject other) {
if (other instanceof RubyFixnum) {
long otherValue = ((RubyFixnum) other).value;
@@ -484,6 +462,7 @@ public IRubyObject cmp(IRubyObject other) {
/** fix_gt
*
*/
+ @JRubyMethod(name = ">", required = 1)
public IRubyObject gt(IRubyObject other) {
if (other instanceof RubyFixnum) {
return RubyBoolean.newBoolean(getRuntime(), value > ((RubyFixnum) other).value);
@@ -494,6 +473,7 @@ public IRubyObject gt(IRubyObject other) {
/** fix_ge
*
*/
+ @JRubyMethod(name = ">=", required = 1)
public IRubyObject ge(IRubyObject other) {
if (other instanceof RubyFixnum) {
return RubyBoolean.newBoolean(getRuntime(), value >= ((RubyFixnum) other).value);
@@ -504,6 +484,7 @@ public IRubyObject ge(IRubyObject other) {
/** fix_lt
*
*/
+ @JRubyMethod(name = "<", required = 1)
public IRubyObject lt(IRubyObject other) {
if (other instanceof RubyFixnum) {
return RubyBoolean.newBoolean(getRuntime(), value < ((RubyFixnum) other).value);
@@ -514,6 +495,7 @@ public IRubyObject lt(IRubyObject other) {
/** fix_le
*
*/
+ @JRubyMethod(name = "<=", required = 1)
public IRubyObject le(IRubyObject other) {
if (other instanceof RubyFixnum) {
return RubyBoolean.newBoolean(getRuntime(), value <= ((RubyFixnum) other).value);
@@ -524,13 +506,15 @@ public IRubyObject le(IRubyObject other) {
/** fix_rev
*
*/
+ @JRubyMethod(name = "~")
public IRubyObject rev() {
return newFixnum(~value);
}
/** fix_and
*
*/
+ @JRubyMethod(name = "&", required = 1)
public IRubyObject and(IRubyObject other) {
if (other instanceof RubyBignum) {
return ((RubyBignum) other).and(this);
@@ -541,6 +525,7 @@ public IRubyObject and(IRubyObject other) {
/** fix_or
*
*/
+ @JRubyMethod(name = "|", required = 1)
public IRubyObject or(IRubyObject other) {
if (other instanceof RubyFixnum) {
return newFixnum(value | ((RubyFixnum) other).value);
@@ -558,6 +543,7 @@ public IRubyObject or(IRubyObject other) {
/** fix_xor
*
*/
+ @JRubyMethod(name = "^", required = 1)
public IRubyObject xor(IRubyObject other) {
if(other instanceof RubyFixnum) {
return newFixnum(value ^ ((RubyFixnum) other).value);
@@ -575,6 +561,7 @@ public IRubyObject xor(IRubyObject other) {
/** fix_aref
*
*/
+ @JRubyMethod(name = "[]", required = 1)
public IRubyObject aref(IRubyObject other) {
if(other instanceof RubyBignum) {
RubyBignum big = (RubyBignum) other;
@@ -606,6 +593,7 @@ public IRubyObject aref(IRubyObject other) {
/** fix_lshift
*
*/
+ @JRubyMethod(name = "<<", required = 1)
public IRubyObject lshift(IRubyObject other) {
long width = num2long(other);
@@ -627,6 +615,7 @@ public IRubyObject lshift(IRubyObject other) {
/** fix_rshift
*
*/
+ @JRubyMethod(name = ">>", required = 1)
public IRubyObject rshift(IRubyObject other) {
long width = num2long(other);
@@ -651,20 +640,23 @@ public IRubyObject rshift(IRubyObject other) {
/** fix_to_f
*
*/
+ @JRubyMethod(name = "to_f")
public IRubyObject to_f() {
return RubyFloat.newFloat(getRuntime(), (double) value);
}
/** fix_size
*
*/
+ @JRubyMethod(name = "size")
public IRubyObject size() {
return newFixnum((long) ((BIT_SIZE + 7) / 8));
}
/** fix_zero_p
*
*/
+ @JRubyMethod(name = "zero?")
public IRubyObject zero_p() {
return RubyBoolean.newBoolean(getRuntime(), value == 0);
}
@@ -695,8 +687,8 @@ public static RubyFixnum unmarshalFrom(UnmarshalStream input) throws java.io.IOE
/** rb_fix_induced_from
*
*/
-
+ @JRubyMethod(name = "induced_from", required = 1, singleton = true)
public static IRubyObject induced_from(IRubyObject recv, IRubyObject other) {
return RubyNumeric.num2fix(other);
-}
+ }
}
Oops, something went wrong.

0 comments on commit 28f4ed9

Please sign in to comment.