From de62dc27fc00a9b91b4f82ecbaafc5e929da75bb Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Sat, 16 Aug 2014 19:50:08 +0100 Subject: [PATCH] Fixes for recent compiler changes. --- src/babelpkg/compat.nim | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/babelpkg/compat.nim b/src/babelpkg/compat.nim index dbc4c43..307c24f 100644 --- a/src/babelpkg/compat.nim +++ b/src/babelpkg/compat.nim @@ -8,21 +8,22 @@ import json -when not defined(`{}`): - proc `{}`*(node: PJsonNode, key: string): PJsonNode = - ## Transverses the node and gets the given value. If any of the - ## names does not exist, returns nil - result = node - if isNil(node): return nil - result = result[key] +when NimrodPatch <= 4 and NimrodMinor == 9: + when not defined(`{}`): + proc `{}`*(node: PJsonNode, key: string): PJsonNode = + ## Transverses the node and gets the given value. If any of the + ## names does not exist, returns nil + result = node + if isNil(node): return nil + result = result[key] -when not defined(`{}=`): - proc `{}=`*(node: PJsonNode, names: varargs[string], value: PJsonNode) = - ## Transverses the node and tries to set the value at the given location - ## to `value` If any of the names are missing, they are added - var node = node - for i in 0..(names.len-2): - if isNil(node[names[i]]): - node[names[i]] = newJObject() - node = node[names[i]] - node[names[names.len-1]] = value + when not defined(`{}=`): + proc `{}=`*(node: PJsonNode, names: varargs[string], value: PJsonNode) = + ## Transverses the node and tries to set the value at the given location + ## to `value` If any of the names are missing, they are added + var node = node + for i in 0..(names.len-2): + if isNil(node[names[i]]): + node[names[i]] = newJObject() + node = node[names[i]] + node[names[names.len-1]] = value