Skip to content

Commit 9b19d8b

Browse files
committed
src: remove unused getEnvOptionsInputType and getNamespaceOptionsInputType
1 parent 0d17c47 commit 9b19d8b

2 files changed

Lines changed: 0 additions & 190 deletions

File tree

src/node_options.cc

Lines changed: 0 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -318,83 +318,6 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors,
318318

319319
namespace options_parser {
320320

321-
// Helper function to convert option types to their string representation
322-
// and add them to a V8 Map
323-
static bool AddOptionTypeToObject(Isolate* isolate,
324-
Local<Context> context,
325-
Local<Object> object,
326-
const std::string& option_name,
327-
const OptionMappingDetails& option_details) {
328-
std::string type;
329-
switch (static_cast<int>(option_details.type)) {
330-
case 0: // No-op
331-
case 1: // V8 flags
332-
break; // V8 and NoOp flags are not supported
333-
334-
case 2:
335-
type = "boolean";
336-
break;
337-
case 3: // integer
338-
case 4: // unsigned integer
339-
case 6: // host port
340-
type = "number";
341-
break;
342-
case 5: // string
343-
type = "string";
344-
break;
345-
case 7: // string array
346-
type = "array";
347-
break;
348-
default:
349-
UNREACHABLE();
350-
}
351-
352-
if (type.empty()) {
353-
return true; // Skip this entry but continue processing
354-
}
355-
356-
Local<String> option_key;
357-
if (!String::NewFromUtf8(isolate,
358-
option_name.data(),
359-
v8::NewStringType::kNormal,
360-
option_name.size())
361-
.ToLocal(&option_key)) {
362-
return true; // Skip this entry but continue processing
363-
}
364-
365-
Local<String> type_value;
366-
if (!String::NewFromUtf8(
367-
isolate, type.data(), v8::NewStringType::kNormal, type.size())
368-
.ToLocal(&type_value)) {
369-
return true; // Skip this entry but continue processing
370-
}
371-
372-
Local<String> help_text;
373-
if (!String::NewFromUtf8(isolate,
374-
option_details.help_text.data(),
375-
v8::NewStringType::kNormal,
376-
option_details.help_text.size())
377-
.ToLocal(&help_text)) {
378-
return true; // Skip this entry but continue processing
379-
}
380-
381-
// Create an object with type and help_text properties
382-
Local<Value> null_value = Null(isolate);
383-
constexpr size_t kOptionInfoLength = 2;
384-
std::array<Local<Name>, kOptionInfoLength> names = {
385-
String::NewFromUtf8Literal(isolate, "type"),
386-
String::NewFromUtf8Literal(isolate, "description")};
387-
std::array<Local<Value>, kOptionInfoLength> values = {type_value, help_text};
388-
Local<Object> option_info = Object::New(
389-
isolate, null_value, names.data(), values.data(), kOptionInfoLength);
390-
391-
if (object->Set(context, option_key, option_info).IsNothing()) {
392-
return false; // Error occurred, stop processing
393-
}
394-
395-
return true;
396-
}
397-
398321
class DebugOptionsParser : public OptionsParser<DebugOptions> {
399322
public:
400323
DebugOptionsParser();
@@ -2085,109 +2008,6 @@ void GetEmbedderOptions(const FunctionCallbackInfo<Value>& args) {
20852008
args.GetReturnValue().Set(ret);
20862009
}
20872010

2088-
// This function returns an object containing all the options available
2089-
// as NODE_OPTIONS and their metadata (input type and help text)
2090-
// Example --experimental-transform metadata:
2091-
// { type: kBoolean, help_text: "..." }
2092-
// This is used to determine the type of the input for each option
2093-
// to generate the config file json schema
2094-
void GetEnvOptionsInputType(const FunctionCallbackInfo<Value>& args) {
2095-
Isolate* isolate = args.GetIsolate();
2096-
Local<Context> context = isolate->GetCurrentContext();
2097-
Environment* env = Environment::GetCurrent(context);
2098-
2099-
if (!env->has_run_bootstrapping_code()) {
2100-
// No code because this is an assertion.
2101-
THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING(
2102-
isolate, "Should not query options before bootstrapping is done");
2103-
}
2104-
2105-
Mutex::ScopedLock lock(per_process::cli_options_mutex);
2106-
2107-
Local<Object> options_metadata = Object::New(isolate);
2108-
2109-
for (const auto& item : _ppop_instance.options_) {
2110-
if (!item.first.empty() && !item.first.starts_with('[') &&
2111-
item.second.env_setting == kAllowedInEnvvar) {
2112-
const auto mapping_details = options_parser::OptionMappingDetails{
2113-
item.second.type,
2114-
item.second.help_text,
2115-
};
2116-
if (!AddOptionTypeToObject(isolate,
2117-
context,
2118-
options_metadata,
2119-
item.first,
2120-
mapping_details)) {
2121-
return;
2122-
}
2123-
}
2124-
}
2125-
args.GetReturnValue().Set(options_metadata);
2126-
}
2127-
2128-
// This function returns a two-level nested map where:
2129-
// - Keys are namespace names (e.g., "testRunner")
2130-
// - Values are objects mapping option names to their metadata
2131-
// This is used for config file JSON schema generation
2132-
void GetNamespaceOptionsInputType(const FunctionCallbackInfo<Value>& args) {
2133-
Isolate* isolate = args.GetIsolate();
2134-
Local<Context> context = isolate->GetCurrentContext();
2135-
Environment* env = Environment::GetCurrent(context);
2136-
2137-
if (!env->has_run_bootstrapping_code()) {
2138-
// No code because this is an assertion.
2139-
THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING(
2140-
isolate, "Should not query options before bootstrapping is done");
2141-
}
2142-
2143-
Mutex::ScopedLock lock(per_process::cli_options_mutex);
2144-
2145-
Local<Map> namespaces_metadata = Map::New(isolate);
2146-
2147-
// Get the mapping of namespaces to their options and metadata
2148-
auto namespace_options = options_parser::MapNamespaceOptionsAssociations();
2149-
2150-
for (const auto& ns_entry : namespace_options) {
2151-
const std::string& namespace_name = ns_entry.first;
2152-
const auto& options_map = ns_entry.second;
2153-
2154-
Local<Object> options_metadata = Object::New(isolate);
2155-
2156-
for (const auto& opt_entry : options_map) {
2157-
const std::string& option_name = opt_entry.first;
2158-
const options_parser::OptionMappingDetails& option_details =
2159-
opt_entry.second;
2160-
2161-
if (!AddOptionTypeToObject(isolate,
2162-
context,
2163-
options_metadata,
2164-
option_name,
2165-
option_details)) {
2166-
return;
2167-
}
2168-
}
2169-
2170-
// Only add namespaces that have options
2171-
if (!options_metadata.IsEmpty()) {
2172-
Local<String> namespace_key;
2173-
if (!String::NewFromUtf8(isolate,
2174-
namespace_name.data(),
2175-
v8::NewStringType::kNormal,
2176-
namespace_name.size())
2177-
.ToLocal(&namespace_key)) {
2178-
continue;
2179-
}
2180-
2181-
if (namespaces_metadata->Set(context, namespace_key, options_metadata)
2182-
.IsEmpty()) {
2183-
return;
2184-
}
2185-
}
2186-
}
2187-
2188-
args.GetReturnValue().Set(namespaces_metadata);
2189-
}
2190-
21912011
// Return an array containing all currently active options as flag
21922012
// strings from all sources (command line, NODE_OPTIONS, config file)
21932013
void GetOptionsAsFlags(const FunctionCallbackInfo<Value>& args) {
@@ -2323,12 +2143,6 @@ void Initialize(Local<Object> target,
23232143
context, target, "getOptionsAsFlags", GetOptionsAsFlags);
23242144
SetMethodNoSideEffect(
23252145
context, target, "getEmbedderOptions", GetEmbedderOptions);
2326-
SetMethodNoSideEffect(
2327-
context, target, "getEnvOptionsInputType", GetEnvOptionsInputType);
2328-
SetMethodNoSideEffect(context,
2329-
target,
2330-
"getNamespaceOptionsInputType",
2331-
GetNamespaceOptionsInputType);
23322146
SetMethodNoSideEffect(
23332147
context, target, "getConfigJsonSchema", GetConfigJsonSchema);
23342148
Local<Object> env_settings = Object::New(isolate);
@@ -2357,8 +2171,6 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
23572171
registry->Register(GetCLIOptionsInfo);
23582172
registry->Register(GetOptionsAsFlags);
23592173
registry->Register(GetEmbedderOptions);
2360-
registry->Register(GetEnvOptionsInputType);
2361-
registry->Register(GetNamespaceOptionsInputType);
23622174
registry->Register(GetConfigJsonSchema);
23632175
}
23642176
} // namespace options_parser

src/node_options.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,6 @@ class OptionsParser {
666666
friend std::unordered_map<std::string, OptionMappingDetails>
667667
MapOptionsByNamespace(std::string namespace_name);
668668
friend std::vector<std::string> MapAvailableNamespaces();
669-
friend void GetEnvOptionsInputType(
670-
const v8::FunctionCallbackInfo<v8::Value>& args);
671669
friend void GetOptionsAsFlags(
672670
const v8::FunctionCallbackInfo<v8::Value>& args);
673671
};

0 commit comments

Comments
 (0)