SetPrototype and Set can fail, so they return optionals. FromJust asserts 
that the optional is not empty (and crashes the program if it is empty).

On Monday, December 19, 2016 at 10:18:31 AM UTC-8, kent williams wrote:
>
> That example has some weird:
> Line 11341:
>
> This->SetPrototype(context, proto).FromJust();
>
> What is the FromJust() for? Does that method have side effects? 
> Same deal at 11347:
> This->Set(context, v8_str("a"), args[0]).FromJust(); 
>
>
>>
>> https://cs.chromium.org/chromium/src/v8/test/cctest/test-api.cc?q=test-api.cc&sq=package:chromium&dr&l=11365
>>
>> Cheers,
>>
>> Yang
>>
>>
>>
>>
>> On Wednesday, December 14, 2016 at 11:53:31 PM UTC+1, kent williams wrote:
>>>
>>> Call me silly but I've spent this afternoon looking at v8/samples and 
>>> the various web pages/blog entries (and the embedder's guide) and not 
>>> getting a clear picture of how to create a new object type with methods and 
>>> a constructor in v8.
>>>
>>> Is there a good example out there?
>>>
>>> In my particular case, I have this implemented using SpiderMonkey, which 
>>> seems a lot more straightforward.  It has the JS_InitClass call where you 
>>> pass in a constructor, a destructor, and an array of method descriptors.
>>>
>>> In v8, it seems spread out and confusing.  There's this: 
>>> https://gist.github.com/mythagel/4527961 but end up sidetracked by 
>>> decoding all the C++11 junk.
>>>
>>> If that's it, I'll just buckle down and figure it out. But if someone 
>>> can point me at something to start from, I'd be much obliged!
>>>
>>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to