}
}
public JsObjectProperty createObjectProperty(final PropertyDescriptorValue propertyDescriptor,
final String hostObjectRefId, ValueNameBuilder nameBuilder) {
final QualifiedNameBuilder qualifiedNameBuilder = nameBuilder.getQualifiedNameBuilder();
JsValue jsValue = wrap(propertyDescriptor.value(), qualifiedNameBuilder);
final JsValue getter = wrapPropertyDescriptorFunction(propertyDescriptor.get(),
qualifiedNameBuilder, "getter");
final JsValue setter = wrapPropertyDescriptorFunction(propertyDescriptor.set(),
qualifiedNameBuilder, "setter");
return new ObjectPropertyBase(jsValue, nameBuilder) {
@Override public JsDeclarativeVariable asDeclarativeVariable() {
return null;
}
@Override public boolean isWritable() {
return propertyDescriptor.writable() == Boolean.TRUE;
}
@Override public JsValue getGetter() {
return getter;
}
@Override public JsValue getSetter() {
return setter;
}
@Override public boolean isConfigurable() {
return propertyDescriptor.configurable() == Boolean.TRUE;
}
@Override public boolean isEnumerable() {
return propertyDescriptor.enumerable() == Boolean.TRUE;
}
@Override
public JsFunction getGetterAsFunction() {
JsObject getterObject = getter.asObject();
if (getterObject == null) {
return null;
}
return getterObject.asFunction();
}
@Override
public RelayOk evaluateGet(EvaluateCallback callback, SyncCallback syncCallback) {
WipContextBuilder.GlobalEvaluateContext evaluateContext =
new WipContextBuilder.GlobalEvaluateContext(valueLoader);
JsFunction getterFunction = getGetterAsFunction();
if (getterFunction == null) {
throw new RuntimeException("Getter is not a function");
}
Map<String, SerializableValue> context = new HashMap<String, SerializableValue>(2);
context.put(GETTER_VAR_NAME, (SerializableValue) getterFunction);
context.put(OBJECT_VAR_NAME, SerializableValue.Util.wrapRefId(hostObjectRefId));
final QualifiedNameBuilder pseudoPropertyNameBuilder =
createPseudoPropertyNameBuilder(qualifiedNameBuilder, "value");
ValueNameBuilder valueNameBuilder = new ValueNameBuilder() {
@Override
public String getShortName() {
return "value";