# HG changeset patch # User bgo-osimis # Date 1551072921 -3600 # Node ID 329f229c27946a5ba04c7b922576d7dd7b5980ed # Parent baa9e1e932db345cd84ed62415f71a9782c46f34 Improvements to the integrated demo for TS <--> C++ diff -r baa9e1e932db -r 329f229c2794 Resources/CodeGeneration/testWasmIntegrated/build-web.sh --- a/Resources/CodeGeneration/testWasmIntegrated/build-web.sh Sun Feb 24 20:22:56 2019 +0100 +++ b/Resources/CodeGeneration/testWasmIntegrated/build-web.sh Mon Feb 25 06:35:21 2019 +0100 @@ -22,5 +22,8 @@ # copy WASM binary to output dir cp build-wasm/testWasmIntegratedCpp.wasm build-final/ +echo "...Serving files at http://127.0.0.1:8080/" +echo "Please open build_final/testWasmIntegrated.html" + sudo python3 serve.py diff -r baa9e1e932db -r 329f229c2794 Resources/CodeGeneration/testWasmIntegrated/main.cpp --- a/Resources/CodeGeneration/testWasmIntegrated/main.cpp Sun Feb 24 20:22:56 2019 +0100 +++ b/Resources/CodeGeneration/testWasmIntegrated/main.cpp Mon Feb 25 06:35:21 2019 +0100 @@ -15,7 +15,7 @@ #define HANDLE_MESSAGE(Type,value) \ stringstream ss; \ - ss << "Received an instance of" #Type ". Here's the dump:\n"; \ + ss << "Received an instance of:\n" #Type "\n. Here's the dump:\n"; \ testWasmIntegratedCpp::StoneDumpValue(ss, value, 0); \ SendFreeTextFromCppJS(ss.str().c_str()); \ return true; diff -r baa9e1e932db -r 329f229c2794 Resources/CodeGeneration/testWasmIntegrated/styles.css --- a/Resources/CodeGeneration/testWasmIntegrated/styles.css Sun Feb 24 20:22:56 2019 +0100 +++ b/Resources/CodeGeneration/testWasmIntegrated/styles.css Mon Feb 25 06:35:21 2019 +0100 @@ -3,8 +3,8 @@ grid-template-columns: 0.55fr 0.55fr 0.55fr 0.55fr 0.6fr 1.1fr 1.1fr; grid-template-rows: 1.1fr 0.9fr 0.2fr 0.3fr 0.1fr 0.3fr 0.1fr; grid-template-areas: - "SerializedInput SerializedInput SerializedInput SerializedInput Trigger CppOutput CppOutput" - "SerializedInput SerializedInput SerializedInput SerializedInput Trigger CppOutput CppOutput" + "SerializedInput SerializedInput SerializedInput SerializedInput ButtonContainer CppOutput CppOutput" + "SerializedInput SerializedInput SerializedInput SerializedInput ButtonContainer CppOutput CppOutput" ". . . . . . ." "Test1 Test2 Test3 Test4 . . ." ". . . . . . ." @@ -15,15 +15,33 @@ height: 480px; } + .TestWasm-ButtonContainer { + display: grid; + grid-template-columns: 0.2fr 0.8fr 0.2fr; + grid-template-rows: 0.2fr 0.5fr 0.2fr 0.5fr 0.2fr 0.5fr 0.2fr; + grid-template-areas: + ". . ." + ". TriggerButton ." + ". . ." + ". ClearButton ." + ". . ." + ". ShowSchemaButton ." + ". . ." + ; + } + + .TestWasm-TriggerButton { grid-area: TriggerButton; } + + .TestWasm-ClearButton { grid-area: ClearButton; } + + .TestWasm-ShowSchemaButton { grid-area: ShowSchemaButton; } + + .TestWasm-SerializedInput { grid-area: SerializedInput; } .TestWasm-CppOutput { grid-area: CppOutput; } -.TestWasm-Trigger { - grid-area: Trigger; - align-items: center; - text-align: center; -} +.TestWasm-ButtonContainer { grid-area: ButtonContainer; } .TestWasm-Test1 { grid-area: Test1; } diff -r baa9e1e932db -r 329f229c2794 Resources/CodeGeneration/testWasmIntegrated/testWasmIntegrated.html --- a/Resources/CodeGeneration/testWasmIntegrated/testWasmIntegrated.html Sun Feb 24 20:22:56 2019 +0100 +++ b/Resources/CodeGeneration/testWasmIntegrated/testWasmIntegrated.html Mon Feb 25 06:35:21 2019 +0100 @@ -13,15 +13,23 @@ -->
- - -
- + + +
+
+ +
+
+ +
+
+ +
+
+
diff -r baa9e1e932db -r 329f229c2794 Resources/CodeGeneration/testWasmIntegrated/testWasmIntegrated.ts --- a/Resources/CodeGeneration/testWasmIntegrated/testWasmIntegrated.ts Sun Feb 24 20:22:56 2019 +0100 +++ b/Resources/CodeGeneration/testWasmIntegrated/testWasmIntegrated.ts Mon Feb 25 06:35:21 2019 +0100 @@ -48,6 +48,53 @@ | define stock messages | +--------------------------------------------------+ */ +let schemaText: string = `rootName: testWasmIntegratedCpp + +struct B: + someAs: vector + someInts: vector + +struct C: + someBs: vector + ddd: vector + +struct A: + someStrings: vector + someInts2: vector + movies: vector + +struct Message1: + a: int32 + b: string + c: EnumMonth0 + d: bool + +struct Message2: + toto: string + tata: vector + tutu: vector + titi: map + lulu: map + movieType: MovieType + +enum MovieType: + - RomCom + - Horror + - ScienceFiction + - Vegetables + +enum CrispType: + - SaltAndPepper + - CreamAndChives + - Paprika + - Barbecue + +enum EnumMonth0: + - January + - February + - March +`; + let stockSerializedMessages = new Map(); stockSerializedMessages["Test 1"] = `{ "type" : "testWasmIntegratedCpp.Message2", @@ -98,7 +145,15 @@ ] } }`; -stockSerializedMessages["Test 2"] = "Test 2 stock message bccbbbbbb"; +stockSerializedMessages["Test 2"] = ` { + "type" : "testWasmIntegratedCpp.Message1", + "value" : { + "a" : -987, + "b" : "Salomé", + "c" : 2, + "d" : true + } +}`; stockSerializedMessages["Test 3"] = "Test 3 stock message sdfsfsdfsdf"; stockSerializedMessages["Test 4"] = "Test 4 stock message 355345345"; stockSerializedMessages["Test 5"] = "Test 5 stock message 34535"; @@ -134,7 +189,7 @@ function SendFreeTextFromCpp(txt: string):string { - setCppOutputValue(getCppOutputValue() + txt); + setCppOutputValue(getCppOutputValue() + "\n" + txt); return ""; } ( window).SendFreeTextFromCpp = SendFreeTextFromCpp; @@ -151,6 +206,18 @@ let SendMessageToCppLocal = ( window).Module.cwrap('SendMessageToCpp', 'string', ['string']); SendMessageToCppLocal(serializedInputValue); } + else if(buttonName == 'Clear') + { + setCppOutputValue(""); + } + else if(buttonName == 'ShowSchema') + { + setCppOutputValue(schemaText); + } + else + { + throw new Error("Internal error!"); + } }