mirror of https://github.com/status-im/nim-eth.git
Reduce compiler warnings in rlp (#674)
This commit is contained in:
parent
8ab060b19f
commit
bb1ab544fc
|
@ -393,7 +393,7 @@ proc readImpl(rlp: var Rlp, T: type[object|tuple],
|
|||
template getUnderlyingType[T](_: Option[T]): untyped = T
|
||||
template getUnderlyingType[T](_: Opt[T]): untyped = T
|
||||
|
||||
template op(RecordType, fieldName, field) =
|
||||
template op(RecordType, fieldName, field) {.used.} =
|
||||
type FieldType {.used.} = type field
|
||||
when hasCustomPragmaFixed(RecordType, fieldName, rlpCustomSerialization):
|
||||
field = rlp.read(result, FieldType)
|
||||
|
|
|
@ -11,7 +11,7 @@ template rlpCustomSerialization* {.pragma.}
|
|||
## a reference to the object holding the field.
|
||||
|
||||
template enumerateRlpFields*[T](x: T, op: untyped) =
|
||||
type RecordType = type x
|
||||
type RecordType {.used.} = type x
|
||||
for fieldName, field in fieldPairs(x):
|
||||
when not hasCustomPragmaFixed(RecordType, fieldName, rlpIgnore):
|
||||
op(RecordType, fieldName, field)
|
||||
|
@ -21,7 +21,7 @@ proc rlpFieldsCount*(T: type): int =
|
|||
|
||||
proc helper: int =
|
||||
var dummy: T
|
||||
template countFields(RT, n, x) = inc result
|
||||
template countFields(RT, n, x) {.used.} = inc result
|
||||
enumerateRlpFields(dummy, countFields)
|
||||
|
||||
const res = helper()
|
||||
|
|
|
@ -173,7 +173,7 @@ proc hasOptionalFields(T: type): bool =
|
|||
proc helper: bool =
|
||||
var dummy: T
|
||||
result = false
|
||||
template detectOptionalField(RT, n, x) =
|
||||
template detectOptionalField(RT, n, x) {.used.} =
|
||||
when x is Option or x is Opt:
|
||||
return true
|
||||
enumerateRlpFields(dummy, detectOptionalField)
|
||||
|
@ -286,7 +286,7 @@ proc appendRecordType*(self: var RlpWriter, obj: object|tuple, wrapInList = wrap
|
|||
else:
|
||||
self.startList(fieldsCount)
|
||||
|
||||
template op(RecordType, fieldName, field) =
|
||||
template op(RecordType, fieldName, field) {.used.} =
|
||||
when hasCustomPragmaFixed(RecordType, fieldName, rlpCustomSerialization):
|
||||
append(self, obj, field)
|
||||
elif (field is Option or field is Opt) and hasOptional:
|
||||
|
|
Loading…
Reference in New Issue