Closed Bug 945788 Opened 11 years ago Closed 11 years ago

Can't declare a cached sequence of dictionaries in JS-implemented WebIDL

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla28

People

(Reporter: reuben, Assigned: bzbarsky)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Trying to declare a cached attribute that is a sequence of dictionaries yields the following error:

 0:04.92 Traceback (most recent call last):
 0:04.92   File "/Users/Reuben/Development/b2g-inbound/config/pythonpath.py", line 56, in <module>
 0:04.92     main(sys.argv[1:])
 0:04.92   File "/Users/Reuben/Development/b2g-inbound/config/pythonpath.py", line 48, in main
 0:04.92     execfile(script, frozenglobals)
 0:04.92   File "/Users/Reuben/Development/b2g-inbound/dom/bindings/BindingGen.py", line 98, in <module>
 0:04.92     main()
 0:04.92   File "/Users/Reuben/Development/b2g-inbound/dom/bindings/BindingGen.py", line 95, in main
 0:04.92     generatedEventsWebIDLFiles);
 0:04.92   File "/Users/Reuben/Development/b2g-inbound/dom/bindings/BindingGen.py", line 22, in generate_binding_files
 0:04.92     root = CGBindingRoot(config, outputprefix, webidlfile)
 0:04.92   File "/Users/Reuben/Development/b2g-inbound/dom/bindings/Codegen.py", line 9500, in __init__
 0:04.92     cgthings.append(CGCallbackInterface(x))
 0:04.92   File "/Users/Reuben/Development/b2g-inbound/dom/bindings/Codegen.py", line 10610, in __init__
 0:04.92     getters = [CallbackGetter(a, descriptor) for a in attrs]
 0:04.92   File "/Users/Reuben/Development/b2g-inbound/dom/bindings/Codegen.py", line 10974, in __init__
 0:04.93     rethrowContentException=descriptor.interface.isJSImplemented())
 0:04.93   File "/Users/Reuben/Development/b2g-inbound/dom/bindings/Codegen.py", line 10676, in __init__
 0:04.93     jsObjectsArePtr=True)
 0:04.93   File "/Users/Reuben/Development/b2g-inbound/dom/bindings/Codegen.py", line 9578, in __init__
 0:04.93     self.getArgs(signature[0], signature[1]),
 0:04.93   File "/Users/Reuben/Development/b2g-inbound/dom/bindings/Codegen.py", line 10822, in getArgs
 0:04.93     args = CGNativeMember.getArgs(self, returnType, argList)
 0:04.93   File "/Users/Reuben/Development/b2g-inbound/dom/bindings/Codegen.py", line 9717, in getArgs
 0:04.93     elementDecl = self.getReturnType(returnType.inner, True)
 0:04.93   File "/Users/Reuben/Development/b2g-inbound/dom/bindings/Codegen.py", line 9589, in getReturnType
 0:04.93     return self.getRetvalInfo(type, isMember)[0]
 0:04.93   File "/Users/Reuben/Development/b2g-inbound/dom/bindings/Codegen.py", line 9703, in getRetvalInfo
 0:04.94     type)
 0:04.94 TypeError: Don't know how to declare return value for ContactFieldInit (Wrapper)
This is example/jsimpl codegen fail.  Will fix.
Assignee: nobody → bzbarsky
Summary: Can't declare a cached sequence of dictionaries → Can't declare a cached sequence of dictionaries in JS-implemented WebIDL
In fact, this is bug 863949, I guess, but let's just do it here.
Attached file Example generated code
This shows the code generated for these two pieces of JS-implemented WebIDL:

  [Cached, Pure]
  readonly attribute sequence<Dict> readonlySequenceOfDictionaries;

  Dict receiveDictionary();

The static methods are the same as for normal bindings, I believe.  This patch's shenanigans affect the TestJSImplInterfaceJSImpl member methods.
Blocks: 946294
Comment on attachment 8341825 [details] [diff] [review]
Add support for dictionary return values to example codegen and js-implemented codegen.


>+++ b/dom/bindings/parser/WebIDL.py
>@@ -2027,17 +2027,17 @@ class IDLWrapperType(IDLType):
>     def isSerializable(self):
>         if self.isInterface():
>             if self.inner.isExternal():
>                 return False
>             return any(m.isMethod() and m.isJsonifier() for m in self.inner.members)
>         elif self.isEnum():
>             return True
>         elif self.isDictionary():
>-            return all(m.isSerializable() for m in self.inner.members)
>+            return all(m.type.isSerializable() for m in self.inner.members)
I don't see how this is related to the bug.


Do we have tests for jsonification?
> I don't see how this is related to the bug.

Without it, this patch fails codegen; see below.  ;)

> Do we have tests for jsonification?

Yes.  TestInterface has a stringifier.  But dictionary-typed attributes are not allowed in WebIDL, so this incorrect code was actually never reached.  When I added the "readonly attribute sequence<Dict>" member in the tests in this patch, we started calling this code to determine whether that attribute is of a serializable type, and then the fact that "m" there is an IDLArgument, which doesn't have an isSerializable method manifested itself in a lovely exception.
Attachment #8341825 - Flags: review?(bugs) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/a439f81ded5c
Flags: in-testsuite+
Target Milestone: --- → mozilla28
https://hg.mozilla.org/mozilla-central/rev/a439f81ded5c
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: