status-im / nim-stew

stew is collection of utilities, std library extensions and budding libraries that are frequently used at Status, but are too small to deserve their own git repository.
133 stars 18 forks source link

add `enumStyle` helper macro #189

Closed etan-status closed 1 year ago

etan-status commented 1 year ago

For serialization and parsing, distinguishing enums with numeric values from enums with associated strings for each value is useful. This adds foundational helpers to allow such distinction.

etan-status commented 1 year ago

Nim 1.6 CI error was already there before:

/home/runner/work/nim-stew/nim-stew/tests/test_varints.nim(11, 10) Warning: use leb128 or a higher level decoder; varints is deprecated [Deprecated]
/home/runner/work/nim-stew/nim-stew/tests/test_varints.nim(36, 7) template/generic instantiation of `suite` from here
/home/runner/work/nim-stew/nim-stew/tests/test_varints.nim(49, 8) template/generic instantiation of `test` from here
/home/runner/work/nim-stew/nim-stew/tests/test_varints.nim(52, 20) template/generic instantiation of `roundtipTest` from here
/home/runner/work/nim-stew/nim-stew/tests/test_varints.nim(42, 31) template/generic instantiation of `readVarint` from here
/home/runner/work/nim-stew/nim-stew/stew/varints.nim(159, 16) template/generic instantiation of `feedByte` from here
/home/runner/work/nim-stew/nim-stew/stew/varints.nim(120, 22) Error: attempting to call undeclared routine: 'IntType'
stack trace: (most recent call last)
     Error: Exception raised during nimble script execution
/tmp/nimblecache-946033505/nimscriptapi_3194862863.nim(187, 16)