GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: expose uv.errmap to binding · nodejs/node@4de4c54

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • uv.cc
  • test/parallel
    • test-uv-binding-constant.js
    • test-uv-errno.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/uv.cc‎

Copy file name to clipboardExpand all lines: src/uv.cc
+23-2Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@
2727
namespace node {
2828
namespace {
2929

30+
using v8::Array;
3031
using v8::Context;
3132
using v8::FunctionCallbackInfo;
33+
using v8::Integer;
34+
using v8::Isolate;
3235
using v8::Local;
36+
using v8::Map;
3337
using v8::Object;
38+
using v8::String;
3439
using v8::Value;
3540

3641

@@ -47,14 +52,30 @@ void InitializeUV(Local<Object> target,
4752
Local<Value> unused,
4853
Local<Context> context) {
4954
Environment* env = Environment::GetCurrent(context);
50-
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "errname"),
55+
Isolate* isolate = env->isolate();
56+
target->Set(FIXED_ONE_BYTE_STRING(isolate, "errname"),
5157
env->NewFunctionTemplate(ErrName)->GetFunction());
5258

5359
#define V(name, _) NODE_DEFINE_CONSTANT(target, UV_##name);
5460
UV_ERRNO_MAP(V)
5561
#undef V
56-
}
5762

63+
Local<Map> err_map = Map::New(isolate);
64+
65+
#define V(name, msg) do { \
66+
Local<Array> arr = Array::New(isolate, 2); \
67+
arr->Set(0, OneByteString(isolate, #name)); \
68+
arr->Set(1, OneByteString(isolate, msg)); \
69+
err_map->Set(context, \
70+
Integer::New(isolate, UV_##name), \
71+
arr).ToLocalChecked(); \
72+
} while (0);
73+
UV_ERRNO_MAP(V)
74+
#undef V
75+
76+
target->Set(context, FIXED_ONE_BYTE_STRING(isolate, "errmap"),
77+
err_map).FromJust();
78+
}
5879

5980
} // anonymous namespace
6081
} // namespace node
Collapse file

‎test/parallel/test-uv-binding-constant.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-uv-binding-constant.js
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const uv = process.binding('uv');
99

1010
const keys = Object.keys(uv);
1111
keys.forEach((key) => {
12-
if (key === 'errname')
13-
return; // skip this
14-
const val = uv[key];
15-
assert.throws(() => uv[key] = 1,
16-
/^TypeError: Cannot assign to read only property/);
17-
assert.strictEqual(uv[key], val);
12+
if (key.startsWith('UV_')) {
13+
const val = uv[key];
14+
assert.throws(() => uv[key] = 1,
15+
/^TypeError: Cannot assign to read only property/);
16+
assert.strictEqual(uv[key], val);
17+
}
1818
});
Collapse file

‎test/parallel/test-uv-errno.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-uv-errno.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const uv = process.binding('uv');
88
const keys = Object.keys(uv);
99

1010
keys.forEach((key) => {
11-
if (key === 'errname')
11+
if (!key.startsWith('UV_'))
1212
return;
1313

1414
assert.doesNotThrow(() => {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.