From a9ea69b5d53b033a9dc59b3534e282a2695605b6 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Sun, 31 May 2020 19:22:08 +0200 Subject: [PATCH] Add more comments explaining why Local::from_raw() is appropriate (#389) --- src/script_or_module.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/script_or_module.rs b/src/script_or_module.rs index 13f41972..70724801 100644 --- a/src/script_or_module.rs +++ b/src/script_or_module.rs @@ -18,6 +18,9 @@ impl ScriptOrModule { /// The name that was passed by the embedder as ResourceName to the /// ScriptOrigin. This can be either a v8::String or v8::Undefined. pub fn get_resource_name(&self) -> Local { + // Note: the C++ `v8::ScriptOrModule::GetResourceName()` does not actually + // return a local handle, but rather a handle whose lifetime is bound to + // the related `ScriptOrModule` object. unsafe { let ptr = v8__ScriptOrModule__GetResourceName(self); Local::from_raw(ptr).unwrap() @@ -27,6 +30,9 @@ impl ScriptOrModule { /// The options that were passed by the embedder as HostDefinedOptions to the /// ScriptOrigin. pub fn get_host_defined_options(&self) -> Local { + // Note: the C++ `v8::ScriptOrModule::GetHostDefinedOptions()` does not + // actually return a local handle, but rather a handle whose lifetime is + // bound to the related `ScriptOrModule` object. unsafe { let ptr = v8__ScriptOrModule__GetHostDefinedOptions(self); Local::from_raw(ptr).unwrap()