Static[T] fixes (#7333)

* fix the usage of unresolved static[T] parameters in proc signatures
* fix tsametype and tmacrogenerics
* Allow creating composite type classes with concepts and using them in type signatures
* Allow integers to be used in ident concatenations
* Support using imported C++ generic types in proc signatures
* fixes #7230
* closes #7379
* re-enable some metatype tests
This commit is contained in:
zah 2018-03-24 16:28:09 +02:00 • committed by Andreas Rumpf
commit 121b9e26fb
18 changed files with 265 additions and 26 deletions

View file

@ -0,0 +1,32 @@
type
Hash*[bits: static[int]] = object
data*: array[bits div 8, uint8]
{.emit: """
void sha_256(void* input, int input_len, void* output, int output_len) {}
void sha_512(void* input, int input_len, void* output, int output_len) {}
void keccak_256(void* input, int input_len, void* output, int output_len) {}
void keccak_512(void* input, int input_len, void* output, int output_len) {}
""".}
template defineKeccak(bits: untyped) =
proc `extKeccak bits`(output: pointer, outSize: csize, input: pointer, inputSize: csize) {.nodecl, importc: "keccak_" & astToStr(bits).}
template defineSha(bits: static[int]) =
proc `extSha bits`(output: pointer, outSize: csize, input: pointer, inputSize: csize) {.nodecl, importc: "sha_" & astToStr(bits).}
template defineHashProcs(bits) =
defineSha(bits)
defineKeccak(bits)
defineHashProcs(256)
defineHashProcs(512)
extSha256(nil, 0, nil, 0)
extSha512(nil, 0, nil, 0)
extKeccak256(nil, 0, nil, 0)
extKeccak512(nil, 0, nil, 0)