src: deprecate embedder APIs with replacements

Implement a number of TODO comments aiming at the eventual removal of
some embedder APIs that now have replacements available.

PR-URL: https://github.com/nodejs/node/pull/32858
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
This commit is contained in:
Anna Henningsen 2020-04-15 01:54:43 +02:00
parent d01a06a916
commit a6c57cc66d
No known key found for this signature in database
GPG Key ID: A94130F0BFC8EBE9

View File

@ -227,15 +227,14 @@ NODE_EXTERN int Start(int argc, char* argv[]);
// in the loop and / or actively executing JavaScript code). // in the loop and / or actively executing JavaScript code).
NODE_EXTERN int Stop(Environment* env); NODE_EXTERN int Stop(Environment* env);
// TODO(addaleax): Officially deprecate this and replace it with something
// better suited for a public embedder API.
// It is recommended to use InitializeNodeWithArgs() instead as an embedder. // It is recommended to use InitializeNodeWithArgs() instead as an embedder.
// Init() calls InitializeNodeWithArgs() and exits the process with the exit // Init() calls InitializeNodeWithArgs() and exits the process with the exit
// code returned from it. // code returned from it.
NODE_EXTERN void Init(int* argc, NODE_DEPRECATED("Use InitializeNodeWithArgs() instead",
const char** argv, NODE_EXTERN void Init(int* argc,
int* exec_argc, const char** argv,
const char*** exec_argv); int* exec_argc,
const char*** exec_argv));
// Set up per-process state needed to run Node.js. This will consume arguments // Set up per-process state needed to run Node.js. This will consume arguments
// from argv, fill exec_argv, and possibly add errors resulting from parsing // from argv, fill exec_argv, and possibly add errors resulting from parsing
// the arguments to `errors`. The return value is a suggested exit code for the // the arguments to `errors`. The return value is a suggested exit code for the
@ -428,12 +427,13 @@ struct InspectorParentHandle {
// Returns nullptr when the Environment cannot be created e.g. there are // Returns nullptr when the Environment cannot be created e.g. there are
// pending JavaScript exceptions. // pending JavaScript exceptions.
// It is recommended to use the second variant taking a flags argument. // It is recommended to use the second variant taking a flags argument.
NODE_EXTERN Environment* CreateEnvironment(IsolateData* isolate_data, NODE_DEPRECATED("Use overload taking a flags argument",
v8::Local<v8::Context> context, NODE_EXTERN Environment* CreateEnvironment(IsolateData* isolate_data,
int argc, v8::Local<v8::Context> context,
const char* const* argv, int argc,
int exec_argc, const char* const* argv,
const char* const* exec_argv); int exec_argc,
const char* const* exec_argv));
NODE_EXTERN Environment* CreateEnvironment( NODE_EXTERN Environment* CreateEnvironment(
IsolateData* isolate_data, IsolateData* isolate_data,
v8::Local<v8::Context> context, v8::Local<v8::Context> context,
@ -463,8 +463,8 @@ struct StartExecutionCallbackInfo {
using StartExecutionCallback = using StartExecutionCallback =
std::function<v8::MaybeLocal<v8::Value>(const StartExecutionCallbackInfo&)>; std::function<v8::MaybeLocal<v8::Value>(const StartExecutionCallbackInfo&)>;
// TODO(addaleax): Deprecate this in favour of the MaybeLocal<> overload. NODE_DEPRECATED("Use variants returning MaybeLocal<> instead",
NODE_EXTERN void LoadEnvironment(Environment* env); NODE_EXTERN void LoadEnvironment(Environment* env));
// The `InspectorParentHandle` arguments here are ignored and not used. // The `InspectorParentHandle` arguments here are ignored and not used.
// For passing `InspectorParentHandle`, use `CreateEnvironment()`. // For passing `InspectorParentHandle`, use `CreateEnvironment()`.
NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment( NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
@ -495,18 +495,18 @@ NODE_EXTERN Environment* GetCurrentEnvironment(v8::Local<v8::Context> context);
// This returns the MultiIsolatePlatform used in the main thread of Node.js. // This returns the MultiIsolatePlatform used in the main thread of Node.js.
// If NODE_USE_V8_PLATFORM has not been defined when Node.js was built, // If NODE_USE_V8_PLATFORM has not been defined when Node.js was built,
// it returns nullptr. // it returns nullptr.
// TODO(addaleax): Deprecate in favour of GetMultiIsolatePlatform(). NODE_DEPRECATED("Use GetMultiIsolatePlatform(env) instead",
NODE_EXTERN MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform(); NODE_EXTERN MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform());
// This returns the MultiIsolatePlatform used for an Environment or IsolateData // This returns the MultiIsolatePlatform used for an Environment or IsolateData
// instance, if one exists. // instance, if one exists.
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env); NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env);
NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env); NODE_EXTERN MultiIsolatePlatform* GetMultiIsolatePlatform(IsolateData* env);
// Legacy variants of MultiIsolatePlatform::Create(). // Legacy variants of MultiIsolatePlatform::Create().
// TODO(addaleax): Deprecate in favour of the v8::TracingController variant. NODE_DEPRECATED("Use variant taking a v8::TracingController* pointer instead",
NODE_EXTERN MultiIsolatePlatform* CreatePlatform( NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
int thread_pool_size, int thread_pool_size,
node::tracing::TracingController* tracing_controller); node::tracing::TracingController* tracing_controller));
NODE_EXTERN MultiIsolatePlatform* CreatePlatform( NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
int thread_pool_size, int thread_pool_size,
v8::TracingController* tracing_controller); v8::TracingController* tracing_controller);