Methods with sequence<DOMString> arguments generate invalid code in callback interfaces

RESOLVED FIXED in mozilla22

Status

()

defect
RESOLVED FIXED
7 years ago
4 months ago

People

(Reporter: mccr8, Assigned: bzbarsky)

Tracking

(Blocks 1 bug)

unspecified
mozilla22
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

callback interface Foo {
  void passStringSequence(sequence<DOMString> arg);
};

The code produced by this does not compile:

/Users/amccreight/mz/cent/obj-dbg/dom/bindings/JSImplBinding.cpp:49:16: error: no matching function for call to 'NonVoidStringToJsval'
          if (!xpc::NonVoidStringToJsval(cx, arg[i], &tmp)) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/amccreight/mz/cent/js/xpconnect/src/xpcpublic.h:283:6: note: candidate function not viable: no known conversion from 'const elem_type' (aka 'const nsString') to 'nsAString_internal &' for 2nd argument; 
bool NonVoidStringToJsval(JSContext *cx, nsAString &str, JS::Value *rval);
     ^
/Users/amccreight/mz/cent/js/xpconnect/src/xpcpublic.h:298:6: note: candidate function not viable: no known conversion from 'const elem_type' (aka 'const nsString') to 'mozilla::dom::DOMString &' for 2nd argument; 
bool NonVoidStringToJsval(JSContext* cx, mozilla::dom::DOMString& str,
     ^
1 error generated.


On the other hand, the output from this method does compile:
  void passCastableObjectSequence(sequence<Foo> arg);
From CallbackMember.getArgConversion:

        if arg.type.isString():
            # XPConnect string-to-JS conversion wants to mutate the string.  So
            # let's give it a string it can mutate
            # XXXbz if we try to do a sequence of strings, this will kinda fail.
So one interesting option is to just add non-mutating version of NonVoidStringToJsval and whatnot that take a const string and make sure to deal accordingly...
of non-const strings, but I think that's OK now that we're mostly
autogenerating this stuff
Attachment #718855 - Flags: review?(peterv)
Assignee: nobody → bzbarsky
Whiteboard: [need review]
Attachment #718855 - Flags: review?(peterv) → review+
Pushed https://hg.mozilla.org/integration/mozilla-inbound/rev/1d8af801d850
Flags: in-testsuite+
Whiteboard: [need review]
Target Milestone: --- → mozilla22
Unfortunately, I had to backout because something in this push caused a spike in mochitest-a11y assertions.
https://hg.mozilla.org/integration/mozilla-inbound/rev/fb572a342efa

https://tbpl.mozilla.org/php/getParsedLog.php?id=20189591&tree=Mozilla-Inbound

A quick skim of the log shows them to be of the type:
###!!! ASSERTION: bad size recorded: 'aInstanceSize == 0 || entry->GetClassSize() == aInstanceSize', file ../../../xpcom/base/nsTraceRefcntImpl.cpp, line 441
https://hg.mozilla.org/mozilla-central/rev/38578014b8a8
Status: NEW → RESOLVED
Closed: 7 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.