Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a57aed1

Browse filesBrowse files
mcollinaMylesBorins
authored andcommitted
src: add kUInteger parsing
This commit adds support for uint64_t option parsing. Backport-PR-URL: #25168 PR-URL: #24811 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1 parent 6183c71 commit a57aed1
Copy full SHA for a57aed1

File tree

Expand file treeCollapse file tree

4 files changed

+26
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+26
-0
lines changed
Open diff view settings
Collapse file

‎lib/internal/print_help.js‎

Copy file name to clipboardExpand all lines: lib/internal/print_help.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ function getArgDescription(type) {
5959
case 'kHostPort':
6060
return '[host:]port';
6161
case 'kInteger':
62+
case 'kUInteger':
6263
case 'kString':
6364
case 'kStringList':
6465
return '...';
Collapse file

‎src/node_options-inl.h‎

Copy file name to clipboardExpand all lines: src/node_options-inl.h
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ void OptionsParser<Options>::AddOption(const std::string& name,
3535
help_text});
3636
}
3737

38+
template <typename Options>
39+
void OptionsParser<Options>::AddOption(const std::string& name,
40+
const std::string& help_text,
41+
uint64_t Options::* field,
42+
OptionEnvvarSettings env_setting) {
43+
options_.emplace(
44+
name,
45+
OptionInfo{kUInteger,
46+
std::make_shared<SimpleOptionField<uint64_t>>(field),
47+
env_setting,
48+
help_text});
49+
}
50+
3851
template <typename Options>
3952
void OptionsParser<Options>::AddOption(const std::string& name,
4053
const std::string& help_text,
@@ -397,6 +410,9 @@ void OptionsParser<Options>::Parse(
397410
case kInteger:
398411
*Lookup<int64_t>(info.field, options) = std::atoll(value.c_str());
399412
break;
413+
case kUInteger:
414+
*Lookup<uint64_t>(info.field, options) = std::stoull(value.c_str());
415+
break;
400416
case kString:
401417
*Lookup<std::string>(info.field, options) = value;
402418
break;
Collapse file

‎src/node_options.cc‎

Copy file name to clipboardExpand all lines: src/node_options.cc
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ void GetOptions(const FunctionCallbackInfo<Value>& args) {
406406
case kInteger:
407407
value = Number::New(isolate, *parser.Lookup<int64_t>(field, opts));
408408
break;
409+
case kUInteger:
410+
value = Number::New(isolate, *parser.Lookup<uint64_t>(field, opts));
411+
break;
409412
case kString:
410413
if (!ToV8Value(context, *parser.Lookup<std::string>(field, opts))
411414
.ToLocal(&value)) {
@@ -492,6 +495,7 @@ void Initialize(Local<Object> target,
492495
NODE_DEFINE_CONSTANT(types, kV8Option);
493496
NODE_DEFINE_CONSTANT(types, kBoolean);
494497
NODE_DEFINE_CONSTANT(types, kInteger);
498+
NODE_DEFINE_CONSTANT(types, kUInteger);
495499
NODE_DEFINE_CONSTANT(types, kString);
496500
NODE_DEFINE_CONSTANT(types, kHostPort);
497501
NODE_DEFINE_CONSTANT(types, kStringList);
Collapse file

‎src/node_options.h‎

Copy file name to clipboardExpand all lines: src/node_options.h
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ enum OptionType {
168168
kV8Option,
169169
kBoolean,
170170
kInteger,
171+
kUInteger,
171172
kString,
172173
kHostPort,
173174
kStringList,
@@ -194,6 +195,10 @@ class OptionsParser {
194195
const std::string& help_text,
195196
bool Options::* field,
196197
OptionEnvvarSettings env_setting = kDisallowedInEnvironment);
198+
void AddOption(const std::string& name,
199+
const std::string& help_text,
200+
uint64_t Options::* field,
201+
OptionEnvvarSettings env_setting = kDisallowedInEnvironment);
197202
void AddOption(const std::string& name,
198203
const std::string& help_text,
199204
int64_t Options::* field,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.