Hi Guys,

We're creating a new dom interface for Image Requests.  We're looking to add a 
new webidl file for imagerequest.rs (A file we just created) and we've been 
following these steps:

    http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface

And have implemented them all. However we're having issues with using custom 
types, such as ImageData in it. 
There seems to be other examples of using custom types in webidl files, we just 
can't find where we need to add the type to make it accessible.

So we have this in our .webidl file:

    
``` 
        interface ImageRequest {
          readonly attribute ImageState state;
          readonly attribute URL currentUrl;
          readonly attribute ImageData imageData;
        };
    ```

And our .rs file struct definition looks like this:

    
```        #[dom_struct]
        pub struct ImageRequest {
          reflector_: Reflector,
          state : ImageState,
          currentUrl : URL,
          imageData : ImageData,
        }
    ```

Our trait implmentation is this:

    
``` 
        impl ImageRequestMethods for ImageRequest {
           fn State(&self) -> ImageState {
               self.state
           }

           fn CurrentUrl(&self) -> URL {
               self.currentUrl
           }

           fn ImageData(&self) -> ImageData {
               self.imageData
           }
        }
    ```

And an example of the error we are getting is this:

error: method `ImageData` has an incompatible type for trait:
expected struct `dom::bindings::js::Root`,
   found struct `dom::imagedata::ImageData` [E0053]

We get similar errors for ImageState and URL.

So basically, we're a little unsure how to make the types accessible in the 
webidl files and why the trait is expecting a 'dom::bindings::js::Root' struct 
rather than the one we define. Our internal pull request for this task (to our 
own fork) is here:

    https://github.com/paterson/servo/pull/13/files

Previously, it seems like the Bindings.conf file was used for stuff related to 
this. For example here is a previous version of it with custom types defined:

    
https://github.com/servo/servo/blob/22e02b573d546f9e0eea3318e2691d3144735fc5/src/components/script/dom/bindings/codegen/Bindings.conf

But that file is now quite different:

    
https://github.com/servo/servo/blob/master/components/script/dom/bindings/codegen/Bindings.conf

So we're guessing this has changed and is implemented. Any ideas/tips would be 
really appreciated!
_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo

Reply via email to