Reviewed-on: #27
This commit is contained in:
commit
5d123250b3
@ -1,2 +1,2 @@
|
||||
pub mod v8;
|
||||
pub mod quickjs;
|
||||
// pub mod mlua;
|
||||
|
||||
@ -102,8 +102,9 @@ impl V8Runtime {
|
||||
Ok(event) => event,
|
||||
Err(err) => break,
|
||||
};
|
||||
let (event, v8runtime) = (event.event, event.runtime);
|
||||
match event {
|
||||
Event::GetScriptConfig(script) => {
|
||||
EventType::GetScriptConfig(script) => {
|
||||
let code = FastString::from(script);
|
||||
|
||||
let result = runtime.execute_script("", code).unwrap();
|
||||
@ -115,7 +116,7 @@ impl V8Runtime {
|
||||
// rtx.send(RuntimeReturn::Value(unsafe { V8Value::new(SerdeValue::from(result)) }))
|
||||
rtx.send(RuntimeReturn::Config(config)).unwrap();
|
||||
}
|
||||
Event::ExecuteFunction(f, args) => {
|
||||
EventType::ExecuteFunction(f, args) => {
|
||||
let value = unsafe { f.get_inner() }.get_value();
|
||||
let value = handlers[value];
|
||||
let mut scope = runtime.handle_scope();
|
||||
@ -133,7 +134,7 @@ impl V8Runtime {
|
||||
let result = result.map(|r| SerdeValue::from(r));
|
||||
|
||||
rtx.send(RuntimeReturn::OptionalValue(
|
||||
result.map(|result| unsafe { V8Value::new(SerdeValue::from(result)) }),
|
||||
result.map(|result| unsafe { V8Value::new(v8runtime.clone(), SerdeValue::from(result)) }),
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
@ -251,7 +252,7 @@ impl ProviderCall for V8Function {
|
||||
self.runtime
|
||||
.lock()
|
||||
.unwrap()
|
||||
.call_event(Event::ExecuteFunction(
|
||||
.call_event(EventType::ExecuteFunction(
|
||||
self.clone(),
|
||||
args.into_iter().map(|v| (*v).clone()).collect(),
|
||||
));
|
||||
@ -277,7 +278,7 @@ impl Provider for V8Runtime {
|
||||
type InitData = V8Init;
|
||||
|
||||
fn init_config(&self, d: Self::InitData) -> Result<RunnerConfig<Self>, Self::Error> {
|
||||
let result = self.call_event(Event::GetScriptConfig(d.code));
|
||||
let result = self.call_event(EventType::GetScriptConfig(d.code));
|
||||
let value = result.as_config().unwrap();
|
||||
Ok(value)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user