@@ -264,17 +264,17 @@ FileHandle* FileHandle::New(BindingData* binding_data,
264
264
}
265
265
266
266
void FileHandle::New (const FunctionCallbackInfo<Value>& args) {
267
- BindingData* binding_data = Realm::GetBindingData<BindingData>(args);
268
- Environment* env = binding_data->env ();
269
267
CHECK (args.IsConstructCall ());
270
268
CHECK (args[0 ]->IsInt32 ());
269
+ Realm* realm = Realm::GetCurrent (args);
270
+ BindingData* binding_data = realm->GetBindingData <BindingData>();
271
271
272
272
std::optional<int64_t > maybeOffset = std::nullopt;
273
273
std::optional<int64_t > maybeLength = std::nullopt;
274
274
if (args[1 ]->IsNumber ())
275
- maybeOffset = args[1 ]->IntegerValue (env ->context ()).FromJust ();
275
+ maybeOffset = args[1 ]->IntegerValue (realm ->context ()).FromJust ();
276
276
if (args[2 ]->IsNumber ())
277
- maybeLength = args[2 ]->IntegerValue (env ->context ()).FromJust ();
277
+ maybeLength = args[2 ]->IntegerValue (realm ->context ()).FromJust ();
278
278
279
279
FileHandle::New (binding_data,
280
280
args[0 ].As <Int32>()->Value (),
@@ -1108,13 +1108,14 @@ static void InternalModuleStat(const FunctionCallbackInfo<Value>& args) {
1108
1108
}
1109
1109
1110
1110
static void Stat (const FunctionCallbackInfo<Value>& args) {
1111
- BindingData* binding_data = Realm::GetBindingData<BindingData>(args);
1112
- Environment* env = binding_data->env ();
1111
+ Realm* realm = Realm::GetCurrent (args);
1112
+ BindingData* binding_data = realm->GetBindingData <BindingData>();
1113
+ Environment* env = realm->env ();
1113
1114
1114
1115
const int argc = args.Length ();
1115
1116
CHECK_GE (argc, 2 );
1116
1117
1117
- BufferValue path (env ->isolate (), args[0 ]);
1118
+ BufferValue path (realm ->isolate (), args[0 ]);
1118
1119
CHECK_NOT_NULL (*path);
1119
1120
THROW_IF_INSUFFICIENT_PERMISSIONS (
1120
1121
env, permission::PermissionScope::kFileSystemRead , path.ToStringView ());
@@ -1143,13 +1144,14 @@ static void Stat(const FunctionCallbackInfo<Value>& args) {
1143
1144
}
1144
1145
1145
1146
static void LStat (const FunctionCallbackInfo<Value>& args) {
1146
- BindingData* binding_data = Realm::GetBindingData<BindingData>(args);
1147
- Environment* env = binding_data->env ();
1147
+ Realm* realm = Realm::GetCurrent (args);
1148
+ BindingData* binding_data = realm->GetBindingData <BindingData>();
1149
+ Environment* env = realm->env ();
1148
1150
1149
1151
const int argc = args.Length ();
1150
1152
CHECK_GE (argc, 3 );
1151
1153
1152
- BufferValue path (env ->isolate (), args[0 ]);
1154
+ BufferValue path (realm ->isolate (), args[0 ]);
1153
1155
CHECK_NOT_NULL (*path);
1154
1156
1155
1157
bool use_bigint = args[1 ]->IsTrue ();
@@ -1177,8 +1179,9 @@ static void LStat(const FunctionCallbackInfo<Value>& args) {
1177
1179
}
1178
1180
1179
1181
static void FStat (const FunctionCallbackInfo<Value>& args) {
1180
- BindingData* binding_data = Realm::GetBindingData<BindingData>(args);
1181
- Environment* env = binding_data->env ();
1182
+ Realm* realm = Realm::GetCurrent (args);
1183
+ BindingData* binding_data = realm->GetBindingData <BindingData>();
1184
+ Environment* env = realm->env ();
1182
1185
1183
1186
const int argc = args.Length ();
1184
1187
CHECK_GE (argc, 2 );
@@ -1209,13 +1212,14 @@ static void FStat(const FunctionCallbackInfo<Value>& args) {
1209
1212
}
1210
1213
1211
1214
static void StatFs (const FunctionCallbackInfo<Value>& args) {
1212
- BindingData* binding_data = Realm::GetBindingData<BindingData>(args);
1213
- Environment* env = binding_data->env ();
1215
+ Realm* realm = Realm::GetCurrent (args);
1216
+ BindingData* binding_data = realm->GetBindingData <BindingData>();
1217
+ Environment* env = realm->env ();
1214
1218
1215
1219
const int argc = args.Length ();
1216
1220
CHECK_GE (argc, 2 );
1217
1221
1218
- BufferValue path (env ->isolate (), args[0 ]);
1222
+ BufferValue path (realm ->isolate (), args[0 ]);
1219
1223
CHECK_NOT_NULL (*path);
1220
1224
THROW_IF_INSUFFICIENT_PERMISSIONS (
1221
1225
env, permission::PermissionScope::kFileSystemRead , path.ToStringView ());
0 commit comments