comparison Resources/CodeGeneration/stonegentool.py @ 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 75664eeacae5
children 84af39146e76
comparison
equal deleted inserted replaced
587:848170ca4351 601:8432926e9db9
74 return JsonHelpers.loadJsonWithComments(filePath) 74 return JsonHelpers.loadJsonWithComments(filePath)
75 75
76 def CanonToCpp(canonicalTypename): 76 def CanonToCpp(canonicalTypename):
77 # C++: prefix map vector and string with std::map, std::vector and 77 # C++: prefix map vector and string with std::map, std::vector and
78 # std::string 78 # std::string
79 # replace int32 by int32_t 79 # replace int32... by int32_t...
80 # replace float32 by float 80 # replace float32 by float
81 # replace float64 by double 81 # replace float64 by double
82 retVal = canonicalTypename 82 retVal = canonicalTypename
83 retVal = retVal.replace("map", "std::map") 83 retVal = retVal.replace("map", "std::map")
84 retVal = retVal.replace("vector", "std::vector") 84 retVal = retVal.replace("vector", "std::vector")
85 retVal = retVal.replace("set", "std::set") 85 retVal = retVal.replace("set", "std::set")
86 retVal = retVal.replace("string", "std::string") 86 retVal = retVal.replace("string", "std::string")
87 #uint32 and uint64 are handled by int32 and uint32 (because search and replace are done as partial words)
87 retVal = retVal.replace("int32", "int32_t") 88 retVal = retVal.replace("int32", "int32_t")
89 retVal = retVal.replace("int64", "int64_t")
88 retVal = retVal.replace("float32", "float") 90 retVal = retVal.replace("float32", "float")
89 retVal = retVal.replace("float64", "double") 91 retVal = retVal.replace("float64", "double")
90 retVal = retVal.replace("json", "Json::Value") 92 retVal = retVal.replace("json", "Json::Value")
91 return retVal 93 return retVal
92 94
93 def CanonToTs(canonicalTypename): 95 def CanonToTs(canonicalTypename):
94 # TS: replace vector with Array and map with Map 96 # TS: replace vector with Array and map with Map
95 # string remains string 97 # string remains string
96 # replace int32 by number 98 # replace int32... by number
97 # replace float32 by number 99 # replace float32... by number
98 # replace float64 by number
99 retVal = canonicalTypename 100 retVal = canonicalTypename
100 retVal = retVal.replace("map", "Map") 101 retVal = retVal.replace("map", "Map")
101 retVal = retVal.replace("vector", "Array") 102 retVal = retVal.replace("vector", "Array")
102 retVal = retVal.replace("set", "Set") 103 retVal = retVal.replace("set", "Set")
104 retVal = retVal.replace("uint32", "number")
105 retVal = retVal.replace("uint64", "number")
103 retVal = retVal.replace("int32", "number") 106 retVal = retVal.replace("int32", "number")
107 retVal = retVal.replace("int64", "number")
104 retVal = retVal.replace("float32", "number") 108 retVal = retVal.replace("float32", "number")
105 retVal = retVal.replace("float64", "number") 109 retVal = retVal.replace("float64", "number")
106 retVal = retVal.replace("bool", "boolean") 110 retVal = retVal.replace("bool", "boolean")
107 retVal = retVal.replace("json", "Object") 111 retVal = retVal.replace("json", "Object")
108 return retVal 112 return retVal