mirror of
https://github.com/status-im/nim-serialization.git
synced 2025-01-29 13:15:49 +00:00
nim devel workaround
This commit is contained in:
parent
d77417cba6
commit
257e2e02eb
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -156,4 +156,5 @@ jobs:
|
||||
nim --version
|
||||
nimble --version
|
||||
nimble install -y --depsOnly
|
||||
rm -f nimble.lock
|
||||
nimble test
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,3 +3,5 @@ tests/test_all
|
||||
nimble.develop
|
||||
nimble.paths
|
||||
build/
|
||||
|
||||
*.exe
|
||||
|
52
nimble.lock
52
nimble.lock
@ -2,53 +2,54 @@
|
||||
"version": 1,
|
||||
"packages": {
|
||||
"unittest2": {
|
||||
"version": "0.0.4",
|
||||
"vcsRevision": "f180f596c88dfd266f746ed6f8dbebce39c824db",
|
||||
"url": "https://github.com/status-im/nim-unittest2.git",
|
||||
"version": "0.0.5",
|
||||
"vcsRevision": "da8398c45cafd5bd7772da1fc96e3924a18d3823",
|
||||
"url": "https://github.com/status-im/nim-unittest2",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [],
|
||||
"checksums": {
|
||||
"sha1": "fa309c41eaf6ef57895b9e603f2620a2f6e11780"
|
||||
"sha1": "b3f8493a4948989ef3e645a38b23aad77e851e26"
|
||||
}
|
||||
},
|
||||
"stew": {
|
||||
"version": "0.1.0",
|
||||
"vcsRevision": "6ad35b876fb6ebe0dfee0f697af173acc47906ee",
|
||||
"vcsRevision": "447b23d3bf6eb7be6531385e4db9124772c98068",
|
||||
"url": "https://github.com/status-im/nim-stew.git",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [],
|
||||
"checksums": {
|
||||
"sha1": "46d58c4feb457f3241e3347778334e325dce5268"
|
||||
"sha1": "98cbd5289c44e355d50b3914b0876ea0dd2a6813"
|
||||
}
|
||||
},
|
||||
"httputils": {
|
||||
"version": "0.3.0",
|
||||
"vcsRevision": "689da19e9e9cfff4ced85e2b25c6b2b5598ed079",
|
||||
"url": "https://github.com/status-im/nim-http-utils.git",
|
||||
"vcsRevision": "a85bd52ae0a956983ca6b3267c72961d2ec0245f",
|
||||
"url": "https://github.com/status-im/nim-http-utils",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"stew"
|
||||
"stew",
|
||||
"unittest2"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "4ad3ad68d13c50184180ab4b2eacc0bd7ed2ed44"
|
||||
"sha1": "92933b21bcd29335f68e377e2b2193fa331e28b3"
|
||||
}
|
||||
},
|
||||
"bearssl": {
|
||||
"version": "0.1.5",
|
||||
"vcsRevision": "ba80e2a0d7ae8aab666cee013e38ff8d33a3e5e7",
|
||||
"version": "0.2.0",
|
||||
"vcsRevision": "acf9645e328bdcab481cfda1c158e07ecd46bd7b",
|
||||
"url": "https://github.com/status-im/nim-bearssl",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"unittest2"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "383abd5becc77bf8e365b780a29d20529e1d9c4c"
|
||||
"sha1": "c939aef6a1c17c95131242a6292ade1c92380792"
|
||||
}
|
||||
},
|
||||
"chronos": {
|
||||
"version": "3.0.11",
|
||||
"vcsRevision": "17fed89c99beac5a92d3668d0d3e9b0e4ac13936",
|
||||
"url": "https://github.com/status-im/nim-chronos.git",
|
||||
"vcsRevision": "8fcbe716b2f069480277aa6781782d3e311ee2c0",
|
||||
"url": "https://github.com/status-im/nim-chronos",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"stew",
|
||||
@ -57,34 +58,21 @@
|
||||
"unittest2"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "f6fffc87571e5f76af2a77c4ebcc0e00909ced4e"
|
||||
}
|
||||
},
|
||||
"testutils": {
|
||||
"version": "0.4.2",
|
||||
"vcsRevision": "aa6e5216f4b4ab5aa971cdcdd70e1ec1203cedf2",
|
||||
"url": "https://github.com/status-im/nim-testutils",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"unittest2"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "94427e0cce0e0c5841edcd3a6530b4e6b857a3cb"
|
||||
"sha1": "a9f6c91ea5b2f48dddd8500c9556562185102808"
|
||||
}
|
||||
},
|
||||
"faststreams": {
|
||||
"version": "0.3.0",
|
||||
"vcsRevision": "1b561a9e71b6bdad1c1cdff753418906037e9d09",
|
||||
"url": "https://github.com/status-im/nim-faststreams.git",
|
||||
"vcsRevision": "814f8927e1f356f39219f37f069b83066bcc893a",
|
||||
"url": "https://github.com/status-im/nim-faststreams",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"stew",
|
||||
"testutils",
|
||||
"chronos",
|
||||
"unittest2"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "97edf9797924af48566a0af8267203dc21d80c77"
|
||||
"sha1": "16c69a7b454d803dcf28f6115f42bb47421d9376"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -201,9 +201,11 @@ template writeFieldIMPL*[Writer](writer: var Writer,
|
||||
mixin writeValue
|
||||
writeValue(writer, fieldVal)
|
||||
|
||||
proc makeFieldReadersTable(RecordType, ReaderType: distinct type):
|
||||
seq[FieldReader[RecordType, ReaderType]] =
|
||||
proc makeFieldReadersTable(RecordType, ReaderType: distinct type,
|
||||
numFields: static[int]):
|
||||
array[numFields, FieldReader[RecordType, ReaderType]] =
|
||||
mixin enumAllSerializedFields, readFieldIMPL, handleReadException
|
||||
var idx = 0
|
||||
|
||||
enumAllSerializedFields(RecordType):
|
||||
proc readField(obj: var RecordType, reader: var ReaderType)
|
||||
@ -232,19 +234,17 @@ proc makeFieldReadersTable(RecordType, ReaderType: distinct type):
|
||||
when RecordType is tuple: obj[i] else: field(obj, realFieldName),
|
||||
err)
|
||||
|
||||
result.add((fieldName, readField))
|
||||
result[idx] = (fieldName, readField)
|
||||
inc idx
|
||||
|
||||
proc fieldReadersTable*(RecordType, ReaderType: distinct type):
|
||||
ptr seq[FieldReader[RecordType, ReaderType]] =
|
||||
proc fieldReadersTable*(RecordType, ReaderType: distinct type): auto =
|
||||
mixin readValue
|
||||
|
||||
# careful: https://github.com/nim-lang/Nim/issues/17085
|
||||
# TODO why is this even here? one could just return the function pointer
|
||||
# to the field reader directly instead of going through this seq etc
|
||||
var tbl {.threadvar.}: ref seq[FieldReader[RecordType, ReaderType]]
|
||||
type T = RecordType
|
||||
const numFields = totalSerializedFields(T)
|
||||
var tbl {.threadvar.}: ref array[numFields, FieldReader[RecordType, ReaderType]]
|
||||
if tbl == nil:
|
||||
tbl = new typeof(tbl)
|
||||
tbl[] = makeFieldReadersTable(RecordType, ReaderType)
|
||||
tbl[] = makeFieldReadersTable(RecordType, ReaderType, numFields)
|
||||
return addr(tbl[])
|
||||
|
||||
proc findFieldIdx*(fieldsTable: FieldReadersTable,
|
||||
|
Loading…
x
Reference in New Issue
Block a user