comparison Resources/CodeGeneration/testWasmIntegrated/main.cpp @ 688:8c0b073efda8 am-dev

Codegen: fix
author Alain Mazy <alain@mazy.be>
date Thu, 16 May 2019 17:54:22 +0200
parents 7105a0bad250
children f185cfcb72a0
comparison
equal deleted inserted replaced
687:342f3e04bfa9 688:8c0b073efda8
1 #include <iostream> 1 #include <iostream>
2 #include <sstream> 2 #include <sstream>
3 #include <emscripten/emscripten.h> 3 #include <emscripten/emscripten.h>
4 #include "testWasmIntegratedCpp_generated.hpp" 4 #include "TestStoneCodeGen_generated.hpp"
5 5
6 using std::stringstream; 6 using std::stringstream;
7 7
8 int main() 8 int main()
9 { 9 {
53 extern "C" void SendFreeTextFromCppJS(const char* message); 53 extern "C" void SendFreeTextFromCppJS(const char* message);
54 54
55 #define HANDLE_MESSAGE(Type,value) \ 55 #define HANDLE_MESSAGE(Type,value) \
56 stringstream ss; \ 56 stringstream ss; \
57 ss << "Received an instance of:\n" #Type "\n. Here's the dump:\n"; \ 57 ss << "Received an instance of:\n" #Type "\n. Here's the dump:\n"; \
58 testWasmIntegratedCpp::StoneDumpValue(ss, value, 0); \ 58 TestStoneCodeGen::StoneDumpValue(ss, value, 0); \
59 SendFreeTextFromCppJS(ss.str().c_str()); \ 59 SendFreeTextFromCppJS(ss.str().c_str()); \
60 return true; 60 return true;
61 61
62 class MyHandler : public testWasmIntegratedCpp::IHandler 62 class MyHandler : public TestStoneCodeGen::IHandler
63 { 63 {
64 public: 64 public:
65 virtual bool Handle(const testWasmIntegratedCpp::A& value) override 65 virtual bool Handle(const TestStoneCodeGen::A& value) override
66 { 66 {
67 HANDLE_MESSAGE(testWasmIntegratedCpp::A,value) 67 HANDLE_MESSAGE(TestStoneCodeGen::A,value)
68 } 68 }
69 virtual bool Handle(const testWasmIntegratedCpp::B& value) override 69 virtual bool Handle(const TestStoneCodeGen::B& value) override
70 { 70 {
71 HANDLE_MESSAGE(testWasmIntegratedCpp::B,value) 71 HANDLE_MESSAGE(TestStoneCodeGen::B,value)
72 } 72 }
73 73
74 virtual bool Handle(const testWasmIntegratedCpp::Message1& value) override 74 virtual bool Handle(const TestStoneCodeGen::Message1& value) override
75 { 75 {
76 HANDLE_MESSAGE(testWasmIntegratedCpp::Message1,value) 76 HANDLE_MESSAGE(TestStoneCodeGen::Message1,value)
77 } 77 }
78 78
79 virtual bool Handle(const testWasmIntegratedCpp::Message2& value) override 79 virtual bool Handle(const TestStoneCodeGen::Message2& value) override
80 { 80 {
81 HANDLE_MESSAGE(testWasmIntegratedCpp::Message2,value) 81 HANDLE_MESSAGE(TestStoneCodeGen::Message2,value)
82 } 82 }
83 83
84 virtual bool Handle(const testWasmIntegratedCpp::C& value) override 84 virtual bool Handle(const TestStoneCodeGen::C& value) override
85 { 85 {
86 HANDLE_MESSAGE(testWasmIntegratedCpp::C,value) 86 HANDLE_MESSAGE(TestStoneCodeGen::C,value)
87 } 87 }
88 }; 88 };
89 89
90 extern "C" void EMSCRIPTEN_KEEPALIVE SendMessageToCpp(const char* message) 90 extern "C" void EMSCRIPTEN_KEEPALIVE SendMessageToCpp(const char* message)
91 { 91 {
92 MyHandler handler; 92 MyHandler handler;
93 try 93 try
94 { 94 {
95 bool handled = testWasmIntegratedCpp::StoneDispatchToHandler(message,&handler); 95 bool handled = TestStoneCodeGen::StoneDispatchToHandler(message,&handler);
96 if(!handled) 96 if(!handled)
97 { 97 {
98 SendFreeTextFromCppJS("This message is valid JSON, but was not recognized!"); 98 SendFreeTextFromCppJS("This message is valid JSON, but was not handled!");
99 } 99 }
100 } 100 }
101 catch(std::exception& e) 101 catch(std::exception& e)
102 { 102 {
103 stringstream ss; 103 stringstream ss;