@@ -1344,50 +1344,37 @@ void Environment::DeserializeProperties(const EnvSerializeInfo* info) {
1344
1344
const std::vector<PropInfo>& templates = info->persistent_templates ;
1345
1345
size_t i = 0 ; // index to the array
1346
1346
size_t id = 0 ;
1347
- #define V (PropertyName, TypeName ) \
1347
+ #define SetProperty (PropertyName, TypeName, vector, type, from ) \
1348
1348
do { \
1349
- if (templates .size () > i && id == templates [i].id ) { \
1350
- const PropInfo& d = templates [i]; \
1349
+ if (vector .size () > i && id == vector [i].id ) { \
1350
+ const PropInfo& d = vector [i]; \
1351
1351
DCHECK_EQ (d.name , #PropertyName); \
1352
1352
MaybeLocal<TypeName> maybe_field = \
1353
- isolate_ ->GetDataFromSnapshotOnce <TypeName>(d.index ); \
1353
+ from ->GetDataFromSnapshotOnce <TypeName>(d.index ); \
1354
1354
Local<TypeName> field; \
1355
1355
if (!maybe_field.ToLocal (&field)) { \
1356
1356
fprintf (stderr, \
1357
- " Failed to deserialize environment template " #PropertyName \
1357
+ " Failed to deserialize environment " #type " " #PropertyName \
1358
1358
" \n " ); \
1359
1359
} \
1360
1360
set_##PropertyName (field); \
1361
1361
i++; \
1362
1362
} \
1363
1363
} while (0 ); \
1364
1364
id++;
1365
+ #define V (PropertyName, TypeName ) SetProperty(PropertyName, TypeName, \
1366
+ templates, template , isolate_)
1365
1367
ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES (V);
1366
1368
#undef V
1367
1369
1368
1370
i = 0 ; // index to the array
1369
1371
id = 0 ;
1370
1372
const std::vector<PropInfo>& values = info->persistent_values ;
1371
- #define V (PropertyName, TypeName ) \
1372
- do { \
1373
- if (values.size () > i && id == values[i].id ) { \
1374
- const PropInfo& d = values[i]; \
1375
- DCHECK_EQ (d.name , #PropertyName); \
1376
- MaybeLocal<TypeName> maybe_field = \
1377
- ctx->GetDataFromSnapshotOnce <TypeName>(d.index ); \
1378
- Local<TypeName> field; \
1379
- if (!maybe_field.ToLocal (&field)) { \
1380
- fprintf (stderr, \
1381
- " Failed to deserialize environment value " #PropertyName \
1382
- " \n " ); \
1383
- } \
1384
- set_##PropertyName (field); \
1385
- i++; \
1386
- } \
1387
- } while (0 ); \
1388
- id++;
1373
+ #define V (PropertyName, TypeName ) SetProperty(PropertyName, TypeName, \
1374
+ values, value, ctx)
1389
1375
ENVIRONMENT_STRONG_PERSISTENT_VALUES (V);
1390
1376
#undef V
1377
+ #undef SetProperty
1391
1378
1392
1379
MaybeLocal<Context> maybe_ctx_from_snapshot =
1393
1380
ctx->GetDataFromSnapshotOnce <Context>(info->context );
0 commit comments