diff --git a/gintro/gimpl.nim b/gintro/gimpl.nim index 9871bb0..6859370 100644 --- a/gintro/gimpl.nim +++ b/gintro/gimpl.nim @@ -1,8 +1,11 @@ +const RecSep = "!" # Record separator for entries in gisup.nim, also defined in gen.nim + +# caution: $$ due to string interpolation let ct4nt = [ "int32|int", "uint32|int", "gboolean|toBool", - "cstring|$"] + "cstring|$$"] proc ct5nt(s: string): string = for i in ct4nt: @@ -10,10 +13,10 @@ proc ct5nt(s: string): string = return i[s.len + 1 .. ^1] proc findSignal(name, obj: NimNode): string = - let str = ($name).replace("-", "_") & "|" + let str = ($name).replace("-", "_") & RecSep for i in SCA: if i.startsWith(str): - let t = i.split("|", 2)[1] + let t = i.split(RecSep, 2)[1] var n = obj while true: if n.kind != nnkBracketExpr: break @@ -50,7 +53,7 @@ proc $1$2 {.cdecl.} = r1s.add(", cast[$5](xdata)") r1s.add(")\n") else: - (sn, wid, num, ahl, all) = sci.split("|") + (sn, wid, num, ahl, all) = sci.split(RecSep) var resl: string if ahl.contains("): "): resl = all.rsplit("): ", 1)[1] diff --git a/tests/gen.nim b/tests/gen.nim index 9c9be25..177087c 100644 --- a/tests/gen.nim +++ b/tests/gen.nim @@ -1,5 +1,5 @@ # High level gobject-introspection based GTK3 bindings for the Nim programming language -# v 0.2 2017-SEP-18 +# v 0.2 2017-SEP-19 # (c) S. Salewski 2017 # https://wiki.gnome.org/Projects/GObjectIntrospection @@ -49,6 +49,7 @@ template isFunctionInfo(info: untyped): untyped = (gBaseInfoGetType(cast[GIBaseInfo](info)) == GIInfoType.Function) const EM = "*" +const RecSep = "!" # Record separator for entries in gisup.nim, also defined in gimpl.nim # hope that will work reliable proc cut(s: var StringStream; pos: int) = @@ -846,16 +847,16 @@ proc writeInterface(info: GIInterfaceInfo) = if gCallableInfoGetNArgs(signalInfo) > 0 or gTypeInfoGetTag(zzzu) != GITypeTag.VOID: var memo = "" memo.add(gCallableInfoGetNArgs(signalInfo)) - memo.add('|') + memo.add(RecSep) var plist, arglist: string var replist: TableRef[string, string] (plist, arglist, replist) = genP(signalInfo, true, info) memo.add(plist) - memo.add('|') + memo.add(RecSep) (plist, arglist, replist) = genP(signalInfo, false, info) memo.add(plist) - memo = memo.replace("\n ", "") - supmod.writeLine(" \"" & ($gBaseInfoGetName(signalInfo)).replace("-", "_") & "|" & $gBaseInfoGetName(info) & "|" & memo & "\",") + memo = memo.replace("\n ", "") + supmod.writeLine(" \"" & ($gBaseInfoGetName(signalInfo)).replace("-", "_") & RecSep & $gBaseInfoGetName(info) & RecSep & memo & "\",") if gCallableInfoGetNArgs(signalInfo) > 0: var plist, arglist: string var replist: TableRef[string, string] @@ -1110,16 +1111,16 @@ proc writeObj(info: GIObjectInfo) = if gCallableInfoGetNArgs(signalInfo) > 0 or gTypeInfoGetTag(zzzu) != GITypeTag.VOID: var memo = "" memo.add(gCallableInfoGetNArgs(signalInfo)) - memo.add('|') + memo.add(RecSep) var plist, arglist: string var replist: TableRef[string, string] (plist, arglist, replist) = genP(signalInfo, true, info) memo.add(plist) - memo.add('|') + memo.add(RecSep) (plist, arglist, replist) = genP(signalInfo, false, info) memo.add(plist) - memo = memo.replace("\n ", "") - supmod.writeLine(" \"" & ($gBaseInfoGetName(signalInfo)).replace("-", "_") & "|" & $gBaseInfoGetName(info) & "|" & memo & "\",") + memo = memo.replace("\n ", "") + supmod.writeLine(" \"" & ($gBaseInfoGetName(signalInfo)).replace("-", "_") & RecSep & $gBaseInfoGetName(info) & RecSep & memo & "\",") if gCallableInfoGetNArgs(signalInfo) > 0: var plist, arglist: string var replist: TableRef[string, string]