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