summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/extensions.rs8
-rw-r--r--core/lib.rs1
-rw-r--r--core/runtime/ops.rs7
3 files changed, 14 insertions, 2 deletions
diff --git a/core/extensions.rs b/core/extensions.rs
index fa6d7851e..e76b4064b 100644
--- a/core/extensions.rs
+++ b/core/extensions.rs
@@ -65,6 +65,12 @@ pub type OpMiddlewareFn = dyn Fn(OpDecl) -> OpDecl;
pub type OpStateFn = dyn FnOnce(&mut OpState);
pub type OpEventLoopFn = dyn Fn(Rc<RefCell<OpState>>, &mut Context) -> bool;
+/// Trait implemented by all generated ops.
+pub trait Op {
+ const NAME: &'static str;
+ const DECL: OpDecl;
+}
+
pub struct OpDecl {
pub name: &'static str,
pub v8_fn_ptr: OpFnRef,
@@ -239,7 +245,7 @@ macro_rules! extension {
ext.ops(vec![
$(
$( #[ $m ] )*
- $( $op )::+ :: decl $( :: < $($op_param),* > )? ()
+ $( $op )::+ $( :: < $($op_param),* > )? :: decl ()
),+
]);
)?
diff --git a/core/lib.rs b/core/lib.rs
index 250d7dead..30a14f3e4 100644
--- a/core/lib.rs
+++ b/core/lib.rs
@@ -132,6 +132,7 @@ pub fn v8_version() -> &'static str {
pub mod _ops {
pub use super::error::throw_type_error;
pub use super::error_codes::get_error_code;
+ pub use super::extensions::Op;
pub use super::extensions::OpDecl;
pub use super::ops::to_op_result;
pub use super::ops::OpCtx;
diff --git a/core/runtime/ops.rs b/core/runtime/ops.rs
index 1c871cda0..9e37977c8 100644
--- a/core/runtime/ops.rs
+++ b/core/runtime/ops.rs
@@ -218,7 +218,8 @@ mod tests {
op_test_result_void_ok,
op_test_result_void_err,
op_test_result_primitive_ok,
- op_test_result_primitive_err
+ op_test_result_primitive_err,
+ op_test_generics<String>,
]
);
@@ -404,4 +405,8 @@ mod tests {
)?;
Ok(())
}
+
+ // We don't actually test this one -- we just want it to compile
+ #[op2(core, fast)]
+ pub fn op_test_generics<T: Clone>() {}
}