rubyjs / therubyracer

Embed the V8 Javascript Interpreter into Ruby
1.66k stars 191 forks source link

Maybe APIs #364

Closed cowboyd closed 9 years ago

cowboyd commented 9 years ago

Add support for V8 methods that return Maybe<T> and MaybeLocal<T>, by performing the check and then generating an appropriate wrapper.

In order to support porting V8::C::Object#Get() and V8::C::Object#Set() over to the Maybe API, I've added two conversion helper classes, Bool::Maybe and Value::Maybe for converting Maybe<bool> and MaybeLocal<v8::Value> respectively. We can add more conversion classes as the need arises.

Of course, It makes the low-level C API just that much more ugly, but they're deprecating the other apis, so it is what it is.

This feels a lot cleaner than the pure C solution in https://github.com/cowboyd/therubyracer/pull/358, so I'll shut that down.

cowboyd commented 9 years ago

Unless there are any objections, I'm going to merge this in a few hours since it's gating large portions of the API. /cc @stormbreakerbg

georgyangelov commented 9 years ago

:+1: I'm going to start implementing the Object API on top of this.

cowboyd commented 9 years ago

Fantastic!