File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -934,6 +934,32 @@ pub fn Persistent(comptime T: type) type {
934934 };
935935 }
936936
937+ pub fn castToFunctionTemplate (self : Self ) FunctionTemplate {
938+ return .{
939+ .handle = @as (* const c .FunctionTemplate , @ptrCast (self .handle )),
940+ };
941+ }
942+ pub fn castToObjectTemplate (self : Self ) ObjectTemplate {
943+ return .{
944+ .handle = @as (* const c .ObjectTemplate , @ptrCast (self .handle )),
945+ };
946+ }
947+
948+ pub fn castToContext (self : Self ) Context {
949+ return .{
950+ .handle = @as (* const c .Context , @ptrCast (self .handle )),
951+ };
952+ }
953+
954+ /// recoverCast is not meant to create a new Persistent, but instead to recover one for which we know that it is a Persistent.
955+ /// This can be used on an object that has previously been `castTo___`. This allows the user to store and operate on the
956+ /// underlying type without needing to extract it from the Persistent. Casting it back to Persistent allows us to reset it.
957+ pub fn recoverCast (data : T ) Self {
958+ return .{
959+ .handle = @as (handleT , @ptrCast (data .handle )),
960+ };
961+ }
962+
937963 pub fn toValue (self : Self ) Value {
938964 return .{
939965 .handle = self .handle ,
@@ -2068,7 +2094,7 @@ pub const Value = struct {
20682094 }
20692095
20702096 pub fn isBigUint64Array (self : Self ) bool {
2071- return c .v8__Value__IsBigUint64Array (self .handle );
2097+ return c .v8__Value__IsBigUint64Array (self .handle );
20722098 }
20732099
20742100 pub fn isFloat32Array (self : Self ) bool {
You can’t perform that action at this time.
0 commit comments