зеркало из https://github.com/mozilla/gecko-dev.git
Bug 687642 - Rename JSFlatString::isElement to JSFlatString::isIndex. This better comports with other terminology being thrown around, and it makes it simpler to distinguish between the value used as the property name (the index, potentially) and the value the property contains (the element). r=dvander
--HG-- extra : rebase_source : e66315100fc331a4bd961a2cd281c36ed23ce471
This commit is contained in:
Родитель
ca975bca37
Коммит
70cbcf0143
|
@ -68,7 +68,7 @@ BEGIN_TEST(testIndexToString)
|
|||
}
|
||||
END_TEST(testIndexToString)
|
||||
|
||||
BEGIN_TEST(testStringIsElement)
|
||||
BEGIN_TEST(testStringIsIndex)
|
||||
{
|
||||
for (size_t i = 0, sz = JS_ARRAY_LENGTH(tests); i < sz; i++) {
|
||||
uint32 u = tests[i].num;
|
||||
|
@ -76,13 +76,13 @@ BEGIN_TEST(testStringIsElement)
|
|||
CHECK(str);
|
||||
|
||||
uint32 n;
|
||||
CHECK(str->isElement(&n));
|
||||
CHECK(str->isIndex(&n));
|
||||
CHECK(u == n);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
END_TEST(testStringIsElement)
|
||||
END_TEST(testStringIsIndex)
|
||||
|
||||
BEGIN_TEST(testStringToPropertyName)
|
||||
{
|
||||
|
@ -91,19 +91,19 @@ BEGIN_TEST(testStringToPropertyName)
|
|||
static const jschar hiChars[] = { 'h', 'i' };
|
||||
JSFlatString *hiStr = NewString(cx, hiChars);
|
||||
CHECK(hiStr);
|
||||
CHECK(!hiStr->isElement(&index));
|
||||
CHECK(!hiStr->isIndex(&index));
|
||||
CHECK(hiStr->toPropertyName(cx) != NULL);
|
||||
|
||||
static const jschar maxChars[] = { '4', '2', '9', '4', '9', '6', '7', '2', '9', '5' };
|
||||
JSFlatString *maxStr = NewString(cx, maxChars);
|
||||
CHECK(maxStr);
|
||||
CHECK(maxStr->isElement(&index));
|
||||
CHECK(maxStr->isIndex(&index));
|
||||
CHECK(index == UINT32_MAX);
|
||||
|
||||
static const jschar maxPlusOneChars[] = { '4', '2', '9', '4', '9', '6', '7', '2', '9', '6' };
|
||||
JSFlatString *maxPlusOneStr = NewString(cx, maxPlusOneChars);
|
||||
CHECK(maxPlusOneStr);
|
||||
CHECK(!maxPlusOneStr->isElement(&index));
|
||||
CHECK(!maxPlusOneStr->isIndex(&index));
|
||||
CHECK(maxPlusOneStr->toPropertyName(cx) != NULL);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -94,7 +94,7 @@ JSFlatString::toPropertyName(JSContext *cx)
|
|||
{
|
||||
#ifdef DEBUG
|
||||
uint32 dummy;
|
||||
JS_ASSERT(!isElement(&dummy));
|
||||
JS_ASSERT(!isIndex(&dummy));
|
||||
#endif
|
||||
if (isAtom())
|
||||
return asAtom().asPropertyName();
|
||||
|
|
|
@ -325,7 +325,7 @@ JSStringFinalizeOp JSExternalString::str_finalizers[JSExternalString::TYPE_LIMIT
|
|||
};
|
||||
|
||||
bool
|
||||
JSFlatString::isElement(uint32 *indexp) const
|
||||
JSFlatString::isIndex(uint32 *indexp) const
|
||||
{
|
||||
const jschar *s = charsZ();
|
||||
jschar ch = *s;
|
||||
|
|
|
@ -487,14 +487,14 @@ class JSFlatString : public JSLinearString
|
|||
/*
|
||||
* Returns true if this string's characters store an unsigned 32-bit
|
||||
* integer value, initializing *indexp to that value if so. (Thus if
|
||||
* calling isElement returns true, js::IndexToString(cx, *indexp) will be a
|
||||
* calling isIndex returns true, js::IndexToString(cx, *indexp) will be a
|
||||
* string equal to this string.)
|
||||
*/
|
||||
bool isElement(uint32 *indexp) const;
|
||||
bool isIndex(uint32 *indexp) const;
|
||||
|
||||
/*
|
||||
* Returns a property name represented by this string, or null on failure.
|
||||
* You must verify that this is not an element per isElement before calling
|
||||
* You must verify that this is not an index per isIndex before calling
|
||||
* this method.
|
||||
*/
|
||||
inline js::PropertyName *toPropertyName(JSContext *cx);
|
||||
|
@ -644,7 +644,7 @@ JS_STATIC_ASSERT(sizeof(JSExternalString) == sizeof(JSString));
|
|||
class JSAtom : public JSFixedString
|
||||
{
|
||||
public:
|
||||
/* Returns the PropertyName for this. isElement() must be false. */
|
||||
/* Returns the PropertyName for this. isIndex() must be false. */
|
||||
inline js::PropertyName *asPropertyName();
|
||||
|
||||
inline void finalize(JSRuntime *rt);
|
||||
|
@ -794,7 +794,7 @@ JSAtom::asPropertyName()
|
|||
{
|
||||
#ifdef DEBUG
|
||||
uint32 dummy;
|
||||
JS_ASSERT(!isElement(&dummy));
|
||||
JS_ASSERT(!isIndex(&dummy));
|
||||
#endif
|
||||
return static_cast<js::PropertyName *>(this);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче