Skip to content

Commit 3f52092

Browse files
committed
Implementation of v8::Object::CreateDataProperty().
1 parent d46ccab commit 3f52092

File tree

7 files changed

+37
-0
lines changed

7 files changed

+37
-0
lines changed

graal-nodejs/deps/v8/src/graal/graal_isolate.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,8 @@ GraalIsolate::GraalIsolate(JavaVM* jvm, JNIEnv* env, v8::Isolate::CreateParams c
642642
ACCESS_METHOD(GraalAccessMethod::object_get_property_names, "objectGetPropertyNames", "(Ljava/lang/Object;ZZZZZZZZ)Ljava/lang/Object;")
643643
ACCESS_METHOD(GraalAccessMethod::object_get_own_property_names, "objectGetOwnPropertyNames", "(Ljava/lang/Object;)Ljava/lang/Object;")
644644
ACCESS_METHOD(GraalAccessMethod::object_creation_context, "objectCreationContext", "(Ljava/lang/Object;)Ljava/lang/Object;")
645+
ACCESS_METHOD(GraalAccessMethod::object_create_data_property, "objectCreateDataProperty", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Z")
646+
ACCESS_METHOD(GraalAccessMethod::object_create_data_property_index, "objectCreateDataProperty", "(Ljava/lang/Object;JLjava/lang/Object;)Z")
645647
ACCESS_METHOD(GraalAccessMethod::object_define_property, "objectDefineProperty", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ZZZZZZ)Z")
646648
ACCESS_METHOD(GraalAccessMethod::object_preview_entries, "objectPreviewEntries", "(Ljava/lang/Object;)Ljava/lang/Object;")
647649
ACCESS_METHOD(GraalAccessMethod::object_set_integrity_level, "objectSetIntegrityLevel", "(Ljava/lang/Object;Z)V")

graal-nodejs/deps/v8/src/graal/graal_isolate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ enum GraalAccessMethod {
157157
object_get_property_names,
158158
object_get_own_property_names,
159159
object_creation_context,
160+
object_create_data_property,
161+
object_create_data_property_index,
160162
object_define_property,
161163
object_preview_entries,
162164
object_set_integrity_level,

graal-nodejs/deps/v8/src/graal/graal_object.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,20 @@ v8::MaybeLocal<v8::Value> GraalObject::GetOwnPropertyDescriptor(v8::Local<v8::Co
299299
return v8_result;
300300
}
301301

302+
v8::Maybe<bool> GraalObject::CreateDataProperty(v8::Local<v8::Context> context, v8::Local<v8::Name> key, v8::Local<v8::Value> value) {
303+
jobject java_key = reinterpret_cast<GraalHandleContent*> (*key)->GetJavaObject();
304+
jobject java_value = reinterpret_cast<GraalHandleContent*> (*value)->GetJavaObject();
305+
JNI_CALL(jboolean, result, Isolate(), GraalAccessMethod::object_create_data_property, Boolean, GetJavaObject(), java_key, java_value);
306+
return v8::Just((bool) result);
307+
}
308+
309+
v8::Maybe<bool> GraalObject::CreateDataProperty(v8::Local<v8::Context> context, uint32_t index, v8::Local<v8::Value> value) {
310+
jlong java_index = (jlong) index;
311+
jobject java_value = reinterpret_cast<GraalHandleContent*> (*value)->GetJavaObject();
312+
JNI_CALL(jboolean, result, Isolate(), GraalAccessMethod::object_create_data_property_index, Boolean, GetJavaObject(), java_index, java_value);
313+
return v8::Just((bool) result);
314+
}
315+
302316
v8::Maybe<bool> GraalObject::DefineProperty(v8::Local<v8::Context> context, v8::Local<v8::Name> key, v8::PropertyDescriptor& descriptor) {
303317
jobject java_key = reinterpret_cast<GraalHandleContent*> (*key)->GetJavaObject();
304318
jobject value = descriptor.has_value() ? reinterpret_cast<GraalHandleContent*> (*descriptor.value())->GetJavaObject() : NULL;

graal-nodejs/deps/v8/src/graal/graal_object.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class GraalObject : public GraalValue {
8787
v8::Maybe<bool> HasPrivate(v8::Local<v8::Context> context, v8::Local<v8::Private> key);
8888
v8::Maybe<bool> DeletePrivate(v8::Local<v8::Context> context, v8::Local<v8::Private> key);
8989
v8::MaybeLocal<v8::Value> GetOwnPropertyDescriptor(v8::Local<v8::Context> context, v8::Local<v8::Name> key);
90+
v8::Maybe<bool> CreateDataProperty(v8::Local<v8::Context> context, v8::Local<v8::Name> key, v8::Local<v8::Value> value);
91+
v8::Maybe<bool> CreateDataProperty(v8::Local<v8::Context> context, uint32_t index, v8::Local<v8::Value> value);
9092
v8::Maybe<bool> DefineProperty(v8::Local<v8::Context> context, v8::Local<v8::Name> key, v8::PropertyDescriptor& descriptor);
9193
v8::MaybeLocal<v8::Array> PreviewEntries(bool* is_key_value);
9294
v8::Maybe<bool> SetIntegrityLevel(v8::Local<v8::Context> context, v8::IntegrityLevel level);

graal-nodejs/deps/v8/src/graal/v8.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,14 @@ namespace v8 {
19401940
return Just(GetEndColumn());
19411941
}
19421942

1943+
Maybe<bool> Object::CreateDataProperty(Local<Context> context, Local<Name> key, Local<Value> value) {
1944+
return reinterpret_cast<GraalObject*> (this)->CreateDataProperty(context, key, value);
1945+
}
1946+
1947+
Maybe<bool> Object::CreateDataProperty(Local<Context> context, uint32_t index, Local<Value> value) {
1948+
return reinterpret_cast<GraalObject*> (this)->CreateDataProperty(context, index, value);
1949+
}
1950+
19431951
Maybe<bool> Object::DefineOwnProperty(Local<Context> context, Local<Name> key, Local<Value> value, PropertyAttribute attributes) {
19441952
return Just(reinterpret_cast<GraalObject*> (this)->ForceSet(key, value, attributes));
19451953
}

graal-nodejs/mx.graal-nodejs/com.oracle.truffle.trufflenode/src/com/oracle/truffle/trufflenode/GraalJSAccess.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,14 @@ public Object objectGetOwnPropertyDescriptor(Object object, Object key) {
926926
return JSRuntime.fromPropertyDescriptor(desc, context);
927927
}
928928

929+
public boolean objectCreateDataProperty(Object object, Object key, Object value) {
930+
return JSRuntime.createDataProperty((JSDynamicObject) object, key, value);
931+
}
932+
933+
public boolean objectCreateDataProperty(Object object, long index, Object value) {
934+
return objectCreateDataProperty(object, Strings.fromLong(index), value);
935+
}
936+
929937
public boolean objectDefineProperty(Object object, Object key,
930938
Object value, Object get, Object set,
931939
boolean hasEnumerable, boolean enumerable,

graal-nodejs/mx.graal-nodejs/com.oracle.truffle.trufflenode/src/svmnodejs.jniconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
{ "name": "numberNew" },
143143
{ "name": "numberObjectNew" },
144144
{ "name": "objectClone" },
145+
{ "name": "objectCreateDataProperty" },
145146
{ "name": "objectCreationContext" },
146147
{ "name": "objectDefineProperty" },
147148
{ "name": "objectDelete" },

0 commit comments

Comments
 (0)