Bug 435288 - Deprecate JS_NewDouble and JS_NewDoubleValue, add correctness assertions (r=brendan)

This commit is contained in:
Jason Orendorff 2008-06-24 14:42:42 -05:00
parent 1d75986c69
commit 8d7a73885f
2 changed files with 12 additions and 1 deletions

View File

@ -345,7 +345,7 @@ JS_PushArgumentsVA(JSContext *cx, void **markp, const char *format, va_list ap)
break;
case 'd':
case 'I':
if (!JS_NewDoubleValue(cx, va_arg(ap, jsdouble), sp))
if (!JS_NewNumberValue(cx, va_arg(ap, jsdouble), sp))
goto bad;
break;
case 's':
@ -1831,16 +1831,25 @@ JS_strdup(JSContext *cx, const char *s)
JS_PUBLIC_API(jsdouble *)
JS_NewDouble(JSContext *cx, jsdouble d)
{
#ifdef DEBUG
jsint i;
#endif
CHECK_REQUEST(cx);
JS_ASSERT(!JSDOUBLE_IS_INT(d, i) || !INT_FITS_IN_JSVAL(i));
return js_NewWeaklyRootedDouble(cx, d);
}
JS_PUBLIC_API(JSBool)
JS_NewDoubleValue(JSContext *cx, jsdouble d, jsval *rval)
{
#ifdef DEBUG
jsint i;
#endif
jsdouble *dp;
CHECK_REQUEST(cx);
JS_ASSERT(!JSDOUBLE_IS_INT(d, i) || !INT_FITS_IN_JSVAL(i));
dp = js_NewWeaklyRootedDouble(cx, d);
if (!dp)
return JS_FALSE;

View File

@ -699,9 +699,11 @@ JS_free(JSContext *cx, void *p);
extern JS_PUBLIC_API(char *)
JS_strdup(JSContext *cx, const char *s);
/* Deprecated -- use JS_NewNumberValue instead. */
extern JS_PUBLIC_API(jsdouble *)
JS_NewDouble(JSContext *cx, jsdouble d);
/* Deprecated -- use JS_NewNumberValue instead. */
extern JS_PUBLIC_API(JSBool)
JS_NewDoubleValue(JSContext *cx, jsdouble d, jsval *rval);