Bug 1199887 - Rename StringRegExpGuard::init(JSContext*, JSObject*) to initRegExp for clarity. r=evilpie

This commit is contained in:
Jeff Walden 2015-08-26 11:43:49 -07:00
parent 307b69a138
commit de8b84df3d
5 changed files with 13 additions and 15 deletions

View File

@ -1052,7 +1052,7 @@ bool
RRegExpReplace::recover(JSContext* cx, SnapshotIterator& iter) const
{
RootedString string(cx, iter.read().toString());
RootedObject regexp(cx, &iter.read().toObject());
Rooted<RegExpObject*> regexp(cx, &iter.read().toObject().as<RegExpObject>());
RootedString repl(cx, iter.read().toString());
RootedValue result(cx);

View File

@ -1042,7 +1042,7 @@ RegExpReplace(JSContext* cx, HandleString string, HandleObject regexp, HandleStr
MOZ_ASSERT(repl);
RootedValue rval(cx);
if (!str_replace_regexp_raw(cx, string, regexp, repl, &rval))
if (!str_replace_regexp_raw(cx, string, regexp.as<RegExpObject>(), repl, &rval))
return nullptr;
return rval.toString();

View File

@ -2101,7 +2101,7 @@ class MOZ_STACK_CLASS StringRegExpGuard
bool init(JSContext* cx, const CallArgs& args, bool convertVoid = false)
{
if (args.length() != 0 && IsObjectWithClass(args[0], ESClass_RegExp, cx))
return init(cx, &args[0].toObject());
return initRegExp(cx, &args[0].toObject());
if (convertVoid && !args.hasDefined(0)) {
fm.pat_ = cx->runtime()->emptyString;
@ -2119,14 +2119,12 @@ class MOZ_STACK_CLASS StringRegExpGuard
return true;
}
bool init(JSContext* cx, JSObject* regexp) {
bool initRegExp(JSContext* cx, JSObject* regexp) {
obj_ = regexp;
MOZ_ASSERT(ObjectClassIs(obj_, ESClass_RegExp, cx));
if (!RegExpToShared(cx, obj_, &re_))
return false;
return true;
return RegExpToShared(cx, obj_, &re_);
}
bool init(JSContext* cx, HandleString pattern) {
@ -3346,13 +3344,13 @@ str_replace_regexp(JSContext* cx, const CallArgs& args, ReplaceData& rdata)
}
bool
js::str_replace_regexp_raw(JSContext* cx, HandleString string, HandleObject regexp,
HandleString replacement, MutableHandleValue rval)
js::str_replace_regexp_raw(JSContext* cx, HandleString string, Handle<RegExpObject*> regexp,
HandleString replacement, MutableHandleValue rval)
{
/* Optimize removal, so we don't have to create ReplaceData */
if (replacement->length() == 0) {
StringRegExpGuard guard(cx);
if (!guard.init(cx, regexp))
if (!guard.initRegExp(cx, regexp))
return false;
RegExpShared& re = guard.regExp();
@ -3368,7 +3366,7 @@ js::str_replace_regexp_raw(JSContext* cx, HandleString string, HandleObject rege
rdata.setReplacementString(repl);
if (!rdata.g.init(cx, regexp))
if (!rdata.g.initRegExp(cx, regexp))
return false;
return StrReplaceRegExp(cx, rdata, rval);

View File

@ -428,10 +428,6 @@ str_split(JSContext* cx, unsigned argc, Value* vp);
JSObject*
str_split_string(JSContext* cx, HandleObjectGroup group, HandleString str, HandleString sep);
bool
str_replace_regexp_raw(JSContext* cx, HandleString string, HandleObject regexp,
HandleString replacement, MutableHandleValue rval);
bool
str_replace_string_raw(JSContext* cx, HandleString string, HandleString pattern,
HandleString replacement, MutableHandleValue rval);

View File

@ -474,6 +474,10 @@ class RegExpObject : public NativeObject
void setPrivate(void* priv) = delete;
};
bool
str_replace_regexp_raw(JSContext* cx, HandleString string, Handle<RegExpObject*> regexp,
HandleString replacement, MutableHandleValue rval);
/*
* Parse regexp flags. Report an error and return false if an invalid
* sequence of flags is encountered (repeat/invalid flag).