changeset 601:8432926e9db9 am-dev

codegen tools: support for int64, uint32, uint64
author Alain Mazy <alain@mazy.be>
date Mon, 29 Apr 2019 12:01:55 +0200
parents 848170ca4351
children 7a7e36c52d62 fd9b9d993fc7
files Resources/CodeGeneration/stonegentool.py Resources/CodeGeneration/template.in.h.j2
diffstat 2 files changed, 41 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CodeGeneration/stonegentool.py	Tue Apr 23 10:15:54 2019 +0200
+++ b/Resources/CodeGeneration/stonegentool.py	Mon Apr 29 12:01:55 2019 +0200
@@ -76,7 +76,7 @@
 def CanonToCpp(canonicalTypename):
   # C++: prefix map vector and string with std::map, std::vector and
   # std::string
-  # replace int32 by int32_t
+  # replace int32... by int32_t...
   # replace float32 by float
   # replace float64 by double
   retVal = canonicalTypename
@@ -84,7 +84,9 @@
   retVal = retVal.replace("vector", "std::vector")
   retVal = retVal.replace("set", "std::set")
   retVal = retVal.replace("string", "std::string")
+  #uint32 and uint64 are handled by int32 and uint32 (because search and replace are done as partial words)
   retVal = retVal.replace("int32", "int32_t")
+  retVal = retVal.replace("int64", "int64_t")
   retVal = retVal.replace("float32", "float")
   retVal = retVal.replace("float64", "double")
   retVal = retVal.replace("json", "Json::Value")
@@ -93,14 +95,16 @@
 def CanonToTs(canonicalTypename):
   # TS: replace vector with Array and map with Map
   # string remains string
-  # replace int32 by number
-  # replace float32 by number
-  # replace float64 by number
+  # replace int32... by number
+  # replace float32... by number
   retVal = canonicalTypename
   retVal = retVal.replace("map", "Map")
   retVal = retVal.replace("vector", "Array")
   retVal = retVal.replace("set", "Set")
+  retVal = retVal.replace("uint32", "number")
+  retVal = retVal.replace("uint64", "number")
   retVal = retVal.replace("int32", "number")
+  retVal = retVal.replace("int64", "number")
   retVal = retVal.replace("float32", "number")
   retVal = retVal.replace("float64", "number")
   retVal = retVal.replace("bool", "boolean")
--- a/Resources/CodeGeneration/template.in.h.j2	Tue Apr 23 10:15:54 2019 +0200
+++ b/Resources/CodeGeneration/template.in.h.j2	Mon Apr 29 12:01:55 2019 +0200
@@ -38,6 +38,39 @@
     return result;
   }
 
+  inline void _StoneDeserializeValue(int64_t& destValue, const Json::Value& jsonValue)
+  {
+    destValue = jsonValue.asInt64();
+  }
+
+  inline Json::Value _StoneSerializeValue(int64_t value)
+  {
+    Json::Value result(value);
+    return result;
+  }
+
+  inline void _StoneDeserializeValue(uint32_t& destValue, const Json::Value& jsonValue)
+  {
+    destValue = jsonValue.asUInt();
+  }
+
+  inline Json::Value _StoneSerializeValue(uint32_t value)
+  {
+    Json::Value result(value);
+    return result;
+  }
+
+  inline void _StoneDeserializeValue(uint64_t& destValue, const Json::Value& jsonValue)
+  {
+    destValue = jsonValue.asUInt64();
+  }
+
+  inline Json::Value _StoneSerializeValue(uint64_t value)
+  {
+    Json::Value result(value);
+    return result;
+  }
+
   inline void _StoneDeserializeValue(Json::Value& destValue, const Json::Value& jsonValue)
   {
     destValue = jsonValue;