Commit graph

5 commits

Author SHA1 Message Date
Bastien Orivel
e94de4e1bd Update syn and related dependencies 2018-11-30 17:48:41 +01:00
Manish Goregaokar
ad198993b1 Assert that DOM structs have the correct first field
DOM structs embed their parent type as their first field. This
introduces a `.parent()` method to the DOM struct that returns its first
field, and codegens a type assert that ensures that `.parent()` returns
the parent struct.

This generates:

On `#[dom_struct]`:

```rust
impl HasParent for Type {
    type Parent = ParentType;
    fn as_parent(&self) -> ParentType {
        &self.first_field
    }
}
```

In the codegen files:

```rust
impl Type {
    fn __assert_parent_type(&self) {
        let _: &ParentType = self.as_parent();
    }
}
````
2018-07-03 09:39:29 -07:00
Anthony Ramine
5dad4c826d Use the better TokenStream API in dom_struct
Before:

```
error[E0412]: cannot find type `SourceBuffer` in this scope
  --> /Users/nox/src/servo/components/script/dom/mediasource.rs:25:1
   |
25 | #[dom_struct]
   | ^^^^^^^^^^^^^ did you mean `SourceBufferList`?
```

After:

```
error[E0412]: cannot find type `SourceBuffer` in this scope
  --> /Users/nox/src/servo/components/script/dom/mediasource.rs:28:39
   |
28 |     source_buffers: DOMRefCell<Vec<JS<SourceBuffer>>>,
   |                                       ^^^^^^^^^^^^ did you mean `SourceBufferList`?
```
2017-09-01 12:15:12 +02:00
Anthony Ramine
12b9a42774 Fix quote dependency version 2017-08-23 18:35:42 +02:00
Anthony Ramine
31e9d81c0f Make #[dom_struct] a proc_macro attribute 2017-02-24 01:50:51 +01:00