comparison Resources/CodeGeneration/testWasmIntegrated/main.cpp @ 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 329f229c2794
children 8c0b073efda8
comparison
equal deleted inserted replaced
507:ce49eae4c887 508:7105a0bad250
6 using std::stringstream; 6 using std::stringstream;
7 7
8 int main() 8 int main()
9 { 9 {
10 std::cout << "Hello world from testWasmIntegrated! (this is sent from C++)" << std::endl; 10 std::cout << "Hello world from testWasmIntegrated! (this is sent from C++)" << std::endl;
11 try
12 {
13 const char* jsonData = R"bgo({"definition":
14 {
15 "val" : [ "berk", 42 ],
16 "zozo" : { "23": "zloutch", "lalala": 42}
17 }
18 })bgo";
19 std::string strValue(jsonData);
20
21 Json::Value readValue;
22
23 Json::CharReaderBuilder builder;
24 Json::CharReader* reader = builder.newCharReader();
25
26 StoneSmartPtr<Json::CharReader> ptr(reader);
27
28 std::string errors;
29
30 bool ok = reader->parse(
31 strValue.c_str(),
32 strValue.c_str() + strValue.size(),
33 &readValue,
34 &errors
35 );
36 if (!ok)
37 {
38 std::stringstream ss;
39 ss << "Jsoncpp parsing error: " << errors;
40 throw std::runtime_error(ss.str());
41 }
42 std::cout << "Json parsing OK" << std::endl;
43 std::cout << readValue << std::endl;
44 }
45 catch(std::exception& e)
46 {
47 std::cout << "Json parsing THROW" << std::endl;
48 std::cout << "e.what() = " << e.what() << std::endl;
49 }
11 } 50 }
12 51
13 extern "C" void SendMessageFromCppJS(const char* message); 52 extern "C" void SendMessageFromCppJS(const char* message);
14 extern "C" void SendFreeTextFromCppJS(const char* message); 53 extern "C" void SendFreeTextFromCppJS(const char* message);
15 54