Closed Bug 768537 Opened 7 years ago Closed 7 years ago

Update dictionary support to recent changes

Categories

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

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: Ms2ger, Assigned: bzbarsky)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 2 obsolete files)

1)  Enforce the requirement that dictionary arguments not followed by a required argument are optional.
2)  Make dictionaries no longer be distinguishable from nullable types.
3)  Disallow dictionaries or unions containing dictionaries inside a nullable type.
4)  Force optional dictionaries to have a default value of null so that codegen doesn't have to worry about dealing with
    optional arguments that have no default value in the IDL but need to be treated as if they were null.
Attachment #636825 - Flags: review?(justin.lebar+bug)
Whiteboard: [need review]
A test for a dictionary argument followed by a required argument?
Comment on attachment 636826 [details] [diff] [review]
part 2.  Allow dictionaries to be initialized with null or undefined, and treat them as dictionaries in which everything has its default value.

Review of attachment 636826 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/bindings/Codegen.py
@@ +4133,5 @@
>  
>          return (string.Template(
>                  "struct ${selfName} ${inheritance}{\n"
>                  "  ${selfName}() {}\n"
> +                "  bool Init(JSContext* cx, JS::Value val);\n"

const JS::Value&?
Attachment #636825 - Attachment is obsolete: true
Attachment #636825 - Flags: review?(justin.lebar+bug)
Attachment #636826 - Attachment is obsolete: true
Attachment #636826 - Flags: review?(peterv)
>+        if self.type.isDictionary() and self.optional and not self.defaultValue:
>+            # Default optional dictionaries to null, for simplicity
>+            self.defaultValue = IDLNullValue(self.location)

Nit: Could you say "so the codegen doesn't have to"?  Otherwise it's not clear whether this is a correctness-affecting simplification.

I'm sorry for taking so long to get to this and the other patches; the Barcelona work week was kind of nuts.
Attachment #636828 - Flags: review?(justin.lebar+bug) → review+
> Nit: Could you say "so the codegen doesn't have to"?

Will do.

No problem on the lag; I was gone most of that time myself.  ;)
Comment on attachment 636829 [details] [diff] [review]
Part 2 with Value ref (probably better with moving GC).

Review of attachment 636829 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/bindings/Codegen.py
@@ +4207,5 @@
>                  "selfName": self.makeClassName(d),
>                  "initParent": CGIndenter(CGGeneric(initParent)).define(),
>                  "initMembers": "\n\n".join(memberInits),
> +                "idInit": CGIndenter(idinit).define(),
> +                "isWorker": toStringBool(self.workers)

|not self.workers|? See also bug 773326, I wonder if we should change something to make it harder to get this wrong.
Attachment #636829 - Flags: review?(peterv) → review+
> |not self.workers|?

Er, yes.  <sigh>

> I wonder if we should change something to make it harder to get this wrong

Make it an enum instead of a bool?  :(

Or fix things so we have only one exception mechanism.  ;)
Sorry, push backed out for compilation errors on all platforms:
https://tbpl.mozilla.org/?tree=Mozilla-Inbound&rev=9deb8edb5070

eg: https://tbpl.mozilla.org/php/getParsedLog.php?id=13605808&tree=Mozilla-Inbound
{
In file included from ../../../../js/xpconnect/wrappers/XrayWrapper.cpp:22:0:
../../../dist/include/nsTSubstring.h:639:18: error: 'nsAString_internal::char_type* nsAString_internal::mData' is protected
../../../dist/include/mozilla/dom/BindingUtils.h:794:77: error: within this context
../../../dist/include/nsTSubstring.h:640:17: error: 'nsAString_internal::size_type nsAString_internal::mLength' is protected
../../../dist/include/mozilla/dom/BindingUtils.h:795:79: error: within this context
../../../dist/include/nsTSubstring.h:641:16: error: 'PRUint32 nsAString_internal::mFlags' is protected
../../../dist/include/mozilla/dom/BindingUtils.h:796:78: error: within this context
make[6]: *** [XrayWrapper.o] Error 1
}

https://hg.mozilla.org/integration/mozilla-inbound/rev/8212be806c67
Target Milestone: mozilla17 → ---
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.