On 4/21/2014 9:34 PM, Boris Zbarsky wrote:
On 4/21/14, 7:31 PM, Joshua Cranmer 🐧 wrote:
Now, creating a Promise (via mozilla::dom::Promise) from C++ and passing
it to JS is possible but kind of difficult, since I need to materialize
an nsIGlobalObject which requires too much code.
You basically need the window the promise will be associated with. Is
the problem that finding the right window in your case is too
complicated?
I'm referring to using a Promise, essentially, in backend code of
Thunderbird. There is no "window"
It's not really
possible to cast to this method from a JS implemented Promise (since the
notion of "promise" in JS is "I have a callable property named then").
No, the notion of "promise" in JS is/will-be
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects
Maybe if I clarified that I meant that "object x is a promise if...".
Promises, AFAICT from observing at a great distance the ES6 discussions,
are not tied to specific JS or DOM objects but rather the existence of a
single method, specifically to allow compatibility with legacy Promise
implementations (e.g., Promises.jsm).
It's also the only way you can react to a promise from C++ without
stabbing yourself.
I'm not following this.
In order to react to a promise, you need to wrap a C++ function into a
JS callable function. I consider manual JSAPI calls pretty hairy
already, and having to work out
Since I need C++ to be able to react to
JS-implemented stuff, this kind of means I have to use XPIDL instead of
WebIDL.
I'm not following the reasoning, but chances are it's wrong. Unless
you need your thing to be gettable from C++ via
createInstace/getService, you shouldn't need XPIDL.
That is exactly what my need.
If there is a real problem here apart from that one, please explain
what it is: getting rid of such problems is high on my priority list.
Can promises be specified in XPIDL in such a way that they are usable
from C++?
No, for lots of reasons. Please don't try to use XPIDL here.
I don't have any other choice.
I've thought about ways to fix this, but they all require modifying
xpconnect to some degree, so I wondered if anyone had better solutions
to this problem space.
I'd like to better understand what your issues are with the current
Promise implementation...
Hopefully the fact that I need to go through XPIDL is sufficient
explanation.
--
Joshua Cranmer
Thunderbird and DXR developer
Source code archæologist
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform