Re: Using promises from C++

2014-04-22 Thread Boris Zbarsky
On 4/22/14, 2:51 AM, Joshua Cranmer 🐧 wrote: I'm giving to thinking in terms of all of the magic hiding that XPIDL/XPCOM/xpconnect does, so things like "what is my global object" being intrinsically important are annoying to me. I understand that. but something like Promises or TextEncoder wh

Re: Using promises from C++

2014-04-22 Thread Joshua Cranmer 🐧
On 4/22/2014 5:55 AM, Gijs Kruitbosch wrote: On 22/04/2014 05:24, Joshua Cranmer 🐧 wrote: For more specific explanation then: I have a (non-negotiably) JS-implemented XPCOM service called the Folder Lookup Service. I want to add an API to it called getOrCreateFolder that returns a Promise. I hav

Re: Using promises from C++

2014-04-22 Thread Gijs Kruitbosch
On 22/04/2014 05:24, Joshua Cranmer 🐧 wrote: For more specific explanation then: I have a (non-negotiably) JS-implemented XPCOM service called the Folder Lookup Service. I want to add an API to it called getOrCreateFolder that returns a Promise. I have non-negotiable C++ code that wants to call t

Re: Using promises from C++

2014-04-21 Thread Joshua Cranmer 🐧
On 4/22/2014 12:46 AM, Boris Zbarsky wrote: On 4/22/14, 12:24 AM, Joshua Cranmer 🐧 wrote: I consider Promise more like a generic platform feature (considering that the specification is moving to ES6 instead of DOM) ES assumes you always have a global. In fact, until ES6 it assumed that there

Re: Using promises from C++

2014-04-21 Thread Boris Zbarsky
On 4/22/14, 12:24 AM, Joshua Cranmer 🐧 wrote: I managed to, in one of my playground techniques, create a global using a backstage pass and some xpconnect APIs, so it's not impossible but it is damn annoying. Right. If you don't have a global to start with, your life will _really_ suck if you

Re: Using promises from C++

2014-04-21 Thread Joshua Cranmer 🐧
On 4/21/2014 10:52 PM, Boris Zbarsky wrote: On 4/21/14, 11:35 PM, Joshua Cranmer 🐧 wrote: I'm referring to using a Promise, essentially, in backend code of Thunderbird. There is no "window" I mean Window in the "DOM Window" sense. Promises can be created using some other global (which one is

Re: Using promises from C++

2014-04-21 Thread Boris Zbarsky
On 4/21/14, 11:35 PM, Joshua Cranmer 🐧 wrote: I'm referring to using a Promise, essentially, in backend code of Thunderbird. There is no "window" I mean Window in the "DOM Window" sense. Promises can be created using some other global (which one is up to the person creating it), but typically

Re: Using promises from C++

2014-04-21 Thread Joshua Cranmer 🐧
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 basicall

Re: Using promises from C++

2014-04-21 Thread Boris Zbarsky
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 associ