On Thu, Apr 19, 2018 at 12:58:33PM -0700, Andrew McCreight wrote:
On Thu, Apr 19, 2018 at 12:53 PM, Gijs Kruitbosch <gijskruitbo...@gmail.com>
wrote:
If I understand correctly, with these changes I could now just use Promise
instead. Is that correct? Can I declare it including the resolution result
of the promise, ie can I now use:
Promise<unsigned long> asyncGetFoo()
in xpidl? Because that would make my life considerably easier...
Bug 1455217 by Nika is going to add a Promise type to XPIDL. So I think
you have to wait for that.
This actually isn't as difficult currently as you may expect. At
least, the difference between XPIDL and WebIDL isn't. From the
C++ consumer, you'd just have to do:
RefPtr<Promise> result(Promise::Resolve(global, cx, resultVal, rv));
Which is more or less what the WebIDL layer does.
The real problem is that you're going to have to do the coercion
on the resolution value yourself. That problem is the same
whether you're implementing it in WebIDL or XPIDL.
If you're just dealing with an integer value, that's pretty
easy. Something like `result.toInt32()` should do the job.
If it's something more complicated, well, it's more complicated.
But WebIDL dictionary types are probably by far the easiest way
to handle it.
So, basically what I'm saying is that a callback interface is
still probably the easiest way to handle this from the C++ side,
but a Promise should work, and shouldn't be that much harder in
XPIDL than it is in WebIDL.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform