conditional TGenericSeq extension

This commit is contained in:
Stefan Talpalaru
2015-06-16 15:15:17 +02:00
parent 8624654c57
commit b487d4e425
3 changed files with 18 additions and 8 deletions

View File

@@ -67,12 +67,16 @@ type
pbyteArray = ptr array[0.. 0xffff, int8]
TGenericSeq {.importc.} = object
len, space, elemSize: int
len, space: int
when defined(gogc):
elemSize: int
PGenSeq = ptr TGenericSeq
{.deprecated: [TAny: Any, TAnyKind: AnyKind].}
const
GenericSeqSize = (3 * sizeof(int))
when defined(gogc):
const GenericSeqSize = (3 * sizeof(int))
else:
const GenericSeqSize = (2 * sizeof(int))
proc genericAssign(dest, src: pointer, mt: PNimType) {.importCompilerProc.}
proc genericShallowAssign(dest, src: pointer, mt: PNimType) {.

View File

@@ -304,7 +304,9 @@ const ArrayDummySize = when defined(cpu16): 10_000 else: 100_000_000
when not defined(JS):
type
TGenericSeq {.compilerproc, pure, inheritable.} = object
len, reserved, elemSize: int
len, reserved: int
when defined(gogc):
elemSize: int
PGenericSeq {.exportc.} = ptr TGenericSeq
UncheckedCharArray {.unchecked.} = array[0..ArrayDummySize, char]
# len and space without counting the terminating zero:
@@ -2682,8 +2684,10 @@ when not defined(JS): #and not defined(NimrodVM):
when not defined(NimrodVM):
include "system/sets"
const
GenericSeqSize = (3 * sizeof(int))
when defined(gogc):
const GenericSeqSize = (3 * sizeof(int))
else:
const GenericSeqSize = (2 * sizeof(int))
proc getDiscriminant(aa: pointer, n: ptr TNimNode): int =
sysAssert(n.kind == nkCase, "getDiscriminant: node != nkCase")

View File

@@ -50,14 +50,16 @@ proc rawNewStringNoInit(space: int): NimString {.compilerProc.} =
if s < 7: s = 7
result = allocStrNoInit(sizeof(TGenericSeq) + s + 1)
result.reserved = s
result.elemSize = 1
when defined(gogc):
result.elemSize = 1
proc rawNewString(space: int): NimString {.compilerProc.} =
var s = space
if s < 7: s = 7
result = allocStr(sizeof(TGenericSeq) + s + 1)
result.reserved = s
result.elemSize = 1
when defined(gogc):
result.elemSize = 1
proc mnewString(len: int): NimString {.compilerProc.} =
result = rawNewString(len)