Skip to content

Commit

Permalink
Fix ArchitectureTest failure by moving regexp string iterator initi…
Browse files Browse the repository at this point in the history
…alization in the regexp proxy
  • Loading branch information
andreabergia committed Nov 25, 2024
1 parent 9162c2c commit 03303eb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public LazilyLoadedCtor(
this(scope, propertyName, className, sealed, false);
}

LazilyLoadedCtor(
public LazilyLoadedCtor(
ScriptableObject scope,
String propertyName,
String className,
Expand Down
2 changes: 2 additions & 0 deletions rhino/src/main/java/org/mozilla/javascript/RegExpProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public interface RegExpProxy {
public static final int RA_REPLACE_ALL = 3;
public static final int RA_SEARCH = 4;

public void register(ScriptableObject scope, boolean sealed);

public boolean isRegExp(Scriptable obj);

public Object compileRegExp(Context cx, String source, String flags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.ResourceBundle;
import java.util.function.BiConsumer;
import org.mozilla.javascript.ast.FunctionNode;
import org.mozilla.javascript.regexp.NativeRegExpStringIterator;
import org.mozilla.javascript.v8dtoa.DoubleConversion;
import org.mozilla.javascript.v8dtoa.FastDtoa;
import org.mozilla.javascript.xml.XMLLib;
Expand Down Expand Up @@ -189,7 +188,7 @@ public static ScriptableObject initSafeStandardObjects(

NativeArrayIterator.init(scope, sealed);
NativeStringIterator.init(scope, sealed);
NativeRegExpStringIterator.init(scope, sealed);
getRegExpProxy(cx).register(scope, sealed);

NativeJavaObject.init(scope, sealed);
NativeJavaMap.init(scope, sealed);
Expand All @@ -198,8 +197,6 @@ public static ScriptableObject initSafeStandardObjects(
cx.hasFeature(Context.FEATURE_E4X) && cx.getE4xImplementationFactory() != null;

// define lazy-loaded properties using their class name
new LazilyLoadedCtor(
scope, "RegExp", "org.mozilla.javascript.regexp.NativeRegExp", sealed, true);
new LazilyLoadedCtor(
scope, "Continuation", "org.mozilla.javascript.NativeContinuation", sealed, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Kit;
import org.mozilla.javascript.LazilyLoadedCtor;
import org.mozilla.javascript.RegExpProxy;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
Expand All @@ -18,6 +19,13 @@
/** */
public class RegExpImpl implements RegExpProxy {

@Override
public void register(ScriptableObject scope, boolean sealed) {
NativeRegExpStringIterator.init(scope, sealed);
new LazilyLoadedCtor(
scope, "RegExp", "org.mozilla.javascript.regexp.NativeRegExp", sealed, true);
}

@Override
public boolean isRegExp(Scriptable obj) {
return obj instanceof NativeRegExp;
Expand Down

0 comments on commit 03303eb

Please sign in to comment.