[openvrml/f14/master] Use JS_NewNumberValue instead of the deprecated JS_NewDoubleValue.

Braden McDaniel braden at fedoraproject.org
Sat Jan 22 07:18:22 UTC 2011


commit b7824d36c9e6370d1f36c1114ac6f6c46a3ad771
Author: Braden McDaniel <braden at endoframe.com>
Date:   Sat Jan 22 01:42:34 2011 -0500

    Use JS_NewNumberValue instead of the deprecated JS_NewDoubleValue.

 javascript-newnumbervalue.patch |  191 +++++++++++++++++++++++++++++++++++++++
 openvrml.spec                   |    7 ++-
 2 files changed, 197 insertions(+), 1 deletions(-)
---
diff --git a/javascript-newnumbervalue.patch b/javascript-newnumbervalue.patch
new file mode 100644
index 0000000..d8c86cd
--- /dev/null
+++ b/javascript-newnumbervalue.patch
@@ -0,0 +1,191 @@
+Index: src/script/javascript.cpp
+===================================================================
+--- src/script/javascript.cpp	(revision 4192)
++++ src/script/javascript.cpp	(revision 4195)
+@@ -1331,7 +1331,7 @@
+             using openvrml::sffloat;
+             const sffloat & f =
+                 *polymorphic_downcast<const sffloat *>(&fieldValue);
+-            if (!JS_NewDoubleValue(cx, f.value(), &rval)) {
++            if (!JS_NewNumberValue(cx, f.value(), &rval)) {
+                 rval = JSVAL_NULL;
+             }
+         }
+@@ -1342,7 +1342,7 @@
+             using openvrml::sfdouble;
+             const sfdouble & f =
+                 *polymorphic_downcast<const sfdouble *>(&fieldValue);
+-            if (!JS_NewDoubleValue(cx, f.value(), &rval)) {
++            if (!JS_NewNumberValue(cx, f.value(), &rval)) {
+                 rval = JSVAL_NULL;
+             }
+         }
+@@ -1403,7 +1403,7 @@
+         {
+             const openvrml::sftime & sftime =
+                 *polymorphic_downcast<const openvrml::sftime *>(&fieldValue);
+-            if (!JS_NewDoubleValue(cx, sftime.value(), &rval)) {
++            if (!JS_NewNumberValue(cx, sftime.value(), &rval)) {
+                 rval = JSVAL_NULL;
+             }
+         }
+@@ -1957,7 +1957,7 @@
+ 
+         size_t i;
+         for (i = 0; i < numFloats; ++i) {
+-            if (!JS_NewDoubleValue(cx, floats[i], &jsvec[i])) {
++            if (!JS_NewNumberValue(cx, floats[i], &jsvec[i])) {
+                 return JS_FALSE;
+             }
+             if (!JS_AddRoot(cx, &jsvec[i])) { return JS_FALSE; }
+@@ -2212,14 +2212,12 @@
+                                uintN, jsval *, jsval * const rval)
+             OPENVRML_NOTHROW
+         {
+-            script * const s =
+-                static_cast<script *>(JS_GetContextPrivate(cx));
++            script * const s = static_cast<script *>(JS_GetContextPrivate(cx));
+             assert(s);
+ 
+-            float speed = s->script_node().node::type().metatype()
+-                .browser().current_speed();
+-            *rval = DOUBLE_TO_JSVAL(JS_NewDouble( cx, speed ));
+-            return JS_TRUE;
++            const jsdouble speed =
++                s->script_node().type().metatype().browser().current_speed();
++            return JS_NewNumberValue(cx, speed, rval);
+         }
+ 
+         JSBool getCurrentFrameRate(JSContext * const cx,
+@@ -2232,11 +2230,9 @@
+             script * const s = static_cast<script *>(JS_GetContextPrivate(cx));
+             assert(s);
+ 
+-            jsdouble * d = JS_NewDouble(cx,
+-                                        s->script_node().node::type().metatype()
+-                                        .browser().frame_rate());
+-            *rval = DOUBLE_TO_JSVAL(d);
+-            return JS_TRUE;
++            const jsdouble frame_rate =
++                s->script_node().type().metatype().browser().frame_rate();
++            return JS_NewNumberValue(cx, frame_rate, rval);
+         }
+ 
+         JSBool getWorldURL(JSContext * const cx,
+@@ -2823,7 +2819,7 @@
+         if (JSVAL_IS_INT(id)
+             && JSVAL_TO_INT(id) >= 0
+             && JSVAL_TO_INT(id) < 3) {
+-            if (!JS_NewDoubleValue(cx, thisColor.value()[JSVAL_TO_INT(id)], rval))
++            if (!JS_NewNumberValue(cx, thisColor.value()[JSVAL_TO_INT(id)], rval))
+             {
+                 return JS_FALSE;
+             }
+@@ -3681,7 +3677,7 @@
+ 
+         if (JSVAL_IS_INT(id)
+             && JSVAL_TO_INT(id) >= 0 && JSVAL_TO_INT(id) < 4) {
+-            if (!JS_NewDoubleValue(cx, thisRot.value()[JSVAL_TO_INT(id)], rval)) {
++            if (!JS_NewNumberValue(cx, thisRot.value()[JSVAL_TO_INT(id)], rval)) {
+                 return JS_FALSE;
+             }
+         }
+@@ -4164,7 +4160,7 @@
+             const sfvec2_t & thisVec =
+                 *boost::polymorphic_downcast<sfvec2_t *>(&sfdata.field_value());
+ 
+-            if (!JS_NewDoubleValue(cx, thisVec.value()[JSVAL_TO_INT(id)], rval)) {
++            if (!JS_NewNumberValue(cx, thisVec.value()[JSVAL_TO_INT(id)], rval)) {
+                 return JS_FALSE;
+             }
+         }
+@@ -4347,7 +4343,7 @@
+             *boost::polymorphic_downcast<sfvec2_t *>(&arg_sfdata.field_value());
+ 
+         const jsdouble result = thisVec.value().dot(argVec.value());
+-        if (!JS_NewDoubleValue(cx, result, rval)) { return JS_FALSE; }
++        if (!JS_NewNumberValue(cx, result, rval)) { return JS_FALSE; }
+         return JS_TRUE;
+     }
+ 
+@@ -4367,7 +4363,7 @@
+         const sfvec2_t & thisVec =
+             *boost::polymorphic_downcast<sfvec2_t *>(&sfdata.field_value());
+ 
+-        if (!JS_NewDoubleValue(cx, thisVec.value().length(), rval)) {
++        if (!JS_NewNumberValue(cx, thisVec.value().length(), rval)) {
+             return JS_FALSE;
+         }
+         return JS_TRUE;
+@@ -4783,7 +4779,7 @@
+             const sfvec3_t & thisVec =
+                 *boost::polymorphic_downcast<sfvec3_t *>(&sfdata.field_value());
+ 
+-            if (!JS_NewDoubleValue(cx, thisVec.value()[JSVAL_TO_INT(id)], vp)) {
++            if (!JS_NewNumberValue(cx, thisVec.value()[JSVAL_TO_INT(id)], vp)) {
+                 return JS_FALSE;
+             }
+         }
+@@ -5024,7 +5020,7 @@
+             *boost::polymorphic_downcast<sfvec3_t *>(&arg_sfdata.field_value());
+ 
+         const jsdouble result = thisVec.value().dot(argVec.value());
+-        if (!JS_NewDoubleValue(cx, result, rval)) { return JS_FALSE; }
++        if (!JS_NewNumberValue(cx, result, rval)) { return JS_FALSE; }
+         return JS_TRUE;
+     }
+ 
+@@ -5044,7 +5040,7 @@
+         const sfvec3_t & thisVec =
+             *boost::polymorphic_downcast<sfvec3_t *>(&sfdata.field_value());
+ 
+-        if (!JS_NewDoubleValue(cx, thisVec.value().length(), rval)) {
++        if (!JS_NewNumberValue(cx, thisVec.value().length(), rval)) {
+             return JS_FALSE;
+         }
+         return JS_TRUE;
+@@ -5749,7 +5745,7 @@
+             //
+             try {
+                 for (size_t i = length; i < newArray.size(); ++i) {
+-                    if (!JS_NewDoubleValue(cx, 0.0, &newArray[i])) {
++                    if (!JS_NewNumberValue(cx, 0.0, &newArray[i])) {
+                         throw std::bad_alloc();
+                     }
+                 }
+@@ -6142,7 +6138,7 @@
+         MFData * const mfdata =
+             static_cast<MFData *>(JS_GetPrivate(cx, mffloatObj));
+         for (size_t i = 0; i < floats.size(); ++i) {
+-            if (!JS_NewDoubleValue(cx, floats[i], &mfdata->array[i])) {
++            if (!JS_NewNumberValue(cx, floats[i], &mfdata->array[i])) {
+                 return JS_FALSE;
+             }
+         }
+@@ -6214,7 +6210,7 @@
+         MFData * const mfdata =
+             static_cast<MFData *>(JS_GetPrivate(cx, mfdoubleObj));
+         for (size_t i = 0; i < doubles.size(); ++i) {
+-            if (!JS_NewDoubleValue(cx, doubles[i], &mfdata->array[i])) {
++            if (!JS_NewNumberValue(cx, doubles[i], &mfdata->array[i])) {
+                 return JS_FALSE;
+             }
+         }
+@@ -7191,7 +7187,7 @@
+         MFData * const mfdata =
+             static_cast<MFData *>(JS_GetPrivate(cx, mftimeObj));
+         for (size_t i = 0; i < times.size(); ++i) {
+-            if (!JS_NewDoubleValue(cx, times[i], &mfdata->array[i])) {
++            if (!JS_NewNumberValue(cx, times[i], &mfdata->array[i])) {
+                 return JS_FALSE;
+             }
+         }
+@@ -7601,7 +7597,7 @@
+             const float (&row)[4] =
+                 *static_cast<float (*)[4]>(JS_GetPrivate(cx, obj));
+ 
+-            if (!JS_NewDoubleValue(cx, row[JSVAL_TO_INT(id)], vp)) {
++            if (!JS_NewNumberValue(cx, row[JSVAL_TO_INT(id)], vp)) {
+                 return JS_FALSE;
+             }
+         }
diff --git a/openvrml.spec b/openvrml.spec
index 69cffcf..fb62db0 100644
--- a/openvrml.spec
+++ b/openvrml.spec
@@ -1,11 +1,12 @@
 # -*- rpm-spec -*-
 Name:           openvrml
 Version:        0.18.6
-Release:        4%{?dist}.1
+Release:        4%{?dist}.2
 Summary:        VRML/X3D player and runtime library
 License:        LGPLv3+
 Group:          System Environment/Libraries
 Source:         http://downloads.sourceforge.net/project/openvrml/%{name}/%{version}/%{name}-%{version}.tar.gz
+Patch0:         javascript-newnumbervalue.patch
 URL:            http://openvrml.org
 BuildRequires:  pkgconfig >= 0.18.0
 BuildRequires:  libtool-ltdl-devel
@@ -139,6 +140,7 @@ OpenVRML API documentation.
 
 %prep
 %setup
+%patch0 -p0
 
 %build
 CXXFLAGS="%optflags -fvisibility=hidden -fvisibility-inlines-hidden -Wno-missing-braces -Wno-strict-aliasing -Wno-unused-variable"
@@ -236,6 +238,9 @@ CXXFLAGS="%optflags -fvisibility=hidden -fvisibility-inlines-hidden -Wno-missing
 %doc %{_datadir}/doc/libopenvrml-%{version}/manual
 
 %changelog
+* Sat Jan 22 2011  Braden McDaniel  <braden at endoframe.com> - 0.18.6-4.2
+- Use JS_NewNumberValue instead of the deprecated JS_NewDoubleValue.
+
 * Tue Oct 05 2010 jkeating - 0.18.6-4.1
 - Rebuilt for gcc bug 634757
 


More information about the scm-commits mailing list