[macruby-changes] [1631] MacRuby/branches/experimental/compiler.cpp
source_changes at macosforge.org
source_changes at macosforge.org
Thu May 28 22:10:57 PDT 2009
Revision: 1631
http://trac.macosforge.org/projects/ruby/changeset/1631
Author: lsansonetti at apple.com
Date: 2009-05-28 22:10:55 -0700 (Thu, 28 May 2009)
Log Message:
-----------
allow true/false to be passed as numeric types
Modified Paths:
--------------
MacRuby/branches/experimental/compiler.cpp
Modified: MacRuby/branches/experimental/compiler.cpp
===================================================================
--- MacRuby/branches/experimental/compiler.cpp 2009-05-29 04:37:24 UTC (rev 1630)
+++ MacRuby/branches/experimental/compiler.cpp 2009-05-29 05:10:55 UTC (rev 1631)
@@ -4271,21 +4271,33 @@
}
static inline long
+bool_to_fix(VALUE rval)
+{
+ if (rval == Qtrue) {
+ return INT2FIX(1);
+ }
+ if (rval == Qfalse) {
+ return INT2FIX(0);
+ }
+ return rval;
+}
+
+static inline long
rval_to_long(VALUE rval)
{
- return NUM2LONG(rb_Integer(rval));
+ return NUM2LONG(rb_Integer(bool_to_fix(rval)));
}
static inline long long
rval_to_long_long(VALUE rval)
{
- return NUM2LL(rb_Integer(rval));
+ return NUM2LL(rb_Integer(bool_to_fix(rval)));
}
static inline double
rval_to_double(VALUE rval)
{
- return RFLOAT_VALUE(rb_Float(rval));
+ return RFLOAT_VALUE(rb_Float(bool_to_fix(rval)));
}
extern "C"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090528/08777bd8/attachment.html>
More information about the macruby-changes
mailing list