comparison Resources/CodeGeneration/template.in.h @ 508:7105a0bad250 bgo-commands-codegen

- Added HandleSerializedMessage to IStoneApplication (empty impl) - Split UpdateWebApplication with "WithString" and "WithSerializedMessage" variants - Due to the modules in TS, globals are now unallowed and the callbacks from C++ to JS are stored in the "window" instance - Split UpdateStoneApplicationStatusFromCpp with "WithString" and "WithSerializedMessage" variants - Split NotifyStatusUpdateFromCppToWeb with "WithString" and "WithSerializedMessage" variants - SendMessageToStoneApplication (C++ global) has been split into SendSerializedMessageToStoneApplication and SendCommandToStoneApplication - In WasmPlatformApplicationAdapter: HandleMessageFromWeb becomes HandleCommandFromWeb - In WasmPlatformApplicationAdapter: added HandleSerializedMessageFromWeb - stonegentool now handles the "json" primitive type (used, a.o., in the VSOL "EditInstance" message) - Fixed indentation and added json serialization overloads in the stonegentool templates - Added test of the json primitive type to testWasmIntegrated (in Resources/CodeGeneration) - Adapted testWasmIntegrated (in Resources/CodeGeneration) to the changes above
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 06 Mar 2019 10:14:59 +0100
parents ce49eae4c887
children 72faa732532b dea3787a8f4b
comparison
equal deleted inserted replaced
507:ce49eae4c887 508:7105a0bad250
36 { 36 {
37 Json::Value result(value); 37 Json::Value result(value);
38 return result; 38 return result;
39 } 39 }
40 40
41 inline void _StoneDeserializeValue(Json::Value& destValue, const Json::Value& jsonValue)
42 {
43 destValue = jsonValue;
44 }
45
46 inline Json::Value _StoneSerializeValue(Json::Value value)
47 {
48 return value;
49 }
50
41 /** Throws in case of problem */ 51 /** Throws in case of problem */
42 inline void _StoneDeserializeValue(double& destValue, const Json::Value& jsonValue) 52 inline void _StoneDeserializeValue(double& destValue, const Json::Value& jsonValue)
43 { 53 {
44 destValue = jsonValue.asDouble(); 54 destValue = jsonValue.asDouble();
45 } 55 }
238 { 248 {
239 {% for key in enum['fields']%} if( value == {{enum['name']}}_{{key}}) 249 {% for key in enum['fields']%} if( value == {{enum['name']}}_{{key}})
240 { 250 {
241 return std::string("{{key}}"); 251 return std::string("{{key}}");
242 } 252 }
243 {%endfor%}; 253 {%endfor%} std::stringstream ss;
254 ss << "Value \"" << value << "\" cannot be converted to {{enum['name']}}. Possible values are: "
255 {% for key in enum['fields']%} << " {{key}} = " << static_cast<int64_t>({{enum['name']}}_{{key}}) << ", "
256 {% endfor %} << std::endl;
257 std::string msg = ss.str();
258 throw std::runtime_error(msg);
244 } 259 }
245 260
246 inline void FromString({{enum['name']}}& value, std::string strValue) 261 inline void FromString({{enum['name']}}& value, std::string strValue)
247 { 262 {
248 {% for key in enum['fields']%} if( strValue == std::string("{{key}}") ) 263 {% for key in enum['fields']%} if( strValue == std::string("{{key}}") )