File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -1122,6 +1122,12 @@ private:
1122
1122
return T (*this , o);
1123
1123
}
1124
1124
1125
+ template <typename T>
1126
+ T read (std::uint64_t offset) {
1127
+ T v;
1128
+ memcpy (&v, data+offset, sizeof (T));
1129
+ return v;
1130
+ }
1125
1131
public:
1126
1132
Writer (size_t capacity = 256 , std::unique_ptr<WriterBacking> backing = nullptr )
1127
1133
: backing(std::move(backing)), size(10 ) {
@@ -1332,6 +1338,7 @@ protected:
1332
1338
std::uint64_t offset_;
1333
1339
1334
1340
void setType_ (std::uint16_t type) noexcept { writer_.write (type, offset_); }
1341
+ std::uint16_t getType_ () const noexcept {return writer_.read <uint16_t >(offset_); }
1335
1342
1336
1343
void setObject_ (std::uint64_t p) noexcept { writer_.write48_ (p, offset_ + 2 ); }
1337
1344
@@ -1351,6 +1358,7 @@ protected:
1351
1358
std::uint64_t next_;
1352
1359
1353
1360
void setType_ (std::uint16_t type) noexcept { writer_.write (type, offset_); }
1361
+ std::uint16_t getType_ () const noexcept { return writer_.read <uint16_t >(offset_); }
1354
1362
1355
1363
void setSize_ (std::uint64_t size) noexcept { writer_.write48_ (size, offset_ + 2 ); }
1356
1364
Original file line number Diff line number Diff line change @@ -903,9 +903,11 @@ def generate_union(self, union: Union) -> None:
903
903
self .o ("protected:" )
904
904
self .o ("\t using scalgoproto::%sUnionOut::%sUnionOut;" % (prefix , prefix ))
905
905
self .o ("public:" )
906
+ self .o ("\t using Type = %sType;" % union .name )
906
907
self .o (
907
908
"\t using IN=%sIn<%s>;" % (union .name , "true" if inplace else "false" )
908
909
)
910
+ self .o ("\t Type type() const noexcept {return (Type)this->getType_();}" )
909
911
idx = 1
910
912
for member in union .members :
911
913
assert member .type_ is not None
You can’t perform that action at this time.
0 commit comments