Why does Boolean :: New () return Handle <> while other primitives return Local <>?

These are the functions for creating new primitives in the V8 C ++ API:

Handle<Boolean> v8::Boolean::New(bool value)
Local<Number> v8::Number::New(double value)
Local<String> v8::String::New(const char *data, int length=-1)

I wonder why it Booleanreturns Handle, and the rest return Local.

My assumption is that it is associated with booleans, which have only two possible meanings, but, unfortunately, the documents are really poor and do not mention such things.

+5
source share
1 answer

This is the implementation of Boolean :: New: ( v8.h )

Handle<Boolean> Boolean::New(bool value) {
  return value ? True() : False();
}

And here is what we can get from api.cc:

v8::Handle<Boolean> True() {
  i::Isolate* isolate = i::Isolate::Current();
  if (!EnsureInitializedForIsolate(isolate, "v8::True()")) {
    return v8::Handle<Boolean>();
  }
  return v8::Handle<Boolean>(
      ToApi<Boolean>(isolate->factory()->true_value()));
}

, . AFAIK - - , Java , ( JVM, ve , ..).

+5

All Articles