diff options
author | Aaron <aaron@10gen.com> | 2010-01-25 10:06:06 -0800 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2010-01-25 10:06:06 -0800 |
commit | a85db023f9a01bcab68386fbe0cf32ccc196d785 (patch) | |
tree | 1b57c1c15c14c7168be49add9fe7340ed8a08c79 /scripting/sm_db.cpp | |
parent | 33bd6d1fe1fff2d9b457662e41e217ceee4d174b (diff) | |
download | mongo-a85db023f9a01bcab68386fbe0cf32ccc196d785.tar.gz |
SERVER-357 NumberLong converts to number (double) implicitly when doing operations
Diffstat (limited to 'scripting/sm_db.cpp')
-rw-r--r-- | scripting/sm_db.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/scripting/sm_db.cpp b/scripting/sm_db.cpp index 1f15d0bc07e..9303b3faf39 100644 --- a/scripting/sm_db.cpp +++ b/scripting/sm_db.cpp @@ -664,6 +664,15 @@ namespace mongo { JSCLASS_NO_OPTIONAL_MEMBERS }; + JSBool numberlong_valueof(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){ + Convertor c(cx); + return *rval = c.toval( double( c.toNumberLongUnsafe( obj ) ) ); + } + + JSBool numberlong_tonumber(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){ + return numberlong_valueof( cx, obj, argc, argv, rval ); + } + JSBool numberlong_tostring(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){ Convertor c(cx); stringstream ss; @@ -671,15 +680,11 @@ namespace mongo { string ret = ss.str(); return *rval = c.toval( ret.c_str() ); } - - JSBool numberlong_tonumber(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){ - Convertor c(cx); - return *rval = c.toval( double( c.toNumberLongUnsafe( obj ) ) ); - } JSFunctionSpec numberlong_functions[] = { - { "toString" , numberlong_tostring , 0 , JSPROP_READONLY | JSPROP_PERMANENT, 0 } , + { "valueOf" , numberlong_valueof , 0 , JSPROP_READONLY | JSPROP_PERMANENT, 0 } , { "toNumber" , numberlong_tonumber , 0 , JSPROP_READONLY | JSPROP_PERMANENT, 0 } , + { "toString" , numberlong_tostring , 0 , JSPROP_READONLY | JSPROP_PERMANENT, 0 } , { 0 } }; |