artichoke_backend/extn/stdlib/delegate/
mod.rs1use std::ffi::CStr;
2
3use crate::extn::prelude::*;
4
5const DELEGATOR_CSTR: &CStr = c"Delegator";
6const SIMPLE_DELEGATOR_CSTR: &CStr = c"SimpleDelegator";
7static DELEGATE_RUBY_SOURCE: &[u8] = include_bytes!("vendor/delegate.rb");
8
9pub fn init(interp: &mut Artichoke) -> InitializeResult<()> {
10 let spec = class::Spec::new("Delegator", DELEGATOR_CSTR, None, None)?;
11 interp.def_class::<Delegator>(spec)?;
12 let spec = class::Spec::new("SimpleDelegator", SIMPLE_DELEGATOR_CSTR, None, None)?;
13 interp.def_class::<SimpleDelegator>(spec)?;
14 interp.def_rb_source_file("delegate.rb", DELEGATE_RUBY_SOURCE)?;
15
16 Ok(())
17}
18
19#[derive(Debug, Clone, Copy)]
20pub struct Delegator;
21
22#[derive(Debug, Clone, Copy)]
23pub struct SimpleDelegator;