Skip to content

Commit b8f7fa0

Browse files
Merge pull request #20 from lightpanda-io/Object.GetPrototype
Add Object.GetPrototype
2 parents bf5d995 + 5c6501f commit b8f7fa0

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
@@ -996,6 +996,11 @@ const v8::Array* v8__Object__GetPropertyNames(
996996
);
997997
}
998998

999+
const v8::Value* v8__Object__GetPrototype(
1000+
const v8::Object& self) {
1001+
return local_to_ptr(ptr_to_local(&self)->GetPrototype());
1002+
}
1003+
9991004
void v8__Object__SetPrototype(
10001005
const v8::Object& self,
10011006
const v8::Context& ctx,

src/binding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ const Array* v8__Object__GetOwnPropertyNames(
515515
const Array* v8__Object__GetPropertyNames(
516516
const Object* self,
517517
const Context* ctx);
518+
const Value* v8__Object__GetPrototype(const Object* self);
518519
void v8__Object__SetPrototype(
519520
const Object* self,
520521
const Context* ctx,

src/v8.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,12 @@ pub const Object = struct {
10941094
};
10951095
}
10961096

1097+
pub fn getPrototype(self: Self) Value {
1098+
return .{
1099+
.handle = c.v8__Object__GetPrototype(self.handle).?,
1100+
};
1101+
}
1102+
10971103
pub fn setPrototype(self: Self, ctx: Context, prototype: Object) bool {
10981104
var out: c.MaybeBool = undefined;
10991105
c.v8__Object__SetPrototype(self.handle, ctx.handle, prototype.handle, &out);

0 commit comments

Comments
 (0)