@@ -39,11 +39,13 @@ void FSContinuationData::Done(int result) {
39
39
done_cb_ (req_);
40
40
}
41
41
42
- FSReqBase::FSReqBase (Environment* env,
43
- v8::Local<v8::Object> req,
44
- AsyncWrap::ProviderType type,
45
- bool use_bigint)
46
- : ReqWrap(env, req, type), use_bigint_(use_bigint) {
42
+ FSReqBase::FSReqBase (BindingData* binding_data,
43
+ v8::Local<v8::Object> req,
44
+ AsyncWrap::ProviderType type,
45
+ bool use_bigint)
46
+ : ReqWrap(binding_data->env (), req, type),
47
+ use_bigint_(use_bigint),
48
+ binding_data_(binding_data) {
47
49
}
48
50
49
51
void FSReqBase::Init (const char * syscall,
@@ -72,9 +74,13 @@ FSReqBase::Init(const char* syscall, size_t len, enum encoding encoding) {
72
74
return buffer_;
73
75
}
74
76
75
- FSReqCallback::FSReqCallback (Environment* env,
76
- v8::Local<v8::Object> req, bool use_bigint)
77
- : FSReqBase(env, req, AsyncWrap::PROVIDER_FSREQCALLBACK, use_bigint) {}
77
+ FSReqCallback::FSReqCallback (BindingData* binding_data,
78
+ v8::Local<v8::Object> req,
79
+ bool use_bigint)
80
+ : FSReqBase(binding_data,
81
+ req,
82
+ AsyncWrap::PROVIDER_FSREQCALLBACK,
83
+ use_bigint) {}
78
84
79
85
template <typename NativeT, typename V8T>
80
86
void FillStatsArray (AliasedBufferBase<NativeT, V8T>* fields,
@@ -112,26 +118,28 @@ void FillStatsArray(AliasedBufferBase<NativeT, V8T>* fields,
112
118
#undef SET_FIELD_WITH_STAT
113
119
}
114
120
115
- v8::Local<v8::Value> FillGlobalStatsArray (Environment* env ,
121
+ v8::Local<v8::Value> FillGlobalStatsArray (BindingData* binding_data ,
116
122
const bool use_bigint,
117
123
const uv_stat_t * s,
118
124
const bool second) {
119
125
const ptrdiff_t offset =
120
126
second ? static_cast <ptrdiff_t >(FsStatsOffset::kFsStatsFieldsNumber ) : 0 ;
121
127
if (use_bigint) {
122
- auto * const arr = env-> fs_stats_field_bigint_array () ;
128
+ auto * const arr = &binding_data-> stats_field_bigint_array ;
123
129
FillStatsArray (arr, s, offset);
124
130
return arr->GetJSArray ();
125
131
} else {
126
- auto * const arr = env-> fs_stats_field_array () ;
132
+ auto * const arr = &binding_data-> stats_field_array ;
127
133
FillStatsArray (arr, s, offset);
128
134
return arr->GetJSArray ();
129
135
}
130
136
}
131
137
132
138
template <typename AliasedBufferT>
133
139
FSReqPromise<AliasedBufferT>*
134
- FSReqPromise<AliasedBufferT>::New(Environment* env, bool use_bigint) {
140
+ FSReqPromise<AliasedBufferT>::New(BindingData* binding_data,
141
+ bool use_bigint) {
142
+ Environment* env = binding_data->env ();
135
143
v8::Local<v8::Object> obj;
136
144
if (!env->fsreqpromise_constructor_template ()
137
145
->NewInstance (env->context ())
@@ -143,7 +151,7 @@ FSReqPromise<AliasedBufferT>::New(Environment* env, bool use_bigint) {
143
151
obj->Set (env->context (), env->promise_string (), resolver).IsNothing ()) {
144
152
return nullptr ;
145
153
}
146
- return new FSReqPromise (env , obj, use_bigint);
154
+ return new FSReqPromise (binding_data , obj, use_bigint);
147
155
}
148
156
149
157
template <typename AliasedBufferT>
@@ -154,12 +162,15 @@ FSReqPromise<AliasedBufferT>::~FSReqPromise() {
154
162
155
163
template <typename AliasedBufferT>
156
164
FSReqPromise<AliasedBufferT>::FSReqPromise(
157
- Environment* env ,
165
+ BindingData* binding_data ,
158
166
v8::Local<v8::Object> obj,
159
167
bool use_bigint)
160
- : FSReqBase(env, obj, AsyncWrap::PROVIDER_FSREQPROMISE, use_bigint),
168
+ : FSReqBase(binding_data,
169
+ obj,
170
+ AsyncWrap::PROVIDER_FSREQPROMISE,
171
+ use_bigint),
161
172
stats_field_array_ (
162
- env->isolate (),
173
+ env () ->isolate(),
163
174
static_cast<size_t>(FsStatsOffset::kFsStatsFieldsNumber )) {}
164
175
165
176
template <typename AliasedBufferT>
@@ -208,15 +219,21 @@ void FSReqPromise<AliasedBufferT>::MemoryInfo(MemoryTracker* tracker) const {
208
219
tracker->TrackField (" stats_field_array" , stats_field_array_);
209
220
}
210
221
211
- FSReqBase* GetReqWrap (Environment* env, v8::Local<v8::Value> value,
222
+ FSReqBase* GetReqWrap (const v8::FunctionCallbackInfo<v8::Value>& args,
223
+ int index,
212
224
bool use_bigint) {
225
+ v8::Local<v8::Value> value = args[index ];
213
226
if (value->IsObject ()) {
214
227
return Unwrap<FSReqBase>(value.As <v8::Object>());
215
- } else if (value->StrictEquals (env->fs_use_promises_symbol ())) {
228
+ }
229
+
230
+ BindingData* binding_data = Unwrap<BindingData>(args.Data ());
231
+ Environment* env = binding_data->env ();
232
+ if (value->StrictEquals (env->fs_use_promises_symbol ())) {
216
233
if (use_bigint) {
217
- return FSReqPromise<AliasedBigUint64Array>::New (env , use_bigint);
234
+ return FSReqPromise<AliasedBigUint64Array>::New (binding_data , use_bigint);
218
235
} else {
219
- return FSReqPromise<AliasedFloat64Array>::New (env , use_bigint);
236
+ return FSReqPromise<AliasedFloat64Array>::New (binding_data , use_bigint);
220
237
}
221
238
}
222
239
return nullptr ;
0 commit comments