Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-04-21 08:47:30 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2019-04-26 09:23:31 +0300
commit0ae46a7a862e26ccd611aed4d189a5e480639a4c (patch)
tree9b37a35a1e512b1c09c6e8f45ab3a45d3e67c43b /src/node_file.h
parent5fe4d5966fd9c2b30b3da3ec7cb47132aa8cdfdd (diff)
src: use predefined AliasedBuffer types in the code base
Instead of allowing the callers to instantiate the template with any numeric types (such as aliasing a Uint8Array to double[]), predefine types that make sense and use those instead. PR-URL: https://github.com/nodejs/node/pull/27334 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_file.h')
-rw-r--r--src/node_file.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/node_file.h b/src/node_file.h
index 2c87f5e44d0..f5c523fb070 100644
--- a/src/node_file.h
+++ b/src/node_file.h
@@ -192,8 +192,9 @@ constexpr uint64_t ToNative(uv_timespec_t ts) {
#undef constexpr // end N3652 bug workaround
template <typename NativeT, typename V8T>
-constexpr void FillStatsArray(AliasedBuffer<NativeT, V8T>* fields,
- const uv_stat_t* s, const size_t offset = 0) {
+constexpr void FillStatsArray(AliasedBufferBase<NativeT, V8T>* fields,
+ const uv_stat_t* s,
+ const size_t offset = 0) {
fields->SetValue(offset + 0, static_cast<NativeT>(s->st_dev));
fields->SetValue(offset + 1, static_cast<NativeT>(s->st_mode));
fields->SetValue(offset + 2, static_cast<NativeT>(s->st_nlink));
@@ -227,7 +228,7 @@ inline Local<Value> FillGlobalStatsArray(Environment* env,
}
}
-template <typename NativeT = double, typename V8T = v8::Float64Array>
+template <typename AliasedBufferT>
class FSReqPromise : public FSReqBase {
public:
static FSReqPromise* New(Environment* env, bool use_bigint) {
@@ -304,7 +305,7 @@ class FSReqPromise : public FSReqBase {
stats_field_array_(env->isolate(), kFsStatsFieldsNumber) {}
bool finished_ = false;
- AliasedBuffer<NativeT, V8T> stats_field_array_;
+ AliasedBufferT stats_field_array_;
};
class FSReqAfterScope {