Skip to content

Instantly share code, notes, and snippets.

@michaelwu
Created August 31, 2015 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelwu/115431c44b361fcc747d to your computer and use it in GitHub Desktop.
Save michaelwu/115431c44b361fcc747d to your computer and use it in GitHub Desktop.
Magic plugin output
// Before
#![feature(plugin)]
#![feature(associated_consts)]
#![feature(custom_attribute)]
#![feature(trace_macros)]
#![plugin(plugins)]
trace_macros!(true);
magic_dom_struct! {
pub struct Test {
foo: Base<i32>,
bar: Mut<i32>,
yyy: Layout<f32>,
zzz: f64,
}
}
// After
#![feature(no_std)]
#![no_std]
#![feature(plugin)]
#![feature(associated_consts)]
#![feature(custom_attribute)]
#![feature(trace_macros)]
#![plugin(plugins)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;
struct _Test_bar;
impl ::dom::bindings::magic::SlotIndex for _Test_bar {
const
IDX:
u8
=
<i32 as ::dom::bindings::magic::MagicDOMClass>::SLOT_COUNT;
}
struct _Test_yyy;
impl ::dom::bindings::magic::SlotIndex for _Test_yyy {
const
IDX:
u8
=
_Test_bar::IDX +
<i32 as ::dom::bindings::magic::MagicDOMClass>::SLOT_SIZE;
}
struct _Test_zzz;
impl ::dom::bindings::magic::SlotIndex for _Test_zzz {
const
IDX:
u8
=
_Test_yyy::IDX +
<f32 as ::dom::bindings::magic::MagicDOMClass>::SLOT_SIZE;
}
#[privatize]
#[jstraceable]
pub struct Test {
foo: i32,
bar: ::dom::bindings::magic::MutMagicField<'x, i32, _Test_bar>,
yyy: ::dom::bindings::magic::LayoutMagicField<'x, f32, _Test_yyy>,
zzz: ::dom::bindings::magic::ConstMagicField<'x, f64, _Test_zzz>,
}
impl ::dom::bindings::magic::SlotCount for Test {
const
SLOT_COUNT:
u8
=
_Test_zzz::IDX +
<f64 as ::dom::bindings::magic::MagicDOMClass>::SLOT_SIZE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment