From 7c3b9b4f4f2f4ec8fdeb0e77bb853fd22ffaa476 Mon Sep 17 00:00:00 2001 From: Andy Finch Date: Thu, 5 Dec 2019 15:30:20 -0500 Subject: feat: first pass at native plugins (#3372) --- core/plugins.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 core/plugins.rs (limited to 'core/plugins.rs') diff --git a/core/plugins.rs b/core/plugins.rs new file mode 100644 index 000000000..50271d53a --- /dev/null +++ b/core/plugins.rs @@ -0,0 +1,22 @@ +use crate::libdeno::PinnedBuf; +use crate::ops::CoreOp; + +pub type PluginInitFn = fn(context: &mut dyn PluginInitContext); + +pub trait PluginInitContext { + fn register_op( + &mut self, + name: &str, + op: Box) -> CoreOp + Send + Sync + 'static>, + ); +} + +#[macro_export] +macro_rules! init_fn { + ($fn:path) => { + #[no_mangle] + pub fn deno_plugin_init(context: &mut dyn PluginInitContext) { + $fn(context) + } + }; +} -- cgit v1.2.3