Mercurial > hg > orthanc-stone
view Resources/CodeGeneration/Graveyard/playground2.ts @ 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 | 6405435480ae |
children |
line wrap: on
line source
class Greeter { greeting: string; constructor(message: string) { this.greeting = message; } greet() { return "Hello, " + this.greeting; } } enum Color { Red, Green, Blue, }; function ColorToString(value: Color) { switch (value) { case Color.Red: return "Red"; case Color.Green: return "Green"; case Color.Blue: return "Blue"; default: throw new Error(`Unrecognized Color value(${value})`); } } let color: Color = Color.Red; document.body.textContent = "<p>---------------------</p>" document.body.textContent += "<p>********************************</p>" class TestMessage { s1: string; s2: Array<string>; s3: Array<Array<string>>; s4: Map<string, number>; s5: Map<number, Array<string>>; s6: Color; s7: boolean; } let tm = new TestMessage(); tm.s2 = new Array<string>() tm.s2.push("toto"); tm.s2.push("toto2"); tm.s2.push("toto3"); tm.s4 = new Map<string, number>(); tm.s4["toto"] = 42; tm.s4["toto"] = 1999; tm.s4["tatata"] = 1999; tm.s6 = Color.Red; tm.s7 = true let txt = JSON.stringify(tm) let txtElem = document.createElement('textarea'); txtElem.value = txt; document.body.appendChild(txtElem); let greeter = new Greeter("world"); let button = document.createElement('button'); button.textContent = "Say Hello"; button.onclick = function() { alert(greeter.greet()); } document.body.appendChild(button);