public class LambdaAccessorSlot extends Slot
LambdaSlot, but allows
defining properties with getter and setter lambdas that require access to the owner object
('this'). This enables the implementation of properties that can access instance fields of the
owner.
Unlike LambdaSlot, Lambda functions used to define getter and setter logic require the
owner's `Scriptable` object as one of the parameters. This is particularly useful for
implementing properties that behave like standard JavaScript properties, but are implemented with
native functionality without the need for reflection.
| Modifier and Type | Method and Description |
|---|---|
ScriptableObject |
buildPropertyDescriptor(Context cx)
The method exists avoid changing the getPropertyDescriptor signature and at the same time to
make it explicit that we don't use Scriptable scope parameter of getPropertyDescriptor, since
it can be problematic when called from inside ThreadSafeSlotMapContainer::compute lambda
which can lead to deadlocks.
|
Object |
getValue(Scriptable owner) |
void |
replaceWith(LambdaAccessorSlot slot) |
void |
setGetter(Scriptable scope,
ScriptableObject.LambdaGetterFunction getter) |
void |
setSetter(Scriptable scope,
ScriptableObject.LambdaSetterFunction setter) |
boolean |
setValue(Object value,
Scriptable scope,
Scriptable start,
boolean isThrow) |
setValue, throwNoSetterExceptionpublic ScriptableObject buildPropertyDescriptor(Context cx)
public boolean setValue(Object value, Scriptable scope, Scriptable start, boolean isThrow)
public Object getValue(Scriptable owner)
public void setGetter(Scriptable scope, ScriptableObject.LambdaGetterFunction getter)
public void setSetter(Scriptable scope, ScriptableObject.LambdaSetterFunction setter)
public void replaceWith(LambdaAccessorSlot slot)
Copyright © 2025 HtmlUnit. All rights reserved.