Add #[heapsize]/#[derive(HeapSizeOf)] plugin to auto-derive HeapSizeOf impls

(fixes #5914)
This commit is contained in:
Manish Goregaokar 2015-03-31 08:32:11 +05:30
parent 05212b702d
commit f4bc92526a
3 changed files with 87 additions and 2 deletions

View file

@ -8,8 +8,7 @@
//!
//! - `#[privatize]` : Forces all fields in a struct/enum to be private
//! - `#[jstraceable]` : Auto-derives an implementation of `JSTraceable` for a struct in the script crate
//! - `#[must_root]` : Prevents data of the marked type from being used on the stack. See the lints module for more
//! details
//! - `#[must_root]` : Prevents data of the marked type from being used on the stack. See the lints module for more details
//! - `#[dom_struct]` : Implies `#[privatize]`,`#[jstraceable]`, and `#[must_root]`.
//! Use this for structs that correspond to a DOM type
@ -31,6 +30,8 @@ use syntax::parse::token::intern;
// Public for documentation to show up
/// Handles the auto-deriving for `#[jstraceable]`
pub mod jstraceable;
/// Handles the auto-deriving for `#[heapsize]`
pub mod heapsize;
/// Autogenerates implementations of Reflectable on DOM structs
pub mod reflector;
pub mod lints;
@ -43,6 +44,8 @@ pub fn plugin_registrar(reg: &mut Registry) {
reg.register_syntax_extension(intern("dom_struct"), MultiModifier(box jstraceable::expand_dom_struct));
reg.register_syntax_extension(intern("jstraceable"), MultiDecorator(box jstraceable::expand_jstraceable));
reg.register_syntax_extension(intern("_generate_reflector"), MultiDecorator(box reflector::expand_reflector));
reg.register_syntax_extension(intern("derive_HeapSizeOf"), MultiDecorator(box heapsize::expand_heapsize));
reg.register_syntax_extension(intern("heapsize"), MultiDecorator(box heapsize::expand_heapsize));
reg.register_macro("to_lower", casing::expand_lower);
reg.register_macro("to_upper", casing::expand_upper);
reg.register_lint_pass(box lints::transmute_type::TransmutePass as LintPassObject);