Skip to content

Commit

Permalink
inline the boxing code
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@3754 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
lrz committed Mar 13, 2010
1 parent fe7c396 commit b6ec030
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 33 deletions.
28 changes: 0 additions & 28 deletions numeric.c
Expand Up @@ -93,34 +93,6 @@ VALUE rb_cFixnum;
VALUE rb_eZeroDivError;
VALUE rb_eFloatDomainError;

static VALUE
rb_box_fixfloat0(double value)
{
CFNumberRef number = CFNumberCreate(NULL, kCFNumberDoubleType, &value);
CFMakeCollectable(number);
return (VALUE)number;
}

VALUE
rb_box_fixfloat(VALUE fixfloat)
{
return rb_box_fixfloat0(NUM2DBL(fixfloat));
}

static VALUE
rb_box_fixnum0(long value)
{
CFNumberRef number = CFNumberCreate(NULL, kCFNumberLongType, &value);
CFMakeCollectable(number);
return (VALUE)number;
}

VALUE
rb_box_fixnum(VALUE fixnum)
{
return rb_box_fixnum0(FIX2LONG(fixnum));
}

void
rb_num_zerodiv(void)
{
Expand Down
14 changes: 9 additions & 5 deletions objc.h
Expand Up @@ -167,9 +167,6 @@ TypeArity(const char *type)
return arity;
}

VALUE rb_box_fixnum(VALUE);
VALUE rb_box_fixfloat(VALUE);

static inline id
rb_rval_to_ocid(VALUE obj)
{
Expand All @@ -184,10 +181,17 @@ rb_rval_to_ocid(VALUE obj)
return (id)kCFNull;
}
if (FIXNUM_P(obj)) {
return (id)rb_box_fixnum(obj);
long val = FIX2LONG(obj);
CFNumberRef number = CFNumberCreate(NULL, kCFNumberLongType, &val);
CFMakeCollectable(number);
return (id)number;
}
if (FIXFLOAT_P(obj)) {
return (id)rb_box_fixfloat(obj);
double val = NUM2DBL(obj);
CFNumberRef number = CFNumberCreate(NULL, kCFNumberDoubleType,
&val);
CFMakeCollectable(number);
return (id)number;
}
}
return (id)obj;
Expand Down

0 comments on commit b6ec030

Please sign in to comment.