From d8373622165f9dbdf12eef8c81204f35a376ff76 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 3 Apr 2018 10:25:20 +0200 Subject: C codegen: preparations for different seq and string implementations --- lib/core/strs.nim | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/core/strs.nim') diff --git a/lib/core/strs.nim b/lib/core/strs.nim index 1958f4974..ff38aef1d 100644 --- a/lib/core/strs.nim +++ b/lib/core/strs.nim @@ -12,12 +12,11 @@ import allocators type - string {.core.} = object + string {.core, exportc: "NimStringV2".} = object len, cap: int data: ptr UncheckedArray[char] -proc nimStringLiteral(x: cstring; len: int): string {.core.} = - string(len: len, cap: len, data: x) +const nimStrVersion {.core.} = 2 template frees(s) = dealloc(s.data, s.cap + 1) @@ -80,7 +79,7 @@ proc newString*(len: int): string = if len > 0: result.data = alloc0(len+1) -converter toCString(x: string): cstring {.core.} = +converter toCString(x: string): cstring {.core, inline.} = if x.len == 0: cstring"" else: cast[cstring](x.data) proc newStringOfCap*(cap: int): string = -- cgit 1.4.1-2-gfad0