Skip to content

Commit 2cab7bf

Browse files
author
Todd L. Montgomery
committed
[C++ OTF]: refactor retrieval of presence.
1 parent b2de3f4 commit 2cab7bf

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

main/cpp/otf_api/Field.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,49 +281,49 @@ class Field
281281
}
282282

283283
Field &addEncoding(const std::string &name, const Ir::TokenPrimitiveType type,
284-
const int64_t value, const Ir::TokenPresence presence = Ir::REQUIRED)
284+
const int64_t value, const Ir *ir)
285285
{
286286
encodingNames_.push_back(name);
287287
primitiveTypes_.push_back(type);
288288
encodingValues_.push_back(EncodingValue(value));
289289
encodingLengths_.push_back(1);
290-
presence_.push_back(presence);
290+
presence_.push_back(ir->presence());
291291
numEncodings_++;
292292
return *this;
293293
}
294294

295295
Field &addEncoding(const std::string &name, const Ir::TokenPrimitiveType type,
296-
const uint64_t value, const Ir::TokenPresence presence = Ir::REQUIRED)
296+
const uint64_t value, const Ir *ir)
297297
{
298298
encodingNames_.push_back(name);
299299
primitiveTypes_.push_back(type);
300300
encodingValues_.push_back(EncodingValue(value));
301301
encodingLengths_.push_back(1);
302-
presence_.push_back(presence);
302+
presence_.push_back(ir->presence());
303303
numEncodings_++;
304304
return *this;
305305
}
306306

307307
Field &addEncoding(const std::string &name, const Ir::TokenPrimitiveType type,
308-
const double value, const Ir::TokenPresence presence = Ir::REQUIRED)
308+
const double value, const Ir *ir)
309309
{
310310
encodingNames_.push_back(name);
311311
primitiveTypes_.push_back(type);
312312
encodingValues_.push_back(EncodingValue(value));
313313
encodingLengths_.push_back(1);
314-
presence_.push_back(presence);
314+
presence_.push_back(ir->presence());
315315
numEncodings_++;
316316
return *this;
317317
}
318318

319319
Field &addEncoding(const std::string &name, const Ir::TokenPrimitiveType type,
320-
const char *array, const int size, const Ir::TokenPresence presence = Ir::REQUIRED)
320+
const char *array, const int size, const Ir *ir)
321321
{
322322
encodingNames_.push_back(name);
323323
primitiveTypes_.push_back(type);
324324
encodingValues_.push_back(EncodingValue(array));
325325
encodingLengths_.push_back(size / Ir::size(type));
326-
presence_.push_back(presence);
326+
presence_.push_back(ir->presence());
327327
numEncodings_++;
328328
return *this;
329329
}

main/cpp/otf_api/Listener.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,14 +452,14 @@ void Listener::processEndField(void)
452452
uint64_t Listener::processBeginEnum(const Ir *ir, const char value)
453453
{
454454
cachedField_.type(Field::ENUM)
455-
.addEncoding(ir->name(), ir->primitiveType(), (uint64_t)value);
455+
.addEncoding(ir->name(), ir->primitiveType(), (uint64_t)value, ir);
456456
return ir->size();
457457
}
458458

459459
uint64_t Listener::processBeginEnum(const Ir *ir, uint8_t value)
460460
{
461461
cachedField_.type(Field::ENUM)
462-
.addEncoding(ir->name(), ir->primitiveType(), (uint64_t)value);
462+
.addEncoding(ir->name(), ir->primitiveType(), (uint64_t)value, ir);
463463
return ir->size();
464464
}
465465

@@ -480,7 +480,7 @@ void Listener::processEndEnum(void)
480480
uint64_t Listener::processBeginSet(const Ir *ir, const uint64_t value)
481481
{
482482
cachedField_.type(Field::SET)
483-
.addEncoding(ir->name(), ir->primitiveType(), value);
483+
.addEncoding(ir->name(), ir->primitiveType(), value, ir);
484484
return ir->size();
485485
}
486486

@@ -512,13 +512,13 @@ void Listener::processEndVarData(void)
512512

513513
uint64_t Listener::processEncoding(const Ir *ir, const int64_t value)
514514
{
515-
cachedField_.addEncoding(ir->name(), ir->primitiveType(), value, ir->presence());
515+
cachedField_.addEncoding(ir->name(), ir->primitiveType(), value, ir);
516516
return ir->size();
517517
}
518518

519519
uint64_t Listener::processEncoding(const Ir *ir, const uint64_t value)
520520
{
521-
cachedField_.addEncoding(ir->name(), ir->primitiveType(), value, ir->presence());
521+
cachedField_.addEncoding(ir->name(), ir->primitiveType(), value, ir);
522522

523523
//printf("encoding %s %d %u\n", ir->name().c_str(), ir->primitiveType(), value);
524524

@@ -554,7 +554,7 @@ uint64_t Listener::processEncoding(const Ir *ir, const uint64_t value)
554554

555555
uint64_t Listener::processEncoding(const Ir *ir, const double value)
556556
{
557-
cachedField_.addEncoding(ir->name(), ir->primitiveType(), value, ir->presence());
557+
cachedField_.addEncoding(ir->name(), ir->primitiveType(), value, ir);
558558
return ir->size();
559559
}
560560

@@ -563,12 +563,12 @@ uint64_t Listener::processEncoding(const Ir *ir, const char *value, const int si
563563
// arrays and variable length fields both come through here
564564
if (cachedField_.type() == Field::VAR_DATA)
565565
{
566-
cachedField_.addEncoding(ir->name(), ir->primitiveType(), value, cachedField_.varDataLength(), ir->presence());
566+
cachedField_.addEncoding(ir->name(), ir->primitiveType(), value, cachedField_.varDataLength(), ir);
567567
return cachedField_.varDataLength();
568568
}
569569
else
570570
{
571-
cachedField_.addEncoding(ir->name(), ir->primitiveType(), value, size, ir->presence());
571+
cachedField_.addEncoding(ir->name(), ir->primitiveType(), value, size, ir);
572572
return size;
573573
}
574574
}

0 commit comments

Comments
 (0)