n-api: directly create Local from Persistent

The `v8::PersistentBase<T>.Get` method didn't exist in node 4 and it's
just a helper which creates a new `v8::Local` from the given object.

PR-URL: https://github.com/nodejs/node/pull/14211
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
This commit is contained in:
Kyle Farnung 2017-07-12 17:14:00 -07:00 committed by Anna Henningsen
parent 8f0102564e
commit e59987c39e
No known key found for this signature in database
GPG Key ID: D8B9F5AEAE84E4CF

View File

@ -56,7 +56,8 @@ struct napi_env__ {
(destination)->SetInternalFieldCount((field_count)); \
(env)->prefix ## _template.Reset(isolate, (destination)); \
} else { \
(destination) = env->prefix ## _template.Get(isolate); \
(destination) = v8::Local<v8::ObjectTemplate>::New( \
isolate, env->prefix ## _template); \
} \
} while (0)