Skip to content

Commit c895ad7

Browse files
Add Object.GetConstructorName
Signed-off-by: Francis Bouvier <[email protected]>
1 parent bf5d995 commit c895ad7

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/binding.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,11 @@ const v8::Object* v8__Object__New(
873873
return local_to_ptr(v8::Object::New(isolate));
874874
}
875875

876+
const v8::String* v8__Object__GetConstructorName(
877+
const v8::Object& self) {
878+
return local_to_ptr(ptr_to_local(&self)->GetConstructorName());
879+
}
880+
876881
void v8__Object__SetInternalField(
877882
const v8::Object& self,
878883
int index,

src/binding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ uint32_t v8__Array__Length(const Array* self);
460460

461461
// Object
462462
const Object* v8__Object__New(Isolate* isolate);
463+
const String* v8__Object__GetConstructorName(const Object* self);
463464
int v8__Object__InternalFieldCount(
464465
const Object* self);
465466
const Value* v8__Object__GetInternalField(

src/v8.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,12 @@ pub const Object = struct {
987987
};
988988
}
989989

990+
pub fn getConstructorName(self: Self) !String {
991+
return String{
992+
.handle = c.v8__Object__GetConstructorName(self.handle) orelse return error.JsException,
993+
};
994+
}
995+
990996
pub fn setInternalField(self: Self, idx: u32, value: anytype) void {
991997
c.v8__Object__SetInternalField(self.handle, @as(c_int, @intCast(idx)), getValueHandle(value));
992998
}

0 commit comments

Comments
 (0)