diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-08-26 20:56:02 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-08-26 20:56:02 -0600 |
commit | 98728a6c751a8959459f80286833152e21fa6cfc (patch) | |
tree | 4a6ab91f56177684393df05269bd8a3d3202ed91 /components/script/dom | |
parent | 7a6d8a30d316fb65c2c846d3d6d0d5e33b29bc5c (diff) | |
parent | 4ee5b664c2c8fde5175a7e3bfe2f1b1d77f6c5e1 (diff) | |
download | servo-98728a6c751a8959459f80286833152e21fa6cfc.tar.gz servo-98728a6c751a8959459f80286833152e21fa6cfc.zip |
Auto merge of #7395 - Manishearth:doc-inherit, r=nox
Document InheritTypes
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7395)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 0fc71b86b71..060a0ebdf8c 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -5773,12 +5773,17 @@ class GlobalGenRoots(): CGGeneric("use std::mem;\n\n")] for descriptor in descriptors: name = descriptor.name - protos = [CGGeneric('pub trait %s : Sized {}\n' % (name + 'Base'))] + protos = [CGGeneric("""\ +/// Types which are derived from `%(name)s` and can be freely converted +/// to `%(name)s` +pub trait %(name)sBase : Sized {}\n""" % {'name': name})] for proto in descriptor.prototypeChain: protos += [CGGeneric('impl %s for %s {}\n' % (proto + 'Base', descriptor.concreteType))] - derived = [CGGeneric('pub trait %s : Sized { fn %s(&self) -> bool; }\n' % - (name + 'Derived', 'is_' + name.lower()))] + derived = [CGGeneric("""\ +/// Types which `%(name)s` derives from +pub trait %(name)sDerived : Sized { fn %(method)s(&self) -> bool; }\n""" % + {'name': name, 'method': 'is_' + name.lower()})] for protoName in descriptor.prototypeChain[1:-1]: protoDescriptor = config.getDescriptor(protoName) delegate = string.Template("""\ @@ -5800,6 +5805,8 @@ impl ${selfName} for ${baseName} { pub struct ${name}Cast; impl ${name}Cast { #[inline] + /// Downcast an instance of a base class of `${name}` to an instance of + /// `${name}`, if it internally is an instance of `${name}` pub fn to_ref<'a, T: ${toBound}+Reflectable>(base: &'a T) -> Option<&'a ${name}> { match base.${checkFn}() { true => Some(unsafe { mem::transmute(base) }), @@ -5827,6 +5834,7 @@ impl ${name}Cast { } #[inline] + /// Upcast an instance of a derived class of `${name}` to `${name}` pub fn from_ref<'a, T: ${fromBound}+Reflectable>(derived: &'a T) -> &'a ${name} { unsafe { mem::transmute(derived) } } |