Add useDefaultWriterIn, useDefaultReaderIn, useDefaultWriterFor, and useDefaultReaderFor

This commit is contained in:
jangko 2023-12-27 16:03:08 +07:00
parent 68722b14fc
commit 289b6f90b2
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 27 additions and 0 deletions

View File

@ -52,8 +52,35 @@ template useDefaultSerializationIn*(T: untyped, Flavor: type) =
mixin writeRecordValue
writeRecordValue(w, value)
template useDefaultWriterIn*(T: untyped, Flavor: type) =
mixin Writer
template writeValue*(w: var Writer(Flavor), value: T) =
mixin writeRecordValue
writeRecordValue(w, value)
template useDefaultReaderIn*(T: untyped, Flavor: type) =
mixin Reader
template readValue*(r: var Reader(Flavor), value: var T) =
mixin readRecordValue
readRecordValue(r, value)
macro useDefaultSerializationFor*(Flavor: type, types: varargs[untyped])=
result = newStmtList()
for T in types:
result.add newCall(bindSym "useDefaultSerializationIn", T, Flavor)
macro useDefaultWriterFor*(Flavor: type, types: varargs[untyped])=
result = newStmtList()
for T in types:
result.add newCall(bindSym "useDefaultWriterIn", T, Flavor)
macro useDefaultReaderFor*(Flavor: type, types: varargs[untyped])=
result = newStmtList()
for T in types:
result.add newCall(bindSym "useDefaultReaderIn", T, Flavor)