uint32_t usage in kjs
Darin Adler
khtml-devel@kde.org
Mon, 24 Feb 2003 08:17:13 -0800
On Monday, February 24, 2003, at 08:07 AM, Darin Adler wrote:
> But more importantly, looking at JavaScriptCore, I see no good reason
> to have added UString::toUInt32. The only place this function is used
> is in ArrayInstanceImp::deleteProperty and clearly UString::toULong
> would be fine instead.
Actually, I oversimplified, there are a couple of other places it's
used.
> I'm going to remove UString::toUInt32 from JavaScriptCore.
But I did decide to remove it. Here's the patch.
Index: kjs/array_object.cpp
===================================================================
RCS file:
/local/home/cvs/Labyrinth/JavaScriptCore/kjs/array_object.cpp,v
retrieving revision 1.26
diff -p -u -u -p -r1.26 kjs/array_object.cpp
--- kjs/array_object.cpp 2003/01/28 20:50:56 1.26
+++ kjs/array_object.cpp 2003/02/24 16:15:38
@@ -175,7 +175,7 @@ bool ArrayInstanceImp::deleteProperty(Ex
return false;
bool ok;
- uint32_t index = propertyName.toUInt32(&ok);
+ unsigned long index = propertyName.toULong(&ok);
if (ok) {
if (index >= length)
return true;
Index: kjs/identifier.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/JavaScriptCore/kjs/identifier.h,v
retrieving revision 1.8
diff -p -u -u -p -r1.8 kjs/identifier.h
--- kjs/identifier.h 2003/01/22 00:11:43 1.8
+++ kjs/identifier.h 2003/02/24 16:15:38
@@ -49,7 +49,6 @@ namespace KJS {
bool isEmpty() const { return _ustring.isEmpty(); }
unsigned long toULong(bool *ok) const { return
_ustring.toULong(ok); }
- uint32_t toUInt32(bool *ok) const { return
_ustring.toUInt32(ok); }
double toDouble() const { return _ustring.toDouble(); }
static Identifier null;
Index: kjs/property_map.cpp
===================================================================
RCS file:
/local/home/cvs/Labyrinth/JavaScriptCore/kjs/property_map.cpp,v
retrieving revision 1.31
diff -p -u -u -p -r1.31 kjs/property_map.cpp
--- kjs/property_map.cpp 2003/01/22 00:11:44 1.31
+++ kjs/property_map.cpp 2003/02/24 16:15:38
@@ -411,9 +411,9 @@ void PropertyMap::addSparseArrayProperti
UString::Rep *key = _singleEntry.key;
if (key) {
UString k(key);
- bool fitsInUInt32;
- k.toUInt32(&fitsInUInt32);
- if (fitsInUInt32)
+ bool fitsInULong;
+ unsigned long i = k.toULong(&fitsInULong);
+ if (fitsInULong && i <= 0xFFFFFFFFU)
list.append(Reference(base, Identifier(key)));
}
#endif
@@ -424,9 +424,9 @@ void PropertyMap::addSparseArrayProperti
UString::Rep *key = _table->entries[i].key;
if (key) {
UString k(key);
- bool fitsInUInt32;
- k.toUInt32(&fitsInUInt32);
- if (fitsInUInt32)
+ bool fitsInULong;
+ unsigned long i = k.toULong(&fitsInULong);
+ if (fitsInULong && i <= 0xFFFFFFFFU)
list.append(Reference(base, Identifier(key)));
}
}
Index: kjs/ustring.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/JavaScriptCore/kjs/ustring.cpp,v
retrieving revision 1.29
diff -p -u -u -p -r1.29 kjs/ustring.cpp
--- kjs/ustring.cpp 2003/01/22 00:11:44 1.29
+++ kjs/ustring.cpp 2003/02/24 16:15:38
@@ -596,22 +596,6 @@ unsigned long UString::toULong(bool *ok)
return static_cast<unsigned long>(d);
}
-uint32_t UString::toUInt32(bool *ok) const
-{
- double d = toDouble();
- bool b = true;
-
- if (isNaN(d) || d != static_cast<uint32_t>(d)) {
- b = false;
- d = 0;
- }
-
- if (ok)
- *ok = b;
-
- return static_cast<uint32_t>(d);
-}
-
int UString::find(const UString &f, int pos) const
{
int sz = size();
Index: kjs/ustring.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/JavaScriptCore/kjs/ustring.h,v
retrieving revision 1.23
diff -p -u -u -p -r1.23 kjs/ustring.h
--- kjs/ustring.h 2003/01/22 00:11:44 1.23
+++ kjs/ustring.h 2003/02/24 16:15:38
@@ -387,8 +387,6 @@ namespace KJS {
*/
unsigned long toULong(bool *ok = 0L) const;
- uint32_t toUInt32(bool *ok = 0L) const;
-
/**
* @return Position of first occurrence of f starting at position
pos.
* -1 if the search was not successful.
===================================================================
-- Darin