mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-26 09:13:46 -05:00
add v8::Module::instantiate_module (#98)
Co-authored-by: Bert Belder <bertbelder@gmail.com>
This commit is contained in:
parent
f839aa221a
commit
32fc7e7bef
2 changed files with 23 additions and 11 deletions
|
@ -627,4 +627,10 @@ v8_inspector::StringBuffer* v8_inspector__StringBuffer__create(
|
||||||
const v8_inspector::StringView& source) {
|
const v8_inspector::StringView& source) {
|
||||||
return v8_inspector::StringBuffer::create(source).release();
|
return v8_inspector::StringBuffer::create(source).release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MaybeBool v8__Module__InstantiateModule(v8::Module& self,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
v8::Module::ResolveCallback callback) {
|
||||||
|
return maybe_to_maybe_bool(self.InstantiateModule(context, callback));
|
||||||
|
}
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
|
@ -1,10 +1,22 @@
|
||||||
use crate::support::int;
|
use crate::support::int;
|
||||||
|
use crate::support::MaybeBool;
|
||||||
use crate::support::Opaque;
|
use crate::support::Opaque;
|
||||||
use crate::Context;
|
use crate::Context;
|
||||||
use crate::Local;
|
use crate::Local;
|
||||||
|
use crate::String;
|
||||||
use crate::Value;
|
use crate::Value;
|
||||||
|
|
||||||
extern "C" {}
|
// Ideally the return value would be Option<Local<Module>>... but not FFI-safe
|
||||||
|
type ResolveCallback =
|
||||||
|
extern "C" fn(Local<Context>, Local<String>, Local<Module>) -> *mut Module;
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
fn v8__Module__InstantiateModule(
|
||||||
|
this: *mut Module,
|
||||||
|
context: Local<Context>,
|
||||||
|
callback: ResolveCallback,
|
||||||
|
) -> MaybeBool;
|
||||||
|
}
|
||||||
|
|
||||||
/// The different states a module can be in.
|
/// The different states a module can be in.
|
||||||
///
|
///
|
||||||
|
@ -60,11 +72,11 @@ impl Module {
|
||||||
/// exception is propagated.)
|
/// exception is propagated.)
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn instantiate_module(
|
pub fn instantiate_module(
|
||||||
&self,
|
&mut self,
|
||||||
_context: Local<Context>,
|
context: Local<Context>,
|
||||||
_callback: Box<ResolveCallback>,
|
callback: ResolveCallback,
|
||||||
) -> Option<bool> {
|
) -> Option<bool> {
|
||||||
unimplemented!();
|
unsafe { v8__Module__InstantiateModule(self, context, callback) }.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluates the module and its dependencies.
|
/// Evaluates the module and its dependencies.
|
||||||
|
@ -78,9 +90,3 @@ impl Module {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResolveCallback<'sc> = dyn Fn(
|
|
||||||
Local<'sc, Context>,
|
|
||||||
Local<'sc, String>,
|
|
||||||
Local<'sc, Module>,
|
|
||||||
) -> Option<Local<'sc, Module>>;
|
|
||||||
|
|
Loading…
Reference in a new issue